Original Post
SOLVED
I've been following several tutorials on OpenGL and I cannot for the life of me get the texture to show up. can someone let me know what I'm doing wrong?
Edit for more clarity: I get a white box. So I can see the quad, but not the texture that should be on top of it. I am using Visual Studio 2010 for compilation and freeGLUT for handling the windowing API.
Edit: glGetError returns 1282 from the start of main until the first call in the resize function.
My load texture function:
My display function:
I've been following several tutorials on OpenGL and I cannot for the life of me get the texture to show up. can someone let me know what I'm doing wrong?
Edit for more clarity: I get a white box. So I can see the quad, but not the texture that should be on top of it. I am using Visual Studio 2010 for compilation and freeGLUT for handling the windowing API.
Edit: glGetError returns 1282 from the start of main until the first call in the resize function.
My load texture function:
char* fileName = "..\\Assets\\ARG.bmp";
GLubyte *TextureImage[1];
memset(TextureImage,0,sizeof(void *)*1);
TextureImage[0] = LoadDIBitmap(fileName, &BitmapInfo);
glEnable( GL_TEXTURE_2D );
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glGenTextures(1, &textures[0]);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, BitmapInfo->bmiHeader.biWidth,
BitmapInfo->bmiHeader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
TextureImage[0]);My display function:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-5.0f);
glEnable (GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glBegin (GL_QUADS);
glTexCoord2d(0.0,0.0); glVertex2d(-1.0,-1.0);
glTexCoord2d(1.0,0.0); glVertex2d(+1.0,-1.0);
glTexCoord2d(1.0,1.0); glVertex2d(+1.0,+1.0);
glTexCoord2d(0.0,1.0); glVertex2d(-1.0,+1.0);
glEnd();
//glDisable (GL_TEXTURE_2D);
glutSwapBuffers();