![]() |
|
Win32.. Game Loop |
decsonic
Member #4,150
December 2003
|
Came Across some problems when handling the WinMain my self,
buffer is a double buffer. Programmer's paranoia: Don't trust anybody's code, not even your own. |
gillius
Member #119
April 2000
|
I don't understand what your problem is? Are you trying to get WM_PAINTs or??? Gillius |
decsonic
Member #4,150
December 2003
|
Well i dont get why hdc doesnt get blitted, done a few tests, it goes inside WM_PAINT alot and my "Game Update" function (off course since WM paint is forced there.) Programmer's paranoia: Don't trust anybody's code, not even your own. |
gillius
Member #119
April 2000
|
what do you mean HDC... Are you trying to use Allegro and then blit to the HDC? Yes you are. Are you sure that the buffer contains the proper image that you are expecting? EDIT: do you have to get a HDC every time you paint? I don't know Win32 very well but it seems you store the HDC once and don't get it in WM_PAINT. Honestly I can't remember if you can do that. Gillius |
Thomas Fjellstrom
Member #476
June 2000
![]() |
I found the BeginPaint thing says its supposed to give a valid HDC.. but it doesnt. so I grabbed mine from the ps struct (IIRC, been a while since I looked at my win32 code...) -- |
decsonic
Member #4,150
December 2003
|
ahh 1 thing i forgot, int main() { } "world" Programmer's paranoia: Don't trust anybody's code, not even your own. |
Kitty Cat
Member #2,815
October 2002
![]() |
I think the only time it's not supposed to draw is when it's minimized. If you're app is in the background, it can still be visible, even if only partially, or if the window on top is translucent. It sounds like, though, that you want your game to pause execution when you go into the background. I don't know how to do that. EDIT: -- |
decsonic
Member #4,150
December 2003
|
the problem is that it doesnt draw when it has focus Programmer's paranoia: Don't trust anybody's code, not even your own. |
A J
Member #3,025
December 2002
![]() |
are you waiting on a WM_PAINT msg before you draw to the screen ? i think you will only receive a WM_PAINT when the window changes state or it gets un-obscured by another window. ___________________________ |
23yrold3yrold
Member #1,134
March 2001
![]() |
Program might be waiting for a new message when it has the focus. Maybe set up a WM_TIMER? And you can call InvalidateRect() instead of sending WM_PAINT messages. That might help too ... actually, yes. That might be your problem. Sending a WM_PAINT message might be totally wasted if there's no "dirty" areas that need updating. -- |
Rick
Member #3,572
June 2003
![]() |
Why are you doing it this way? You shouldn't be calling the WM_PAINT message to update the screen. Update the screen in GameUpdate. ======================================================== |
Specter Phoenix
Member #1,425
July 2001
![]() |
This is the just of my code nowadays from learning WinAPI/DirectX:
Of course for the WNDCLASSEX I use the shorter form to save typing: WNDCLASSEX winclass = { winclass.cbSize = sizeof(WNDCLASSEX), CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW, WindowProc, 0, 0, hinstance, LoadIcon(NULL, IDI_APPLICATION), LoadCursor(NULL, IDC_CROSS), (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, "WINCLASS1", LoadIcon(NULL, IDI_APPLICATION) };
I use WS_POPUP for use with DX:).
|
decsonic
Member #4,150
December 2003
|
void Update( HWND hWnd ) { HDC DC = BeginPaint(hWnd,&ps); blit_to_hdc( buffer, DC,0,0,0,0,800,600); EndPaint( hWnd, &ps ); } atm that just crashes::) Programmer's paranoia: Don't trust anybody's code, not even your own. |
23yrold3yrold
Member #1,134
March 2001
![]() |
Do you create 'buffer' anywhere? -- |
decsonic
Member #4,150
December 2003
|
yup its a double buffer, 800,600. Programmer's paranoia: Don't trust anybody's code, not even your own. |
|