Skip to content
This repository has been archived by the owner on Mar 29, 2018. It is now read-only.

Commit

Permalink
Adding support for Processing 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Marshall committed May 29, 2015
1 parent 8749df5 commit e2d3e84
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions HoC_DataApplications_v1.0/SceneViewer/PointCloud.pde
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -52,25 +53,26 @@ public class VBPointCloud {
}

public void draw() {
gl = pgl.beginGL();
pgl = beginPGL();
gl = ((PJOGL)pgl).gl.getGL2();

This comment has been minimized.

Copy link
@kaisark

kaisark Mar 17, 2018

I get a type mismatch on line 57. Which version of jogl-all-2.1.0.jar are you using?

gl.glPointSize(pointSize);

//GL doesnt take Processing's color values ... so I'm doin it here!
int c = p.g.strokeColor;
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();
}
}

1 comment on commit e2d3e84

@kaisark
Copy link

@kaisark kaisark commented on e2d3e84 Mar 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a "type mismatch" error on the following line:
57. gl = ((PJOGL)pgl).gl.getGL2();

Which version of jogl-all-2.1.0.jar are you using?

Please sign in to comment.