- Timestamp:
- 08/22/08 17:51:54 (16 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.