OPENGL2 renderer   15 comments

During most of last year I have been working on a 3D renderer for the Android port of Processing. This renderer, called A3D, is entirely based on OpenGL ES 1.1, and introduces some new features to the Processing API such as multi-texturing and 3D models. With A3D as the starting point, it was relatively straightforward to implement a new renderer for the PC/Mac version of Processing that would eventually replace the core OPENGL renderer.

The original OPENGL renderer in Processing has some limitations, which are mostly solved with the new one (called OPENGL2 for now) thanks to the fact that it is entirely implemented with OpenGL through the JOGL2 bindings. An exciting possibility of switching to JOGL 2 is that is makes possible to access the latest OpenGL profiles (3 and 4) and the programmable pipeline. Anyways, OPENGL2 is not finished yet, but already in a functional state. The following videos were generated from a couple of demos I wrote using some of the new functionality available in the renderer:

Planet demo: shape recording, multitexturing

Rocket demo: OBJ loading, particle systems


Posted February 9, 2011 by ac in Programming

Tagged with , , ,

15 responses to “OPENGL2 renderer

Subscribe to comments with RSS.

  1. Andrés, I can’t wait for this!! I’m so excited. Of anything in the new version of Processing, this is what I want most. :-)

    • Hey! OPENGL2 source is already available in the trunk, you can checkout and compile it if want to give it a try :-) I tested it on OSX (Snow Leopard), Ubuntu 10.4, and Win7, and works. However, some parts are still unfinished and the PDE is going a mayor overhaul. But in general things are coming along nicely.

  2. Hi,

    Just a quick question. I am trying some stuff out with the A3D on Android and wanted to use GLTexture to see if I could speed some things up in combination with offscreen rendering following this example: But it seems that GLTexture is not implemented.. Is there a workaround or is this a feature to come in the future ? I was just wondering. By the way thanks for the awesome work on the A3D renderer!

    • Hello there,

      The GLTexture class will not be part of the A3D/OPENGL2 core API. It might be available in a future update of GLGraphics compatible with these new renderers.

      But when you set the A3D renderer in your Processing sketch, the PFont class automatically starts using OpenGL textures to draw the text, so you don’t need to do anything special in order to get hardware-accelerated fonts.

      • Hi,

        Thanks for replying on the post. The reason I want to use GLtexture is to use it in combination with offsreen rendering for speeding things up when using the camera preview. For a project I am currently working on I do a lot of live camera manipulation with al kind of pixel level manipulation which obviously is slow. So I am still looking for ways to speed things up. That’s why I thought the approch of th blprnt blog could help me.

      • Actually, the PShape3D in OPENGL2 is equivalent to GLModel, so you might be able to re-implement blprnt’s method without GLGraphics.

  3. Hey!

    It’s good to see that finally Processing OpenGL is improving, congrats for you!

    Any chances to include GLGraphics’ Shader and FBO support into OPENGL2? I’m having a lot of troubles mixing my old GLGraphics patches with OPENGL2/Syphon.


    • Thanks!

      A 2.0 version of GLGraphics to work in conjunction with the OPENGL2 renderer is planned, but I need a few months before I get started with it, as I’m pretty busy with other things at the moment (debugging and improving OPENGL/A3D among them :-)

      BTW, OPENGL2 does use FBOs to create offscreen rendering surfaces, i.e.: canvas = createGraphics(800, 600, OPENGL2). Is this what you need?

      • Yes, this FBO created by createGraphics will work if I can pass it to GLSLShader as a GLTexture.

      • Ok. Once pre-release 0197 is out, you could get the opengl ID of the framebuffer and textures objects and use them to in your GLSL shaders. But you have to to manually handle the shaders with direct JOGL calls inside the sketch.

        This is one possible work-around until GLGraphics for OPENGL2 is ready.

  4. Hey AC i’m trying to use some of my shader sketches that I have written in my VJ performance by using syphon to get them into VDMX but have no idea how I would go about getting the framebuffer ID like you said to get everything working.

    You wouldn’t be able to provide some example code of how this might work by any chance? Would save my ass.

    Thanks mate.

    • Hey Josh, sorry for the super late reply. I completely lost track of your comment.

      I tested the syphon library with the latest alpha release of Processing 2.0 (just came out today, grab from here), and sending frames out from any texture works out of the box:

      import codeanticode.syphon.*;
      PGraphics canvas;
      SyphonServer syphon;
      void setup() {
      size(400,400, P3D);
      canvas = createGraphics(400, 400, P3D);
      syphon = new SyphonServer(this);

      void draw() {
      canvas.translate(width/2, height/2);
      canvas.rotateX(frameCount * 0.01);
      canvas.rotateY(frameCount * 0.01);;
      image(canvas, 0, 0);

  5. Hey Ac, thanks for the reply. I actually meant to post this in the Glgraphics section as my need is to be able to use my shader toy patches using the GlGraphics library and send the result to Syphon…

    Is this possible yet?……. thanks.

    • Yes, it is possible to use syphon with Processing 1.5.1 and GLGraphics. Not through the syphon library I wrote, which only works in the newer releases, but directly importing the jsyphon Java package. This thread in the Processing forum has all the relevant info.

      In a nutshell, all you need to do is to create a JSyphonServer object, and push GLTextures with it:

      GLTexture tex;

      syphon.publishFrameTexture(tex.getTextureID(), tex.getTextureTarget(), 0, 0, tex.width, tex.height, tex.width, tex.height, false);

      If you want to send the contents of a GLGraphicsOffScreen surface, just do:

      GLTexture tex = offscreen.getTexture();
      syphon.publishFrameTexture(tex.getTextureID(), tex.getTextureTarget(), 0, 0, tex.width, tex.height, tex.width, tex.height, false);

  6. Agh awesome. Thanks for that, got it working. These shader patches are now usable for VJ gigs.

    Thanks for all your help!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: