PDA

View Full Version : Memory Problem



İsmail
06-03-2009, 11:33 PM
I try to texture a cube with a bmp file. I did but I have a problem about memory. Memory usage of my program increases without stopping. When I want to esc, an error message occurs "Debug Error ...path../.exe Damage: After Normal block (#1773 at 0x09f3ae58. Please retry t debug application".

How can I solve this problem?

ZbuffeR
06-04-2009, 02:00 AM
Be sure that the part that reads the bmp and does glTexImage2D is called only _once_ near the start of the program, and NOT called at each display refresh.

İsmail
06-04-2009, 05:30 AM
At each display refresh I call glTexImage2D. The program is working as I want. But memory usage of my program increases without stopping.

bmateusz
06-04-2009, 05:52 AM
You have to call glTexImage2D only once, at loading. After that use glBindTexture(GL_TEXTURE_2D, texture_id);
Your program uploads the texture to the video ram every frame.

Dark Photon
06-04-2009, 06:41 AM
At each display refresh I call glTexImage2D. The program is working as I want. But memory usage of my program increases without stopping.
That's one reason why. Here's the way to think about this API call:

* glTexImage2D: malloc and memcpy
* glTexSubImage2D: memcpy

You call glTexImage2D "once" per MIPmap level to allocate. You can even call it with a NULL pointer (with no PBO bound) to do the malloc but not the memcpy (i.e. leave the contents of the memory block unspecified). Then you call glTexSubImage2D one or more times to change the contents of that MIPmap's memory block.