Java Code Examples for processing.opengl.PGL#genBuffers()

The following examples show how to use processing.opengl.PGL#genBuffers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PointCloud.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initPointCloud() {
        PGL pgl = ((PGraphicsOpenGL) parentApplet.g).pgl;

        // TODO: lookt at the shaders... 
        myShader = parentApplet.loadShader(PointCloud.class.getResource("points.frag").toString(),
                PointCloud.class.getResource("points.vert").toString());

        myShader.bind();
        shaderProgram = myShader.glProgram;
        vertLoc = pgl.getAttribLocation(shaderProgram, "vertex");
        colorsLoc = pgl.getAttribLocation(shaderProgram, "color");
        transformLoc = pgl.getUniformLocation(shaderProgram, "transform");

        myShader.unbind();

//         System.out.println("Shader program " + shaderProgram + " vertex loc " + vertLoc + " transform loc " + transformLoc + " colors " + colorsLoc);
        // Allocate the buffer in central memory (native),  then java, then OpenGL 
        // Native memory         
        int byteSize = nbPoints * 4 * 4; // 4 : SizeOf Float   -> ? SIZEOF_FLOAT
        verticesNative = ByteBuffer.allocateDirect(byteSize).order(ByteOrder.nativeOrder()).
                asFloatBuffer();
        colorsNative = ByteBuffer.allocateDirect(byteSize).order(ByteOrder.nativeOrder()).asIntBuffer();

        // Java memory 
        verticesJava = new float[nbPoints * 4];
        colorsJava = new int[nbPoints];

//        System.out.println("Buffer vertex object: " + glVertBuff);
        // unbind the buffer.
        pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
        
        // Generate a buffer color data and color. 
        IntBuffer intBuffer = IntBuffer.allocate(2);
        pgl.genBuffers(2, intBuffer);
        vertexBuffer = intBuffer.get(0);
        colorBuffer = intBuffer.get(1);
        
    }
 
Example 2
Source File: PointCloudColorTest.java    From KinectPV2 with MIT License 4 votes vote down vote up
public void setup() {

		  kinect = new KinectPV2(this);

		  kinect.enableDepthImg(true);
		  kinect.enableColorImg(true);
		  kinect.enableColorPointCloud(true);
		
		  kinect.init();
		 
		  sh = loadShader("frag.glsl", "vert.glsl");
		  
		  PGL pgl = beginPGL();

		  // allocate buffer big enough to get all VBO ids back
		  IntBuffer intBuffer = IntBuffer.allocate(2);
		  pgl.genBuffers(2, intBuffer);

		  //memory location of the VBO
		  vertexVboId = intBuffer.get(0);
		  colorVboId = intBuffer.get(1);

		  endPGL();
	}
 
Example 3
Source File: Demo_KinectV2_ParticleDepth.java    From haxademic with MIT License 4 votes vote down vote up
protected void firstFrame() {
	  kinect = new KinectPV2(this);

	  kinect.enableDepthImg(true);

	  kinect.enablePointCloud(true);

	  kinect.setLowThresholdPC(minD);
	  kinect.setHighThresholdPC(maxD);

	  kinect.init();

	  sh = loadShader(FileUtil.getPath("haxademic/shaders/vertex/kinect-points-frag.glsl"), FileUtil.getPath("haxademic/shaders/vertex/kinect-points-vert.glsl"));

	  PGL pgl = beginPGL();

	  IntBuffer intBuffer = IntBuffer.allocate(1);
	  pgl.genBuffers(1, intBuffer);

	  //memory location of the VBO
	  vertexVboId = intBuffer.get(0);

	  endPGL();
}