Changeset 2244
- Timestamp:
- 03/13/07 11:11:19 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/MultipleReflections
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/MultipleReflections/MultipleReflections.cpp
r2242 r2244 20 20 ID3DXFont* g_pFont; ///< Font for drawing text 21 21 ID3DXSprite* g_pTextSprite; ///< Sprite for batching draw text calls 22 bool g_showWelcomeScreen = true; 22 23 //slider ids 23 24 #define FIRST_SLIDER 10 … … 125 126 } 126 127 127 128 void compileShaders() 129 { 130 HRESULT hr; 131 //load effect files 132 DWORD dwShaderFlags = 0; 133 ID3DXBuffer* errBuff; // buffer for error message 134 if (FAILED(hr = D3DXCreateEffectFromFile( g_pd3dDevice, L"Media\\Shaders\\basicShaders.fx", NULL, NULL, dwShaderFlags, 135 NULL, &g_basicShaders, &errBuff ))) // if compilation error occurs 136 { 137 int BufSize = errBuff->GetBufferSize(); 138 139 wchar_t* wbuf = new wchar_t[BufSize]; 140 mbstowcs( wbuf, (const char*)errBuff->GetBufferPointer(), BufSize ); 141 MessageBox(NULL, wbuf, L".fx Compilation Error", MB_ICONERROR); // error message 142 143 delete wbuf; 144 exit(-1); 145 } 146 dwShaderFlags += D3DXSHADER_PREFER_FLOW_CONTROL; 147 if (FAILED(hr = D3DXCreateEffectFromFile( g_pd3dDevice, L"Media\\Shaders\\MultipleReflection.fx", NULL, NULL, dwShaderFlags, 148 NULL, &g_reflectionShaders, &errBuff ))) // if compilation error occurs 149 { 150 int BufSize = errBuff->GetBufferSize(); 151 152 wchar_t* wbuf = new wchar_t[BufSize]; 153 mbstowcs( wbuf, (const char*)errBuff->GetBufferPointer(), BufSize ); 154 MessageBox(NULL, wbuf, L".fx Compilation Error", MB_ICONERROR); // error message 155 156 delete wbuf; 157 exit(-1); 158 } 159 } 128 160 //-------------------------------------------------------------------------------------- 129 161 // Create any D3DPOOL_MANAGED resources here … … 142 174 g_objectMesh->SetContainerSize(environmentSize); 143 175 144 //load effect files145 DWORD dwShaderFlags = 0;146 ID3DXBuffer* errBuff; // buffer for error message147 if (FAILED(hr = D3DXCreateEffectFromFile( g_pd3dDevice, L"Media\\Shaders\\basicShaders.fx", NULL, NULL, dwShaderFlags,148 NULL, &g_basicShaders, &errBuff ))) // if compilation error occurs149 {150 int BufSize = errBuff->GetBufferSize();151 152 wchar_t* wbuf = new wchar_t[BufSize];153 mbstowcs( wbuf, (const char*)errBuff->GetBufferPointer(), BufSize );154 MessageBox(NULL, wbuf, L".fx Compilation Error", MB_ICONERROR); // error message155 156 delete wbuf;157 exit(-1);158 }159 dwShaderFlags += D3DXSHADER_PREFER_FLOW_CONTROL;160 if (FAILED(hr = D3DXCreateEffectFromFile( g_pd3dDevice, L"Media\\Shaders\\MultipleReflection.fx", NULL, NULL, dwShaderFlags,161 NULL, &g_reflectionShaders, &errBuff ))) // if compilation error occurs162 {163 int BufSize = errBuff->GetBufferSize();164 165 wchar_t* wbuf = new wchar_t[BufSize];166 mbstowcs( wbuf, (const char*)errBuff->GetBufferPointer(), BufSize );167 MessageBox(NULL, wbuf, L".fx Compilation Error", MB_ICONERROR); // error message168 169 delete wbuf;170 exit(-1);171 }172 173 174 176 // Initialize the font 175 177 V_RETURN( D3DXCreateFont( g_pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, … … 438 440 } 439 441 442 void renderWelcomeText() 443 { 444 const D3DSURFACE_DESC* backBufferDesc = DXUTGetBackBufferSurfaceDesc(); 445 446 CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 20 ); 447 txtHelper.Begin(); 448 449 txtHelper.SetInsertionPos( backBufferDesc->Width / 2 - 100, backBufferDesc->Height /2 ); 450 txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) ); 451 452 txtHelper.DrawFormattedTextLine( L"Compiling shaders. Please wait..." ); 453 } 440 454 //-------------------------------------------------------------------------------------- 441 455 // Render the scene … … 451 465 if( SUCCEEDED( pd3dDevice->BeginScene() ) ) 452 466 { 453 renderEnvMaps(); 454 renderToScreen(); 455 renderText(); 456 if(g_showGUI) 457 g_HUD.OnRender( fElapsedTime ); 467 if(g_showWelcomeScreen) 468 { 469 renderWelcomeText(); 470 g_showWelcomeScreen = false; 471 } 472 else 473 { 474 if(g_basicShaders == 0) 475 compileShaders(); 476 renderEnvMaps(); 477 renderToScreen(); 478 renderText(); 479 if(g_showGUI) 480 g_HUD.OnRender( fElapsedTime ); 481 } 458 482 V( pd3dDevice->EndScene() ); 459 } 483 } 460 484 } 461 485
Note: See TracChangeset
for help on using the changeset viewer.