Memory Leak in OpenGL Tutorial

Started by
10 comments, last by archanfel 17 years, 10 months ago
Hello, there. Have any of you ever compile the tutorial code in VS 2005? I just tried lesson 1 and lesson 2, It seems to have a small memory leak every time the window refreshes. But there isn't anything wrong in the rendering loop, though. Later I found out the memory keeps increasing upto a certain size, then stops increasing. [Edited by - archanfel on June 26, 2006 5:43:17 PM]
Advertisement
Quote:Have any of you ever compile the tutorial code in VS 2005?

I just tried lesson 1 and lesson 2...

Which tutorials are you referring to?

The NeHe OpenGL Tutorial
It will be the aux file then glaux.h
which is used for loading bitmaps, there is another header which is on the site for loading bitmaps use that instead if you are worried.
Quote:NOTE #2: When the first tutorials were written, GLAUX was the way to go. Over time GLAUX lost support. Many of the tutorials on this site still use the old GLAUX code. If your compiler does not support GLAUX or you would rather not use it, download the GLAUX REPLACEMENT CODE from the main page (left menu).
Quote:Original post by archanfel
Have any of you ever compile the tutorial code in VS 2005?

No

Quote:Original post by archanfel
I just tried lesson 1 and lesson 2,
It seems to have a small memory leak every time the window refreshes.
But there isn't anything wrong in the rendering loop, though.

I'm not surprised. A lot of the nehe stuff is pretty badly written.

Good thing it's just a tutorial eh? it'd be a real problem if the leak was in some real game code.

Quote:Original post by Anonymous Poster
Quote:NOTE #2: When the first tutorials were written, GLAUX was the way to go. Over time GLAUX lost support. Many of the tutorials on this site still use the old GLAUX code. If your compiler does not support GLAUX or you would rather not use it, download the GLAUX REPLACEMENT CODE from the main page (left menu).


I've excluded GLAUX.
and I am commenting out all the code in the drawing function as well.
and also I check carefully to make sure no dynamic memory allocation in the rendering loop.
and the memory leak is still there.

Anyone have a better idea what it may be?
Quote:I've excluded GLAUX.
and I am commenting out all the code in the drawing function as well.
and also I check carefully to make sure no dynamic memory allocation in the rendering loop.
and the memory leak is still there.

Can you post this version of your program, so we can take a look at it?
It is too messy to post the entire code.

so this is the message loop:
while(!done) // Loop That Runs While done=FALSE
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
{
if (msg.message==WM_QUIT) // Have We Received A Quit Message?
{
done=TRUE; // If So done=TRUE
}
else // If Not, Deal With Window Messages
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
else // If There Are No Messages
{
// Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
if (active) // Program Active?
{
if (keys[VK_ESCAPE]) // Was ESC Pressed?
{
done=TRUE; // ESC Signalled A Quit
}
else // Not Time To Quit, Update Screen
{
DrawGLScene(); // Draw The Scene
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
}
}

if (keys[VK_F1]) // Is F1 Being Pressed?
{
keys[VK_F1]=FALSE; // If So Make Key FALSE
KillGLWindow(); // Kill Our Current Window
fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
// Recreate Our OpenGL Window
if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
{
return 0; // Quit If Window Was Not Created
}
}
}
}

This topic is closed to new replies.

Advertisement