Advertisement

Texturing and Multitexturing

Started by December 20, 2002 09:31 AM
11 comments, last by wolf_2002 22 years, 2 months ago
It will not disable both textures. According to OpenGL''s machine state mechanim, it will disable the last activated texture. That is, it will disable GL_TEXTURE1_ARB.

At this point, GL_TEXTURE1_ARB is still activated, but I guess you may want to activate GL_TEXTURE0_ARB so that next texture calls will affect the texture unit 0.

For instance, let''s append the following lines of code :
glBindTexture(GL_TEXTURE_2D, quadric_texture);
render_the_quadric();

The resulting code is :

  glActiveTextureARB(GL_TEXTURE0_ARB);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, m_texture[0]);glActiveTextureARB(GL_TEXTURE1_ARB);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, m_texture[1]);glBegin(GL_TRIANGLES);glNormal3f( 0.0f, 0.0f, 1.0f);glColor3f(m_red1,m_green1,m_blue1);glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.5f, 1.0f);glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.5f, 1.0f);glVertex3f( 0.0f, m_height, 0.0f);// TopglColor3f(m_red2,m_green2,m_blue2);glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);glVertex3f(-m_width,-m_height, 0.0f);// Bottom LeftglColor3f(m_red3,m_green3,m_blue3);glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f);glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f);glVertex3f( m_width,-m_height, 0.0f);// Bottom RightglEnd();glPopMatrix();glDisable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, quadric_texture);render_the_quadric();  

Do you think that those two last lines bind the texture ''quadric_texture'' to texture unit 0 ? false ! It binds it to texture unit 1 because it is the last texture that was activated (note: don''t mistake "activating" a texture unit and "enabling" a texture unit). In other words, you have to call glActiveTextureARB(GL_TEXTURE0_ARB) after rendering a multitextured object, otherwise you don''t know if the following objects will be rendered using the right texture unit.
ok thanks a lot,
this help (i hope ;-) )

Any Object that i render with multitexturescalls looks good (i have no Problem with this) with this:

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_texture[0]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_texture[1]);

glBegin(GL_TRIANGLES);

glNormal3f( 0.0f, 0.0f, 1.0f);
glColor3f(m_red1,m_green1,m_blue1);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.5f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.5f, 1.0f);
glVertex3f( 0.0f, m_height, 0.0f);
.
.
.
.
I can render one from both or all together only the first/last all works

thats not the Problem for now. My Problem is i can''t render my Bitmapfont with the ''Standard'' Texturecalls (in a other class defined) like this

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fTexture[0]);
glDisable(GL_DEPTH_TEST);
.
.
.

my Textures are black, when i don''t render the multitextureobject, my Font works pretty good.

or have i misunderstood you ?????



Advertisement
Oh God,
now i know what you mean,
sorry yesterday wasn''t a god Day ;-)

Thanks a LOT!!!!

regards Wolf


This topic is closed to new replies.

Advertisement