-
win32, openGL basecode
hey all, i wrote this openGL 'basecode' that creates a window using win32. my knowledge of the win32 api is very limited. most of my programming experience is with linux.
anyway, i've set up this code to use as a starting point to my windows openGL projects, everything seems to work ok but i want to make sure im doing everthing properly (ie. window creation, destruction ....) i would be most appreciative if someone could have a quick look over my code to make sure there are no glaring omissions. any input is welcome.
thanx!
-
well its in c++. but some of things can be changed:
CREATESTRUCT* creation = (CREATESTRUCT*)(lParam);
LPCREATESTRUCT.?
PostMessage(hWnd, WM_QUIT, 0, 0);
could be:
PostQuitMessage (0) ;
WNDCLASSEX needs 2 more parameters. if u dont need it?
case WM_SYSCOMMAND:
{
switch(wParam)
{
case SC_SCREENSAVE:
case SC_MONITORPOWER:
i think the switch part should be coded like this:
switch(HIWORD(wParam))
------------------------------------------------------------------------------------
goodluck.
-
You gotta start some where right?
-
hey, thanx for the reply samsam. i checked out the CREATESTRUCT and LPCREATSTRUCT thing, they are the same structure but LP... returns a pointer to the struct. i switched to that cause i was casting it as a pointer anyway! the postQuitMessage(0) seems like a better solution too. (same result but probably more efficient). i left out a few of the WNDCLASSEX variables, i dont really need them at the moment.
the only thing im not sure about is the HIWORD(wparam), what is the difference between using that and just using wParam???
-
Hi perspective:
With WM_SYSCOMMAND:
four LOWORD bits of the wParam parameter are used by the system. To get the ok result, when testing with the wParam
value , its better to use HIWORD(wParam) for(SC_SCREENSAVE)
cheers!
-
ahhhh, i see. its all making sense now (wow, microsoft stuff making sense... lol, j/k)
thanx!
-
MS, i know we are all stalk with em.:)
*By the way;
in your WM_DESTROY, u can keep your version if somewhere in your code you have a WM_CLOSE processed.that in it
you are processing the deselecting & deleting of rendering context .
because if you dont send msg to that part before quiting
you havent cleaned up after your prog is done.
you know what i mean right?
WM_CLOSE:
delete this
delete that
break;
WM_DESTROY:
sendMessage(to WM_CLOSE for clean up)
break;
cheers!