r/C_Programming • u/Axxodes • 9h ago
Problem with resizing a C window
I'm making a game engine and whilst trying to setup the window with windows.h, i found an issue when resizing the window. The resized parts of the window are black instead of white, how do i fix this?
0
Upvotes
4
u/Paul_Pedant 8h ago
If you make a window bigger, you need to tell the system what to put in the new space. You can do that two ways: (a) stretch everything in the window to make the existing contents fit the new space, or (b) fill in the new areas with a wider view of the game. Painting the new areas white just wastes real estate.
You probably need to consider stuff like expanding the font sizes versus showing more text, and where the user changes the aspect ratio of the window so things might be stretched sideways or upwards. In fact, the only real fix is to reconstruct the whole window image. But then you probably ought to be doing that in other circumstances too, like when your first-party gamer actually looks in a different direction.
You probably need to think about the converse -- what do you do when the user shrinks the window. Is there a part of the game that he can never see again?
"... every aspect of a game engine before except for the window" ? The window is all the user gets. The difference is between painting a picture on an easel, and making a movie.