Archived

This topic is now archived and is closed to further replies.

A win32 wrapper question

This topic is 5773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to start off coding really efficiently, and have been having some trouble getting a working wrapper for setting up the window for a DirectX game (using VC++ 6.0). What I''m aiming for is a simple cpp/h file that I can use in every project that''ll setup WNDCLASSEX and create a window using that class for either windowed mode DirectX or Fullscreen. Are there any tutorials or sites you guys/gals know of that may help in this development? (I searched around GameDev, but all I found were DirectX wrappers). ''''You shall be as Gods!'''' Xenogears ''''You handle the salads until you get killed!'''' Space Ghost C2C

Share this post


Link to post
Share on other sites
Do you need tutorials on how to perform the actual DirectX and Window''s function, or just the structure of the code?
If it''s just the structure you want, I''d start easy like this:
We''d have 2 .cpp''s and 1 .h:
  • main.cpp
  • engine.cpp
  • engine.h
    Engine.cpp: This .cpp file will hold the functions actual functions for your engine that main.cpp will call. i.e.- CreateDirectX(HWND, blah... )... etc. Think of these functions as a library that main.cpp and go call when it needs them. Make sure that you include the header file (#include "engine.h")
    Engine.h: This header file will hold what are called prototypes, if you know what these are then bear with me, but prototypes are like functions but minus the body. Example:

    // this is a normal function:
    void Function(int number)
    {
    print(number);
    }
    // here is the above function''s prototype
    void Function(int number); // the semicolon is crucial

    As you can see, the prototype basically defines what the function will look like. Now in the header file, you will make a list of all your prototypes in engine.cpp that you want main.cpp to call.
    Main.cpp: This is where winmain will be located. Be sure it includes engine.h as well. Engine.h is the "medium" through which the two .cpp files will communicate. Now, main.cpp can call functions from engine.cpp that are prototyped in engine.h at will!
    I hope this makes sense, and if it doesn''t then oh well,
    Good luck,
    -Jesse

    Share this post


    Link to post
    Share on other sites
    Thanks for your reply. I was actually having trouble with trying to call a user function called SetUpWindow() that would be in my wrapper, and I'd just send a bool variable that would tell the function to set up, register, and create a WNDCLASSEX structure... Like set the dwStyle flags for CreateWindowEx() as WS_OVERLAPPEDWINDOW|WS_VISIBLE for a windowed DirectX game or WS_POPUP|WS_VISIBLE for a fullscreen one... I think I'm almost there, but I have some trouble getting the function pointer to WndProc() to carry over to QuickWindow.cpp, my wrapper... I'm I going about this the right way? I'm hoping the end result is a file I can include in every program I make, so I don't have to keep writing the window stuff everytime.

    (Edited for my atrocious spelling and grammar)

    'You shall be as Gods!' Xenogears
    'You handle the salads until you get killed!' Space Ghost C2C

    Edited by - DeltaI on February 22, 2002 10:22:46 AM

    Edited by - DeltaI on February 22, 2002 10:24:14 AM

    Share this post


    Link to post
    Share on other sites
    There''s a search tool in the upper right, next to the login icon. If you click on i, you can search various GDNet forums for similar threads; there are several.

    [ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
    Thanks to Kylotan for the idea!

    Share this post


    Link to post
    Share on other sites
    quote:
    Original post by DeltaI
    I searched around GameDev, but all I found were DirectX wrappers


    Already did that, and only found DirectX wrappers... But I''ll try again.



    ''''You shall be as Gods!'''' Xenogears
    ''''You handle the salads until you get killed!'''' Space Ghost C2C

    Share this post


    Link to post
    Share on other sites