Changeset 3031
- Timestamp:
- 10/15/08 01:51:10 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r3028 r3031 57 57 void Material::Render(RenderState *state) 58 58 { 59 state->SetState(mTexture != NULL, mAlphaTestEnabled, mCullFaceEnabled); 60 61 state->SetTexture(mTexture); 59 state->SetState(mTexture, mAlphaTestEnabled, mCullFaceEnabled); 62 60 63 61 glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3028 r3031 15 15 ShaderProgram *RenderState::sCgMrtFragmentProgram = NULL; 16 16 ShaderProgram *RenderState::sCgMrtFragmentTexProgram = NULL; 17 ShaderProgram *RenderState::sCgMrtVertexProgram = NULL; 18 19 17 20 int RenderState::sTexParam; 18 21 … … 34 37 35 38 36 bool RenderState::Set State(Mode mode)39 bool RenderState::SetMode(Mode mode) 37 40 { 38 41 /////////// … … 85 88 86 89 87 void RenderState::SetState(bool texturing, bool alphaTest, bool cullFace) 88 { 90 void RenderState::SetState(Texture *tex, bool alphaTest, bool cullFace) 91 { 92 const bool texturing = (tex != NULL); 93 89 94 if (!mLockCullFaceEnabled) 90 95 { … … 146 151 } 147 152 } 153 154 SetTexture(tex); 148 155 } 149 156 … … 166 173 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 167 174 168 Set State(RENDER);175 SetMode(RENDER); 169 176 } 170 177 … … 196 203 void RenderState::SetTexture(Texture *tex) 197 204 { 198 if ( tex)199 { 200 if ( GetRenderPassType() == RenderState::DEFERRED)201 {202 RenderState::sCgMrtFragmentProgram->SetTexture("tex", tex->GetId());203 }204 else205 {205 if (GetRenderPassType() == RenderState::DEFERRED) 206 { 207 if (tex) 208 RenderState::sCgMrtFragmentTexProgram->SetTexture("tex", tex->GetId()); 209 } 210 else 211 { 212 if (tex) 206 213 tex->Bind(); 207 } 208 } 209 else 210 { 211 if (!GetRenderPassType() == RenderState::DEFERRED) 214 else 212 215 glBindTexture(GL_TEXTURE_2D, 0); 213 216 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r3028 r3031 44 44 change was issued. 45 45 */ 46 bool Set State(Mode mode);46 bool SetMode(Mode mode); 47 47 /** Sets the current render state. 48 48 */ 49 void SetState( bool texturing, bool alphaTest, bool cullFace);49 void SetState(Texture *tex, bool alphaTest, bool cullFace); 50 50 /** Returns either query or render mode 51 51 */ … … 86 86 static ShaderProgram *sCgMrtFragmentProgram; 87 87 static ShaderProgram *sCgMrtFragmentTexProgram; 88 static ShaderProgram *sCgMrtVertexProgram; 88 89 89 90 static int sTexParam; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp
r2954 r3031 97 97 if (node->GetLastRenderedFrame() != mFrameId) 98 98 { 99 if (mRenderState->Set State(RenderState::RENDER))99 if (mRenderState->SetMode(RenderState::RENDER)) 100 100 ++ mStats.mNumStateChanges; 101 101 … … 254 254 255 255 // change to query mode and render box 256 if (mRenderState->Set State(RenderState::QUERY))256 if (mRenderState->SetMode(RenderState::QUERY)) 257 257 ++ mStats.mNumStateChanges; 258 258 … … 265 265 void RenderTraverser::ApplyRenderQueue() 266 266 { 267 if (mRenderState->Set State(RenderState::RENDER))267 if (mRenderState->SetMode(RenderState::RENDER)) 268 268 ++ mStats.mNumStateChanges; 269 269 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp
r3030 r3031 92 92 93 93 cgGLSetTextureParameter(p, tex); 94 cgGLEnableTextureParameter(p); 95 94 96 mTextureParams.push_back(p); 95 97 } … … 101 103 102 104 // enable all texture parameters 103 /*CGParameterArray::const_iterator it, it_end = mTextureParams.end(); 105 CGParameterArray::const_iterator it, it_end = mTextureParams.end(); 106 104 107 for (it = mTextureParams.begin(); it != it_end; ++ it) 105 108 cgGLEnableTextureParameter(*it); 106 */107 109 } 108 110 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
r2960 r3031 1 1 #include "Transform3.h" 2 2 #include "RenderState.h" 3 #include "ShaderProgram.h" 3 4 4 5 … … 33 34 if (state->GetRenderPassType() == RenderState::DEFERRED) 34 35 { 35 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix.x); 36 //cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix.x); 37 RenderState::sCgMrtVertexProgram->SetMatrix("modelView", mMatrix); 36 38 } 37 39 … … 49 51 { 50 52 static Matrix4x4 identity = IdentityMatrix(); 51 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)identity.x);53 RenderState::sCgMrtVertexProgram->SetMatrix("modelView", identity); 52 54 } 53 55 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3028 r3031 282 282 static CGcontext sCgContext = NULL; 283 283 284 ShaderProgram *sCgMrtVertexProgram = NULL;285 286 284 static CGparameter sEyePosParamTex; 287 285 static CGparameter sEyePosParam; … … 490 488 InitCg(); 491 489 492 DeferredRenderer::InitCG(sCgContext);493 SkyPreetham::InitCG(sCgContext);494 495 490 Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 496 491 … … 557 552 cgGLSetManageTextureParameters(sCgContext, true); 558 553 559 sCgMrtVertexProgram =560 new ShaderProgram(sCgContext, "src/shaders/mrt.cg", RenderState::sCg FragmentProfile, "vtx");561 562 if (! sCgMrtVertexProgram->IsValid())554 RenderState::sCgMrtVertexProgram = 555 new ShaderProgram(sCgContext, "src/shaders/mrt.cg", RenderState::sCgVertexProfile, "vtx"); 556 557 if (!RenderState::sCgMrtVertexProgram->IsValid()) 563 558 cerr << "fragment program failed to load" << endl; 564 559 … … 567 562 568 563 if (!RenderState::sCgMrtFragmentTexProgram->IsValid()) 569 cerr << "fragment program failed to load" << endl;564 cerr << "fragment tex program failed to load" << endl; 570 565 571 566 RenderState::sCgMrtFragmentProgram = … … 577 572 578 573 PrintGLerror("init"); 574 575 DeferredRenderer::InitCG(sCgContext); 576 SkyPreetham::InitCG(sCgContext); 579 577 580 578 cout << "cg initialization successful" << endl; … … 856 854 if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 857 855 { 858 cgGLSetMatrixParameterfc(Transform3::sModelMatrixParam, (const float *)IdentityMatrix().x);856 RenderState::sCgMrtVertexProgram->SetMatrix("modelView", IdentityMatrix()); 859 857 } 860 858 } … … 908 906 909 907 cgGLEnableProfile(RenderState::sCgVertexProfile); 910 sCgMrtVertexProgram->Bind();908 RenderState::sCgMrtVertexProgram->Bind(); 911 909 912 910 cgGLEnableProfile(RenderState::sCgFragmentProfile); … … 915 913 const Vector3 pos = camera->GetPosition(); 916 914 917 cgGLSetParameter3f(sEyePosParam, pos.x, pos.y, pos.z);918 cgGLSetParameter3f(sEyePosParamTex, pos.x, pos.y, pos.z);915 RenderState::sCgMrtFragmentProgram->SetValue3f("eyePos", pos.x, pos.y, pos.z); 916 RenderState::sCgMrtFragmentTexProgram->SetValue3f("eyePos", pos.x, pos.y, pos.z); 919 917 920 918 … … 1751 1749 DEL_PTR(RenderState::sCgMrtFragmentProgram); 1752 1750 DEL_PTR(RenderState::sCgMrtFragmentTexProgram); 1753 DEL_PTR( sCgMrtVertexProgram);1751 DEL_PTR(RenderState::sCgMrtVertexProgram); 1754 1752 1755 1753 DeferredRenderer::ReleaseCG(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3018 r3031 43 43 44 44 vtxout vtx(vtxin IN, 45 const uniform float4x4 ModelViewProj, 46 uniform float4x4 ModelView) 45 uniform float4x4 modelView) 47 46 { 48 47 vtxout OUT; … … 52 51 53 52 //OUT.worldPos = mul(glstate.matrix.inverse.projection, OUT.position); 54 OUT.worldPos = mul( ModelView, IN.position);53 OUT.worldPos = mul(modelView, IN.position); 55 54 // transform the vertex position into eye space 56 55 OUT.position = mul(glstate.matrix.mvp, IN.position); … … 75 74 76 75 pixel fragtex(fragin IN, 77 uniform sampler2D dirtTex,78 76 uniform sampler2D tex, 79 77 uniform float3 eyePos,
Note: See TracChangeset
for help on using the changeset viewer.