1 | /--------------------------------------------------------------------------------------
|
---|
2 | // File: ToneMap9.cpp
|
---|
3 | //
|
---|
4 | // Empty starting point for new Direct3D applications
|
---|
5 | //
|
---|
6 | // Copyright (c) Microsoft Corporation. All rights reserved.
|
---|
7 | //--------------------------------------------------------------------------------------
|
---|
8 | #include "dxstdafx.h"
|
---|
9 | #include "resource.h"
|
---|
10 |
|
---|
11 |
|
---|
12 | //--------------------------------------------------------------------------------------
|
---|
13 | // Rejects any devices that aren't acceptable by returning false
|
---|
14 | //--------------------------------------------------------------------------------------
|
---|
15 | bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat,
|
---|
16 | D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext )
|
---|
17 | {
|
---|
18 | // Typically want to skip backbuffer formats that don't support alpha blending
|
---|
19 | IDirect3D9* pD3D = DXUTGetD3DObject();
|
---|
20 | if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType,
|
---|
21 | AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,
|
---|
22 | D3DRTYPE_TEXTURE, BackBufferFormat ) ) )
|
---|
23 | return false;
|
---|
24 |
|
---|
25 | return true;
|
---|
26 | }
|
---|
27 |
|
---|
28 |
|
---|
29 | //--------------------------------------------------------------------------------------
|
---|
30 | // Before a device is created, modify the device settings as needed
|
---|
31 | //--------------------------------------------------------------------------------------
|
---|
32 | bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, const D3DCAPS9* pCaps, void* pUserContext )
|
---|
33 | {
|
---|
34 | return true;
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 | //--------------------------------------------------------------------------------------
|
---|
39 | // Create any D3DPOOL_MANAGED resources here
|
---|
40 | //--------------------------------------------------------------------------------------
|
---|
41 | HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
|
---|
42 | {
|
---|
43 | return S_OK;
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | //--------------------------------------------------------------------------------------
|
---|
48 | // Create any D3DPOOL_DEFAULT resources here
|
---|
49 | //--------------------------------------------------------------------------------------
|
---|
50 | HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice,
|
---|
51 | const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
|
---|
52 | {
|
---|
53 | return S_OK;
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | //--------------------------------------------------------------------------------------
|
---|
58 | // Handle updates to the scene
|
---|
59 | //--------------------------------------------------------------------------------------
|
---|
60 | void CALLBACK OnFrameMove( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
|
---|
61 | {
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | //--------------------------------------------------------------------------------------
|
---|
66 | // Render the scene
|
---|
67 | //--------------------------------------------------------------------------------------
|
---|
68 | void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
|
---|
69 | {
|
---|
70 | HRESULT hr;
|
---|
71 |
|
---|
72 | // Clear the render target and the zbuffer
|
---|
73 | V( pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0) );
|
---|
74 |
|
---|
75 | // Render the scene
|
---|
76 | if( SUCCEEDED( pd3dDevice->BeginScene() ) )
|
---|
77 | {
|
---|
78 | V( pd3dDevice->EndScene() );
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | //--------------------------------------------------------------------------------------
|
---|
84 | // Handle messages to the application
|
---|
85 | //--------------------------------------------------------------------------------------
|
---|
86 | LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
|
---|
87 | bool* pbNoFurtherProcessing, void* pUserContext )
|
---|
88 | {
|
---|
89 | return 0;
|
---|
90 | }
|
---|
91 |
|
---|
92 |
|
---|
93 | //--------------------------------------------------------------------------------------
|
---|
94 | // Release resources created in the OnResetDevice callback here
|
---|
95 | //--------------------------------------------------------------------------------------
|
---|
96 | void CALLBACK OnLostDevice( void* pUserContext )
|
---|
97 | {
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | //--------------------------------------------------------------------------------------
|
---|
102 | // Release resources created in the OnCreateDevice callback here
|
---|
103 | //--------------------------------------------------------------------------------------
|
---|
104 | void CALLBACK OnDestroyDevice( void* pUserContext )
|
---|
105 | {
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|
110 | //--------------------------------------------------------------------------------------
|
---|
111 | // Initialize everything and go into a render loop
|
---|
112 | //--------------------------------------------------------------------------------------
|
---|
113 | INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int )
|
---|
114 | {
|
---|
115 | // Enable run-time memory check for debug builds.
|
---|
116 | #if defined(DEBUG) | defined(_DEBUG)
|
---|
117 | _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | // Set the callback functions
|
---|
121 | DXUTSetCallbackDeviceCreated( OnCreateDevice );
|
---|
122 | DXUTSetCallbackDeviceReset( OnResetDevice );
|
---|
123 | DXUTSetCallbackDeviceLost( OnLostDevice );
|
---|
124 | DXUTSetCallbackDeviceDestroyed( OnDestroyDevice );
|
---|
125 | DXUTSetCallbackMsgProc( MsgProc );
|
---|
126 | DXUTSetCallbackFrameRender( OnFrameRender );
|
---|
127 | DXUTSetCallbackFrameMove( OnFrameMove );
|
---|
128 |
|
---|
129 | // TODO: Perform any application-level initialization here
|
---|
130 |
|
---|
131 | // Initialize DXUT and create the desired Win32 window and Direct3D device for the application
|
---|
132 | DXUTInit( true, true, true ); // Parse the command line, handle the default hotkeys, and show msgboxes
|
---|
133 | DXUTSetCursorSettings( true, true ); // Show the cursor and clip it when in full screen
|
---|
134 | DXUTCreateWindow( L"ToneMap9" );
|
---|
135 | DXUTCreateDevice( D3DADAPTER_DEFAULT, true, 640, 480, IsDeviceAcceptable, ModifyDeviceSettings );
|
---|
136 |
|
---|
137 | // Start the render loop
|
---|
138 | DXUTMainLoop();
|
---|
139 |
|
---|
140 | // TODO: Perform any application-level cleanup here
|
---|
141 |
|
---|
142 | return DXUTGetExitCode();
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|