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 › Transparecy with OPENGL
Page Index Toggle Pages: 1
Transparecy with OPENGL (Read 889 times)
Transparecy with OPENGL
Feb 15th, 2010, 12:14pm
 
Hi all!

I've been looking for posts talking about this theme but they are old (2006)

It's possible today in Processing to draw textures in OPENGL mode with transparencies?

I've tryed with mask() but this function is not supported by OPENGL mode.

Thanks!

Guillermo
Re: Transparecy with OPENGL
Reply #1 - Feb 15th, 2010, 1:56pm
 
You first need to look at this topic
http://processing.org/discourse/yabb2/num_1248087778.html

then here is a solution for you.
If you need more info about texturing, just ask Smiley

Code:
import processing.opengl.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*; //...

//...
GLU glu = new GLU();

void setup() {
 size(800, 600, OPENGL);
}

void draw() {
 PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;
 GL gl = pgl.beginGL();
 
 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); //"replace" background() call;
 
 //these
 gl.glEnable( GL.GL_BLEND ); //to make blending possible !
 gl.glDisable(GL.GL_DEPTH_TEST);// to make them blended in every positions

 //...revove this bunch of code by taking OCD lib per example
 //LIB URL : http://www.gdsstudios.com/processing/libraries/ocd/
 gl.glMatrixMode( GL.GL_PROJECTION );
 gl.glLoadIdentity();
 glu.gluPerspective( 45.0, (float)width/(float)height, 0.1, 10000.0 );
 gl.glMatrixMode( GL.GL_MODELVIEW );
 gl.glLoadIdentity();
 glu.gluLookAt( 0.0, 1.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );
 //
 
 //A TRIANGLE
 gl.glRotatef(millis()/10., 0, 1, 1);
 gl.glBegin(GL.GL_TRIANGLE_FAN);
   gl.glColor4f(1.0f, 0.0f, 0.0f, 0.7f); //glColor4f(r, g, b, alpha) instead of glColor3f(r, g, b)
   gl.glVertex3f( 0.0f, 1.0f, 0.0f);
   gl.glVertex3f(-1.0f,-1.0f, 1.0f);
   gl.glVertex3f( 1.0f,-1.0f, 1.0f);
 gl.glEnd();
   
 //ANOTHER TRIANGLE
 gl.glRotatef(millis()/10., 1, 0, 1);
 gl.glBegin(GL.GL_TRIANGLE_FAN);
   gl.glColor4f(0.0f,1.0f,0.0f, 0.7f);
   gl.glVertex3f( 0.0f, 1.0f, 0.0f);
   gl.glVertex3f(-1.0f,-1.0f, 1.0f);
   gl.glVertex3f( 1.0f,-1.0f, 1.0f);
 gl.glEnd();
 
 pgl.endGL();
}
Re: Transparecy with OPENGL
Reply #2 - Feb 16th, 2010, 2:52am
 
Thank you Bloom:

I think that this info will be useful. I want to work with images as masks of other images or videos. I will try with GL objetct and texture blending, and with JMCVdeo to have video in Opengl. I've tryed to install GSVideo in MAC OS X, but i had to install GStreamer with Macports and it's dificult. I can't do it.

Any other library to work with video in OPengl?

Thanks again.
Page Index Toggle Pages: 1