Jump to content

  • Log In with Google      Sign In   
  • Create Account


How do I generate mipmaps using GL Image?


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
4 replies to this topic

#1 Sean_Seanston   Members   -  Reputation: 279

Like
0Likes
Like

Posted 01 July 2014 - 09:51 AM

I'm following these tutorials here:http://www.mbsoftworks.sk/index.php?page=tutorials&series=1

Except that I've decided to use GLFW instead of GLUT, and use the Unoffical OpenGL SDK in general.

 

So I've got to the tutorial on textures:

http://www.mbsoftworks.sk/index.php?page=tutorials&series=1&tutorial=9

 

He uses something called FreeImage, but since I already have GL Image set up as part of the SDK, I thought I'd use that instead.

 

Loading a texture seems simple:http://glsdk.sourceforge.net/docs/html/group__module__glimg.html

 

I've used that code in my application and it all compiles fine, but I'm just wondering about one thing: the tutorial mentions generating mipmaps, but I'm not sure how that works with GL Image. I've searched for documentation and found this:

http://glsdk.sourceforge.net/docs/html/group__module__glimg__texture.html

Where it mentions that when CreateTexture() returns:

The texture returned will always be texture-complete, with the proper base and max mipmap level set, and reasonable filtering parameters set on it.

 

 

But there's no other mention of the word mipmap on that page and I haven't been able to find anything else regarding mipmaps and GL Image.

I'm quite unfamiliar with how mipmaps work in OpenGL though, so maybe it should be obvious to someone who knows about this.

 

GL Image seems to take care of the calls to glGenTextures(), glTexImage2D() etc. with the short bit of code I linked to, but does it have its own function to generate mipmaps somehow, or should I manually bind the texture to GL_TEXTURE_2D and then call glGenerateMipmap(GL_TEXTURE_2D);?

But then what about the reference to "the proper base and mipmap level" being set by CreateTexture()? Is that just something it does to allow proper mipmap generation later on by the usual glGenerateMipmap() method?



Sponsor:

#2 Ohforf sake   Members   -  Reputation: 1794

Like
1Likes
Like

Posted 01 July 2014 - 10:20 AM

From a cursory glance it seems like you can load DDS files into an image set and load that into a texture. DDS files support pre baked mipmap levels, that are stored alongside the full resolution image. By the looks of it, the createTexture method just reacts to the presence (or absence) of mipmap levels in the image set.

#3 Sean_Seanston   Members   -  Reputation: 279

Like
0Likes
Like

Posted 01 July 2014 - 01:27 PM

I see...

 

Well one thing is that it mentions different loaders for DDS as for JPG, BMP, GIF etc.

 

glimg::loaders::dds being for DDS, and glimg::loaders::stb for the others.

 

Those are used to load the texture into the image set... so that's before CreateTexture() and the mipmapping that was mentioned... makes sense I guess that it would work like you say, considering the single mention of mipmapping with no further explanation.

 

So then presumably... using CreateTexture() with an ImageSet that was loaded using the stb loader would ignore mipmaps by default.

 

Do you think then it's most likely that the following code is how mipmapping is meant to be done with ordinary JPGs?:

//Declare texture ID
GLuint texture = 0;
//Load JPG into ImageSet
std::auto_ptr< glimg::ImageSet > imgSet( glimg::loaders::stb::LoadFromFile( argPath.c_str() ) );
//Create texture from ImageSet
texture = glimg::CreateTexture( imgSet.get(), 0 );

//If MipMaps are required
if( mipMaps )
{
//Bind texture to context
glBindTexture( GL_TEXTURE_2D, texture );
//Generate Mipmaps for texture
glGenerateMipmap( GL_TEXTURE_2D );
}

Is there any reason that might seem odd to someone who understands OpenGL textures, or like it wouldn't work as desired?

 

This then working off the assumption that I'm essentially doing the same thing as he's doing in the tutorial, because I'm assuming that CreateTexture() goes exactly as far as generating the texture, binding it to the context, and copying over the texture data, as well as probably unbinding it when it's done. At that rate, I assume it makes sense to bind the texture, call glGenerateMipmap() and continue as in the tutorial.

 

I'll see if it works once I have the rest of the tutorial working, just thought I'd see if I could get a clearer idea beforehand so I'm not stuck then...


Edited by Sean_Seanston, 01 July 2014 - 01:30 PM.


#4 L. Spiro   Crossbones+   -  Reputation: 13260

Like
1Likes
Like

Posted 01 July 2014 - 08:20 PM

Your conclusion is correct.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 Sean_Seanston   Members   -  Reputation: 279

Like
0Likes
Like

Posted 02 July 2014 - 03:45 PM

Alright cool, that's great then.

 

Thanks.






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