Sign in to follow this  

DXUT Framework

This topic is 4305 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

Thanks guys, I finally went along with using the DXUT framework and by looking at the 'EmptyProject' ...project, it looks really nice. Anyways, I don't want to use the EmptyProject as my template project, instead, I'd like (As I always do) make my own. I have the same file as in EmptyProject with some things changed:
#pragma comment(lib, "dxerr9.lib")
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "d3dx9d.lib")
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "comctl32.lib")

#include <dxstdafx.h>
#include <dxut.h>
#include <d3dx9.h>

bool CALLBACK IsDeviceAcceptable(D3DCAPS9 *pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void *pUserContext)
{
    // Typically want to skip backbuffer formats that don't support alpha blending
    IDirect3D9 *pD3D = DXUTGetD3DObject(); 
    if(FAILED(pD3D->CheckDeviceFormat(pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat)))
        return false;

    return true;
}

bool CALLBACK ModifyDeviceSettings(DXUTDeviceSettings *pDeviceSettings, const D3DCAPS9 *pCaps, void *pUserContext)
{
    return true;
}

HRESULT CALLBACK OnCreateDevice(IDirect3DDevice9 *pd3dDevice, const D3DSURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext)
{
    return S_OK;
}

HRESULT CALLBACK OnResetDevice(IDirect3DDevice9 * pd3dDevice, const D3DSURFACE_DESC * pBackBufferSurfaceDesc, void * pUserContext)
{
    return S_OK;
}

void CALLBACK OnFrameMove(IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
{
}

void CALLBACK OnFrameRender(IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
{
    HRESULT hr;

    // Clear the render target and the zbuffer 
    V(pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0));

    // Render the scene
    if(SUCCEEDED(pd3dDevice->BeginScene()))
    {
        V(pd3dDevice->EndScene());
    }
}

LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool *pbNoFurtherProcessing, void *pUserContext)
{
    return 0;
}

void CALLBACK OnLostDevice(void *pUserContext)
{
}

void CALLBACK OnDestroyDevice(void *pUserContext)
{
}

INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    // Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

    // Set the callback functions
    DXUTSetCallbackDeviceCreated(OnCreateDevice);
    DXUTSetCallbackDeviceReset(OnResetDevice);
    DXUTSetCallbackDeviceLost(OnLostDevice);
    DXUTSetCallbackDeviceDestroyed(OnDestroyDevice);
    DXUTSetCallbackMsgProc(MsgProc);
    DXUTSetCallbackFrameRender(OnFrameRender);
    DXUTSetCallbackFrameMove(OnFrameMove);
   
    // TODO: Perform any application-level initialization here

    // Initialize DXUT and create the desired Win32 window and Direct3D device for the application
    DXUTInit(true, true, true); // Parse the command line, handle the default hotkeys, and show msgboxes
    DXUTSetCursorSettings(true, true); // Show the cursor and clip it when in full screen
    DXUTCreateWindow(L"EmptyProject");
    DXUTCreateDevice(D3DADAPTER_DEFAULT, true, 640, 480, IsDeviceAcceptable, ModifyDeviceSettings);

    // Start the render loop
    DXUTMainLoop();

    // TODO: Perform any application-level cleanup here

    return DXUTGetExitCode();
}

Sorry for posting that code but I figured you'd need it (possibly). Anyways, so I've linked to the so called necessary libraries, and since I don't want to use precompiled headers (dxstfax.h or whatever), I included the headers myself. I checked DXUT.h and other headers and it looks like the functions called in this source aren't dependent on it, or anything else. The errors I get are unresolved externals, which most likely means the PrecompileHeader is needed or I didn't link the correct libraries. I really really wouldn't like to use the precompiled header and would like to know if you guys could please help me bypass this? Thanks guys.

Share this post


Link to post
Share on other sites
(Sticks hands straight up into the air, lies flat on the ground, facing the ground) "I'M STUPID! I'M STUPID!" (Stupid Police come and handcuff him)

I forgot to link to d3dx9.lib lol :)

Anyways, I'm getting an 'Unexpected end of file' error now. It's on line '105', the line after the last line (which includes the } curly brace). Anyone please help?


#pragma comment(lib, "dxerr.lib")
#pragma comment(lib, "dxguid.lib")

#if defined(DEBUG) || defined(_DEBUG)
#pragma comment(lib, "d3dx9d.lib")
#else

#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "comctl32.lib")

#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr.h>

bool CALLBACK IsDeviceAcceptable(D3DCAPS9 *pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void *pUserContext)
{
// Typically want to skip backbuffer formats that don't support alpha blending
IDirect3D9 *pD3D = DXUTGetD3DObject();
if(FAILED(pD3D->CheckDeviceFormat(pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat)))
return false;

return true;
}

bool CALLBACK ModifyDeviceSettings(DXUTDeviceSettings *pDeviceSettings, const D3DCAPS9 *pCaps, void *pUserContext)
{
return true;
}

HRESULT CALLBACK OnCreateDevice(IDirect3DDevice9 *pd3dDevice, const D3DSURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext)
{
return S_OK;
}

HRESULT CALLBACK OnResetDevice(IDirect3DDevice9 * pd3dDevice, const D3DSURFACE_DESC * pBackBufferSurfaceDesc, void * pUserContext)
{
return S_OK;
}

