@@ -17,11 +17,10 @@ import processing.opengl.*;
1717import java.awt.GraphicsDevice ;
1818import java.awt.DisplayMode ;
1919import java.awt.Frame ;
20- import javax.media.opengl.GL2 ;
20+ import javax.media.opengl.GL ;
2121
2222public class Stage extends PApplet {
23-
24-
23+
2524 MusicBeam ctrl = null ;
2625
2726 int width ;
@@ -36,12 +35,10 @@ public class Stage extends PApplet {
3635
3736 float minRadius;
3837
39- PGraphicsOpenGL pgl;
40-
41- GL2 gl;
42-
4338 DisplayMode dm;
4439
40+ PGraphicsOpenGL pgl;
41+
4542
4643 Stage (MusicBeam main, int gd)
4744 {
@@ -69,10 +66,7 @@ public class Stage extends PApplet {
6966
7067 void setup () {
7168 frameRate (getRefreshRate());
72-
7369 pgl = (PGraphicsOpenGL ) g;
74- gl = pgl. beginPGL(). gl. getGL2();
75-
7670 noStroke ();
7771 colorMode (HSB , 360 , 100 , 100 );
7872 }
@@ -86,19 +80,27 @@ public class Stage extends PApplet {
8680 textSize (30 );
8781 text (frameRate , 100 , 100 );
8882 }
89-
90- pgl. beginPGL();
91- gl. glDisable(GL2. GL_DEPTH_TEST );
92- gl. glEnable(GL2. GL_BLEND );
93- gl. glBlendFunc(GL2. GL_SRC_ALPHA , GL2. GL_ONE );
94- pgl. endPGL();
83+
84+ enableGLBlending();
9585
9686 translate (width / 2 , height / 2 );
9787 for (int i = 0 ; i < effectArray. length; i++ )
9888 if (effectArray[i]. isActive())
9989 effectArray[i]. refresh();
10090 }
10191
92+ /**
93+ * Enables GLBlending and sets a function to blend overlaying colors.
94+ *
95+ */
96+ private void enableGLBlending () {
97+ GL gl = pgl. beginGL();
98+ gl. glDisable(GL. GL_DEPTH_TEST );
99+ gl. glEnable(GL. GL_BLEND );
100+ gl. glBlendFunc(GL. GL_SRC_ALPHA , GL. GL_ONE );
101+ pgl. endGL();
102+ }
103+
102104 public int sketchWidth () {
103105 return dm. getWidth();
104106 }
0 commit comments