Ok, here it is. I started learning OpenGL about 6-7 months back, and i got to NeHe's 6th tutorial. Then i had to stop, because i couldnt get textures to work. So i learned DX. I thaught i would try OpenGL again, and im at lesson 6, and i am having the exact same problem. I think the problem is when im trying to either load or display my image. Here are the three functions that take care of that.
Load Textures:
int LoadTextures()
{
int Status=false;
AUX_RGBImageRec *TextureImage[1];
memset(TextureImage, 0, sizeof(void *)*1);
if(TextureImage[0]=LoadBMP("C:\\Damian\\PROGRAMMINGPROJECTS\\FireflyOpenGL\\Data\\Images\\File.bmp"))
{
Status=true;
glGenTextures(1, &Texture[0]);
glBindTexture(GL_TEXTURE_2D, Texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0,3,TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if(TextureImage[0])
{
if(TextureImage[0]->data)
{
memset(TextureImage[0]->data, 0, sizeof(TextureImage[0]->data));
}
memset(TextureImage[0], 0, sizeof(TextureImage[0]));
}
return(Status);
}
DrawGLScene:
int GLDrawScene(GLvoid) //Draws the OpenGL Scene
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the Screen each frame
//World Stuff
glLoadIdentity(); //Load the Identity
glTranslatef(-1.5f, 0.0f, -12.0f); //Drawing
glRotatef(RotX, 1.0f, 0.0f, 0.0f);
glRotatef(RotY, 0.0f, 1.0f, 0.0f);
glRotatef(RotZ, 0.0f, 0.0f, 1.0f);
glBindTexture(GL_TEXTURE_2D, Texture[0]);
//Pyramid
glBegin(GL_TRIANGLES);
//Top Point(front)
glTexCoord2f(0.5f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f);
//Bottom Left hand corner(front)
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,-1.0f,1.0f);
//Bottom Right Hand Corner(front)
glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, -1.0f,1.0f);
//Top Point(Right)
glTexCoord2f(0.5f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f);
//Bottom Left hand corner(Right)
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,-1.0f,-1.0f);
//Bottom Right Hand Corner(Right)
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f,1.0f);
//Top Point(back)
glTexCoord2f(0.5f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f);
//Bottom Left hand corner(back)
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,-1.0f, -1.0f);
//Bottom Right Hand Corner(back)
glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, -1.0f,-1.0f);
//Top Point(left)
glTexCoord2f(0.5f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f);
//Bottom Left hand corner(left)
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,-1.0f,-1.0f);
//Bottom Right Hand Corner(left)
glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, -1.0f,1.0f);
glEnd();
//World Stuff
glLoadIdentity();
glTranslatef(1.5f, 0.0f, -12.0f);
glRotatef(RotX, 1.0f, 0.0f, 0.0f);
glRotatef(RotY, 0.0f, 1.0f, 0.0f);
glRotatef(RotZ, 0.0f, 0.0f, 1.0f);
//Cube
glBegin(GL_QUADS);
//Top
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f, 1.0f,1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f( 1.0f, 1.0f,1.0f);
glTexCoord2f(1.0f,1.0f); glVertex3f( 1.0f, 1.0f,-1.0f);
glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f, 1.0f,-1.0f);
//Front
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f( 1.0f,-1.0f, 1.0f);
glTexCoord2f(1.0f,1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
//Left
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f,1.0f); glVertex3f(-1.0f, 1.0f,-1.0f);
glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f);
//Bottom
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f( 1.0f,-1.0f, 1.0f);
glTexCoord2f(1.0f,1.0f); glVertex3f( 1.0f,-1.0f,-1.0f);
glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f);
//Back
glTexCoord2f(0.0f,0.0f); glVertex3f(-1.0f, 1.0f,-1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f( 1.0f, 1.0f,-1.0f);
glTexCoord2f(1.0f,1.0f); glVertex3f( 1.0f,-1.0f,-1.0f);
glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f);
//Right
glTexCoord2f(0.0f,0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f,1.0f); glVertex3f( 1.0f, -1.0f,-1.0f);
glTexCoord2f(0.0f,1.0f); glVertex3f( 1.0f, 1.0f,-1.0f);
glEnd();
//Rotation
RotX+=0.1f;
RotZ+=0.2f;
RotY+=0.3f;
return(true); //Return Success
}
LoadBMP:
AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if(!Filename)
{
return(NULL);
}
File=fopen(Filename, "r");
if(File)
{
fclose(File);
return(auxDIBImageLoad(Filename));
}
return(NULL);
}
Here is The specific problem:
It doesnt display the actual texture. I tried removing the color, thinking it was overriding the picture or something, but it didnt work.
If you want any other part of the code tell me. I would have come to you 2 days ago when i started having the problem, but i wanted to try to find it myself.
P.S. Oh ya, and it also wont display anything but a screenshot of my desktop in Fullscreen mode if that helps.
______________________________
Quantum
CEO of Quantum Rebound Software
Website Up Soon
[edited by - QReboundSoftware on August 9, 2003 9:20:32 AM]
______________________________QuantumCEO of Quantum Rebound SoftwareWebsite Up Soon