Changeset 2862


Ignore:
Timestamp:
08/22/08 17:51:54 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
8 added
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Readme.txt

    r2847 r2862  
    8181The project is separated into one section containing supportive code (utils), the traversal algorithms (traversal), and the basic engine classes like Camera, Geometry, Material, or RenderState (rendering).  
    8282 
    83 the tool uses some free 3rd party libraries, like DevIL for the image processing, and glfont2 for the HUD (http://students.cs.byu.edu/~bfish/glfont2.php, many thanks to Brad Fish for fast antialiased text). Also thanks to Alexander Kusternig for providing me his code for the SSAO shader. 
     83The tool employs some free 3rd party libraries:  
     84 
     85DevIL for texture loading / unloading 
     86glfont2 (http://students.cs.byu.edu/~bfish/glfont2.php) for the antialiased fonts of the HUD. Thanks to the author Brad Fish.  
     87The RenderTexture library. Thanks to the author Mark J. Harris. 
     88 
     89Thanks also to Alexander Kusternig for providing me his code for the SSAO shader. 
    8490 
    8591If you find any problem with the code or have any comments, please feel free to ask us at any time. 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp

    r2861 r2862  
    7777        glGenTextures(1, &mTexId); 
    7878        glBindTexture(GL_TEXTURE_2D, mTexId); 
    79         //glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, GL_RGBA, glformat, NULL); 
    8079        glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, GL_RGBA, glformat, NULL); 
     80 
    8181        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, color_attachment[attachment_idx], GL_TEXTURE_2D, mTexId, 0); 
    8282 
     
    118118 
    119119 
    120 FrameBufferObject::FrameBufferObject(int w, int h, DEPTH_FORMAT d) 
    121 : mWidth(w), mHeight(h) 
     120FrameBufferObject::FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex) 
     121: mWidth(w), mHeight(h), mDepthTexId(0) 
    122122{ 
    123123        glGenFramebuffersEXT(1, &mId); 
    124         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 
     124         
     125        Bind(); 
    125126 
    126127        cout << "creating fbo" << endl; 
     
    152153                glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormat, mWidth, mHeight); 
    153154                glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepthId); 
    154         } 
     155 
     156                if (useDepthTex) 
     157                { 
     158                        //cout << "adding depth texture" << endl; 
     159 
     160                        glGenTextures(1, &mDepthTexId); 
     161                        glBindTexture(GL_TEXTURE_2D, mDepthTexId); 
     162 
     163                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
     164                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 
     165                         
     166                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
     167                        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
     168                        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
     169 
     170                        glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, w, h, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); 
     171 
     172                        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, mDepthTexId, 0); 
     173                } 
     174        } 
     175 
     176        Release(); 
    155177} 
    156178 
     
    164186        cout << "adding color buffer" << endl; 
    165187 
    166         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 
     188        Bind(); 
    167189 
    168190        int idx = (int)mColorBuffers.size(); 
     
    172194        mColorBuffers.push_back(colorBuf); 
    173195 
     196        Release(); 
     197 
     198        return idx; 
     199} 
     200 
     201 
     202void FrameBufferObject::Bind() const 
     203{ 
     204        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 
     205} 
     206 
     207 
     208void FrameBufferObject::Release() 
     209{ 
    174210        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
    175  
    176         return idx; 
    177 } 
    178  
    179  
    180 void FrameBufferObject::Bind() const 
    181 { 
    182         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 
    183 } 
    184  
    185  
    186 void FrameBufferObject::Release() 
    187 { 
    188         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
    189211} 
    190212 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h

    r2861 r2862  
    4747        /** constructor requesting an opengl occlusion query. 
    4848        */ 
    49         FrameBufferObject(int w, int h, DEPTH_FORMAT d); 
     49        FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false); 
    5050        /** Creates and adds a color buffer to the current frame buffer object. 
    5151                Returns the index that allows to retrieve the color buffer object. 
     
    6666        */ 
    6767        static void Release(); 
     68         
    6869 
    6970protected: 
     
    7677        int mHeight; 
    7778        int mWidth; 
     79 
     80        unsigned int mDepthTexId; 
    7881}; 
    7982 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2861 r2862  
    6969                str.read(reinterpret_cast<char *>(&dist), sizeof(float)); 
    7070 
    71                 if (i>=3) dist=2e20; 
     71                //if (i>=3) dist=2e20; 
    7272                int numShapes; 
    7373                str.read(reinterpret_cast<char *>(&numShapes), sizeof(int)); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp

    r2849 r2862  
    139139 
    140140#ifdef ATI 
    141         depthTexture->Initialize(true, true, false, false, false, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 
     141        depthTexture->Initialize(true, true, false, false, false, 32, 32, 32, 32, RenderTexture::RT_COPY_TO_TEXTURE); 
    142142#else 
    143         depthTexture->Initialize(true, true, false, false, false, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 
     143        depthTexture->Initialize(true, true, false, false, false, 32, 32, 32, 32); 
    144144#endif 
    145145 
     
    185185 
    186186        GrabDepthBuffer(mDepth, depthTexture); 
    187         ExportDepthBuffer(mDepth); 
    188         PrintGLerror("grab"); 
     187        //ExportDepthBuffer(mDepth); PrintGLerror("grab"); 
    189188 
    190189        DEL_PTR(depthTexture); 
Note: See TracChangeset for help on using the changeset viewer.