namespace Msp {
namespace GL {
+void operator<<(LexicalConverter &conv, FramebufferStatus status)
+{
+ switch(status)
+ {
+ case FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
+ conv.result("incomplete attachment");
+ break;
+ case FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
+ conv.result("missing attachment");
+ break;
+ case FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
+ conv.result("mismatched attachment dimensions");
+ break;
+ case FRAMEBUFFER_INCOMPLETE_FORMATS:
+ conv.result("mismatched attachment formats");
+ break;
+ case FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
+ conv.result("missing draw buffer attachment");
+ break;
+ case FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
+ conv.result("missing read buffer attachment");
+ break;
+ case FRAMEBUFFER_UNSUPPORTED:
+ conv.result("unsupported");
+ break;
+ default:
+ conv.result(lexical_cast<string, unsigned>(status, "%#x"));
+ break;
+ }
+}
+
+framebuffer_incomplete::framebuffer_incomplete(FramebufferStatus status):
+ runtime_error(lexical_cast<string>(status))
+{ }
+
+
Framebuffer::Framebuffer(unsigned i):
id(i),
dirty(0)
return static_cast<FramebufferStatus>(glCheckFramebufferStatus(GL_FRAMEBUFFER));
}
+void Framebuffer::require_complete() const
+{
+ FramebufferStatus status = check_status();
+ if(status!=FRAMEBUFFER_COMPLETE)
+ throw framebuffer_incomplete(status);
+}
+
void Framebuffer::clear(BufferBits bits)
{
Bind _bind(this, true);
FRONT_AND_BACK = GL_FRONT_AND_BACK
};
+class framebuffer_incomplete: public std::runtime_error
+{
+public:
+ framebuffer_incomplete(FramebufferStatus);
+ virtual ~framebuffer_incomplete() throw() { }
+};
+
/**
Framebuffer objects can be used to perform offscreen rendering. The most
common application is rendering to a texture, which can then be used for
or one of the error status codes otherwise. */
FramebufferStatus check_status() const;
+ /** Ensures that the framebuffer is complete, throwing an exception if it
+ isn't. */
+ void require_complete() const;
+
void clear(BufferBits);
/** Blits a region from another framebuffer into this one. If the source