More Win/GL Quake bugs - MainWndProc
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
More Win/GL Quake bugs - MainWndProc
Two things here. First one is that if you handle a message in your WndProc you should normally return 0, not 1. This is all over the MSDN documentation for window messages, and the fix is easy. Find this:
The next one is straight from MSDN as well:
So guess what: both Win and GL Quake set hbrBackground to NULL, but neither handle WM_ERASEBKGND! Add this somewhere after your "switch (uMsg)":
Yes, here we're returning 1 because:
(We're not really erasing the background, but we are drawing over it with our renderer.)
Neither of these will give you any performance gains by the way, there's no voodoo at work here. What they will do is make your program a better behaved citizen in Windows-land (and may help prevent odd behaviour on bad drivers).
While we're at it, and now that we've mentioned the WNDCLASS struct, find your VID_InitDIB function and set the correct class styles for OpenGL (GLQuake totally fails to do this):
- Code: Select all
LONG lRet = 1;
- Code: Select all
LONG lRet = 0;
The next one is straight from MSDN as well:
The DefWindowProc function erases the background by using the class background brush specified by the hbrBackground member of the WNDCLASS structure. If hbrBackground is NULL, the application should process the WM_ERASEBKGND message and erase the background.
So guess what: both Win and GL Quake set hbrBackground to NULL, but neither handle WM_ERASEBKGND! Add this somewhere after your "switch (uMsg)":
- Code: Select all
case WM_ERASEBKGND:
return 1;
Yes, here we're returning 1 because:
An application should return nonzero if it erases the background; otherwise, it should return zero.
(We're not really erasing the background, but we are drawing over it with our renderer.)
Neither of these will give you any performance gains by the way, there's no voodoo at work here. What they will do is make your program a better behaved citizen in Windows-land (and may help prevent odd behaviour on bad drivers).
While we're at it, and now that we've mentioned the WNDCLASS struct, find your VID_InitDIB function and set the correct class styles for OpenGL (GLQuake totally fails to do this):
- Code: Select all
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
Re: More Win/GL Quake bugs - MainWndProc
Well, I've added it:
I'm not using the MGL code anymore, so I guess it should work fine.
- Code: Select all
// mh - begin
// http://forums.inside3d.com/viewtopic.php?f=12&t=2708
case WM_ERASEBKGND:
return 1;
// mh - end
default:
/* pass all unhandled messages to DefWindowProc */
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
break;
}
/* return 0 if handled message, 1 if not */
return lRet;
}
I'm not using the MGL code anymore, so I guess it should work fine.
-

mankrip - Posts: 915
- Joined: Fri Jul 04, 2008 3:02 am
4 posts
• Page 1 of 1
Return to Programming Tutorials
Who is online
Users browsing this forum: No registered users and 1 guest