Skip to content

Documentation: How to use the GlFrameBuffer? #25

Description

@kihaki

Hey, I am trying to render to a texture using a framebuffer, but I can't seem to make it work, could you help me out here?

So I am setting up a SurfaceView and tried a simple rendering, which works just fine:

        val core = EglCore(flags = EglCore.FLAG_TRY_GLES3)
        val window = EglWindowSurface(core, surface)
        window.makeCurrent()

        val simpleProgram = GlFlatProgram()
        simpleProgram.setColor(Color.GREEN)
        val circle = GlCircle()
        circle.radius = 0.15F
        simpleProgram.draw(circle)

        // Publish
        window.swapBuffers()

But when I am trying to render to a FBO it crashes:

        val core = EglCore(flags = EglCore.FLAG_TRY_GLES3)
        val window = EglWindowSurface(core, surface)
        window.makeCurrent()

        val simpleProgram = GlFlatProgram()
        simpleProgram.setColor(Color.GREEN)
        val circle = GlCircle()
        circle.radius = 0.15F

        val fbTexture = GlTexture()
        val fbo = GlFramebuffer()
        fbo.attach(fbTexture, GLES20.GL_COLOR_ATTACHMENT0)
        fbo.bind()

        simpleProgram.draw(circle)

        // Publish
        window.swapBuffers()

java.lang.RuntimeException: Error during draw start: glError 0x502: invalid operation

Could you help me out with a working sample or a pinpoint in what's wrong? I couldn't glean much more from the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions