Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Processing 2 and OpenGL Frame Buffer Objects (FBO)

$
0
0
Hi Jonsku,

I'm trying to get your code to work and understand some reasoning behind it.  I'm using the current git processing code.

Why do you call 
  1. PGL pgl = ((PGraphicsOpenGL) g).beginPGL();
  2. gl = pgl.gl.getGL().getGL2();
every draw?  And why are you setting the viewport every draw?
Also I really don't understand this idea of pushing and popping framebuffers.  This may be more of a processing specific implementation thing, but do you have any insight?

I am trying to use your code to follow a workflow as follows.  I renamed your class to FBOGraphics for my test:
  1. public void setup() {

        [setup gl context, create fbo]


        ((FBOGraphics) g).pushFramebuffer();

        gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, myFBO); // Bind our frame buffer

        fill(255, 255, 255);

        rect(100, 100, 200, 500);

        ((FBOGraphics) g).popFramebuffer();

    }


    public void draw() {

        background(0);

        // why the repeat?  If I don't use we crash

        PGL pgl = ((PGraphicsOpenGL) g).beginPGL();

        gl = pgl.gl.getGL().getGL2();


        gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0);

        ((PGraphicsOpenGL) g).drawTexture(GL.GL_TEXTURE_2D, fboTexture, width, height, 0, 0, width, height);

    }


And it does nothing (which is the same I was seeing with your full code).  Any ideas?

Thanks


Viewing all articles
Browse latest Browse all 1768

Trending Articles