PDA

View Full Version : Why is my windows 2000 out of memery when I run my openGL program?



jiangerlai
03-16-2003, 02:19 AM
I have written a openGL program in visual c++6.0. I use double color buffers and swap them 10 times a minute to realize animation. When I run my program,my operating system run out of memory after about 1 minute.And I have checked my program without finding any errors?I guess it's openGL buffers' fault.Can anyone explain the reasons for this phenomenon. Thanks!! Eager for your help!

morbac
03-16-2003, 02:46 AM
hehe, we always think it isn't our fault when something is going wrong...
I often thought this, but I could always find the error in my code !

Continue searching the error in your code, or show us your code if you want to be helped !

jiangerlai
03-16-2003, 02:56 AM
Originally posted by morbac:
Continue searching the error in your code, or show us your code if you want to be helped !
In my program,there are four textures.I load them each time when they are used.I guess it's the key reason.Do you agree with me?

Bob
03-16-2003, 03:45 AM
You mean you completely reload the texture for each use? Like loading it from disk, allocating a texture id and uploading it? And on top of all, not deleting the old texture?

If so, no wonder you run out of memory.

oliii
03-16-2003, 05:08 AM
load them and bind them at initialisation. Then call glBind() again in your display routine.

something like that

void init()
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &m_Texture);
glBindTexture(GL_TEXTURE_2D, m_Texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, ImageSize, ImageSize,0, GL_RGBA, GL_UNSIGNED_BYTE, Image);

}

void display()
{
glBindTexture(GL_TEXTURE_2D, m_Texture);
}