Note that there are some explanatory texts on larger screens.

plurals
  1. POopenGL texture mapping
    text
    copied!<p>Hey, I am creating a game using openGL in c++ when I try and map a texture to an object it changes the colour of everything else I have drawn eg everything goes a transparent red or green..</p> <pre><code>glEnable (GL_TEXTURE_2D); Bitmap image; image.loadBMP ("Texture.bmp"); glGenTextures(1, &amp;m_TextureID); glBindTexture ( GL_TEXTURE_2D, m_TextureID); glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_MODULATE); glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); gluBuild2DMipmaps ( GL_TEXTURE_2D, 3, image.width, image.height, GL_RGB, GL_UNSIGNED_BYTE, image.data); glEnd(); </code></pre> <p>this is my texture code and here is how i am mapping the texture</p> <pre><code>glBegin(GL_QUADS); glEnable (GL_TEXTURE_2D); //glColor3d(1, 0, 0); glTexCoord2f (0.0f,0.0f); glVertex3f(0, 0, 0); // bottom left glTexCoord2f (1.0f,0.0f); glVertex3f(10, 0, 0); // bottom right glTexCoord2f (1.0f,1.0f); glVertex3f(10, 0.6, 0);// top right glTexCoord2f (0.0f,1.0f); glVertex3f(0, 0.6, 0); // top left glEnd(); </code></pre> <p>etc...</p> <p>all my non textured objects are drawn like this</p> <pre><code>glBegin(GL_QUADS);//BACK glColor3d(1,0,0); glVertex3f(10, 0, 0); glVertex3f(10, 0, -5.6); glVertex3f(10, 0.6, -5.6); glVertex3f(10, 0.6, 0); glEnd(); </code></pre> <p>etc... am i missing something really obvious ? thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload