unwanted coloring...(blending??)
WHY DO MY TEXTURES BECOME GREEN??
I made a texture mapped cube (needless to say it is made up of 6 quads). it has 6 different bitmaps mapped onto the 6 faces of the cube. it works fine too, but if i try to draw a grid (with green vertical and horizontal lines) it makes all the textures on my cube also GREEN in color.. as in the textures are there but they dont have their original colors, now there are only shades of green.
Following is the code to draw the green grid, and i call this function right before making my texture mapped cube. i even tried calling this function after drawing my cube but no luck.
/*this function was taken from a tutorial by Ben Humphrey*/
void Draw3DGrid()
{
glColor3ub(0, 255, 0);
// Draw a 1x1 grid along the X and Z axis''
for(int i = -50; i <= 50; i += 1)
{
// Start drawing some lines
glBegin(GL_LINES);
// Do the horizontal lines (along the X)
glVertex3f(-50, 0, i);
glVertex3f(50, 0, i);
// Do the vertical lines (along the Z)
glVertex3f(i, 0, -50);
glVertex3f(i, 0, 50);
// Stop drawing lines
glEnd();
}
}
//CODE FOR DRAWGLSCENE:
void DrawGLScene(GLvoid)
{
g_Camera.Update();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); g_Camera.Look();
Draw3DSGrid();
glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS);
// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad
glEnd();
//... and so on for other quads.
glutSwapBuffers();
}
Could you please be more specific in what should i do with glEnable(GL_TEXTURE_2D)? Do i need to disable/enable at more than one places e.g. before or after drawing the grid or the cube? i am just a beginner in opengl, please help.
Following is what i have done in my initializer function:
void InitGL(.. )
{
LoadGLTextures();
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_TEXTURE_2D);
g_Camera.PositionCamera(0, 1.5f, 6, 0, 1.5f, 0, 0, 1, 0);
ShowCursor(false);
}
Anyone? any ideas? please...
Following is what i have done in my initializer function:
void InitGL(.. )
{
LoadGLTextures();
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_TEXTURE_2D);
g_Camera.PositionCamera(0, 1.5f, 6, 0, 1.5f, 0, 0, 1, 0);
ShowCursor(false);
}
Anyone? any ideas? please...
Try glColor3f(1,1,1) before drawing.
EDIT:
That should have been *after* your grid is drawn and before drawing the rest of your scene. What is happening is that when you set the green colour for the grid, that colour is then used for all drawing after that call, unless you change it. (note the Color3f could be Color3ub(255,255,255) if you prefer.
[edited by - JuNC on April 13, 2003 6:59:17 PM]
EDIT:
That should have been *after* your grid is drawn and before drawing the rest of your scene. What is happening is that when you set the green colour for the grid, that colour is then used for all drawing after that call, unless you change it. (note the Color3f could be Color3ub(255,255,255) if you prefer.
[edited by - JuNC on April 13, 2003 6:59:17 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement