Jump to content
  • Advertisement
Sign in to follow this  
GenuineXP

OpenGL Animation with Mipmaps

This topic is 4332 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

Hello. I'm working on a basic game engine that uses OpenGL to render 2D graphics. I was wondering if it's possible to produce animations on quads in OpenGL using mipmaps. Could each frame be loaded into a different level mipmap all of the same dimensions? Basically, I'm wondering if I can store an animtation in a single texture's mipmaps so that I can address that texture with one texture name (GLuint) and access each frame of the animation by specifying a mipmap level to use. At this point, my engine supports two animation processes through subclasses of the class Sequence: Strips and Layers. Strip objects create animations by using one large texture with each frame distributed evenly in rows. With this method, the target texture is always the same but the texture coordinates differ. Layer objects create animations by loading many small textures, each individual texture being a frame in the animation. The texture coordinates in this method never differ, but the target texture does. So, would it be possible to add some sort of mipmap animation? I'm using DevIL to load my images and it natively supports loading GIF files with mulitple frames. In fact, DevIL stores each frame in a similar way to mipmaps. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
A mipmap level must be half the size of the previous level. Sure you can use it for animation, as long as you're fine with the size requirement. Although it would be way easier to use a 3D texture instead, or subtexture a 2D one, if you really need to put it all in one single texture object.

Share this post


Link to post
Share on other sites
Thanks for the reply. I'm unfamiliar with 3D textures in OpenGL. I assume they're just texture with any number of "layers" or "depths". Can anyone give me any good references I can learn about 3D textures from?

Thanks again. I appreciate it.

Share this post


Link to post
Share on other sites
I've looked up 3D textures in OpenGL and they seem pretty easy to use (thanks, OpenGL!). But... I'm not sure how to get the texel data I need in glTexImage3D() from DevIL.

Any clue as how to do this? Can I somehow add layers to a 3D texture after it's been loaded? I'm not sure how to squeeze all the data for several images into one pointer to pass to glTexImage3D().

Thanks again. :-)

Share this post


Link to post
Share on other sites
Create the texture object with glTexImage3D as you want the final texture to be, but pass a null pointer for the image data. This allocates a textrure but with uninitialized data. Then use glTexSubImage3D to upload the slices.

Share this post


Link to post
Share on other sites
Thanks for all of the replies, everyone. You've been very helpful. :-)

I've switched to 3D textures, but now I'm having a new problem. Whenever I load 32-bit images (images that have an alpha channel), I get nothing. The texture is completely blank and I wind up with white, blank quads on the screen!

Other images work; I've successfully loaded 24-bit JPEGs and BMPs, but as soon as I load a few 32-bit PNGs, nothing happens. Is there a reason for this? Can I support an alpha channel using 3D textures?

Thanks!

Share this post


Link to post
Share on other sites
My Texture class has a MakeCompliant() method that makes sure that the width and height of images are both a power of two before they're loaded by OpenGL.

Share this post


Link to post
Share on other sites
Haha, I just realized that the MakeCompliant() method was still trying to use 2D textures! It probably wasn't that the images I was loading had an alpha channel, but that their widths and heights weren't powers of two and were being resized and then loaded incorrectly.

I'll try tinkering with it and see what happens.

Thanks again for all of the help.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!