Offscreen Rendering


Hey there,

I started to build a very tiny tool that is based on OpenGL 2. This is really easy to do on Windows and Mac with the very nice new OpenGLRenderer.
Well, I used glAccum to create an easy blooming effect.

Now the hard part. On iOS I found that JUCE instanciates the GLES-Context in GLES2 mode.
That means several features including glAccum are deactivated in favour of shaders and so on :slight_smile:
I found how to get the Shader stuff running in the same way as OpenGL2 before. Everything works but the glAccum.
That’s why I though I can create an OpenGLFrameBuffer, rendering to it and drawing it with an alpha value before
I draw new stuff. My first try was to reder to the FBO and draw it. Unfortunately, it crashes when I try to activate the
FBO for drawing.

in newOpenGLContextCreated():

    offScreen =  new OpenGLFrameBuffer();
    offScreen->initialise(openGLContext, getContextWidth(), getContextWidth());

in renderOpenGL():

    offScreen->makeCurrentRenderingTarget(); //<<-- here it crahses
    .... rendering some stuff ...

Does anybody know a good solution for this? Maybe I missuse the Framebuffer Classes. Since there is only few documentation about this it’s pretty much reading the code and comparing it to raw GLES2 stuff.



IIRC, there’s some off screen rendering code in the Juce demo (render to texture). might that help?


Hey Hugh,

thanks for the answer.

Well, offscreen rendering to a texture would be great if it renders from OpenGL to a OpenGL-Texture. What Juce currently does is 2D rednering, drawing it to one single texture and then blitting the texture to the screen. This is great from coding perspective but it’s quite a loss of performance. What I have in mind for JUCE is to upload textures, colors an some verticies to the graphics card. After that juce should only alter positions or small portions of the stuff residing inside the Graphics context.

In my current small project I tried to use some OpenGL ES2 specific stuff. Of course this cannot be generalized since OGLES2 is platform dependend. Nevertheless, juce uses one offscreen internally. I though I can build another one with the same concept. This wasn’t quite possible because of lacking features in OGLES2 mode. Nevertheless, I ended up building it on my own but I had to understand the JUCE code to reset it after the drawing process.

kind regards