From 0f17efa9fd1f8c7c70fd42fb33994cdf6e6d51b2 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Tue, 17 Jan 2012 18:08:30 +0000 Subject: [PATCH] Code cleanup, updated TexturedSphere example, some more fixes --- .../Form/TexturedSphere/TexturedSphere.pde | 6 +- .../src/processing/opengl/PFontTexture.java | 12 +- .../src/processing/opengl/PFramebuffer.java | 171 ++---- .../opengl/src/processing/opengl/PGL.java | 30 +- .../processing/opengl/PGraphicsOpenGL.java | 505 ++---------------- .../opengl/src/processing/opengl/PShader.java | 56 +- .../src/processing/opengl/PShape3D.java | 471 +++++----------- .../src/processing/opengl/PTexture.java | 76 +-- 8 files changed, 311 insertions(+), 1016 deletions(-) diff --git a/java/libraries/opengl/examples/Form/TexturedSphere/TexturedSphere.pde b/java/libraries/opengl/examples/Form/TexturedSphere/TexturedSphere.pde index 734838469..c106a204c 100755 --- a/java/libraries/opengl/examples/Form/TexturedSphere/TexturedSphere.pde +++ b/java/libraries/opengl/examples/Form/TexturedSphere/TexturedSphere.pde @@ -28,6 +28,7 @@ int SINCOS_LENGTH = int(360.0 / SINCOS_PRECISION); void setup() { size(1024, 768, P3D); + smooth(); texmap = loadImage("world32k.jpg"); initializeSphere(sDetail); } @@ -43,8 +44,7 @@ void renderGlobe() { pushMatrix(); noFill(); stroke(255,200); - strokeWeight(2); - smooth(); + strokeWeight(2); popMatrix(); lights(); pushMatrix(); @@ -169,4 +169,4 @@ void texturedSphere(float r, PImage t) vertex(sphereX[voff]*r, sphereY[voff]*r, sphereZ[voff]*r, u, v); endShape(); -} +} \ No newline at end of file diff --git a/java/libraries/opengl/src/processing/opengl/PFontTexture.java b/java/libraries/opengl/src/processing/opengl/PFontTexture.java index 2a2bff77d..e10784b22 100644 --- a/java/libraries/opengl/src/processing/opengl/PFontTexture.java +++ b/java/libraries/opengl/src/processing/opengl/PFontTexture.java @@ -52,7 +52,7 @@ import processing.core.PImage; */ class PFontTexture implements PConstants { protected PApplet parent; - protected PGraphicsOpenGL ogl; + protected PGraphicsOpenGL renderer; protected GLContext context; protected PFont font; @@ -71,8 +71,8 @@ class PFontTexture implements PConstants { public PFontTexture(PApplet parent, PFont font, int maxw, int maxh) { this.parent = parent; this.font = font; - ogl = (PGraphicsOpenGL)parent.g; - context = ogl.getContext(); + renderer = (PGraphicsOpenGL)parent.g; + context = renderer.getContext(); initTexture(maxw, maxh); } @@ -124,7 +124,7 @@ class PFontTexture implements PConstants { textures = new PTexture[1]; textures[0] = tex; images = new PImage[1]; - images[0] = ogl.wrapTexture(tex); + images[0] = renderer.wrapTexture(tex); currentTex = 0; } else if (resize) { // Replacing old smaller texture with larger one. @@ -134,7 +134,7 @@ class PFontTexture implements PConstants { tex.put(tex0); textures[currentTex] = tex; - images[currentTex].setCache(ogl, tex); + images[currentTex].setCache(renderer, tex); images[currentTex].width = tex.width; images[currentTex].height = tex.height; } else { @@ -148,7 +148,7 @@ class PFontTexture implements PConstants { PImage[] tempImg = images; images = new PImage[textures.length + 1]; PApplet.arrayCopy(tempImg, images, tempImg.length); - images[tempImg.length] = ogl.wrapTexture(tex); + images[tempImg.length] = renderer.wrapTexture(tex); } lastTex = currentTex; diff --git a/java/libraries/opengl/src/processing/opengl/PFramebuffer.java b/java/libraries/opengl/src/processing/opengl/PFramebuffer.java index ef5126058..66e421ae7 100644 --- a/java/libraries/opengl/src/processing/opengl/PFramebuffer.java +++ b/java/libraries/opengl/src/processing/opengl/PFramebuffer.java @@ -1,23 +1,24 @@ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* - Part of the Processing project - http://processing.org + Part of the Processing project - http://processing.org - Copyright (c) 2010 Ben Fry and Casey Reas + Copyright (c) 2011 Andres Colubri + Copyright (c) 2010 Ben Fry and Casey Reas - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License version 2.1 as published by the Free Software Foundation. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1 as published by the Free Software Foundation. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA */ package processing.opengl; @@ -38,7 +39,7 @@ import processing.core.PConstants; */ public class PFramebuffer implements PConstants { protected PApplet parent; - protected PGraphicsOpenGL ogl; + protected PGraphicsOpenGL renderer; protected PGL pgl; public int glFboID; @@ -57,7 +58,6 @@ public class PFramebuffer implements PConstants { protected int nsamples; protected int numColorBuffers; - //protected int[] colorBufferAttchPoints; protected PTexture[] colorBufferTex; protected boolean screenFb; @@ -79,9 +79,8 @@ public class PFramebuffer implements PConstants { int depthBits, int stencilBits, boolean combinedDepthStencil, boolean screen) { this.parent = parent; - ogl = (PGraphicsOpenGL)parent.g; - pgl = ogl.pgl; - //gl.registerPGLObject(this); + renderer = (PGraphicsOpenGL)parent.g; + pgl = renderer.pgl; glFboID = 0; glDepthBufferID = 0; @@ -110,10 +109,8 @@ public class PFramebuffer implements PConstants { } numColorBuffers = colorBuffers; - //colorBufferAttchPoints = new int[numColorBuffers]; colorBufferTex = new PTexture[numColorBuffers]; for (int i = 0; i < numColorBuffers; i++) { - //colorBufferAttchPoints[i] = GL.GL_COLOR_ATTACHMENT0 + i; colorBufferTex[i] = null; } @@ -155,19 +152,19 @@ public class PFramebuffer implements PConstants { protected void finalize() throws Throwable { try { if (glFboID != 0) { - ogl.finalizeFrameBufferObject(glFboID); + renderer.finalizeFrameBufferObject(glFboID); } if (glDepthBufferID != 0) { - ogl.finalizeRenderBufferObject(glDepthBufferID); + renderer.finalizeRenderBufferObject(glDepthBufferID); } if (glStencilBufferID != 0) { - ogl.finalizeRenderBufferObject(glStencilBufferID); + renderer.finalizeRenderBufferObject(glStencilBufferID); } if (glColorBufferMultisampleID != 0) { - ogl.finalizeRenderBufferObject(glColorBufferMultisampleID); + renderer.finalizeRenderBufferObject(glColorBufferMultisampleID); } if (glDepthStencilBufferID != 0) { - ogl.finalizeRenderBufferObject(glDepthStencilBufferID); + renderer.finalizeRenderBufferObject(glDepthStencilBufferID); } } finally { super.finalize(); @@ -175,33 +172,25 @@ public class PFramebuffer implements PConstants { } public void clear() { - ogl.pushFramebuffer(); - ogl.setFramebuffer(this); -// getGl().glClearColor(0f, 0f, 0f, 0.0f); -// getGl().glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); + renderer.pushFramebuffer(); + renderer.setFramebuffer(this); pgl.setClearColor(0, 0, 0, 0); pgl.clearAllBuffers(); - ogl.popFramebuffer(); + renderer.popFramebuffer(); } public void copy(PFramebuffer dest) { -// getGl().glBindFramebuffer(GL2.GL_READ_FRAMEBUFFER, this.glFboID); -// getGl().glBindFramebuffer(GL2.GL_DRAW_FRAMEBUFFER, dest.glFboID); pgl.bindReadFramebuffer(this.glFboID); - pgl.bindWriteFramebuffer(dest.glFboID); - -// getGl2().glBlitFramebuffer(0, 0, this.width, this.height, 0, 0, dest.width, dest.height, GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST); + pgl.bindWriteFramebuffer(dest.glFboID); pgl.copyFramebuffer(this.width, this.height, dest.width, dest.height); } public void bind() { if (screenFb) { if (PGraphicsOpenGL.fboSupported) { -// getGl().glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); pgl.bindFramebuffer(0); } } else if (fboMode) { -// getGl().glBindFramebuffer(GL.GL_FRAMEBUFFER, glFboID); pgl.bindFramebuffer(glFboID); } else { backupScreen(); @@ -209,11 +198,10 @@ public class PFramebuffer implements PConstants { if (0 < numColorBuffers) { // Drawing the current contents of the first color buffer to emulate // front-back buffer swap. - ogl.drawTexture(colorBufferTex[0].glTarget, colorBufferTex[0].glID, width, height, 0, 0, width, height, 0, 0, width, height); + renderer.drawTexture(colorBufferTex[0].glTarget, colorBufferTex[0].glID, width, height, 0, 0, width, height, 0, 0, width, height); } if (noDepth) { -// getGl().glDisable(GL.GL_DEPTH_TEST); pgl.disableDepthTest(); } } @@ -226,11 +214,9 @@ public class PFramebuffer implements PConstants { public void finish() { if (noDepth) { // No need to clear depth buffer because depth testing was disabled. - if (ogl.hintEnabled(DISABLE_DEPTH_TEST)) { -// getGl().glDisable(GL.GL_DEPTH_TEST); + if (renderer.hintEnabled(DISABLE_DEPTH_TEST)) { pgl.disableDepthTest(); } else { -// getGl().glEnable(GL.GL_DEPTH_TEST); pgl.enableDepthTest(); } } @@ -248,8 +234,6 @@ public class PFramebuffer implements PConstants { // no FBOs are available should be done before any onscreen drawing. pgl.setClearColor(0, 0, 0, 0); pgl.clearDepthBuffer(); -// getGl().glClearColor(0, 0, 0, 0); -// getGl().glClear(GL.GL_DEPTH_BUFFER_BIT); } } } @@ -258,7 +242,6 @@ public class PFramebuffer implements PConstants { public void backupScreen() { if (pixelBuffer == null) createPixelBuffer(); pixelBuffer.rewind(); - //getGl().glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer); pgl.readPixels(pixelBuffer, 0, 0, width, height); copyToTexture(pixelBuffer, backupTexture.glID, backupTexture.glTarget); @@ -266,14 +249,13 @@ public class PFramebuffer implements PConstants { // Draws the contents of the backup texture to the screen. public void restoreBackup() { - ogl.drawTexture(backupTexture, 0, 0, width, height, 0, 0, width, height); + renderer.drawTexture(backupTexture, 0, 0, width, height, 0, 0, width, height); } // Copies current content of screen to color buffers. public void copyToColorBuffers() { if (pixelBuffer == null) createPixelBuffer(); pixelBuffer.rewind(); - //getGl().glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer); pgl.readPixels(pixelBuffer, 0, 0, width, height); for (int i = 0; i < numColorBuffers; i++) { copyToTexture(pixelBuffer, colorBufferTex[i].glID, colorBufferTex[i].glTarget); @@ -283,7 +265,6 @@ public class PFramebuffer implements PConstants { public void readPixels() { if (pixelBuffer == null) createPixelBuffer(); pixelBuffer.rewind(); -// getGl().glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer); pgl.readPixels(pixelBuffer, 0, 0, width, height); } @@ -333,23 +314,21 @@ public class PFramebuffer implements PConstants { } if (fboMode) { - ogl.pushFramebuffer(); - ogl.setFramebuffer(this); + renderer.pushFramebuffer(); + renderer.setFramebuffer(this); // Making sure nothing is attached. for (int i = 0; i < numColorBuffers; i++) { -// getGl().glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + i, GL.GL_TEXTURE_2D, 0, 0); pgl.cleanFramebufferTexture(i); } for (int i = 0; i < numColorBuffers; i++) { pgl.setFramebufferTexture(i, colorBufferTex[i].glTarget, colorBufferTex[i].glID); -// getGl().glFramebufferTexture2D(GL.GL_FRAMEBUFFER, colorBufferAttchPoints[i], colorBufferTex[i].glTarget, colorBufferTex[i].glID, 0); } validateFbo(); - ogl.popFramebuffer(); + renderer.popFramebuffer(); } } @@ -366,7 +345,7 @@ public class PFramebuffer implements PConstants { glFboID = 0; } else if (fboMode) { //glFboID = ogl.createGLResource(PGraphicsOpenGL.GL_FRAME_BUFFER); - glFboID = ogl.createFrameBufferObject(); + glFboID = renderer.createFrameBufferObject(); } else { glFboID = 0; } @@ -391,23 +370,23 @@ public class PFramebuffer implements PConstants { protected void release() { if (glFboID != 0) { - ogl.finalizeFrameBufferObject(glFboID); + renderer.finalizeFrameBufferObject(glFboID); glFboID = 0; } if (glDepthBufferID != 0) { - ogl.finalizeRenderBufferObject(glDepthBufferID); + renderer.finalizeRenderBufferObject(glDepthBufferID); glDepthBufferID = 0; } if (glStencilBufferID != 0) { - ogl.finalizeRenderBufferObject(glStencilBufferID); + renderer.finalizeRenderBufferObject(glStencilBufferID); glStencilBufferID = 0; } if (glColorBufferMultisampleID != 0) { - ogl.finalizeRenderBufferObject(glColorBufferMultisampleID); + renderer.finalizeRenderBufferObject(glColorBufferMultisampleID); glColorBufferMultisampleID = 0; } if (glDepthStencilBufferID != 0) { - ogl.finalizeRenderBufferObject(glDepthStencilBufferID); + renderer.finalizeRenderBufferObject(glDepthStencilBufferID); glDepthStencilBufferID = 0; } } @@ -417,19 +396,15 @@ public class PFramebuffer implements PConstants { if (screenFb) return; if (fboMode) { - ogl.pushFramebuffer(); - ogl.setFramebuffer(this); + renderer.pushFramebuffer(); + renderer.setFramebuffer(this); - glColorBufferMultisampleID = ogl.createRenderBufferObject(); + glColorBufferMultisampleID = renderer.createRenderBufferObject(); pgl.bindRenderbuffer(glColorBufferMultisampleID); - pgl.setRenderbufferNumSamples(nsamples, width, height); + pgl.setRenderbufferNumSamples(nsamples, PGL.RGBA8, width, height); pgl.setRenderbufferColorAttachment(glColorBufferMultisampleID); -// getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glColorBufferMultisampleID); -// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, GL.GL_RGBA8, width, height); -// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0, GL.GL_RENDERBUFFER, glColorBufferMultisampleID); - - ogl.popFramebuffer(); + renderer.popFramebuffer(); } } @@ -442,27 +417,22 @@ public class PFramebuffer implements PConstants { } if (fboMode) { - ogl.pushFramebuffer(); - ogl.setFramebuffer(this); + renderer.pushFramebuffer(); + renderer.setFramebuffer(this); - glDepthStencilBufferID = ogl.createRenderBufferObject(); + glDepthStencilBufferID = renderer.createRenderBufferObject(); pgl.bindRenderbuffer(glDepthStencilBufferID); - //getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glDepthStencilBufferID); if (multisample) { -// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, GL.GL_DEPTH24_STENCIL8, width, height); - pgl.setRenderbufferNumSamples(nsamples, width, height); + pgl.setRenderbufferNumSamples(nsamples, PGL.DEPTH_24BIT_STENCIL_8BIT, width, height); } else { pgl.setRenderbufferStorage(PGL.DEPTH_24BIT_STENCIL_8BIT, width, height); -// getGl().glRenderbufferStorage(GL.GL_RENDERBUFFER, GL.GL_DEPTH24_STENCIL8, width, height); } pgl.setRenderbufferDepthAttachment(glDepthStencilBufferID); pgl.setRenderbufferStencilAttachment(glDepthStencilBufferID); -// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, glDepthStencilBufferID); -// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, glDepthStencilBufferID); - ogl.popFramebuffer(); + renderer.popFramebuffer(); } } @@ -475,11 +445,10 @@ public class PFramebuffer implements PConstants { } if (fboMode) { - ogl.pushFramebuffer(); - ogl.setFramebuffer(this); + renderer.pushFramebuffer(); + renderer.setFramebuffer(this); - glDepthBufferID = ogl.createRenderBufferObject(); - //getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glDepthBufferID); + glDepthBufferID = renderer.createRenderBufferObject(); pgl.bindRenderbuffer(glDepthBufferID); int glConst = PGL.DEPTH_16BIT; @@ -492,17 +461,14 @@ public class PFramebuffer implements PConstants { } if (multisample) { - //getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, glConst, width, height); - pgl.setRenderbufferNumSamples(nsamples, width, height); + pgl.setRenderbufferNumSamples(nsamples, glConst, width, height); } else { - //getGl().glRenderbufferStorage(GL.GL_RENDERBUFFER, glConst, width, height); pgl.setRenderbufferStorage(glConst, width, height); } pgl.setRenderbufferDepthAttachment(glDepthBufferID); - //getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, glDepthBufferID); - ogl.popFramebuffer(); + renderer.popFramebuffer(); } } @@ -515,11 +481,10 @@ public class PFramebuffer implements PConstants { } if (fboMode) { - ogl.pushFramebuffer(); - ogl.setFramebuffer(this); + renderer.pushFramebuffer(); + renderer.setFramebuffer(this); - glStencilBufferID = ogl.createRenderBufferObject(); -// getGl().glBindRenderbuffer(GL.GL_RENDERBUFFER, glStencilBufferID); + glStencilBufferID = renderer.createRenderBufferObject(); pgl.bindRenderbuffer(glStencilBufferID); int glConst = PGL.STENCIL_1BIT; @@ -531,17 +496,14 @@ public class PFramebuffer implements PConstants { glConst = PGL.STENCIL_8BIT; } if (multisample) { -// getGl2().glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, nsamples, glConst, width, height); - pgl.setRenderbufferNumSamples(nsamples, width, height); + pgl.setRenderbufferNumSamples(nsamples, glConst, width, height); } else { -// getGl().glRenderbufferStorage(GL.GL_RENDERBUFFER, glConst, width, height); pgl.setRenderbufferStorage(glConst, width, height); } pgl.setRenderbufferStencilAttachment(glStencilBufferID); -// getGl().glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, glStencilBufferID); - ogl.popFramebuffer(); + renderer.popFramebuffer(); } } @@ -561,17 +523,10 @@ public class PFramebuffer implements PConstants { pgl.bindTexture(gltarget, glid); pgl.copyTexSubImage(buffer, gltarget, 0, 0, width, height); pgl.unbindTexture(gltarget); - pgl.disableTexturing(gltarget); - -// getGl().glEnable(gltarget); -// getGl().glBindTexture(gltarget, glid); -// getGl().glTexSubImage2D(gltarget, 0, 0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer); -// getGl().glBindTexture(gltarget, 0); -// getGl().glDisable(gltarget); + pgl.disableTexturing(gltarget); } public boolean validateFbo() { -// int status = getGl().glCheckFramebufferStatus(GL.GL_FRAMEBUFFER); int status = pgl.getFramebufferStatus(); if (status == PGL.FRAMEBUFFER_COMPLETE) { return true; @@ -589,12 +544,4 @@ public class PFramebuffer implements PConstants { throw new RuntimeException("PFramebuffer: unknown framebuffer error (" + Integer.toHexString(status) + ")"); } } - -// protected GL getGl() { -// return ogl.gl; -// } -// -// protected GL2GL3 getGl2() { -// return ogl.gl2x; -// } } diff --git a/java/libraries/opengl/src/processing/opengl/PGL.java b/java/libraries/opengl/src/processing/opengl/PGL.java index 85157f529..f86c6d36e 100644 --- a/java/libraries/opengl/src/processing/opengl/PGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGL.java @@ -1,3 +1,26 @@ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Processing project - http://processing.org + + Copyright (c) 2011 Andres Colubri + Copyright (c) 2010 Ben Fry and Casey Reas + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License version 2.1 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + */ + package processing.opengl; import java.nio.Buffer; @@ -78,6 +101,7 @@ public class PGL { public static final int CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE; public static final int REPEAT = GL.GL_REPEAT; + public static final int RGBA8 = GL.GL_RGBA8; public static final int DEPTH_24BIT_STENCIL_8BIT = GL.GL_DEPTH24_STENCIL8; public static final int DEPTH_16BIT = GL.GL_DEPTH_COMPONENT16; @@ -892,11 +916,11 @@ public class PGL { } public void bindRenderbuffer(int id) { - gl.glBindRenderbuffer(GL.GL_RENDERBUFFER,id); + gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, id); } - public void setRenderbufferNumSamples(int samples, int w, int h) { - gl2x.glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, GL.GL_RGBA8, w, h); + public void setRenderbufferNumSamples(int samples, int format, int w, int h) { + gl2x.glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, format, w, h); } public void setRenderbufferStorage(int format, int w, int h) { diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 53382f9ed..f22b689c0 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -58,21 +58,9 @@ import processing.core.PApplet; * */ public class PGraphicsOpenGL extends PGraphics { - /* - public int pipeline; - public GL gl; - public GL2 gl2; - public GL2GL3 gl2x; - public GL2ES1 gl2f; - public GL2ES2 gl2p; - public GL3 gl3p; - public GL4 gl4p; - */ - + /** Interface between Processing and OpenGL */ protected PGL pgl; - - /** Selected GL profile */ protected GLProfile profile; @@ -85,10 +73,8 @@ public class PGraphicsOpenGL extends PGraphics { /** The rendering context (holds rendering state info) */ protected GLContext context; - - - /** The PApplet renderer. For the primary surface, pgl == this. */ - protected PGraphicsOpenGL ogl; + /** The PApplet renderer. For the primary surface, renderer == this. */ + protected PGraphicsOpenGL renderer; // ........................................................ @@ -352,12 +338,6 @@ public class PGraphicsOpenGL extends PGraphics { */ static public boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; -// /** Size of an int (in bytes). */ -// protected static final int SIZEOF_INT = Integer.SIZE / 8; -// -// /** Size of a float (in bytes). */ -// protected static final int SIZEOF_FLOAT = Float.SIZE / 8; - // ........................................................ // Bezier and Catmull-Rom curves @@ -555,13 +535,7 @@ public class PGraphicsOpenGL extends PGraphics { if (primarySurface) { // Allocation of the main renderer, which mainly involves initializing OpenGL. if (context == null) { - initPrimary(); - // If there are registered GL objects (i.e.: PTexture, PShape3D, etc), it means - // that the context has been re-created, so we need to re-allocate them in - // order to be able to keep using them. This step doesn't refresh their data, this - // is, they are empty after re-allocation. - //getGLObjects(); - //allocateGLObjects(); + initPrimary(); } else { reapplySettings(); } @@ -605,7 +579,6 @@ public class PGraphicsOpenGL extends PGraphics { int[] temp = new int[1]; pgl.genVertexArray(temp); - //gl2x.glGenVertexArrays(1, temp, 0); int id = temp[0]; if (glVertexArrays.containsKey(id)) { @@ -620,8 +593,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteVertexArrayObject(int id) { if (glVertexArrays.containsKey(id)) { int[] temp = { id }; - pgl.delVertexArray(temp); - //gl2x.glDeleteVertexArrays(1, temp, 0); + pgl.delVertexArray(temp); glVertexArrays.remove(id); } } @@ -630,7 +602,6 @@ public class PGraphicsOpenGL extends PGraphics { for (Integer id : glVertexArrays.keySet()) { int[] temp = { id.intValue() }; pgl.delVertexArray(temp); - //gl2x.glDeleteVertexArrays(1, temp, 0); } glVertexArrays.clear(); } @@ -651,7 +622,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glVertexArrays.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl2x.glDeleteVertexArrays(1, temp, 0); pgl.delVertexArray(temp); } } @@ -668,7 +638,6 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedTextureObjects(); int[] temp = new int[1]; - //gl.glGenTextures(1, temp, 0); pgl.genTexture(temp); int id = temp[0]; @@ -685,7 +654,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glTextureObjects.containsKey(id)) { int[] temp = { id }; pgl.delTexture(temp); - //gl.glDeleteTextures(1, temp, 0); glTextureObjects.remove(id); } } @@ -693,7 +661,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllTextureObjects() { for (Integer id : glTextureObjects.keySet()) { int[] temp = { id.intValue() }; - //gl.glDeleteTextures(1, temp, 0); pgl.delTexture(temp); } glTextureObjects.clear(); @@ -715,7 +682,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glTextureObjects.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl.glDeleteTextures(1, temp, 0); pgl.delTexture(temp); } } @@ -731,7 +697,6 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedVertexBufferObjects(); int[] temp = new int[1]; - //gl.glGenBuffers(1, temp, 0); pgl.genBuffer(temp); int id = temp[0]; @@ -747,7 +712,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteVertexBufferObject(int id) { if (glVertexBuffers.containsKey(id)) { int[] temp = { id }; - //gl.glDeleteBuffers(1, temp, 0); pgl.delBuffer(temp); glVertexBuffers.remove(id); } @@ -756,7 +720,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllVertexBufferObjects() { for (Integer id : glVertexBuffers.keySet()) { int[] temp = { id.intValue() }; - //gl.glDeleteBuffers(1, temp, 0); pgl.delBuffer(temp); } glVertexBuffers.clear(); @@ -778,7 +741,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glVertexBuffers.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl.glDeleteBuffers(1, temp, 0); pgl.delBuffer(temp); } } @@ -794,7 +756,6 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedFrameBufferObjects(); int[] temp = new int[1]; - //gl.glGenFramebuffers(1, temp, 0); pgl.genFramebuffer(temp); int id = temp[0]; @@ -810,7 +771,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteFrameBufferObject(int id) { if (glFrameBuffers.containsKey(id)) { int[] temp = { id }; - //gl.glDeleteFramebuffers(1, temp, 0); pgl.delFramebuffer(temp); glFrameBuffers.remove(id); } @@ -819,7 +779,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllFrameBufferObjects() { for (Integer id : glFrameBuffers.keySet()) { int[] temp = { id.intValue() }; - //gl.glDeleteFramebuffers(1, temp, 0); pgl.delFramebuffer(temp); } glFrameBuffers.clear(); @@ -841,7 +800,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glFrameBuffers.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl.glDeleteFramebuffers(1, temp, 0); pgl.delFramebuffer(temp); } } @@ -857,7 +815,6 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedRenderBufferObjects(); int[] temp = new int[1]; - //gl.glGenRenderbuffers(1, temp, 0); pgl.genRenderbuffer(temp); int id = temp[0]; @@ -873,7 +830,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteRenderBufferObject(int id) { if (glRenderBuffers.containsKey(id)) { int[] temp = { id }; - //gl.glDeleteRenderbuffers(1, temp, 0); pgl.delRenderbuffer(temp); glRenderBuffers.remove(id); } @@ -882,7 +838,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllRenderBufferObjects() { for (Integer id : glRenderBuffers.keySet()) { int[] temp = { id.intValue() }; - //gl.glDeleteRenderbuffers(1, temp, 0); pgl.delRenderbuffer(temp); } glRenderBuffers.clear(); @@ -904,7 +859,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glRenderBuffers.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl.glDeleteRenderbuffers(1, temp, 0); pgl.delRenderbuffer(temp); } } @@ -918,11 +872,10 @@ public class PGraphicsOpenGL extends PGraphics { protected int createGLSLProgramObject() { - ogl.report("before delete"); + renderer.report("before delete"); deleteFinalizedGLSLProgramObjects(); int[] temp = new int[1]; - //int id = gl2x.glCreateProgram(); pgl.genProgram(temp); int id = temp[0]; @@ -939,7 +892,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glslPrograms.containsKey(id)) { int[] temp = { id }; pgl.delProgram(temp); - //gl2x.glDeleteProgram(id); glslPrograms.remove(id); } } @@ -947,7 +899,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllGLSLProgramObjects() { for (Integer id : glslPrograms.keySet()) { int[] temp = { id.intValue() }; - //gl2x.glDeleteProgram(id); pgl.delProgram(temp); } glslPrograms.clear(); @@ -969,7 +920,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glslPrograms.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl2x.glDeleteProgram(id.intValue()); pgl.delProgram(temp); } } @@ -985,7 +935,6 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedGLSLVertShaderObjects(); int[] temp = new int[1]; - //int id = gl2x.glCreateShader(GL2.GL_VERTEX_SHADER); pgl.genVertexShader(temp); int id = temp[0]; @@ -1002,7 +951,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glslVertexShaders.containsKey(id)) { int[] temp = { id }; pgl.delVertexShader(temp); - //gl2x.glDeleteShader(id); glslVertexShaders.remove(id); } } @@ -1010,7 +958,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllGLSLVertShaderObjects() { for (Integer id : glslVertexShaders.keySet()) { int[] temp = { id.intValue() }; - //gl2x.glDeleteShader(id); pgl.delVertexShader(temp); } glslVertexShaders.clear(); @@ -1032,7 +979,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glslVertexShaders.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl2x.glDeleteShader(id.intValue()); pgl.delVertexShader(temp); } } @@ -1049,7 +995,6 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedGLSLFragShaderObjects(); int[] temp = new int[1]; - //int id = gl2x.glCreateShader(GL2.GL_FRAGMENT_SHADER); pgl.genFragmentShader(temp); int id = temp[0]; @@ -1065,7 +1010,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteGLSLFragShaderObject(int id) { if (glslFragmentShaders.containsKey(id)) { int[] temp = { id }; - //gl2x.glDeleteShader(id); pgl.delFragmentShader(temp); glslFragmentShaders.remove(id); } @@ -1075,7 +1019,6 @@ public class PGraphicsOpenGL extends PGraphics { for (Integer id : glslFragmentShaders.keySet()) { int[] temp = { id.intValue() }; pgl.delFragmentShader(temp); - //gl2x.glDeleteShader(id); } glslFragmentShaders.clear(); } @@ -1096,7 +1039,6 @@ public class PGraphicsOpenGL extends PGraphics { if (glslFragmentShaders.get(id)) { finalized.add(id); int[] temp = { id.intValue() }; - //gl2x.glDeleteShader(id.intValue()); pgl.delFragmentShader(temp); } } @@ -1264,38 +1206,27 @@ public class PGraphicsOpenGL extends PGraphics { protected void createFillBuffers() { glFillVertexBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillVertexBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * MAX_TESS_VERTICES * SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glFillVertexBufferID); pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode); glFillColorBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillColorBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * MAX_TESS_VERTICES * SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glFillColorBufferID); pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode); glFillNormalBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillNormalBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * MAX_TESS_VERTICES * SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glFillNormalBufferID); pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode); glFillTexCoordBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 2 * MAX_TESS_VERTICES * SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glFillTexCoordBufferID); pgl.initVertexBuffer(2 * MAX_TESS_VERTICES, vboMode); pgl.unbindVertexBuffer(); glFillIndexBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillIndexBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, MAX_TESS_INDICES * SIZEOF_INT, null, vboMode); pgl.bindIndexBuffer(glFillIndexBufferID); pgl.initIndexBuffer(MAX_TESS_INDICES, vboMode); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); pgl.unbindIndexBuffer(); } @@ -1318,38 +1249,27 @@ public class PGraphicsOpenGL extends PGraphics { protected void createLineBuffers() { glLineVertexBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineVertexBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glLineVertexBufferID); pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode); glLineColorBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineColorBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glLineColorBufferID); pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode); glLineNormalBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineNormalBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glLineNormalBufferID); pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode); glLineAttribBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineAttribBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glLineAttribBufferID); pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode); pgl.unbindVertexBuffer(); glLineIndexBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineIndexBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, MAX_TESS_INDICES * PGraphicsOpenGL.SIZEOF_INT, null, vboMode); pgl.bindIndexBuffer(glLineIndexBufferID); pgl.initIndexBuffer(MAX_TESS_INDICES, vboMode); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); pgl.unbindIndexBuffer(); } @@ -1372,38 +1292,27 @@ public class PGraphicsOpenGL extends PGraphics { protected void createPointBuffers() { glPointVertexBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointVertexBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glPointVertexBufferID); pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode); glPointColorBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointColorBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glPointColorBufferID); pgl.initVertexBuffer(4 * MAX_TESS_VERTICES, vboMode); glPointNormalBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointNormalBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glPointNormalBufferID); pgl.initVertexBuffer(3 * MAX_TESS_VERTICES, vboMode); glPointAttribBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointAttribBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 2 * MAX_TESS_VERTICES * PGraphicsOpenGL.SIZEOF_FLOAT, null, vboMode); pgl.bindVertexBuffer(glPointAttribBufferID); pgl.initVertexBuffer(2 * MAX_TESS_VERTICES, vboMode); pgl.unbindVertexBuffer(); glPointIndexBufferID = createVertexBufferObject(); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointIndexBufferID); - //gl2f.glBufferData(GL.GL_ARRAY_BUFFER, MAX_TESS_INDICES * PGraphicsOpenGL.SIZEOF_INT, null, vboMode); pgl.bindIndexBuffer(glPointIndexBufferID); pgl.initIndexBuffer(MAX_TESS_INDICES, vboMode); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); pgl.unbindIndexBuffer(); } @@ -1467,12 +1376,12 @@ public class PGraphicsOpenGL extends PGraphics { report("top beginDraw()"); if (!primarySurface) { - ogl.saveGLState(); + renderer.saveGLState(); // Disabling all lights, so the offscreen renderer can set completely // new light configuration (otherwise some light configuration from the // primary renderer might stay). - ogl.disableLights(); + renderer.disableLights(); } inGeo.reset(); @@ -1491,20 +1400,15 @@ public class PGraphicsOpenGL extends PGraphics { // this is necessary for 3D drawing if (hints[DISABLE_DEPTH_TEST]) { pgl.disableDepthTest(); - //gl.glDisable(GL.GL_DEPTH_TEST); } else { - //gl.glEnable(GL.GL_DEPTH_TEST); pgl.enableDepthTest(); } // use <= since that's what processing.core does - //gl.glDepthFunc(GL.GL_LEQUAL); pgl.setDepthFunc(PGL.LESS_OR_EQUAL); if (hints[DISABLE_DEPTH_MASK]) { - //gl.glDepthMask(false); pgl.disableDepthMask(); } else { - //gl.glDepthMask(true); pgl.enableDepthMask(); } @@ -1516,9 +1420,7 @@ public class PGraphicsOpenGL extends PGraphics { // setup opengl viewport. pgl.getViweport(savedViewport); - //gl.glGetIntegerv(GL.GL_VIEWPORT, savedViewport, 0); viewport[0] = 0; viewport[1] = 0; viewport[2] = width; viewport[3] = height; - //gl.glViewport(0, 0, width, height); pgl.setViewport(viewport); if (resized) { // To avoid having garbage in the screen after a resize, @@ -1527,8 +1429,8 @@ public class PGraphicsOpenGL extends PGraphics { if (texture != null) { // The screen texture should be deleted because it // corresponds to the old window size. - this.removeCache(ogl); - this.removeParams(ogl); + this.removeCache(renderer); + this.removeParams(renderer); texture = null; loadTexture(); } @@ -1562,7 +1464,6 @@ public class PGraphicsOpenGL extends PGraphics { // because y is flipped pgl.setFrontFace(PGL.CLOCKWISE); - //gl.glFrontFace(GL.GL_CW); setSurfaceParams(); @@ -1577,7 +1478,6 @@ public class PGraphicsOpenGL extends PGraphics { pushFramebuffer(); if (offscreenMultisample) { setFramebuffer(offscreenFramebufferMultisample); - //gl2x.glDrawBuffer(GL.GL_COLOR_ATTACHMENT0); pgl.setDrawBuffer(0); } else { setFramebuffer(offscreenFramebuffer); @@ -1587,8 +1487,6 @@ public class PGraphicsOpenGL extends PGraphics { // Clear depth and stencil buffers. pgl.setClearColor(0, 0, 0, 0); pgl.clearDepthAndStencilBuffers(); - //gl.glClearColor(0, 0, 0, 0); - //gl.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT); drawing = true; @@ -1614,7 +1512,6 @@ public class PGraphicsOpenGL extends PGraphics { } // Restoring previous viewport. - //gl.glViewport(savedViewport[0], savedViewport[1], savedViewport[2], savedViewport[3]); pgl.setViewport(savedViewport); if (primarySurface) { @@ -1622,7 +1519,6 @@ public class PGraphicsOpenGL extends PGraphics { // operation. Thus, only the main renderer (the primary surface) // should call it at the end of draw, and none of the offscreen // renderers... - //gl.glFlush(); pgl.flush(); if (drawable != null) { @@ -1635,7 +1531,7 @@ public class PGraphicsOpenGL extends PGraphics { } popFramebuffer(); - ogl.restoreGLState(); + renderer.restoreGLState(); } drawing = false; @@ -1673,7 +1569,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void restoreGLState() { // Restoring viewport. pgl.setViewport(viewport); - //gl.glViewport(0, 0, width, height); restoreGLMatrices(); @@ -1682,19 +1577,13 @@ public class PGraphicsOpenGL extends PGraphics { pgl.disableDepthTest(); pgl.setClearColor(0, 0, 0, 0); pgl.clearDepthBuffer(); -// gl.glDisable(GL.GL_DEPTH_TEST); -// gl.glClearColor(0, 0, 0, 0); -// gl.glClear(GL.GL_DEPTH_BUFFER_BIT); } else { - //gl.glEnable(GL.GL_DEPTH_TEST); pgl.enableDepthTest(); } if (hints[DISABLE_DEPTH_MASK]) { - //gl.glDepthMask(false); pgl.disableDepthMask(); } else { - //gl.glDepthMask(true); pgl.enableDepthMask(); } @@ -1776,10 +1665,8 @@ public class PGraphicsOpenGL extends PGraphics { // Some things the user might have changed from OpenGL, // but we want to make sure they return to the Processing // defaults (plus these cannot be changed through the API - // so they should remain constant anyways): - //gl.glFrontFace(GL.GL_CW); + // so they should remain constant anyways): pgl.setFrontFace(PGL.CLOCKWISE); - //gl.glDepthFunc(GL.GL_LEQUAL); pgl.setDepthFunc(PGL.LESS_OR_EQUAL); setSurfaceParams(); @@ -1857,23 +1744,17 @@ public class PGraphicsOpenGL extends PGraphics { pgl.disableDepthTest(); pgl.setClearColor(0, 0, 0, 0); pgl.clearDepthBuffer(); -// gl.glDisable(GL.GL_DEPTH_TEST); -// gl.glClearColor(0, 0, 0, 0); -// gl.glClear(GL.GL_DEPTH_BUFFER_BIT); } else if (which == ENABLE_DEPTH_TEST) { flush(); - //gl.glEnable(GL.GL_DEPTH_TEST); pgl.enableDepthTest(); } else if (which == DISABLE_DEPTH_MASK) { flush(); - //gl.glDepthMask(false); pgl.disableDepthMask(); } else if (which == ENABLE_DEPTH_MASK) { flush(); - //gl.glDepthMask(true); pgl.enableDepthMask(); } else if (which == DISABLE_ACCURATE_2D) { @@ -2213,11 +2094,9 @@ public class PGraphicsOpenGL extends PGraphics { protected void clipImpl(float x1, float y1, float x2, float y2) { flush(); -// gl.glEnable(GL.GL_SCISSOR_TEST); pgl.enableClipping(); float h = y2 - y1; -// gl.glScissor((int)x1, (int)(height - y1 - h), (int)(x2 - x1), (int)h); pgl.setClipRect((int)x1, (int)(height - y1 - h), (int)(x2 - x1), (int)h); clip = true; @@ -2227,9 +2106,7 @@ public class PGraphicsOpenGL extends PGraphics { public void noClip() { if (clip) { flush(); - //gl.glDisable(GL.GL_SCISSOR_TEST); - pgl.disableClipping(); - + pgl.disableClipping(); clip = false; } } @@ -2305,8 +2182,6 @@ public class PGraphicsOpenGL extends PGraphics { // The modelview transformation has been applied already to the // tessellated vertices, so we set the OpenGL modelview matrix as // the identity to avoid applying the model transformations twice. - //gl2f.glPushMatrix(); - //gl2f.glLoadIdentity(); pgl.pushMatrix(); pgl.loadIdentity(); } @@ -2324,7 +2199,6 @@ public class PGraphicsOpenGL extends PGraphics { } if (flushMode == FLUSH_WHEN_FULL && !hints[DISABLE_TRANSFORM_CACHE]) { - //gl2f.glPopMatrix(); pgl.popMatrix(); } } @@ -2345,29 +2219,17 @@ public class PGraphicsOpenGL extends PGraphics { pgl.enableVertexArrays(); pgl.enableColorArrays(); pgl.enableNormalArrays(); -// gl2f.glEnableClientState(GL2.GL_VERTEX_ARRAY); -// gl2f.glEnableClientState(GL2.GL_COLOR_ARRAY); -// gl2f.glEnableClientState(GL2.GL_NORMAL_ARRAY); int size = tessGeo.pointVertexCount; -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointVertexBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.pointVertices, 0, 3 * size), vboMode); -// gl2f.glVertexPointer(3, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glPointVertexBufferID); pgl.copyVertexBufferData(tessGeo.pointVertices, 3 * size, vboMode); pgl.setVertexFormat(3, 0, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointColorBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.pointColors, 0, 4 * size), vboMode); -// gl2f.glColorPointer(4, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glPointColorBufferID); pgl.copyVertexBufferData(tessGeo.pointColors, 4 * size, vboMode); pgl.setColorFormat(4, 0, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glPointNormalBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.pointNormals, 0, 3 * size), vboMode); -// gl2f.glNormalPointer(GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glPointNormalBufferID); pgl.copyVertexBufferData(tessGeo.pointNormals, 3 * size, vboMode); pgl.setNormalFormat(3, 0, 0); @@ -2375,21 +2237,13 @@ public class PGraphicsOpenGL extends PGraphics { setupPointShader(glPointAttribBufferID, tessGeo.pointAttributes, size); size = tessGeo.pointIndexCount; -// gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, glPointIndexBufferID); -// gl2f.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, size * PGraphicsOpenGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.pointIndices, 0, size), vboMode); -// gl2f.glDrawElements(GL.GL_TRIANGLES, size, GL.GL_UNSIGNED_INT, 0); pgl.bindIndexBuffer(glPointIndexBufferID); pgl.copyIndexBufferData(tessGeo.pointIndices, size, vboMode); pgl.renderIndexBuffer(size); pgl.unbindIndexBuffer(); pgl.unbindVertexBuffer(); - //gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); -// gl2f.glDisableClientState(GL2.GL_VERTEX_ARRAY); -// gl2f.glDisableClientState(GL2.GL_COLOR_ARRAY); -// gl2f.glDisableClientState(GL2.GL_NORMAL_ARRAY); pgl.disableVertexArrays(); pgl.disableColorArrays(); pgl.disableNormalArrays(); @@ -2405,32 +2259,20 @@ public class PGraphicsOpenGL extends PGraphics { startLineShader(); -// gl2f.glEnableClientState(GL2.GL_VERTEX_ARRAY); -// gl2f.glEnableClientState(GL2.GL_COLOR_ARRAY); -// gl2f.glEnableClientState(GL2.GL_NORMAL_ARRAY); pgl.enableVertexArrays(); pgl.enableColorArrays(); pgl.enableNormalArrays(); int size = tessGeo.lineVertexCount; -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineVertexBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.lineVertices, 0, 3 * size), vboMode); -// gl2f.glVertexPointer(3, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glLineVertexBufferID); pgl.copyVertexBufferData(tessGeo.lineVertices, 3 * size, vboMode); pgl.setVertexFormat(3, 0, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineColorBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.lineColors, 0, 4 * size), vboMode); -// gl2f.glColorPointer(4, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glLineColorBufferID); pgl.copyVertexBufferData(tessGeo.lineColors, 4 * size, vboMode); pgl.setColorFormat(4, 0, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glLineNormalBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.lineNormals, 0, 3 * size), vboMode); -// gl2f.glNormalPointer(GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glLineNormalBufferID); pgl.copyVertexBufferData(tessGeo.lineNormals, 3 * size, vboMode); pgl.setNormalFormat(3, 0, 0); @@ -2438,22 +2280,13 @@ public class PGraphicsOpenGL extends PGraphics { setupLineShader(glLineAttribBufferID, tessGeo.lineAttributes, size); size = tessGeo.lineIndexCount; -// gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, glLineIndexBufferID); -// gl2f.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, size * PGraphicsOpenGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.lineIndices, 0, size), vboMode); -// gl2f.glDrawElements(GL.GL_TRIANGLES, size, GL.GL_UNSIGNED_INT, 0); pgl.bindIndexBuffer(glLineIndexBufferID); pgl.copyIndexBufferData(tessGeo.lineIndices, size, vboMode); pgl.renderIndexBuffer(size); - - -// gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); + pgl.unbindIndexBuffer(); pgl.unbindVertexBuffer(); -// gl2f.glDisableClientState(GL2.GL_VERTEX_ARRAY); -// gl2f.glDisableClientState(GL2.GL_COLOR_ARRAY); -// gl2f.glDisableClientState(GL2.GL_NORMAL_ARRAY); pgl.disableVertexArrays(); pgl.disableColorArrays(); pgl.disableNormalArrays(); @@ -2468,47 +2301,30 @@ public class PGraphicsOpenGL extends PGraphics { fillVBOsCreated = true; } -// gl2f.glEnableClientState(GL2.GL_VERTEX_ARRAY); -// gl2f.glEnableClientState(GL2.GL_COLOR_ARRAY); -// gl2f.glEnableClientState(GL2.GL_NORMAL_ARRAY); pgl.enableVertexArrays(); pgl.enableColorArrays(); pgl.enableNormalArrays(); int size = tessGeo.fillVertexCount; -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillVertexBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.fillVertices, 0, 3 * size), vboMode); -// gl2f.glVertexPointer(3, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glFillVertexBufferID); pgl.copyVertexBufferData(tessGeo.fillVertices, 3 * size, vboMode); pgl.setVertexFormat(3, 0, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillColorBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.fillColors, 0, 4 * size), vboMode); -// gl2f.glColorPointer(4, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glFillColorBufferID); pgl.copyVertexBufferData(tessGeo.fillColors, 4 * size, vboMode); pgl.setColorFormat(4, 0, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillNormalBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.fillNormals, 0, 3 * size), vboMode); -// gl2f.glNormalPointer(GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(glFillNormalBufferID); pgl.copyVertexBufferData(tessGeo.fillNormals, 3 * size, vboMode); pgl.setNormalFormat(3, 0, 0); if (texCache.hasTexture) { -// gl2f.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 2 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.fillTexcoords, 0, 2 * size), vboMode); -// gl2f.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0); pgl.enableTexCoordArrays(); pgl.bindVertexBuffer(glFillTexCoordBufferID); pgl.copyVertexBufferData(tessGeo.fillTexcoords, 2 * size, vboMode); pgl.setTexCoordFormat(2, 0, 0); } - - //gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, glFillIndexBufferID); + pgl.bindIndexBuffer(glFillIndexBufferID); pgl.setActiveTexUnit(0); @@ -2519,19 +2335,13 @@ public class PGraphicsOpenGL extends PGraphics { PTexture tex = null; if (img != null) { - tex = ogl.getTexture(img); - if (tex != null) { -// gl2f.glEnable(tex.glTarget); -// gl2f.glActiveTexture(GL.GL_TEXTURE0); -// gl2f.glBindTexture(tex.glTarget, tex.glID); + tex = renderer.getTexture(img); + if (tex != null) { tex.bind(); -// pgl.enableTexturing(tex.glTarget); -// pgl.bindTexture(tex.glTarget, tex.glID); tex0 = tex; } } if (tex == null && tex0 != null) { - //gl2f.glDisable(tex0.glTarget); tex0.unbind(); pgl.disableTexturing(tex0.glTarget); } @@ -2540,64 +2350,37 @@ public class PGraphicsOpenGL extends PGraphics { size = texCache.lastIndex[i] - texCache.firstIndex[i] + 1; pgl.copyIndexBufferData(tessGeo.fillIndices, offset, size, vboMode); pgl.renderIndexBuffer(size); - //gl2f.glBufferData(GL.GL_ELEMENT_ARRAY_BUFFER, size * PGraphicsOpenGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.fillIndices, offset, size), vboMode); - //gl2f.glDrawElements(GL.GL_TRIANGLES, size, GL.GL_UNSIGNED_INT, 0); } if (texCache.hasTexture) { - //tex0 = null; - // Unbinding all the textures in the cache. for (int i = 0; i < texCache.count; i++) { PImage img = texCache.textures[i]; if (img != null) { - PTexture tex = ogl.getTexture(img); + PTexture tex = renderer.getTexture(img); if (tex != null) { tex.unbind(); } - - //if (tex0 != tex) { - //gl2f.glDisable(tex.glTarget); - //pgl.disableTexturing(tex.glTarget); - //tex0 = tex; - - //} } } -// if (tex0 != null) { -// gl2f.glActiveTexture(GL.GL_TEXTURE0); -// gl2f.glBindTexture(tex0.glTarget, 0); -// } // Disabling texturing for each of the targets used // by textures in the cache. for (int i = 0; i < texCache.count; i++) { PImage img = texCache.textures[i]; if (img != null) { - PTexture tex = ogl.getTexture(img); + PTexture tex = renderer.getTexture(img); if (tex != null) { pgl.disableTexturing(tex.glTarget); } - //if (tex0 != tex) { - //gl2f.glDisable(tex.glTarget); - //pgl.disableTexturing(tex.glTarget); - //tex0 = tex; - - //} } } - //gl2f.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY); pgl.disableTexCoordArrays(); } -// gl2f.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); pgl.unbindIndexBuffer(); pgl.unbindVertexBuffer(); -// gl2f.glDisableClientState(GL2.GL_VERTEX_ARRAY); -// gl2f.glDisableClientState(GL2.GL_COLOR_ARRAY); -// gl2f.glDisableClientState(GL2.GL_NORMAL_ARRAY); pgl.disableVertexArrays(); pgl.disableColorArrays(); pgl.disableNormalArrays(); @@ -2660,8 +2443,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void setupLineShader(int attrBufID, float[] attribs, int nvert) { - //int[] viewport = {0, 0, 0, 0}; - //gl2f.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); lineShader.setVecUniform("viewport", viewport[0], viewport[1], viewport[2], viewport[3]); lineShader.setIntUniform("lights", lightCount); @@ -2670,10 +2451,6 @@ public class PGraphicsOpenGL extends PGraphics { lineAttribsLoc = lineShader.getAttribLocation("attribs"); -// gl2x.glEnableVertexAttribArray(lineAttribsLoc); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, attrBufID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 4 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(attribs, 0, 4 * nvert), vboMode); -// gl2x.glVertexAttribPointer(lineAttribsLoc, 4, GL.GL_FLOAT, false, 0, 0); pgl.enableAttribsArray(lineAttribsLoc); pgl.bindVertexBuffer(attrBufID); pgl.copyVertexBufferData(attribs, 4 * nvert, vboMode); @@ -2682,8 +2459,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void setupLineShader(int attrBufID) { - //int[] viewport = {0, 0, 0, 0}; - //gl2f.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); lineShader.setVecUniform("viewport", viewport[0], viewport[1], viewport[2], viewport[3]); lineShader.setIntUniform("lights", lightCount); @@ -2691,9 +2466,7 @@ public class PGraphicsOpenGL extends PGraphics { lineShader.setVecUniform("eye", cameraEyeX, cameraEyeY, cameraEyeZ, 0); lineAttribsLoc = lineShader.getAttribLocation("attribs"); - //gl2x.glEnableVertexAttribArray(lineAttribsID); - //gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, attrBufID); - //gl2x.glVertexAttribPointer(lineAttribsID, 4, GL.GL_FLOAT, false, 0, 0); + pgl.enableAttribsArray(lineAttribsLoc); pgl.bindVertexBuffer(attrBufID); pgl.setAttribsFormat(lineAttribsLoc, 4, 0, 0); @@ -2701,7 +2474,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void stopLineShader() { - //gl2x.glDisableVertexAttribArray(lineAttribsLoc); pgl.disableAttribsArray(lineAttribsLoc); lineShader.stop(); } @@ -2725,10 +2497,7 @@ public class PGraphicsOpenGL extends PGraphics { pointShader.setVecUniform("eye", cameraEyeX, cameraEyeY, cameraEyeZ, 0); pointAttribsLoc = PGraphicsOpenGL.pointShader.getAttribLocation("vertDisp"); -// gl2x.glEnableVertexAttribArray(pointAttribsID); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, attrBufID); -// gl2f.glBufferData(GL.GL_ARRAY_BUFFER, 2 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(attribs, 0, 2 * nvert), vboMode); -// ogl.gl2x.glVertexAttribPointer(pointAttribsID, 2, GL.GL_FLOAT, false, 0, 0); + pgl.enableAttribsArray(pointAttribsLoc); pgl.bindVertexBuffer(attrBufID); pgl.copyVertexBufferData(attribs, 2 * nvert, vboMode); @@ -2742,9 +2511,7 @@ public class PGraphicsOpenGL extends PGraphics { pointShader.setVecUniform("eye", cameraEyeX, cameraEyeY, cameraEyeZ, 0); pointAttribsLoc = PGraphicsOpenGL.pointShader.getAttribLocation("vertDisp"); -// gl2x.glEnableVertexAttribArray(pointAttribsID); -// gl2f.glBindBuffer(GL.GL_ARRAY_BUFFER, attrBufID); -// ogl.gl2x.glVertexAttribPointer(pointAttribsID, 2, GL.GL_FLOAT, false, 0, 0); + pgl.enableAttribsArray(pointAttribsLoc); pgl.bindVertexBuffer(attrBufID); pgl.setAttribsFormat(pointAttribsLoc, 2, 0, 0); @@ -2752,7 +2519,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void stopPointShader() { - //gl2x.glDisableVertexAttribArray(pointAttribsID); pgl.disableAttribsArray(pointAttribsLoc); pointShader.stop(); } @@ -2819,11 +2585,11 @@ public class PGraphicsOpenGL extends PGraphics { } // setup matrix for forward differencing to speed up drawing - ogl.splineForward(detail, bezierDrawMatrix); + renderer.splineForward(detail, bezierDrawMatrix); // multiply the basis and forward diff matrices together // saves much time since this needn't be done for each curve - bezierDrawMatrix.apply(ogl.bezierBasisMatrix); + bezierDrawMatrix.apply(renderer.bezierBasisMatrix); } public void bezierVertex(float x2, float y2, @@ -2990,10 +2756,10 @@ public class PGraphicsOpenGL extends PGraphics { (s-1)/2f, 0, (1-s)/2f, 0, 0, 1, 0, 0); - ogl.splineForward(curveDetail, curveDrawMatrix); + renderer.splineForward(curveDetail, curveDrawMatrix); if (bezierBasisInverse == null) { - bezierBasisInverse = ogl.bezierBasisMatrix.get(); + bezierBasisInverse = renderer.bezierBasisMatrix.get(); bezierBasisInverse.invert(); curveToBezierMatrix = new PMatrix3D(); } @@ -3306,10 +3072,6 @@ public class PGraphicsOpenGL extends PGraphics { pgl.enablePointSmooth(); pgl.enableLineSmooth(); pgl.enablePolygonSmooth(); -// gl2f.glEnable(GL2.GL_MULTISAMPLE); -// gl2f.glEnable(GL2.GL_POINT_SMOOTH); -// gl2f.glEnable(GL2.GL_LINE_SMOOTH); -// gl2f.glEnable(GL2.GL_POLYGON_SMOOTH); } } @@ -3327,10 +3089,6 @@ public class PGraphicsOpenGL extends PGraphics { } } -// gl2f.glDisable(GL2.GL_MULTISAMPLE); -// gl2f.glDisable(GL2.GL_POINT_SMOOTH); -// gl2f.glDisable(GL.GL_LINE_SMOOTH); -// gl2f.glDisable(GL2.GL_POLYGON_SMOOTH); pgl.disableMultisample(); pgl.disablePointSmooth(); pgl.disableLineSmooth(); @@ -3404,7 +3162,7 @@ public class PGraphicsOpenGL extends PGraphics { * Implementation of actual drawing for a line of text. */ protected void textLineImpl(char buffer[], int start, int stop, float x, float y) { - textTex = (PFontTexture)textFont.getCache(ogl); + textTex = (PFontTexture)textFont.getCache(renderer); if (textTex == null) { textTex = new PFontTexture(parent, textFont, maxTextureSize, maxTextureSize); textFont.setCache(this, textTex); @@ -3519,7 +3277,6 @@ public class PGraphicsOpenGL extends PGraphics { public void pushMatrix() { - //gl2f.glPushMatrix(); pgl.pushMatrix(); modelviewStack.push(new PMatrix3D(modelview)); } @@ -3529,7 +3286,6 @@ public class PGraphicsOpenGL extends PGraphics { if (hints[DISABLE_TRANSFORM_CACHE]) { flush(); } - //gl2f.glPopMatrix(); pgl.popMatrix(); PMatrix3D mat = modelviewStack.pop(); modelview.set(mat); @@ -3551,7 +3307,6 @@ public class PGraphicsOpenGL extends PGraphics { flush(); } - //gl2f.glTranslatef(tx, ty, tz); pgl.translate(tx, ty, tz); modelview.translate(tx, ty, tz); } @@ -3592,7 +3347,6 @@ public class PGraphicsOpenGL extends PGraphics { flush(); } - //gl2f.glRotatef(PApplet.degrees(angle), v0, v1, v2); pgl.rotate(angle, v0, v1, v2); modelview.rotate(angle, v0, v1, v2); } @@ -3622,7 +3376,6 @@ public class PGraphicsOpenGL extends PGraphics { flush(); } - //gl2f.glScalef(sx, sy, sz); pgl.scale(sx, sy, sz); modelview.scale(sx, sy, sz); } @@ -3652,7 +3405,6 @@ public class PGraphicsOpenGL extends PGraphics { public void resetMatrix() { - //gl2f.glLoadIdentity(); pgl.loadIdentity(); modelview.reset(); } @@ -3698,7 +3450,6 @@ public class PGraphicsOpenGL extends PGraphics { glMatrix[ 2] = n20; glMatrix[ 6] = n21; glMatrix[10] = n22; glMatrix[14] = n23; glMatrix[ 3] = n30; glMatrix[ 7] = n31; glMatrix[11] = n32; glMatrix[15] = n33; - //gl2f.glMultMatrixf(glMatrix, 0); pgl.multMatrix(glMatrix); modelview.apply(n00, n01, n02, n03, @@ -3710,22 +3461,18 @@ public class PGraphicsOpenGL extends PGraphics { protected void loadProjection() { pgl.setProjectionMode(); - //gl2f.glMatrixMode(GL2.GL_PROJECTION); loadMatrix(projection); - //gl2f.glMatrixMode(GL2.GL_MODELVIEW); pgl.setModelviewMode(); } protected void loadCamera() { - //gl2f.glMatrixMode(GL2.GL_MODELVIEW); pgl.setModelviewMode(); loadMatrix(camera); } protected void loadModelview() { - //gl2f.glMatrixMode(GL2.GL_MODELVIEW); pgl.setModelviewMode(); loadMatrix(modelview); } @@ -3737,7 +3484,6 @@ public class PGraphicsOpenGL extends PGraphics { glMatrix[ 2] = pMatrix.m20; glMatrix[ 6] = pMatrix.m21; glMatrix[10] = pMatrix.m22; glMatrix[14] = pMatrix.m23; glMatrix[ 3] = pMatrix.m30; glMatrix[ 7] = pMatrix.m31; glMatrix[11] = pMatrix.m32; glMatrix[15] = pMatrix.m33; - //gl2f.glLoadMatrixf(glMatrix, 0); pgl.loadMatrix(glMatrix); } @@ -3790,22 +3536,16 @@ public class PGraphicsOpenGL extends PGraphics { public void pushProjection() { pgl.setProjectionMode(); pgl.pushMatrix(); - //gl2f.glMatrixMode(GL2.GL_PROJECTION); - //gl2f.glPushMatrix(); projectionStack.push(new PMatrix3D(projection)); - //gl2f.glMatrixMode(GL2.GL_MODELVIEW); pgl.setModelviewMode(); } public void popProjection() { - //gl2f.glMatrixMode(GL2.GL_PROJECTION); pgl.setProjectionMode(); pgl.popMatrix(); - //gl2f.glPopMatrix(); PMatrix3D mat = projectionStack.pop(); projection.set(mat); - //gl2f.glMatrixMode(GL2.GL_MODELVIEW); pgl.setModelviewMode(); } @@ -4407,12 +4147,10 @@ public class PGraphicsOpenGL extends PGraphics { protected void setFillColor() { pgl.setColor(fillR, fillG, fillB, fillA); - //gl2f.glColor4f(fillR, fillG, fillB, fillA); } protected void setTintColor() { pgl.setColor(tintR, tintG, tintB, tintA); - //gl2f.glColor4f(tintR, tintG, tintB, tintA); } ////////////////////////////////////////////////////////////// @@ -4443,8 +4181,6 @@ public class PGraphicsOpenGL extends PGraphics { // OPENGL uses GL_COLOR_MATERIAL mode, so the ambient and diffuse components // for all vertices are taken from the glColor/color buffer settings. - //gl2f.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, colorFloats, 0); - pgl.setMaterialAmbient(colorFloats); } @@ -4469,14 +4205,12 @@ public class PGraphicsOpenGL extends PGraphics { protected void specularFromCalc() { super.specularFromCalc(); - calcColorBuffer(); - //gl2f.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, colorFloats, 0); + calcColorBuffer(); pgl.setMaterialSpecular(colorFloats); } public void shininess(float shine) { - super.shininess(shine); - //gl2f.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, shine); + super.shininess(shine); pgl.setMaterialShininess(shine); } @@ -4501,7 +4235,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void emissiveFromCalc() { super.emissiveFromCalc(); calcColorBuffer(); - //gl2f.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_EMISSION, colorFloats, 0); pgl.setMaterialEmission(colorFloats); } @@ -4835,7 +4568,6 @@ public class PGraphicsOpenGL extends PGraphics { flush(); lights = true; - //gl2f.glEnable(GL2.GL_LIGHTING); pgl.enableLighting(); } } @@ -4846,57 +4578,45 @@ public class PGraphicsOpenGL extends PGraphics { flush(); lights = false; - //gl2f.glDisable(GL2.GL_LIGHTING); pgl.disableLighting(); } } - protected void lightAmbient(int num) { - //gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_AMBIENT, lightDiffuse[num], 0); + protected void lightAmbient(int num) { pgl.setAmbientLight(num, lightDiffuse[num]); } protected void lightNoAmbient(int num) { - //gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_AMBIENT, zeroLight, 0); pgl.setAmbientLight(num, zeroLight); } protected void lightNoSpot(int num) { pgl.setSpotLightCutoff(num, 180); pgl.setSpotLightExponent(num, 0); -// gl2f.glLightf(GL2.GL_LIGHT0 + num, GL2.GL_SPOT_CUTOFF, 180); -// gl2f.glLightf(GL2.GL_LIGHT0 + num, GL2.GL_SPOT_EXPONENT, 0); } protected void lightDiffuse(int num) { pgl.setDiffuseLight(num, lightDiffuse[num]); -// gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_DIFFUSE, lightDiffuse[num], 0); } protected void lightNoDiffuse(int num) { - //gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_DIFFUSE, zeroLight, 0); pgl.setDiffuseLight(num, zeroLight); } protected void lightDirection(int num) { if (lightType[num] == DIRECTIONAL) { -// gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_POSITION, lightNormal[num], 0); - pgl.setLightDirection(num, lightNormal[num]); - + pgl.setLightDirection(num, lightNormal[num]); } else { // spotlight pgl.setSpotLightDirection(num, lightNormal[num]); - //gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_SPOT_DIRECTION, lightNormal[num], 0); } } protected void lightEnable(int num) { -// gl2f.glEnable(GL2.GL_LIGHT0 + num); pgl.enableLight(num); } protected void lightDisable(int num) { - //gl2f.glDisable(GL2.GL_LIGHT0 + num); pgl.disableLight(num); } @@ -4904,36 +4624,26 @@ public class PGraphicsOpenGL extends PGraphics { pgl.setLightConstantAttenuation(num, lightFalloffConstant[num]); pgl.setLightLinearAttenuation(num, lightFalloffLinear[num]); pgl.setLightQuadraticAttenuation(num, lightFalloffQuadratic[num]); - -// gl2f.glLightf(GL2.GL_LIGHT0 + num, GL2.GL_CONSTANT_ATTENUATION, lightFalloffConstant[num]); -// gl2f.glLightf(GL2.GL_LIGHT0 + num, GL2.GL_LINEAR_ATTENUATION, lightFalloffLinear[num]); -// gl2f.glLightf(GL2.GL_LIGHT0 + num, GL2.GL_QUADRATIC_ATTENUATION, lightFalloffQuadratic[num]); } protected void lightPosition(int num) { pgl.setLightPosition(num, lightPosition[num]); -// gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_POSITION, lightPosition[num], 0); } protected void lightSpecular(int num) { pgl.setSpecularLight(num, lightSpecular[num]); -// gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_SPECULAR, lightSpecular[num], 0); } protected void lightNoSpecular(int num) { -// gl2f.glLightfv(GL2.GL_LIGHT0 + num, GL2.GL_SPECULAR, zeroLight, 0); pgl.setSpecularLight(num, zeroLight); } protected void lightSpotAngle(int num) { pgl.setSpotLightCutoff(num, lightSpotAngle[num]); - //gl2f.glLightf(GL2.GL_LIGHT0 + num, GL2.GL_SPOT_CUTOFF, lightSpotAngle[num]); - } protected void lightSpotConcentration(int num) { pgl.setSpotLightExponent(num, lightSpotConcentration[num]); - //gl2f.glLightf(GL2.GL_LIGHT0 + num, GL2.GL_SPOT_EXPONENT, lightSpotConcentration[num]); } ////////////////////////////////////////////////////////////// @@ -4951,11 +4661,7 @@ public class PGraphicsOpenGL extends PGraphics { pgl.setClearColor(0, 0, 0, 0); pgl.clearDepthBuffer(); - //gl.glClearColor(0, 0, 0, 0); - //gl.glClear(GL.GL_DEPTH_BUFFER_BIT); - //gl.glClearColor(backgroundR, backgroundG, backgroundB, 1); - //gl.glClear(GL.GL_COLOR_BUFFER_BIT); pgl.setClearColor(backgroundR, backgroundG, backgroundB, 1); pgl.clearColorBuffer(); } @@ -5025,7 +4731,6 @@ public class PGraphicsOpenGL extends PGraphics { */ public void report(String where) { if (!hints[DISABLE_OPENGL_ERROR_REPORT]) { - //int err = gl.glGetError(); int err = pgl.getError(); if (err != 0) { //String errString = glu.gluErrorString(err); @@ -5096,10 +4801,8 @@ public class PGraphicsOpenGL extends PGraphics { pixelBuffer.rewind(); if (primarySurface) { pgl.setReadBuffer(PGL.FRONT); -// gl2x.glReadBuffer(GL.GL_FRONT); } - pgl.readPixels(pixelBuffer, 0, 0, width, height); -// gl.glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer); + pgl.readPixels(pixelBuffer, 0, 0, width, height); if (notCurrent) { popFramebuffer(); @@ -5442,8 +5145,8 @@ public class PGraphicsOpenGL extends PGraphics { PTexture.Parameters params = PTexture.newParameters(ARGB, sampling); texture = new PTexture(parent, width, height, params); texture.setFlippedY(true); - this.setCache(ogl, texture); - this.setParams(ogl, params); + this.setCache(renderer, texture); + this.setParams(renderer, params); texCrop = new int[4]; texCrop[0] = 0; @@ -5490,7 +5193,6 @@ public class PGraphicsOpenGL extends PGraphics { protected void copyFrameToTexture() { // Make sure that the execution off all the openGL commands is // finished before loading the texture. - //gl.glFinish(); pgl.finish(); loadTexture(); } @@ -5539,10 +5241,8 @@ public class PGraphicsOpenGL extends PGraphics { getsetBuffer.rewind(); if (primarySurface) { -// gl2x.glReadBuffer(GL.GL_FRONT); pgl.setReadBuffer(PGL.FRONT); } - //gl.glReadPixels(x, height - y - 1, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getsetBuffer); pgl.readPixels(getsetBuffer, x, height - y - 1, 1, 1); if (notCurrent) { @@ -5581,10 +5281,8 @@ public class PGraphicsOpenGL extends PGraphics { newbieBuffer.rewind(); if (primarySurface) { -// gl2x.glReadBuffer(GL.GL_FRONT); pgl.setReadBuffer(PGL.FRONT); } -// gl.glReadPixels(x, height - y - h, w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, newbieBuffer); pgl.readPixels(newbieBuffer, x, height - y - h, w, h); if (notCurrent) { @@ -5791,43 +5489,31 @@ public class PGraphicsOpenGL extends PGraphics { flush(); blendMode = mode; -// gl.glEnable(GL.GL_BLEND); pgl.enableBlend(); - if (mode == REPLACE) { // This is equivalent to disable blending. if (blendEqSupported) { pgl.setBlendEquation(PGL.BLEND_EQ_ADD); - //gl.glBlendEquation(GL.GL_FUNC_ADD); } - //gl.glBlendFunc(GL.GL_ONE, GL.GL_ZERO); pgl.setReplaceBlend(); } else if (mode == BLEND) { if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_ADD); pgl.setBlendEquation(PGL.BLEND_EQ_ADD); } - //gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); pgl.setDefaultBlend(); } else if (mode == ADD) { if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_ADD); pgl.setBlendEquation(PGL.BLEND_EQ_ADD); } - //gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); pgl.setAdditiveBlend(); } else if (mode == SUBTRACT) { if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_ADD); pgl.setBlendEquation(PGL.BLEND_EQ_ADD); } - //gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ZERO); pgl.setSubstractiveBlend(); } else if (mode == LIGHTEST) { if (blendEqSupported) { - //gl.glBlendEquation(GL2.GL_MAX); - //gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_DST_ALPHA); pgl.setBlendEquation(PGL.BLEND_EQ_MAX); pgl.setLightestBlend(); } else { @@ -5835,8 +5521,6 @@ public class PGraphicsOpenGL extends PGraphics { } } else if (mode == DARKEST) { if (blendEqSupported) { - //gl.glBlendEquation(GL2.GL_MIN); - //gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_DST_ALPHA); pgl.setBlendEquation(PGL.BLEND_EQ_MIN); pgl.setDarkestBlend(); } else { @@ -5844,8 +5528,6 @@ public class PGraphicsOpenGL extends PGraphics { } } else if (mode == DIFFERENCE) { if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_REVERSE_SUBTRACT); - //gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE); pgl.setBlendEquation(PGL.BLEND_EQ_REVERSE_SUBTRACT); pgl.setDifferenceBlend(); @@ -5854,24 +5536,18 @@ public class PGraphicsOpenGL extends PGraphics { } } else if (mode == EXCLUSION) { if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_ADD); pgl.setBlendEquation(PGL.BLEND_EQ_ADD); } - //gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE_MINUS_SRC_COLOR); pgl.setExclussionBlend(); } else if (mode == MULTIPLY) { if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_ADD); pgl.setBlendEquation(PGL.BLEND_EQ_ADD); } - //gl.glBlendFunc(GL.GL_DST_COLOR, GL.GL_SRC_COLOR); pgl.setMultiplyBlend(); } else if (mode == SCREEN) { if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_ADD); pgl.setBlendEquation(PGL.BLEND_EQ_ADD); } -// gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE); pgl.setScreenBlend(); } // HARD_LIGHT, SOFT_LIGHT, OVERLAY, DODGE, BURN modes cannot be implemented @@ -5882,13 +5558,10 @@ public class PGraphicsOpenGL extends PGraphics { protected void setDefaultBlend() { blendMode = BLEND; - //gl.glEnable(GL.GL_BLEND); pgl.enableBlend(); if (blendEqSupported) { - //gl.glBlendEquation(GL.GL_FUNC_ADD); pgl.setBlendEquation(PGL.BLEND_EQ_ADD); } - //gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); pgl.setDefaultBlend(); } @@ -5940,7 +5613,7 @@ public class PGraphicsOpenGL extends PGraphics { * @param img the image to have a texture metadata associated to it */ public PTexture getTexture(PImage img) { - PTexture tex = (PTexture)img.getCache(ogl); + PTexture tex = (PTexture)img.getCache(renderer); if (tex == null) { tex = addTexture(img); } else { @@ -5973,15 +5646,15 @@ public class PGraphicsOpenGL extends PGraphics { * @param img the image to have a texture metadata associated to it */ protected PTexture addTexture(PImage img) { - PTexture.Parameters params = (PTexture.Parameters)img.getParams(ogl); + PTexture.Parameters params = (PTexture.Parameters)img.getParams(renderer); if (params == null) { params = PTexture.newParameters(); - img.setParams(ogl, params); + img.setParams(renderer, params); } PTexture tex = new PTexture(img.parent, img.width, img.height, params); img.loadPixels(); if (img.pixels != null) tex.set(img.pixels); - img.setCache(ogl, tex); + img.setCache(renderer, tex); return tex; } @@ -5993,7 +5666,7 @@ public class PGraphicsOpenGL extends PGraphics { img.width = tex.width; img.height = tex.height; img.format = ARGB; - img.setCache(ogl, tex); + img.setCache(renderer, tex); return img; } @@ -6031,28 +5704,21 @@ public class PGraphicsOpenGL extends PGraphics { /** Utility function to render texture without blend. */ protected void drawTexture(int target, int id, int tw, int th, int[] crop, int x, int y, int w, int h) { -// gl.glEnable(target); -// gl.glBindTexture(target, id); pgl.enableTexturing(target); pgl.bindTexture(target, id); int savedBlendMode = blendMode; blendMode(REPLACE); - // The texels of the texture replace the color of wherever is on the screen. -// gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); + // The texels of the texture replace the color of wherever is on the screen. pgl.setTexEnvironmentMode(PGL.REPLACE); - drawTexture(tw, th, crop, x, y, w, h); // Returning to the default texture environment mode, GL_MODULATE. This allows tinting a texture - // with the current fragment color. -// gl2f.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); + // with the current fragment color. pgl.setTexEnvironmentMode(PGL.MODULATE); -// gl.glBindTexture(target, 0); -// gl.glDisable(target); pgl.unbindTexture(target); pgl.disableTexturing(target); @@ -6104,41 +5770,6 @@ public class PGraphicsOpenGL extends PGraphics { if (hintEnabled(ENABLE_DEPTH_MASK)) { pgl.enableDepthMask(); } - - -// gl.glDepthMask(false); -// -// gl2f.glMatrixMode(GL2.GL_PROJECTION); -// gl2f.glPushMatrix(); -// gl2f.glLoadIdentity(); -// -// gl2f.glOrthof(0, width, 0, height, -1, 1); -// -// gl2f.glMatrixMode(GL2.GL_MODELVIEW); -// gl2f.glPushMatrix(); -// gl2f.glLoadIdentity(); -// -// gl2f.glTranslatef(x, y, 0); -// gl2f.glScalef(w, h, 1); -// // Rendering the quad with the appropriate texture coordinates needed for the -// // specified crop region -// float s0 = (float)crop[0] / tw; -// float s1 = (float)(crop[0] + crop[2]) / tw; -// float t0 = (float)crop[1] / th; -// float t1 = (float)(crop[1] + crop[3]) / th; -// drawTexQuad(s0, t0, s1, t1); -// -// // Restoring matrices. -// gl2f.glMatrixMode(GL2.GL_PROJECTION); -// gl2f.glPopMatrix(); -// gl2f.glMatrixMode(GL2.GL_MODELVIEW); -// gl2f.glPopMatrix(); -// -// if (hintEnabled(ENABLE_DEPTH_MASK)) { -// gl.glDepthMask(true); -// } else { -// gl.glDepthMask(false); -// } } @@ -6167,20 +5798,12 @@ public class PGraphicsOpenGL extends PGraphics { * Utility function to copy buffer to texture. */ protected void copyToTexture(PTexture tex, IntBuffer buffer, int x, int y, int w, int h) { - buffer.rewind(); - + buffer.rewind(); pgl.enableTexturing(tex.glTarget); pgl.bindTexture(tex.glTarget, tex.glID); pgl.copyTexSubImage(buffer, tex.glTarget, x, y, w, h); pgl.bindTexture(tex.glTarget, 0); pgl.disableTexturing(tex.glTarget); - - -// gl.glEnable(tex.glTarget); -// gl.glBindTexture(tex.glTarget, tex.glID); -// gl.glTexSubImage2D(tex.glTarget, 0, x, y, w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer); -// gl.glBindTexture(tex.glTarget, 0); -// gl.glDisable(tex.glTarget); } ////////////////////////////////////////////////////////////// @@ -6190,13 +5813,11 @@ public class PGraphicsOpenGL extends PGraphics { protected void setSurfaceParams() { // The default shade model is GL_SMOOTH, but we set // here just in case... - //gl2f.glShadeModel(GL2.GL_SMOOTH); pgl.setShadeModel(PGL.SMOOTH); // The ambient and diffuse components for each vertex are taken // from the glColor/color buffer setting: -// gl2f.glEnable(GL2.GL_COLOR_MATERIAL); pgl.enableColorMaterial(); // For a quick overview of how the lighting model works in OpenGL @@ -6206,16 +5827,12 @@ public class PGraphicsOpenGL extends PGraphics { // Some normal related settings: pgl.enableNormalization(); pgl.enableRescaleNormals(); -// gl2f.glEnable(GL2.GL_NORMALIZE); -// gl2f.glEnable(GL2.GL_RESCALE_NORMAL); // Light model defaults: // The default opengl ambient light is (0.2, 0.2, 0.2), so // here we set our own default value. pgl.setTwoSidedLightModel(); pgl.setDefaultAmbientLight(baseLight); -// gl2f.glLightModelf(GL2.GL_LIGHT_MODEL_TWO_SIDE, 0); -// gl2f.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, baseLight, 0); } protected void saveGLMatrices() { @@ -6223,10 +5840,6 @@ public class PGraphicsOpenGL extends PGraphics { pgl.pushMatrix(); pgl.setModelviewMode(); pgl.pushMatrix(); -// gl2f.glMatrixMode(GL2.GL_PROJECTION); -// gl2f.glPushMatrix(); -// gl2f.glMatrixMode(GL2.GL_MODELVIEW); -// gl2f.glPushMatrix(); } protected void restoreGLMatrices() { @@ -6234,16 +5847,11 @@ public class PGraphicsOpenGL extends PGraphics { pgl.popMatrix(); pgl.setModelviewMode(); pgl.popMatrix(); -// gl2f.glMatrixMode(GL2.GL_PROJECTION); -// gl2f.glPopMatrix(); -// gl2f.glMatrixMode(GL2.GL_MODELVIEW); -// gl2f.glPopMatrix(); } protected void setDefNormals(float nx, float ny, float nz) { pgl.setNormal(nx, ny, nz); -// gl2f.glNormal3f(nx, ny, nz); } ////////////////////////////////////////////////////////////// @@ -6292,7 +5900,7 @@ public class PGraphicsOpenGL extends PGraphics { } } - ogl = this; + renderer = this; profile = null; @@ -6360,14 +5968,12 @@ public class PGraphicsOpenGL extends PGraphics { protected void initOffscreen() { // Getting the context and capabilities from the main renderer. - ogl = (PGraphicsOpenGL)parent.g; + renderer = (PGraphicsOpenGL)parent.g; - context = ogl.getContext(); - capabilities = ogl.getCapabilities(); + context = renderer.getContext(); + capabilities = renderer.getCapabilities(); drawable = null; - //registerPGLObject(this); - updateGLInterfaces(); loadTextureImpl(BILINEAR); @@ -6375,11 +5981,9 @@ public class PGraphicsOpenGL extends PGraphics { // is changed), we make sure that all the OpenGL resources associated // to the surface are released by calling delete(). if (offscreenFramebuffer != null) { - //offscreenFramebuffer.delete(); offscreenFramebuffer = null; } if (offscreenFramebufferMultisample != null) { - //offscreenFramebufferMultisample.delete(); offscreenFramebufferMultisample = null; } @@ -6390,14 +5994,21 @@ public class PGraphicsOpenGL extends PGraphics { offscreenFramebufferMultisample = new PFramebuffer(parent, texture.glWidth, texture.glHeight, nsamples, 0, offscreenDepthBits, offscreenStencilBits, offscreenDepthBits == 24 && offscreenStencilBits == 8, false); + + + offscreenFramebufferMultisample.clear(); offscreenMultisample = true; + renderer.report("after cleaning fbm"); + // The offscreen framebuffer where the multisampled image is finally drawn to doesn't // need depth and stencil buffers since they are part of the multisampled framebuffer. offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1, 0, 0, - false, false); + false, false); + + } else { offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1, offscreenDepthBits, offscreenStencilBits, @@ -6410,18 +6021,14 @@ public class PGraphicsOpenGL extends PGraphics { } protected void updateOffscreenContext() { - context = ogl.getContext(); - capabilities = ogl.getCapabilities(); + context = renderer.getContext(); + capabilities = renderer.getCapabilities(); drawable = null; updateGLInterfaces(); } protected void getGLParameters() { -// OPENGL_VENDOR = gl.glGetString(GL.GL_VENDOR); -// OPENGL_RENDERER = gl.glGetString(GL.GL_RENDERER); -// OPENGL_VERSION = gl.glGetString(GL.GL_VERSION); -// OPENGL_EXTENSIONS = gl.glGetString(GL.GL_EXTENSIONS); OPENGL_VENDOR = pgl.getVendorString(); OPENGL_RENDERER = pgl.getRendererString(); OPENGL_VERSION = pgl.getVersionString(); diff --git a/java/libraries/opengl/src/processing/opengl/PShader.java b/java/libraries/opengl/src/processing/opengl/PShader.java index 00e3048c1..5f342a9a9 100644 --- a/java/libraries/opengl/src/processing/opengl/PShader.java +++ b/java/libraries/opengl/src/processing/opengl/PShader.java @@ -33,15 +33,13 @@ import java.net.URL; */ public class PShader { protected PApplet parent; - protected PGraphicsOpenGL ogl; + protected PGraphicsOpenGL renderer; protected PGL pgl; protected int programObject; protected int vertexShader; - //protected int geometryShader; protected int fragmentShader; protected boolean initialized; - //protected int maxOutVertCount; /** * Creates an instance of GLSLShader. @@ -50,19 +48,14 @@ public class PShader { */ public PShader(PApplet parent) { this.parent = parent; - ogl = (PGraphicsOpenGL) parent.g; - pgl = ogl.pgl; + renderer = (PGraphicsOpenGL) parent.g; + pgl = renderer.pgl; - programObject = ogl.createGLSLProgramObject(); + programObject = renderer.createGLSLProgramObject(); vertexShader = 0; - //geometryShader = 0; fragmentShader = 0; - initialized = false; - - //IntBuffer buf = IntBuffer.allocate(1); - //gl.glGetIntegerv(GL2.GL_MAX_GEOMETRY_OUTPUT_VERTICES, buf); - //maxOutVertCount = buf.get(0); + initialized = false; } /** @@ -83,13 +76,13 @@ public class PShader { protected void finalize() throws Throwable { try { if (vertexShader != 0) { - ogl.finalizeGLSLVertShaderObject(vertexShader); + renderer.finalizeGLSLVertShaderObject(vertexShader); } if (fragmentShader != 0) { - ogl.finalizeGLSLFragShaderObject(fragmentShader); + renderer.finalizeGLSLFragShaderObject(fragmentShader); } if (programObject != 0) { - ogl.finalizeGLSLProgramObject(programObject); + renderer.finalizeGLSLProgramObject(programObject); } } finally { super.finalize(); @@ -159,8 +152,6 @@ public class PShader { * Links the shader program and validates it. */ public void setup() { -// gl.glLinkProgram(programObject); -// gl.glValidateProgram(programObject); pgl.linkProgram(programObject); pgl.validateProgram(programObject); checkLogInfo("GLSL program validation: ", programObject); @@ -187,7 +178,6 @@ public class PShader { // textures. // gl.glUniform1iARB(loc, unit); - //ogl.gl.getGL2().glUseProgramObjectARB(programObject); pgl.startProgram(programObject); } @@ -195,7 +185,6 @@ public class PShader { * Stops the execution of the shader program. */ public void stop() { - //ogl.gl.getGL2().glUseProgramObjectARB(0); pgl.stopProgram(); } @@ -206,7 +195,6 @@ public class PShader { * @return int */ public int getAttribLocation(String name) { -// return gl.glGetAttribLocation(programObject, name); return pgl.getAttribLocation(programObject, name); } @@ -217,7 +205,6 @@ public class PShader { * @return int */ public int getUniformLocation(String name) { -// return gl.glGetUniformLocation(programObject, name); return pgl.getUniformLocation(programObject, name); } @@ -231,7 +218,6 @@ public class PShader { public void setTexUniform(String name, int unit) { int loc = getUniformLocation(name); if (-1 < loc) { -// gl.glUniform1i(loc, unit); pgl.setIntUniform(loc, unit); } } @@ -267,7 +253,6 @@ public class PShader { public void setIntUniform(String name, int x) { int loc = getUniformLocation(name); if (-1 < loc) { -// gl.glUniform1i(loc, x); pgl.setIntUniform(loc, x); } } @@ -281,7 +266,6 @@ public class PShader { public void setFloatUniform(String name, float x) { int loc = getUniformLocation(name); if (-1 < loc) { - //gl.glUniform1f(loc, x); pgl.setFloatUniform(loc, x); } } @@ -296,7 +280,6 @@ public class PShader { public void setVecUniform(String name, float x, float y) { int loc = getUniformLocation(name); if (-1 < loc) { -// gl.glUniform2f(loc, x, y); pgl.setFloatUniform(loc, x, y); } } @@ -312,7 +295,6 @@ public class PShader { public void setVecUniform(String name, float x, float y, float z) { int loc = getUniformLocation(name); if (-1 < loc) { -// gl.glUniform3f(loc, x, y, z); pgl.setFloatUniform(loc, x, y, z); } } @@ -329,7 +311,6 @@ public class PShader { public void setVecUniform(String name, float x, float y, float z, float w) { int loc = getUniformLocation(name); if (-1 < loc) { -// gl.glUniform4f(loc, x, y, z, w); pgl.setFloatUniform(loc, x, y, z, w); } } @@ -347,7 +328,6 @@ public class PShader { if (-1 < loc) { pgl.setMatUniform(loc, m00, m01, m10, m11); - //gl.glUniformMatrix2fv(loc, 1, false, mat, 0); } } @@ -398,7 +378,6 @@ public class PShader { public void setFloatAttribute(String name, float x) { int loc = getAttribLocation(name); if (-1 < loc) { -// gl.glVertexAttrib1f(loc, x); pgl.setFloatAttrib(loc, x); } } @@ -413,7 +392,6 @@ public class PShader { public void setVecAttribute(String name, float x, float y) { int loc = getAttribLocation(name); if (-1 < loc) { -// gl.glVertexAttrib2f(loc, x, y); pgl.setFloatAttrib(loc, x, y); } } @@ -429,7 +407,6 @@ public class PShader { public void setVecAttribute(String name, float x, float y, float z) { int loc = getAttribLocation(name); if (-1 < loc) { -// gl.glVertexAttrib3f(loc, x, y, z); pgl.setFloatAttrib(loc, x, y, z); } } @@ -446,7 +423,6 @@ public class PShader { public void setVecAttribute(String name, float x, float y, float z, float w) { int loc = getAttribLocation(name); if (-1 < loc) { -// gl.glVertexAttrib4f(loc, x, y, z, w); pgl.setFloatAttrib(loc, x, y, z, w); } } @@ -456,15 +432,12 @@ public class PShader { * @param filename the shader's filename, used to print error log information */ private void attachVertexShader(String shaderSource, String file) { - vertexShader = ogl.createGLSLVertShaderObject(); + vertexShader = renderer.createGLSLVertShaderObject(); -// gl.glShaderSource(vertexShader, 1, new String[] { shaderSource }, (int[]) null, 0); -// gl.glCompileShader(vertexShader); pgl.setShaderSource(vertexShader, shaderSource); pgl.compileShader(vertexShader); checkLogInfo("Vertex shader " + file + " compilation: ", vertexShader); -// ogl.gl.getGL2().glAttachObjectARB(programObject, vertexShader); pgl.attachShader(programObject, vertexShader); } @@ -473,15 +446,12 @@ public class PShader { * @param filename the shader's filename, used to print error log information */ private void attachFragmentShader(String shaderSource, String file) { - fragmentShader = ogl.createGLSLFragShaderObject(); + fragmentShader = renderer.createGLSLFragShaderObject(); -// gl.glShaderSource(fragmentShader, 1, new String[] { shaderSource }, (int[]) null, 0); -// gl.glCompileShader(fragmentShader); pgl.setShaderSource(fragmentShader, shaderSource); pgl.compileShader(fragmentShader); checkLogInfo("Fragment shader " + file + " compilation: ", fragmentShader); -// ogl.gl.getGL2().glAttachObjectARB(programObject, fragmentShader); pgl.attachShader(programObject, fragmentShader); } @@ -499,15 +469,15 @@ public class PShader { protected void release() { if (vertexShader != 0) { - ogl.deleteGLSLVertShaderObject(vertexShader); + renderer.deleteGLSLVertShaderObject(vertexShader); vertexShader = 0; } if (fragmentShader != 0) { - ogl.deleteGLSLFragShaderObject(fragmentShader); + renderer.deleteGLSLFragShaderObject(fragmentShader); fragmentShader = 0; } if (programObject != 0) { - ogl.deleteGLSLProgramObject(programObject); + renderer.deleteGLSLProgramObject(programObject); programObject = 0; } } diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index 2aea0623c..a4e76c462 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -73,7 +73,7 @@ import java.util.Hashtable; */ public class PShape3D extends PShape { - protected PGraphicsOpenGL ogl; + protected PGraphicsOpenGL renderer; protected PGL pgl; protected PShape3D root; @@ -240,8 +240,8 @@ public class PShape3D extends PShape { protected int imageMode; public PShape3D(PApplet parent, int family) { - ogl = (PGraphicsOpenGL)parent.g; - pgl = ogl.pgl; + renderer = (PGraphicsOpenGL)parent.g; + pgl = renderer.pgl; glMode = PGL.STATIC_DRAW; @@ -263,50 +263,50 @@ public class PShape3D extends PShape { glPointAttribBufferID = 0; glPointIndexBufferID = 0; - this.tessellator = ogl.tessellator; + this.tessellator = renderer.tessellator; this.family = family; this.root = this; this.parent = null; this.tessellated = false; - tess = ogl.newTessGeometry(RETAINED); + tess = renderer.newTessGeometry(RETAINED); if (family == GEOMETRY || family == PRIMITIVE || family == PATH) { - in = ogl.newInGeometry(); + in = renderer.newInGeometry(); } // Modes are retrieved from the current values in the renderer. - textureMode = ogl.textureMode; - rectMode = ogl.rectMode; - ellipseMode = ogl.ellipseMode; - shapeMode = ogl.shapeMode; - imageMode = ogl.imageMode; + textureMode = renderer.textureMode; + rectMode = renderer.rectMode; + ellipseMode = renderer.ellipseMode; + shapeMode = renderer.shapeMode; + imageMode = renderer.imageMode; - colorMode(ogl.colorMode, ogl.colorModeX, ogl.colorModeY, ogl.colorModeZ, ogl.colorModeA); + colorMode(renderer.colorMode, renderer.colorModeX, renderer.colorModeY, renderer.colorModeZ, renderer.colorModeA); // Initial values for fill, stroke and tint colors are also imported from the renderer. // This is particular relevant for primitive shapes, since is not possible to set // their color separately when creating them, and their input vertices are actually // generated at rendering time, by which the color configuration of the renderer might // have changed. - fill = ogl.fill; - fillR = ((ogl.fillColor >> 16) & 0xFF) / 255.0f; - fillG = ((ogl.fillColor >> 8) & 0xFF) / 255.0f; - fillB = ((ogl.fillColor >> 0) & 0xFF) / 255.0f; - fillA = ((ogl.fillColor >> 24) & 0xFF) / 255.0f; + fill = renderer.fill; + fillR = ((renderer.fillColor >> 16) & 0xFF) / 255.0f; + fillG = ((renderer.fillColor >> 8) & 0xFF) / 255.0f; + fillB = ((renderer.fillColor >> 0) & 0xFF) / 255.0f; + fillA = ((renderer.fillColor >> 24) & 0xFF) / 255.0f; - stroke = ogl.stroke; - strokeR = ((ogl.strokeColor >> 16) & 0xFF) / 255.0f; - strokeG = ((ogl.strokeColor >> 8) & 0xFF) / 255.0f; - strokeB = ((ogl.strokeColor >> 0) & 0xFF) / 255.0f; - strokeA = ((ogl.strokeColor >> 24) & 0xFF) / 255.0f; + stroke = renderer.stroke; + strokeR = ((renderer.strokeColor >> 16) & 0xFF) / 255.0f; + strokeG = ((renderer.strokeColor >> 8) & 0xFF) / 255.0f; + strokeB = ((renderer.strokeColor >> 0) & 0xFF) / 255.0f; + strokeA = ((renderer.strokeColor >> 24) & 0xFF) / 255.0f; - strokeWeight = ogl.strokeWeight; + strokeWeight = renderer.strokeWeight; - tint = ogl.tint; - tintR = ((ogl.tintColor >> 16) & 0xFF) / 255.0f; - tintG = ((ogl.tintColor >> 8) & 0xFF) / 255.0f; - tintB = ((ogl.tintColor >> 0) & 0xFF) / 255.0f; - tintA = ((ogl.tintColor >> 24) & 0xFF) / 255.0f; + tint = renderer.tint; + tintR = ((renderer.tintColor >> 16) & 0xFF) / 255.0f; + tintG = ((renderer.tintColor >> 8) & 0xFF) / 255.0f; + tintB = ((renderer.tintColor >> 0) & 0xFF) / 255.0f; + tintA = ((renderer.tintColor >> 24) & 0xFF) / 255.0f; normalX = normalY = 0; normalZ = 1; @@ -368,67 +368,67 @@ public class PShape3D extends PShape { protected void finalizeFillBuffers() { if (glFillVertexBufferID != 0) { - ogl.finalizeVertexBufferObject(glFillVertexBufferID); + renderer.finalizeVertexBufferObject(glFillVertexBufferID); } if (glFillColorBufferID != 0) { - ogl.finalizeVertexBufferObject(glFillColorBufferID); + renderer.finalizeVertexBufferObject(glFillColorBufferID); } if (glFillNormalBufferID != 0) { - ogl.finalizeVertexBufferObject(glFillNormalBufferID); + renderer.finalizeVertexBufferObject(glFillNormalBufferID); } if (glFillTexCoordBufferID != 0) { - ogl.finalizeVertexBufferObject(glFillTexCoordBufferID); + renderer.finalizeVertexBufferObject(glFillTexCoordBufferID); } if (glFillIndexBufferID != 0) { - ogl.finalizeVertexBufferObject(glFillIndexBufferID); + renderer.finalizeVertexBufferObject(glFillIndexBufferID); } } protected void finalizeLineBuffers() { if (glLineVertexBufferID != 0) { - ogl.finalizeVertexBufferObject(glLineVertexBufferID); + renderer.finalizeVertexBufferObject(glLineVertexBufferID); } if (glLineColorBufferID != 0) { - ogl.finalizeVertexBufferObject(glLineColorBufferID); + renderer.finalizeVertexBufferObject(glLineColorBufferID); } if (glLineNormalBufferID != 0) { - ogl.finalizeVertexBufferObject(glLineNormalBufferID); + renderer.finalizeVertexBufferObject(glLineNormalBufferID); } if (glLineAttribBufferID != 0) { - ogl.finalizeVertexBufferObject(glLineAttribBufferID); + renderer.finalizeVertexBufferObject(glLineAttribBufferID); } if (glLineIndexBufferID != 0) { - ogl.finalizeVertexBufferObject(glLineIndexBufferID); + renderer.finalizeVertexBufferObject(glLineIndexBufferID); } } protected void finalizePointBuffers() { if (glPointVertexBufferID != 0) { - ogl.finalizeVertexBufferObject(glPointVertexBufferID); + renderer.finalizeVertexBufferObject(glPointVertexBufferID); } if (glPointColorBufferID != 0) { - ogl.finalizeVertexBufferObject(glPointColorBufferID); + renderer.finalizeVertexBufferObject(glPointColorBufferID); } if (glPointNormalBufferID != 0) { - ogl.finalizeVertexBufferObject(glPointNormalBufferID); + renderer.finalizeVertexBufferObject(glPointNormalBufferID); } if (glPointAttribBufferID != 0) { - ogl.finalizeVertexBufferObject(glPointAttribBufferID); + renderer.finalizeVertexBufferObject(glPointAttribBufferID); } if (glPointIndexBufferID != 0) { - ogl.finalizeVertexBufferObject(glPointIndexBufferID); + renderer.finalizeVertexBufferObject(glPointIndexBufferID); } } @@ -1636,11 +1636,11 @@ public class PShape3D extends PShape { } // setup matrix for forward differencing to speed up drawing - ogl.splineForward(detail, bezierDrawMatrix); + renderer.splineForward(detail, bezierDrawMatrix); // multiply the basis and forward diff matrices together // saves much time since this needn't be done for each curve - bezierDrawMatrix.apply(ogl.bezierBasisMatrix); + bezierDrawMatrix.apply(renderer.bezierBasisMatrix); } public void bezierVertex(float x2, float y2, @@ -1807,10 +1807,10 @@ public class PShape3D extends PShape { (s-1)/2f, 0, (1-s)/2f, 0, 0, 1, 0, 0); - ogl.splineForward(curveDetail, curveDrawMatrix); + renderer.splineForward(curveDetail, curveDrawMatrix); if (bezierBasisInverse == null) { - bezierBasisInverse = ogl.bezierBasisMatrix.get(); + bezierBasisInverse = renderer.bezierBasisMatrix.get(); bezierBasisInverse.invert(); curveToBezierMatrix = new PMatrix3D(); } @@ -2161,8 +2161,8 @@ public class PShape3D extends PShape { protected void tessellateSphere() { // TODO: move to InGeometry float r = params[0]; - int nu = ogl.sphereDetailU; - int nv = ogl.sphereDetailV; + int nu = renderer.sphereDetailU; + int nv = renderer.sphereDetailV; if ((nu < 3) || (nv < 2)) { nu = nv = 30; @@ -2419,39 +2419,27 @@ public class PShape3D extends PShape { protected void initFillBuffers(int nvert, int nind) { - glFillVertexBufferID = ogl.createVertexBufferObject(); + glFillVertexBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glFillVertexBufferID); pgl.initVertexBuffer(3 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillVertexBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 3 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glFillColorBufferID = ogl.createVertexBufferObject(); + glFillColorBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glFillColorBufferID); pgl.initVertexBuffer(4 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillColorBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 4 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glFillNormalBufferID = ogl.createVertexBufferObject(); + glFillNormalBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glFillNormalBufferID); pgl.initVertexBuffer(3 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillNormalBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 3 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glFillTexCoordBufferID = ogl.createVertexBufferObject(); + glFillTexCoordBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glFillTexCoordBufferID); pgl.initVertexBuffer(2 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 2 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); pgl.unbindVertexBuffer(); - -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - - glFillIndexBufferID = ogl.createVertexBufferObject(); + + glFillIndexBufferID = renderer.createVertexBufferObject(); pgl.bindIndexBuffer(glFillIndexBufferID); pgl.initIndexBuffer(nind, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillIndexBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, nind * PGraphicsOpenGL.SIZEOF_INT, null, glMode); pgl.unbindIndexBuffer(); } @@ -2637,51 +2625,28 @@ public class PShape3D extends PShape { float[] normals, float[] texcoords) { pgl.bindVertexBuffer(glFillVertexBufferID); pgl.copyVertexBufferSubData(vertices, 3 * offset, 3 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillVertexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(vertices)); pgl.bindVertexBuffer(glFillColorBufferID); pgl.copyVertexBufferSubData(colors, 4 * offset, 4 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillColorBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(colors)); pgl.bindVertexBuffer(glFillNormalBufferID); pgl.copyVertexBufferSubData(normals, 3 * offset, 3 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillNormalBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(normals)); pgl.bindVertexBuffer(glFillTexCoordBufferID); pgl.copyVertexBufferSubData(texcoords, 2 * offset, 2 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 2 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 2 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(texcoords)); pgl.unbindVertexBuffer(); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } protected void copyFillVertices(int offset, int size, float[] vertices) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillVertexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(vertices)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glFillVertexBufferID); pgl.copyVertexBufferSubData(vertices, 3 * offset, 3 * size, glMode); pgl.unbindVertexBuffer(); } - protected void copyFillColors(int offset, int size, float[] colors) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillColorBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(colors)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - + protected void copyFillColors(int offset, int size, float[] colors) { pgl.bindVertexBuffer(glFillColorBufferID); pgl.copyVertexBufferSubData(colors, 4 * offset, 4 * size, glMode); pgl.unbindVertexBuffer(); @@ -2689,12 +2654,6 @@ public class PShape3D extends PShape { protected void copyFillNormals(int offset, int size, float[] normals) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillNormalBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(normals)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - - pgl.bindVertexBuffer(glFillNormalBufferID); pgl.copyVertexBufferSubData(normals, 3 * offset, 3 * size, glMode); pgl.unbindVertexBuffer(); @@ -2702,11 +2661,6 @@ public class PShape3D extends PShape { protected void copyFillTexCoords(int offset, int size, float[] texcoords) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 2 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 2 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(texcoords)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glFillTexCoordBufferID); pgl.copyVertexBufferSubData(texcoords, 2 * offset, 2 * size, glMode); pgl.unbindVertexBuffer(); @@ -2714,11 +2668,6 @@ public class PShape3D extends PShape { protected void copyFillIndices(int offset, int size, int[] indices) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glFillIndexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, offset * PGraphicsOpenGL.SIZEOF_INT, -// size * PGraphicsOpenGL.SIZEOF_INT, IntBuffer.wrap(indices)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindIndexBuffer(glFillIndexBufferID); pgl.copyIndexBufferSubData(indices, offset, size, glMode); pgl.unbindIndexBuffer(); @@ -2726,39 +2675,28 @@ public class PShape3D extends PShape { protected void initLineBuffers(int nvert, int nind) { - glLineVertexBufferID = ogl.createVertexBufferObject(); + glLineVertexBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glLineVertexBufferID); pgl.initVertexBuffer(3 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineVertexBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 3 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glLineColorBufferID = ogl.createVertexBufferObject(); + glLineColorBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glLineColorBufferID); pgl.initVertexBuffer(4 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineColorBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 4 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glLineNormalBufferID = ogl.createVertexBufferObject(); + glLineNormalBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glLineNormalBufferID); pgl.initVertexBuffer(3 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineNormalBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 3 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glLineAttribBufferID = ogl.createVertexBufferObject(); + glLineAttribBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glLineAttribBufferID); pgl.initVertexBuffer(4 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineAttribBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 4 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); pgl.unbindVertexBuffer(); - glLineIndexBufferID = ogl.createVertexBufferObject(); + glLineIndexBufferID = renderer.createVertexBufferObject(); pgl.bindIndexBuffer(glLineIndexBufferID); pgl.initIndexBuffer(nind, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineIndexBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, nind * PGraphicsOpenGL.SIZEOF_INT, null, glMode); - -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); + pgl.unbindIndexBuffer(); } @@ -2786,39 +2724,21 @@ public class PShape3D extends PShape { float[] vertices, float[] colors, float[] normals, float[] attribs) { pgl.bindVertexBuffer(glLineVertexBufferID); pgl.copyVertexBufferSubData(vertices, 3 * offset, 3 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineVertexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(vertices)); pgl.bindVertexBuffer(glLineColorBufferID); pgl.copyVertexBufferSubData(colors, 4 * offset, 4 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineColorBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(colors)); pgl.bindVertexBuffer(glLineNormalBufferID); pgl.copyVertexBufferSubData(normals, 3 * offset, 3 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineNormalBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(normals)); pgl.bindVertexBuffer(glLineAttribBufferID); pgl.copyVertexBufferSubData(attribs, 4 * offset, 4 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineAttribBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(attribs)); pgl.unbindVertexBuffer(); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - protected void copyLineVertices(int offset, int size, float[] vertices) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineVertexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(vertices)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - + protected void copyLineVertices(int offset, int size, float[] vertices) { pgl.bindVertexBuffer(glLineVertexBufferID); pgl.copyVertexBufferSubData(vertices, 3 * offset, 3 * size, glMode); pgl.unbindVertexBuffer(); @@ -2826,11 +2746,6 @@ public class PShape3D extends PShape { protected void copyLineColors(int offset, int size, float[] colors) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineColorBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(colors)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glLineColorBufferID); pgl.copyVertexBufferSubData(colors, 4 * offset, 4 * size, glMode); pgl.unbindVertexBuffer(); @@ -2838,11 +2753,6 @@ public class PShape3D extends PShape { protected void copyLineNormals(int offset, int size, float[] normals) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineNormalBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(normals)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glLineNormalBufferID); pgl.copyVertexBufferSubData(normals, 3 * offset, 3 * size, glMode); pgl.unbindVertexBuffer(); @@ -2850,11 +2760,6 @@ public class PShape3D extends PShape { protected void copyLineAttributes(int offset, int size, float[] attribs) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineAttribBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(attribs)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glLineAttribBufferID); pgl.copyVertexBufferSubData(attribs, 4 * offset, 4 * size, glMode); pgl.unbindVertexBuffer(); @@ -2862,11 +2767,6 @@ public class PShape3D extends PShape { protected void copyLineIndices(int offset, int size, int[] indices) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glLineIndexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, offset * PGraphicsOpenGL.SIZEOF_INT, -// size * PGraphicsOpenGL.SIZEOF_INT, IntBuffer.wrap(indices)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindIndexBuffer(glLineIndexBufferID); pgl.copyIndexBufferSubData(indices, offset, size, glMode); pgl.unbindIndexBuffer(); @@ -2874,38 +2774,27 @@ public class PShape3D extends PShape { protected void initPointBuffers(int nvert, int nind) { - glPointVertexBufferID = ogl.createVertexBufferObject(); + glPointVertexBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glPointVertexBufferID); pgl.initVertexBuffer(3 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointVertexBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 3 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glPointColorBufferID = ogl.createVertexBufferObject(); + glPointColorBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glPointColorBufferID); pgl.initVertexBuffer(4 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointColorBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 4 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glPointNormalBufferID = ogl.createVertexBufferObject(); + glPointNormalBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glPointNormalBufferID); pgl.initVertexBuffer(3 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointNormalBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 3 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - glPointAttribBufferID = ogl.createVertexBufferObject(); + glPointAttribBufferID = renderer.createVertexBufferObject(); pgl.bindVertexBuffer(glPointAttribBufferID); pgl.initVertexBuffer(2 * nvert, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointAttribBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, 2 * nvert * PGraphicsOpenGL.SIZEOF_FLOAT, null, glMode); - pgl.unbindVertexBuffer(); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); + pgl.unbindVertexBuffer(); - glPointIndexBufferID = ogl.createVertexBufferObject(); + glPointIndexBufferID = renderer.createVertexBufferObject(); pgl.bindIndexBuffer(glPointIndexBufferID); pgl.initIndexBuffer(nind, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointIndexBufferID); -// getGl().glBufferData(GL.GL_ARRAY_BUFFER, nind * PGraphicsOpenGL.SIZEOF_INT, null, glMode); pgl.unbindIndexBuffer(); } @@ -2934,39 +2823,21 @@ public class PShape3D extends PShape { float[] vertices, float[] colors, float[] normals, float[] attribs) { pgl.bindVertexBuffer(glPointVertexBufferID); pgl.copyVertexBufferSubData(vertices, 3 * offset, 3 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointVertexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(vertices)); pgl.bindVertexBuffer(glPointColorBufferID); pgl.copyVertexBufferSubData(colors, 4 * offset, 4 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointColorBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(colors)); pgl.bindVertexBuffer(glPointNormalBufferID); pgl.copyVertexBufferSubData(normals, 3 * offset, 3 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointNormalBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(normals)); pgl.bindVertexBuffer(glPointAttribBufferID); pgl.copyVertexBufferSubData(attribs, 2 * offset, 2 * size, glMode); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointAttribBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 2 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 2 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(attribs)); pgl.unbindVertexBuffer(); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - protected void copyPointVertices(int offset, int size, float[] vertices) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointVertexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(vertices)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - + protected void copyPointVertices(int offset, int size, float[] vertices) { pgl.bindVertexBuffer(glPointVertexBufferID); pgl.copyVertexBufferSubData(vertices, 3 * offset, 3 * size, glMode); pgl.unbindVertexBuffer(); @@ -2974,11 +2845,6 @@ public class PShape3D extends PShape { protected void copyPointColors(int offset, int size, float[] colors) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointColorBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 4 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 4 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(colors)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glPointColorBufferID); pgl.copyVertexBufferSubData(colors, 4 * offset, 4 * size, glMode); pgl.unbindVertexBuffer(); @@ -2986,11 +2852,6 @@ public class PShape3D extends PShape { protected void copyPointNormals(int offset, int size, float[] normals) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointNormalBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 3 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 3 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(normals)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glPointNormalBufferID); pgl.copyVertexBufferSubData(normals, 3 * offset, 3 * size, glMode); pgl.unbindVertexBuffer(); @@ -2998,11 +2859,6 @@ public class PShape3D extends PShape { protected void copyPointAttributes(int offset, int size, float[] attribs) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointAttribBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, 2 * offset * PGraphicsOpenGL.SIZEOF_FLOAT, -// 2 * size * PGraphicsOpenGL.SIZEOF_FLOAT, FloatBuffer.wrap(attribs)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindVertexBuffer(glPointAttribBufferID); pgl.copyVertexBufferSubData(attribs, 2 * offset, 2 * size, glMode); pgl.unbindVertexBuffer(); @@ -3010,11 +2866,6 @@ public class PShape3D extends PShape { protected void copyPointIndices(int offset, int size, int[] indices) { -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glPointIndexBufferID); -// getGl().glBufferSubData(GL.GL_ARRAY_BUFFER, offset * PGraphicsOpenGL.SIZEOF_INT, -// size * PGraphicsOpenGL.SIZEOF_INT, IntBuffer.wrap(indices)); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - pgl.bindIndexBuffer(glPointIndexBufferID); pgl.copyIndexBufferSubData(indices, offset, size, glMode); pgl.unbindIndexBuffer(); @@ -3037,27 +2888,27 @@ public class PShape3D extends PShape { protected void deleteFillBuffers() { if (glFillVertexBufferID != 0) { - ogl.deleteVertexBufferObject(glFillVertexBufferID); + renderer.deleteVertexBufferObject(glFillVertexBufferID); glFillVertexBufferID = 0; } if (glFillColorBufferID != 0) { - ogl.deleteVertexBufferObject(glFillColorBufferID); + renderer.deleteVertexBufferObject(glFillColorBufferID); glFillColorBufferID = 0; } if (glFillNormalBufferID != 0) { - ogl.deleteVertexBufferObject(glFillNormalBufferID); + renderer.deleteVertexBufferObject(glFillNormalBufferID); glFillNormalBufferID = 0; } if (glFillTexCoordBufferID != 0) { - ogl.deleteVertexBufferObject(glFillTexCoordBufferID); + renderer.deleteVertexBufferObject(glFillTexCoordBufferID); glFillTexCoordBufferID = 0; } if (glFillIndexBufferID != 0) { - ogl.deleteVertexBufferObject(glFillIndexBufferID); + renderer.deleteVertexBufferObject(glFillIndexBufferID); glFillIndexBufferID = 0; } } @@ -3065,27 +2916,27 @@ public class PShape3D extends PShape { protected void deleteLineBuffers() { if (glLineVertexBufferID != 0) { - ogl.deleteVertexBufferObject(glLineVertexBufferID); + renderer.deleteVertexBufferObject(glLineVertexBufferID); glLineVertexBufferID = 0; } if (glLineColorBufferID != 0) { - ogl.deleteVertexBufferObject(glLineColorBufferID); + renderer.deleteVertexBufferObject(glLineColorBufferID); glLineColorBufferID = 0; } if (glLineNormalBufferID != 0) { - ogl.deleteVertexBufferObject(glLineNormalBufferID); + renderer.deleteVertexBufferObject(glLineNormalBufferID); glLineNormalBufferID = 0; } if (glLineAttribBufferID != 0) { - ogl.deleteVertexBufferObject(glLineAttribBufferID); + renderer.deleteVertexBufferObject(glLineAttribBufferID); glLineAttribBufferID = 0; } if (glLineIndexBufferID != 0) { - ogl.deleteVertexBufferObject(glLineIndexBufferID); + renderer.deleteVertexBufferObject(glLineIndexBufferID); glLineIndexBufferID = 0; } } @@ -3093,27 +2944,27 @@ public class PShape3D extends PShape { protected void deletePointBuffers() { if (glPointVertexBufferID != 0) { - ogl.deleteVertexBufferObject(glPointVertexBufferID); + renderer.deleteVertexBufferObject(glPointVertexBufferID); glPointVertexBufferID = 0; } if (glPointColorBufferID != 0) { - ogl.deleteVertexBufferObject(glPointColorBufferID); + renderer.deleteVertexBufferObject(glPointColorBufferID); glPointColorBufferID = 0; } if (glPointNormalBufferID != 0) { - ogl.deleteVertexBufferObject(glPointNormalBufferID); + renderer.deleteVertexBufferObject(glPointNormalBufferID); glPointNormalBufferID = 0; } if (glPointAttribBufferID != 0) { - ogl.deleteVertexBufferObject(glPointAttribBufferID); + renderer.deleteVertexBufferObject(glPointAttribBufferID); glPointAttribBufferID = 0; } if (glPointIndexBufferID != 0) { - ogl.deleteVertexBufferObject(glPointIndexBufferID); + renderer.deleteVertexBufferObject(glPointIndexBufferID); glPointIndexBufferID = 0; } } @@ -3126,7 +2977,7 @@ public class PShape3D extends PShape { public void draw() { - draw(ogl); + draw(renderer); } @@ -3203,66 +3054,42 @@ public class PShape3D extends PShape { protected void renderPoints() { - ogl.startPointShader(); + renderer.startPointShader(); pgl.enableVertexArrays(); pgl.enableColorArrays(); pgl.enableNormalArrays(); -// getGl().glEnableClientState(GL2.GL_NORMAL_ARRAY); -// getGl().glEnableClientState(GL2.GL_COLOR_ARRAY); -// getGl().glEnableClientState(GL2.GL_VERTEX_ARRAY); - - pgl.bindVertexBuffer(root.glPointVertexBufferID); pgl.setVertexFormat(3, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glPointVertexBufferID); -// getGl().glVertexPointer(3, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(root.glPointColorBufferID); pgl.setColorFormat(4, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glPointColorBufferID); -// getGl().glColorPointer(4, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(root.glPointNormalBufferID); pgl.setNormalFormat(3, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glPointNormalBufferID); -// getGl().glNormalPointer(GL.GL_FLOAT, 0, 0); - ogl.setupPointShader(root.glPointAttribBufferID); + renderer.setupPointShader(root.glPointAttribBufferID); int offset = tess.firstPointIndex; int size = tess.lastPointIndex - tess.firstPointIndex + 1; pgl.bindIndexBuffer(root.glPointIndexBufferID); pgl.renderIndexBuffer(offset, size); -// getGl().glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, root.glPointIndexBufferID); -// getGl().glDrawElements(GL.GL_TRIANGLES, tess.lastPointIndex - tess.firstPointIndex + 1, GL.GL_UNSIGNED_INT, -// tess.firstPointIndex * PGraphicsOpenGL.SIZEOF_INT); - -// getGl().glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); pgl.unbindIndexBuffer(); pgl.unbindVertexBuffer(); pgl.disableVertexArrays(); pgl.disableColorArrays(); pgl.disableNormalArrays(); - -// getGl().glDisableClientState(GL2.GL_VERTEX_ARRAY); -// getGl().glDisableClientState(GL2.GL_COLOR_ARRAY); -// getGl().glDisableClientState(GL2.GL_NORMAL_ARRAY); - - ogl.stopPointShader(); + + renderer.stopPointShader(); } protected void renderLines() { - ogl.startLineShader(); + renderer.startLineShader(); -// getGl().glEnableClientState(GL2.GL_NORMAL_ARRAY); -// getGl().glEnableClientState(GL2.GL_COLOR_ARRAY); -// getGl().glEnableClientState(GL2.GL_VERTEX_ARRAY); pgl.enableVertexArrays(); pgl.enableColorArrays(); pgl.enableNormalArrays(); @@ -3275,82 +3102,50 @@ public class PShape3D extends PShape { pgl.bindVertexBuffer(root.glLineNormalBufferID); pgl.setNormalFormat(3, 0, 0); - -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glLineNormalBufferID); -// getGl().glNormalPointer(GL.GL_FLOAT, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glLineColorBufferID); -// getGl().glColorPointer(4, GL.GL_FLOAT, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glLineVertexBufferID); -// getGl().glVertexPointer(3, GL.GL_FLOAT, 0, 0); - - ogl.setupLineShader(root.glLineAttribBufferID); + + renderer.setupLineShader(root.glLineAttribBufferID); int offset = tess.firstLineIndex; int size = tess.lastLineIndex - tess.firstLineIndex + 1; pgl.bindIndexBuffer(root.glLineIndexBufferID); pgl.renderIndexBuffer(offset, size); -// getGl().glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, root.glLineIndexBufferID); -// getGl().glDrawElements(GL.GL_TRIANGLES, tess.lastLineIndex - tess.firstLineIndex + 1, GL.GL_UNSIGNED_INT, -// tess.firstLineIndex * PGraphicsOpenGL.SIZEOF_INT); - -// getGl().glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); pgl.unbindIndexBuffer(); pgl.unbindVertexBuffer(); -// getGl().glDisableClientState(GL2.GL_VERTEX_ARRAY); -// getGl().glDisableClientState(GL2.GL_COLOR_ARRAY); -// getGl().glDisableClientState(GL2.GL_NORMAL_ARRAY); pgl.disableVertexArrays(); pgl.disableColorArrays(); pgl.disableNormalArrays(); - ogl.stopLineShader(); + renderer.stopLineShader(); } protected void renderFill(PImage textureImage) { -// getGl().glEnableClientState(GL2.GL_NORMAL_ARRAY); -// getGl().glEnableClientState(GL2.GL_COLOR_ARRAY); -// getGl().glEnableClientState(GL2.GL_VERTEX_ARRAY); -// getGl().glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY); pgl.enableVertexArrays(); pgl.enableColorArrays(); pgl.enableNormalArrays(); pgl.enableTexCoordArrays(); - - + pgl.bindVertexBuffer(root.glFillVertexBufferID); pgl.setVertexFormat(3, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glFillColorBufferID); -// getGl().glVertexPointer(3, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(root.glFillColorBufferID); pgl.setColorFormat(4, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glFillColorBufferID); -// getGl().glColorPointer(4, GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(root.glFillNormalBufferID); pgl.setNormalFormat(3, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glFillNormalBufferID); -// getGl().glNormalPointer(GL.GL_FLOAT, 0, 0); pgl.bindVertexBuffer(root.glFillTexCoordBufferID); pgl.setTexCoordFormat(2, 0, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, root.glFillTexCoordBufferID); -// getGl().glTexCoordPointer(2, GL.GL_FLOAT, 0, 0); PTexture tex = null; if (textureImage != null) { - tex = ogl.getTexture(textureImage); + tex = renderer.getTexture(textureImage); if (tex != null) { pgl.enableTexturing(tex.glTarget); pgl.setActiveTexUnit(0); pgl.bindTexture(tex.glTarget, tex.glID); -// getGl().glEnable(tex.glTarget); -// getGl().glActiveTexture(GL.GL_TEXTURE0); -// getGl().glBindTexture(tex.glTarget, tex.glID); } } @@ -3359,29 +3154,14 @@ public class PShape3D extends PShape { pgl.bindIndexBuffer(root.glFillIndexBufferID); pgl.renderIndexBuffer(offset, size); -// getGl().glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, root.glFillIndexBufferID); -// getGl().glDrawElements(GL.GL_TRIANGLES, tess.lastFillIndex - tess.firstFillIndex + 1, GL.GL_UNSIGNED_INT, -// tess.firstFillIndex * PGraphicsOpenGL.SIZEOF_INT); - if (tex != null) { pgl.unbindTexture(tex.glTarget); pgl.disableTexturing(tex.glTarget); -// -// getGl().glActiveTexture(GL.GL_TEXTURE0); -// getGl().glBindTexture(tex.glTarget, 0); -// getGl().glDisable(tex.glTarget); } pgl.unbindIndexBuffer(); pgl.unbindVertexBuffer(); -// getGl().glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0); -// getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - -// getGl().glDisableClientState(GL2.GL_VERTEX_ARRAY); -// getGl().glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY); -// getGl().glDisableClientState(GL2.GL_COLOR_ARRAY); -// getGl().glDisableClientState(GL2.GL_NORMAL_ARRAY); pgl.disableVertexArrays(); pgl.disableColorArrays(); pgl.disableNormalArrays(); @@ -3538,15 +3318,6 @@ public class PShape3D extends PShape { } - /////////////////////////////////////////////////////////// - - // - - // Utilities methods - -// protected GL2ES1 getGl() { -// return ogl.gl2f; -// } /////////////////////////////////////////////////////////////////////////// @@ -3774,23 +3545,23 @@ public class PShape3D extends PShape { int mtlIdxCur = -1; OBJMaterial mtl = null; - ogl.saveDrawingState(); + renderer.saveDrawingState(); // The recorded shapes are not merged, they are grouped // according to the group names found in the OBJ file. //ogl.mergeRecShapes = false; // Using RGB mode for coloring. - ogl.colorMode = RGB; + renderer.colorMode = RGB; // Strokes are not used to draw the model. - ogl.stroke = false; + renderer.stroke = false; // Normals are automatically computed if not specified in the OBJ file. - ogl.autoNormal(true); + renderer.autoNormal(true); // Using normal mode for texture coordinates (i.e.: normalized between 0 and 1). - ogl.textureMode = NORMAL; + renderer.textureMode = NORMAL; //ogl.beginShapeRecorderImpl(); for (int i = 0; i < faces.size(); i++) { @@ -3803,29 +3574,29 @@ public class PShape3D extends PShape { mtl = materials.get(mtlIdxCur); // Setting colors. - ogl.specular(mtl.ks.x * 255.0f, mtl.ks.y * 255.0f, mtl.ks.z * 255.0f); - ogl.ambient(mtl.ka.x * 255.0f, mtl.ka.y * 255.0f, mtl.ka.z * 255.0f); - if (ogl.fill) { - ogl.fill(mtl.kd.x * 255.0f, mtl.kd.y * 255.0f, mtl.kd.z * 255.0f, mtl.d * 255.0f); + renderer.specular(mtl.ks.x * 255.0f, mtl.ks.y * 255.0f, mtl.ks.z * 255.0f); + renderer.ambient(mtl.ka.x * 255.0f, mtl.ka.y * 255.0f, mtl.ka.z * 255.0f); + if (renderer.fill) { + renderer.fill(mtl.kd.x * 255.0f, mtl.kd.y * 255.0f, mtl.kd.z * 255.0f, mtl.d * 255.0f); } - ogl.shininess(mtl.ns); + renderer.shininess(mtl.ns); - if (ogl.tint && mtl.kdMap != null) { + if (renderer.tint && mtl.kdMap != null) { // If current material is textured, then tinting the texture using the diffuse color. - ogl.tint(mtl.kd.x * 255.0f, mtl.kd.y * 255.0f, mtl.kd.z * 255.0f, mtl.d * 255.0f); + renderer.tint(mtl.kd.x * 255.0f, mtl.kd.y * 255.0f, mtl.kd.z * 255.0f, mtl.d * 255.0f); } } // Recording current face. if (face.vertIdx.size() == 3) { - ogl.beginShape(TRIANGLES); // Face is a triangle, so using appropriate shape kind. + renderer.beginShape(TRIANGLES); // Face is a triangle, so using appropriate shape kind. } else if (face.vertIdx.size() == 4) { - ogl.beginShape(QUADS); // Face is a quad, so using appropriate shape kind. + renderer.beginShape(QUADS); // Face is a quad, so using appropriate shape kind. } else { - ogl.beginShape(); + renderer.beginShape(); } - ogl.shapeName(face.name); + renderer.shapeName(face.name); for (int j = 0; j < face.vertIdx.size(); j++){ int vertIdx, normIdx; @@ -3855,29 +3626,29 @@ public class PShape3D extends PShape { } } - PTexture texMtl = (PTexture)mtl.kdMap.getCache(ogl); + PTexture texMtl = (PTexture)mtl.kdMap.getCache(renderer); if (texMtl != null) { // Texture orientation in Processing is inverted. texMtl.setFlippedY(true); } - ogl.texture(mtl.kdMap); + renderer.texture(mtl.kdMap); if (norms != null) { - ogl.normal(norms.x, norms.y, norms.z); + renderer.normal(norms.x, norms.y, norms.z); } if (tex != null) { - ogl.vertex(vert.x, vert.y, vert.z, tex.x, tex.y); + renderer.vertex(vert.x, vert.y, vert.z, tex.x, tex.y); } else { - ogl.vertex(vert.x, vert.y, vert.z); + renderer.vertex(vert.x, vert.y, vert.z); } } else { // This face is not textured. if (norms != null) { - ogl.normal(norms.x, norms.y, norms.z); + renderer.normal(norms.x, norms.y, norms.z); } - ogl.vertex(vert.x, vert.y, vert.z); + renderer.vertex(vert.x, vert.y, vert.z); } } - ogl.endShape(CLOSE); + renderer.endShape(CLOSE); } // Allocate space for the geometry that the triangulator has generated from the OBJ model. @@ -3893,7 +3664,7 @@ public class PShape3D extends PShape { //ogl.endShapeRecorderImpl(this); //ogl.endShapeRecorderImpl(null); - ogl.restoreDrawingState(); + renderer.restoreDrawingState(); } diff --git a/java/libraries/opengl/src/processing/opengl/PTexture.java b/java/libraries/opengl/src/processing/opengl/PTexture.java index 4e5e6a913..8f3b489e8 100644 --- a/java/libraries/opengl/src/processing/opengl/PTexture.java +++ b/java/libraries/opengl/src/processing/opengl/PTexture.java @@ -3,6 +3,7 @@ /* Part of the Processing project - http://processing.org + Copyright (c) 2011 Andres Colubri Copyright (c) 2010 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or @@ -22,7 +23,6 @@ package processing.opengl; -import javax.media.opengl.GL; import javax.media.opengl.GLContext; import processing.core.PApplet; import processing.core.PConstants; @@ -37,10 +37,10 @@ import processing.core.PImage; public class PTexture implements PConstants { public int width, height; - protected PApplet parent; // The Processing applet - protected PGraphicsOpenGL ogl; // The main renderer - protected PGL pgl; // The interface between Processing and OpenGL. - protected GLContext context; // The context that created this texture. + protected PApplet parent; // The Processing applet + protected PGraphicsOpenGL renderer; // The main renderer + protected PGL pgl; // The interface between Processing and OpenGL. + protected GLContext context; // The context that created this texture. // These are public but use at your own risk! public int glID; @@ -91,9 +91,9 @@ public class PTexture implements PConstants { public PTexture(PApplet parent, int width, int height, Object params) { this.parent = parent; - ogl = (PGraphicsOpenGL)parent.g; - pgl = ogl.pgl; - context = ogl.getContext(); + renderer = (PGraphicsOpenGL)parent.g; + pgl = renderer.pgl; + context = renderer.getContext(); glID = 0; @@ -104,7 +104,7 @@ public class PTexture implements PConstants { protected void finalize() throws Throwable { try { if (glID != 0) { - ogl.finalizeTextureObject(glID); + renderer.finalizeTextureObject(glID); } } finally { super.finalize(); @@ -190,13 +190,13 @@ public class PTexture implements PConstants { public void set(PImage img) { - PTexture tex = (PTexture)img.getCache(ogl); + PTexture tex = (PTexture)img.getCache(renderer); set(tex); } public void set(PImage img, int x, int y, int w, int h) { - PTexture tex = (PTexture)img.getCache(ogl); + PTexture tex = (PTexture)img.getCache(renderer); set(tex, x, y, w, h); } @@ -239,8 +239,6 @@ public class PTexture implements PConstants { pgl.enableTexturing(glTarget); pgl.bindTexture(glTarget, glID); -// getGl().glEnable(glTarget); -// getGl().glBindTexture(glTarget, glID); if (usingMipmaps) { if (PGraphicsOpenGL.mipmapGeneration) { @@ -262,8 +260,6 @@ public class PTexture implements PConstants { rgbaPixels = null; } -// getGl().glBindTexture(glTarget, 0); -// getGl().glDisable(glTarget); pgl.bindTexture(glTarget, 0); pgl.disableTexturing(glTarget); } @@ -294,18 +290,18 @@ public class PTexture implements PConstants { // Attaching the texture to the color buffer of a FBO, binding the FBO and reading the pixels // from the current draw buffer (which is the color buffer of the FBO). tempFbo.setColorBuffer(this); - ogl.pushFramebuffer(); - ogl.setFramebuffer(tempFbo); + renderer.pushFramebuffer(); + renderer.setFramebuffer(tempFbo); tempFbo.readPixels(); - ogl.popFramebuffer(); + renderer.popFramebuffer(); } else { // Here we don't have FBOs, so the method above is of no use. What we do instead is // to draw the texture to the screen framebuffer, and then grab the pixels from there. - ogl.pushFramebuffer(); - ogl.setFramebuffer(tempFbo); - ogl.drawTexture(this, 0, 0, glWidth, glHeight, 0, 0, glWidth, glHeight); + renderer.pushFramebuffer(); + renderer.setFramebuffer(tempFbo); + renderer.drawTexture(this, 0, 0, glWidth, glHeight, 0, 0, glWidth, glHeight); tempFbo.readPixels(); - ogl.popFramebuffer(); + renderer.popFramebuffer(); } if (tempPixels == null) { @@ -408,15 +404,11 @@ public class PTexture implements PConstants { public void bind() { pgl.enableTexturing(glTarget); pgl.bindTexture(glTarget, glID); -// getGl().glEnable(glTarget); -// getGl().glBindTexture(glTarget, glID); } public void unbind() { pgl.enableTexturing(glTarget); pgl.unbindTexture(glTarget); -// getGl().glEnable(glTarget); -// getGl().glBindTexture(glTarget, 0); } //////////////////////////////////////////////////////////// @@ -705,16 +697,10 @@ public class PTexture implements PConstants { protected void allocate() { release(); // Just in the case this object is being re-allocated. -// getGl().glEnable(glTarget); pgl.enableTexturing(glTarget); - glID = ogl.createTextureObject(); + glID = renderer.createTextureObject(); - //getGl().glBindTexture(glTarget, glID); -// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_MIN_FILTER, glMinFilter); -// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_MAG_FILTER, glMagFilter); -// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_WRAP_S, glWrapS); -// getGl().glTexParameteri(glTarget, GL.GL_TEXTURE_WRAP_T, glWrapT); pgl.bindTexture(glTarget, glID); pgl.setTexMinFilter(glTarget, glMinFilter); pgl.setTexMagFilter(glTarget, glMagFilter); @@ -723,7 +709,6 @@ public class PTexture implements PConstants { // First, we use glTexImage2D to set the full size of the texture (glW/glH might be diff // from w/h in the case that the GPU doesn't support NPOT textures) -// pgl.gl.glTexImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null); pgl.initTex(glTarget, glFormat, glWidth, glHeight); // Once OpenGL knows the size of the new texture, we make sure it doesn't @@ -732,8 +717,6 @@ public class PTexture implements PConstants { setTexels(0, 0, width, height, texels); texels = null; -// getGl().glBindTexture(glTarget, 0); -// getGl().glDisable(glTarget); pgl.unbindTexture(glTarget); pgl.disableTexturing(glTarget); } @@ -744,7 +727,7 @@ public class PTexture implements PConstants { */ protected void release() { if (glID != 0) { - ogl.finalizeTextureObject(glID); + renderer.finalizeTextureObject(glID); glID = 0; } } @@ -770,19 +753,19 @@ public class PTexture implements PConstants { tempFbo.disableDepthTest(); // FBO copy: - ogl.pushFramebuffer(); - ogl.setFramebuffer(tempFbo); + renderer.pushFramebuffer(); + renderer.setFramebuffer(tempFbo); if (scale) { // Rendering tex into "this", and scaling the source rectangle // to cover the entire destination region. - ogl.drawTexture(tex, x, y, w, h, 0, 0, width, height); + renderer.drawTexture(tex, x, y, w, h, 0, 0, width, height); } else { // Rendering tex into "this" but without scaling so the contents // of the source texture fall in the corresponding texels of the // destination. - ogl.drawTexture(tex, x, y, w, h, x, y, w, h); + renderer.drawTexture(tex, x, y, w, h, x, y, w, h); } - ogl.popFramebuffer(); + renderer.popFramebuffer(); } protected void setTexels(int x, int y, int w, int h, int[] pix) { @@ -803,7 +786,7 @@ public class PTexture implements PConstants { height = src.height; parent = src.parent; - ogl = src.ogl; + renderer = src.renderer; glID = src.glID; glTarget = src.glTarget; @@ -923,13 +906,6 @@ public class PTexture implements PConstants { flippedY = false; } - /////////////////////////////////////////////////////////////////////////// - - // Utilities - -// protected GL getGl() { -// return ogl.pgl.gl; -// } ///////////////////////////////////////////////////////////////////////////