From beae245e5add238d58d9711f342b4b1e6b9f01dc Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Wed, 27 Mar 2002 04:44:44 +0000 Subject: [PATCH] sync with glgsg --- panda/src/crgsg/crGraphicsStateGuardian.I | 2 +- panda/src/crgsg/crGraphicsStateGuardian.cxx | 82 +++++++++++---------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/panda/src/crgsg/crGraphicsStateGuardian.I b/panda/src/crgsg/crGraphicsStateGuardian.I index cb33e40d9f..6f6452e38f 100644 --- a/panda/src/crgsg/crGraphicsStateGuardian.I +++ b/panda/src/crgsg/crGraphicsStateGuardian.I @@ -331,7 +331,7 @@ INLINE void CRGraphicsStateGuardian:: call_glStencilOp(GLenum fail,GLenum zfail,GLenum zpass) { #ifdef GSG_VERBOSE crgsg_cat.debug() << "crStencilOp(fail, zfail, "; - switch (op) { + switch (zpass) { case GL_KEEP: crgsg_cat.debug(false) << "GL_KEEP)"; break; diff --git a/panda/src/crgsg/crGraphicsStateGuardian.cxx b/panda/src/crgsg/crGraphicsStateGuardian.cxx index ed53a5d59c..570ba3b648 100644 --- a/panda/src/crgsg/crGraphicsStateGuardian.cxx +++ b/panda/src/crgsg/crGraphicsStateGuardian.cxx @@ -983,7 +983,6 @@ draw_sprite(GeomSprite *geom, GeomContext *) { // will certainly look close enough. Then, we transform to camera-space // by hand and apply the inverse frustum to the transformed point. // For some cracked out reason, this actually works. - #ifdef GSG_VERBOSE crgsg_cat.debug() << "draw_sprite()" << endl; #endif @@ -1010,35 +1009,27 @@ draw_sprite(GeomSprite *geom, GeomContext *) { Texture *tex = geom->get_texture(); if(tex != NULL) { - // set up the texture-rendering state - NodeTransitions state; - - TextureTransition *ta = new TextureTransition; - ta->set_on(tex); - state.set_transition(ta); - - TextureApplyTransition *taa = new TextureApplyTransition; - taa->set_mode(TextureApplyProperty::M_modulate); - state.set_transition(taa); - - modify_state(state); - - tex_xsize = tex->_pbuffer->get_xsize(); - tex_ysize = tex->_pbuffer->get_ysize(); + // set up the texture-rendering state + modify_state(RenderState::make + (TextureAttrib::make(tex), + TextureApplyAttrib::make(TextureApplyAttrib::M_modulate))); + tex_xsize = tex->_pbuffer->get_xsize(); + tex_ysize = tex->_pbuffer->get_ysize(); } // save the modelview matrix - LMatrix4f modelview_mat; - - const TransformTransition *ctatt; - if (!get_attribute_into(ctatt, this)) - modelview_mat = LMatrix4f::ident_mat(); - else - modelview_mat = ctatt->get_matrix(); + const LMatrix4f &modelview_mat = _transform->get_mat(); // get the camera information - float aspect_ratio = - get_current_camera()->get_lens()->get_aspect_ratio(); + + // Hmm, this doesn't work any more, since we don't store the camera + // pointer in new scene graph land. Need to find a better way to + // get the current window's aspect ratio. Here's a temporary hack + // for now. + + // float aspect_ratio = + // get_current_camera()->get_lens()->get_aspect_ratio(); + float aspect_ratio = 1.333333; // load up our own matrices chromium.MatrixMode(GL_MODELVIEW); @@ -1058,11 +1049,12 @@ draw_sprite(GeomSprite *geom, GeomContext *) { // the user can override alpha sorting if they want bool alpha = false; - if (geom->get_alpha_disable() == false) { + if (!geom->get_alpha_disable()) { // figure out if alpha's enabled (if not, no reason to sort) - const TransparencyTransition *ctratt; - if (get_attribute_into(ctratt, this)) - alpha = (ctratt->get_mode() != TransparencyProperty::M_none); + const TransparencyAttrib *trans = _qpstate->get_transparency(); + if (trans != (const TransparencyAttrib *)NULL) { + alpha = (trans->get_mode() != TransparencyAttrib::M_none); + } } // sort container and iterator @@ -1088,7 +1080,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) { bool theta_on = !(geom->get_theta_bind_type() == G_OFF); // x direction - if (x_overall == true) + if (x_overall) scaled_width = geom->_x_texel_ratio[0] * half_width; else { nassertv(((int)geom->_x_texel_ratio.size() >= geom->get_num_prims())); @@ -1096,7 +1088,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) { } // y direction - if (y_overall == true) + if (y_overall) scaled_height = geom->_y_texel_ratio[0] * half_height * aspect_ratio; else { nassertv(((int)geom->_y_texel_ratio.size() >= geom->get_num_prims())); @@ -1105,7 +1097,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) { // theta if (theta_on) { - if (theta_overall == true) + if (theta_overall) theta = geom->_theta[0]; else { nassertv(((int)geom->_theta.size() >= geom->get_num_prims())); @@ -1132,14 +1124,14 @@ draw_sprite(GeomSprite *geom, GeomContext *) { // build the final object that will go into the vector. ws._v.set(cameraspace_vert[0],cameraspace_vert[1],cameraspace_vert[2]); - if (color_overall == false) + if (!color_overall) ws._c = geom->get_next_color(ci); - if (x_overall == false) + if (!x_overall) ws._x_ratio = *x_walk++; - if (y_overall == false) + if (!y_overall) ws._y_ratio = *y_walk++; if (theta_on) { - if (theta_overall == false) + if (!theta_overall) ws._theta = *theta_walk++; } @@ -1154,13 +1146,13 @@ draw_sprite(GeomSprite *geom, GeomContext *) { sort(cameraspace_vector.begin(), cameraspace_vector.end(), draw_sprite_vertex_less()); - if(_dithering_enabled) + if (_dithering_enabled) chromium.Disable(GL_DITHER); } Vertexf ul, ur, ll, lr; - if (color_overall == true) + if (color_overall) chromium.Color4fv(geom->get_next_color(ci).get_data()); //////////////////////////////////////////////////////////////////////////// @@ -3946,7 +3938,13 @@ void report_errors_loop(GLenum error_code) { #define MAXGLERRORSREPORTED 20 int cnt=0; while ((cnt