Changeset 3048
- Timestamp:
- 10/20/08 02:29:28 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r3047 r3048 33 33 mColorWriteEnabled = true; 34 34 /// if lighting is used 35 boolmLightingEnabled = true;35 mLightingEnabled = true; 36 36 } 37 37 … … 92 92 93 93 94 Technique Technique::GetQueryTechnique() 95 { 96 Technique tech; 97 98 tech.Init(); 99 100 tech.SetColorWriteEnabled(false); 101 tech.SetLightingEnabled(false); 102 103 return tech; 104 } 105 106 94 107 /***********************************************/ 95 108 /* class Material implementation */ … … 99 112 void Material::Render(RenderState *state) 100 113 { 101 if (state->GetRenderPassType() == RenderState::DEFERRED) 102 mTechniques[1]->Render(state); 103 else 104 mTechniques[0]->Render(state); 114 mTechniques[state->GetRenderTechnique()]->Render(state); 105 115 } 106 116 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
r3047 r3048 105 105 GPUProgramParameters * const GetVertexProgramParameters() { return &mVertexProgramParameters; } 106 106 107 static Technique GetQueryTechnique(); 107 108 108 109 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3047 r3048 17 17 18 18 RenderState::RenderState(): 19 mRenderT ype(FORWARD),19 mRenderTechnique(FORWARD), 20 20 mUseAlphaToCoverage(true), 21 21 mLockCullFaceEnabled(false) … … 85 85 if (mode == QUERY) 86 86 { 87 if (mRenderType != DEPTH_PASS) 88 { 87 if (mLightingEnabled) 89 88 glDisable(GL_LIGHTING); 89 90 if (mColorWriteEnabled) 90 91 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 91 }92 92 93 93 if (mFragmentProgramEnabled) 94 {95 94 ResourceManager::GetSingleton()->DisableFragmentProfile(); 96 }97 95 98 96 if (mVertexProgramEnabled) 99 {100 97 ResourceManager::GetSingleton()->DisableVertexProfile(); 101 }102 98 103 99 glDepthMask(GL_FALSE); 104 100 105 static Technique defaultTech; 106 SetState(&defaultTech); 101 /// the query box material 102 static Technique queryTech = Technique::GetQueryTechnique(); 103 SetState(&queryTech); 107 104 } 108 105 else // mode returns to render … … 111 108 //-- restore render state 112 109 113 if (mRenderType != DEPTH_PASS) 114 { 110 if (mLightingEnabled) 115 111 glEnable(GL_LIGHTING); 112 113 if (mColorWriteEnabled) 116 114 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 117 }118 115 119 116 if (mFragmentProgramEnabled) 120 {121 117 ResourceManager::GetSingleton()->EnableFragmentProfile(); 122 }123 118 124 119 if (mVertexProgramEnabled) 125 {126 120 ResourceManager::GetSingleton()->EnableVertexProfile(); 127 }128 121 129 122 glDepthMask(GL_TRUE); … … 175 168 } 176 169 177 if (mTexturesEnabled && 178 (!texturing || (mRenderType == DEPTH_PASS) && !mAlphaTestEnabled)) 170 if (mTexturesEnabled && !texturing) 179 171 { 180 172 mTexturesEnabled = false; … … 187 179 else if (!mTexturesEnabled && texturing) 188 180 { 189 // support only alpha textures in depth pass 190 if ((mRenderType != DEPTH_PASS) || mAlphaTestEnabled) 181 if (mAlphaTestEnabled) 191 182 { 192 183 mTexturesEnabled = true; … … 282 273 283 274 284 void RenderState::SetRender PassType(RenderPassType t)275 void RenderState::SetRenderTechnique(RenderTechnique t) 285 276 { 286 mRenderT ype = t;287 } 288 289 290 RenderState::Render PassType RenderState::GetRenderPassType() const291 { 292 return mRenderT ype;277 mRenderTechnique = t; 278 } 279 280 281 RenderState::RenderTechnique RenderState::GetRenderTechnique() const 282 { 283 return mRenderTechnique; 293 284 } 294 285 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r3047 r3048 25 25 }; 26 26 27 /// the used render t ype for this render pass28 enum Render PassType27 /// the used render technique 28 enum RenderTechnique 29 29 { 30 30 FORWARD, 31 DE PTH_PASS,32 DE FERRED31 DEFERRED, 32 DEPTH_PASS 33 33 }; 34 34 … … 58 58 */ 59 59 inline int GetCurrentVboId() const { return mCurrentVboId; } 60 /** Sets the type of rendering used(foreward, depth pass, deferred)60 /** Sets the render technique (foreward, depth pass, deferred) 61 61 */ 62 void SetRender PassType(RenderPassType t);62 void SetRenderTechnique(RenderTechnique t); 63 63 /** See Set 64 64 */ 65 Render PassType GetRenderPassType() const;65 RenderTechnique GetRenderTechnique() const; 66 66 /** If alpha to coverage is instead of alpha testing 67 67 */ … … 84 84 85 85 int mCurrentVboId; 86 87 Render PassType mRenderType;86 /// the current render technique 87 RenderTechnique mRenderTechnique; 88 88 89 89 bool mUseAlphaToCoverage; … … 99 99 bool mVertexProgramEnabled; 100 100 101 bool m UseLighting;101 bool mLightingEnabled; 102 102 bool mColorWriteEnabled; 103 103 }; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3047 r3048 118 118 119 119 /////////////// 120 //-- load lodlevels120 //-- load LOD levels 121 121 122 122 // note: lods must be ordered from smallest distance to largest … … 126 126 for (int i = 0; i < numLODs; ++ i) 127 127 { 128 // the distance until the next LOD level is used 128 129 float dist; 129 130 str.read(reinterpret_cast<char *>(&dist), sizeof(float)); … … 158 159 //-- hack: add tree animation (should be done per material script!) 159 160 160 if ( numLODs > 1)161 if (0)//numLODs > 1) 161 162 { 162 163 ShapeContainer::iterator sstart, send; … … 320 321 deferred->SetVertexProgram(mMrtDefaultVertexProgram); 321 322 323 324 /////////// 325 //-- add depth pass 326 327 Technique *depthPass = new Technique(*tech); 328 depthPass->SetColorWriteEnabled(false); 329 depthPass->SetLightingEnabled(false); 330 322 331 mat->AddTechnique(deferred); 332 mat->AddTechnique(depthPass); 323 333 324 334 return mat; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r3045 r3048 121 121 Technique *tech; 122 122 123 if (state->GetRenderPassType() == RenderState::DEFERRED) 124 tech = mat->GetTechnique(1); 125 else 126 tech = mat->GetTechnique(0); 123 tech = mat->GetTechnique(state->GetRenderTechnique()); 127 124 128 125 GPUProgramParameters *vtxParams = tech->GetVertexProgramParameters(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3046 r3048 485 485 visualization = new Visualization(bvh, camera, NULL, &state); 486 486 487 state.SetRender PassType(RenderState::FORWARD);487 state.SetRenderTechnique(RenderState::FORWARD); 488 488 489 489 // frame time is restarted every frame … … 819 819 glDisable(GL_MULTISAMPLE_ARB); 820 820 821 state.SetRender PassType(RenderState::DEFERRED);821 state.SetRenderTechnique(RenderState::DEFERRED); 822 822 823 823 loader->EnableVertexProfile(); … … 905 905 glEnable(GL_MULTISAMPLE_ARB); 906 906 907 state.SetRender PassType(RenderState::FORWARD);907 state.SetRenderTechnique(RenderState::FORWARD); 908 908 glEnable(GL_LIGHTING); 909 909 … … 919 919 state.SetUseAlphaToCoverage(false); 920 920 921 state.SetRender PassType(RenderState::DEPTH_PASS);921 state.SetRenderTechnique(RenderState::DEPTH_PASS); 922 922 923 923 if (!fbo) InitFBO(); fbo->Bind(); … … 939 939 glEnable(GL_MULTISAMPLE_ARB); 940 940 941 state.SetRender PassType(RenderState::DEPTH_PASS);941 state.SetRenderTechnique(RenderState::DEPTH_PASS); 942 942 943 943 // the scene is rendered withouth any shading … … 951 951 break; 952 952 953 case R enderState::DEFERRED:953 case RENDER_DEFERRED: 954 954 955 955 if (showShadowMap && !renderLightView) … … 1012 1012 // this would conveniently solves some issues (e.g, skys without shadows) 1013 1013 1014 RenderSky();1014 //RenderSky(); 1015 1015 1016 1016 … … 1048 1048 1049 1049 1050 state.SetRender PassType(RenderState::FORWARD);1050 state.SetRenderTechnique(RenderState::FORWARD); 1051 1051 state.Reset(); 1052 1052 … … 1863 1863 { 1864 1864 if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 1865 state.SetRender PassType(RenderState::DEFERRED);1865 state.SetRenderTechnique(RenderState::DEFERRED); 1866 1866 1867 1867 const bool useToneMapping = … … 1870 1870 1871 1871 preetham->RenderSkyDome(-light->GetDirection(), camera, &state, !useToneMapping); 1872 1872 /// once again reset the state 1873 1873 state.Reset(); 1874 1874 } … … 1890 1890 glDisable(GL_LIGHTING); 1891 1891 glViewport(0, 0, texWidth, texHeight); 1892 1892 // rese the state before the final visible objects pass 1893 1893 state.Reset(); 1894 1894 InitDeferredRendering(); … … 1897 1897 { 1898 1898 glEnable(GL_LIGHTING); 1899 state.SetRenderPassType(RenderState::FORWARD); 1899 state.SetRenderTechnique(RenderState::FORWARD); 1900 // rese the state before the final visible objects pass 1900 1901 state.Reset(); 1901 1902 } … … 1955 1956 glDisableClientState(GL_NORMAL_ARRAY); 1956 1957 1957 state.SetRender PassType(RenderState::DEPTH_PASS);1958 state.SetRenderTechnique(RenderState::DEPTH_PASS); 1958 1959 1959 1960 // hack: disable cull face because of alpha textured balconies
Note: See TracChangeset
for help on using the changeset viewer.