From e2d3e848c6437a01e629eef594df75e3b397bad5 Mon Sep 17 00:00:00 2001 From: Austin Marshall Date: Thu, 28 May 2015 19:49:03 -0700 Subject: [PATCH] Adding support for Processing 2.x --- .../SceneViewer/PointCloud.pde | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/HoC_DataApplications_v1.0/SceneViewer/PointCloud.pde b/HoC_DataApplications_v1.0/SceneViewer/PointCloud.pde index 376c5b7..edd8953 100644 --- a/HoC_DataApplications_v1.0/SceneViewer/PointCloud.pde +++ b/HoC_DataApplications_v1.0/SceneViewer/PointCloud.pde @@ -1,36 +1,37 @@ -/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ +/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ * - * Copyright 2008 Aaron Koblin + * Copyright 2008 Aaron Koblin * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. * - *////////////////////////////////////////////////////////////// + *////////////////////////////////////////////////////////////// // OpenGL trickery for point rendering. Buffers make things speedy! import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; -import javax.media.opengl.GL; +import javax.media.opengl.GL2; public class VBPointCloud { PApplet p; - GL gl; - PGraphicsOpenGL pgl; + GL2 gl; + PGraphicsOpenGL pg; + PGL pgl; public float pointSize = .5f; FloatBuffer f, c; public VBPointCloud(PApplet p) { this.p = p; - this.pgl = (PGraphicsOpenGL) p.g; + this.pg = (PGraphicsOpenGL) p.g; } public void loadFloats(float[] points) { @@ -52,7 +53,8 @@ public class VBPointCloud { } public void draw() { - gl = pgl.beginGL(); + pgl = beginPGL(); + gl = ((PJOGL)pgl).gl.getGL2(); gl.glPointSize(pointSize); //GL doesnt take Processing's color values ... so I'm doin it here! @@ -60,17 +62,17 @@ public class VBPointCloud { gl.glColor4f(p.red(c)/255f,p.green(c)/255f,p.blue(c)/255f,p.alpha(c)/255f); //I'll help you make it look a little pretty - gl.glEnable(GL.GL_POINT_SMOOTH); - gl.glDisable(GL.GL_DEPTH_TEST); - gl.glEnable(GL.GL_BLEND); - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); + gl.glEnable(GL2.GL_POINT_SMOOTH); + gl.glDisable(GL2.GL_DEPTH_TEST); + gl.glEnable(GL2.GL_BLEND); + gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE); - gl.glEnableClientState(GL.GL_VERTEX_ARRAY); - // gl.glEnableClientState(GL.GL_COLOR_ARRAY); - gl.glVertexPointer(3, GL.GL_FLOAT, 0, f); - // gl.glColorPointer(4,GL.GL_FLOAT,0,c); - gl.glDrawArrays(GL.GL_POINTS, 0, f.capacity() / 3); - gl.glDisableClientState(GL.GL_VERTEX_ARRAY); - pgl.endGL(); + gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); + // gl.glEnableClientState(GL2.GL_COLOR_ARRAY); + gl.glVertexPointer(3, GL2.GL_FLOAT, 0, f); + // gl.glColorPointer(4,GL2.GL_FLOAT,0,c); + gl.glDrawArrays(GL2.GL_POINTS, 0, f.capacity() / 3); + gl.glDisableClientState(GL2.GL_VERTEX_ARRAY); + endPGL(); } }