diff options
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 45 | ||||
-rw-r--r-- | source/blender/gpu/GPU_material.h | 8 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 356 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 8 | ||||
-rw-r--r-- | source/blender/include/BSE_drawview.h | 2 | ||||
-rw-r--r-- | source/blender/nodes/intern/SHD_nodes/SHD_output.c | 4 | ||||
-rw-r--r-- | source/blender/src/drawmesh.c | 81 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 46 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 133 | ||||
-rw-r--r-- | source/blender/src/renderwin.c | 6 | ||||
-rw-r--r-- | source/blender/src/sculptmode.c | 2 | ||||
-rw-r--r-- | source/blender/src/space.c | 4 | ||||
-rw-r--r-- | source/blender/src/toets.c | 4 | ||||
-rw-r--r-- | source/blender/src/usiblender.c | 4 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_BucketManager.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_BucketManager.h | 2 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 76 |
19 files changed, 399 insertions, 387 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index d3c3c7111fc..26801b1af72 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -41,24 +41,49 @@ struct MTFace; struct Image; struct Scene; struct Object; -struct GPUVertexAttribs; -/* OpenGL drawing functions shared with the game engine, - * previously these were duplicated. */ +/* OpenGL drawing functions. These are also shared with + * the game engine, whereas they were previously duplicated. */ + +/* Initialize */ + +void GPU_state_init(void); + +/* Material drawing + * - first the state is initialized by a particular object and it's materials + * - after this, materials can be quickly enabled by their number, + * GPU_enable_material returns 0 if drawing should be skipped + * - after drawing, the material must be disabled again */ + +void GPU_set_object_materials(struct Scene *scene, struct Object *ob, + int glsl, int *do_alpha_pass); +int GPU_enable_material(int nr, void *attribs); +void GPU_disable_material(void); + +/* Lights + * - returns how many lights were enabled */ + +int GPU_default_lights(void); +int GPU_scene_object_lights(struct Scene *scene, struct Object *ob, + int lay, float viewmat[][4]); + +/* Text render */ void GPU_render_text(struct MTFace *tface, int mode, const char *textstr, int textlen, unsigned int *col, float *v1, float *v2, float *v3, float *v4, int glattrib); +/* TexFace state setting, NULL clears it */ + int GPU_set_tpage(struct MTFace *tface); -/* Mipmap settings */ +/* Mipmap settings, these free textures on changes */ void GPU_set_mipmap(int mipmap); void GPU_set_linear_mipmap(int linear); void GPU_paint_set_mipmap(int mipmap); -/* Image free and update */ +/* Image opengl free and update */ void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h); void GPU_update_images_framechange(void); @@ -66,16 +91,6 @@ int GPU_update_image_time(struct MTFace *tface, double time); void GPU_free_image(struct Image *ima); void GPU_free_images(void); -/* Material drawing - * - first the state is initialized by a particular object and it's materials - * - after this, materials can be quickly enabled by their number - * - after drawing, the material must be disabled again */ - -void GPU_set_object_materials(struct Scene *scene, struct Object *ob, - int check_alpha, int glsl, int *has_alpha); -int GPU_enable_material(int nr, void *attribs); -void GPU_disable_material(void); - #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index c97a800c815..669aa18f28e 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -83,6 +83,13 @@ typedef enum GPUBuiltin { GPU_VIEW_NORMAL = 32 } GPUBuiltin; +typedef enum GPUBlendMode { + GPU_BLEND_SOLID, + GPU_BLEND_ALPHA, + GPU_BLEND_ADD, + GPU_BLEND_CLIPALPHA +} GPUBlendMode; + typedef struct GPUNodeStack { GPUType type; char *name; @@ -107,6 +114,7 @@ int GPU_stack_link(GPUMaterial *mat, char *name, GPUNodeStack *in, GPUNodeStack void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link); void GPU_material_enable_alpha(GPUMaterial *material); +GPUBlendMode GPU_material_blend_mode(GPUMaterial *material); /* High level functions to create and use GPU materials */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7cd265362e0..12fce3da3c0 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -35,6 +35,7 @@ #include "GL/glew.h" #include "DNA_image_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" #include "DNA_node_types.h" @@ -54,6 +55,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_node.h" +#include "BKE_object.h" #include "BKE_utildefines.h" #include "GPU_extensions.h" @@ -756,8 +758,11 @@ static struct GPUMaterialState { Object *gob; Scene *gscene; + int hasalpha[MAXMATBUF]; + int alphapass; + int lastmatnr, lastretval; -} GMS = {{{{0}}}, 0, {NULL}, NULL, NULL, NULL, -1, -1}; +} GMS; Material *gpu_active_node_material(Material *ma) { @@ -773,18 +778,27 @@ Material *gpu_active_node_material(Material *ma) return ma; } -void GPU_set_object_materials(Scene *scene, Object *ob, int check_alpha, int glsl, int *has_alpha) +void GPU_set_object_materials(Scene *scene, Object *ob, int glsl, int *do_alpha_pass) { extern Material defmaterial; /* from material.c */ Material *ma; - int a; - - if(has_alpha) - *has_alpha = 0; + GPUBlendMode blendmode; + int a, has_alpha; + /* initialize state */ + memset(&GMS, 0, sizeof(GMS)); + GMS.lastmatnr = -1; + GMS.lastretval = -1; + GMS.gob = ob; GMS.gscene = scene; + GMS.totmat= ob->totcol; + GMS.alphapass = (G.vd && G.vd->transp); + if(do_alpha_pass) + *do_alpha_pass = 0; + + /* no materials assigned? */ if(ob->totcol==0) { GMS.matbuf[0][0][0]= defmaterial.r; GMS.matbuf[0][0][1]= defmaterial.g; @@ -803,12 +817,29 @@ void GPU_set_object_materials(Scene *scene, Object *ob, int check_alpha, int gls GMS.gmatbuf[0]= NULL; } + /* setup materials */ for(a=1; a<=ob->totcol; a++) { + /* find a suitable material */ ma= give_current_material(ob, a); if(!glsl) ma= gpu_active_node_material(ma); if(ma==NULL) ma= &defmaterial; - if(a<MAXMATBUF) { + /* this shouldn't happen .. */ + if(a>=MAXMATBUF) + continue; + + /* create glsl material if requested */ + if(glsl) + GPU_material_from_blender(GMS.gscene, ma); + + if(glsl && ma->gpumaterial) { + /* do glsl only if creating it succeed, else fallback */ + GMS.gmatbuf[a]= ma; + blendmode = GPU_material_blend_mode(ma->gpumaterial); + has_alpha = ELEM(blendmode, GPU_BLEND_ALPHA, GPU_BLEND_ADD); + } + else { + /* fixed function opengl materials */ if (ma->mode & MA_SHLESS) { GMS.matbuf[a][0][0]= ma->r; GMS.matbuf[a][0][1]= ma->g; @@ -817,38 +848,29 @@ void GPU_set_object_materials(Scene *scene, Object *ob, int check_alpha, int gls GMS.matbuf[a][0][0]= (ma->ref+ma->emit)*ma->r; GMS.matbuf[a][0][1]= (ma->ref+ma->emit)*ma->g; GMS.matbuf[a][0][2]= (ma->ref+ma->emit)*ma->b; - } - /* draw transparent, not in pick-select, nor editmode */ - if(check_alpha) { - if(G.vd && G.vd->transp) { // drawing the transparent pass - if(ma->alpha==1.0) GMS.matbuf[a][0][3]= 0.0; // means skip solid - else GMS.matbuf[a][0][3]= ma->alpha; - } - else { // normal pass - if(ma->alpha==1.0) GMS.matbuf[a][0][3]= 1.0; - else { - GMS.matbuf[a][0][3]= 0.0; // means skip transparent - if(has_alpha) - *has_alpha= 1; // return value, to indicate adding to after-draw queue - } - } - } - else - GMS.matbuf[a][0][3]= 1.0; - - if (!(ma->mode & MA_SHLESS)) { GMS.matbuf[a][1][0]= ma->spec*ma->specr; GMS.matbuf[a][1][1]= ma->spec*ma->specg; GMS.matbuf[a][1][2]= ma->spec*ma->specb; GMS.matbuf[a][1][3]= 1.0; } - GMS.gmatbuf[a]= (glsl)? ma: NULL; + has_alpha = (ma->alpha != 1.0f); + if(do_alpha_pass && GMS.alphapass) + GMS.matbuf[a][0][3]= ma->alpha; + else + GMS.matbuf[a][0][3]= 1.0f; + } + + /* setting do_alpha_pass = 1 indicates this object needs to be + * drawn in a second alpha pass for improved blending */ + if(do_alpha_pass) { + GMS.hasalpha[a] = has_alpha; + *do_alpha_pass |= has_alpha && !GMS.alphapass; } } - GMS.totmat= ob->totcol; + /* let's start with a clean state */ GPU_disable_material(); } @@ -863,43 +885,44 @@ int GPU_enable_material(int nr, void *attribs) if(gattribs) memset(gattribs, 0, sizeof(*gattribs)); - if(nr<MAXMATBUF && nr!=GMS.lastmatnr) { - if(GMS.gboundmat) { - GPU_material_unbind(GMS.gboundmat->gpumaterial); - GMS.gboundmat= NULL; - } + /* keep current material */ + if(nr>=MAXMATBUF || nr==GMS.lastmatnr) + return GMS.lastretval; - if(gattribs) { - Material *mat = GMS.gmatbuf[nr]; + /* unbind glsl material */ + if(GMS.gboundmat) { + GPU_material_unbind(GMS.gboundmat->gpumaterial); + GMS.gboundmat= NULL; + } - if(mat) { - GPU_material_from_blender(GMS.gscene, mat); + /* draw materials with alpha in alpha pass */ + GMS.lastmatnr = nr; + GMS.lastretval = (GMS.alphapass)? GMS.hasalpha[nr]: !GMS.hasalpha[nr]; - if(mat->gpumaterial) { - GPU_material_vertex_attributes(mat->gpumaterial, gattribs); - GPU_material_bind(mat->gpumaterial, GMS.gob->lay); - GPU_material_bind_uniforms(mat->gpumaterial, GMS.gob->obmat, G.vd->viewmat, G.vd->viewinv); - GMS.gboundmat= mat; - } - } - } + if(GMS.lastretval) { + if(gattribs && GMS.gmatbuf[nr]) { + /* bind glsl material and get attributes */ + Material *mat = GMS.gmatbuf[nr]; - if(!GMS.gboundmat) { + GPU_material_vertex_attributes(mat->gpumaterial, gattribs); + GPU_material_bind(mat->gpumaterial, GMS.gob->lay); + GPU_material_bind_uniforms(mat->gpumaterial, GMS.gob->obmat, G.vd->viewmat, G.vd->viewinv); + GMS.gboundmat= mat; + } + else { + /* or do fixed function opengl material */ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, GMS.matbuf[nr][0]); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, GMS.matbuf[nr][1]); - GMS.lastmatnr = nr; - GMS.lastretval= GMS.matbuf[nr][0][3]!=0.0; - - /* matbuf alpha: 0.0 = skip draw, 1.0 = no blending, else blend */ - if(GMS.matbuf[nr][0][3]!= 0.0 && GMS.matbuf[nr][0][3]!= 1.0) { - glEnable(GL_BLEND); - } - else - glDisable(GL_BLEND); } + + /* enable alpha blending if needed */ + if(GMS.alphapass) + glEnable(GL_BLEND); + else + glDisable(GL_BLEND); } - - return GMS.lastretval; /* TODO: what is this used for */ + + return GMS.lastretval; } void GPU_disable_material(void) @@ -913,3 +936,220 @@ void GPU_disable_material(void) } } +/* Lights */ + +int GPU_default_lights(void) +{ + int a, count = 0; + + /* initialize */ + if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) { + U.light[0].flag= 1; + U.light[0].vec[0]= -0.3; U.light[0].vec[1]= 0.3; U.light[0].vec[2]= 0.9; + U.light[0].col[0]= 0.8; U.light[0].col[1]= 0.8; U.light[0].col[2]= 0.8; + U.light[0].spec[0]= 0.5; U.light[0].spec[1]= 0.5; U.light[0].spec[2]= 0.5; + U.light[0].spec[3]= 1.0; + + U.light[1].flag= 0; + U.light[1].vec[0]= 0.5; U.light[1].vec[1]= 0.5; U.light[1].vec[2]= 0.1; + U.light[1].col[0]= 0.4; U.light[1].col[1]= 0.4; U.light[1].col[2]= 0.8; + U.light[1].spec[0]= 0.3; U.light[1].spec[1]= 0.3; U.light[1].spec[2]= 0.5; + U.light[1].spec[3]= 1.0; + + U.light[2].flag= 0; + U.light[2].vec[0]= 0.3; U.light[2].vec[1]= -0.3; U.light[2].vec[2]= -0.2; + U.light[2].col[0]= 0.8; U.light[2].col[1]= 0.5; U.light[2].col[2]= 0.4; + U.light[2].spec[0]= 0.5; U.light[2].spec[1]= 0.4; U.light[2].spec[2]= 0.3; + U.light[2].spec[3]= 1.0; + } + + glLightfv(GL_LIGHT0, GL_POSITION, U.light[0].vec); + glLightfv(GL_LIGHT0, GL_DIFFUSE, U.light[0].col); + glLightfv(GL_LIGHT0, GL_SPECULAR, U.light[0].spec); + + glLightfv(GL_LIGHT1, GL_POSITION, U.light[1].vec); + glLightfv(GL_LIGHT1, GL_DIFFUSE, U.light[1].col); + glLightfv(GL_LIGHT1, GL_SPECULAR, U.light[1].spec); + + glLightfv(GL_LIGHT2, GL_POSITION, U.light[2].vec); + glLightfv(GL_LIGHT2, GL_DIFFUSE, U.light[2].col); + glLightfv(GL_LIGHT2, GL_SPECULAR, U.light[2].spec); + + for(a=0; a<8; a++) { + if(a<3) { + if(U.light[a].flag) { + glEnable(GL_LIGHT0+a); + count++; + } + else + glDisable(GL_LIGHT0+a); + + // clear stuff from other opengl lamp usage + glLightf(GL_LIGHT0+a, GL_SPOT_CUTOFF, 180.0); + glLightf(GL_LIGHT0+a, GL_CONSTANT_ATTENUATION, 1.0); + glLightf(GL_LIGHT0+a, GL_LINEAR_ATTENUATION, 0.0); + } + else + glDisable(GL_LIGHT0+a); + } + + glDisable(GL_LIGHTING); + + glDisable(GL_COLOR_MATERIAL); + + return count; +} + +int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4]) +{ + Base *base; + Lamp *la; + int count; + float position[4], direction[4], energy[4]; + + /* disable all lights */ + for(count=0; count<8; count++) + glDisable(GL_LIGHT0+count); + + count= 0; + + for(base=scene->base.first; base; base=base->next) { + if(base->object->type!=OB_LAMP) + continue; + + if(!(base->lay & lay) || !(base->lay & ob->lay)) + continue; + + la= base->object->data; + + /* setup lamp transform */ + glPushMatrix(); + glLoadMatrixf((float *)viewmat); + + where_is_object_simul(base->object); + + if(la->type==LA_SUN) { + /* sun lamp */ + VECCOPY(position, base->object->obmat[2]); + direction[3]= 0.0; + + glLightfv(GL_LIGHT0+count, GL_POSITION, direction); + } + else { + /* other lamps with attenuation */ + VECCOPY(position, base->object->obmat[3]); + position[3]= 1.0f; + + glLightfv(GL_LIGHT0+count, GL_POSITION, position); + glLightf(GL_LIGHT0+count, GL_CONSTANT_ATTENUATION, 1.0); + glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, la->att1/la->dist); + glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, la->att2/(la->dist*la->dist)); + + if(la->type==LA_SPOT) { + /* spot lamp */ + direction[0]= -base->object->obmat[2][0]; + direction[1]= -base->object->obmat[2][1]; + direction[2]= -base->object->obmat[2][2]; + glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, direction); + glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->spotsize/2.0); + glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.0*la->spotblend); + } + else + glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, 180.0); + } + + /* setup energy */ + energy[0]= la->energy*la->r; + energy[1]= la->energy*la->g; + energy[2]= la->energy*la->b; + energy[3]= 1.0; + + glLightfv(GL_LIGHT0+count, GL_DIFFUSE, energy); + glLightfv(GL_LIGHT0+count, GL_SPECULAR, energy); + glEnable(GL_LIGHT0+count); + + glPopMatrix(); + + count++; + if(count==8) + break; + } + + return count; +} + +/* Default OpenGL State */ + +void GPU_state_init(void) +{ + /* also called when doing opengl rendering and in the game engine */ + float mat_ambient[] = { 0.0, 0.0, 0.0, 0.0 }; + float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; + float mat_shininess[] = { 35.0 }; + int a, x, y; + GLubyte pat[32*32]; + const GLubyte *patc= pat; + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); + + GPU_default_lights(); + + /* no local viewer, looks ugly in ortho mode */ + /* glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, &one); */ + + glDepthFunc(GL_LEQUAL); + /* scaling matrices */ + glEnable(GL_NORMALIZE); + + glShadeModel(GL_FLAT); + + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDisable(GL_FOG); + glDisable(GL_LIGHTING); + glDisable(GL_LOGIC_OP); + glDisable(GL_STENCIL_TEST); + glDisable(GL_TEXTURE_1D); + glDisable(GL_TEXTURE_2D); + + /* default on, disable/enable should be local per function */ + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + + glPixelTransferi(GL_MAP_COLOR, GL_FALSE); + glPixelTransferi(GL_RED_SCALE, 1); + glPixelTransferi(GL_RED_BIAS, 0); + glPixelTransferi(GL_GREEN_SCALE, 1); + glPixelTransferi(GL_GREEN_BIAS, 0); + glPixelTransferi(GL_BLUE_SCALE, 1); + glPixelTransferi(GL_BLUE_BIAS, 0); + glPixelTransferi(GL_ALPHA_SCALE, 1); + glPixelTransferi(GL_ALPHA_BIAS, 0); + + glPixelTransferi(GL_DEPTH_BIAS, 0); + glPixelTransferi(GL_DEPTH_SCALE, 1); + glDepthRange(0.0, 1.0); + + a= 0; + for(x=0; x<32; x++) { + for(y=0; y<4; y++) { + if( (x) & 1) pat[a++]= 0x88; + else pat[a++]= 0x22; + } + } + + glPolygonStipple(patc); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + + glFrontFace(GL_CCW); + glCullFace(GL_BACK); + glDisable(GL_CULL_FACE); +} + diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 09fcc826c59..acf84268d99 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -295,6 +295,14 @@ void GPU_material_enable_alpha(GPUMaterial *material) material->alpha= 1; } +GPUBlendMode GPU_material_blend_mode(GPUMaterial *material) +{ + if(material->alpha) + return GPU_BLEND_ALPHA; + else + return GPU_BLEND_SOLID; +} + void gpu_material_add_node(GPUMaterial *material, GPUNode *node) { BLI_addtail(&material->nodes, node); diff --git a/source/blender/include/BSE_drawview.h b/source/blender/include/BSE_drawview.h index 1be10985301..e2c6a0e174a 100644 --- a/source/blender/include/BSE_drawview.h +++ b/source/blender/include/BSE_drawview.h @@ -36,8 +36,6 @@ struct rctf; struct ScrArea; struct ImBuf; -void default_gl_light(void); -void init_gl_stuff(void); void circf(float x, float y, float rad); void circ(float x, float y, float rad); diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_output.c b/source/blender/nodes/intern/SHD_nodes/SHD_output.c index 8b5bdcd88d6..76856cfd2e8 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_output.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_output.c @@ -66,8 +66,8 @@ static int gpu_shader_output(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GP { GPUNodeLink *outlink; - if(in[1].hasinput) - GPU_material_enable_alpha(mat); + /*if(in[1].hasinput) + GPU_material_enable_alpha(mat);*/ GPU_stack_link(mat, "output_node", in, out, &outlink); GPU_material_output_link(mat, outlink); diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c index 16202685848..1ce661303b1 100644 --- a/source/blender/src/drawmesh.c +++ b/source/blender/src/drawmesh.c @@ -253,81 +253,6 @@ static void draw_tfaces3D(Object *ob, Mesh *me, DerivedMesh *dm) BLI_edgehash_free(data.eh, NULL); } -static int set_gl_light(Object *ob) -{ - Base *base; - Lamp *la; - int count; - /* float zero[4]= {0.0, 0.0, 0.0, 0.0}; */ - float vec[4]; - - vec[3]= 1.0; - - for(count=0; count<8; count++) glDisable(GL_LIGHT0+count); - - count= 0; - - base= FIRSTBASE; - while(base) { - if(base->object->type==OB_LAMP ) { - if(base->lay & G.vd->lay) { - if(base->lay & ob->lay) - { - la= base->object->data; - - glPushMatrix(); - glLoadMatrixf((float *)G.vd->viewmat); - - where_is_object_simul(base->object); - VECCOPY(vec, base->object->obmat[3]); - - if(la->type==LA_SUN) { - vec[0]= base->object->obmat[2][0]; - vec[1]= base->object->obmat[2][1]; - vec[2]= base->object->obmat[2][2]; - vec[3]= 0.0; - glLightfv(GL_LIGHT0+count, GL_POSITION, vec); - } - else { - vec[3]= 1.0; - glLightfv(GL_LIGHT0+count, GL_POSITION, vec); - glLightf(GL_LIGHT0+count, GL_CONSTANT_ATTENUATION, 1.0); - glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, la->att1/la->dist); - /* post 2.25 engine supports quad lights */ - glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, la->att2/(la->dist*la->dist)); - - if(la->type==LA_SPOT) { - vec[0]= -base->object->obmat[2][0]; - vec[1]= -base->object->obmat[2][1]; - vec[2]= -base->object->obmat[2][2]; - glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, vec); - glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->spotsize/2.0); - glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.0*la->spotblend); - } - else glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, 180.0); - } - - vec[0]= la->energy*la->r; - vec[1]= la->energy*la->g; - vec[2]= la->energy*la->b; - vec[3]= 1.0; - glLightfv(GL_LIGHT0+count, GL_DIFFUSE, vec); - glLightfv(GL_LIGHT0+count, GL_SPECULAR, vec);//zero); - glEnable(GL_LIGHT0+count); - - glPopMatrix(); - - count++; - if(count>7) break; - } - } - } - base= base->next; - } - - return count; -} - static Material *give_current_material_or_def(Object *ob, int matnr) { extern Material defmaterial; // render module abuse... @@ -428,7 +353,7 @@ static void draw_textured_begin(Object *ob) } else /* draw with lights in the scene otherwise */ - Gtexdraw.islit= set_gl_light(ob); + Gtexdraw.islit= GPU_scene_object_lights(G.scene, ob, G.vd->lay, G.vd->viewmat); obcol[0]= CLAMPIS(ob->col[0]*255, 0, 255); obcol[1]= CLAMPIS(ob->col[1]*255, 0, 255); @@ -454,7 +379,7 @@ static void draw_textured_end() glShadeModel(GL_FLAT); glDisable(GL_CULL_FACE); - /* XXX, bad patch - default_gl_light() calls + /* XXX, bad patch - GPU_default_lights() calls * glLightfv(GL_LIGHT_POSITION, ...) which * is transformed by the current matrix... we * need to make sure that matrix is identity. @@ -465,7 +390,7 @@ static void draw_textured_end() */ glPushMatrix(); glLoadIdentity(); - default_gl_light(); + GPU_default_lights(); glPopMatrix(); } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index ffb63e7ae18..fb4973c403f 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -165,7 +165,7 @@ int draw_glsl_material(Object *ob, int dt) (G.fileflags & G_FILE_GAME_MAT_GLSL) && (dt >= OB_SHADED)); } -static int check_material_alpha(Base *base, Object *ob) +static int check_material_alpha(Base *base, Object *ob, int glsl) { if(base->flag & OB_FROMDUPLI) return 0; @@ -176,7 +176,7 @@ static int check_material_alpha(Base *base, Object *ob) if(G.obedit && G.obedit->data==ob->data) return 0; - return (ob->dtx & OB_DRAWTRANSP); + return (glsl || (ob->dtx & OB_DRAWTRANSP)); } /***/ @@ -2443,7 +2443,7 @@ static int draw_mesh_object(Base *base, int dt, int flag) { Object *ob= base->object; Mesh *me= ob->data; - int has_alpha= 0, drawlinked= 0, retval= 0; + int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha; if(G.obedit && ob!=G.obedit && ob->data==G.obedit->data) { if(ob_get_key(ob)); @@ -2459,9 +2459,11 @@ static int draw_mesh_object(Base *base, int dt, int flag) cageDM = editmesh_get_derived_cage_and_final(&finalDM, get_viewedit_datamask()); - if(dt>OB_WIRE) // no transp in editmode, the fancy draw over goes bad then - GPU_set_object_materials(G.scene, ob, 0, - draw_glsl_material(ob, dt), NULL); + if(dt>OB_WIRE) { + // no transp in editmode, the fancy draw over goes bad then + glsl = draw_glsl_material(ob, dt); + GPU_set_object_materials(G.scene, ob, glsl, NULL); + } draw_em_fancy(ob, G.editMesh, cageDM, finalDM, dt); @@ -2475,10 +2477,13 @@ static int draw_mesh_object(Base *base, int dt, int flag) else { /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */ if(me->totface<=4 || boundbox_clip(ob->obmat, (ob->bb)? ob->bb: me->bb)) { - if(dt==OB_SOLID || draw_glsl_material(ob, dt)) - GPU_set_object_materials(G.scene, ob, - check_material_alpha(base, ob), - draw_glsl_material(ob, dt), &has_alpha); + glsl = draw_glsl_material(ob, dt); + check_alpha = check_material_alpha(base, ob, glsl); + + if(dt==OB_SOLID || glsl) { + GPU_set_object_materials(G.scene, ob, glsl, + (check_alpha)? &do_alpha_pass: NULL); + } draw_mesh_fancy(base, dt, flag); @@ -2487,7 +2492,7 @@ static int draw_mesh_object(Base *base, int dt, int flag) } /* GPU_set_object_materials checked if this is needed */ - if(has_alpha) add_view3d_after(G.vd, base, V3D_TRANSP, flag); + if(do_alpha_pass) add_view3d_after(G.vd, base, V3D_TRANSP, flag); return retval; } @@ -2791,7 +2796,7 @@ static int drawDispList(Base *base, int dt) } else { if(draw_glsl_material(ob, dt)) { - GPU_set_object_materials(G.scene, ob, 0, 1, NULL); + GPU_set_object_materials(G.scene, ob, 1, NULL); drawDispListsolid(lb, ob, 1); } else if(dt == OB_SHADED) { @@ -2799,7 +2804,7 @@ static int drawDispList(Base *base, int dt) drawDispListshaded(lb, ob); } else { - GPU_set_object_materials(G.scene, ob, 0, 0, NULL); + GPU_set_object_materials(G.scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); drawDispListsolid(lb, ob, 0); } @@ -2829,7 +2834,7 @@ static int drawDispList(Base *base, int dt) if(dl->nors==NULL) addnormalsDispList(ob, lb); if(draw_glsl_material(ob, dt)) { - GPU_set_object_materials(G.scene, ob, 0, 1, NULL); + GPU_set_object_materials(G.scene, ob, 1, NULL); drawDispListsolid(lb, ob, 1); } else if(dt==OB_SHADED) { @@ -2837,7 +2842,7 @@ static int drawDispList(Base *base, int dt) drawDispListshaded(lb, ob); } else { - GPU_set_object_materials(G.scene, ob, 0, 0, NULL); + GPU_set_object_materials(G.scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); drawDispListsolid(lb, ob, 0); @@ -2857,7 +2862,7 @@ static int drawDispList(Base *base, int dt) if(solid) { if(draw_glsl_material(ob, dt)) { - GPU_set_object_materials(G.scene, ob, 0, 1, NULL); + GPU_set_object_materials(G.scene, ob, 1, NULL); drawDispListsolid(lb, ob, 1); } else if(dt == OB_SHADED) { @@ -2866,7 +2871,7 @@ static int drawDispList(Base *base, int dt) drawDispListshaded(lb, ob); } else { - GPU_set_object_materials(G.scene, ob, 0, 0, NULL); + GPU_set_object_materials(G.scene, ob, 0, NULL); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); drawDispListsolid(lb, ob, 0); @@ -5477,6 +5482,7 @@ void draw_object_backbufsel(Object *ob) static void draw_object_mesh_instance(Object *ob, int dt, int outline) { DerivedMesh *dm=NULL, *edm=NULL; + int glsl; if(G.obedit && ob->data==G.obedit->data) edm= editmesh_get_derived_base(); @@ -5493,8 +5499,10 @@ static void draw_object_mesh_instance(Object *ob, int dt, int outline) if(outline) draw_mesh_object_outline(ob, dm?dm:edm); - if(dm) - GPU_set_object_materials(G.scene, ob, 0, draw_glsl_material(ob, dt), NULL); + if(dm) { + glsl = draw_glsl_material(ob, dt); + GPU_set_object_materials(G.scene, ob, glsl, NULL); + } else { glEnable(GL_COLOR_MATERIAL); BIF_ThemeColor(TH_BONE_SOLID); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 9560bf26f2e..b6c0af109e7 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -194,133 +194,6 @@ static void star_stuff_term_func(void) glEnd(); } -void default_gl_light(void) -{ - int a; - - /* initialize */ - if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) { - U.light[0].flag= 1; - U.light[0].vec[0]= -0.3; U.light[0].vec[1]= 0.3; U.light[0].vec[2]= 0.9; - U.light[0].col[0]= 0.8; U.light[0].col[1]= 0.8; U.light[0].col[2]= 0.8; - U.light[0].spec[0]= 0.5; U.light[0].spec[1]= 0.5; U.light[0].spec[2]= 0.5; - U.light[0].spec[3]= 1.0; - - U.light[1].flag= 0; - U.light[1].vec[0]= 0.5; U.light[1].vec[1]= 0.5; U.light[1].vec[2]= 0.1; - U.light[1].col[0]= 0.4; U.light[1].col[1]= 0.4; U.light[1].col[2]= 0.8; - U.light[1].spec[0]= 0.3; U.light[1].spec[1]= 0.3; U.light[1].spec[2]= 0.5; - U.light[1].spec[3]= 1.0; - - U.light[2].flag= 0; - U.light[2].vec[0]= 0.3; U.light[2].vec[1]= -0.3; U.light[2].vec[2]= -0.2; - U.light[2].col[0]= 0.8; U.light[2].col[1]= 0.5; U.light[2].col[2]= 0.4; - U.light[2].spec[0]= 0.5; U.light[2].spec[1]= 0.4; U.light[2].spec[2]= 0.3; - U.light[2].spec[3]= 1.0; - } - - - glLightfv(GL_LIGHT0, GL_POSITION, U.light[0].vec); - glLightfv(GL_LIGHT0, GL_DIFFUSE, U.light[0].col); - glLightfv(GL_LIGHT0, GL_SPECULAR, U.light[0].spec); - - glLightfv(GL_LIGHT1, GL_POSITION, U.light[1].vec); - glLightfv(GL_LIGHT1, GL_DIFFUSE, U.light[1].col); - glLightfv(GL_LIGHT1, GL_SPECULAR, U.light[1].spec); - - glLightfv(GL_LIGHT2, GL_POSITION, U.light[2].vec); - glLightfv(GL_LIGHT2, GL_DIFFUSE, U.light[2].col); - glLightfv(GL_LIGHT2, GL_SPECULAR, U.light[2].spec); - - for(a=0; a<8; a++) { - if(a<3) { - if(U.light[a].flag) glEnable(GL_LIGHT0+a); - else glDisable(GL_LIGHT0+a); - - // clear stuff from other opengl lamp usage - glLightf(GL_LIGHT0+a, GL_SPOT_CUTOFF, 180.0); - glLightf(GL_LIGHT0+a, GL_CONSTANT_ATTENUATION, 1.0); - glLightf(GL_LIGHT0+a, GL_LINEAR_ATTENUATION, 0.0); - } - else glDisable(GL_LIGHT0+a); - } - - glDisable(GL_LIGHTING); - - glDisable(GL_COLOR_MATERIAL); -} - -/* also called when render 'ogl' - keep synced with Myinit_gl_stuff in the game engine! */ -void init_gl_stuff(void) -{ - float mat_ambient[] = { 0.0, 0.0, 0.0, 0.0 }; - float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; - float mat_shininess[] = { 35.0 }; - int a, x, y; - GLubyte pat[32*32]; - const GLubyte *patc= pat; - - - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); - - default_gl_light(); - - /* no local viewer, looks ugly in ortho mode */ - /* glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, &one); */ - - glDepthFunc(GL_LEQUAL); - /* scaling matrices */ - glEnable(GL_NORMALIZE); - - glShadeModel(GL_FLAT); - - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glDisable(GL_LIGHTING); - glDisable(GL_LOGIC_OP); - glDisable(GL_STENCIL_TEST); - glDisable(GL_TEXTURE_1D); - glDisable(GL_TEXTURE_2D); - - /* default on, disable/enable should be local per function */ - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - - glPixelTransferi(GL_MAP_COLOR, GL_FALSE); - glPixelTransferi(GL_RED_SCALE, 1); - glPixelTransferi(GL_RED_BIAS, 0); - glPixelTransferi(GL_GREEN_SCALE, 1); - glPixelTransferi(GL_GREEN_BIAS, 0); - glPixelTransferi(GL_BLUE_SCALE, 1); - glPixelTransferi(GL_BLUE_BIAS, 0); - glPixelTransferi(GL_ALPHA_SCALE, 1); - glPixelTransferi(GL_ALPHA_BIAS, 0); - - glPixelTransferi(GL_DEPTH_BIAS, 0); - glPixelTransferi(GL_DEPTH_SCALE, 1); - glDepthRange(0.0, 1.0); - - a= 0; - for(x=0; x<32; x++) { - for(y=0; y<4; y++) { - if( (x) & 1) pat[a++]= 0x88; - else pat[a++]= 0x22; - } - } - - glPolygonStipple(patc); - - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); -} - void circf(float x, float y, float rad) { GLUquadricObj *qobj = gluNewQuadric(); @@ -2716,7 +2589,7 @@ static void view3d_draw_transp(View3D *v3d) glDepthMask(0); v3d->transp= TRUE; - + for(v3da= v3d->afterdraw.first; v3da; v3da= next) { next= v3da->next; if(v3da->type==V3D_TRANSP) { @@ -3214,8 +3087,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata) TOTTRI_ENABLE; /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, 1); // clears zbuffer if it is used! view3d_draw_transp(v3d); + view3d_draw_xray(v3d, 1); // clears zbuffer if it is used! TOTTRI_DISABLE; @@ -3444,8 +3317,8 @@ void drawview3d_render(struct View3D *v3d, float viewmat[][4], int winx, int win if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID); /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, !shadow); // clears zbuffer if it is used! view3d_draw_transp(v3d); + view3d_draw_xray(v3d, !shadow); // clears zbuffer if it is used! if(v3d->flag & V3D_CLIPPING) view3d_clr_clipping(); diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c index 50ed79e8a66..73611b4aed2 100644 --- a/source/blender/src/renderwin.c +++ b/source/blender/src/renderwin.c @@ -100,6 +100,8 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "GPU_draw.h" + #include "blendef.h" #include "mydevice.h" #include "winlay.h" @@ -674,7 +676,7 @@ static void open_renderwin(int winpos[2], int winsize[2], int imagesize[2]) /* mywindow has to know about it too */ mywindow_build_and_set_renderwin(winpos[0], winpos[1], winsize[0], winsize[1]+RW_HEADERY); /* and we should be able to draw 3d in it */ - init_gl_stuff(); + GPU_state_init(); renderwin_draw(render_win, 1); renderwin_draw(render_win, 1); @@ -1337,7 +1339,7 @@ void BIF_do_ogl_render(View3D *v3d, int anim) if(render_win) render_win->flags &= ~RW_FLAGS_ESCAPE; - init_gl_stuff(); + GPU_state_init(); waitcursor(1); diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index be59a0af924..31d5ae4610d 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -1515,7 +1515,7 @@ void sculptmode_draw_mesh(int only_damaged) mymultmatrix(OBACT->obmat); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); - GPU_set_object_materials(G.scene, OBACT, 0, 0, NULL); + GPU_set_object_materials(G.scene, OBACT, 0, NULL); glEnable(GL_CULL_FACE); glShadeModel(GL_SMOOTH); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index f43732d3102..ae369f80acc 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -434,7 +434,7 @@ static void SaveState(void) { glPushAttrib(GL_ALL_ATTRIB_BITS); - init_gl_stuff(); + GPU_state_init(); if(G.f & G_TEXTUREPAINT) GPU_paint_set_mipmap(1); @@ -4520,7 +4520,7 @@ static void winqreadinfospace(ScrArea *sa, void *spacedata, BWinEvent *evt) if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) U.light[0].flag= 1; - default_gl_light(); + GPU_default_lights(); addqueue(sa->win, REDRAW, 1); allqueue(REDRAWVIEW3D, 0); } diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index 5f80f14d069..efd97ed9786 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -104,6 +104,8 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "GPU_draw.h" + #include "mydevice.h" #include "transform.h" @@ -964,7 +966,7 @@ int blenderqread(unsigned short event, short val) /* Reset lights * This isn't done when reading userdef, do it now * */ - default_gl_light(); + GPU_default_lights(); } return 0; } diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index 6827cd6577d..ea0b5d132c7 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -146,6 +146,7 @@ #include "PIL_time.h" #include "GPU_extensions.h" +#include "GPU_draw.h" /***/ @@ -1041,8 +1042,9 @@ void BIF_init(void) BIF_filelist_init_icons(); - init_gl_stuff(); /* drawview.c, after homefile */ + GPU_state_init(); GPU_extensions_init(); + readBlog(); BLI_strncpy(G.lib, G.sce, FILE_MAX); } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 0d4c5cd4d3d..b7b63594bcb 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -618,6 +618,7 @@ int main(int argc, char** argv) Main *maggie = bfd->main; Scene *scene = bfd->curscene; char *startscenename = scene->id.name + 2; + G.main = maggie; G.fileflags = bfd->fileflags; //Seg Fault; icon.c gIcons == 0 diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index c523cbcf0c8..991393e4114 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1403,7 +1403,7 @@ void KX_Scene::UpdateParents(double curtime) RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool &bucketCreated) { - return m_bucketmanager->RAS_BucketManagerFindBucket(polymat, bucketCreated); + return m_bucketmanager->FindBucket(polymat, bucketCreated); } diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 67c9b56a78c..14ee9a0e2c7 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -154,7 +154,7 @@ void RAS_BucketManager::Renderbuckets( RAS_MaterialBucket::EndFrame(); } -RAS_MaterialBucket* RAS_BucketManager::RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material, bool &bucketCreated) +RAS_MaterialBucket* RAS_BucketManager::FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated) { bucketCreated = false; BucketList::iterator it; diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index b875512b464..08b67ed022f 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -58,7 +58,7 @@ public: RAS_IRasterizer* rasty, class RAS_IRenderTools* rendertools); - RAS_MaterialBucket* RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material, bool &bucketCreated); + RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated); void ReleaseDisplayLists(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index b3cf5b7fafe..5dae911aa82 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -38,6 +38,8 @@ #include "MT_CmMatrix4x4.h" #include "RAS_IRenderTools.h" // rendering text +#include "GPU_draw.h" + /** * 32x32 bit masks for vinterlace stereo mode */ @@ -86,81 +88,9 @@ RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() { } - - -static void Myinit_gl_stuff(void) -{ - float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; - float mat_shininess[] = { 35.0 }; -/* float one= 1.0; */ - int a, x, y; - GLubyte pat[32*32]; - const GLubyte *patc= pat; - - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); - - -#if defined(__FreeBSD) || defined(__linux__) - glDisable(GL_DITHER); /* op sgi/sun hardware && 12 bits */ -#endif - - /* no local viewer, looks ugly in ortho mode */ - /* glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, &one); */ - - glDepthFunc(GL_LEQUAL); - /* scaling matrices */ - glEnable(GL_NORMALIZE); - - glShadeModel(GL_FLAT); - - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glDisable(GL_LIGHTING); - glDisable(GL_LOGIC_OP); - glDisable(GL_STENCIL_TEST); - glDisable(GL_TEXTURE_1D); - glDisable(GL_TEXTURE_2D); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - - glPixelTransferi(GL_MAP_COLOR, GL_FALSE); - glPixelTransferi(GL_RED_SCALE, 1); - glPixelTransferi(GL_RED_BIAS, 0); - glPixelTransferi(GL_GREEN_SCALE, 1); - glPixelTransferi(GL_GREEN_BIAS, 0); - glPixelTransferi(GL_BLUE_SCALE, 1); - glPixelTransferi(GL_BLUE_BIAS, 0); - glPixelTransferi(GL_ALPHA_SCALE, 1); - glPixelTransferi(GL_ALPHA_BIAS, 0); - - a = 0; - for(x=0; x<32; x++) - { - for(y=0; y<4; y++) - { - if( (x) & 1) pat[a++]= 0x88; - else pat[a++]= 0x22; - } - } - - glPolygonStipple(patc); - - glFrontFace(GL_CCW); - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); -} - - - bool RAS_OpenGLRasterizer::Init() { - - Myinit_gl_stuff(); + GPU_state_init(); m_redback = 0.4375; m_greenback = 0.4375; |