Changeset 3043
- Timestamp:
- 10/19/08 02:07:36 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3042 r3043 17 17 18 18 RenderState::RenderState(): 19 mRenderType(F IXED),19 mRenderType(FORWARD), 20 20 mUseAlphaToCoverage(true), 21 21 mLockCullFaceEnabled(false) … … 67 67 ResourceManager::GetSingleton()->DisableFragmentProfile(); 68 68 ResourceManager::GetSingleton()->DisableVertexProfile(); 69 } 70 71 69 70 mFragmentProgramEnabled = false; 71 mVertexProgramEnabled = false; 72 } 73 74 // q matt: is this function really necessary or would it be better 75 // to just create a query material and use the setstate function? 72 76 bool RenderState::SetMode(Mode mode) 73 77 { … … 85 89 glDisable(GL_LIGHTING); 86 90 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 87 88 if (mRenderType == DEFERRED) 89 { 90 ResourceManager::GetSingleton()->DisableFragmentProfile(); 91 ResourceManager::GetSingleton()->DisableFragmentProfile(); 92 } 93 } 94 91 } 92 93 if (mFragmentProgramEnabled) 94 { 95 ResourceManager::GetSingleton()->DisableFragmentProfile(); 96 } 97 98 if (mVertexProgramEnabled) 99 { 100 ResourceManager::GetSingleton()->DisableVertexProfile(); 101 } 102 95 103 glDepthMask(GL_FALSE); 96 104 … … 107 115 glEnable(GL_LIGHTING); 108 116 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 109 110 if (mRenderType == DEFERRED) 111 { 112 ResourceManager::GetSingleton()->EnableFragmentProfile(); 113 ResourceManager::GetSingleton()->EnableVertexProfile(); 114 } 117 } 118 119 if (mFragmentProgramEnabled) 120 { 121 ResourceManager::GetSingleton()->EnableFragmentProfile(); 122 } 123 124 if (mVertexProgramEnabled) 125 { 126 ResourceManager::GetSingleton()->EnableVertexProfile(); 115 127 } 116 128 … … 168 180 mTexturesEnabled = false; 169 181 170 if ( mRenderType != DEFERRED)//!mat->mFragmentProgram)182 if (!tech->GetFragmentProgram()) 171 183 glDisable(GL_TEXTURE_2D); 172 184 … … 180 192 mTexturesEnabled = true; 181 193 182 if ( mRenderType != DEFERRED)//!mat->mFragmentProgram)194 if (!tech->GetFragmentProgram()) 183 195 glEnable(GL_TEXTURE_2D); 184 196 … … 187 199 } 188 200 189 if (mRenderType == DEFERRED) 190 { 191 ShaderProgram *frag = tech->GetFragmentProgram(); 192 193 if (frag) 194 { 195 if (frag != mCurrentFragmentProgram) 196 { 197 mCurrentFragmentProgram = frag; 198 mCurrentFragmentProgram->Bind(); 199 } 201 ////////// 202 //-- fragment and vertex programs 203 204 ShaderProgram *frag = tech->GetFragmentProgram(); 205 206 if (frag) 207 { 208 if (!mFragmentProgramEnabled) 209 { 210 mFragmentProgramEnabled = true; 211 ResourceManager::GetSingleton()->EnableFragmentProfile(); 212 } 213 214 if (frag != mCurrentFragmentProgram) 215 { 216 mCurrentFragmentProgram = frag; 217 mCurrentFragmentProgram->Bind(); 218 } 200 219 201 tech->GetFragmentProgramParameters()->UpdateParameters(); 202 203 } 204 205 ShaderProgram *vert = tech->GetVertexProgram(); 206 207 if (vert) 208 { 209 if (vert != mCurrentVertexProgram) 210 { 211 mCurrentVertexProgram = vert; 212 mCurrentVertexProgram->Bind(); 213 } 214 215 tech->GetVertexProgramParameters()->UpdateParameters(); 216 } 220 tech->GetFragmentProgramParameters()->UpdateParameters(); 217 221 } 218 222 else 219 223 { 220 // set fixed texture 224 if (mFragmentProgramEnabled) 225 { 226 mFragmentProgramEnabled = false; 227 ResourceManager::GetSingleton()->DisableFragmentProfile(); 228 } 229 } 230 231 ShaderProgram *vert = tech->GetVertexProgram(); 232 233 if (vert) 234 { 235 if (!mVertexProgramEnabled) 236 { 237 mVertexProgramEnabled = true; 238 ResourceManager::GetSingleton()->EnableVertexProfile(); 239 } 240 241 if (vert != mCurrentVertexProgram) 242 { 243 mCurrentVertexProgram = vert; 244 mCurrentVertexProgram->Bind(); 245 } 246 247 tech->GetVertexProgramParameters()->UpdateParameters(); 248 } 249 else 250 { 251 if (mVertexProgramEnabled) 252 { 253 mVertexProgramEnabled = false; 254 ResourceManager::GetSingleton()->DisableVertexProfile(); 255 } 256 } 257 258 if (!mFragmentProgramEnabled) 259 { 260 // set FORWARD texture 221 261 if (tex) 222 262 { -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r3042 r3043 28 28 enum RenderPassType 29 29 { 30 F IXED,30 FORWARD, 31 31 DEPTH_PASS, 32 32 DEFERRED … … 95 95 ShaderProgram *mCurrentVertexProgram; 96 96 ShaderProgram *mCurrentFragmentProgram; 97 98 bool mFragmentProgramEnabled; 99 bool mVertexProgramEnabled; 97 100 }; 98 101 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp
r3041 r3043 8 8 namespace CHCDemoEngine 9 9 { 10 11 static float sCurrentTimer = 0; 10 12 11 13 … … 222 224 { 223 225 static PerfTimer mytimer; 224 mProgram->SetValue1f(mTimer, mytimer.Elapsedms(false) * M_PI / 180.0f); 225 } 226 mProgram->SetValue1f(mTimer, sCurrentTimer); 227 } 228 } 229 230 231 void GPUProgramParameters::InitFrame() 232 { 233 static PerfTimer mytimer; 234 sCurrentTimer = mytimer.Elapsedms(false) * M_PI / 180.0f; 226 235 } 227 236 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h
r3041 r3043 86 86 87 87 88 static void InitFrame(); 88 89 89 90 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r3042 r3043 140 140 vtxParams->SetValue1f(8, 8e-5f); 141 141 } 142 142 /* 143 143 tech->GetVertexProgramParameters()->UpdateParameters(); 144 144 tech->GetVertexProgram()->Bind(); … … 146 146 tech->GetFragmentProgramParameters()->UpdateParameters(); 147 147 tech->GetFragmentProgram()->Bind(); 148 149 // Render sky dome.148 */ 149 // render sky dome 150 150 mSkyDome->Render(state); 151 151 152 // Render additively blended sun disc.152 // render additively blended sun disc. 153 153 //RenderSunDisk(sunDir, camera); 154 154 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3041 r3043 112 112 enum RenderMethod 113 113 { 114 RENDER_F IXED,114 RENDER_FORWARD, 115 115 RENDER_DEPTH_PASS, 116 116 RENDER_DEFERRED, … … 120 120 121 121 /// one of four possible render methods 122 int renderMethod = RENDER_F IXED;122 int renderMethod = RENDER_FORWARD; 123 123 124 124 … … 485 485 visualization = new Visualization(bvh, camera, NULL, &state); 486 486 487 state.SetRenderPassType(RenderState::F IXED);487 state.SetRenderPassType(RenderState::FORWARD); 488 488 489 489 // frame time is restarted every frame 490 490 frameTimer.Start(); 491 492 491 // the rendering loop 493 492 glutMainLoop(); 494 495 493 // clean up 496 494 CleanUp(); … … 870 868 } 871 869 870 GPUProgramParameters::InitFrame(); 872 871 873 872 … … 889 888 890 889 if (renderLightView) 891 renderMethod = RenderState::F IXED;890 renderMethod = RenderState::FORWARD; 892 891 893 892 glEnableClientState(GL_VERTEX_ARRAY); … … 897 896 switch (renderMethod) 898 897 { 899 case RENDER_F IXED:898 case RENDER_FORWARD: 900 899 901 900 glEnable(GL_MULTISAMPLE_ARB); 902 901 903 state.SetRenderPassType(RenderState::F IXED);902 state.SetRenderPassType(RenderState::FORWARD); 904 903 glEnable(GL_LIGHTING); 905 904 … … 1053 1052 1054 1053 1055 state.SetRenderPassType(RenderState::F IXED);1054 state.SetRenderPassType(RenderState::FORWARD); 1056 1055 state.Reset(); 1057 1056 … … 1904 1903 { 1905 1904 glEnable(GL_LIGHTING); 1906 state.SetRenderPassType(RenderState::F IXED);1905 state.SetRenderPassType(RenderState::FORWARD); 1907 1906 state.Reset(); 1908 1907 }
Note: See TracChangeset
for help on using the changeset viewer.