[C++/OpenGL] Can't load multyple textures.

Started by
2 comments, last by wolfscaptain 12 years, 1 month ago
I am trying to create multyple texture with soil, but when I compile I only see white cube without textures.
I think glGenTextures is causing the problem, because without it textures load.

Can I use SOIL and glGentextures?


int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
/* load an image file directly as a new OpenGL texture */
texture[0] = SOIL_load_OGL_texture
(
"lol.bmp",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y
);
if(texture[0] == 0)
return false;
glGenTextures(3,&texture[0]);
// Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // ( NEW )
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); // ( NEW )
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); // ( NEW )
return true; // Return Success
}
Advertisement
Shouldn't you call glGenTextures before SOIL_load_Ogl_texture, rather than after it? Or am I misremembering my OpenGL?

Shouldn't you call glGenTextures before SOIL_load_Ogl_texture, rather than after it? Or am I misremembering my OpenGL?


Still the same..
You are loading an OpenGL texture with SOIL, then you are reseting your id to a new one with GenTextures, then you are setting texture parameters to three empty texture objects.

This topic is closed to new replies.

Advertisement