Changeset 2877 for GTP/trunk/App
- Timestamp:
- 08/28/08 00:07:12 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2873 r2877 292 292 </File> 293 293 <File 294 RelativePath=".\src\RenderTexture.cpp"295 >296 </File>297 <File298 RelativePath=".\src\RenderTexture.h"299 >300 </File>301 <File302 294 RelativePath=".\src\SampleGenerator.cpp" 303 295 > -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h
r2867 r2877 65 65 static void Release(); 66 66 67 unsigned int GetDepthTex() const { return mDepthTexId; } 67 68 68 69 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r2862 r2877 7 7 #include <IL/il.h> 8 8 #include <assert.h> 9 #include "RenderTexture.h" 9 #include "FrameBufferObject.h" 10 10 11 11 12 … … 16 17 17 18 19 static GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT}; 20 18 21 19 22 static void PrintGLerror(char *msg) … … 48 51 49 52 50 void GrabDepthBuffer(float *data, RenderTexture *rt) 51 { 52 rt->BindDepth(); 53 rt->EnableTextureTarget(); 54 55 const int texFormat = GL_DEPTH_COMPONENT; 56 glGetTexImage(rt->GetTextureTarget(), 0, texFormat, GL_FLOAT, data); 57 58 rt->DisableTextureTarget(); 53 //void GrabDepthBuffer(float *data, RenderTexture *rt) 54 void GrabDepthBuffer(float *data, GLuint depthTexture) 55 { 56 glEnable(GL_TEXTURE_2D); 57 glBindTexture(GL_TEXTURE_2D, depthTexture); 58 59 glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_FLOAT, data); 60 61 glBindTexture(GL_TEXTURE_2D, 0); 62 glDisable(GL_TEXTURE_2D); 59 63 } 60 64 … … 136 140 orthoCam->SetPosition(pos); 137 141 138 RenderTexture *depthTexture = new RenderTexture(texWidth, texHeight, true, true); 139 140 #ifdef ATI 141 depthTexture->Initialize(true, true, false, false, false, 32, 32, 32, 32, RenderTexture::RT_COPY_TO_TEXTURE); 142 #else 143 depthTexture->Initialize(true, true, false, false, false, 32, 32, 32, 32); 144 #endif 145 146 PrintGLerror("Init"); 147 148 depthTexture->BeginCapture(); 149 { 150 glViewport(0, 0, texWidth, texHeight); 151 glPushAttrib(GL_VIEWPORT_BIT); 152 153 glClearColor(1, 1, 1, 1); 154 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 155 156 glFrontFace(GL_CCW); 157 glCullFace(GL_BACK); 158 159 glEnable(GL_CULL_FACE); 160 161 glShadeModel(GL_FLAT); 162 glEnable(GL_DEPTH_TEST); 163 164 glMatrixMode(GL_PROJECTION); 165 glPushMatrix(); 166 167 glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 168 169 glMatrixMode(GL_MODELVIEW); 170 glPushMatrix(); 171 172 orthoCam->SetupCameraView(); 173 174 mDepth = new float[texHeight * texWidth]; 175 176 //renderer->SetCamera(orthoCam); 177 renderer->RenderScene(); 178 179 glPopMatrix(); 180 glPopMatrix(); 181 182 glPopAttrib(); 183 } 184 depthTexture->EndCapture(); 185 186 GrabDepthBuffer(mDepth, depthTexture); 187 //ExportDepthBuffer(mDepth); PrintGLerror("grab"); 188 189 DEL_PTR(depthTexture); 142 FrameBufferObject *fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32, true); 143 fbo->AddColorBuffer(ColorBufferObject::BUFFER_UBYTE, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, false); 144 145 PrintGLerror("here667"); 146 147 fbo->Bind(); 148 149 glDrawBuffers(1, mrt); 150 151 glViewport(0, 0, texWidth, texHeight); 152 glPushAttrib(GL_VIEWPORT_BIT); 153 154 glClearColor(1, 1, 1, 1); 155 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 156 157 glFrontFace(GL_CCW); 158 glCullFace(GL_BACK); 159 160 glEnable(GL_CULL_FACE); 161 162 glShadeModel(GL_FLAT); 163 glEnable(GL_DEPTH_TEST); 164 165 glMatrixMode(GL_PROJECTION); 166 glPushMatrix(); 167 168 169 glOrtho(+xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z); 170 171 glMatrixMode(GL_MODELVIEW); 172 glPushMatrix(); 173 174 orthoCam->SetupCameraView(); 175 176 mDepth = new float[texHeight * texWidth]; 177 178 renderer->RenderScene(); 179 180 glPopMatrix(); 181 glMatrixMode(GL_PROJECTION); 182 183 glPopMatrix(); 184 185 glPopAttrib(); 186 187 FrameBufferObject::Release(); 188 189 GrabDepthBuffer(mDepth, fbo->GetDepthTex()); 190 191 ExportDepthBuffer(mDepth); 192 PrintGLerror("grab"); 193 194 DEL_PTR(fbo); 190 195 DEL_PTR(orthoCam); 191 196 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2875 r2877 225 225 DeferredShader *deferredShader = NULL; 226 226 227 GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT};227 static GLenum mrt[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT}; 228 228 229 229
Note: See TracChangeset
for help on using the changeset viewer.