Image Loading, uses SDL_Image and converts it to a GL texture, which works fine!!
BUT only with one texture.
Code: Select all
bool GL_LoadIMG(char *file)
{
SDL_Surface *SDLTexture = LoadIMG(file);
GLuint GLTexture;
printf("\n");
if(SDLTexture)
{
printf("OGL - Image loaded.\n");
glGenTextures(1, &GLTexture);
glBindTexture(GL_TEXTURE_2D, GLTexture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, SDLTexture->w, SDLTexture->h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, SDLTexture->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
printf("OGL - Image optimized.\n");
SDL_FreeSurface(SDLTexture);
}
else
{
printf("OGL - Image could not be loaded.\n");
return false;
}
return true;
}
Code: Select all
menuTextures[1] = GL_LoadIMG("data\\textures\\homeicon.png");
printf("\n");
menuTextures[2] = GL_LoadIMG("data\\textures\\file.png");
printf("\n");
menuTextures[3] = GL_LoadIMG("data\\textures\\edit.png");
printf("\n");
menuTextures[4] = GL_LoadIMG("data\\textures\\mode.png");
printf("\n");
menuTextures[5] = GL_LoadIMG("data\\textures\\options.png");
printf("\n");
glBindTexture(GL_TEXTURE_2D, menuTextures[NUMBER]);
EDIT: I take that back, depending on whether I put glBindTexture or GL_Begin first here: (I can access the first or last texture, but still none between)
Code: Select all
glBindTexture(GL_TEXTURE_2D, menuTextures[3]);
glBegin(GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex3f (0.0, 0.0, 0.0);
glTexCoord2f (1.0, 0.0);
glVertex3f (50.0, 0.0, 0.0);
glTexCoord2f (1.0, 1.0);
glVertex3f (50.0, 50.0, 0.0);
glTexCoord2f (0.0, 1.0);
glVertex3f (0.0, 50.0, 0.0);
glEnd();