source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/RayTraceEffects [DirectX]/Common/DXUT.h @ 3255

Revision 3255, 9.9 KB checked in by szirmay, 15 years ago (diff)
Line 
1//--------------------------------------------------------------------------------------
2// File: DXUT.h
3//
4// DirectX SDK Direct3D sample framework
5//
6// Copyright (c) Microsoft Corporation. All rights reserved.
7//--------------------------------------------------------------------------------------
8#pragma once
9#ifndef DXUT_H
10#define DXUT_H
11
12#ifndef UNICODE
13#error "The sample framework requires a Unicode build. If you are using Microsoft Visual C++ .NET, under the General tab of the project properties change the Character Set to 'Use Unicode Character Set'."
14#endif
15
16
17//--------------------------------------------------------------------------------------
18// Structs
19//--------------------------------------------------------------------------------------
20class CD3DEnumeration;
21class CD3DSettingsDlg;
22
23struct DXUTDeviceSettings
24{
25    UINT AdapterOrdinal;
26    D3DDEVTYPE DeviceType;
27    D3DFORMAT AdapterFormat;
28    DWORD BehaviorFlags;
29    D3DPRESENT_PARAMETERS pp;
30};
31
32
33//--------------------------------------------------------------------------------------
34// Error codes
35//--------------------------------------------------------------------------------------
36#define DXUTERR_NODIRECT3D              MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0901)
37#define DXUTERR_NOCOMPATIBLEDEVICES     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0902)
38#define DXUTERR_MEDIANOTFOUND           MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0903)
39#define DXUTERR_NONZEROREFCOUNT         MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0904)
40#define DXUTERR_CREATINGDEVICE          MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0905)
41#define DXUTERR_RESETTINGDEVICE         MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0906)
42#define DXUTERR_CREATINGDEVICEOBJECTS   MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0907)
43#define DXUTERR_RESETTINGDEVICEOBJECTS  MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0908)
44#define DXUTERR_INCORRECTVERSION        MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0909)
45
46
47//--------------------------------------------------------------------------------------
48// Callback registration
49//--------------------------------------------------------------------------------------
50typedef bool    (CALLBACK *LPDXUTCALLBACKISDEVICEACCEPTABLE)( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed );
51typedef void    (CALLBACK *LPDXUTCALLBACKMODIFYDEVICESETTINGS)( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps );
52typedef HRESULT (CALLBACK *LPDXUTCALLBACKDEVICECREATED)( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
53typedef HRESULT (CALLBACK *LPDXUTCALLBACKDEVICERESET)( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
54typedef void    (CALLBACK *LPDXUTCALLBACKDEVICEDESTROYED)();
55typedef void    (CALLBACK *LPDXUTCALLBACKDEVICELOST)();
56typedef void    (CALLBACK *LPDXUTCALLBACKFRAMEMOVE)( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime );
57typedef void    (CALLBACK *LPDXUTCALLBACKFRAMERENDER)( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime );
58typedef void    (CALLBACK *LPDXUTCALLBACKKEYBOARD)( UINT nChar, bool bKeyDown, bool bAltDown );
59typedef void    (CALLBACK *LPDXUTCALLBACKMOUSE)( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos );
60typedef LRESULT (CALLBACK *LPDXUTCALLBACKMSGPROC)( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing );
61typedef void    (CALLBACK *LPDXUTCALLBACKTIMER)( UINT idEvent );
62
63// Device callbacks
64void DXUTSetCallbackDeviceCreated( LPDXUTCALLBACKDEVICECREATED pCallbackDeviceCreated );
65void DXUTSetCallbackDeviceReset( LPDXUTCALLBACKDEVICERESET pCallbackDeviceReset );
66void DXUTSetCallbackDeviceLost( LPDXUTCALLBACKDEVICELOST pCallbackDeviceLost );
67void DXUTSetCallbackDeviceDestroyed( LPDXUTCALLBACKDEVICEDESTROYED pCallbackDeviceDestroyed );
68
69// Frame callbacks
70void DXUTSetCallbackFrameMove( LPDXUTCALLBACKFRAMEMOVE pCallbackFrameMove );
71void DXUTSetCallbackFrameRender( LPDXUTCALLBACKFRAMERENDER pCallbackFrameRender );
72
73// Message callbacks
74void DXUTSetCallbackKeyboard( LPDXUTCALLBACKKEYBOARD pCallbackKeyboard );
75void DXUTSetCallbackMouse( LPDXUTCALLBACKMOUSE pCallbackMouse, bool bIncludeMouseMove = false );
76void DXUTSetCallbackMsgProc( LPDXUTCALLBACKMSGPROC pCallbackMsgProc );
77
78
79//--------------------------------------------------------------------------------------
80// Initialization
81//--------------------------------------------------------------------------------------
82HRESULT DXUTInit( bool bParseCommandLine = true, bool bHandleDefaultHotkeys = true, bool bShowMsgBoxOnError = true );
83
84// Choose either DXUTCreateWindow or DXUTSetWindow.  If using DXUTSetWindow, consider using DXUTStaticWndProc
85HRESULT DXUTCreateWindow( const WCHAR* strWindowTitle = L"Direct3D Window",
86                          HINSTANCE hInstance = NULL, HICON hIcon = NULL, HMENU hMenu = NULL,
87                          int x = CW_USEDEFAULT, int y = CW_USEDEFAULT );
88HRESULT DXUTSetWindow( HWND hWndFocus, HWND hWndDeviceFullScreen, HWND hWndDeviceWindowed, bool bHandleMessages = true );
89LRESULT CALLBACK DXUTStaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
90
91// Choose either DXUTCreateDevice or DXUTSetDevice or DXUTCreateDeviceFromSettings
92HRESULT DXUTCreateDevice( UINT AdapterOrdinal = D3DADAPTER_DEFAULT, bool bWindowed = true,
93                          int nSuggestedWidth = 640, int nSuggestedHeight = 480,
94                          LPDXUTCALLBACKISDEVICEACCEPTABLE pCallbackIsDeviceAcceptable = NULL,
95                          LPDXUTCALLBACKMODIFYDEVICESETTINGS pCallbackModifyDeviceSettings = NULL );
96HRESULT DXUTCreateDeviceFromSettings( DXUTDeviceSettings* pDeviceSettings, bool bPreserveInput = false );
97HRESULT DXUTSetDevice( IDirect3DDevice9* pd3dDevice );
98
99// Choose either DXUTMainLoop or implement your own main loop
100HRESULT DXUTMainLoop( HACCEL hAccel = NULL );
101
102// If not using DXUTMainLoop consider using DXUTRender3DEnvironment
103void DXUTRender3DEnvironment();
104
105
106//--------------------------------------------------------------------------------------
107// Finding valid device settings
108//--------------------------------------------------------------------------------------
109enum DXUT_MATCH_TYPE
110{
111    DXUTMT_IGNORE_INPUT = 0,  // Use the closest valid value to a default
112    DXUTMT_PRESERVE_INPUT,    // Use input without change, but may cause no valid device to be found
113    DXUTMT_CLOSEST_TO_INPUT   // Use the closest valid value to the input
114};
115
116struct DXUTMatchOptions
117{
118    DXUT_MATCH_TYPE eAdapterOrdinal;
119    DXUT_MATCH_TYPE eDeviceType;
120    DXUT_MATCH_TYPE eWindowed;
121    DXUT_MATCH_TYPE eAdapterFormat;
122    DXUT_MATCH_TYPE eVertexProcessing;
123    DXUT_MATCH_TYPE eResolution;
124    DXUT_MATCH_TYPE eBackBufferFormat;
125    DXUT_MATCH_TYPE eBackBufferCount;
126    DXUT_MATCH_TYPE eMultiSample;
127    DXUT_MATCH_TYPE eSwapEffect;
128    DXUT_MATCH_TYPE eDepthFormat;
129    DXUT_MATCH_TYPE eStencilFormat;
130    DXUT_MATCH_TYPE ePresentFlags;
131    DXUT_MATCH_TYPE eRefreshRate;
132    DXUT_MATCH_TYPE ePresentInterval;
133};
134
135HRESULT DXUTFindValidDeviceSettings( DXUTDeviceSettings* pOut, DXUTDeviceSettings* pIn = NULL, DXUTMatchOptions* pMatchOptions = NULL );
136
137
138//--------------------------------------------------------------------------------------
139// Common Tasks
140//--------------------------------------------------------------------------------------
141void    DXUTSetCursorSettings( bool bShowCursorWhenFullScreen, bool bClipCursorWhenFullScreen );
142void    DXUTSetMultimonSettings( bool bAutoChangeAdapter );
143void    DXUTSetShortcutKeySettings( bool bAllowWhenFullscreen = false, bool bAllowWhenWindowed = true ); // Controls the Windows key, and accessibility shortcut keys
144void    DXUTSetConstantFrameTime( bool bConstantFrameTime, float fTimePerFrame = 0.0333f );
145void    DXUTSetShowSettingsDialog( bool bShow );
146HRESULT DXUTSetTimer( LPDXUTCALLBACKTIMER pCallbackTimer, float fTimeoutInSecs = 1.0f, UINT* pnIDEvent = NULL );
147HRESULT DXUTKillTimer( UINT nIDEvent );
148HRESULT DXUTToggleFullScreen();
149HRESULT DXUTToggleREF();
150void    DXUTPause( bool bPauseTime, bool bPauseRendering );
151void    DXUTResetFrameworkState();
152void    DXUTShutdown();
153
154
155//--------------------------------------------------------------------------------------
156// State Retrieval 
157//--------------------------------------------------------------------------------------
158IDirect3D9*             DXUTGetD3DObject(); // Does not addref unlike typical Get* APIs
159IDirect3DDevice9*       DXUTGetD3DDevice(); // Does not addref unlike typical Get* APIs
160DXUTDeviceSettings      DXUTGetDeviceSettings();
161D3DPRESENT_PARAMETERS   DXUTGetPresentParameters();
162const D3DSURFACE_DESC*  DXUTGetBackBufferSurfaceDesc();
163const D3DCAPS9*         DXUTGetDeviceCaps();
164HWND                    DXUTGetHWND();
165HWND                    DXUTGetHWNDFocus();
166HWND                    DXUTGetHWNDDeviceFullScreen();
167HWND                    DXUTGetHWNDDeviceWindowed();
168const RECT&             DXUTGetWindowClientRect();
169double                  DXUTGetTime();
170float                   DXUTGetElapsedTime();
171bool                    DXUTIsWindowed();
172float                   DXUTGetFPS();
173LPCWSTR                 DXUTGetWindowTitle();
174LPCWSTR                 DXUTGetFrameStats();
175LPCWSTR                 DXUTGetDeviceStats();
176bool                    DXUTGetShowSettingsDialog();
177bool                    DXUTIsRenderingPaused();
178bool                    DXUTIsTimePaused();
179int                     DXUTGetExitCode();
180bool                    DXUTIsKeyDown( BYTE vKey ); // Pass a virtual-key code, ex. VK_F1, 'A', VK_RETURN, VK_LSHIFT, etc
181bool                    DXUTIsMouseButtonDown( BYTE vButton ); // Pass a virtual-key code: VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_XBUTTON1, VK_XBUTTON2
182
183#endif
184
185
186
187
Note: See TracBrowser for help on using the repository browser.