We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › PApplet and a second OPENGL frame
Page Index Toggle Pages: 1
PApplet and a second OPENGL frame (Read 483 times)
PApplet and a second OPENGL frame
Mar 2nd, 2008, 9:51pm
 
I was playing around with a simple JOGL example working with GLEventListener and the Animator class. I build a standard Processing sketch which opens a second OPENGL frame with its own framerate

Quote:

import javax.media.opengl.*;
import com.sun.opengl.util.FPSAnimator;

void setup() {
 size(400, 300);
 
 Frame f = new Frame("OPENGL frame");
 GLCanvas canvas = new GLCanvas();
 canvas.addGLEventListener(new GLRenderer());
 f.add(canvas);
 f.setSize(300, 300);
 f.setLocation(0,0);
 f.setUndecorated(true);
 f.show();
 FPSAnimator animator = new FPSAnimator(canvas, 60);
 animator.start();
}

void draw() {
 background(0);
 fill(255);
 rect(10,10,frameCount%100,10);
}

class GLRenderer implements GLEventListener {
 GL gl;

 public void init(GLAutoDrawable drawable) {
   this.gl = drawable.getGL();
   gl.glClearColor(0, 0, 0, 0);
 }

 public void display(GLAutoDrawable drawable) {
   gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
   gl.glColor3f(1, 1, 1);
   gl.glRectf(-0.8, 0.8, frameCount%100/100f -0.8, 0.7);
 }
 
 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
 }

 public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
 }
}

Re: PApplet and a second OPENGL frame
Reply #1 - Mar 18th, 2008, 12:58pm
 
damn, I spent most of my Sunday trying (and failing) to figure this out... Guess I should have searched a bit harder.

I ended up doing it by creating an embedded pApplet, but I find yours so much more impressive, because you actually achieved what I was trying to do!
Page Index Toggle Pages: 1