Windows Screen Corruption

Started by
5 comments, last by Guardian_Light 22 years, 10 months ago
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
Advertisement
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

  Downloads:  ZeroOne Realm

Thanks for the advice, but I''m afraid it didn''t help with my corruption problem...

Michael Sikora
Abandon GDI and use DirectX in windowed mode, far far quicker, and easier.
If at first you don't succeed, redefine success.
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
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
Well I started restoring everything...still didn''t help :-(

Anyways thanks for the help so far...

Michael Sikora

This topic is closed to new replies.

Advertisement