Archived

This topic is now archived and is closed to further replies.

Guardian_Light

Windows Screen Corruption

Recommended Posts

I've been writing a Tetris clone for windows... It was a little bit of a challenge to see if I could write all the source code in about an hour (starting with a basic skeleton). Anyways I seemed to actually get it mostly done...except I've never written high performance graphics (if they can be called that =) with GDI. The game runs fine for about five minutes in game. Then it stops redrawing and nothing else in windows redraws. If I move the window or any windows the screen isn't repainted. The game does not freeze, everything runs normally in windows. I've tested it on two different machines running different versions of windows. I'm releasing my hdc after every paint, and delete any compatible memory dc's I use. The only problem I can think is that I acquire two dc's in one paint message sometimes... but considering the program does this about 4000 times before it crashes, I've dismissed the idea... Hopefully I've given sufficient information and someone can suggest a solution, or even just knows what the real problem is =) Michael Sikora, Edited by - guardian_light on July 1, 2001 8:11:53 PM

Share this post


Link to post
Share on other sites
I had a similar problem with my game, the problem was when I was setting a custom brush and pen to an hdc, I wasnt resetting them to its previous state.


// Save the current object and set the new.
hGDI = SelectObject(dc, fnt);

TextOut(dc,x,y,text,strlen(text));

// Restore the previous object
SelectObject(dc, hGDI);



Hope this helps..


  Game Download  ZeroOne Realm

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''ve used directx in the past and will countinue to. I (obviously) perfer it to GDI, but that''s not in question. I''d think that someone must have run into this problem with GDI before....and I could really use the solution =)

Michael Sikora

Share this post


Link to post
Share on other sites
I''ve had a similar problem with a clock I was drawing. After a while GDI started drawing using the default brushes or GDI wouldn''t draw anything at all. The cause of the problem is probably that you don''t call DeleteObject after every SelectObject thus claiming increasingly more resources. This solved my problem anyway. Hope this helps. Good luck!

Jasper

Share this post


Link to post
Share on other sites