Thread: win32, openGL basecode

  1. #1
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    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!

  2. #2
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    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.

  3. #3
    |<o>| <--cyclopse LouDu's Avatar
    Join Date
    Mar 2003
    Posts
    137
    You gotta start some where right?
    Languages <> C++, HTML

    /*The Ledgend of Ludlow Coming to a PC Near
    You intro Cinenmatic Needed email me of
    Reply to one of my threads if you can make
    one, thats decent. */

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    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???

  5. #5
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    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!

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    ahhhh, i see. its all making sense now (wow, microsoft stuff making sense... lol, j/k)

    thanx!

  7. #7
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    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!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opengl and networking on win32
    By viaxd in forum Windows Programming
    Replies: 7
    Last Post: 01-11-2006, 09:15 AM
  2. win32 or opengl
    By jaylc185 in forum Game Programming
    Replies: 8
    Last Post: 06-02-2005, 05:28 PM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  4. win32 openGL?
    By c++.prog.newbie in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2004, 03:42 PM
  5. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM