From 5a74bb7f3a3a6345160e65922d3d52c3283cc129 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 24 Sep 2004 17:57:34 +0000 Subject: [PATCH] remove unneeded call_gl* methods, reset viewport between frames --- .../src/glstuff/glGraphicsStateGuardian_src.I | 547 ------------------ .../glstuff/glGraphicsStateGuardian_src.cxx | 147 ++--- .../src/glstuff/glGraphicsStateGuardian_src.h | 63 -- 3 files changed, 54 insertions(+), 703 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I index 577a3af834..5e9964d8b2 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.I +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I @@ -82,553 +82,6 @@ report_my_errors(int line, const char *source_file) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glClearColor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glClearColor(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha) { - if (red != _clear_color_red || - green != _clear_color_green || - blue != _clear_color_blue || - alpha != _clear_color_alpha) { - GLP(ClearColor)(red, green, blue, alpha); - _clear_color_red = red; - _clear_color_green = green; - _clear_color_blue = blue; - _clear_color_alpha = alpha; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glClearDepth -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glClearDepth(GLclampd depth) { - if (depth != _clear_depth) { -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glClearDepth(" << (double)depth << ")" << endl; -#endif - GLP(ClearDepth)(depth); - _clear_depth = depth; - } -} - - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glClearStencil -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glClearStencil(GLint s) { - if (s != _clear_stencil) { - GLP(ClearStencil)(s); - _clear_stencil = s; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glClearAccum -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glClearAccum(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha) { - if (red != _clear_accum_red || - green != _clear_accum_green || - blue != _clear_accum_blue || - alpha != _clear_accum_alpha) { - GLP(ClearAccum)(red, green, blue, alpha); - _clear_accum_red = red; - _clear_accum_green = green; - _clear_accum_blue = blue; - _clear_accum_alpha = alpha; - } -} - - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glShadeModel -// Access: -// Description: Set the shading model to be either GL_FLAT or GL_SMOOTH -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glShadeModel(GLenum mode) { - if (_shade_model_mode != mode) { - GLP(ShadeModel)(mode); - _shade_model_mode = mode; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glScissor -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) -{ - if ( _scissor_x != x || _scissor_y != y || - _scissor_width != width || _scissor_height != height ) - { - _scissor_x = x; _scissor_y = y; - _scissor_width = width; _scissor_height = height; - GLP(Scissor)( x, y, width, height ); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glViewport -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) -{ - if ( _viewport_x != x || _viewport_y != y || - _viewport_width != width || _viewport_height != height ) - { - _viewport_x = x; _viewport_y = y; - _viewport_width = width; _viewport_height = height; - GLP(Viewport)( x, y, width, height ); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glLightModelLocal -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glLightModelLocal(GLboolean local) -{ - if ( _lmodel_local != local ) - { - _lmodel_local = local; - GLP(LightModeli)( GL_LIGHT_MODEL_LOCAL_VIEWER, local ); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glLightModelLocal -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glLightModelTwoSide(GLboolean twoside) -{ - if (_lmodel_twoside != twoside) { - _lmodel_twoside = twoside; -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glLightModel(GL_LIGHT_MODEL_TWO_SIDE, " << (int)twoside << ")" << endl; -#endif - GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, twoside); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glStencilFunc -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glStencilFunc(GLenum func,GLint ref,GLuint mask) { - -#ifdef GSG_VERBOSE - GLCAT.spam() << "glStencilFunc("; - switch (func) { - case GL_NEVER: - GLCAT.spam(false) << "GL_NEVER, "; - break; - case GL_LESS: - GLCAT.spam(false) << "GL_LESS, "; - break; - case GL_EQUAL: - GLCAT.spam(false) << "GL_EQUAL, "; - break; - case GL_LEQUAL: - GLCAT.spam(false) << "GL_LEQUAL, "; - break; - case GL_GREATER: - GLCAT.spam(false) << "GL_GREATER, "; - break; - case GL_NOTEQUAL: - GLCAT.spam(false) << "GL_NOTEQUAL, "; - break; - case GL_GEQUAL: - GLCAT.spam(false) << "GL_GEQUAL, "; - break; - case GL_ALWAYS: - GLCAT.spam(false) << "GL_ALWAYS, "; - break; - default: - GLCAT.spam(false) << "unknown, "; - break; - } - GLCAT.spam(false) << (int)ref << ", " << (int)mask << ")\n"; -#endif - GLP(StencilFunc)(func, ref, mask); -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glStencilOp -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glStencilOp(GLenum fail,GLenum zfail,GLenum zpass) { -#ifdef GSG_VERBOSE - GLCAT.spam() << "glStencilOp(fail, zfail, "; - switch (zpass) { - case GL_KEEP: - GLCAT.spam(false) << "GL_KEEP)"; - break; - case GL_ZERO: - GLCAT.spam(false) << "GL_ZERO)"; - break; - case GL_REPLACE: - GLCAT.spam(false) << "GL_REPLACE)"; - break; - case GL_INCR: - GLCAT.spam(false) << "GL_INCR)"; - break; - case GL_DECR: - GLCAT.spam(false) << "GL_DECR)"; - break; - case GL_INVERT: - GLCAT.spam(false) << "GL_INVERT)"; - break; - default: - GLCAT.spam(false) << "unknown)"; - break; - } - GLCAT.spam(false) << endl; -#endif - GLP(StencilOp)(fail,zfail,zpass); -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glLineWidth -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glLineWidth(GLfloat width) { - if (_line_width != width) { - _line_width = width; -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glLineWidth(" << width << ")" << endl; -#endif - GLP(LineWidth)(width); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glPointSize -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glPointSize(GLfloat size) { - if (_point_size != size) { - _point_size = size; -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glPointSize(" << size << ")" << endl; -#endif - GLP(PointSize)(size); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glBlendFunc -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glBlendFunc(GLenum sfunc, GLenum dfunc) { - if (_blend_source_func != sfunc || _blend_dest_func != dfunc) { - _blend_source_func = sfunc; - _blend_dest_func = dfunc; -#ifdef GSG_VERBOSE - GLCAT.spam() << "glBlendFunc("; - switch (sfunc) { - case GL_ZERO: - GLCAT.spam(false) << "GL_ZERO, "; - break; - case GL_ONE: - GLCAT.spam(false) << "GL_ONE, "; - break; - case GL_DST_COLOR: - GLCAT.spam(false) << "GL_DST_COLOR, "; - break; - case GL_ONE_MINUS_DST_COLOR: - GLCAT.spam(false) << "GL_ONE_MINUS_DST_COLOR, "; - break; - case GL_SRC_ALPHA: - GLCAT.spam(false) << "GL_SRC_ALPHA, "; - break; - case GL_ONE_MINUS_SRC_ALPHA: - GLCAT.spam(false) << "GL_ONE_MINUS_SRC_ALPHA, "; - break; - case GL_DST_ALPHA: - GLCAT.spam(false) << "GL_DST_ALPHA, "; - break; - case GL_ONE_MINUS_DST_ALPHA: - GLCAT.spam(false) << "GL_ONE_MINUS_DST_ALPHA, "; - break; - case GL_SRC_ALPHA_SATURATE: - - GLCAT.spam(false) << "GL_SRC_ALPHA_SATURATE, "; - break; - default: - GLCAT.spam(false) << "unknown, "; - break; - } - switch (dfunc) { - case GL_ZERO: - GLCAT.spam(false) << "GL_ZERO)"; - break; - case GL_ONE: - GLCAT.spam(false) << "GL_ONE)"; - break; - case GL_SRC_COLOR: - GLCAT.spam(false) << "GL_SRC_COLOR)"; - break; - case GL_ONE_MINUS_SRC_COLOR: - GLCAT.spam(false) << "GL_ONE_MINUS_SRC_COLOR)"; - break; - case GL_SRC_ALPHA: - GLCAT.spam(false) << "GL_SRC_ALPHA)"; - break; - case GL_ONE_MINUS_SRC_ALPHA: - GLCAT.spam(false) << "GL_ONE_MINUS_SRC_ALPHA)"; - break; - case GL_DST_ALPHA: - GLCAT.spam(false) << "GL_DST_ALPHA)"; - break; - case GL_ONE_MINUS_DST_ALPHA: - GLCAT.spam(false) << "GL_ONE_MINUS_DST_ALPHA)"; - break; - default: - GLCAT.spam(false) << "unknown)"; - break; - } - GLCAT.spam(false) << endl; -#endif - GLP(BlendFunc)(sfunc, dfunc); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glFogMode -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glFogMode(GLint mode) { - if (_fog_mode != mode) { - _fog_mode = mode; -#ifdef GSG_VERBOSE - GLCAT.spam() << "glFog(GL_FOG_MODE, "; - switch(mode) { - case GL_LINEAR: - GLCAT.spam(false) << "GL_LINEAR)" << endl; - break; - case GL_EXP: - GLCAT.spam(false) << "GL_EXP)" << endl; - break; - case GL_EXP2: - GLCAT.spam(false) << "GL_EXP2)" << endl; - break; -#ifdef GL_FOG_FUNC_SGIS - case GL_FOG_FUNC_SGIS: - GLCAT.spam(false) << "GL_FOG_FUNC_SGIS)" << endl; - break; -#endif - default: - GLCAT.spam(false) << "unknown)" << endl; - break; - } -#endif - GLP(Fogi)(GL_FOG_MODE, mode); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glFogStart -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glFogStart(GLfloat start) { - if (_fog_start != start) { - _fog_start = start; -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glFog(GL_FOG_START, " << start << ")" << endl; -#endif - GLP(Fogf)(GL_FOG_START, start); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glFogEnd -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glFogEnd(GLfloat end) { - if (_fog_end != end) { - _fog_end = end; -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glFog(GL_FOG_END, " << end << ")" << endl; -#endif - GLP(Fogf)(GL_FOG_END, end); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glFogDensity -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glFogDensity(GLfloat density) { - if (_fog_density != density) { - _fog_density = density; -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glFog(GL_FOG_DENSITY, " << density << ")" << endl; -#endif - GLP(Fogf)(GL_FOG_DENSITY, density); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glFogColor -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glFogColor(const Colorf &color) { - if (_fog_color != color) { - _fog_color = color; -#ifdef GSG_VERBOSE - GLCAT.spam() - << "glFog(GL_FOG_COLOR, " << color << ")" << endl; -#endif - GLP(Fogfv)(GL_FOG_COLOR, color.get_data()); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glAlphaFunc -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glAlphaFunc(GLenum func, GLclampf ref) { - if (_alpha_func != func || _alpha_func_ref != ref) { - _alpha_func = func; - _alpha_func_ref = ref; -#ifdef GSG_VERBOSE - GLCAT.spam() << "glAlphaFunc("; - switch (func) { - case GL_NEVER: - GLCAT.spam(false) << "GL_NEVER, "; - break; - case GL_LESS: - GLCAT.spam(false) << "GL_LESS, "; - break; - case GL_EQUAL: - GLCAT.spam(false) << "GL_EQUAL, "; - break; - case GL_LEQUAL: - GLCAT.spam(false) << "GL_LEQUAL, "; - break; - case GL_GREATER: - GLCAT.spam(false) << "GL_GREATER, "; - break; - case GL_NOTEQUAL: - GLCAT.spam(false) << "GL_NOTEQUAL, "; - break; - case GL_GEQUAL: - GLCAT.spam(false) << "GL_GEQUAL, "; - break; - case GL_ALWAYS: - GLCAT.spam(false) << "GL_ALWAYS, "; - break; - } - GLCAT.spam() << ref << ")" << endl; -#endif - GLP(AlphaFunc)(func, ref); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::call_glPolygonMode -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -call_glPolygonMode(GLenum mode) { - if (_polygon_mode != mode) { - _polygon_mode = mode; -#ifdef GSG_VERBOSE - GLCAT.spam() << "glPolygonMode(GL_BACK_AND_FRONT, "; - switch (mode) { - case GL_POINT: - GLCAT.spam(false) << "GL_POINT)" << endl; - break; - case GL_LINE: - GLCAT.spam(false) << "GL_LINE)" << endl; - break; - case GL_FILL: - GLCAT.spam(false) << "GL_FILL)" << endl; - break; - } -#endif - GLP(PolygonMode)(GL_FRONT_AND_BACK, mode); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::set_pack_alignment -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -set_pack_alignment(GLint alignment) { - if (_pack_alignment != alignment) { - GLP(PixelStorei)(GL_PACK_ALIGNMENT, alignment); - _pack_alignment = alignment; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::set_unpack_alignment -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void CLP(GraphicsStateGuardian):: -set_unpack_alignment(GLint alignment) { - if (_unpack_alignment != alignment) { - GLP(PixelStorei)(GL_UNPACK_ALIGNMENT, alignment); - _unpack_alignment = alignment; - } -} - //////////////////////////////////////////////////////////////////// // Function: CLP(GraphicsStateGuardian)::enable_multisample // Access: diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index d13dffb52c..10f886a133 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -396,48 +396,9 @@ reset() { } #endif - // Set up our clear values to invalid values, so the GLP(Clear)* calls - // will be made initially. - _clear_color_red = -1.0f; - _clear_color_green = -1.0f; - _clear_color_blue = -1.0f; - _clear_color_alpha = -1.0f; - _clear_depth = -1.0f; - _clear_stencil = -1; - _clear_accum_red = -1.0f; - _clear_accum_green = -1.0f; - _clear_accum_blue = -1.0f; - _clear_accum_alpha = -1.0f; - // Set up the specific state values to GL's known initial values. - _shade_model_mode = GL_SMOOTH; GLP(FrontFace)(GL_CCW); - _scissor_x = 0; - _scissor_y = 0; - _scissor_width = -1; - _scissor_height = -1; - _viewport_x = 0; - _viewport_y = 0; - _viewport_width = -1; - _viewport_height = -1; - _lmodel_local = 0; - _lmodel_twoside = 0; - _line_width = 1.0f; - _point_size = 1.0f; - _blend_source_func = GL_ONE; - _blend_dest_func = GL_ZERO; - _depth_mask = false; - _fog_mode = GL_EXP; - _fog_density = 1.0f; - _fog_color.set(0.0f, 0.0f, 0.0f, 0.0f); - _alpha_func = GL_ALWAYS; - _alpha_func_ref = 0; - _polygon_mode = GL_FILL; - - _pack_alignment = 4; - _unpack_alignment = 4; - // Set up all the enabled/disabled flags to GL's known initial // values: everything off. _multisample_enabled = false; @@ -555,10 +516,10 @@ do_clear(const RenderBuffer &buffer) { CPT(RenderState) state = RenderState::make_empty(); if (buffer_type & RenderBuffer::T_color) { - call_glClearColor(_color_clear_value[0], - _color_clear_value[1], - _color_clear_value[2], - _color_clear_value[3]); + GLP(ClearColor)(_color_clear_value[0], + _color_clear_value[1], + _color_clear_value[2], + _color_clear_value[3]); state = state->add_attrib(ColorWriteAttrib::make(ColorWriteAttrib::M_on)); mask |= GL_COLOR_BUFFER_BIT; @@ -566,26 +527,24 @@ do_clear(const RenderBuffer &buffer) { } if (buffer_type & RenderBuffer::T_depth) { - call_glClearDepth(_depth_clear_value); + GLP(ClearDepth)(_depth_clear_value); mask |= GL_DEPTH_BUFFER_BIT; // In order to clear the depth buffer, the depth mask must enable // writing to the depth buffer. - if (!_depth_mask) { - state = state->add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_on)); - } + state = state->add_attrib(DepthWriteAttrib::make(DepthWriteAttrib::M_on)); } if (buffer_type & RenderBuffer::T_stencil) { - call_glClearStencil(_stencil_clear_value != false); + GLP(ClearStencil)(_stencil_clear_value != false); mask |= GL_STENCIL_BUFFER_BIT; } if (buffer_type & RenderBuffer::T_accum) { - call_glClearAccum(_accum_clear_value[0], - _accum_clear_value[1], - _accum_clear_value[2], - _accum_clear_value[3]); + GLP(ClearAccum)(_accum_clear_value[0], + _accum_clear_value[1], + _accum_clear_value[2], + _accum_clear_value[3]); mask |= GL_ACCUM_BUFFER_BIT; } @@ -636,8 +595,8 @@ prepare_display_region() { GLsizei height = GLsizei(h); enable_scissor( true ); - call_glScissor( x, y, width, height ); - call_glViewport( x, y, width, height ); + GLP(Scissor)( x, y, width, height ); + GLP(Viewport)( x, y, width, height ); } report_my_gl_errors(); } @@ -712,6 +671,8 @@ begin_frame() { _vertices_display_list_pcollector.clear_level(); #endif + _actual_display_region = NULL; + report_my_gl_errors(); return true; } @@ -762,7 +723,7 @@ draw_point(GeomPoint *geom, GeomContext *gc) { _vertices_other_pcollector.add_level(geom->get_num_vertices()); #endif - call_glPointSize(geom->get_size()); + GLP(PointSize)(geom->get_size()); issue_scene_graph_color(); int nprims = geom->get_num_prims(); @@ -831,7 +792,7 @@ draw_line(GeomLine *geom, GeomContext *gc) { _vertices_other_pcollector.add_level(geom->get_num_vertices()); #endif - call_glLineWidth(geom->get_width()); + GLP(LineWidth)(geom->get_width()); issue_scene_graph_color(); int nprims = geom->get_num_prims(); @@ -862,9 +823,9 @@ draw_line(GeomLine *geom, GeomContext *gc) { // Otherwise we want flat shading for performance reasons. if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -913,7 +874,7 @@ draw_linestrip(GeomLinestrip *geom, GeomContext *gc) { _vertices_other_pcollector.add_level(geom->get_num_vertices()); #endif - call_glLineWidth(geom->get_width()); + GLP(LineWidth)(geom->get_width()); issue_scene_graph_color(); int nprims = geom->get_num_prims(); @@ -945,9 +906,9 @@ draw_linestrip(GeomLinestrip *geom, GeomContext *gc) { // Otherwise we want flat shading for performance reasons. if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -1323,9 +1284,9 @@ draw_polygon(GeomPolygon *geom, GeomContext *gc) { // Otherwise we want flat shading for performance reasons. if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -1409,9 +1370,9 @@ draw_tri(GeomTri *geom, GeomContext *gc) { // Otherwise we want flat shading for performance reasons. if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -1493,9 +1454,9 @@ draw_quad(GeomQuad *geom, GeomContext *gc) { // Otherwise we want flat shading for performance reasons. if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -1577,9 +1538,9 @@ draw_tristrip(GeomTristrip *geom, GeomContext *gc) { // Otherwise we want flat shading for performance reasons. if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -1683,9 +1644,9 @@ draw_trifan(GeomTrifan *geom, GeomContext *gc) { // Otherwise we want flat shading for performance reasons. if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -1783,9 +1744,9 @@ draw_sphere(GeomSphere *geom, GeomContext *gc) { ti); if (wants_normals()) { - call_glShadeModel(GL_SMOOTH); + GLP(ShadeModel)(GL_SMOOTH); } else { - call_glShadeModel(GL_FLAT); + GLP(ShadeModel)(GL_FLAT); } // Draw overall @@ -2145,7 +2106,7 @@ texture_to_pixel_buffer(TextureContext *tc, PixelBuffer *pb, bool CLP(GraphicsStateGuardian):: copy_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr) { nassertr(pb != NULL && dr != NULL, false); - set_pack_alignment(1); + GLP(PixelStorei)(GL_PACK_ALIGNMENT, 1); // Bug fix for RE, RE2, and VTX - need to disable texturing in order // for GLP(ReadPixels)() to work @@ -2267,8 +2228,8 @@ void CLP(GraphicsStateGuardian)::apply_material(const Material *material) { GLP(Enable)(GL_COLOR_MATERIAL); } - call_glLightModelLocal(material->get_local()); - call_glLightModelTwoSide(material->get_twoside()); + GLP(LightModeli)(GL_LIGHT_MODEL_LOCAL_VIEWER, material->get_local()); + GLP(LightModeli)(GL_LIGHT_MODEL_TWO_SIDE, material->get_twoside()); report_my_gl_errors(); } @@ -2280,20 +2241,20 @@ void CLP(GraphicsStateGuardian)::apply_material(const Material *material) { void CLP(GraphicsStateGuardian):: apply_fog(Fog *fog) { Fog::Mode fmode = fog->get_mode(); - call_glFogMode(get_fog_mode_type(fmode)); + GLP(Fogi)(GL_FOG_MODE, get_fog_mode_type(fmode)); if (fmode == Fog::M_linear) { float onset, opaque; fog->get_linear_range(onset, opaque); - call_glFogStart(onset); - call_glFogEnd(opaque); + GLP(Fogf)(GL_FOG_START, onset); + GLP(Fogf)(GL_FOG_END, opaque); } else { // Exponential fog is always camera-relative. - call_glFogDensity(fog->get_exp_density()); + GLP(Fogf)(GL_FOG_DENSITY, fog->get_exp_density()); } - call_glFogColor(fog->get_color()); + GLP(Fogfv)(GL_FOG_COLOR, fog->get_color().get_data()); report_my_gl_errors(); } @@ -2543,12 +2504,12 @@ issue_render_mode(const RenderModeAttrib *attrib) { switch (mode) { case RenderModeAttrib::M_filled: - call_glPolygonMode(GL_FILL); + GLP(PolygonMode)(GL_FRONT_AND_BACK, GL_FILL); break; case RenderModeAttrib::M_wireframe: - call_glLineWidth(attrib->get_line_width()); - call_glPolygonMode(GL_LINE); + GLP(LineWidth)(attrib->get_line_width()); + GLP(PolygonMode)(GL_FRONT_AND_BACK, GL_LINE); break; default: @@ -2630,7 +2591,7 @@ issue_alpha_test(const AlphaTestAttrib *attrib) { enable_alpha_test(false); } else { assert(GL_NEVER==(AlphaTestAttrib::M_never-1+0x200)); - call_glAlphaFunc(PANDA_TO_GL_COMPAREFUNC(mode), attrib->get_reference_alpha()); + GLP(AlphaFunc)(PANDA_TO_GL_COMPAREFUNC(mode), attrib->get_reference_alpha()); enable_alpha_test(true); } } @@ -3353,7 +3314,7 @@ apply_texture_immediate(CLP(TextureContext) *gtc, Texture *tex) { nassertr(wanted_size == (int)pb->_image.size(), false); #endif // NDEBUG - set_unpack_alignment(1); + GLP(PixelStorei)(GL_UNPACK_ALIGNMENT, 1); #ifdef GSG_VERBOSE GLCAT.debug() @@ -3598,7 +3559,7 @@ draw_pixel_buffer(PixelBuffer *pb, const DisplayRegion *dr) { } set_transform(TransformState::make_identity()); - set_unpack_alignment(1); + GLP(PixelStorei)(GL_UNPACK_ALIGNMENT, 1); WindowProperties props = _win->get_properties(); @@ -4276,7 +4237,7 @@ set_blend_mode(ColorWriteAttrib::Mode color_write_mode, enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); enable_blend(true); - call_glBlendFunc(GL_ZERO, GL_ONE); + GLP(BlendFunc)(GL_ZERO, GL_ONE); return; } @@ -4289,21 +4250,21 @@ set_blend_mode(ColorWriteAttrib::Mode color_write_mode, enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); enable_blend(true); - call_glBlendFunc(GL_DST_COLOR, GL_ZERO); + GLP(BlendFunc)(GL_DST_COLOR, GL_ZERO); return; case ColorBlendAttrib::M_add: enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); enable_blend(true); - call_glBlendFunc(GL_ONE, GL_ONE); + GLP(BlendFunc)(GL_ONE, GL_ONE); return; case ColorBlendAttrib::M_multiply_add: enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); enable_blend(true); - call_glBlendFunc(GL_DST_COLOR, GL_ONE); + GLP(BlendFunc)(GL_DST_COLOR, GL_ONE); return; default: @@ -4331,7 +4292,7 @@ set_blend_mode(ColorWriteAttrib::Mode color_write_mode, enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); enable_blend(true); - call_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + GLP(BlendFunc)(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); return; case TransparencyAttrib::M_multisample: @@ -4747,7 +4708,7 @@ save_mipmap_images(Texture *tex) { int ysize = pb->get_ysize(); // Specify byte-alignment for the pixels on output. - set_pack_alignment(1); + GLP(PixelStorei)(GL_PACK_ALIGNMENT, 1); int mipmap_level = 0; do { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 4321ead1a7..7c254913d4 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -174,35 +174,6 @@ protected: CPT(DisplayRegion) dr); virtual void restore_frame_buffer(SavedFrameBuffer *frame_buffer); - INLINE void call_glClearColor(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha); - INLINE void call_glClearDepth(GLclampd depth); - INLINE void call_glClearStencil(GLint s); - INLINE void call_glClearAccum(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha); - INLINE void call_glShadeModel(GLenum mode); - INLINE void call_glBlendFunc(GLenum sfunc, GLenum dfunc); - INLINE void call_glCullFace(GLenum mode); - INLINE void call_glScissor(GLint x, GLint y, GLsizei width, GLsizei height); - INLINE void call_glViewport(GLint x, GLint y, GLsizei width, GLsizei height); - INLINE void call_glLightModelLocal(GLboolean local); - INLINE void call_glLightModelTwoSide(GLboolean twoside); - INLINE void call_glStencilFunc(GLenum func,GLint refval,GLuint mask); - INLINE void call_glStencilOp(GLenum fail,GLenum zfail,GLenum pass); - INLINE void call_glClipPlane(GLenum plane, const double equation[4]); - INLINE void call_glLineWidth(GLfloat width); - INLINE void call_glPointSize(GLfloat size); - INLINE void call_glFogMode(GLint mode); - INLINE void call_glFogStart(GLfloat start); - INLINE void call_glFogEnd(GLfloat end); - INLINE void call_glFogDensity(GLfloat density); - INLINE void call_glFogColor(const Colorf &color); - INLINE void call_glAlphaFunc(GLenum func, GLclampf ref); - INLINE void call_glPolygonMode(GLenum mode); - - INLINE void set_pack_alignment(GLint alignment); - INLINE void set_unpack_alignment(GLint alignment); - INLINE void enable_multisample(bool val); INLINE void enable_line_smooth(bool val); INLINE void enable_point_smooth(bool val); @@ -254,40 +225,6 @@ protected: void save_mipmap_images(Texture *tex); #endif - GLclampf _clear_color_red, _clear_color_green, _clear_color_blue, - _clear_color_alpha; - GLclampd _clear_depth; - GLint _clear_stencil; - GLclampf _clear_accum_red, _clear_accum_green, _clear_accum_blue, - _clear_accum_alpha; - GLenum _shade_model_mode; - GLint _scissor_x; - GLint _scissor_y; - GLsizei _scissor_width; - GLsizei _scissor_height; - GLint _viewport_x; - GLint _viewport_y; - GLsizei _viewport_width; - GLsizei _viewport_height; - GLboolean _lmodel_local; - GLboolean _lmodel_twoside; - GLfloat _line_width; - GLfloat _point_size; - GLenum _blend_source_func; - GLenum _blend_dest_func; - GLboolean _depth_mask; - GLint _fog_mode; - GLfloat _fog_start; - GLfloat _fog_end; - GLfloat _fog_density; - Colorf _fog_color; - GLenum _alpha_func; - GLclampf _alpha_func_ref; - GLenum _polygon_mode; - - GLint _pack_alignment; - GLint _unpack_alignment; - bool _multisample_enabled; bool _line_smooth_enabled; bool _point_smooth_enabled;