Blender V2.61 - r43446
|
#include <string.h>
#include "GL/glew.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_smoke_types.h"
#include "DNA_view3d_types.h"
#include "MEM_guardedalloc.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "BKE_bmfont.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_DerivedMesh.h"
#include "BLI_threads.h"
#include "BLI_blenlib.h"
#include "GPU_buffers.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_material.h"
#include "smoke_API.h"
Go to the source code of this file.
Classes | |
struct | GPUTextureState |
struct | GPUMaterialFixed |
struct | GPUMaterialState |
Defines | |
#define | FIXEDMAT 8 |
Typedefs | |
typedef struct GPUMaterialFixed | GPUMaterialFixed |
Functions | |
static void | gpu_mcol (unsigned int ucol) |
void | GPU_render_text (MTFace *tface, int mode, const char *textstr, int textlen, unsigned int *col, float *v1, float *v2, float *v3, float *v4, int glattrib) |
static int | is_pow2_limit (int num) |
static int | smaller_pow2_limit (int num) |
void | GPU_set_mipmap (int mipmap) |
void | GPU_set_linear_mipmap (int linear) |
static int | gpu_get_mipmap (void) |
static GLenum | gpu_get_mipmap_filter (int mag) |
void | GPU_set_anisotropic (float value) |
float | GPU_get_anisotropic (void) |
static void | gpu_make_repbind (Image *ima) |
static void | gpu_clear_tpage (void) |
static void | gpu_set_alpha_blend (GPUBlendMode alphablend) |
static void | gpu_verify_alpha_blend (int alphablend) |
static void | gpu_verify_reflection (Image *ima) |
int | GPU_verify_image (Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap) |
static void | gpu_verify_repeat (Image *ima) |
int | GPU_set_tpage (MTFace *tface, int mipmap, int alphablend) |
void | GPU_paint_set_mipmap (int mipmap) |
void | GPU_paint_update_image (Image *ima, int x, int y, int w, int h, int mipmap) |
void | GPU_update_images_framechange (void) |
int | GPU_update_image_time (Image *ima, double time) |
void | GPU_free_smoke (SmokeModifierData *smd) |
void | GPU_create_smoke (SmokeModifierData *smd, int highres) |
static void | gpu_queue_image_for_free (Image *ima) |
void | GPU_free_unused_buffers (void) |
void | GPU_free_image (Image *ima) |
void | GPU_free_images (void) |
void | GPU_free_images_anim (void) |
static void | gpu_material_to_fixed (GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob, const int new_shading_nodes) |
static Material * | gpu_active_node_material (Material *ma) |
void | GPU_begin_object_materials (View3D *v3d, RegionView3D *rv3d, Scene *scene, Object *ob, int glsl, int *do_alpha_after) |
int | GPU_enable_material (int nr, void *attribs) |
void | GPU_set_material_alpha_blend (int alphablend) |
int | GPU_get_material_alpha_blend (void) |
void | GPU_disable_material (void) |
void | GPU_end_object_materials (void) |
int | GPU_default_lights (void) |
int | GPU_scene_object_lights (Scene *scene, Object *ob, int lay, float viewmat[][4], int ortho) |
void | GPU_state_init (void) |
static void | gpu_get_print (const char *name, GLenum type) |
void | GPU_state_print (void) |
Variables | |
Material | defmaterial |
static struct GPUTextureState | GTS |
static ListBase | image_free_queue = {NULL, NULL} |
static struct GPUMaterialState | GMS |
Definition in file gpu_draw.c.
#define FIXEDMAT 8 |
Definition at line 906 of file gpu_draw.c.
Referenced by GPU_begin_object_materials().
typedef struct GPUMaterialFixed GPUMaterialFixed |
Definition at line 969 of file gpu_draw.c.
References bNode::id, ID_MA, nodeGetActiveID(), Material::nodetree, NULL, and Material::use_nodes.
Referenced by GPU_begin_object_materials().
void GPU_begin_object_materials | ( | View3D * | v3d, |
RegionView3D * | rv3d, | ||
Scene * | scene, | ||
Object * | ob, | ||
int | glsl, | ||
int * | do_alpha_after | ||
) |
Definition at line 983 of file gpu_draw.c.
References Material::alpha, GPUMaterialState::alphablend, GPUMaterialState::alphablend_fixed, Object::col, RenderData::color_mgt_flag, defmaterial, GPUMaterialFixed::diff, ELEM3, FIXEDMAT, give_current_material(), GPUMaterialState::glay, GPUMaterialState::gmatbuf, GPUMaterialState::gmatbuf_fixed, GMS, GPUMaterialState::gob, gpu_active_node_material(), GPU_BLEND_ADD, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT, GPU_BLEND_SOLID, GPU_disable_material(), GPU_material_alpha_blend(), GPU_material_from_blender(), gpu_material_to_fixed(), GPUMaterialState::gscene, GPUMaterialState::gviewinv, GPUMaterialState::gviewmat, GPUMaterialState::is_alpha_pass, GPUMaterialState::lastalphablend, GPUMaterialState::lastmatnr, GPUMaterialState::lastretval, View3D::lay, GPUMaterialState::matbuf, GPUMaterialState::matbuf_fixed, MEM_callocN(), NULL, Scene::r, R_COLOR_MANAGEMENT, scene_use_new_shading_nodes(), Object::totcol, GPUMaterialState::totmat, View3D::transp, GPUMaterialState::use_alpha_pass, RegionView3D::viewinv, and RegionView3D::viewmat.
Referenced by draw_mesh_object(), draw_mesh_textured(), draw_object_mesh_instance(), drawCurveDerivedMesh(), and drawDispList().
static void gpu_clear_tpage | ( | void | ) | [static] |
Definition at line 321 of file gpu_draw.c.
References GPUTextureState::alphablend, GPUTextureState::curima, GPUTextureState::curtile, GPUTextureState::curtilemode, GPUTextureState::curtileXRep, GPUTextureState::curtileYRep, GTS, GPUTextureState::lasttface, and NULL.
Referenced by GPU_set_tpage().
void GPU_create_smoke | ( | SmokeModifierData * | smd, |
int | highres | ||
) |
Definition at line 805 of file gpu_draw.c.
References SmokeModifierData::domain, SmokeDomainSettings::fluid, GPU_texture_create_3D(), MOD_SMOKE_TYPE_DOMAIN, NULL, SmokeDomainSettings::res, SmokeDomainSettings::res_wt, SmokeDomainSettings::shadow, smoke_get_density(), smoke_turbulence_get_density(), SmokeDomainSettings::tex, SmokeDomainSettings::tex_shadow, SmokeModifierData::type, and SmokeDomainSettings::wt.
Referenced by draw_object().
int GPU_default_lights | ( | void | ) |
Definition at line 1229 of file gpu_draw.c.
References SolidLight::col, SolidLight::flag, UserDef::light, normalize_v3_v3(), SolidLight::spec, U, and SolidLight::vec.
Referenced by draw_textured_end(), GPU_state_init(), view3d_main_area_draw_objects(), and WM_read_homefile().
void GPU_disable_material | ( | void | ) |
Definition at line 1190 of file gpu_draw.c.
References GPUMaterialState::gboundmat, GMS, GPU_BLEND_SOLID, GPU_material_from_blender(), GPU_material_unbind(), GPU_set_material_alpha_blend(), GPUMaterialState::gscene, GPUMaterialState::is_alpha_pass, GPUMaterialState::lastmatnr, GPUMaterialState::lastretval, and NULL.
Referenced by draw_em_fancy(), draw_mesh_fancy(), draw_mesh_object_outline(), draw_object(), GPU_begin_object_materials(), GPU_end_object_materials(), and tex_mat_set_texture_cb().
int GPU_enable_material | ( | int | nr, |
void * | attribs | ||
) |
Definition at line 1083 of file gpu_draw.c.
References GameSettings::alpha_blend, GPUMaterialState::alphablend, DerivedMesh::auto_bump_scale, Object::col, Object::derivedFinal, GPUMaterialFixed::diff, KDL::diff(), ELEM, Material::emit, Material::game, GPUMaterialState::gboundmat, GPUMaterialState::glay, GPUMaterialState::gmatbuf, GMS, GPUMaterialState::gob, GPU_BLEND_CLIP, GPU_BLEND_SOLID, GPU_material_bind(), GPU_material_bind_uniforms(), GPU_material_from_blender(), GPU_material_unbind(), GPU_material_vertex_attributes(), GPU_set_material_alpha_blend(), GPUMaterialState::gscene, GPUMaterialState::gviewinv, GPUMaterialState::gviewmat, GPUMaterialFixed::hard, GPUMaterialState::is_alpha_pass, GPUMaterialState::lastmatnr, GPUMaterialState::lastretval, Object::lay, GPUMaterialState::matbuf, Object::mode, mul_v3_v3fl(), NULL, OB_MODE_TEXTURE_PAINT, Object::obmat, Material::r, Material::ref, GPUMaterialFixed::spec, Material::spec, spec(), Material::specr, GPUMaterialState::totmat, and GPUMaterialState::use_alpha_pass.
Referenced by bbs_mesh_solid(), bbs_mesh_solid_EM(), ccgDM_drawFacesTex_common(), draw_dm_faces_sel(), draw_em_fancy(), draw_em_fancy__setFaceOpts(), draw_mesh_fancy(), draw_mesh_object_outline(), draw_mesh_text(), draw_mesh_textured(), draw_mesh_textured_old(), draw_object(), draw_object_backbufsel(), draw_object_mesh_instance(), drawCurveDerivedMesh(), drawDispListsolid(), tex_mat_set_material_cb(), and tex_mat_set_texture_cb().
void GPU_end_object_materials | ( | void | ) |
Definition at line 1204 of file gpu_draw.c.
References GPUMaterialState::alphablend, GPUMaterialState::gmatbuf, GMS, GPU_disable_material(), GTS, GPUMaterialState::matbuf, GPUMaterialState::matbuf_fixed, MEM_freeN(), NULL, and GPUTextureState::tilemode.
Referenced by draw_mesh_fancy(), draw_mesh_object(), draw_mesh_textured(), draw_object_mesh_instance(), drawCurveDerivedMesh(), and drawDispList().
void GPU_free_image | ( | Image * | ima | ) |
Definition at line 854 of file gpu_draw.c.
References Image::bindcode, BLI_thread_is_main(), gpu_queue_image_for_free(), GPU_texture_free(), Image::gputexture, IMA_MIPMAP_COMPLETE, MEM_freeN(), NULL, Image::repbind, Image::totbind, and Image::tpageflag.
Referenced by finish_bake_internal(), free_old_images(), GPU_free_images(), GPU_free_images_anim(), GPU_free_unused_buffers(), GPU_paint_set_mipmap(), GPU_paint_update_image(), GPU_verify_image(), image_free_buffers(), image_undo_restore(), paint_redraw(), and texture_paint_camera_project_exec().
void GPU_free_images | ( | void | ) |
Definition at line 884 of file gpu_draw.c.
References G, GPU_free_image(), Image::id, and ID::next.
Referenced by GPU_set_anisotropic(), GPU_set_linear_mipmap(), GPU_set_mipmap(), and texture_paint_toggle_exec().
void GPU_free_images_anim | ( | void | ) |
Definition at line 894 of file gpu_draw.c.
References ELEM, G, GPU_free_image(), Image::id, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE, ID::next, and Image::source.
Referenced by ED_view3d_draw_offscreen().
void GPU_free_smoke | ( | SmokeModifierData * | smd | ) |
Definition at line 791 of file gpu_draw.c.
References SmokeModifierData::domain, GPU_texture_free(), MOD_SMOKE_TYPE_DOMAIN, NULL, SmokeDomainSettings::tex, SmokeDomainSettings::tex_shadow, and SmokeModifierData::type.
Referenced by draw_object().
void GPU_free_unused_buffers | ( | void | ) |
Definition at line 832 of file gpu_draw.c.
References BLI_freelistN(), BLI_lock_thread(), BLI_thread_is_main(), BLI_unlock_thread(), ListBase::first, GPU_free_image(), Image::id, LOCK_OPENGL, and ID::next.
Referenced by wm_draw_update(), and WM_exit_ext().
float GPU_get_anisotropic | ( | void | ) |
Definition at line 293 of file gpu_draw.c.
References GPUTextureState::anisotropic, and GTS.
Referenced by RAS_OpenGLRasterizer::GetAnisotropicFiltering(), GPU_verify_image(), and RAS_OpenGLRasterizer::RAS_OpenGLRasterizer().
int GPU_get_material_alpha_blend | ( | void | ) |
Definition at line 1185 of file gpu_draw.c.
References GMS, and GPUMaterialState::lastalphablend.
Referenced by RAS_OpenGLRasterizer::IndexPrimitivesInternal().
static int gpu_get_mipmap | ( | void | ) | [static] |
Definition at line 253 of file gpu_draw.c.
References GPUTextureState::domipmap, and GTS.
Referenced by GPU_paint_update_image(), and GPU_verify_image().
static GLenum gpu_get_mipmap_filter | ( | int | mag | ) | [static] |
Definition at line 258 of file gpu_draw.c.
References GPUTextureState::domipmap, GTS, and GPUTextureState::linearmipmap.
Referenced by GPU_paint_set_mipmap(), and GPU_verify_image().
static void gpu_get_print | ( | const char * | name, |
GLenum | type | ||
) | [static] |
Definition at line 1451 of file gpu_draw.c.
Referenced by GPU_state_print().
static void gpu_make_repbind | ( | Image * | ima | ) | [static] |
Definition at line 300 of file gpu_draw.c.
References BKE_image_get_ibuf(), IMA_MIPMAP_COMPLETE, MEM_callocN(), MEM_freeN(), NULL, Image::repbind, Image::totbind, Image::tpageflag, Image::xrep, and Image::yrep.
Referenced by GPU_verify_image().
static void gpu_material_to_fixed | ( | GPUMaterialFixed * | smat, |
const Material * | bmat, | ||
const int | gamma, | ||
const Object * | ob, | ||
const int | new_shading_nodes | ||
) | [static] |
Definition at line 939 of file gpu_draw.c.
References CLAMPIS, Object::col, copy_v3_v3(), GPUMaterialFixed::diff, Material::emit, Material::har, GPUMaterialFixed::hard, linearrgb_to_srgb_v3_v3(), MA_OBCOLOR, MA_SHLESS, Material::mode, mul_v3_v3(), mul_v3_v3fl(), Material::r, Material::ref, Material::shade_flag, Material::spec, GPUMaterialFixed::spec, Material::specr, and zero_v4().
Referenced by GPU_begin_object_materials().
static void gpu_mcol | ( | unsigned int | ucol | ) | [static] |
Definition at line 83 of file gpu_draw.c.
Referenced by GPU_render_text().
void GPU_paint_set_mipmap | ( | int | mipmap | ) |
Definition at line 642 of file gpu_draw.c.
References Image::bindcode, GPUTextureState::domipmap, G, GPU_free_image(), gpu_get_mipmap_filter(), GTS, Image::id, IMA_MIPMAP_COMPLETE, ID::next, and Image::tpageflag.
Referenced by texture_paint_toggle_exec().
void GPU_paint_update_image | ( | Image * | ima, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h, | ||
int | mipmap | ||
) |
Definition at line 674 of file gpu_draw.c.
References Image::bindcode, BKE_image_get_ibuf(), GPU_free_image(), gpu_get_mipmap(), IMA_MIPMAP_COMPLETE, IMB_partial_rect_from_float(), IMB_rect_from_float(), is_power_of_2_i(), MEM_freeN(), MEM_mallocN(), NULL, ImBuf::rect, ImBuf::rect_float, Image::repbind, Image::tpageflag, ImBuf::x, and ImBuf::y.
Referenced by imapaint_image_update().
static void gpu_queue_image_for_free | ( | Image * | ima | ) | [static] |
Definition at line 823 of file gpu_draw.c.
References BLI_addtail(), BLI_lock_thread(), BLI_unlock_thread(), LOCK_OPENGL, and MEM_dupallocN().
Referenced by GPU_free_image().
void GPU_render_text | ( | MTFace * | tface, |
int | mode, | ||
const char * | textstr, | ||
int | textlen, | ||
unsigned int * | col, | ||
float * | v1, | ||
float * | v2, | ||
float * | v3, | ||
float * | v4, | ||
int | glattrib | ||
) |
Definition at line 90 of file gpu_draw.c.
References ListBase::first, GEMAT_TEXT, gpu_mcol(), Image::ibufs, if(), matrixGlyph(), MAX3(), MAX4, MIN3, MIN4, MTFace::mode, NULL, TF_OBCOL, MTFace::tpage, and MTFace::uv.
Referenced by draw_mesh_text(), KX_BlenderRenderTools::RenderText(), and GPC_RenderTools::RenderText().
Definition at line 1295 of file gpu_draw.c.
References Lamp::att1, Lamp::att2, Scene::base, copy_v3_v3(), Object::data, Lamp::dist, Lamp::energy, ListBase::first, glLoadMatrixf, LA_SPOT, LA_SUN, Object::lay, Base::lay, mul_v3_v3fl(), negate_v3_v3(), Base::next, OB_LAMP, Base::object, Object::obmat, Lamp::r, Lamp::spotblend, Lamp::spotsize, Lamp::type, Object::type, and where_is_object_simul().
Referenced by draw_textured_begin().
static void gpu_set_alpha_blend | ( | GPUBlendMode | alphablend | ) | [static] |
Definition at line 346 of file gpu_draw.c.
References ELEM, UserDef::glalphaclip, GPU_BLEND_ADD, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT, GPU_BLEND_CLIP, GPU_BLEND_SOLID, and U.
Referenced by GPU_set_material_alpha_blend(), and gpu_verify_alpha_blend().
void GPU_set_anisotropic | ( | float | value | ) |
Definition at line 279 of file gpu_draw.c.
References GPUTextureState::anisotropic, GPU_free_images(), and GTS.
Referenced by main(), RAS_OpenGLRasterizer::SetAnisotropicFiltering(), WM_init(), and RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer().
void GPU_set_linear_mipmap | ( | int | linear | ) |
Definition at line 245 of file gpu_draw.c.
References GPU_free_images(), GTS, and GPUTextureState::linearmipmap.
Referenced by set_ge_parameters().
void GPU_set_material_alpha_blend | ( | int | alphablend | ) |
Definition at line 1176 of file gpu_draw.c.
References GMS, gpu_set_alpha_blend(), and GPUMaterialState::lastalphablend.
Referenced by RAS_OpenGLRasterizer::BeginFrame(), GPU_disable_material(), GPU_enable_material(), RAS_OpenGLRasterizer::IndexPrimitivesInternal(), RAS_OpenGLRasterizer::Init(), and RAS_OpenGLRasterizer::SetAlphaBlend().
void GPU_set_mipmap | ( | int | mipmap | ) |
Definition at line 237 of file gpu_draw.c.
References GPUTextureState::domipmap, GPU_free_images(), and GTS.
Referenced by main(), set_ge_parameters(), and WM_init().
int GPU_set_tpage | ( | MTFace * | tface, |
int | mipmap, | ||
int | alphablend | ||
) |
Definition at line 593 of file gpu_draw.c.
References GPUTextureState::curima, GPUTextureState::curtile, GPUTextureState::curtilemode, GPUTextureState::curtileXRep, GPUTextureState::curtileYRep, gpu_clear_tpage(), gpu_verify_alpha_blend(), GPU_verify_image(), gpu_verify_reflection(), gpu_verify_repeat(), GTS, GPUTextureState::ima, GPUTextureState::lasttface, NULL, GPUTextureState::tile, MTFace::tile, GPUTextureState::tilemode, GPUTextureState::tileXRep, GPUTextureState::tileYRep, and MTFace::tpage.
Referenced by KX_PolygonMaterial::DefaultActivate(), draw_textured_end(), and set_draw_settings_cached().
void GPU_state_init | ( | void | ) |
Definition at line 1375 of file gpu_draw.c.
References GPU_default_lights().
Referenced by RAS_OpenGLRasterizer::Init(), and wm_window_add_ghostwindow().
void GPU_state_print | ( | void | ) |
Definition at line 1465 of file gpu_draw.c.
References gpu_get_print().
int GPU_update_image_time | ( | Image * | ima, |
double | time | ||
) |
Definition at line 750 of file gpu_draw.c.
References Image::animspeed, KDL::diff(), IMA_TWINANIM, Image::lastframe, Image::lastupdate, Image::tpageflag, Image::twend, Image::twsta, Image::xrep, and Image::yrep.
Referenced by KX_PolygonMaterial::DefaultActivate(), and GPU_texture_from_blender().
void GPU_update_images_framechange | ( | void | ) |
Definition at line 732 of file gpu_draw.c.
References G, Image::id, IMA_TWINANIM, Image::lastframe, ID::next, Image::tpageflag, Image::twend, Image::twsta, Image::xrep, and Image::yrep.
static void gpu_verify_alpha_blend | ( | int | alphablend | ) | [static] |
Definition at line 381 of file gpu_draw.c.
References GPUTextureState::alphablend, gpu_set_alpha_blend(), and GTS.
Referenced by GPU_set_tpage().
Definition at line 408 of file gpu_draw.c.
References Image::bindcode, BKE_image_get_ibuf(), GPUTextureState::curima, GPUTextureState::curtile, GPUTextureState::curtilemode, GPUTextureState::curtileXRep, GPUTextureState::curtileYRep, GPU_free_image(), GPU_get_anisotropic(), gpu_get_mipmap(), gpu_get_mipmap_filter(), gpu_make_repbind(), GTS, GPUTextureState::ima, IMA_MIPMAP_COMPLETE, IMA_TILES, IMA_TPAGE_REFRESH, IMA_TWINANIM, IMB_rect_from_float(), is_pow2_limit(), Image::lastframe, MAX2, MEM_freeN(), MEM_mallocN(), NULL, Image::ok, ImBuf::rect, ImBuf::rect_float, Image::repbind, smaller_pow2_limit(), GPUTextureState::tile, GPUTextureState::tilemode, GPUTextureState::tileXRep, GPUTextureState::tileYRep, Image::totbind, Image::tpageflag, ImBuf::x, Image::xrep, ImBuf::y, and Image::yrep.
Referenced by GPU_set_tpage(), GPU_texture_from_blender(), and tex_mat_set_texture_cb().
static void gpu_verify_reflection | ( | Image * | ima | ) | [static] |
Definition at line 391 of file gpu_draw.c.
References Image::flag, and IMA_REFLECT.
Referenced by GPU_set_tpage().
static void gpu_verify_repeat | ( | Image * | ima | ) | [static] |
Definition at line 579 of file gpu_draw.c.
References GL_CLAMP_TO_EDGE, IMA_CLAMP_U, IMA_CLAMP_V, and Image::tpageflag.
Referenced by GPU_set_tpage().
static int is_pow2_limit | ( | int | num | ) | [static] |
Definition at line 192 of file gpu_draw.c.
References UserDef::glreslimit, is_power_of_2_i(), and U.
Referenced by GPU_verify_image().
static int smaller_pow2_limit | ( | int | num | ) | [static] |
Definition at line 206 of file gpu_draw.c.
References UserDef::glreslimit, power_of_2_min_i(), and U.
Referenced by GPU_verify_image().
Definition at line 71 of file material.c.
struct GPUMaterialState GMS [static] |
struct GPUTextureState GTS [static] |
ListBase image_free_queue = {NULL, NULL} [static] |
Definition at line 821 of file gpu_draw.c.