Jump to content
  • Advertisement
Sign in to follow this  
Sourabh Pradhan

Displaying Multiple Textures Rapidly

This topic is 2644 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 would like some help on a task. Basically I have a quad and I want to render texture images on to that quad rapidly (lets say 30fps). So lets say I have a set of 10 images, what should basically happen is
the first image should be added as a texture on to the quad. Then in the next frame that image should get replaced by another image onto that same quad. And so on..

Now I have got the basic quad and one image being displayed alright. I need some help on how to proceed next. Any help will be appreciated.

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
hi,

I think this is fairly straight forward. My solution for this would basically be, to load all 10 images onto the GPU and save the Id in a vector/array. Every frame you grab the next Id from the vector and if you arrive at the end of the rewind the iterator (the modulo operator might come in handy here). I hope this helps.

Share this post


Link to post
Share on other sites
How big are these textures? you may also be able to put them in a single texture and change the texture coordinates instead. I would probably be impracticle with larger textures though.

Share this post


Link to post
Share on other sites
@doeme Sorry but I should have mentioned that this is in OPENGL ES. Can I use a vector/array in es? becoz the GL_TEXTURE_2D_ARRAY isn't available in GLES is it?

@Nanoha For now the size i am working with is 256x256. Could you elaborate what you mean by changing the texture coordinates?

Share this post


Link to post
Share on other sites
You will need to setup a vertex buffer object to render quads.

As for rendering textures rapidly, the fastest method is multi-texturing, where you bind 2 to 4 textures at a time and render them in a single pass on the same quad. The number of textures you can bind at a time depends on the OpenGL implementation. Of course, how you want the textures rendered matters too. If you want to simply replace textures, only bind one texture at a time. Then you bind another texture later, if you want to swap. Does that make sense?

Share this post


Link to post
Share on other sites

@doeme Sorry but I should have mentioned that this is in OPENGL ES. Can I use a vector/array in es? becoz the GL_TEXTURE_2D_ARRAY isn't available in GLES is it?

@Nanoha For now the size i am working with is 256x256. Could you elaborate what you mean by changing the texture coordinates?


I think by "array", he means a sequential location in RAM :
int myarray[10];

and then you allocate 10 textures (or whatever number you prefer)

glGenTextures(1, &myarray[0]);
glGenTextures(1, &myarray[1]);
glGenTextures(1, &myarray[2]);

or the ultra high performance method glGenTextures(10, &myarray[0]);

Share this post


Link to post
Share on other sites


I think by "array", he means a sequential location in RAM :
int myarray[10];

and then you allocate 10 textures (or whatever number you prefer)


That's exactly what i meant.

Share this post


Link to post
Share on other sites

@Nanoha For now the size i am working with is 256x256. Could you elaborate what you mean by changing the texture coordinates?


That size sounds good. Normally when you texture your quad you probable give it texture coordinates of (0, 0), (0, 1), (1, 0), (1, 1) (not necessarily in that order).which says yto show all of the texture. You could instead put any number of little images on one texture. You may have each quarter of an image being 1 "frame" of your animated texture. To show the first "frame" you might use coordinates of (0, 0), (0, 0.5), (0.5, 0), (0.5, 0.5) instead. You need to update these coordinates to show a different part of the texture.

On a 1024*1024 texture you could put 16 256*256 images. This will quite likely be faster than using 16 different textures.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!