Updated OpenGL examples

This commit is contained in:
codeanticode
2012-08-15 04:40:03 +00:00
parent 15749d072c
commit 59265902cf
2 changed files with 18 additions and 11 deletions

View File

@@ -40,25 +40,25 @@ void draw() {
updateGeometry();
pgl = pg.beginGL();
pgl = pg.beginPGL();
flatShader.bind();
vertLoc = pgl.glGetAttribLocation(flatShader.glProgram, "inVertex");
colorLoc = pgl.glGetAttribLocation(flatShader.glProgram, "inColor");
vertLoc = pgl.getAttribLocation(flatShader.glProgram, "inVertex");
colorLoc = pgl.getAttribLocation(flatShader.glProgram, "inColor");
pgl.glEnableVertexAttribArray(vertLoc);
pgl.glEnableVertexAttribArray(colorLoc);
pgl.enableVertexAttribArray(vertLoc);
pgl.enableVertexAttribArray(colorLoc);
pgl.glVertexAttribPointer(vertLoc, 4, PGL.GL_FLOAT, false, 0, vertData);
pgl.glVertexAttribPointer(colorLoc, 4, PGL.GL_FLOAT, false, 0, colorData);
pgl.vertexAttribPointer(vertLoc, 4, PGL.FLOAT, false, 0, vertData);
pgl.vertexAttribPointer(colorLoc, 4, PGL.FLOAT, false, 0, colorData);
pgl.glDrawArrays(PGL.GL_TRIANGLES, 0, 3);
pgl.drawArrays(PGL.TRIANGLES, 0, 3);
pgl.glDisableVertexAttribArray(vertLoc);
pgl.glDisableVertexAttribArray(colorLoc);
pgl.disableVertexAttribArray(vertLoc);
pgl.disableVertexAttribArray(colorLoc);
flatShader.unbind();
pg.endGL();
pg.endPGL();
}
void updateGeometry() {

View File

@@ -0,0 +1,7 @@
size(100, 100, P3D);
PGraphicsOpenGL pg = (PGraphicsOpenGL)g;
println(pg.OPENGL_VENDOR);
println(pg.OPENGL_RENDERER);
println(pg.OPENGL_VERSION);
println(pg.GLSL_VERSION);
println(pg.OPENGL_EXTENSIONS);