本文整理汇总了Java中com.jogamp.opengl.GL2.glBindBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glBindBuffer方法的具体用法?Java GL2.glBindBuffer怎么用?Java GL2.glBindBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glBindBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installShaders
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void installShaders(GL2 gl) throws IOException {
if (shadersInstalled) {
return;
}
gl.glEnable(GL3.GL_PROGRAM_POINT_SIZE);
checkEventVertexBufferAllocation(BUF_INITIAL_SIZE_EVENTS);
shadersInstalled = true;
IntBuffer b = IntBuffer.allocate(8); // buffer to hold return values
shaderprogram = gl.glCreateProgram();
vertexShader = gl.glCreateShader(GL2ES2.GL_VERTEX_SHADER);
fragmentShader = gl.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER);
checkGLError(gl, "creating shaders and shader program");
String vsrc = readFromStream(SpaceTimeRollingEventDisplayMethod.class
.getResourceAsStream("SpaceTimeRollingEventDisplayMethod_Vertex.glsl"));
gl.glShaderSource(vertexShader, 1, new String[]{vsrc}, (int[]) null, 0);
gl.glCompileShader(vertexShader);
b.clear();
gl.glGetShaderiv(vertexShader, GL2ES2.GL_COMPILE_STATUS, b);
if (b.get(0) != GL.GL_TRUE) {
log.warning("error compiling vertex shader");
printShaderLog(gl);
}
checkGLError(gl, "compiling vertex shader");
String fsrc = readFromStream(SpaceTimeRollingEventDisplayMethod.class
.getResourceAsStream("SpaceTimeRollingEventDisplayMethod_Fragment.glsl"));
gl.glShaderSource(fragmentShader, 1, new String[]{fsrc}, (int[]) null, 0);
gl.glCompileShader(fragmentShader);
b.clear();
gl.glGetShaderiv(fragmentShader, GL2ES2.GL_COMPILE_STATUS, b);
if (b.get(0) != GL.GL_TRUE) {
log.warning("error compiling fragment shader");
printShaderLog(gl);
}
checkGLError(gl, "compiling fragment shader");
gl.glAttachShader(shaderprogram, vertexShader);
gl.glAttachShader(shaderprogram, fragmentShader);
gl.glLinkProgram(shaderprogram);
b.clear();
// gl.glGetShaderiv(shaderprogram, GL2ES2.GL_COMPILE_STATUS, b);
// if (b.get(0) != GL.GL_TRUE) {
// log.warning("error linking shader program");
// printShaderLog(gl);
// }
checkGLError(gl, "linking shader program");
b.clear();
gl.glGenVertexArrays(1, b);
vao = b.get(0);
gl.glBindVertexArray(vao);
b.clear();
gl.glGenBuffers(1, b);
vbo = b.get(0);
checkGLError(gl, "setting up vertex array and vertex buffer");
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo);
// gl.glBindAttribLocation(shaderprogram, polarity_vert, "polarity"); // symbolic names in vertex and fragment shaders
gl.glBindAttribLocation(shaderprogram, v_vert, "v");
// gl.glBindAttribLocation(shaderprogram, polarity_frag, "frag_polarity");
checkGLError(gl, "binding shader attributes");
gl.glVertexAttribPointer(v_vert, 3, GL.GL_FLOAT, false, EVENT_SIZE_BYTES, 0);
// gl.glVertexAttribPointer(polarity_vert, 1, GL.GL_FLOAT, false, EVENT_SIZE_BYTES, 3);
checkGLError(gl, "setting vertex attribute pointers");
idMv = gl.glGetUniformLocation(shaderprogram, "mv");
idProj = gl.glGetUniformLocation(shaderprogram, "proj");
idt0 = gl.glGetUniformLocation(shaderprogram, "t0");
idt1 = gl.glGetUniformLocation(shaderprogram, "t1");
idPointSize = gl.glGetUniformLocation(shaderprogram, "pointSize");
if ((idMv < 0) || (idProj < 0) || (idt0 < 0) || (idt1 < 0) || (idPointSize < 0)) {
throw new RuntimeException("cannot locate uniform variable idMv, idProj, idt0, idt1, or idPointSize in shader program");
}
checkGLError(gl, "getting IDs for uniform modelview and projection matrices in shaders");
}