Ok, the following is the code for textures.h, which has my LoadGLTextures() function.
Please bear with me, because I really don't have much of an idea how to do this right at all:
Code:
AUX_RGBImageRec *LoadBMP(char *Filename);
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator, Nothing's Happened Yet.
AUX_RGBImageRec *TextureImage[2]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL, Clear Image Record
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP("C:/Documents and Settings/Dean/My Documents/My Pictures/gamesprites/tilegrass.bmp"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(1, &texture[0]); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
// Generate The Texture
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); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}
free(TextureImage[0]); // Free The Image Structure
}
if (TextureImage[1]=LoadBMP("C:/Documents and Settings/Dean/My Documents/My Pictures/gamesprites/s1.bmp"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(1, &texture[1]); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[1]);
// Generate The Texture
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
}
if (TextureImage[1]) // If Texture Exists
{
if (TextureImage[1]->data) // If Texture Image Exists
{
free(TextureImage[1]->data); // Free The Texture Image Memory
}
free(TextureImage[1]); // Free The Image Structure
}
return Status; // Return The Status
}
...and this is the code for my function that draws polygons:
Code:
glLoadIdentity();
glTranslatef(0.0f,-12.0f,-15.0f);
glBegin(GL_QUADS);
glBindTexture(GL_TEXTURE_2D, texture[0]);
//Ground Rectangle{
glTexCoord2f(0.0f,0.0f);
glVertex3f(-9.0f,0.0f,0.0f); //Bottom Left
glTexCoord2f(1.0f,0.0f);
glVertex3f(9.0f,0.0f,0.0f); //Bottom Right
glTexCoord2f(1.0f,1.0f);
glVertex3f(9.0f,9.0f,0.0f); //Top Right
glTexCoord2f(0.0f,1.0f);
glVertex3f(-9.0f,9.0f,0.0f); //Top Left
//}
glTranslatef(0.0f,9.0f,-1.0f);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexCoord2f(0.0f,0.0f);
glVertex3f(-11.0f,0.0f,0.0f); //Bottom Left
glTexCoord2f(1.0f,0.0f);
glVertex3f(11.0f,0.0f,0.0f); //Bottom Right
glTexCoord2f(1.0f,1.0f);
glVertex3f(11.0f,9.0f,0.0f); //Top Right
glTexCoord2f(0.0f,1.0f);
glVertex3f(-11.0f,9.0f,0.0f); //Top Left
I want there to be a rectangle on top, with "s1.bmp", and one below with "tilegrass.bmp".
Only one rectangle shows up, though: the one that "tilegrass.bmp" is supposed to be on,
but instead of that, "s1.bmp" is on it.
I really need some help with this stuff. :\