texture mapping question

Started by
0 comments, last by jluqu 19 years, 6 months ago
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(); }
Advertisement
nevermind, was trying to map a image with length/width not a power of 2

This topic is closed to new replies.

Advertisement