View Full Version : texturing concepts
07-23-2001, 05:57 AM
hello, just a newbie question :
do you load all the textures at startup or one by one when it's needed ?
i'm currently making a texturemanaging class and i don't know if i must have a methos that can load many textures from a queue.
how do you do usually?
any help/advice is welcome
sorry because it's off topic.
07-23-2001, 06:35 AM
There's no real universal answer to this question. It pretty much depends on what you want to be able to use the class for. For small apps and demos, loading all textures at startup will probably sufficient - for larger scale projects though that is not viable; you can easily run in the 100s of Megabytes of textures and you probably won't want to keep them all in memory.
OpenGL keeps a copy of the texture image in memory until you tell the driver to delete it. So, the most versatile approach would be a texture manager that keeps track of how much a texture has been used (or maybe predicts how much it will be used), deletes unused textures and loads them back when they are used again.
An exaggerated example, if you have 500 megs of textures in a FPS game level, load the ones that you immediately need. Then, during gameplay, depending on where the player is moving in the level, load the textures of the areas he's moving into and delete the ones of areas he's unlikely to return to.
Also, you could make the texture manager dynamic in terms of video memory consumption, e.g. tell it to load textures up to 70% of the total video memory minus the mem used for the frame buffers, and if loading another texture would exceed that amount, delete the textures that are most unlikely to be used again.
Also, look into texture compression to keep texture memory consumption as low as possible. The more video mem you use the more likely texture swapping gets, which can result in a significant slow down.
07-23-2001, 06:55 AM
tanks for reply,
is it usefull to sort textures ?
do you think that statistics about the frequency of a texture has been loaded can be really usefull ?
maybe the map file organisation is the key of this ?
everything seems harder since you're post(lot of work to do! http://www.opengl.org/discussion_boards/ubb/smile.gif)
07-23-2001, 07:05 AM
i have an idea suddenly...
what about checking the most used textures for each level at the end of the level creating process in order to give them an higher priority ?
07-23-2001, 04:32 PM
Prioritizing textures is definitely worth looking into (you can tell OpenGL to give textures a priority - higher priority textures will be kept in video memory more likely than ones with lower priority).
If you want to have your own mechanism of deleting unused textures or textures that are less likely to be used again than others, from OpenGL, depends on the amount (in memory) of textures that will be used.
If an app tries to load 300 megs of textures, it will probably worthwhile to not load all of them but only the ones that are being used or will be used in the near future, and/or to delete ones that are unlikely to be used.
If an app wants to load just 50MB of textures it might be better to let the graphics card driver handle it on its own (even if the card has only 32MB of video memory, the driver will handle swapping them back and forth between video and system/AGP memory).
If quality is not too big of an issue, and depending on what kind of textures are being used (problematic with big color gradients, etc.), texture compression is a wonderful way to save loads of video memory. S3TC compresses up to 1:8 - so if a little loss of quality is not an issue, that's IMO the best way to go with very little effort.
07-24-2001, 12:21 AM
if i have understood,
i need to make experiments to see by myself what's working better, in wich cases.
about the free memory of the graphic card, is there some opengl specific functions for this ? (to know how many ram is used,how many ram maximum avaiable, etc etc..)
how to know how many bytes a texture will take into memory ? am i wrong or a bmp file will take the same place in memory that in the disk because it's uncompressed ?
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.