Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_draw.c
| Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "BKE_bmfont.h" | #include "BKE_bmfont.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_localview.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_DerivedMesh.h" | #include "BKE_DerivedMesh.h" | ||||
| #ifdef WITH_GAMEENGINE | #ifdef WITH_GAMEENGINE | ||||
| # include "BKE_object.h" | # include "BKE_object.h" | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 1,537 Lines • ▼ Show 20 Lines | static struct GPUMaterialState { | ||||
| Material **gmatbuf; | Material **gmatbuf; | ||||
| Material *gmatbuf_fixed[FIXEDMAT]; | Material *gmatbuf_fixed[FIXEDMAT]; | ||||
| Material *gboundmat; | Material *gboundmat; | ||||
| Object *gob; | Object *gob; | ||||
| DupliObject *dob; | DupliObject *dob; | ||||
| Scene *gscene; | Scene *gscene; | ||||
| int glay; | int glay; | ||||
| bool gscenelock; | bool gscenelock; | ||||
| LocalViewInfo *glocalview; | |||||
| float (*gviewmat)[4]; | float (*gviewmat)[4]; | ||||
| float (*gviewinv)[4]; | float (*gviewinv)[4]; | ||||
| float (*gviewcamtexcofac); | float (*gviewcamtexcofac); | ||||
| bool backface_culling; | bool backface_culling; | ||||
| bool two_sided_lighting; | bool two_sided_lighting; | ||||
| GPUBlendMode *alphablend; | GPUBlendMode *alphablend; | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | #endif | ||||
| GMS.two_sided_lighting = false; | GMS.two_sided_lighting = false; | ||||
| if (ob && ob->type == OB_MESH) | if (ob && ob->type == OB_MESH) | ||||
| GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0; | GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0; | ||||
| GMS.gob = ob; | GMS.gob = ob; | ||||
| GMS.gscene = scene; | GMS.gscene = scene; | ||||
| GMS.is_opensubdiv = use_opensubdiv; | GMS.is_opensubdiv = use_opensubdiv; | ||||
| GMS.totmat = use_matcap ? 1 : ob->totcol + 1; /* materials start from 1, default material is 0 */ | GMS.totmat = use_matcap ? 1 : ob->totcol + 1; /* materials start from 1, default material is 0 */ | ||||
| GMS.glay = (v3d->localvd) ? v3d->localvd->lay : v3d->lay; /* keep lamps visible in local view */ | GMS.glay = v3d->lay; | ||||
| GMS.glocalview = &v3d->localviewd->info; | |||||
| GMS.gscenelock = (v3d->scenelock != 0); | GMS.gscenelock = (v3d->scenelock != 0); | ||||
| GMS.gviewmat = rv3d->viewmat; | GMS.gviewmat = rv3d->viewmat; | ||||
| GMS.gviewinv = rv3d->viewinv; | GMS.gviewinv = rv3d->viewinv; | ||||
| GMS.gviewcamtexcofac = rv3d->viewcamtexcofac; | GMS.gviewcamtexcofac = rv3d->viewcamtexcofac; | ||||
| /* alpha pass setup. there's various cases to handle here: | /* alpha pass setup. there's various cases to handle here: | ||||
| * - object transparency on: only solid materials draw in the first pass, | * - object transparency on: only solid materials draw in the first pass, | ||||
| * and only transparent in the second 'alpha' pass. | * and only transparent in the second 'alpha' pass. | ||||
| ▲ Show 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | for (int a = 0; a < 8; a++) { | ||||
| } | } | ||||
| else | else | ||||
| GPU_basic_shader_light_set(a, NULL); | GPU_basic_shader_light_set(a, NULL); | ||||
| } | } | ||||
| return count; | return count; | ||||
| } | } | ||||
| int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[4][4], int ortho) | int GPU_scene_object_lights( | ||||
| Scene *scene, Object *ob, LocalViewInfo *localview, | |||||
| int lay, float viewmat[4][4], int ortho) | |||||
| { | { | ||||
| /* disable all lights */ | /* disable all lights */ | ||||
| for (int count = 0; count < 8; count++) | for (int count = 0; count < 8; count++) | ||||
| GPU_basic_shader_light_set(count, NULL); | GPU_basic_shader_light_set(count, NULL); | ||||
| /* view direction for specular is not computed correct by default in | /* view direction for specular is not computed correct by default in | ||||
| * opengl, so we set the settings ourselfs */ | * opengl, so we set the settings ourselfs */ | ||||
| GPU_basic_shader_light_set_viewer(!ortho); | GPU_basic_shader_light_set_viewer(!ortho); | ||||
| int count = 0; | int count = 0; | ||||
| for (Base *base = scene->base.first; base; base = base->next) { | for (Base *base = scene->base.first; base; base = base->next) { | ||||
| if (base->object->type != OB_LAMP) | if (base->object->type != OB_LAMP) | ||||
| continue; | continue; | ||||
| if (!(base->lay & lay) || !(base->lay & ob->lay)) | if (!(base->lay & lay) || !(base->lay & ob->lay)) | ||||
| continue; | continue; | ||||
| if (localview && !BKE_localview_info_cmp(*localview, ob->localview)) | |||||
| continue; | |||||
| Lamp *la = base->object->data; | Lamp *la = base->object->data; | ||||
| /* setup lamp transform */ | /* setup lamp transform */ | ||||
| glPushMatrix(); | glPushMatrix(); | ||||
| glLoadMatrixf((float *)viewmat); | glLoadMatrixf((float *)viewmat); | ||||
| /* setup light */ | /* setup light */ | ||||
| ▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines | |||||