I am writing an openGL program where I have created 25-30 objects that are randomly moving on the screen. My problem is that after the objects move for sometime, the screen goes haywire. I think my program is affecting the graphics card. Lines appear on the screen of different colors (mainly green) and the whole display of my computer goes crazy. This does not stop even after I close my program. To get my screen to normal, I have to restart the computer.
Wow really strange behavior. Maybe a memory leak or something? Also try checking out if every glPush(something) has a corresponding glPop. But making the whole os go crazy?
Hello there,
If you are using double buffering, then see that the swapping of the buffers is ok. Also do check out that you release the DC and RC before you exit from the program. Thanx
I havent released anything before exiting my program. What is RC and DC?? Could you please tell me how I can release RC and DC??
Thanks a million…
Originally posted by MMMovania: Hello there,
If you are using double buffering, then see that the swapping of the buffers is ok. Also do check out that you release the DC and RC before you exit from the program. Thanx
The OS should automatically trash them for you when your app ends. So I’m willing to bet that that’s not what’s responsible for your crazy video output problem. It’s good practice to delete them when you’re done with them though.
If, however you are attempting to acquire a new DC each frame, then you had better be deleting at the end of the draw frame, otherwise you’re chewing up memory fast…again, eventually you’d just run out of heap space and your app would crash.
Blub may be onto something, sounds like some funky hardware going on.
Thanks for the advice. I have another question though. What if my program is running without a RC or DC? I have not previously declared or used RC or DC anywhere in my program.
Goldie…
Originally posted by MMMovania:
[b]Hello there,
As for the releasing of DC (Device Context) and RC (Resource Context). Do following.
Set the current rendering context to null by calling wglMakeCurrent(hDC,NULL);
Make a call to wglDeleteContext(hRC);
Make a call to ReleaseDC(hDC);
Thats about it. I hope this will solve your problem.Thanx[/b]
Hello there,
Well you can’t draw anything unless you have the device and resource contexts. Think of them as canvases on which you do your drawing. So if you don’t have anything to draw on how would you draw?
Ok. Here is my main function. I really do not see RC or DC anywhere here.
The animation works, but I am not doing anything fancy. I am just incrementing/decrementing the coods of the objects I am drawing in the scene, I have put this in the idle function, so everytime the scene refreshes it places the object in the new positions and this is giving the illusion of movement.
Yeah if you are using glut or any such library, the device context and resource context handling is done by the library itself. You don’t have to work with these yourself.
As far as your code goes, there is one thing missing, you have not specified the idle function where as you say you are changing variable values in it. In the code, you have passed null to the glutIdleFunc. Rectify this by providing the function name to glutIdleFunc(yourIdleFuncName) and see if you still get errors.
Well I set idle function to NULL there 'cause I want to trigger it only on some key stroke. So later on I do specify the idle function.
So now that I am using glut, I dont need to worry about RC or DC right?
Also I was using an ATI Radeon 7500 64MB card so far, now I am using an ATI Radeon 9550 256MB card, and the problem is no longer there. Do you think this might have been the problem all along?
Thanks a lot for your help.
Originally posted by MMMovania: Yeah if you are using glut or any such library, the device context and resource context handling is done by the library itself. You don’t have to work with these yourself.
As far as your code goes, there is one thing missing, you have not specified the idle function where as you say you are changing variable values in it. In the code, you have passed null to the glutIdleFunc. Rectify this by providing the function name to glutIdleFunc(yourIdleFuncName) and see if you still get errors.