source: GTP/trunk/App/Demos/Illum/Standalone/DepthOfField [DirectX]/Common/DXUT.h @ 761

Revision 761, 12.3 KB checked in by szirmay, 19 years ago (diff)

Added a folder remotely

Line 
1//--------------------------------------------------------------------------------------
2// File: DXUT.h
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//--------------------------------------------------------------------------------------
6#pragma once
7#ifndef DXUT_H
8#define DXUT_H
9
10#ifndef UNICODE
11#error "DXUT requires a Unicode build. See the nearby comments for details"
12//
13// If you are using Microsoft Visual C++ .NET, under the General tab of the project
14// properties change the Character Set to 'Use Unicode Character Set'. 
15//
16// Windows XP and later are native Unicode so Unicode applications will perform better. 
17// For Windows 98 and Windows Me support, consider using the Microsoft Layer for Unicode (MSLU). 
18//
19// To use MSLU, link against a set of libraries similar to this
20//      /nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib /nod:secur32.lib /nod:oleacc.lib /nod:oledlg.lib /nod:sensapi.lib UnicoWS.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib dxerr9.lib dxguid.lib d3dx9d.lib d3d9.lib comctl32.lib
21// and put the unicows.dll (available for download from msdn.microsoft.com) in the exe's folder.
22//
23// For more details see the MSDN article titled:
24// "MSLU: Develop Unicode Applications for Windows 9x Platforms with the Microsoft Layer for Unicode"
25// at http://msdn.microsoft.com/msdnmag/issues/01/10/MSLU/default.aspx
26//
27#endif
28
29//--------------------------------------------------------------------------------------
30// Structs
31//--------------------------------------------------------------------------------------
32class CD3DEnumeration;
33
34struct DXUTDeviceSettings
35{
36    UINT AdapterOrdinal;
37    D3DDEVTYPE DeviceType;
38    D3DFORMAT AdapterFormat;
39    DWORD BehaviorFlags;
40    D3DPRESENT_PARAMETERS pp;
41};
42
43
44//--------------------------------------------------------------------------------------
45// Error codes
46//--------------------------------------------------------------------------------------
47#define DXUTERR_NODIRECT3D              MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0901)
48#define DXUTERR_NOCOMPATIBLEDEVICES     MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0902)
49#define DXUTERR_MEDIANOTFOUND           MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0903)
50#define DXUTERR_NONZEROREFCOUNT         MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0904)
51#define DXUTERR_CREATINGDEVICE          MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0905)
52#define DXUTERR_RESETTINGDEVICE         MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0906)
53#define DXUTERR_CREATINGDEVICEOBJECTS   MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0907)
54#define DXUTERR_RESETTINGDEVICEOBJECTS  MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0908)
55#define DXUTERR_INCORRECTVERSION        MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0909)
56
57
58//--------------------------------------------------------------------------------------
59// Callback registration
60//--------------------------------------------------------------------------------------
61typedef bool    (CALLBACK *LPDXUTCALLBACKISDEVICEACCEPTABLE)( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext );
62typedef bool    (CALLBACK *LPDXUTCALLBACKMODIFYDEVICESETTINGS)( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext );
63typedef HRESULT (CALLBACK *LPDXUTCALLBACKDEVICECREATED)( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
64typedef HRESULT (CALLBACK *LPDXUTCALLBACKDEVICERESET)( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
65typedef void    (CALLBACK *LPDXUTCALLBACKDEVICEDESTROYED)( void* pUserContext );
66typedef void    (CALLBACK *LPDXUTCALLBACKDEVICELOST)( void* pUserContext );
67typedef void    (CALLBACK *LPDXUTCALLBACKFRAMEMOVE)( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );
68typedef void    (CALLBACK *LPDXUTCALLBACKFRAMERENDER)( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext );
69typedef void    (CALLBACK *LPDXUTCALLBACKKEYBOARD)( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext );
70typedef void    (CALLBACK *LPDXUTCALLBACKMOUSE)( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext );
71typedef LRESULT (CALLBACK *LPDXUTCALLBACKMSGPROC)( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext );
72typedef void    (CALLBACK *LPDXUTCALLBACKTIMER)( UINT idEvent, void* pUserContext );
73
74// Device callbacks
75void DXUTSetCallbackDeviceCreated( LPDXUTCALLBACKDEVICECREATED pCallbackDeviceCreated, void* pUserContext = NULL );
76void DXUTSetCallbackDeviceReset( LPDXUTCALLBACKDEVICERESET pCallbackDeviceReset, void* pUserContext = NULL );
77void DXUTSetCallbackDeviceLost( LPDXUTCALLBACKDEVICELOST pCallbackDeviceLost, void* pUserContext = NULL );
78void DXUTSetCallbackDeviceDestroyed( LPDXUTCALLBACKDEVICEDESTROYED pCallbackDeviceDestroyed, void* pUserContext = NULL );
79void DXUTSetCallbackDeviceChanging( LPDXUTCALLBACKMODIFYDEVICESETTINGS pCallbackModifyDeviceSettings, void* pUserContext = NULL );
80
81// Frame callbacks
82void DXUTSetCallbackFrameMove( LPDXUTCALLBACKFRAMEMOVE pCallbackFrameMove, void* pUserContext = NULL );
83void DXUTSetCallbackFrameRender( LPDXUTCALLBACKFRAMERENDER pCallbackFrameRender, void* pUserContext = NULL );
84
85// Message callbacks
86void DXUTSetCallbackKeyboard( LPDXUTCALLBACKKEYBOARD pCallbackKeyboard, void* pUserContext = NULL );
87void DXUTSetCallbackMouse( LPDXUTCALLBACKMOUSE pCallbackMouse, bool bIncludeMouseMove = false, void* pUserContext = NULL );
88void DXUTSetCallbackMsgProc( LPDXUTCALLBACKMSGPROC pCallbackMsgProc, void* pUserContext = NULL );
89
90
91//--------------------------------------------------------------------------------------
92// Initialization
93//--------------------------------------------------------------------------------------
94HRESULT DXUTInit( bool bParseCommandLine = true, bool bHandleDefaultHotkeys = true, bool bShowMsgBoxOnError = true, bool bHandleAltEnter = true );
95
96// Choose either DXUTCreateWindow or DXUTSetWindow.  If using DXUTSetWindow, consider using DXUTStaticWndProc
97HRESULT DXUTCreateWindow( const WCHAR* strWindowTitle = L"Direct3D Window",
98                          HINSTANCE hInstance = NULL, HICON hIcon = NULL, HMENU hMenu = NULL,
99                          int x = CW_USEDEFAULT, int y = CW_USEDEFAULT );
100HRESULT DXUTSetWindow( HWND hWndFocus, HWND hWndDeviceFullScreen, HWND hWndDeviceWindowed, bool bHandleMessages = true );
101LRESULT CALLBACK DXUTStaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
102
103// Choose either DXUTCreateDevice or DXUTSetDevice or DXUTCreateDeviceFromSettings
104HRESULT DXUTCreateDevice( UINT AdapterOrdinal = D3DADAPTER_DEFAULT, bool bWindowed = true,
105                          int nSuggestedWidth = 0, int nSuggestedHeight = 0,
106                          LPDXUTCALLBACKISDEVICEACCEPTABLE pCallbackIsDeviceAcceptable = NULL,
107                          LPDXUTCALLBACKMODIFYDEVICESETTINGS pCallbackModifyDeviceSettings = NULL,
108                          void* pUserContext = NULL );
109HRESULT DXUTCreateDeviceFromSettings( DXUTDeviceSettings* pDeviceSettings, bool bPreserveInput = false, bool bClipWindowToSingleAdapter = true );
110HRESULT DXUTSetDevice( IDirect3DDevice9* pd3dDevice );
111
112// Choose either DXUTMainLoop or implement your own main loop
113HRESULT DXUTMainLoop( HACCEL hAccel = NULL );
114
115// If not using DXUTMainLoop consider using DXUTRender3DEnvironment
116void DXUTRender3DEnvironment();
117
118
119//--------------------------------------------------------------------------------------
120// Finding valid device settings
121//--------------------------------------------------------------------------------------
122enum DXUT_MATCH_TYPE
123{
124    DXUTMT_IGNORE_INPUT = 0,  // Use the closest valid value to a default
125    DXUTMT_PRESERVE_INPUT,    // Use input without change, but may cause no valid device to be found
126    DXUTMT_CLOSEST_TO_INPUT   // Use the closest valid value to the input
127};
128
129struct DXUTMatchOptions
130{
131    DXUT_MATCH_TYPE eAdapterOrdinal;
132    DXUT_MATCH_TYPE eDeviceType;
133    DXUT_MATCH_TYPE eWindowed;
134    DXUT_MATCH_TYPE eAdapterFormat;
135    DXUT_MATCH_TYPE eVertexProcessing;
136    DXUT_MATCH_TYPE eResolution;
137    DXUT_MATCH_TYPE eBackBufferFormat;
138    DXUT_MATCH_TYPE eBackBufferCount;
139    DXUT_MATCH_TYPE eMultiSample;
140    DXUT_MATCH_TYPE eSwapEffect;
141    DXUT_MATCH_TYPE eDepthFormat;
142    DXUT_MATCH_TYPE eStencilFormat;
143    DXUT_MATCH_TYPE ePresentFlags;
144    DXUT_MATCH_TYPE eRefreshRate;
145    DXUT_MATCH_TYPE ePresentInterval;
146};
147
148HRESULT DXUTFindValidDeviceSettings( DXUTDeviceSettings* pOut, DXUTDeviceSettings* pIn = NULL, DXUTMatchOptions* pMatchOptions = NULL );
149
150
151//--------------------------------------------------------------------------------------
152// Common Tasks
153//--------------------------------------------------------------------------------------
154void    DXUTSetCursorSettings( bool bShowCursorWhenFullScreen, bool bClipCursorWhenFullScreen );
155void    DXUTSetMultimonSettings( bool bAutoChangeAdapter );
156void    DXUTSetShortcutKeySettings( bool bAllowWhenFullscreen = false, bool bAllowWhenWindowed = true ); // Controls the Windows key, and accessibility shortcut keys
157void    DXUTSetWindowSettings( bool bCallDefWindowProc = true );
158void    DXUTSetConstantFrameTime( bool bConstantFrameTime, float fTimePerFrame = 0.0333f );
159HRESULT DXUTSetTimer( LPDXUTCALLBACKTIMER pCallbackTimer, float fTimeoutInSecs = 1.0f, UINT* pnIDEvent = NULL, void* pCallbackUserContext = NULL );
160HRESULT DXUTKillTimer( UINT nIDEvent );
161HRESULT DXUTToggleFullScreen();
162HRESULT DXUTToggleREF();
163void    DXUTPause( bool bPauseTime, bool bPauseRendering );
164void    DXUTResetFrameworkState();
165void    DXUTShutdown( int nExitCode = 0 );
166
167
168//--------------------------------------------------------------------------------------
169// State Retrieval 
170//--------------------------------------------------------------------------------------
171IDirect3D9*             DXUTGetD3DObject(); // Does not addref unlike typical Get* APIs
172IDirect3DDevice9*       DXUTGetD3DDevice(); // Does not addref unlike typical Get* APIs
173DXUTDeviceSettings      DXUTGetDeviceSettings();
174D3DPRESENT_PARAMETERS   DXUTGetPresentParameters();
175const D3DSURFACE_DESC*  DXUTGetBackBufferSurfaceDesc();
176const D3DCAPS9*         DXUTGetDeviceCaps();
177HINSTANCE               DXUTGetHINSTANCE();
178HWND                    DXUTGetHWND();
179HWND                    DXUTGetHWNDFocus();
180HWND                    DXUTGetHWNDDeviceFullScreen();
181HWND                    DXUTGetHWNDDeviceWindowed();
182RECT                    DXUTGetWindowClientRect();
183RECT                    DXUTGetWindowClientRectAtModeChange(); // Useful for returning to windowed mode with the same resolution as before toggle to full screen mode
184RECT                    DXUTGetFullsceenClientRectAtModeChange(); // Useful for returning to full screen mode with the same resolution as before toggle to windowed mode
185double                  DXUTGetTime();
186float                   DXUTGetElapsedTime();
187bool                    DXUTIsWindowed();
188float                   DXUTGetFPS();
189LPCWSTR                 DXUTGetWindowTitle();
190LPCWSTR                 DXUTGetFrameStats( bool bIncludeFPS = false );
191LPCWSTR                 DXUTGetDeviceStats();
192bool                    DXUTIsRenderingPaused();
193bool                    DXUTIsTimePaused();
194bool                    DXUTIsActive();
195int                     DXUTGetExitCode();
196bool                    DXUTGetShowMsgBoxOnError();
197bool                    DXUTGetHandleDefaultHotkeys();
198bool                    DXUTIsKeyDown( BYTE vKey ); // Pass a virtual-key code, ex. VK_F1, 'A', VK_RETURN, VK_LSHIFT, etc
199bool                    DXUTIsMouseButtonDown( BYTE vButton ); // Pass a virtual-key code: VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_XBUTTON1, VK_XBUTTON2
200bool                    DXUTGetAutomation();  // Returns true if -automation parameter is used to launch the app
201
202#endif
203
204
205
206
Note: See TracBrowser for help on using the repository browser.