Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-21 22:29:37 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-21 22:29:37 +0400
commitb8445173c4c8588a64870e93dd781d181d31c78b (patch)
treea94a5ab2198690f6ef16231627b77b0b8a337dec /source/blender/gpu
parenta1407ff34215e5a72de2988e06c54379a1843c14 (diff)
2.5:
* Fix armature drawing crash with materials. * Mixed texture/material preview was doing wrong gamma correction. * Use *f math functions for AAO.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 1031a240470..eb834abc670 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -800,7 +800,7 @@ static struct GPUMaterialState {
int lastmatnr, lastretval;
GPUBlendMode lastblendmode;
-} GMS;
+} GMS = {NULL};
Material *gpu_active_node_material(Material *ma)
{
@@ -930,10 +930,33 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
int GPU_enable_material(int nr, void *attribs)
{
+ extern Material defmaterial; /* from material.c */
GPUVertexAttribs *gattribs = attribs;
GPUMaterial *gpumat;
GPUBlendMode blendmode;
+ /* no GPU_begin_object_materials, use default material */
+ if(!GMS.matbuf) {
+ float diff[4], spec[4];
+
+ memset(&GMS, 0, sizeof(GMS));
+
+ diff[0]= (defmaterial.ref+defmaterial.emit)*defmaterial.r;
+ diff[1]= (defmaterial.ref+defmaterial.emit)*defmaterial.g;
+ diff[2]= (defmaterial.ref+defmaterial.emit)*defmaterial.b;
+ diff[3]= 1.0;
+
+ spec[0]= defmaterial.spec*defmaterial.specr;
+ spec[1]= defmaterial.spec*defmaterial.specg;
+ spec[2]= defmaterial.spec*defmaterial.specb;
+ spec[3]= 1.0;
+
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diff);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
+
+ return 0;
+ }
+
/* prevent index to use un-initialized array items */
if(nr>=GMS.totmat)
nr= 0;
@@ -1021,11 +1044,11 @@ void GPU_end_object_materials(void)
MEM_freeN(GMS.matbuf);
MEM_freeN(GMS.gmatbuf);
MEM_freeN(GMS.blendmode);
-
- GMS.matbuf= NULL;
- GMS.gmatbuf= NULL;
- GMS.blendmode= NULL;
}
+
+ GMS.matbuf= NULL;
+ GMS.gmatbuf= NULL;
+ GMS.blendmode= NULL;
}
/* Lights */