Changeset 2862 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 08/22/08 17:51:54 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp
r2861 r2862 77 77 glGenTextures(1, &mTexId); 78 78 glBindTexture(GL_TEXTURE_2D, mTexId); 79 //glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, GL_RGBA, glformat, NULL);80 79 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, w, h, 0, GL_RGBA, glformat, NULL); 80 81 81 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, color_attachment[attachment_idx], GL_TEXTURE_2D, mTexId, 0); 82 82 … … 118 118 119 119 120 FrameBufferObject::FrameBufferObject(int w, int h, DEPTH_FORMAT d )121 : mWidth(w), mHeight(h) 120 FrameBufferObject::FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex) 121 : mWidth(w), mHeight(h), mDepthTexId(0) 122 122 { 123 123 glGenFramebuffersEXT(1, &mId); 124 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 124 125 Bind(); 125 126 126 127 cout << "creating fbo" << endl; … … 152 153 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormat, mWidth, mHeight); 153 154 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(); 155 177 } 156 178 … … 164 186 cout << "adding color buffer" << endl; 165 187 166 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId);188 Bind(); 167 189 168 190 int idx = (int)mColorBuffers.size(); … … 172 194 mColorBuffers.push_back(colorBuf); 173 195 196 Release(); 197 198 return idx; 199 } 200 201 202 void FrameBufferObject::Bind() const 203 { 204 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 205 } 206 207 208 void FrameBufferObject::Release() 209 { 174 210 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 175 176 return idx;177 }178 179 180 void FrameBufferObject::Bind() const181 {182 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId);183 }184 185 186 void FrameBufferObject::Release()187 {188 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);189 211 } 190 212 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h
r2861 r2862 47 47 /** constructor requesting an opengl occlusion query. 48 48 */ 49 FrameBufferObject(int w, int h, DEPTH_FORMAT d );49 FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false); 50 50 /** Creates and adds a color buffer to the current frame buffer object. 51 51 Returns the index that allows to retrieve the color buffer object. … … 66 66 */ 67 67 static void Release(); 68 68 69 69 70 protected: … … 76 77 int mHeight; 77 78 int mWidth; 79 80 unsigned int mDepthTexId; 78 81 }; 79 82 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2861 r2862 69 69 str.read(reinterpret_cast<char *>(&dist), sizeof(float)); 70 70 71 if (i>=3) dist=2e20;71 //if (i>=3) dist=2e20; 72 72 int numShapes; 73 73 str.read(reinterpret_cast<char *>(&numShapes), sizeof(int)); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r2849 r2862 139 139 140 140 #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); 142 142 #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); 144 144 #endif 145 145 … … 185 185 186 186 GrabDepthBuffer(mDepth, depthTexture); 187 ExportDepthBuffer(mDepth); 188 PrintGLerror("grab"); 187 //ExportDepthBuffer(mDepth); PrintGLerror("grab"); 189 188 190 189 DEL_PTR(depthTexture);
Note: See TracChangeset
for help on using the changeset viewer.