Changeset 2959 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
- Timestamp:
- 09/19/08 23:13:47 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2958 r2959 273 273 static CGparameter sMaxDepthParamTex; 274 274 static Matrix4x4 oldViewProjMatrix; 275 static CGprogram sCgMrtFragmentSkyDomeProgram = NULL;276 275 277 276 … … 547 546 cerr << "fragment tex program failed to load" << endl; 548 547 549 sCgMrtFragmentSkyDomeProgram =548 RenderState::sCgMrtFragmentProgram = 550 549 cgCreateProgramFromFile(sCgContext, 551 550 CG_SOURCE, 552 "src/shaders/ sky_preetham.cg",551 "src/shaders/mrt.cg", 553 552 RenderState::sCgFragmentProfile, 554 "frag _skydome",553 "frag", 555 554 NULL); 556 555 557 if ( sCgMrtFragmentSkyDomeProgram != NULL)558 { 559 cgGLLoadProgram( sCgMrtFragmentSkyDomeProgram);560 561 /*sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth");556 if (RenderState::sCgMrtFragmentProgram != NULL) 557 { 558 cgGLLoadProgram(RenderState::sCgMrtFragmentProgram); 559 560 sMaxDepthParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "maxDepth"); 562 561 Material::sDiffuseParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "diffuse"); 563 562 Material::sAmbientParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "ambient"); 564 563 565 564 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 566 */567 565 } 568 566 else 569 cerr << "fragment skyprogram failed to load" << endl; 567 cerr << "fragment program failed to load" << endl; 568 570 569 571 570 PrintGLerror("init"); … … 618 617 void InitGLstate() 619 618 { 620 glClearColor(0. 3f, 0.3f, 0.4f, 1.0f);619 glClearColor(0.4f, 0.4f, 0.4f, 1.0f); 621 620 622 621 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); … … 643 642 glDisable(GL_TEXTURE_2D); 644 643 645 GLfloat ambientColor[] = {0. 5, 0.5, 0.5, 1.0};644 GLfloat ambientColor[] = {0.2, 0.2, 0.2, 1.0}; 646 645 GLfloat diffuseColor[] = {1.0, 0.0, 0.0, 1.0}; 647 646 GLfloat specularColor[] = {0.0, 0.0, 0.0, 1.0}; … … 671 670 if (!skyDome) cerr << "loadig plane failed" << endl; 672 671 673 preetham = new SkyPreetham(3.0f, skyDome); 672 const float turbitiy = 3.0f; 673 preetham = new SkyPreetham(turbitiy, skyDome); 674 674 675 675 676 676 ////////////////////////////// 677 677 678 //GLfloat lmodel_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f};679 GLfloat lmodel_ambient[] = { 1.0f, 1.0f, 1.0f, 1.0f};678 //GLfloat lmodel_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f}; 679 GLfloat lmodel_ambient[] = {0.7f, 0.7f, 0.8f, 1.0f}; 680 680 681 681 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); 682 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); 682 //glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); 683 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); 683 684 glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SINGLE_COLOR_EXT); 684 685 } … … 795 796 void SetupLighting() 796 797 { 797 //glEnable(GL_LIGHTING);798 798 glEnable(GL_LIGHT0); 799 glDisable(GL_LIGHT1); 799 800 800 801 Vector3 lightDir = -light->GetDirection(); … … 807 808 GLfloat diffuse[] = {1.0f, 0.95f, 0.85f, 1.0f}; 808 809 GLfloat specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; 810 //GLfloat specular[] = {0.0f, 0.0f, 0.0f, 1.0f}; 809 811 810 812 Vector3 sunAmbient; … … 832 834 diffuse[1] = sunDiffuse.y; 833 835 diffuse[2] = sunDiffuse.z; 834 836 835 837 //cout<< "sunambient: " << sunAmbient << endl; 836 838 //cout<< "sundiffuse: " << sunDiffuse << endl; … … 1101 1103 RenderSky(); 1102 1104 1103 1104 1105 1105 1106 if ((renderMethod == RENDER_DEFERRED) || … … 1960 1961 void RenderSky() 1961 1962 { 1962 glEnable(GL_LIGHTING);1963 //glEnable(GL_LIGHTING); 1963 1964 cgGLEnableProfile(RenderState::sCgVertexProfile); 1964 1965 1965 if (state.GetRenderPassType() == RenderState::DEFERRED) 1966 { 1967 cgGLEnableProfile(RenderState::sCgFragmentProfile); 1968 cgGLBindProgram(sCgMrtFragmentSkyDomeProgram); 1969 } 1966 if ((renderMethod == RENDER_DEFERRED) || (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 1967 state.SetRenderPassType(RenderState::DEFERRED); 1970 1968 1971 1969 SceneEntityContainer::const_iterator sit, sit_end = skyGeometry.end(); … … 1976 1974 //cube->Render(&state); 1977 1975 //aeroplane->Render(&state); 1978 glDisable(GL_CULL_FACE); 1976 //glEnable(GL_LIGHTING); 1977 1979 1978 preetham->Compute(-light->GetDirection(), camera, &state); 1980 glEnable(GL_CULL_FACE); 1981 1979 1982 1980 cgGLDisableProfile(RenderState::sCgVertexProfile); 1983 1981 cgGLDisableProfile(RenderState::sCgFragmentProfile); … … 2034 2032 2035 2033 glDepthFunc(GL_LESS); 2034 state.Reset(); 2036 2035 2037 2036 PrintGLerror("visibleobjects");
Note: See TracChangeset
for help on using the changeset viewer.