02-16-2001, 10:18 AM
Hi I was trying to render objects with textures and without in the same scene and the code I wrote came something like
(imagine that I already initialized everything and read the textures,and named(glGentextures) then and defined then(glTexImage2D))
void draw()
{
//first draw the textured triangle
glEnable(GL_TEXTURE_2D);
glBind(GL_TEXTURE_2D,TextureName);
glBegin(GL_TRIANGLE);
glTexCoord2f(...);glVertex3f(...)
glTexCoord2f(...);glVertex3f(...)
glTexCoord2f(...);glVertex3f(...)
glEnd();
glBind(GL_TEXTURE_2D,0);
glDisable(GL_TEXTURE_2D);
//then draw the colored triangle
glBegin(GL_TRIANGLES);
glColor3f(1,0,0);glVertex3f(...);
glColor3f(0,1,0);glVertex3f(...);
glColor3f(0,0,1);glVertex3f(...);
glEnd();
}
I first enable texturing , set the actual texture , and draw the triangle with textures , then I disabled texturing and the use of textured objects and I draw the second triangle. But this doesnt work! When I do this ALL the scene is painted as the last color of the second triangle! Evererything turns blue! Please can anyone enlight-me of whats going on and how to solve this?
-My hat!
Fisban
(imagine that I already initialized everything and read the textures,and named(glGentextures) then and defined then(glTexImage2D))
void draw()
{
//first draw the textured triangle
glEnable(GL_TEXTURE_2D);
glBind(GL_TEXTURE_2D,TextureName);
glBegin(GL_TRIANGLE);
glTexCoord2f(...);glVertex3f(...)
glTexCoord2f(...);glVertex3f(...)
glTexCoord2f(...);glVertex3f(...)
glEnd();
glBind(GL_TEXTURE_2D,0);
glDisable(GL_TEXTURE_2D);
//then draw the colored triangle
glBegin(GL_TRIANGLES);
glColor3f(1,0,0);glVertex3f(...);
glColor3f(0,1,0);glVertex3f(...);
glColor3f(0,0,1);glVertex3f(...);
glEnd();
}
I first enable texturing , set the actual texture , and draw the triangle with textures , then I disabled texturing and the use of textured objects and I draw the second triangle. But this doesnt work! When I do this ALL the scene is painted as the last color of the second triangle! Evererything turns blue! Please can anyone enlight-me of whats going on and how to solve this?
-My hat!
Fisban