|
|
@ -23,6 +23,7 @@ |
|
|
|
// TODO: more error checking in debug build.
|
|
|
|
// TODO: make texture class? for easier switching between linear/nearest interpolation for example
|
|
|
|
// NOTE: stencil attachment is not supported
|
|
|
|
// NOTE: in end() we don't set a viewport, because it will be always set (the 'main' fbo is also an J::fbo)
|
|
|
|
|
|
|
|
namespace J { |
|
|
|
|
|
|
@ -59,7 +60,7 @@ public: |
|
|
|
unbind(); |
|
|
|
} |
|
|
|
|
|
|
|
// ctor from EAGLContext, not using texture, so you cannot use it as lookup, only as renderer.
|
|
|
|
// ctor from EAGLContext, not using textures, so you cannot use it as lookup, only as renderer.
|
|
|
|
fbo(EAGLContext* context, CAEAGLLayer* layer); |
|
|
|
|
|
|
|
~fbo() { |
|
|
@ -78,22 +79,14 @@ public: |
|
|
|
|
|
|
|
void begin(){ |
|
|
|
bind(); |
|
|
|
// FIXME: this should be done, but also switching back should be done...
|
|
|
|
//glPushAttrib(GL_VIEWPORT);
|
|
|
|
glViewport(0, 0, width, height); |
|
|
|
|
|
|
|
// NOTE: commented out, because we don't want fbo's to nest.
|
|
|
|
/*GLint savedFramebuffer = -1;
|
|
|
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &savedFramebuffer); |
|
|
|
std::cout << "sfb: " << savedFramebuffer << ", fbo: " << fbo_number << std::endl;*/ |
|
|
|
} |
|
|
|
|
|
|
|
void end(){ |
|
|
|
unbind(); |
|
|
|
// FIXME: switch back to previous viewport. See begin()
|
|
|
|
//glPopAttrib();
|
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
void bind(){ |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo_number); |
|
|
|
check_error(); |
|
|
@ -102,8 +95,7 @@ public: |
|
|
|
void unbind(){ |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
|
} |
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
void create_attach_renderbuffer(GLenum format, GLenum attachment_point) { |
|
|
|
GLuint buffer; |
|
|
|
glGenRenderbuffers(1, &buffer); |
|
|
|