Ignore:
Timestamp:
08/20/08 16:30:28 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2856 r2857  
    3232#include "Transform3.h" 
    3333#include "SampleGenerator.h" 
     34#include "FrameBufferObject.h" 
    3435 
    3536 
     
    201202static Matrix4x4 matProjectionView = IdentityMatrix(); 
    202203 
     204FrameBufferObject *myfbo = NULL; 
     205 
    203206 
    204207// function forward declarations 
     
    466469        CreateNoiseTex2D(); 
    467470 
    468         // init render traverser 
     471        // initialize the render traverser 
    469472        ResetTraverser(); 
    470473 
     
    476479        frameTimer.Start(); 
    477480 
    478  
     481        // the rendering loop 
    479482        glutMainLoop(); 
    480483 
     
    663666void InitFBO() 
    664667{ 
     668        // this fbo basicly stores the scene information we get from standard rendering of a frame 
     669        // we store colors, normals, positions (for the ssao) 
     670        myfbo = new FrameBufferObject(texWidth, texHeight, true, FrameBufferObject::DEPTH_24); 
     671 
     672 
     673        ColorBufferObject *diffuseBuffer =  
     674                myfbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32,  
     675                                      ColorBufferObject::WRAP_CLAMP_TO_EDGE,  
     676                                                          ColorBufferObject::FILTER_LINEAR,  
     677                                                          false, false); 
     678 
     679        ColorBufferObject *mypositionBuffer =  
     680                myfbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32,  
     681                                      ColorBufferObject::WRAP_CLAMP_TO_EDGE,  
     682                                                          ColorBufferObject::FILTER_NEAREST,  
     683                                                          false, false); 
     684 
     685 
     686        ColorBufferObject *mynormalsBuffer =  
     687                myfbo->AddColorBuffer(ColorBufferObject::BUFFER_UBYTE,  
     688                                      ColorBufferObject::WRAP_CLAMP_TO_EDGE,  
     689                                                          ColorBufferObject::FILTER_NEAREST,  
     690                                                          false, false); 
     691 
     692         
     693 
     694 
     695        //////////////////////// 
     696 
    665697        glGenFramebuffersEXT(1, &fbo); 
    666698        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); 
     
    673705        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer); 
    674706         
     707#if 1 
    675708        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
    676  
     709#else 
    677710        int samples = 8; 
    678         //glEnable(GL_MULTISAMPLE_ARB); 
    679         //glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_RGBA8, texWidth, texHeight); 
     711        glEnable(GL_MULTISAMPLE_ARB); 
     712        glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_RGBA8, texWidth, texHeight); 
     713#endif 
     714 
    680715        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorsBuffer); 
    681716         
     
    11111146 
    11121147 
     1148// the main rendering loop 
    11131149void Display()  
    11141150{        
     
    11661202                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
    11671203 
    1168                 state.SetRenderType(RenderState::DEPTH_PASS); 
    1169                 glDisable(GL_LIGHTING); 
    1170  
    11711204                cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    11721205                cgGLDisableProfile(RenderState::sCgVertexProfile); 
     1206 
     1207                state.SetRenderType(RenderState::DEPTH_PASS); 
     1208 
     1209                // the scene is rendered withouth any shading    
     1210                glDisable(GL_LIGHTING); 
    11731211         
    11741212                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    12191257        SetupEyeView(); 
    12201258 
    1221  
    1222         /*state.Reset(); 
    1223         state.SetState(RenderState::RENDER); 
    1224          
     1259        // actually render the scene geometry using one of the specified algorithms 
     1260        traverser->RenderScene(); 
     1261 
     1262 
     1263 
     1264        ///////// 
     1265        //-- do the rest of the rendering 
     1266 
    12251267        glEnableClientState(GL_VERTEX_ARRAY); 
    12261268        glEnableClientState(GL_NORMAL_ARRAY); 
    12271269 
    1228         for (int i = 0; i < loader->mSceneEntities.size(); ++ i) 
    1229         { 
    1230                 SceneEntity *ent = loader->mSceneEntities[i]; 
    1231  
    1232                 ent->UpdateLODs(camera); 
    1233                 ent->Render(&state); 
    1234         }*/ 
    1235  
    1236         // actually render the scene geometry using one of the specified algorithms 
    1237         traverser->RenderScene(); 
    1238  
    1239  
    1240  
    1241         ///////// 
    1242         //-- do the rest of the rendering 
    1243  
    1244         glEnableClientState(GL_VERTEX_ARRAY); 
    1245         glEnableClientState(GL_NORMAL_ARRAY); 
    1246  
    12471270 
    12481271        // reset depth pass and render visible objects 
     
    12641287        glDisableClientState(GL_NORMAL_ARRAY); 
    12651288 
     1289 
    12661290        if (renderType == RenderState::DEFERRED)  
    12671291        { 
    1268                 glPopAttrib(); 
     1292                //glPopAttrib(); 
    12691293                glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
    12701294 
     
    12961320        } 
    12971321 
    1298         glFlush(); 
     1322        //glFlush(); 
    12991323 
    13001324        const bool restart = true; 
     
    13031327        DisplayStats(); 
    13041328 
     1329        // flip textures for temporal smoothing 
    13051330        isFirstTexture = !isFirstTexture; 
    13061331 
Note: See TracChangeset for help on using the changeset viewer.