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 › Really 'pure' OPENGL in Processing
Page Index Toggle Pages: 1
Really 'pure' OPENGL in Processing (Read 3063 times)
Really 'pure' OPENGL in Processing
May 2nd, 2008, 11:38pm
 
OPENGL without processing.opengl.*

Quote:


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

GLCanvas canvas;

void setup() {
 size(400, 300);
 
 canvas = new GLCanvas();
 canvas.setSize(200, 200);
 canvas.addGLEventListener(new GLRenderer());
 FPSAnimator animator = new FPSAnimator(canvas, 60);
 animator.start();
 
 add(canvas);
 
}

void draw() {
 background(50);
 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(1, 0, 0, 0);  
   canvas.setLocation(100, 80);    
 }

 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: Really 'pure' OPENGL in Processing
Reply #1 - May 3rd, 2008, 2:30am
 
Nice!

Re: Really 'pure' OPENGL in Processing
Reply #2 - May 4th, 2008, 8:37pm
 
cool, but what's the benefit?
Re: Really 'pure' OPENGL in Processing
Reply #3 - May 4th, 2008, 9:15pm
 
you can avoid some strange sideeffects that processing opengl produces, you can adapt other jogl examples more easily. And its running as a own threat, so you dont have to wait for eg. video capture things.
Re: Really 'pure' OPENGL in Processing
Reply #4 - May 24th, 2008, 2:19pm
 
As I've just found out though, you can run into problems with rendering text in it, the version of jogl that processing uses doesn't implement the TextRender class, which makes it a little difficult to actually get text into that window (based on my current understanding at least). I'll keep plugging away at it though.

Good work Ascorbin
Re: Really 'pure' OPENGL in Processing
Reply #5 - May 24th, 2008, 9:13pm
 
You can do text with the GLUT functions in com.sun.opengl.util.GLUT, notably glutStrokeString and glutBitmapString though you need to use gl.glRasterPos3f() etc to set the text position.
Re: Really 'pure' OPENGL in Processing
Reply #6 - May 25th, 2008, 11:48am
 
don't you need platform dependant versions of GLUT though?

I was thinking of doing it in a different way, writing text to an offscreen buffer and then texturing that onto a plane. It could give me some interesting masking effects to work with.
Re: Really 'pure' OPENGL in Processing
Reply #7 - May 25th, 2008, 11:54am
 
GLUT is part of JOGL so is platform independent.
Re: Really 'pure' OPENGL in Processing
Reply #8 - May 28th, 2008, 10:51pm
 
This would be a great addition to Processing Hacks:
http://processing.org/hacks/
Re: Really 'pure' OPENGL in Processing
Reply #9 - Sep 29th, 2008, 1:27am
 
Quote:
You can do text with the GLUT functions in com.sun.opengl.util.GLUT, notably glutStrokeString and glutBitmapString though you need to use gl.glRasterPos3f() etc to set the text position.


Hello,

i would be happy to see some code example of use of glutStrokeString. i have been trying to find example with no luck.

any one has some basic examples ?

cheers,

henri
Re: Really 'pure' OPENGL in Processing
Reply #10 - Jan 11th, 2009, 9:44pm
 
In the case the main applet is using the OPENGL renderer, this technique would effectively create two separate OpenGL contexts, am I correct?

If this is the case, and I have an OpenGL texture that I created in the context of the main window, does anyone around here know how to share this texture between the two contexts? From what I've read online, the jogl classes GLCanvas and GLDrawable have a method called createContext(GLContext shareWith) that creates a new context and shares it with the context shareWith. This would open the possibility of sharing the context of the GLRenderer with the one of main renderer.

And another question: what about the performance penalty of switching between two contexts? Any comments about this?
Page Index Toggle Pages: 1