Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I writing my resource mangaer, and I consider about how it can work for graphics objects (like textures, meshes).
I think about this :
I want to load texture (in pseudocode):

Texture t = resMgr.GetTex("image.png");

and GetTex make something like this:

  1. load texture from disk to main memory
  2. create texture object (load it to gpu memory)
  3. unload texture from main memory

I consider about 3 step, does game engines that you know unload meshes/textures after load them into gpu memory ?

share|improve this question
add comment

3 Answers

No, fetching them from the hard drive is very time-intensive. It is possible that you have so much texture/model/animation data that everything will not fit concurrently on the GPU, especially for someone using an older graphics card or laptop.

Main memory is probably the cheapest resource you have to work with on a modern computer. You should leave things like unloading textures from memory for when you are switching maps.

share|improve this answer
add comment

Loading and unloading resources at runtime is not practical. The only time you do that is when you are streaming resources.

A general idea to go on is to load rescouers that you need for a current map or segment. and when the player is past that to unload the rescoures. Never keep something you dont need, but keep what you need now or soon.

share|improve this answer
add comment

You should generally free your mesh and texture data after uploading into OpenGL textures or vertex buffers. The driver must keep a copy of your data in any case, so why waste memory by keeping another useless copy around?

Main memory may be cheap, but even so you shouldn't waste for no reason. Especially not on 32-bit architectures where you may bump into the 4GB per-process virtual address space limit sooner rather than later.

The best performing method to load mesh data, if using OpenGL, is to:

  1. Create vertex buffer object.
  2. Use glMapBuffer to get a pointer to driver memory.
  3. Load data directly into driver memory.
  4. glUnmapBuffer to tell the driver you've finished filling the buffer with data.

Less applicable on textures, since the driver may need to convert your data to an internal format.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.