Thread: D3DFrameWork example

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    D3DFrameWork example

    Ok, I've got the framework class done.

    As it is all you need to do to get D3D up and running is simply run the code as is. This is only the EXE right now - I'll release the sources later.
    I want to test this on several systems before I release it to the newbs for game dev.
    The last thing we need is this board to get flooded with posts about why the framework doesn't work.

    The idea here is that you simply have 3 functions for the game.

    Setup() - all setup is done here
    Display() - scene is drawn here
    Shutdown() - everything allocated in setup is released here.

    Upon exiting the message loop the framework will shutdown and release the IDirect3DDevice9 pointer as well as delete the global D3D9 object. The IDirect3D9 pointer is relased shortly after creation inside of D3DFrameWork::Init().

    All you must do to use this framework is to add code to Setup(), Display(), and Shutdown(). I took this idea from one of my books....but I revised it a little bit. There is a global D3D9 object that represents the entire device. It is global for simplicity sake and not much would be gained by hiding it.

    Please test this code as is to see if it works on your system. It should fire up Direct3D, clear the screen to black and sit there. Press ESC to exit the program.

    You should not receive any errors from Windows about this program when it closes. If you do...let me know.

    After I verify that it works well on most systems (it should work on all) I will place the framework inside of a DLL and you will simply need to d/l the DLL and link with it in your projects. This will protect my framework code from needless tampering.
    Last edited by VirtualAce; 07-06-2004 at 03:21 AM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Worked fine for me.

  3. #3
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Worked for me as well, as long as you don't alt + tab or alt + enter.

  4. #4
    Programmer in Training TWIXMIX's Avatar
    Join Date
    Feb 2004
    Posts
    57
    Yup, worked for me to.
    Learning C++
    Programmer in training

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Yeah, ALT-Tab/Enter is not supported as of yet. Not hard to fix though.

    Only one person so far has had issues with the code and that is probably due to the stencil buffer format and/or the pixel format being used.

    If you could provide your system specs in your responses it would greatly assist me.

    Looks like it will work on quite a few systems though.

  6. #6
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Barton 2500 @ 2.1GHz
    1GB PC2700
    GeForceFX 5900SE 128 MB

  7. #7
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Works fine.

    Athlon XP2800
    1GB PC2700
    Radeon 9800Pro 128MB
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    AMD XP 2200+
    512 mb ram
    RADEON AIW 7500

  9. #9
    ---
    Join Date
    May 2004
    Posts
    1,379
    Athlon XP +3200 @ 2.2Ghz
    1024 MB RAM
    GeForce 4 ti 4200

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    So....did it work sand_man? I don't see any post about if you tried it or not. I'm assuming it did since you provided the specs.

  11. #11
    ---
    Join Date
    May 2004
    Posts
    1,379
    lol
    yeah sorry it worked fine dude.

  12. #12
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    Bubba, shouldnt you be asking for the screen resolution and depth? i dont think knowing their RAM and CPU speed is gonna help much... (just a suggestion )

    and yeah worked for me,

    1024x768 at 32 bit geforce fx 5600

    EDIT: for the stencil buffer problem the other guy had, why dont you do something like this:

    Code:
    if (g_D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32) == D3D_OK)
    {
    	g_PresentParameters.EnableAutoDepthStencil = true;
        g_PresentParameters.AutoDepthStencilFormat = D3DFMT_D32;
    
    	Debug.LogInfo("<li>32-bit depth buffer selected");
    }
    else if (g_D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8) == D3D_OK)
    {
    	g_PresentParameters.EnableAutoDepthStencil = true;
    	g_PresentParameters.AutoDepthStencilFormat = D3DFMT_D24X8;
    
    	Debug.LogInfo("<li>24-bit depth buffer selected");
    }
    else if (g_D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16) == D3D_OK)
    {
    	g_PresentParameters.EnableAutoDepthStencil = true;
    	g_PresentParameters.AutoDepthStencilFormat = D3DFMT_D16;
    
    	Debug.LogInfo("<li>16-bit depth buffer selected");
    }
    else
    {
    	g_PresentParameters.EnableAutoDepthStencil = false;
    
    	Debug.LogInfo("<li>No depth buffer selected");
    }
    I use it in all my dx apps, and they run fine on all comps, well all the comps that i know of anyway...
    Last edited by X PaYnE X; 07-21-2004 at 04:17 PM.

  13. #13
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Yeah I'm not cycling through all of the formats...but that is to come.

  14. #14
    Registered User Draco's Avatar
    Join Date
    Apr 2002
    Posts
    463
    Worked just fine for me.

    AthlonXP 1900+
    WindowsXP
    GeForce3
    1024*768*32, if your program uses desktop resolution

Popular pages Recent additions subscribe to a feed