Commits

Bill Meltsner committed ff4ce31

made Framebuffer Volatile and fixed a few bugs

Comments (0)

Files changed (2)

src/modules/graphics/opengl/Framebuffer.cpp

 		}
 		virtual void deleteFBO(GLuint framebuffer, GLuint depthbuffer, GLuint img)
 		{
-			glDeleteTextures(1, &framebuffer);
+			glDeleteTextures(1, &img);
 			glDeleteRenderbuffers(1, &depthbuffer);
-			glDeleteFramebuffers(1, &img);
+			glDeleteFramebuffers(1, &framebuffer);
 		}
 
 		virtual void bindFBO(GLuint framebuffer)
 		{
 			// generate depth buffer
 			glGenRenderbuffersEXT(1, &depthbuffer);
-			glBindRenderbuffer(GL_RENDERBUFFER_EXT, depthbuffer);
+			glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer);
 			glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, width, height);
 			glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
 
 
 		virtual void deleteFBO(GLuint framebuffer, GLuint depthbuffer, GLuint img)
 		{
-			glDeleteTextures(1, &framebuffer);
+			glDeleteTextures(1, &img);
 			glDeleteRenderbuffersEXT(1, &depthbuffer);
-			glDeleteFramebuffersEXT(1, &img);
+			glDeleteFramebuffersEXT(1, &framebuffer);
 		}
 
 		virtual void bindFBO(GLuint framebuffer)
 			
 		}
 
-		status = strategy->createFBO(fbo, depthbuffer, img, width, height);
+		loadVolatile();
 	}
 
 	Framebuffer::~Framebuffer()
 		if (current == this)
 			stopGrab();
 
-		strategy->deleteFBO(fbo, depthbuffer, img);
+		unloadVolatile();
 	}
 
 	void Framebuffer::bindDefaultBuffer()
 
 		return img;
 	}
+	
+	bool Framebuffer::loadVolatile()
+	{
+		status = strategy->createFBO(fbo, depthbuffer, img, width, height);
+		return (status == GL_FRAMEBUFFER_COMPLETE);
+	}
+	
+	void Framebuffer::unloadVolatile()
+	{
+		strategy->deleteFBO(fbo, depthbuffer, img);
+	}
 
 } // opengl
 } // graphics

src/modules/graphics/opengl/Framebuffer.h

 #define LOVE_GRAPHICS_FRAMEBUFFER_H
 
 #include <graphics/Drawable.h>
+#include <graphics/Volatile.h>
 #include <image/Image.h>
 #include <image/ImageData.h>
 #include <common/math.h>
 namespace opengl
 {
 
-	class Framebuffer : public Drawable
+	class Framebuffer : public Drawable, public Volatile
 	{
 	public:
 		Framebuffer(int width, int height);
 
 		virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
 		love::image::ImageData * getImageData(love::image::Image * image);
+		
+		bool loadVolatile();
+		void unloadVolatile();
 
 	private:
 		GLsizei width;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.