void CALLBACK OnFrameMove(IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
{
}

void CALLBACK OnFrameRender(IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
{
HRESULT hr;

// Clear the render target and the zbuffer
V(pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0));

// Render the scene
if(SUCCEEDED(pd3dDevice->BeginScene()))
{
V(pd3dDevice->EndScene());
}
}

LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool *pbNoFurtherProcessing, void *pUserContext)
{
return 0;
}

void CALLBACK OnLostDevice(void *pUserContext)
{
}

void CALLBACK OnDestroyDevice(void *pUserContext)
{
}

INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

// Set the callback functions
DXUTSetCallbackDeviceCreated(OnCreateDevice);
DXUTSetCallbackDeviceReset(OnResetDevice);
DXUTSetCallbackDeviceLost(OnLostDevice);
DXUTSetCallbackDeviceDestroyed(OnDestroyDevice);
DXUTSetCallbackMsgProc(MsgProc);
DXUTSetCallbackFrameRender(OnFrameRender);
DXUTSetCallbackFrameMove(OnFrameMove);

// TODO: Perform any application-level initialization here

// Initialize DXUT and create the desired Win32 window and Direct3D device for the application
DXUTInit(true, true, true); // Parse the command line, handle the default hotkeys, and show msgboxes
DXUTSetCursorSettings(true, true); // Show the cursor and clip it when in full screen
DXUTCreateWindow(L"EmptyProject");
DXUTCreateDevice(D3DADAPTER_DEFAULT, true, 640, 480, IsDeviceAcceptable, ModifyDeviceSettings);

// Start the render loop
DXUTMainLoop();

// TODO: Perform any application-level cleanup here

return DXUTGetExitCode();
}

Share this post


Link to post
Share on other sites
I couldnt see any problems but that can mean multiple things...a common thing that happens to me with large programs and forgetting a closing bracket somewhere.
Hope that helps!

Share this post


Link to post
Share on other sites
You're missing an #endif for the #ifdef that you have at the top. You probably meant #endif instead of #else.

Also, you'll probably find that DXUT does things just slightly differently from what you want in the end, so I recommend copying the DXUT sources into your own project folder, and treating them as your own source. Edit away!

Share this post


Link to post
Share on other sites
I think I know what you guys mean, about editing the DXUT stuff. Thanks for the help, I'm really sorry but I'm really desparate. I managed to fix the errors on my own but now I still get the unresolved externals on the DXUT calls :(


#pragma comment(lib, "dxerr.lib")
#pragma comment(lib, "dxguid.lib")
//#pragma comment(lib, "d3dx9d.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "comctl32.lib")

#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr.h>
#include <dxut.h>

bool CALLBACK IsDeviceAcceptable(D3DCAPS9 *pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void *pUserContext)
{
// Typically want to skip backbuffer formats that don't support alpha blending
IDirect3D9 *pD3D = DXUTGetD3DObject();
if(FAILED(pD3D->CheckDeviceFormat(pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat)))
return false;

return true;
}

bool CALLBACK ModifyDeviceSettings(DXUTDeviceSettings *pDeviceSettings, const D3DCAPS9 *pCaps, void *pUserContext)
{
return true;
}

HRESULT CALLBACK OnCreateDevice(IDirect3DDevice9 *pd3dDevice, const D3DSURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext)
{
return S_OK;
}

HRESULT CALLBACK OnResetDevice(IDirect3DDevice9 * pd3dDevice, const D3DSURFACE_DESC * pBackBufferSurfaceDesc, void * pUserContext)
{
return S_OK;
}

void CALLBACK OnFrameMove(IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
{
}

void CALLBACK OnFrameRender(IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext)
{
// Clear the render target and the zbuffer
pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0);

// Render the scene
if(SUCCEEDED(pd3dDevice->BeginScene()))
{
pd3dDevice->EndScene();
}
}

LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool *pbNoFurtherProcessing, void *pUserContext)
{
return 0;
}

void CALLBACK OnLostDevice(void *pUserContext)
{
}

void CALLBACK OnDestroyDevice(void *pUserContext)
{
}

INT WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

// Set the callback functions
DXUTSetCallbackDeviceCreated(OnCreateDevice);
DXUTSetCallbackDeviceReset(OnResetDevice);
DXUTSetCallbackDeviceLost(OnLostDevice);
DXUTSetCallbackDeviceDestroyed(OnDestroyDevice);
DXUTSetCallbackMsgProc(MsgProc);
DXUTSetCallbackFrameRender(OnFrameRender);
DXUTSetCallbackFrameMove(OnFrameMove);

// TODO: Perform any application-level initialization here

// Initialize DXUT and create the desired Win32 window and Direct3D device for the application
DXUTInit(true, true, true); // Parse the command line, handle the default hotkeys, and show msgboxes
DXUTSetCursorSettings(true, true); // Show the cursor and clip it when in full screen
DXUTCreateWindow(L"EmptyProject");
DXUTCreateDevice(D3DADAPTER_DEFAULT, true, 640, 480, IsDeviceAcceptable, ModifyDeviceSettings);

// Start the render loop
DXUTMainLoop();

// TODO: Perform any application-level cleanup here

return DXUTGetExitCode();
}

Share this post


Link to post
Share on other sites
Why not just "#include dxstdafx.h" in your program? It has all the stuff in it to include the myraid of other dxut .h files. You don't have to use a precompiled header if you don't want to.

Share this post


Link to post
Share on other sites

This topic is 4305 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this