WIN32 game turns white
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
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?
I am using GDI. The ball and paddles are just RECTs that I filled using FillRect()
Here's the code for drawing the paddles:
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)));
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.
I recommend creating the brushes just once after you've created the window, and deleting them when the application is closing.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement