Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by Polas22 Mar 26, 2012 at 4:57 PM 2 replies 2.2k views
Original Post
Polas22
Polas22
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
}
yckx
yckx
Shouldn't you call glGenTextures before SOIL_load_Ogl_texture, rather than after it? Or am I misremembering my OpenGL?
Polas22
Polas22

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


Still the same..
wolfscaptain
wolfscaptain
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.