Search in sources :

Example 6 with GLException

use of javax.media.opengl.GLException in project spaceships-demo by puniverse.

the class VAO method setVertex.

public void setVertex(GL3 gl, String attributeName, VBO vbo) {
    vbo.bind(gl);
    final int location = getLocation(gl, attributeName);
    gl.glEnableVertexAttribArray(location);
    if (vbo.getBuffer() instanceof FloatBuffer)
        gl.glVertexAttribPointer(location, vbo.getComponents(), vbo.getComponentType(), vbo.isNormalized(), vbo.getStride(), 0);
    else if (vbo.getBuffer() instanceof IntBuffer)
        gl.glVertexAttribIPointer(location, vbo.getComponents(), vbo.getComponentType(), vbo.getStride(), 0);
    else if (vbo.getBuffer() instanceof DoubleBuffer)
        gl.glVertexAttribPointer(location, vbo.getComponents(), vbo.getComponentType(), false, vbo.getStride(), 0);
    else
        throw new GLException("Unrecognized buffer type: " + vbo.getBuffer().getClass().getName());
}
Also used : DoubleBuffer(java.nio.DoubleBuffer) IntBuffer(java.nio.IntBuffer) GLException(javax.media.opengl.GLException) FloatBuffer(java.nio.FloatBuffer)

Aggregations

GLException (javax.media.opengl.GLException)6 ShaderCode (com.jogamp.opengl.util.glsl.ShaderCode)1 ShaderProgram (com.jogamp.opengl.util.glsl.ShaderProgram)1 IOException (java.io.IOException)1 DoubleBuffer (java.nio.DoubleBuffer)1 FloatBuffer (java.nio.FloatBuffer)1 IntBuffer (java.nio.IntBuffer)1 DebugGL3 (javax.media.opengl.DebugGL3)1 GL3 (javax.media.opengl.GL3)1