Jump to content
  • Advertisement
Sign in to follow this  

OpenGL texture mapping question

This topic is 5463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm a bit new to OpenGl, and i'm just trying to map a texture onto a polygon. I'm pretty familiar with the process at this point, but for some reason it won't do anything except draw a white rectangle on the screen and its driving me InSaNe!! Heres the key parts of the code. Can anyone tell me what i'm missing? GLuint texture[4]; void init(void) { ImageLoad("Grass.bmp", &grass); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glGenTextures(1, texture); for (int i = 0; i < 4; i++) { glBindTexture(GL_TEXTURE_2D, texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, grass.sizeX, grass.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, grass.data); } ... } void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(0, 25, 60, 0, 10, 0, 0, 1, 0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3f( 10.0f, 10.0f, 10.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0f, 10.0f, 10.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0f, 10.0f, -10.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 10.0f, 10.0f, -10.0f); glEnd(); glutSwapBuffers(); }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!