WIN32 game turns white

Started by
3 comments, last by KittyRa 18 years, 7 months ago
I am making space pong in WIN32 (my school doesn't have DirectX). Everything works fine until about a minute into play when the paddles and ball turn white. There are stars moving in the background but they don't turn white (they are not yellowish). Does anyone know why this happens/how I can fix it? thanks
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
Advertisement
Doubtful anyone will be able to help without seeing some code. What are you using to draw graphics? GDI? Are your graphics simple shapes (ellipse, rectangle etc) or bitmaps?
Progress is born from the opportunity to make mistakes.

My prize winning Connect 4 AI looks one move ahead, can you beat it? @nickstadb
I am using GDI. The ball and paddles are just RECTs that I filled using FillRect()

Here's the code for drawing the paddles:
paddle.top		= PADDLE2_START_Y;	paddle.left		= PADDLE2_START_X;	paddle.right	= PADDLE2_START_X+PADDLE_WIDTH;	paddle.bottom   = PADDLE2_START_Y+PADDLE_HEIGHT;	FillRect(ghdc,&p1,CreateSolidBrush(RGB(255,0,0)));	FillRect(ghdc,&p2,CreateSolidBrush(RGB(0,0,255)));
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
You need to delete the brushes after usage. Otherwise, they fill up the memory reserved for GDI, thus causing "empty" graphics and/or crashes.

I recommend creating the brushes just once after you've created the window, and deleting them when the application is closing.

Niko Suni

Oh okay. Thanks a lot!
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!

This topic is closed to new replies.

Advertisement