Browse Source

Fixed Framebuffers scaling their contents when not sized identically to the main window

Bill Meltsner 14 years ago
parent
commit
fade6f0cbc
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/modules/graphics/opengl/Framebuffer.cpp

+ 15 - 2
src/modules/graphics/opengl/Framebuffer.cpp

@@ -186,14 +186,25 @@ namespace opengl
 
 		// cleanup after previous fbo
 		if (current != NULL)
-			glPopAttrib();
+			current->stopGrab();
 
 		// bind buffer and clear screen
-		glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+		glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_TRANSFORM_BIT);
 		strategy->bindFBO(fbo);
 		glClearColor(.0f, .0f, .0f, .0f);
 		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 		glViewport(0, 0, width, height);
+		
+		// Reset the projection matrix
+		glMatrixMode(GL_PROJECTION);
+		glPushMatrix();
+		glLoadIdentity();
+		
+		// Set up orthographic view (no depth)
+		glOrtho(0.0, width, height, 0.0, -1.0, 1.0);
+		
+		// Switch back to modelview matrix
+		glMatrixMode(GL_MODELVIEW);
 
 		// indicate we are using this fbo
 		current = this;
@@ -207,6 +218,8 @@ namespace opengl
 
 		// bind default
 		strategy->bindFBO( 0 );
+		glMatrixMode(GL_PROJECTION);
+		glPopMatrix();
 		glPopAttrib();
 		current = NULL;
 	}