problem when running program within IDE but works fine outside of the IDE

My little program draws a colored point wherever the mouse is clicked and when you want to take a screenshot and make it a tga file you press F2. When I run this from the debug directory it runs as expected with no problems. However, if I run it within the IDE it keeps crashing when it returns to the render routine after the screen has been saved to file. The only difference between this and another tga screenshot program which works fine wherever its run from, is the user interaction so I am assuming that that is the cause.

I have placed the files on my site at http://programming.swangen.co.uk/opengl/mini_projects/texture_creator/.

Thanks in advance for any help in what could be causing this error. The error actually states it is an unhandled exception in <program: address> : Access Violation.

Tina

This often happens, when you don´t release your stuff properly. If you run your program from your directory, this doesn´t matter so much. It also crushes at termination, but you don´t recognise it. However if you start it from your IDE (especially in DEBUG mode), than the IDE might recognise the false termination and therefore you get an error message.
Look in your code, where you release all your temporary variables, your OpenGL stuff, etc., somewhere has to be an error. You can use your debugger, to find the function, which caused the crash or you could do it the way i often do it: Write a small function, which can write text to a file (for example: ’ Log (“Releasing OpenGL”); ') Put such a function everywhere, where you would expect something to be wrong, and hunt the error down, by surrounding it with those function calls.

Good luck hunting.
Jan.

Aha, found the problem… strange why it didn’t occur before the screenshot though…

This section of code caused the problem
screen = (GLubyte**)malloc(256);
for (int l=0;l<256;l++)
{
screen[l] = (GLubyte*)malloc(256);
}

Forgot to specify the size of the variable type.

screen = (GLubyte**)malloc(sizeof(GLubyte*) * 256);
for (int l=0;l<256;l++)
{
screen[l] = (GLubyte*)malloc(sizeof(GLubyte) * 256);
}

Tina