sync with glgsg

This commit is contained in:
Dave Schuyler 2002-03-27 04:44:44 +00:00
parent 9e741771f6
commit beae245e5a
2 changed files with 44 additions and 40 deletions

View File

@ -331,7 +331,7 @@ INLINE void CRGraphicsStateGuardian::
call_glStencilOp(GLenum fail,GLenum zfail,GLenum zpass) { call_glStencilOp(GLenum fail,GLenum zfail,GLenum zpass) {
#ifdef GSG_VERBOSE #ifdef GSG_VERBOSE
crgsg_cat.debug() << "crStencilOp(fail, zfail, "; crgsg_cat.debug() << "crStencilOp(fail, zfail, ";
switch (op) { switch (zpass) {
case GL_KEEP: case GL_KEEP:
crgsg_cat.debug(false) << "GL_KEEP)"; crgsg_cat.debug(false) << "GL_KEEP)";
break; break;

View File

@ -983,7 +983,6 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
// will certainly look close enough. Then, we transform to camera-space // will certainly look close enough. Then, we transform to camera-space
// by hand and apply the inverse frustum to the transformed point. // by hand and apply the inverse frustum to the transformed point.
// For some cracked out reason, this actually works. // For some cracked out reason, this actually works.
#ifdef GSG_VERBOSE #ifdef GSG_VERBOSE
crgsg_cat.debug() << "draw_sprite()" << endl; crgsg_cat.debug() << "draw_sprite()" << endl;
#endif #endif
@ -1010,35 +1009,27 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
Texture *tex = geom->get_texture(); Texture *tex = geom->get_texture();
if(tex != NULL) { if(tex != NULL) {
// set up the texture-rendering state // set up the texture-rendering state
NodeTransitions state; modify_state(RenderState::make
(TextureAttrib::make(tex),
TextureTransition *ta = new TextureTransition; TextureApplyAttrib::make(TextureApplyAttrib::M_modulate)));
ta->set_on(tex); tex_xsize = tex->_pbuffer->get_xsize();
state.set_transition(ta); tex_ysize = tex->_pbuffer->get_ysize();
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();
} }
// save the modelview matrix // save the modelview matrix
LMatrix4f modelview_mat; const LMatrix4f &modelview_mat = _transform->get_mat();
const TransformTransition *ctatt;
if (!get_attribute_into(ctatt, this))
modelview_mat = LMatrix4f::ident_mat();
else
modelview_mat = ctatt->get_matrix();
// get the camera information // 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 // load up our own matrices
chromium.MatrixMode(GL_MODELVIEW); chromium.MatrixMode(GL_MODELVIEW);
@ -1058,11 +1049,12 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
// the user can override alpha sorting if they want // the user can override alpha sorting if they want
bool alpha = false; 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) // figure out if alpha's enabled (if not, no reason to sort)
const TransparencyTransition *ctratt; const TransparencyAttrib *trans = _qpstate->get_transparency();
if (get_attribute_into(ctratt, this)) if (trans != (const TransparencyAttrib *)NULL) {
alpha = (ctratt->get_mode() != TransparencyProperty::M_none); alpha = (trans->get_mode() != TransparencyAttrib::M_none);
}
} }
// sort container and iterator // sort container and iterator
@ -1088,7 +1080,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
bool theta_on = !(geom->get_theta_bind_type() == G_OFF); bool theta_on = !(geom->get_theta_bind_type() == G_OFF);
// x direction // x direction
if (x_overall == true) if (x_overall)
scaled_width = geom->_x_texel_ratio[0] * half_width; scaled_width = geom->_x_texel_ratio[0] * half_width;
else { else {
nassertv(((int)geom->_x_texel_ratio.size() >= geom->get_num_prims())); nassertv(((int)geom->_x_texel_ratio.size() >= geom->get_num_prims()));
@ -1096,7 +1088,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
} }
// y direction // y direction
if (y_overall == true) if (y_overall)
scaled_height = geom->_y_texel_ratio[0] * half_height * aspect_ratio; scaled_height = geom->_y_texel_ratio[0] * half_height * aspect_ratio;
else { else {
nassertv(((int)geom->_y_texel_ratio.size() >= geom->get_num_prims())); nassertv(((int)geom->_y_texel_ratio.size() >= geom->get_num_prims()));
@ -1105,7 +1097,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
// theta // theta
if (theta_on) { if (theta_on) {
if (theta_overall == true) if (theta_overall)
theta = geom->_theta[0]; theta = geom->_theta[0];
else { else {
nassertv(((int)geom->_theta.size() >= geom->get_num_prims())); 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. // build the final object that will go into the vector.
ws._v.set(cameraspace_vert[0],cameraspace_vert[1],cameraspace_vert[2]); 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); ws._c = geom->get_next_color(ci);
if (x_overall == false) if (!x_overall)
ws._x_ratio = *x_walk++; ws._x_ratio = *x_walk++;
if (y_overall == false) if (!y_overall)
ws._y_ratio = *y_walk++; ws._y_ratio = *y_walk++;
if (theta_on) { if (theta_on) {
if (theta_overall == false) if (!theta_overall)
ws._theta = *theta_walk++; ws._theta = *theta_walk++;
} }
@ -1154,13 +1146,13 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
sort(cameraspace_vector.begin(), cameraspace_vector.end(), sort(cameraspace_vector.begin(), cameraspace_vector.end(),
draw_sprite_vertex_less()); draw_sprite_vertex_less());
if(_dithering_enabled) if (_dithering_enabled)
chromium.Disable(GL_DITHER); chromium.Disable(GL_DITHER);
} }
Vertexf ul, ur, ll, lr; Vertexf ul, ur, ll, lr;
if (color_overall == true) if (color_overall)
chromium.Color4fv(geom->get_next_color(ci).get_data()); chromium.Color4fv(geom->get_next_color(ci).get_data());
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -3946,7 +3938,13 @@ void report_errors_loop(GLenum error_code) {
#define MAXGLERRORSREPORTED 20 #define MAXGLERRORSREPORTED 20
int cnt=0; int cnt=0;
while ((cnt<MAXGLERRORSREPORTED) && (error_code != GL_NO_ERROR)) { while ((cnt<MAXGLERRORSREPORTED) && (error_code != GL_NO_ERROR)) {
crgsg_cat.error() << gluErrorString(error_code) << "\n"; const GLubyte *error_string = gluErrorString(error_code);
if (error_string != (const GLubyte *)NULL) {
crgsg_cat.error() << error_string << "\n";
} else {
crgsg_cat.error()
<< "Error number " << (int)error_code << "; no string available.\n";
}
error_code = chromium.GetError(); error_code = chromium.GetError();
cnt++; cnt++;
} }
@ -5477,6 +5475,7 @@ ostream &output_cr_enum(ostream &out, GLenum v) {
return out << "GL_ONE_MINUS_DST_ALPHA"; return out << "GL_ONE_MINUS_DST_ALPHA";
case GL_SRC_ALPHA_SATURATE: case GL_SRC_ALPHA_SATURATE:
return out << "GL_SRC_ALPHA_SATURATE"; return out << "GL_SRC_ALPHA_SATURATE";
#ifdef USING_OPENGL_1_2 //[
case GL_CONSTANT_COLOR: case GL_CONSTANT_COLOR:
return out << "GL_CONSTANT_COLOR"; return out << "GL_CONSTANT_COLOR";
case GL_ONE_MINUS_CONSTANT_COLOR: case GL_ONE_MINUS_CONSTANT_COLOR:
@ -5485,6 +5484,7 @@ ostream &output_cr_enum(ostream &out, GLenum v) {
return out << "GL_CONSTANT_ALPHA"; return out << "GL_CONSTANT_ALPHA";
case GL_ONE_MINUS_CONSTANT_ALPHA: case GL_ONE_MINUS_CONSTANT_ALPHA:
return out << "GL_ONE_MINUS_CONSTANT_ALPHA"; return out << "GL_ONE_MINUS_CONSTANT_ALPHA";
#endif //]
/* Render Mode */ /* Render Mode */
case GL_FEEDBACK: case GL_FEEDBACK:
@ -6076,6 +6076,7 @@ ostream &output_cr_enum(ostream &out, GLenum v) {
*/ */
/* GL 1.2 texturing */ /* GL 1.2 texturing */
#ifdef USING_OPENGL_1_2 //[
case GL_PACK_SKIP_IMAGES: case GL_PACK_SKIP_IMAGES:
return out << "GL_PACK_SKIP_IMAGES"; return out << "GL_PACK_SKIP_IMAGES";
case GL_PACK_IMAGE_HEIGHT: case GL_PACK_IMAGE_HEIGHT:
@ -6098,6 +6099,7 @@ ostream &output_cr_enum(ostream &out, GLenum v) {
case GL_TEXTURE_BINDING_3D: case GL_TEXTURE_BINDING_3D:
return out << "GL_TEXTURE_BINDING_3D"; return out << "GL_TEXTURE_BINDING_3D";
#endif #endif
#endif //]
/* Internal texture formats (GL 1.1) */ /* Internal texture formats (GL 1.1) */
case GL_ALPHA4: case GL_ALPHA4:
@ -6192,6 +6194,7 @@ ostream &output_cr_enum(ostream &out, GLenum v) {
return out << "GL_OUT_OF_MEMORY"; return out << "GL_OUT_OF_MEMORY";
/* OpenGL 1.2 */ /* OpenGL 1.2 */
#ifdef USING_OPENGL_1_2 //[
case GL_RESCALE_NORMAL: case GL_RESCALE_NORMAL:
return out << "GL_RESCALE_NORMAL"; return out << "GL_RESCALE_NORMAL";
case GL_CLAMP_TO_EDGE: case GL_CLAMP_TO_EDGE:
@ -6242,6 +6245,7 @@ ostream &output_cr_enum(ostream &out, GLenum v) {
return out << "GL_TEXTURE_BASE_LEVEL"; return out << "GL_TEXTURE_BASE_LEVEL";
case GL_TEXTURE_MAX_LEVEL: case GL_TEXTURE_MAX_LEVEL:
return out << "GL_TEXTURE_MAX_LEVEL"; return out << "GL_TEXTURE_MAX_LEVEL";
#endif //]
} }
return out << (int)v; return out << (int)v;