• Advertisement
Sign in to follow this  

glBindTexture yet again

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

How closely related is the time glBindTexture takes relative to the size of the texture, For a 2d games lets say I have 3 textures tex 1:is huge, has several terrain items like rocks, trees and bushes tex 2:is a sprite sheet for some guy (guy A) tex 3:same as 2 but for another guy (guy B) I don’t know the draw order in advance so if I had from top to bottom Rock Guy A Tree Guy B Rock Would a situation like this where I have to bind and unbind a large texture many times cause problems and if so what can I do about it.

Share this post


Link to post
Share on other sites
Advertisement
Here's some info on this subject:
Quote:
Keep mind that switching textures is a fairly expensive operation. If a texture is not already resident in dedicated texture memory, switching to a non-resident texture requires that the texture be downloaded to the hardware before use. Even if the texture is already downloaded, caches that maximize texture performance may be invalidated when switching textures. The details of switching textures varies depending on your OpenGL implementation, but suffice it to say that OpenGL implementations are inevitably optimized to maximize texturing performance for whatever texture is currently bound so changing textures is something to minimize. Real-world applications often derive significant performance gains by sorting by texture the objects that they render to minimize the number of glBindTexture() commands required to render the scene. For example, if a scene uses three different tree textures to draw several dozen trees within a scene, it is a good idea to draw all the trees that share a single texture first before switching to a different tree texture.

From here. So I'm not sure, but what you can do is profile normal use. then you can use glPrioritizeTextures on those textures and then profile against that and see if it makes that much of a difference. Either way, the thing is that everyone has different video cards, so you might want to look into making a system that optimizes it for you or you can also see if you can simplify your texture maps some so they are smaller, then profile against that. I'm not an expert myself, for I'm learning OpenGL too, but this will be a problem I'll have to overcome too.

Share this post


Link to post
Share on other sites
i was thinking of dividing up larger ones,
what i want to know if its better to have more binds of smaller textures or fewer binds of larger textures, but becouse of 2^n constriant more textures mean more wasted space.
also though in gl i havent had much success mesuring preformance, the numbers i get back seem fairly random

Share this post


Link to post
Share on other sites
Quote:
Original post by Kaze
what i want to know if its better to have more binds of smaller textures or fewer binds of larger textures, but becouse of 2^n constriant more textures mean more wasted space.


I'll try and profile some of my code's performance soon, I have a large texture as well as the 100 some bmps that make it up as well, but reading more on this, for example here, you want to minimize the number of calls to glBindTexture, but then agian, I'm not sure how having huge textures will affect the program. We'll wait for an OpenGL expert to drop by [wink]

Share this post


Link to post
Share on other sites
than just one last thing,
is putting all my graphics on one uber huge texture a practical solution or the ramblings of a madman

Share this post


Link to post
Share on other sites
Quote:
Original post by Kaze
than just one last thing,
is putting all my graphics on one uber huge texture a practical solution or the ramblings of a madman


Definitly the latter [wink]. Not all graphics cards support textures above specific sizes. On my 128MB Radeon X800, it maxes out at 2048x2048. (Found this little program that tells you quite a bit for OpenGL settings). So yea, unless you can fit everything on less than 1024x1024, I don't see that being a good idea.

Share this post


Link to post
Share on other sites
A TNT2 will support 1024x1024 so you should be ok with a few of those if you want to preload them. With the looks of new engines like UT 1k x 1k textures might be the lowest mip-mapped ones ;-) lol.

Share this post


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

  • Advertisement