resolve confusion with tex_gen and tex_mat interrelations

This commit is contained in:
David Rose 2005-03-05 03:53:01 +00:00
parent 53f446569e
commit 3b8c754898
2 changed files with 16 additions and 3 deletions

View File

@ -611,6 +611,7 @@ reset() {
_needs_tex_mat = false;
_current_tex_gen = DCAST(TexGenAttrib, TexGenAttrib::make());
_needs_tex_gen = false;
_tex_gen_modifies_mat = false;
_auto_antialias_mode = false;
_render_mode = RenderModeAttrib::M_filled;
@ -4597,8 +4598,17 @@ finish_modify_state() {
do_issue_texture();
}
// If one of the previously-loaded TexGen modes modified the texture
// matrix, then if either state changed, we have to change both of
// them now.
if (_tex_gen_modifies_mat &&
(_needs_tex_mat || _needs_tex_gen)) {
_needs_tex_mat = true;
_needs_tex_gen = true;
}
// Apply the texture matrix, if needed.
if (_needs_tex_mat || _needs_tex_gen) {
if (_needs_tex_mat) {
_needs_tex_mat = false;
int num_stages = _current_texture->get_num_on_stages();
@ -4643,6 +4653,8 @@ finish_modify_state() {
static const float r_data[4] = { 0, 0, 1, 0 };
static const float q_data[4] = { 0, 0, 0, 1 };
_tex_gen_modifies_mat = false;
for (int i = 0; i < num_stages; i++) {
TextureStage *stage = _current_texture->get_on_stage(i);
_glActiveTexture(GL_TEXTURE0 + i);
@ -4685,7 +4697,7 @@ finish_modify_state() {
// Now we need to reset the texture matrix next time
// around to undo this.
_needs_tex_mat = true;
_tex_gen_modifies_mat = true;
}
GLP(TexGeni)(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
@ -4723,7 +4735,7 @@ finish_modify_state() {
// Now we need to reset the texture matrix next time
// around to undo this.
_needs_tex_mat = true;
_tex_gen_modifies_mat = true;
}
GLP(TexGeni)(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);

View File

@ -276,6 +276,7 @@ protected:
bool _needs_tex_mat;
CPT(TexGenAttrib) _current_tex_gen;
bool _needs_tex_gen;
bool _tex_gen_modifies_mat;
bool _auto_antialias_mode;
RenderModeAttrib::Mode _render_mode;