Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 PauliusM   Members   -  Reputation: 112

Like
0Likes
Like

Posted 26 March 2012 - 10:57 AM

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
}


Sponsor:

#2 yckx   Prime Members   -  Reputation: 1159

Like
0Likes
Like

Posted 26 March 2012 - 11:10 AM

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

#3 PauliusM   Members   -  Reputation: 112

Like
0Likes
Like

Posted 27 March 2012 - 03:48 AM

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


Still the same..

#4 wolfscaptain   Members   -  Reputation: 200

Like
0Likes
Like

Posted 27 March 2012 - 09:28 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS