Original Post
Hi I'm trying to apply a texture to my isometric tiles but they are just remaining white therefore I think there might be a problem with my texture loading function even though it doesen't generate any errors. Here's my code. Also, I've applied textures to simple polygons before, just without this texture loading function which leads me to believe it's my function causing the problem. All help/advice appreciated.
const int NUM_TEXTURES = 1;
GLuint texture[NUM_TEXTURES];
SDL_Surface *load_image(std::string filename)
{
SDL_Surface* loadedImage = NULL;
loadedImage = IMG_Load(filename.c_str());
return loadedImage;
}
void create_textures()
{
SDL_Surface *tempBMP = NULL;
glGenTextures(NUM_TEXTURES, &texture[0]);
for (int i = 0; i < NUM_TEXTURES; i++)
{
tempBMP = load_image("texture1.bmp");
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, tempBMP->w, tempBMP->h,
0, GL_BGR, GL_UNSIGNED_BYTE, tempBMP->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
SDL_FreeSurface(tempBMP);
}
}