• Advertisement
Sign in to follow this  

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

This topic is 2123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

[CODE]
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
}
[/CODE]

Share this post


Link to post
Share on other sites
Advertisement
Shouldn't you call glGenTextures before SOIL_load_Ogl_texture, rather than after it? Or am I misremembering my OpenGL?

Share this post


Link to post
Share on other sites
[quote name='yckx' timestamp='1332781822' post='4925402']
Shouldn't you call glGenTextures before SOIL_load_Ogl_texture, rather than after it? Or am I misremembering my OpenGL?
[/quote]

Still the same..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement