From dd8045298f100d02659e239241dec5634caab507 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Tue, 14 Aug 2012 17:39:33 +0000 Subject: [PATCH] PGL update in android --- .../src/processing/opengl/FrameBuffer.java | 76 +- android/core/src/processing/opengl/PGL.java | 740 +++++++++--------- .../processing/opengl/PGraphicsOpenGL.java | 599 +++++++------- .../core/src/processing/opengl/PShader.java | 136 ++-- .../src/processing/opengl/PShapeOpenGL.java | 216 ++--- .../core/src/processing/opengl/Texture.java | 110 +-- core/src/processing/opengl/PGL.java | 164 ++-- .../processing/opengl/PGraphicsOpenGL.java | 5 - 8 files changed, 1009 insertions(+), 1037 deletions(-) diff --git a/android/core/src/processing/opengl/FrameBuffer.java b/android/core/src/processing/opengl/FrameBuffer.java index c28cd3489..e63c638df 100644 --- a/android/core/src/processing/opengl/FrameBuffer.java +++ b/android/core/src/processing/opengl/FrameBuffer.java @@ -166,23 +166,23 @@ public class FrameBuffer implements PConstants { public void clear() { pg.pushFramebuffer(); pg.setFramebuffer(this); - pgl.glClearDepth(1); - pgl.glClearStencil(0); - pgl.glClearColor(0, 0, 0, 0); - pgl.glClear(PGL.GL_DEPTH_BUFFER_BIT | PGL.GL_STENCIL_BUFFER_BIT | PGL.GL_COLOR_BUFFER_BIT); + pgl.clearDepth(1); + pgl.clearStencil(0); + pgl.clearColor(0, 0, 0, 0); + pgl.clear(PGL.DEPTH_BUFFER_BIT | PGL.STENCIL_BUFFER_BIT | PGL.COLOR_BUFFER_BIT); pg.popFramebuffer(); } public void copy(FrameBuffer dest) { - pgl.glBindFramebuffer(PGL.GL_READ_FRAMEBUFFER, this.glFbo); - pgl.glBindFramebuffer(PGL.GL_DRAW_FRAMEBUFFER, dest.glFbo); - pgl.glBlitFramebuffer(0, 0, this.width, this.height, + pgl.bindFramebuffer(PGL.READ_FRAMEBUFFER, this.glFbo); + pgl.bindFramebuffer(PGL.DRAW_FRAMEBUFFER, dest.glFbo); + pgl.blitFramebuffer(0, 0, this.width, this.height, 0, 0, dest.width, dest.height, - PGL.GL_COLOR_BUFFER_BIT, PGL.GL_NEAREST); + PGL.COLOR_BUFFER_BIT, PGL.NEAREST); } public void bind() { - pgl.glBindFramebuffer(PGL.GL_FRAMEBUFFER, glFbo); + pgl.bindFramebuffer(PGL.FRAMEBUFFER, glFbo); } public void disableDepthTest() { @@ -193,9 +193,9 @@ public class FrameBuffer implements PConstants { if (noDepth) { // No need to clear depth buffer because depth testing was disabled. if (pg.hintEnabled(ENABLE_DEPTH_TEST)) { - pgl.glEnable(PGL.GL_DEPTH_TEST); + pgl.enable(PGL.DEPTH_TEST); } else { - pgl.glDisable(PGL.GL_DEPTH_TEST); + pgl.disable(PGL.DEPTH_TEST); } } } @@ -203,7 +203,7 @@ public class FrameBuffer implements PConstants { public void readPixels() { if (pixelBuffer == null) createPixelBuffer(); pixelBuffer.rewind(); - pgl.glReadPixels(0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixelBuffer); + pgl.readPixels(0, 0, width, height, PGL.RGBA, PGL.UNSIGNED_BYTE, pixelBuffer); } public void getPixels(int[] pixels) { @@ -256,11 +256,11 @@ public class FrameBuffer implements PConstants { // Making sure nothing is attached. for (int i = 0; i < numColorBuffers; i++) { - pgl.glFramebufferTexture2D(PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0 + i, PGL.GL_TEXTURE_2D, 0, 0); + pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i, PGL.TEXTURE_2D, 0, 0); } for (int i = 0; i < numColorBuffers; i++) { - pgl.glFramebufferTexture2D(PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0 + i, colorBufferTex[i].glTarget, colorBufferTex[i].glName, 0); + pgl.framebufferTexture2D(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0 + i, colorBufferTex[i].glTarget, colorBufferTex[i].glName, 0); } pgl.validateFramebuffer(); @@ -357,9 +357,9 @@ public class FrameBuffer implements PConstants { pg.setFramebuffer(this); glMultisample = pg.createRenderBufferObject(context.code()); - pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glMultisample); - pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, PGL.GL_RGBA8, width, height); - pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0, PGL.GL_RENDERBUFFER, glMultisample); + pgl.bindRenderbuffer(PGL.RENDERBUFFER, glMultisample); + pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, PGL.RGBA8, width, height); + pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.COLOR_ATTACHMENT0, PGL.RENDERBUFFER, glMultisample); pg.popFramebuffer(); } @@ -376,16 +376,16 @@ public class FrameBuffer implements PConstants { pg.setFramebuffer(this); glDepthStencil = pg.createRenderBufferObject(context.code()); - pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glDepthStencil); + pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepthStencil); if (multisample) { - pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, PGL.GL_DEPTH24_STENCIL8, width, height); + pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, PGL.DEPTH24_STENCIL8, width, height); } else { - pgl.glRenderbufferStorage(PGL.GL_RENDERBUFFER, PGL.GL_DEPTH24_STENCIL8, width, height); + pgl.renderbufferStorage(PGL.RENDERBUFFER, PGL.DEPTH24_STENCIL8, width, height); } - pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_DEPTH_ATTACHMENT, PGL.GL_RENDERBUFFER, glDepthStencil); - pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_STENCIL_ATTACHMENT, PGL.GL_RENDERBUFFER, glDepthStencil); + pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT, PGL.RENDERBUFFER, glDepthStencil); + pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT, PGL.RENDERBUFFER, glDepthStencil); pg.popFramebuffer(); } @@ -402,24 +402,24 @@ public class FrameBuffer implements PConstants { pg.setFramebuffer(this); glDepth = pg.createRenderBufferObject(context.code()); - pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glDepth); + pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth); - int glConst = PGL.GL_DEPTH_COMPONENT16; + int glConst = PGL.DEPTH_COMPONENT16; if (depthBits == 16) { - glConst = PGL.GL_DEPTH_COMPONENT16; + glConst = PGL.DEPTH_COMPONENT16; } else if (depthBits == 24) { - glConst = PGL.GL_DEPTH_COMPONENT24; + glConst = PGL.DEPTH_COMPONENT24; } else if (depthBits == 32) { - glConst = PGL.GL_DEPTH_COMPONENT32; + glConst = PGL.DEPTH_COMPONENT32; } if (multisample) { - pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, glConst, width, height); + pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst, width, height); } else { - pgl.glRenderbufferStorage(PGL.GL_RENDERBUFFER, glConst, width, height); + pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height); } - pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_DEPTH_ATTACHMENT, PGL.GL_RENDERBUFFER, glDepth); + pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.DEPTH_ATTACHMENT, PGL.RENDERBUFFER, glDepth); pg.popFramebuffer(); } @@ -436,23 +436,23 @@ public class FrameBuffer implements PConstants { pg.setFramebuffer(this); glStencil = pg.createRenderBufferObject(context.code()); - pgl.glBindRenderbuffer(PGL.GL_RENDERBUFFER, glStencil); + pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil); - int glConst = PGL.GL_STENCIL_INDEX1; + int glConst = PGL.STENCIL_INDEX1; if (stencilBits == 1) { - glConst = PGL.GL_STENCIL_INDEX1; + glConst = PGL.STENCIL_INDEX1; } else if (stencilBits == 4) { - glConst = PGL.GL_STENCIL_INDEX4; + glConst = PGL.STENCIL_INDEX4; } else if (stencilBits == 8) { - glConst = PGL.GL_STENCIL_INDEX8; + glConst = PGL.STENCIL_INDEX8; } if (multisample) { - pgl.glRenderbufferStorageMultisample(PGL.GL_RENDERBUFFER, nsamples, glConst, width, height); + pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst, width, height); } else { - pgl.glRenderbufferStorage(PGL.GL_RENDERBUFFER, glConst, width, height); + pgl.renderbufferStorage(PGL.RENDERBUFFER, glConst, width, height); } - pgl.glFramebufferRenderbuffer(PGL.GL_FRAMEBUFFER, PGL.GL_STENCIL_ATTACHMENT, PGL.GL_RENDERBUFFER, glStencil); + pgl.framebufferRenderbuffer(PGL.FRAMEBUFFER, PGL.STENCIL_ATTACHMENT, PGL.RENDERBUFFER, glStencil); pg.popFramebuffer(); } diff --git a/android/core/src/processing/opengl/PGL.java b/android/core/src/processing/opengl/PGL.java index a3a21035f..8261a8027 100644 --- a/android/core/src/processing/opengl/PGL.java +++ b/android/core/src/processing/opengl/PGL.java @@ -53,39 +53,39 @@ import android.opengl.GLU; */ public class PGL { /** Size of a short (in bytes). */ - public static final int SIZEOF_SHORT = Short.SIZE / 8; + protected static final int SIZEOF_SHORT = Short.SIZE / 8; /** Size of an int (in bytes). */ - public static final int SIZEOF_INT = Integer.SIZE / 8; + protected static final int SIZEOF_INT = Integer.SIZE / 8; /** Size of a float (in bytes). */ - public static final int SIZEOF_FLOAT = Float.SIZE / 8; + protected static final int SIZEOF_FLOAT = Float.SIZE / 8; /** Size of a byte (in bytes). */ - public static final int SIZEOF_BYTE = Byte.SIZE / 8; + protected static final int SIZEOF_BYTE = Byte.SIZE / 8; /** Size of a vertex index. */ - public static final int SIZEOF_INDEX = SIZEOF_SHORT; + protected static final int SIZEOF_INDEX = SIZEOF_SHORT; /** Type of a vertex index. */ - public static final int INDEX_TYPE = GLES20.GL_UNSIGNED_SHORT; + protected static final int INDEX_TYPE = GLES20.GL_UNSIGNED_SHORT; /** Initial sizes for arrays of input and tessellated data. */ - public static final int DEFAULT_IN_VERTICES = 16; - public static final int DEFAULT_IN_EDGES = 32; - public static final int DEFAULT_IN_TEXTURES = 16; - public static final int DEFAULT_TESS_VERTICES = 16; - public static final int DEFAULT_TESS_INDICES = 32; + protected static final int DEFAULT_IN_VERTICES = 16; + protected static final int DEFAULT_IN_EDGES = 32; + protected static final int DEFAULT_IN_TEXTURES = 16; + protected static final int DEFAULT_TESS_VERTICES = 16; + protected static final int DEFAULT_TESS_INDICES = 32; /** Maximum lights by default is 8, the minimum defined by OpenGL. */ - public static final int MAX_LIGHTS = 8; + protected static final int MAX_LIGHTS = 8; /** Maximum index value of a tessellated vertex. GLES restricts the vertex * indices to be of type unsigned short. Since Java only supports signed * shorts as primitive type we have 2^15 = 32768 as the maximum number of * vertices that can be referred to within a single VBO. */ - public static final int MAX_VERTEX_INDEX = 32767; - public static final int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1; + protected static final int MAX_VERTEX_INDEX = 32767; + protected static final int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1; /** Count of tessellated fill, line or point vertices that will * trigger a flush in the immediate mode. It doesn't necessarily @@ -93,20 +93,20 @@ public class PGL { * be effectively much large since the renderer uses offsets to * refer to vertices beyond the MAX_VERTEX_INDEX limit. */ - public static final int FLUSH_VERTEX_COUNT = MAX_VERTEX_INDEX1; + protected static final int FLUSH_VERTEX_COUNT = MAX_VERTEX_INDEX1; /** Maximum dimension of a texture used to hold font data. **/ - public static final int MAX_FONT_TEX_SIZE = 512; + protected static final int MAX_FONT_TEX_SIZE = 512; /** Minimum stroke weight needed to apply the full path stroking * algorithm that properly generates caps and joing. */ - public static final float MIN_CAPS_JOINS_WEIGHT = 2.f; + protected static final float MIN_CAPS_JOINS_WEIGHT = 2.f; /** Maximum length of linear paths to be stroked with the * full algorithm that generates accurate caps and joins. */ - public static final int MAX_CAPS_JOINS_LENGTH = 1000; + protected static final int MAX_CAPS_JOINS_LENGTH = 1000; /** Minimum array size to use arrayCopy method(). **/ protected static final int MIN_ARRAYCOPY_SIZE = 2; @@ -115,7 +115,7 @@ public class PGL { protected static final boolean MIPMAPS_ENABLED = false; /** Machine Epsilon for float precision. **/ - public static float FLOAT_EPS = Float.MIN_VALUE; + protected static float FLOAT_EPS = Float.MIN_VALUE; // Calculation of the Machine Epsilon for float precision. From: // http://en.wikipedia.org/wiki/Machine_epsilon#Approximation_using_Java static { @@ -132,7 +132,7 @@ public class PGL { * Set to true if the host system is big endian (PowerPC, MIPS, SPARC), false * if little endian (x86 Intel for Mac or PC). */ - public static boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; + protected static boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; protected static final String SHADER_PREPROCESSOR_DIRECTIVE = "#ifdef GL_ES\n" + "precision mediump float;\n" + @@ -146,157 +146,157 @@ public class PGL { // The values for constants not defined in the GLES20 interface can be found in this file: // http://androidxref.com/source/raw/development/tools/glesv2debugger/src/com/android/glesv2debugger/GLEnum.java - public static final int GL_FALSE = GLES20.GL_FALSE; - public static final int GL_TRUE = GLES20.GL_TRUE; + public static final int FALSE = GLES20.GL_FALSE; + public static final int TRUE = GLES20.GL_TRUE; - public static final int GL_LESS = GLES20.GL_LESS; - public static final int GL_LEQUAL = GLES20.GL_LEQUAL; + public static final int LESS = GLES20.GL_LESS; + public static final int LEQUAL = GLES20.GL_LEQUAL; - public static final int GL_CCW = GLES20.GL_CCW; - public static final int GL_CW = GLES20.GL_CW; + public static final int CCW = GLES20.GL_CCW; + public static final int CW = GLES20.GL_CW; - public static final int GL_CULL_FACE = GLES20.GL_CULL_FACE; - public static final int GL_FRONT = GLES20.GL_FRONT; - public static final int GL_BACK = GLES20.GL_BACK; - public static final int GL_FRONT_AND_BACK = GLES20.GL_FRONT_AND_BACK; + public static final int CULL_FACE = GLES20.GL_CULL_FACE; + public static final int FRONT = GLES20.GL_FRONT; + public static final int BACK = GLES20.GL_BACK; + public static final int FRONT_AND_BACK = GLES20.GL_FRONT_AND_BACK; - public static final int GL_VIEWPORT = GLES20.GL_VIEWPORT; + public static final int VIEWPORT = GLES20.GL_VIEWPORT; - public static final int GL_SCISSOR_TEST = GLES20.GL_SCISSOR_TEST; - public static final int GL_DEPTH_TEST = GLES20.GL_DEPTH_TEST; - public static final int GL_DEPTH_WRITEMASK = GLES20.GL_DEPTH_WRITEMASK; + public static final int SCISSOR_TEST = GLES20.GL_SCISSOR_TEST; + public static final int DEPTH_TEST = GLES20.GL_DEPTH_TEST; + public static final int DEPTH_WRITEMASK = GLES20.GL_DEPTH_WRITEMASK; - public static final int GL_COLOR_BUFFER_BIT = GLES20.GL_COLOR_BUFFER_BIT; - public static final int GL_DEPTH_BUFFER_BIT = GLES20.GL_DEPTH_BUFFER_BIT; - public static final int GL_STENCIL_BUFFER_BIT = GLES20.GL_STENCIL_BUFFER_BIT; + public static final int COLOR_BUFFER_BIT = GLES20.GL_COLOR_BUFFER_BIT; + public static final int DEPTH_BUFFER_BIT = GLES20.GL_DEPTH_BUFFER_BIT; + public static final int STENCIL_BUFFER_BIT = GLES20.GL_STENCIL_BUFFER_BIT; - public static final int GL_FUNC_ADD = GLES20.GL_FUNC_ADD; - public static final int GL_FUNC_MIN = 0x8007; - public static final int GL_FUNC_MAX = 0x8008; - public static final int GL_FUNC_REVERSE_SUBTRACT = GLES20.GL_FUNC_REVERSE_SUBTRACT; + public static final int FUNC_ADD = GLES20.GL_FUNC_ADD; + public static final int FUNC_MIN = 0x8007; + public static final int FUNC_MAX = 0x8008; + public static final int FUNC_REVERSE_SUBTRACT = GLES20.GL_FUNC_REVERSE_SUBTRACT; - public static final int GL_TEXTURE_2D = GLES20.GL_TEXTURE_2D; + public static final int TEXTURE_2D = GLES20.GL_TEXTURE_2D; - public static final int GL_TEXTURE_BINDING_2D = GLES20.GL_TEXTURE_BINDING_2D; + public static final int TEXTURE_BINDING_2D = GLES20.GL_TEXTURE_BINDING_2D; - public static final int GL_RGB = GLES20.GL_RGB; - public static final int GL_RGBA = GLES20.GL_RGBA; - public static final int GL_ALPHA = GLES20.GL_ALPHA; - public static final int GL_UNSIGNED_INT = GLES20.GL_UNSIGNED_INT; - public static final int GL_UNSIGNED_BYTE = GLES20.GL_UNSIGNED_BYTE; - public static final int GL_UNSIGNED_SHORT = GLES20.GL_UNSIGNED_SHORT; - public static final int GL_FLOAT = GLES20.GL_FLOAT; + public static final int RGB = GLES20.GL_RGB; + public static final int RGBA = GLES20.GL_RGBA; + public static final int ALPHA = GLES20.GL_ALPHA; + public static final int UNSIGNED_INT = GLES20.GL_UNSIGNED_INT; + public static final int UNSIGNED_BYTE = GLES20.GL_UNSIGNED_BYTE; + public static final int UNSIGNED_SHORT = GLES20.GL_UNSIGNED_SHORT; + public static final int FLOAT = GLES20.GL_FLOAT; - public static final int GL_NEAREST = GLES20.GL_NEAREST; - public static final int GL_LINEAR = GLES20.GL_LINEAR; - public static final int GL_LINEAR_MIPMAP_NEAREST = GLES20.GL_LINEAR_MIPMAP_NEAREST; - public static final int GL_LINEAR_MIPMAP_LINEAR = GLES20.GL_LINEAR_MIPMAP_LINEAR; + public static final int NEAREST = GLES20.GL_NEAREST; + public static final int LINEAR = GLES20.GL_LINEAR; + public static final int LINEAR_MIPMAP_NEAREST = GLES20.GL_LINEAR_MIPMAP_NEAREST; + public static final int LINEAR_MIPMAP_LINEAR = GLES20.GL_LINEAR_MIPMAP_LINEAR; - public static final int GL_CLAMP_TO_EDGE = GLES20.GL_CLAMP_TO_EDGE; - public static final int GL_REPEAT = GLES20.GL_REPEAT; + public static final int CLAMP_TO_EDGE = GLES20.GL_CLAMP_TO_EDGE; + public static final int REPEAT = GLES20.GL_REPEAT; - public static final int GL_RGBA8 = -1; - public static final int GL_DEPTH24_STENCIL8 = 0x88F0; + public static final int RGBA8 = -1; + public static final int DEPTH24_STENCIL8 = 0x88F0; - public static final int GL_DEPTH_COMPONENT = GLES20.GL_DEPTH_COMPONENT; - public static final int GL_DEPTH_COMPONENT16 = GLES20.GL_DEPTH_COMPONENT16; - public static final int GL_DEPTH_COMPONENT24 = 0x81A6; - public static final int GL_DEPTH_COMPONENT32 = 0x81A7; + public static final int DEPTH_COMPONENT = GLES20.GL_DEPTH_COMPONENT; + public static final int DEPTH_COMPONENT16 = GLES20.GL_DEPTH_COMPONENT16; + public static final int DEPTH_COMPONENT24 = 0x81A6; + public static final int DEPTH_COMPONENT32 = 0x81A7; - public static final int GL_STENCIL_INDEX = GLES20.GL_STENCIL_INDEX; - public static final int GL_STENCIL_INDEX1 = 0x8D46; - public static final int GL_STENCIL_INDEX4 = 0x8D47; - public static final int GL_STENCIL_INDEX8 = GLES20.GL_STENCIL_INDEX8; + public static final int STENCIL_INDEX = GLES20.GL_STENCIL_INDEX; + public static final int STENCIL_INDEX1 = 0x8D46; + public static final int STENCIL_INDEX4 = 0x8D47; + public static final int STENCIL_INDEX8 = GLES20.GL_STENCIL_INDEX8; - public static final int GL_ARRAY_BUFFER = GLES20.GL_ARRAY_BUFFER; - public static final int GL_ELEMENT_ARRAY_BUFFER = GLES20.GL_ELEMENT_ARRAY_BUFFER; + public static final int ARRAY_BUFFER = GLES20.GL_ARRAY_BUFFER; + public static final int ELEMENT_ARRAY_BUFFER = GLES20.GL_ELEMENT_ARRAY_BUFFER; - public static final int GL_SAMPLES = GLES20.GL_SAMPLES; + public static final int SAMPLES = GLES20.GL_SAMPLES; - public static final int GL_FRAMEBUFFER_COMPLETE = GLES20.GL_FRAMEBUFFER_COMPLETE; - public static final int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GLES20.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - public static final int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GLES20.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; - public static final int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GLES20.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; - public static final int GL_FRAMEBUFFER_INCOMPLETE_FORMATS = 0x8CDA; - public static final int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = -1; - public static final int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER = -1; - public static final int GL_FRAMEBUFFER_UNSUPPORTED = GLES20.GL_FRAMEBUFFER_UNSUPPORTED; + public static final int FRAMEBUFFER_COMPLETE = GLES20.GL_FRAMEBUFFER_COMPLETE; + public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GLES20.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GLES20.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GLES20.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; + public static final int FRAMEBUFFER_INCOMPLETE_FORMATS = 0x8CDA; + public static final int FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = -1; + public static final int FRAMEBUFFER_INCOMPLETE_READ_BUFFER = -1; + public static final int FRAMEBUFFER_UNSUPPORTED = GLES20.GL_FRAMEBUFFER_UNSUPPORTED; - public static final int GL_STATIC_DRAW = GLES20.GL_STATIC_DRAW; - public static final int GL_DYNAMIC_DRAW = GLES20.GL_DYNAMIC_DRAW; - public static final int GL_STREAM_DRAW = GLES20.GL_STREAM_DRAW; + public static final int STATIC_DRAW = GLES20.GL_STATIC_DRAW; + public static final int DYNAMIC_DRAW = GLES20.GL_DYNAMIC_DRAW; + public static final int STREAM_DRAW = GLES20.GL_STREAM_DRAW; - public static final int GL_READ_ONLY = -1; - public static final int GL_WRITE_ONLY = -1; - public static final int GL_READ_WRITE = -1; + public static final int READ_ONLY = -1; + public static final int WRITE_ONLY = -1; + public static final int READ_WRITE = -1; - public static final int GL_TRIANGLE_FAN = GLES20.GL_TRIANGLE_FAN; - public static final int GL_TRIANGLE_STRIP = GLES20.GL_TRIANGLE_STRIP; - public static final int GL_TRIANGLES = GLES20.GL_TRIANGLES; + public static final int TRIANGLE_FAN = GLES20.GL_TRIANGLE_FAN; + public static final int TRIANGLE_STRIP = GLES20.GL_TRIANGLE_STRIP; + public static final int TRIANGLES = GLES20.GL_TRIANGLES; - public static final int GL_VENDOR = GLES20.GL_VENDOR; - public static final int GL_RENDERER = GLES20.GL_RENDERER; - public static final int GL_VERSION = GLES20.GL_VERSION; - public static final int GL_EXTENSIONS = GLES20.GL_EXTENSIONS; - public static final int GL_SHADING_LANGUAGE_VERSION = GLES20.GL_SHADING_LANGUAGE_VERSION; + public static final int VENDOR = GLES20.GL_VENDOR; + public static final int RENDERER = GLES20.GL_RENDERER; + public static final int VERSION = GLES20.GL_VERSION; + public static final int EXTENSIONS = GLES20.GL_EXTENSIONS; + public static final int SHADING_LANGUAGE_VERSION = GLES20.GL_SHADING_LANGUAGE_VERSION; - public static final int GL_MAX_TEXTURE_SIZE = GLES20.GL_MAX_TEXTURE_SIZE; - public static final int GL_MAX_SAMPLES = -1; - public static final int GL_ALIASED_LINE_WIDTH_RANGE = GLES20.GL_ALIASED_LINE_WIDTH_RANGE; - public static final int GL_ALIASED_POINT_SIZE_RANGE = GLES20.GL_ALIASED_POINT_SIZE_RANGE; - public static final int GL_DEPTH_BITS = GLES20.GL_DEPTH_BITS; - public static final int GL_STENCIL_BITS = GLES20.GL_STENCIL_BITS; + public static final int MAX_TEXTURE_SIZE = GLES20.GL_MAX_TEXTURE_SIZE; + public static final int MAX_SAMPLES = -1; + public static final int ALIASED_LINE_WIDTH_RANGE = GLES20.GL_ALIASED_LINE_WIDTH_RANGE; + public static final int ALIASED_POINT_SIZE_RANGE = GLES20.GL_ALIASED_POINT_SIZE_RANGE; + public static final int DEPTH_BITS = GLES20.GL_DEPTH_BITS; + public static final int STENCIL_BITS = GLES20.GL_STENCIL_BITS; - public static final int GLU_TESS_WINDING_NONZERO = PGLU.GLU_TESS_WINDING_NONZERO; - public static final int GLU_TESS_WINDING_ODD = PGLU.GLU_TESS_WINDING_ODD; + public static final int TESS_WINDING_NONZERO = PGLU.GLU_TESS_WINDING_NONZERO; + public static final int TESS_WINDING_ODD = PGLU.GLU_TESS_WINDING_ODD; - public static final int GL_TEXTURE0 = GLES20.GL_TEXTURE0; - public static final int GL_TEXTURE1 = GLES20.GL_TEXTURE1; - public static final int GL_TEXTURE2 = GLES20.GL_TEXTURE2; - public static final int GL_TEXTURE3 = GLES20.GL_TEXTURE3; - public static final int GL_TEXTURE_MIN_FILTER = GLES20.GL_TEXTURE_MIN_FILTER; - public static final int GL_TEXTURE_MAG_FILTER = GLES20.GL_TEXTURE_MAG_FILTER; - public static final int GL_TEXTURE_WRAP_S = GLES20.GL_TEXTURE_WRAP_S; - public static final int GL_TEXTURE_WRAP_T = GLES20.GL_TEXTURE_WRAP_T; + public static final int TEXTURE0 = GLES20.GL_TEXTURE0; + public static final int TEXTURE1 = GLES20.GL_TEXTURE1; + public static final int TEXTURE2 = GLES20.GL_TEXTURE2; + public static final int TEXTURE3 = GLES20.GL_TEXTURE3; + public static final int TEXTURE_MIN_FILTER = GLES20.GL_TEXTURE_MIN_FILTER; + public static final int TEXTURE_MAG_FILTER = GLES20.GL_TEXTURE_MAG_FILTER; + public static final int TEXTURE_WRAP_S = GLES20.GL_TEXTURE_WRAP_S; + public static final int TEXTURE_WRAP_T = GLES20.GL_TEXTURE_WRAP_T; - public static final int GL_BLEND = GLES20.GL_BLEND; - public static final int GL_ONE = GLES20.GL_ONE; - public static final int GL_ZERO = GLES20.GL_ZERO; - public static final int GL_SRC_ALPHA = GLES20.GL_SRC_ALPHA; - public static final int GL_DST_ALPHA = GLES20.GL_DST_ALPHA; - public static final int GL_ONE_MINUS_SRC_ALPHA = GLES20.GL_ONE_MINUS_SRC_ALPHA; - public static final int GL_ONE_MINUS_DST_COLOR = GLES20.GL_ONE_MINUS_DST_COLOR; - public static final int GL_ONE_MINUS_SRC_COLOR = GLES20.GL_ONE_MINUS_SRC_COLOR; - public static final int GL_DST_COLOR = GLES20.GL_DST_COLOR; - public static final int GL_SRC_COLOR = GLES20.GL_SRC_COLOR; + public static final int BLEND = GLES20.GL_BLEND; + public static final int ONE = GLES20.GL_ONE; + public static final int ZERO = GLES20.GL_ZERO; + public static final int SRC_ALPHA = GLES20.GL_SRC_ALPHA; + public static final int DST_ALPHA = GLES20.GL_DST_ALPHA; + public static final int ONE_MINUS_SRC_ALPHA = GLES20.GL_ONE_MINUS_SRC_ALPHA; + public static final int ONE_MINUS_DST_COLOR = GLES20.GL_ONE_MINUS_DST_COLOR; + public static final int ONE_MINUS_SRC_COLOR = GLES20.GL_ONE_MINUS_SRC_COLOR; + public static final int DST_COLOR = GLES20.GL_DST_COLOR; + public static final int SRC_COLOR = GLES20.GL_SRC_COLOR; - public static final int GL_FRAMEBUFFER = GLES20.GL_FRAMEBUFFER; - public static final int GL_COLOR_ATTACHMENT0 = GLES20.GL_COLOR_ATTACHMENT0; - public static final int GL_COLOR_ATTACHMENT1 = -1; - public static final int GL_COLOR_ATTACHMENT2 = -1; - public static final int GL_COLOR_ATTACHMENT3 = -1; - public static final int GL_RENDERBUFFER = GLES20.GL_RENDERBUFFER; - public static final int GL_DEPTH_ATTACHMENT = GLES20.GL_DEPTH_ATTACHMENT; - public static final int GL_STENCIL_ATTACHMENT = GLES20.GL_STENCIL_ATTACHMENT; - public static final int GL_READ_FRAMEBUFFER = -1; - public static final int GL_DRAW_FRAMEBUFFER = -1; + public static final int FRAMEBUFFER = GLES20.GL_FRAMEBUFFER; + public static final int COLOR_ATTACHMENT0 = GLES20.GL_COLOR_ATTACHMENT0; + public static final int COLOR_ATTACHMENT1 = -1; + public static final int COLOR_ATTACHMENT2 = -1; + public static final int COLOR_ATTACHMENT3 = -1; + public static final int RENDERBUFFER = GLES20.GL_RENDERBUFFER; + public static final int DEPTH_ATTACHMENT = GLES20.GL_DEPTH_ATTACHMENT; + public static final int STENCIL_ATTACHMENT = GLES20.GL_STENCIL_ATTACHMENT; + public static final int READ_FRAMEBUFFER = -1; + public static final int DRAW_FRAMEBUFFER = -1; - public static final int GL_VERTEX_SHADER = GLES20.GL_VERTEX_SHADER; - public static final int GL_FRAGMENT_SHADER = GLES20.GL_FRAGMENT_SHADER; - public static final int GL_INFO_LOG_LENGTH = GLES20.GL_INFO_LOG_LENGTH; - public static final int GL_SHADER_SOURCE_LENGTH = GLES20.GL_SHADER_SOURCE_LENGTH; - public static final int GL_COMPILE_STATUS = GLES20.GL_COMPILE_STATUS; - public static final int GL_LINK_STATUS = GLES20.GL_LINK_STATUS; - public static final int GL_VALIDATE_STATUS = GLES20.GL_VALIDATE_STATUS; + public static final int VERTEX_SHADER = GLES20.GL_VERTEX_SHADER; + public static final int FRAGMENT_SHADER = GLES20.GL_FRAGMENT_SHADER; + public static final int INFO_LOG_LENGTH = GLES20.GL_INFO_LOG_LENGTH; + public static final int SHADER_SOURCE_LENGTH = GLES20.GL_SHADER_SOURCE_LENGTH; + public static final int COMPILE_STATUS = GLES20.GL_COMPILE_STATUS; + public static final int LINK_STATUS = GLES20.GL_LINK_STATUS; + public static final int VALIDATE_STATUS = GLES20.GL_VALIDATE_STATUS; - public static final int GL_MULTISAMPLE = -1; - public static final int GL_POINT_SMOOTH = -1; - public static final int GL_LINE_SMOOTH = -1; - public static final int GL_POLYGON_SMOOTH = -1; + public static final int MULTISAMPLE = -1; + public static final int POINT_SMOOTH = -1; + public static final int LINE_SMOOTH = -1; + public static final int POLYGON_SMOOTH = -1; // Some EGL constants needed to initialize an GLES2 context. - public static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; - public static final int EGL_OPENGL_ES2_BIT = 0x0004; + protected static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098; + protected static final int EGL_OPENGL_ES2_BIT = 0x0004; /** Basic GLES 1.0 interface */ public GL10 gl; @@ -305,10 +305,10 @@ public class PGL { public PGLU glu; /** The PGraphics object using this interface */ - public PGraphicsOpenGL pg; + protected PGraphicsOpenGL pg; /** Whether OpenGL has been initialized or not */ - public boolean initialized; + protected boolean initialized; /** The renderer object driving the rendering loop, * analogous to the GLEventListener in JOGL */ @@ -324,7 +324,7 @@ public class PGL { // FBO for incremental drawing - public static final boolean FORCE_SCREEN_FBO = false; + protected static final boolean FORCE_SCREEN_FBO = false; protected boolean firstOnscreenFrame = true; protected int fboWidth, fboHeight; protected int backTex, frontTex; @@ -420,15 +420,11 @@ public class PGL { } - public void setFrameRate(float framerate) { + protected void setFrameRate(float framerate) { } - public void setToolkit(int toolkit) { - } - - - public void initPrimarySurface(int antialias) { + protected void initPrimarySurface(int antialias) { // We do the initialization in updatePrimary() because // at the moment initPrimarySurface() gets called we // cannot rely on the GL surface actually being @@ -436,12 +432,12 @@ public class PGL { } - public void initOffscreenSurface(PGL primary) { + protected void initOffscreenSurface(PGL primary) { initialized = true; } - public void updatePrimary() { + protected void updatePrimary() { if (!initialized) { String ext = GLES20.glGetString(GLES20.GL_EXTENSIONS); if (-1 < ext.indexOf("texture_non_power_of_two")) { @@ -464,8 +460,8 @@ public class PGL { GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); - GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, fboWidth, fboHeight, 0, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, null); - initTexture(GLES20.GL_TEXTURE_2D, PGL.GL_RGBA, fboWidth, fboHeight); + GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, fboWidth, fboHeight, 0, PGL.RGBA, PGL.UNSIGNED_BYTE, null); + initTexture(GLES20.GL_TEXTURE_2D, PGL.RGBA, fboWidth, fboHeight); } GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); @@ -477,7 +473,7 @@ public class PGL { int[] depthStencil = { 0 }; GLES20.glGenRenderbuffers(1, depthStencil, 0); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthStencil[0]); - GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, fboWidth, fboHeight); + GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, DEPTH24_STENCIL8, fboWidth, fboHeight); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthStencil[0]); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_STENCIL_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthStencil[0]); } else { // separate depth and stencil buffers @@ -510,42 +506,42 @@ public class PGL { } - public void updateOffscreen(PGL primary) { + protected void updateOffscreen(PGL primary) { gl = primary.gl; } - public boolean primaryIsDoubleBuffered() { + protected boolean primaryIsDoubleBuffered() { return PGraphicsOpenGL.screenFramebuffer.glFbo != 0; } - public boolean primaryIsFboBacked() { + protected boolean primaryIsFboBacked() { return PGraphicsOpenGL.screenFramebuffer.glFbo != 0; } - public int getFboTexTarget() { + protected int getFboTexTarget() { return GLES20.GL_TEXTURE_2D; } - public int getFboTexName() { + protected int getFboTexName() { return glColorTex[0]; } - public int getFboWidth() { + protected int getFboWidth() { return fboWidth; } - public int getFboHeight() { + protected int getFboHeight() { return fboHeight; } - public void bindPrimaryColorFBO() { + protected void bindPrimaryColorFBO() { GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, glColorFbo[0]); PGraphicsOpenGL.screenFramebuffer.glFbo = glColorFbo[0]; @@ -558,7 +554,7 @@ public class PGL { } - public void bindPrimaryMultiFBO() { + protected void bindPrimaryMultiFBO() { GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, glColorFbo[0]); PGraphicsOpenGL.screenFramebuffer.glFbo = glColorFbo[0]; } @@ -569,7 +565,7 @@ public class PGL { // Frame rendering - public void beginOnscreenDraw(boolean clear) { + protected void beginOnscreenDraw(boolean clear) { if (clear && !FORCE_SCREEN_FBO) { // Simplest scenario: clear mode means we clear both the color and depth buffers. // No need for saving front color buffer, etc. @@ -601,7 +597,7 @@ public class PGL { } - public void endOnscreenDraw(boolean clear0) { + protected void endOnscreenDraw(boolean clear0) { if (!clear0 || FORCE_SCREEN_FBO) { // We are in the primary surface, and no clear mode, this means that the current // contents of the front buffer needs to be used in the next frame as the background. @@ -623,20 +619,20 @@ public class PGL { } - public void beginOffscreenDraw(boolean clear) { + protected void beginOffscreenDraw(boolean clear) { } - public void endOffscreenDraw(boolean clear0) { + protected void endOffscreenDraw(boolean clear0) { } - public boolean canDraw() { + protected boolean canDraw() { return true; } - public void requestDraw() { + protected void requestDraw() { pg.parent.andresNeedsBetterAPI(); } @@ -646,12 +642,12 @@ public class PGL { // Caps query - public String glGetString(int name) { + public String getString(int name) { return GLES20.glGetString(name); } - public void glGetIntegerv(int name, int[] values, int offset) { + public void getIntegerv(int name, int[] values, int offset) { if (-1 < name) { GLES20.glGetIntegerv(name, values, offset); } else { @@ -660,7 +656,7 @@ public class PGL { } - public void glGetBooleanv(int name, boolean[] values, int offset) { + public void getBooleanv(int name, boolean[] values, int offset) { if (-1 < name) { GLES20.glGetBooleanv(name, values, offset); } else { @@ -674,14 +670,14 @@ public class PGL { // Enable/disable caps - public void glEnable(int cap) { + public void enable(int cap) { if (-1 < cap) { GLES20.glEnable(cap); } } - public void glDisable(int cap) { + public void disable(int cap) { if (-1 < cap) { GLES20.glDisable(cap); } @@ -693,12 +689,12 @@ public class PGL { // Render control - public void glFlush() { + public void flush() { GLES20.glFlush(); } - public void glFinish() { + public void finish() { GLES20.glFinish(); } @@ -708,19 +704,14 @@ public class PGL { // Error handling - public int glGetError() { + public int getError() { return GLES20.glGetError(); } - public String glErrorString(int err) { + public String errorString(int err) { return GLU.gluErrorString(err); } - - - public String gluErrorString(int err) { - return PGLU.gluErrorString(err); - } ///////////////////////////////////////////////////////////////////////////////// @@ -728,22 +719,22 @@ public class PGL { // Rendering options - public void glFrontFace(int mode) { + public void frontFace(int mode) { GLES20.glFrontFace(mode); } - public void glCullFace(int mode) { + public void cullFace(int mode) { GLES20.glCullFace(mode); } - public void glDepthMask(boolean flag) { + public void depthMask(boolean flag) { GLES20.glDepthMask(flag); } - public void glDepthFunc(int func) { + public void depthFunc(int func) { GLES20.glDepthFunc(func); } @@ -753,50 +744,50 @@ public class PGL { // Textures - public void glGenTextures(int n, int[] ids, int offset) { + public void genTextures(int n, int[] ids, int offset) { GLES20.glGenTextures(n, ids, offset); } - public void glDeleteTextures(int n, int[] ids, int offset) { + public void deleteTextures(int n, int[] ids, int offset) { GLES20.glDeleteTextures(n, ids, offset); } - public void glActiveTexture(int unit) { + public void activeTexture(int unit) { GLES20.glActiveTexture(unit); } - public void glBindTexture(int target, int id) { + public void bindTexture(int target, int id) { GLES20.glBindTexture(target, id); - if (target == GL_TEXTURE_2D) { + if (target == TEXTURE_2D) { boundTextures[0] = id; } } - public void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer data) { + public void texImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer data) { GLES20.glTexImage2D(target, level, internalFormat, width, height, border, format, type, data); } - public void glTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, Buffer data) { + public void texSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, Buffer data) { GLES20.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, data); } - public void glTexParameteri(int target, int param, int value) { + public void texParameteri(int target, int param, int value) { GLES20.glTexParameteri(target, param, value); } - public void glGetTexParameteriv(int target, int param, int[] values, int offset) { + public void getTexParameteriv(int target, int param, int[] values, int offset) { GLES20.glGetTexParameteriv(target, param, values, offset); } - public void glGenerateMipmap(int target) { + public void generateMipmap(int target) { GLES20.glGenerateMipmap(target); } @@ -806,74 +797,74 @@ public class PGL { // Vertex Buffers - public void glGenBuffers(int n, int[] ids, int offset) { + public void genBuffers(int n, int[] ids, int offset) { GLES20.glGenBuffers(n, ids, offset); } - public void glDeleteBuffers(int n, int[] ids, int offset) { + public void deleteBuffers(int n, int[] ids, int offset) { GLES20.glDeleteBuffers(n, ids, offset); } - public void glBindBuffer(int target, int id) { + public void bindBuffer(int target, int id) { GLES20.glBindBuffer(target, id); } - public void glBufferData(int target, int size, Buffer data, int usage) { + public void bufferData(int target, int size, Buffer data, int usage) { GLES20.glBufferData(target, size, data, usage); } - public void glBufferSubData(int target, int offset, int size, Buffer data) { + public void bufferSubData(int target, int offset, int size, Buffer data) { GLES20.glBufferSubData(target, offset, size, data); } - public void glDrawArrays(int mode, int first, int count) { + public void drawArrays(int mode, int first, int count) { GLES20.glDrawArrays(mode, first, count); } - public void glDrawElements(int mode, int count, int type, int offset) { + public void drawElements(int mode, int count, int type, int offset) { GLES20.glDrawElements(mode, count, type, offset); } - public void glEnableVertexAttribArray(int loc) { + public void enableVertexAttribArray(int loc) { GLES20.glEnableVertexAttribArray(loc); } - public void glDisableVertexAttribArray(int loc) { + public void disableVertexAttribArray(int loc) { GLES20.glDisableVertexAttribArray(loc); } - public void glVertexAttribPointer(int loc, int size, int type, boolean normalized, int stride, int offset) { + public void vertexAttribPointer(int loc, int size, int type, boolean normalized, int stride, int offset) { GLES20.glVertexAttribPointer(loc, size, type, normalized, stride, offset); } - public void glVertexAttribPointer(int loc, int size, int type, boolean normalized, int stride, Buffer data) { + public void vertexAttribPointer(int loc, int size, int type, boolean normalized, int stride, Buffer data) { GLES20.glVertexAttribPointer(loc, size, type, normalized, stride, data); } - public ByteBuffer glMapBuffer(int target, int access) { + public ByteBuffer mapBuffer(int target, int access) { //return gl2f.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2.GL_READ_WRITE); return null; } - public ByteBuffer glMapBufferRange(int target, int offset, int length, int access) { + public ByteBuffer mapBufferRange(int target, int offset, int length, int access) { //return gl2x.glMapBufferRange(GL.GL_ARRAY_BUFFER, offset, length, GL2.GL_READ_WRITE); return null; } - public void glUnmapBuffer(int target) { + public void unmapBuffer(int target) { //gl2f.glUnmapBuffer(GL.GL_ARRAY_BUFFER); } @@ -883,62 +874,62 @@ public class PGL { // Framebuffers, renderbuffers - public void glGenFramebuffers(int n, int[] ids, int offset) { + public void genFramebuffers(int n, int[] ids, int offset) { GLES20.glGenFramebuffers(n, ids, offset); } - public void glDeleteFramebuffers(int n, int[] ids, int offset) { + public void deleteFramebuffers(int n, int[] ids, int offset) { GLES20.glDeleteFramebuffers(n, ids, offset); } - public void glGenRenderbuffers(int n, int[] ids, int offset) { + public void genRenderbuffers(int n, int[] ids, int offset) { GLES20.glGenRenderbuffers(n, ids, offset); } - public void glDeleteRenderbuffers(int n, int[] ids, int offset) { + public void deleteRenderbuffers(int n, int[] ids, int offset) { GLES20.glDeleteRenderbuffers(n, ids, offset); } - public void glBindFramebuffer(int target, int id) { + public void bindFramebuffer(int target, int id) { GLES20.glBindFramebuffer(target, id); } - public void glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) { + public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) { // GLES20.glBlitFramebuffer(0, 0, srcW, srcH, 0, 0, destW, destH, GLES20.GL_COLOR_BUFFER_BIT, GLES20.GL_NEAREST); } - public void glFramebufferTexture2D(int target, int attachment, int texTarget, int texId, int level) { + public void framebufferTexture2D(int target, int attachment, int texTarget, int texId, int level) { GLES20.glFramebufferTexture2D(target, attachment, texTarget, texId, level); } - public void glBindRenderbuffer(int target, int id) { + public void bindRenderbuffer(int target, int id) { GLES20.glBindRenderbuffer(target, id); } - public void glRenderbufferStorageMultisample(int target, int samples, int format, int width, int height) { + public void renderbufferStorageMultisample(int target, int samples, int format, int width, int height) { // GLES20.glRenderbufferStorageMultisample(GLES20.GL_RENDERBUFFER, samples, format, w, h); } - public void glRenderbufferStorage(int target, int format, int width, int height) { + public void renderbufferStorage(int target, int format, int width, int height) { GLES20.glRenderbufferStorage(target, format, width, height); } - public void glFramebufferRenderbuffer(int target, int attachment, int rendbufTarget, int rendbufId) { + public void framebufferRenderbuffer(int target, int attachment, int rendbufTarget, int rendbufId) { GLES20.glFramebufferRenderbuffer(target, attachment, rendbufTarget, rendbufId); } - public int glCheckFramebufferStatus(int target) { + public int checkFramebufferStatus(int target) { return GLES20.glCheckFramebufferStatus(target); } @@ -948,217 +939,217 @@ public class PGL { // Shaders - public int glCreateProgram() { + public int createProgram() { return GLES20.glCreateProgram(); } - public void glDeleteProgram(int id) { + public void deleteProgram(int id) { GLES20.glDeleteProgram(id); } - public int glCreateShader(int type) { + public int createShader(int type) { return GLES20.glCreateShader(type); } - public void glDeleteShader(int id) { + public void deleteShader(int id) { GLES20.glDeleteShader(id); } - public void glLinkProgram(int prog) { + public void linkProgram(int prog) { GLES20.glLinkProgram(prog); } - public void glValidateProgram(int prog) { + public void validateProgram(int prog) { GLES20.glValidateProgram(prog); } - public void glUseProgram(int prog) { + public void useProgram(int prog) { GLES20.glUseProgram(prog); } - public int glGetAttribLocation(int prog, String name) { + public int getAttribLocation(int prog, String name) { return GLES20.glGetAttribLocation(prog, name); } - public int glGetUniformLocation(int prog, String name) { + public int getUniformLocation(int prog, String name) { return GLES20.glGetUniformLocation(prog, name); } - public void glUniform1i(int loc, int value) { + public void uniform1i(int loc, int value) { GLES20.glUniform1i(loc, value); } - public void glUniform2i(int loc, int value0, int value1) { + public void uniform2i(int loc, int value0, int value1) { GLES20.glUniform2i(loc, value0, value1); } - public void glUniform3i(int loc, int value0, int value1, int value2) { + public void uniform3i(int loc, int value0, int value1, int value2) { GLES20.glUniform3i(loc, value0, value1, value2); } - public void glUniform4i(int loc, int value0, int value1, int value2, int value3) { + public void uniform4i(int loc, int value0, int value1, int value2, int value3) { GLES20.glUniform4i(loc, value0, value1, value2, value3); } - public void glUniform1f(int loc, float value) { + public void uniform1f(int loc, float value) { GLES20.glUniform1f(loc, value); } - public void glUniform2f(int loc, float value0, float value1) { + public void uniform2f(int loc, float value0, float value1) { GLES20.glUniform2f(loc, value0, value1); } - public void glUniform3f(int loc, float value0, float value1, float value2) { + public void uniform3f(int loc, float value0, float value1, float value2) { GLES20.glUniform3f(loc, value0, value1, value2); } - public void glUniform4f(int loc, float value0, float value1, float value2, float value3) { + public void uniform4f(int loc, float value0, float value1, float value2, float value3) { GLES20.glUniform4f(loc, value0, value1, value2, value3); } - public void glUniform1iv(int loc, int count, int[] v, int offset) { + public void uniform1iv(int loc, int count, int[] v, int offset) { GLES20.glUniform1iv(loc, count, v, offset); } - public void glUniform2iv(int loc, int count, int[] v, int offset) { + public void uniform2iv(int loc, int count, int[] v, int offset) { GLES20.glUniform2iv(loc, count, v, offset); } - public void glUniform3iv(int loc, int count, int[] v, int offset) { + public void uniform3iv(int loc, int count, int[] v, int offset) { GLES20.glUniform3iv(loc, count, v, offset); } - public void glUniform4iv(int loc, int count, int[] v, int offset) { + public void uniform4iv(int loc, int count, int[] v, int offset) { GLES20.glUniform4iv(loc, count, v, offset); } - public void glUniform1fv(int loc, int count, float[] v, int offset) { + public void uniform1fv(int loc, int count, float[] v, int offset) { GLES20.glUniform1fv(loc, count, v, offset); } - public void glUniform2fv(int loc, int count, float[] v, int offset) { + public void uniform2fv(int loc, int count, float[] v, int offset) { GLES20.glUniform2fv(loc, count, v, offset); } - public void glUniform3fv(int loc, int count, float[] v, int offset) { + public void uniform3fv(int loc, int count, float[] v, int offset) { GLES20.glUniform3fv(loc, count, v, offset); } - public void glUniform4fv(int loc, int count, float[] v, int offset) { + public void uniform4fv(int loc, int count, float[] v, int offset) { GLES20.glUniform4fv(loc, count, v, offset); } - public void glUniformMatrix2fv(int loc, int count, boolean transpose, float[] mat, int offset) { + public void uniformMatrix2fv(int loc, int count, boolean transpose, float[] mat, int offset) { GLES20.glUniformMatrix2fv(loc, count, transpose, mat, offset); } - public void glUniformMatrix3fv(int loc, int count, boolean transpose, float[] mat, int offset) { + public void uniformMatrix3fv(int loc, int count, boolean transpose, float[] mat, int offset) { GLES20.glUniformMatrix3fv(loc, count, transpose, mat, offset); } - public void glUniformMatrix4fv(int loc, int count, boolean transpose, float[] mat, int offset) { + public void uniformMatrix4fv(int loc, int count, boolean transpose, float[] mat, int offset) { GLES20.glUniformMatrix4fv(loc, count, transpose, mat, offset); } - public void glVertexAttrib1f(int loc, float value) { + public void vertexAttrib1f(int loc, float value) { GLES20.glVertexAttrib1f(loc, value); } - public void glVertexAttrib2f(int loc, float value0, float value1) { + public void vertexAttrib2f(int loc, float value0, float value1) { GLES20.glVertexAttrib2f(loc, value0, value1); } - public void glVertexAttrib3f(int loc, float value0, float value1, float value2) { + public void vertexAttrib3f(int loc, float value0, float value1, float value2) { GLES20.glVertexAttrib3f(loc, value0, value1, value2); } - public void glVertexAttrib4f(int loc, float value0, float value1, float value2, float value3) { + public void vertexAttrib4f(int loc, float value0, float value1, float value2, float value3) { GLES20.glVertexAttrib4f(loc, value0, value1, value2, value3); } - public void glVertexAttrib1fv(int loc, float[] v, int offset) { + public void vertexAttrib1fv(int loc, float[] v, int offset) { GLES20.glVertexAttrib1fv(loc, v, offset); } - public void glVertexAttrib2fv(int loc, float[] v, int offset) { + public void vertexAttrib2fv(int loc, float[] v, int offset) { GLES20.glVertexAttrib2fv(loc, v, offset); } - public void glVertexAttrib3fv(int loc, float[] v, int offset) { + public void vertexAttrib3fv(int loc, float[] v, int offset) { GLES20.glVertexAttrib3fv(loc, v, offset); } - public void glVertexAttrib4fv(int loc, float[] v, int offset) { + public void vertexAttrib4fv(int loc, float[] v, int offset) { GLES20.glVertexAttrib4fv(loc, v, offset); } - public void glShaderSource(int id, String source) { + public void shaderSource(int id, String source) { GLES20.glShaderSource(id, source); } - public void glCompileShader(int id) { + public void compileShader(int id) { GLES20.glCompileShader(id); } - public void glAttachShader(int prog, int shader) { + public void attachShader(int prog, int shader) { GLES20.glAttachShader(prog, shader); } - public void glGetShaderiv(int shader, int pname, int[] params, int offset) { + public void getShaderiv(int shader, int pname, int[] params, int offset) { GLES20.glGetShaderiv(shader, pname, params, offset); } - public String glGetShaderInfoLog(int shader) { + public String getShaderInfoLog(int shader) { return GLES20.glGetShaderInfoLog(shader); } - public void glGetProgramiv(int prog, int pname, int[] params, int offset) { + public void getProgramiv(int prog, int pname, int[] params, int offset) { GLES20.glGetProgramiv(prog, pname, params, offset); } - public String glGetProgramInfoLog(int prog) { + public String getProgramInfoLog(int prog) { return GLES20.glGetProgramInfoLog(prog); } @@ -1168,7 +1159,7 @@ public class PGL { // Viewport - public void glViewport(int x, int y, int width, int height) { + public void viewport(int x, int y, int width, int height) { GLES20.glViewport(x, y, width, height); } @@ -1178,7 +1169,7 @@ public class PGL { // Clipping (scissor test) - public void glScissor(int x, int y, int w, int h) { + public void scissor(int x, int y, int w, int h) { GLES20.glScissor(x, y, w, h); } @@ -1188,12 +1179,12 @@ public class PGL { // Blending - public void glBlendEquation(int eq) { + public void blendEquation(int eq) { GLES20.glBlendEquation(eq); } - public void glBlendFunc(int srcFactor, int dstFactor) { + public void blendFunc(int srcFactor, int dstFactor) { GLES20.glBlendFunc(srcFactor, dstFactor); } @@ -1203,42 +1194,42 @@ public class PGL { // Pixels - public void glReadBuffer(int buf) { + public void readBuffer(int buf) { // GLES20.glReadBuffer(buf); } - public void glReadPixels(int x, int y, int width, int height, int format, int type, Buffer buffer) { + public void readPixels(int x, int y, int width, int height, int format, int type, Buffer buffer) { GLES20.glReadPixels(x, y, width, height, format, type, buffer); } - public void glDrawBuffer(int buf) { + public void drawBuffer(int buf) { // GLES20.glDrawBuffer(GLES20.GL_COLOR_ATTACHMENT0 + buf); } - public void glClearDepth(float d) { + public void clearDepth(float d) { GLES20.glClearDepthf(d); } - public void glClearStencil(int s) { + public void clearStencil(int s) { GLES20.glClearStencil(s); } - public void glColorMask(boolean wr, boolean wg, boolean wb, boolean wa) { + public void colorMask(boolean wr, boolean wg, boolean wb, boolean wa) { GLES20.glColorMask(wr, wg, wb, wa); } - public void glClearColor(float r, float g, float b, float a) { + public void clearColor(float r, float g, float b, float a) { GLES20.glClearColor(r, g, b, a); } - public void glClear(int mask) { + public void clear(int mask) { GLES20.glClear(mask); } @@ -1248,17 +1239,17 @@ public class PGL { // Context interface - public Context createEmptyContext() { + protected Context createEmptyContext() { return new Context(); } - public Context getCurrentContext() { + protected Context getCurrentContext() { return new Context(); } - public class Context { + protected class Context { Context() { } @@ -1282,12 +1273,12 @@ public class PGL { // Tessellator interface - public Tessellator createTessellator(TessellatorCallback callback) { + protected Tessellator createTessellator(TessellatorCallback callback) { return new Tessellator(callback); } - public class Tessellator { + protected class Tessellator { protected PGLUtessellator tess; protected TessellatorCallback callback; protected GLUCallback gluCallback; @@ -1353,7 +1344,12 @@ public class PGL { } - public interface TessellatorCallback { + protected String tessError(int err) { + return PGLU.gluErrorString(err); + } + + + protected interface TessellatorCallback { public void begin(int type); public void end(); public void vertex(Object data); @@ -1368,27 +1364,27 @@ public class PGL { // Utility functions - public boolean contextIsCurrent(Context other) { + protected boolean contextIsCurrent(Context other) { return other == null || other.current(); } - public void enableTexturing(int target) { - if (target == GL_TEXTURE_2D) { + protected void enableTexturing(int target) { + if (target == TEXTURE_2D) { texturingTargets[0] = true; } } - public void disableTexturing(int target) { - if (target == GL_TEXTURE_2D) { + protected void disableTexturing(int target) { + if (target == TEXTURE_2D) { texturingTargets[0] = false; } } - public boolean texturingIsEnabled(int target) { - if (target == GL_TEXTURE_2D) { + protected boolean texturingIsEnabled(int target) { + if (target == TEXTURE_2D) { return texturingTargets[0]; } else { return false; @@ -1396,8 +1392,8 @@ public class PGL { } - public boolean textureIsBound(int target, int id) { - if (target == GL_TEXTURE_2D) { + protected boolean textureIsBound(int target, int id) { + if (target == TEXTURE_2D) { return boundTextures[0] == id; } else { return false; @@ -1414,22 +1410,22 @@ public class PGL { int h = PApplet.min(16, height - y); for (int x = 0; x < width; x += 16) { int w = PApplet.min(16, width - x); - glTexSubImage2D(target, 0, x, y, w, h, format, GL_UNSIGNED_BYTE, IntBuffer.wrap(texels)); + texSubImage2D(target, 0, x, y, w, h, format, UNSIGNED_BYTE, IntBuffer.wrap(texels)); } } } public void copyToTexture(int target, int format, int id, int x, int y, int w, int h, IntBuffer buffer) { - glActiveTexture(GL_TEXTURE0); + activeTexture(TEXTURE0); boolean enabledTex = false; if (!texturingIsEnabled(target)) { enableTexturing(target); enabledTex = true; } - glBindTexture(target, id); - glTexSubImage2D(target, 0, x, y, w, h, format, GL_UNSIGNED_BYTE, buffer); - glBindTexture(target, 0); + bindTexture(target, id); + texSubImage2D(target, 0, x, y, w, h, format, UNSIGNED_BYTE, buffer); + bindTexture(target, 0); if (enabledTex) { disableTexturing(target); } @@ -1446,14 +1442,14 @@ public class PGL { int texX0, int texY0, int texX1, int texY1, int scrX0, int scrY0, int scrX1, int scrY1) { if (!loadedTexShader) { - texVertShader = createShader(GL_VERTEX_SHADER, texVertShaderSource); - texFragShader = createShader(GL_FRAGMENT_SHADER, texFragShaderSource); + texVertShader = createShader(VERTEX_SHADER, texVertShaderSource); + texFragShader = createShader(FRAGMENT_SHADER, texFragShaderSource); if (0 < texVertShader && 0 < texFragShader) { texShaderProgram = createProgram(texVertShader, texFragShader); } if (0 < texShaderProgram) { - texVertLoc = glGetAttribLocation(texShaderProgram, "inVertex"); - texTCoordLoc = glGetAttribLocation(texShaderProgram, "inTexcoord"); + texVertLoc = getAttribLocation(texShaderProgram, "inVertex"); + texTCoordLoc = getAttribLocation(texShaderProgram, "inTexcoord"); } texData = allocateDirectFloatBuffer(texCoords.length); loadedTexShader = true; @@ -1462,21 +1458,21 @@ public class PGL { if (0 < texShaderProgram) { // The texture overwrites anything drawn earlier. boolean[] depthTest = new boolean[1]; - glGetBooleanv(GL_DEPTH_TEST, depthTest, 0); - glDisable(GL_DEPTH_TEST); + getBooleanv(DEPTH_TEST, depthTest, 0); + disable(DEPTH_TEST); // When drawing the texture we don't write to the // depth mask, so the texture remains in the background // and can be occluded by anything drawn later, even if // if it is behind it. boolean[] depthMask = new boolean[1]; - glGetBooleanv(GL_DEPTH_WRITEMASK, depthMask, 0); - glDepthMask(false); + getBooleanv(DEPTH_WRITEMASK, depthMask, 0); + depthMask(false); - glUseProgram(texShaderProgram); + useProgram(texShaderProgram); - glEnableVertexAttribArray(texVertLoc); - glEnableVertexAttribArray(texTCoordLoc); + enableVertexAttribArray(texVertLoc); + enableVertexAttribArray(texTCoordLoc); // Vertex coordinates of the textured quad are specified // in normalized screen space (-1, 1): @@ -1508,58 +1504,52 @@ public class PGL { texData.rewind(); texData.put(texCoords); - glActiveTexture(GL_TEXTURE0); + activeTexture(TEXTURE0); boolean enabledTex = false; - if (!texturingIsEnabled(GL_TEXTURE_2D)) { - enableTexturing(GL_TEXTURE_2D); + if (!texturingIsEnabled(TEXTURE_2D)) { + enableTexturing(TEXTURE_2D); enabledTex = true; } - glBindTexture(target, id); + bindTexture(target, id); texData.position(0); - glVertexAttribPointer(texVertLoc, 2, GL_FLOAT, false, 4 * SIZEOF_FLOAT, texData); + vertexAttribPointer(texVertLoc, 2, FLOAT, false, 4 * SIZEOF_FLOAT, texData); texData.position(2); - glVertexAttribPointer(texTCoordLoc, 2, GL_FLOAT, false, 4 * SIZEOF_FLOAT, texData); + vertexAttribPointer(texTCoordLoc, 2, FLOAT, false, 4 * SIZEOF_FLOAT, texData); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + drawArrays(TRIANGLE_STRIP, 0, 4); - glBindTexture(target, 0); + bindTexture(target, 0); if (enabledTex) { - disableTexturing(GL_TEXTURE_2D); + disableTexturing(TEXTURE_2D); } - glDisableVertexAttribArray(texVertLoc); - glDisableVertexAttribArray(texTCoordLoc); + disableVertexAttribArray(texVertLoc); + disableVertexAttribArray(texTCoordLoc); - glUseProgram(0); + useProgram(0); if (depthTest[0]) { - glEnable(GL_DEPTH_TEST); + enable(DEPTH_TEST); } else { - glDisable(GL_DEPTH_TEST); + disable(DEPTH_TEST); } - glDepthMask(depthMask[0]); + depthMask(depthMask[0]); } } - - - public void drawTextureCustom(int target, int id, int width, int height, - int X0, int Y0, int X1, int Y1, int program) { - // ... - } - + public void drawRectangle(float r, float g, float b, float a, int scrX0, int scrY0, int scrX1, int scrY1) { if (!loadedRectShader) { - rectVertShader = createShader(GL_VERTEX_SHADER, rectVertShaderSource); - rectFragShader = createShader(GL_FRAGMENT_SHADER, rectFragShaderSource); + rectVertShader = createShader(VERTEX_SHADER, rectVertShaderSource); + rectFragShader = createShader(FRAGMENT_SHADER, rectFragShaderSource); if (0 < rectVertShader && 0 < rectFragShader) { rectShaderProgram = createProgram(rectVertShader, rectFragShader); } if (0 < rectShaderProgram) { - rectVertLoc = glGetAttribLocation(rectShaderProgram, "inVertex"); - rectColorLoc = glGetUniformLocation(rectShaderProgram, "rectColor"); + rectVertLoc = getAttribLocation(rectShaderProgram, "inVertex"); + rectColorLoc = getUniformLocation(rectShaderProgram, "rectColor"); } rectData = allocateDirectFloatBuffer(rectCoords.length); loadedRectShader = true; @@ -1568,21 +1558,21 @@ public class PGL { if (0 < rectShaderProgram) { // The rectangle overwrites anything drawn earlier. boolean[] depthTest = new boolean[1]; - glGetBooleanv(GL_DEPTH_TEST, depthTest, 0); - glDisable(GL_DEPTH_TEST); + getBooleanv(DEPTH_TEST, depthTest, 0); + disable(DEPTH_TEST); // When drawing the rectangle we don't write to the // depth mask, so the rectangle remains in the background // and can be occluded by anything drawn later, even if // if it is behind it. boolean[] depthMask = new boolean[1]; - glGetBooleanv(GL_DEPTH_WRITEMASK, depthMask, 0); - glDepthMask(false); + getBooleanv(DEPTH_WRITEMASK, depthMask, 0); + depthMask(false); - glUseProgram(rectShaderProgram); + useProgram(rectShaderProgram); - glEnableVertexAttribArray(rectVertLoc); - glUniform4f(rectColorLoc, r, g, b, a); + enableVertexAttribArray(rectVertLoc); + uniform4f(rectColorLoc, r, g, b, a); // Vertex coordinates of the rectangle are specified // in normalized screen space (-1, 1): @@ -1607,20 +1597,20 @@ public class PGL { rectData.put(rectCoords); rectData.position(0); - glVertexAttribPointer(rectVertLoc, 2, GL_FLOAT, false, 2 * SIZEOF_FLOAT, rectData); + vertexAttribPointer(rectVertLoc, 2, FLOAT, false, 2 * SIZEOF_FLOAT, rectData); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + drawArrays(TRIANGLE_STRIP, 0, 4); - glDisableVertexAttribArray(rectVertLoc); + disableVertexAttribArray(rectVertLoc); - glUseProgram(0); + useProgram(0); if (depthTest[0]) { - glEnable(GL_DEPTH_TEST); + enable(DEPTH_TEST); } else { - glDisable(GL_DEPTH_TEST); + disable(DEPTH_TEST); } - glDepthMask(depthMask[0]); + depthMask(depthMask[0]); } } @@ -1630,7 +1620,7 @@ public class PGL { colorBuffer = IntBuffer.allocate(1); } colorBuffer.rewind(); - glReadPixels(scrX, pg.height - scrY - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, colorBuffer); + readPixels(scrX, pg.height - scrY - 1, 1, 1, RGBA, UNSIGNED_BYTE, colorBuffer); return colorBuffer.get(); } @@ -1952,16 +1942,16 @@ public class PGL { public int createShader(int shaderType, String source) { - int shader = glCreateShader(shaderType); + int shader = createShader(shaderType); if (shader != 0) { - glShaderSource(shader, source); - glCompileShader(shader); + shaderSource(shader, source); + compileShader(shader); int[] compiled = new int[1]; - glGetShaderiv(shader, GL_COMPILE_STATUS, compiled, 0); - if (compiled[0] == GL_FALSE) { + getShaderiv(shader, COMPILE_STATUS, compiled, 0); + if (compiled[0] == FALSE) { System.err.println("Could not compile shader " + shaderType + ":"); - System.err.println(glGetShaderInfoLog(shader)); - glDeleteShader(shader); + System.err.println(getShaderInfoLog(shader)); + deleteShader(shader); shader = 0; } } @@ -1970,17 +1960,17 @@ public class PGL { public int createProgram(int vertexShader, int fragmentShader) { - int program = glCreateProgram(); + int program = createProgram(); if (program != 0) { - glAttachShader(program, vertexShader); - glAttachShader(program, fragmentShader); - glLinkProgram(program); + attachShader(program, vertexShader); + attachShader(program, fragmentShader); + linkProgram(program); int[] linked = new int[1]; - glGetProgramiv(program, GL_LINK_STATUS, linked, 0); - if (linked[0] == GL_FALSE) { + getProgramiv(program, LINK_STATUS, linked, 0); + if (linked[0] == FALSE) { System.err.println("Could not link program: "); - System.err.println(glGetProgramInfoLog(program)); - glDeleteProgram(program); + System.err.println(getProgramInfoLog(program)); + deleteProgram(program); program = 0; } } @@ -1989,18 +1979,18 @@ public class PGL { public boolean validateFramebuffer() { - int status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - if (status == GL_FRAMEBUFFER_COMPLETE) { + int status = checkFramebufferStatus(FRAMEBUFFER); + if (status == FRAMEBUFFER_COMPLETE) { return true; - } else if (status == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) { + } else if (status == FRAMEBUFFER_INCOMPLETE_ATTACHMENT) { throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT (" + Integer.toHexString(status) + ")"); - } else if (status == GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) { + } else if (status == FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) { throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT (" + Integer.toHexString(status) + ")"); - } else if (status == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS) { + } else if (status == FRAMEBUFFER_INCOMPLETE_DIMENSIONS) { throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS (" + Integer.toHexString(status) + ")"); - } else if (status == GL_FRAMEBUFFER_INCOMPLETE_FORMATS) { + } else if (status == FRAMEBUFFER_INCOMPLETE_FORMATS) { throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_FORMATS (" + Integer.toHexString(status) + ")"); - } else if (status == GL_FRAMEBUFFER_UNSUPPORTED) { + } else if (status == FRAMEBUFFER_UNSUPPORTED) { throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_UNSUPPORTED" + Integer.toHexString(status)); } else { throw new RuntimeException("PFramebuffer: unknown framebuffer error (" + Integer.toHexString(status) + ")"); @@ -2043,7 +2033,7 @@ public class PGL { } - public class AndroidRenderer implements Renderer { + protected class AndroidRenderer implements Renderer { public AndroidRenderer() { } @@ -2067,7 +2057,7 @@ public class PGL { } - public class AndroidContextFactory implements GLSurfaceView.EGLContextFactory { + protected class AndroidContextFactory implements GLSurfaceView.EGLContextFactory { public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, @@ -2082,7 +2072,7 @@ public class PGL { } - public class AndroidConfigChooser implements EGLConfigChooser { + protected class AndroidConfigChooser implements EGLConfigChooser { // Desired size (in bits) for the rgba color, depth and stencil buffers. public int redTarget; public int greenTarget; diff --git a/android/core/src/processing/opengl/PGraphicsOpenGL.java b/android/core/src/processing/opengl/PGraphicsOpenGL.java index 6efebc8fe..9717c28b9 100644 --- a/android/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/android/core/src/processing/opengl/PGraphicsOpenGL.java @@ -501,11 +501,6 @@ public class PGraphicsOpenGL extends PGraphics { } - public void setToolkit(int toolkit) { - pgl.setToolkit(toolkit); - } - - public void setSize(int iwidth, int iheight) { resized = (0 < width && width != iwidth) || (0 < height && height != iwidth); @@ -611,7 +606,7 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedTextureObjects(); int[] temp = new int[1]; - pgl.glGenTextures(1, temp, 0); + pgl.genTextures(1, temp, 0); int id = temp[0]; GLResource res = new GLResource(id, context); @@ -629,7 +624,7 @@ public class PGraphicsOpenGL extends PGraphics { GLResource res = new GLResource(id, context); if (glTextureObjects.containsKey(res)) { int[] temp = { id }; - pgl.glDeleteTextures(1, temp, 0); + pgl.deleteTextures(1, temp, 0); glTextureObjects.remove(res); } } @@ -637,7 +632,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllTextureObjects() { for (GLResource res : glTextureObjects.keySet()) { int[] temp = { res.id }; - pgl.glDeleteTextures(1, temp, 0); + pgl.deleteTextures(1, temp, 0); } glTextureObjects.clear(); } @@ -657,7 +652,7 @@ public class PGraphicsOpenGL extends PGraphics { if (glTextureObjects.get(res)) { finalized.add(res); int[] temp = { res.id }; - pgl.glDeleteTextures(1, temp, 0); + pgl.deleteTextures(1, temp, 0); } } @@ -679,7 +674,7 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedVertexBufferObjects(); int[] temp = new int[1]; - pgl.glGenBuffers(1, temp, 0); + pgl.genBuffers(1, temp, 0); int id = temp[0]; GLResource res = new GLResource(id, context); @@ -697,7 +692,7 @@ public class PGraphicsOpenGL extends PGraphics { GLResource res = new GLResource(id, context); if (glVertexBuffers.containsKey(res)) { int[] temp = { id }; - pgl.glDeleteBuffers(1, temp, 0); + pgl.deleteBuffers(1, temp, 0); glVertexBuffers.remove(res); } } @@ -705,7 +700,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllVertexBufferObjects() { for (GLResource res : glVertexBuffers.keySet()) { int[] temp = { res.id }; - pgl.glDeleteBuffers(1, temp, 0); + pgl.deleteBuffers(1, temp, 0); } glVertexBuffers.clear(); } @@ -725,7 +720,7 @@ public class PGraphicsOpenGL extends PGraphics { if (glVertexBuffers.get(res)) { finalized.add(res); int[] temp = { res.id }; - pgl.glDeleteBuffers(1, temp, 0); + pgl.deleteBuffers(1, temp, 0); } } @@ -747,7 +742,7 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedFrameBufferObjects(); int[] temp = new int[1]; - pgl.glGenFramebuffers(1, temp, 0); + pgl.genFramebuffers(1, temp, 0); int id = temp[0]; GLResource res = new GLResource(id, context); @@ -765,7 +760,7 @@ public class PGraphicsOpenGL extends PGraphics { GLResource res = new GLResource(id, context); if (glFrameBuffers.containsKey(res)) { int[] temp = { id }; - pgl.glDeleteFramebuffers(1, temp, 0); + pgl.deleteFramebuffers(1, temp, 0); glFrameBuffers.remove(res); } } @@ -773,7 +768,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllFrameBufferObjects() { for (GLResource res : glFrameBuffers.keySet()) { int[] temp = { res.id }; - pgl.glDeleteFramebuffers(1, temp, 0); + pgl.deleteFramebuffers(1, temp, 0); } glFrameBuffers.clear(); } @@ -793,7 +788,7 @@ public class PGraphicsOpenGL extends PGraphics { if (glFrameBuffers.get(res)) { finalized.add(res); int[] temp = { res.id }; - pgl.glDeleteFramebuffers(1, temp, 0); + pgl.deleteFramebuffers(1, temp, 0); } } @@ -815,7 +810,7 @@ public class PGraphicsOpenGL extends PGraphics { deleteFinalizedRenderBufferObjects(); int[] temp = new int[1]; - pgl.glGenRenderbuffers(1, temp, 0); + pgl.genRenderbuffers(1, temp, 0); int id = temp[0]; GLResource res = new GLResource(id, context); @@ -833,7 +828,7 @@ public class PGraphicsOpenGL extends PGraphics { GLResource res = new GLResource(id, context); if (glRenderBuffers.containsKey(res)) { int[] temp = { id }; - pgl.glDeleteRenderbuffers(1, temp, 0); + pgl.deleteRenderbuffers(1, temp, 0); glRenderBuffers.remove(res); } } @@ -841,7 +836,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteAllRenderBufferObjects() { for (GLResource res : glRenderBuffers.keySet()) { int[] temp = { res.id }; - pgl.glDeleteRenderbuffers(1, temp, 0); + pgl.deleteRenderbuffers(1, temp, 0); } glRenderBuffers.clear(); } @@ -861,7 +856,7 @@ public class PGraphicsOpenGL extends PGraphics { if (glRenderBuffers.get(res)) { finalized.add(res); int[] temp = { res.id }; - pgl.glDeleteRenderbuffers(1, temp, 0); + pgl.deleteRenderbuffers(1, temp, 0); } } @@ -882,7 +877,7 @@ public class PGraphicsOpenGL extends PGraphics { protected int createGLSLProgramObject(int context) { deleteFinalizedGLSLProgramObjects(); - int id = pgl.glCreateProgram(); + int id = pgl.createProgram(); GLResource res = new GLResource(id, context); @@ -898,14 +893,14 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteGLSLProgramObject(int id, int context) { GLResource res = new GLResource(id, context); if (glslPrograms.containsKey(res)) { - pgl.glDeleteProgram(res.id); + pgl.deleteProgram(res.id); glslPrograms.remove(res); } } protected void deleteAllGLSLProgramObjects() { for (GLResource res : glslPrograms.keySet()) { - pgl.glDeleteProgram(res.id); + pgl.deleteProgram(res.id); } glslPrograms.clear(); } @@ -924,7 +919,7 @@ public class PGraphicsOpenGL extends PGraphics { for (GLResource res : glslPrograms.keySet()) { if (glslPrograms.get(res)) { finalized.add(res); - pgl.glDeleteProgram(res.id); + pgl.deleteProgram(res.id); } } @@ -945,7 +940,7 @@ public class PGraphicsOpenGL extends PGraphics { protected int createGLSLVertShaderObject(int context) { deleteFinalizedGLSLVertShaderObjects(); - int id = pgl.glCreateShader(PGL.GL_VERTEX_SHADER); + int id = pgl.createShader(PGL.VERTEX_SHADER); GLResource res = new GLResource(id, context); @@ -961,14 +956,14 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteGLSLVertShaderObject(int id, int context) { GLResource res = new GLResource(id, context); if (glslVertexShaders.containsKey(res)) { - pgl.glDeleteShader(res.id); + pgl.deleteShader(res.id); glslVertexShaders.remove(res); } } protected void deleteAllGLSLVertShaderObjects() { for (GLResource res : glslVertexShaders.keySet()) { - pgl.glDeleteShader(res.id); + pgl.deleteShader(res.id); } glslVertexShaders.clear(); } @@ -987,7 +982,7 @@ public class PGraphicsOpenGL extends PGraphics { for (GLResource res : glslVertexShaders.keySet()) { if (glslVertexShaders.get(res)) { finalized.add(res); - pgl.glDeleteShader(res.id); + pgl.deleteShader(res.id); } } @@ -1008,7 +1003,7 @@ public class PGraphicsOpenGL extends PGraphics { protected int createGLSLFragShaderObject(int context) { deleteFinalizedGLSLFragShaderObjects(); - int id = pgl.glCreateShader(PGL.GL_FRAGMENT_SHADER); + int id = pgl.createShader(PGL.FRAGMENT_SHADER); GLResource res = new GLResource(id, context); @@ -1024,14 +1019,14 @@ public class PGraphicsOpenGL extends PGraphics { protected void deleteGLSLFragShaderObject(int id, int context) { GLResource res = new GLResource(id, context); if (glslFragmentShaders.containsKey(res)) { - pgl.glDeleteShader(res.id); + pgl.deleteShader(res.id); glslFragmentShaders.remove(res); } } protected void deleteAllGLSLFragShaderObjects() { for (GLResource res : glslFragmentShaders.keySet()) { - pgl.glDeleteShader(res.id); + pgl.deleteShader(res.id); } glslFragmentShaders.clear(); } @@ -1050,7 +1045,7 @@ public class PGraphicsOpenGL extends PGraphics { for (GLResource res : glslFragmentShaders.keySet()) { if (glslFragmentShaders.get(res)) { finalized.add(res); - pgl.glDeleteShader(res.id); + pgl.deleteShader(res.id); } } @@ -1124,44 +1119,44 @@ public class PGraphicsOpenGL extends PGraphics { int sizex = INIT_INDEX_BUFFER_SIZE * PGL.SIZEOF_INDEX; glPolyVertex = createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW); glPolyColor = createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW); glPolyNormal = createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormal); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal); + pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW); glPolyTexcoord = createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoord); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord); + pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, null, PGL.STATIC_DRAW); glPolyAmbient = pgPrimary.createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbient); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW); glPolySpecular = pgPrimary.createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecular); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW); glPolyEmissive = pgPrimary.createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissive); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW); glPolyShininess = pgPrimary.createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininess); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess); + pgl.bufferData(PGL.ARRAY_BUFFER, sizef, null, PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); glPolyIndex = createVertexBufferObject(polyBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, sizex, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizex, null, PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); polyBuffersCreated = true; } @@ -1175,44 +1170,44 @@ public class PGraphicsOpenGL extends PGraphics { int sizef = size * PGL.SIZEOF_FLOAT; int sizei = size * PGL.SIZEOF_INT; - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyColors, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyColors, 0, size), PGL.STATIC_DRAW); if (lit) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormal); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal); + pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbient); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyAmbient, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyAmbient, 0, size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecular); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polySpecular, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polySpecular, 0, size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissive); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyEmissive, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyEmissive, 0, size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininess); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.polyShininess, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess); + pgl.bufferData(PGL.ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.polyShininess, 0, size), PGL.STATIC_DRAW); } if (tex) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoord); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord); + pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size), PGL.STATIC_DRAW); } - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.polyIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.polyIndices, 0, tessGeo.polyIndexCount), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, tessGeo.polyIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.polyIndices, 0, tessGeo.polyIndexCount), PGL.STATIC_DRAW); } protected void unbindPolyBuffers() { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } @@ -1265,24 +1260,24 @@ public class PGraphicsOpenGL extends PGraphics { glLineVertex = createVertexBufferObject(lineBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW); glLineColor = createVertexBufferObject(lineBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW); glLineAttrib = createVertexBufferObject(lineBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineAttrib); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, null, PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); glLineIndex = createVertexBufferObject(lineBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glLineIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, sizex, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glLineIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizex, null, PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); lineBuffersCreated = true; } @@ -1296,24 +1291,24 @@ public class PGraphicsOpenGL extends PGraphics { int sizef = size * PGL.SIZEOF_FLOAT; int sizei = size * PGL.SIZEOF_INT; - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineVertices, 0, 4 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.lineColors, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.lineColors, 0, size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineAttrib); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineAttribs, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineAttribs, 0, 4 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glLineIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.lineIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.lineIndices, 0, tessGeo.lineIndexCount), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glLineIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, tessGeo.lineIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.lineIndices, 0, tessGeo.lineIndexCount), PGL.STATIC_DRAW); } protected void unbindLineBuffers() { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } @@ -1350,24 +1345,24 @@ public class PGraphicsOpenGL extends PGraphics { int sizex = INIT_INDEX_BUFFER_SIZE * PGL.SIZEOF_INDEX; glPointVertex = createVertexBufferObject(pointBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, null, PGL.STATIC_DRAW); glPointColor = createVertexBufferObject(pointBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, null, PGL.STATIC_DRAW); glPointAttrib = createVertexBufferObject(pointBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointAttrib); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib); + pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, null, PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); glPointIndex = createVertexBufferObject(pointBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPointIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, sizex, null, PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPointIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, sizex, null, PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); pointBuffersCreated = true; } @@ -1381,24 +1376,24 @@ public class PGraphicsOpenGL extends PGraphics { int sizef = size * PGL.SIZEOF_FLOAT; int sizei = size * PGL.SIZEOF_INT; - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.pointVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.pointVertices, 0, 4 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.pointColors, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.pointColors, 0, size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointAttrib); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.pointAttribs, 0, 2 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib); + pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.pointAttribs, 0, 2 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPointIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.pointIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.pointIndices, 0, tessGeo.pointIndexCount), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPointIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, tessGeo.pointIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.pointIndices, 0, tessGeo.pointIndexCount), PGL.STATIC_DRAW); } protected void unbindPointBuffers() { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } @@ -1471,7 +1466,7 @@ public class PGraphicsOpenGL extends PGraphics { if (primarySurface) { pgl.updatePrimary(); if (pgl.primaryIsDoubleBuffered()) { - pgl.glDrawBuffer(PGL.GL_BACK); + pgl.drawBuffer(PGL.BACK); } } else { if (!pgl.initialized) { @@ -1492,7 +1487,7 @@ public class PGraphicsOpenGL extends PGraphics { setFramebuffer(offscreenFramebuffer); } pgl.updateOffscreen(pgPrimary.pgl); - pgl.glDrawBuffer(PGL.GL_COLOR_ATTACHMENT0); + pgl.drawBuffer(PGL.COLOR_ATTACHMENT0); } // We are ready to go! @@ -1516,12 +1511,12 @@ public class PGraphicsOpenGL extends PGraphics { // this is necessary for 3D drawing if (hints[DISABLE_DEPTH_TEST]) { - pgl.glDisable(PGL.GL_DEPTH_TEST); + pgl.disable(PGL.DEPTH_TEST); } else { - pgl.glEnable(PGL.GL_DEPTH_TEST); + pgl.enable(PGL.DEPTH_TEST); } // use <= since that's what processing.core does - pgl.glDepthFunc(PGL.GL_LEQUAL); + pgl.depthFunc(PGL.LEQUAL); if (hints[ENABLE_ACCURATE_2D]) { flushMode = FLUSH_CONTINUOUSLY; @@ -1531,23 +1526,23 @@ public class PGraphicsOpenGL extends PGraphics { if (primarySurface) { int[] temp = new int[1]; - pgl.glGetIntegerv(PGL.GL_SAMPLES, temp, 0); + pgl.getIntegerv(PGL.SAMPLES, temp, 0); if (quality != temp[0] && 1 < temp[0] && 1 < quality) { quality = temp[0]; } } if (quality < 2) { - pgl.glDisable(PGL.GL_MULTISAMPLE); + pgl.disable(PGL.MULTISAMPLE); } else { - pgl.glEnable(PGL.GL_MULTISAMPLE); + pgl.enable(PGL.MULTISAMPLE); } - pgl.glDisable(PGL.GL_POINT_SMOOTH); - pgl.glDisable(PGL.GL_LINE_SMOOTH); - pgl.glDisable(PGL.GL_POLYGON_SMOOTH); + pgl.disable(PGL.POINT_SMOOTH); + pgl.disable(PGL.LINE_SMOOTH); + pgl.disable(PGL.POLYGON_SMOOTH); // setup opengl viewport. viewport[0] = 0; viewport[1] = 0; viewport[2] = width; viewport[3] = height; - pgl.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + pgl.viewport(viewport[0], viewport[1], viewport[2], viewport[3]); if (resized) { // To avoid having garbage in the screen after a resize, // in the case background is not called in draw(). @@ -1590,20 +1585,20 @@ public class PGraphicsOpenGL extends PGraphics { // Because y is flipped, the vertices that should be specified by // the user in CCW order to define a front-facing facet, end up being // CW. - pgl.glFrontFace(PGL.GL_CW); - pgl.glDisable(PGL.GL_CULL_FACE); + pgl.frontFace(PGL.CW); + pgl.disable(PGL.CULL_FACE); // Processing uses only one texture unit. - pgl.glActiveTexture(PGL.GL_TEXTURE0); + pgl.activeTexture(PGL.TEXTURE0); // The current normal vector is set to be parallel to the Z axis. normalX = normalY = normalZ = 0; // Clear depth and stencil buffers. - pgl.glDepthMask(true); - pgl.glClearDepth(1); - pgl.glClearStencil(0); - pgl.glClear(PGL.GL_DEPTH_BUFFER_BIT | PGL.GL_STENCIL_BUFFER_BIT); + pgl.depthMask(true); + pgl.clearDepth(1); + pgl.clearStencil(0); + pgl.clear(PGL.DEPTH_BUFFER_BIT | PGL.STENCIL_BUFFER_BIT); if (primarySurface) { pgl.beginOnscreenDraw(clearColorBuffer); @@ -1615,10 +1610,10 @@ public class PGraphicsOpenGL extends PGraphics { // Restoring the clipping configuration of the offscreen surface. if (clip) { - pgl.glEnable(PGL.GL_SCISSOR_TEST); - pgl.glScissor(clipRect[0], clipRect[1], clipRect[2], clipRect[3]); + pgl.enable(PGL.SCISSOR_TEST); + pgl.scissor(clipRect[0], clipRect[1], clipRect[2], clipRect[3]); } else { - pgl.glDisable(PGL.GL_SCISSOR_TEST); + pgl.disable(PGL.SCISSOR_TEST); } } @@ -1632,9 +1627,9 @@ public class PGraphicsOpenGL extends PGraphics { } if (hints[DISABLE_DEPTH_MASK]) { - pgl.glDepthMask(false); + pgl.depthMask(false); } else { - pgl.glDepthMask(true); + pgl.depthMask(true); } pixelsOp = OP_NONE; @@ -1674,7 +1669,7 @@ public class PGraphicsOpenGL extends PGraphics { restoreSurface = true; } - pgl.glFlush(); + pgl.flush(); } else { if (offscreenMultisample) { offscreenFramebufferMultisample.copy(offscreenFramebuffer); @@ -1686,10 +1681,10 @@ public class PGraphicsOpenGL extends PGraphics { pushFramebuffer(); setFramebuffer(offscreenFramebuffer); } - pgl.glColorMask(false, false, false, true); - pgl.glClearColor(0, 0, 0, 1); - pgl.glClear(PGL.GL_COLOR_BUFFER_BIT); - pgl.glColorMask(true, true, true, true); + pgl.colorMask(false, false, false, true); + pgl.clearColor(0, 0, 0, 1); + pgl.clear(PGL.COLOR_BUFFER_BIT); + pgl.colorMask(true, true, true, true); if (offscreenMultisample) { popFramebuffer(); } @@ -1732,13 +1727,13 @@ public class PGraphicsOpenGL extends PGraphics { } - public PGL beginGL() { + public PGL beginPGL() { flush(); return pgl; } - public void endGL() { + public void endPGL() { restoreGL(); } @@ -1752,42 +1747,42 @@ public class PGraphicsOpenGL extends PGraphics { blendMode(blendMode); if (hints[DISABLE_DEPTH_TEST]) { - pgl.glDisable(PGL.GL_DEPTH_TEST); + pgl.disable(PGL.DEPTH_TEST); } else { - pgl.glEnable(PGL.GL_DEPTH_TEST); + pgl.enable(PGL.DEPTH_TEST); } - pgl.glDepthFunc(PGL.GL_LEQUAL); + pgl.depthFunc(PGL.LEQUAL); if (quality < 2) { - pgl.glDisable(PGL.GL_MULTISAMPLE); + pgl.disable(PGL.MULTISAMPLE); } else { - pgl.glEnable(PGL.GL_MULTISAMPLE); - pgl.glDisable(PGL.GL_POINT_SMOOTH); - pgl.glDisable(PGL.GL_LINE_SMOOTH); - pgl.glDisable(PGL.GL_POLYGON_SMOOTH); + pgl.enable(PGL.MULTISAMPLE); + pgl.disable(PGL.POINT_SMOOTH); + pgl.disable(PGL.LINE_SMOOTH); + pgl.disable(PGL.POLYGON_SMOOTH); } - pgl.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + pgl.viewport(viewport[0], viewport[1], viewport[2], viewport[3]); if (clip) { - pgl.glEnable(PGL.GL_SCISSOR_TEST); - pgl.glScissor(clipRect[0], clipRect[1], clipRect[2], clipRect[3]); + pgl.enable(PGL.SCISSOR_TEST); + pgl.scissor(clipRect[0], clipRect[1], clipRect[2], clipRect[3]); } else { - pgl.glDisable(PGL.GL_SCISSOR_TEST); + pgl.disable(PGL.SCISSOR_TEST); } - pgl.glFrontFace(PGL.GL_CW); - pgl.glDisable(PGL.GL_CULL_FACE); + pgl.frontFace(PGL.CW); + pgl.disable(PGL.CULL_FACE); - pgl.glActiveTexture(PGL.GL_TEXTURE0); + pgl.activeTexture(PGL.TEXTURE0); if (hints[DISABLE_DEPTH_MASK]) { - pgl.glDepthMask(false); + pgl.depthMask(false); } else { - pgl.glDepthMask(true); + pgl.depthMask(true); } if (pgl.primaryIsDoubleBuffered()) { - pgl.glDrawBuffer(PGL.GL_BACK); + pgl.drawBuffer(PGL.BACK); } } @@ -1798,9 +1793,9 @@ public class PGraphicsOpenGL extends PGraphics { // We read or write from the back buffer, where all the // drawing in the current frame is taking place. if (op == OP_READ) { - pgl.glReadBuffer(PGL.GL_BACK); + pgl.readBuffer(PGL.BACK); } else { - pgl.glDrawBuffer(PGL.GL_BACK); + pgl.drawBuffer(PGL.BACK); } offscreenNotCurrent = false; } else if (pgl.primaryIsFboBacked()) { @@ -1808,11 +1803,11 @@ public class PGraphicsOpenGL extends PGraphics { // We read from the color FBO, but the multisample FBO is currently bound, so: offscreenNotCurrent = true; pgl.bindPrimaryColorFBO(); - pgl.glReadBuffer(PGL.GL_COLOR_ATTACHMENT0); + pgl.readBuffer(PGL.COLOR_ATTACHMENT0); } else { // We write directly to the multisample FBO. offscreenNotCurrent = false; - pgl.glDrawBuffer(PGL.GL_COLOR_ATTACHMENT0); + pgl.drawBuffer(PGL.COLOR_ATTACHMENT0); } } else { offscreenNotCurrent = false; @@ -1831,7 +1826,7 @@ public class PGraphicsOpenGL extends PGraphics { setFramebuffer(offscreenFramebuffer); pgl.updateOffscreen(pgPrimary.pgl); } - pgl.glReadBuffer(PGL.GL_COLOR_ATTACHMENT0); + pgl.readBuffer(PGL.COLOR_ATTACHMENT0); } else { // We can write directly to the color FBO, or to the multisample FBO // if multisampling is enabled. @@ -1849,7 +1844,7 @@ public class PGraphicsOpenGL extends PGraphics { } pgl.updateOffscreen(pgPrimary.pgl); } - pgl.glDrawBuffer(PGL.GL_COLOR_ATTACHMENT0); + pgl.drawBuffer(PGL.COLOR_ATTACHMENT0); } } pixelsOp = op; @@ -2029,16 +2024,16 @@ public class PGraphicsOpenGL extends PGraphics { if (which == DISABLE_DEPTH_TEST) { flush(); - pgl.glDisable(PGL.GL_DEPTH_TEST); + pgl.disable(PGL.DEPTH_TEST); } else if (which == ENABLE_DEPTH_TEST) { flush(); - pgl.glEnable(PGL.GL_DEPTH_TEST); + pgl.enable(PGL.DEPTH_TEST); } else if (which == DISABLE_DEPTH_MASK) { flush(); - pgl.glDepthMask(false); + pgl.depthMask(false); } else if (which == ENABLE_DEPTH_MASK) { flush(); - pgl.glDepthMask(true); + pgl.depthMask(true); } else if (which == DISABLE_ACCURATE_2D) { flush(); setFlushMode(FLUSH_WHEN_FULL); @@ -2284,14 +2279,14 @@ public class PGraphicsOpenGL extends PGraphics { protected void clipImpl(float x1, float y1, float x2, float y2) { flush(); - pgl.glEnable(PGL.GL_SCISSOR_TEST); + pgl.enable(PGL.SCISSOR_TEST); float h = y2 - y1; clipRect[0] = (int)x1; clipRect[1] = (int)(height - y1 - h); clipRect[2] = (int)(x2 - x1); clipRect[3] = (int)h; - pgl.glScissor(clipRect[0], clipRect[1], clipRect[2], clipRect[3]); + pgl.scissor(clipRect[0], clipRect[1], clipRect[2], clipRect[3]); clip = true; } @@ -2300,7 +2295,7 @@ public class PGraphicsOpenGL extends PGraphics { public void noClip() { if (clip) { flush(); - pgl.glDisable(PGL.GL_SCISSOR_TEST); + pgl.disable(PGL.SCISSOR_TEST); clip = false; } } @@ -2483,25 +2478,25 @@ public class PGraphicsOpenGL extends PGraphics { cache.indexOffset[n] + cache.indexCount[n] - ioffset; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(glPolyVertex, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(glPolyColor, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setVertexAttribute(glPolyVertex, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(glPolyColor, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); if (lights) { - shader.setNormalAttribute(glPolyNormal, 3, PGL.GL_FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); - shader.setAmbientAttribute(glPolyAmbient, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setSpecularAttribute(glPolySpecular, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setEmissiveAttribute(glPolyEmissive, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setShininessAttribute(glPolyShininess, 1, PGL.GL_FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); + shader.setNormalAttribute(glPolyNormal, 3, PGL.FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); + shader.setAmbientAttribute(glPolyAmbient, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setSpecularAttribute(glPolySpecular, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setEmissiveAttribute(glPolyEmissive, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setShininessAttribute(glPolyShininess, 1, PGL.FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); } if (tex != null) { - shader.setTexcoordAttribute(glPolyTexcoord, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); + shader.setTexcoordAttribute(glPolyTexcoord, 2, PGL.FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); shader.setTexture(tex); } - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndex); - pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex); + pgl.drawElements(PGL.TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } shader.unbind(); @@ -2621,13 +2616,13 @@ public class PGraphicsOpenGL extends PGraphics { int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(glLineVertex, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(glLineColor, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setLineAttribute(glLineAttrib, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setVertexAttribute(glLineVertex, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(glLineColor, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setLineAttribute(glLineAttrib, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glLineIndex); - pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glLineIndex); + pgl.drawElements(PGL.TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } shader.unbind(); @@ -2719,13 +2714,13 @@ public class PGraphicsOpenGL extends PGraphics { int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(glPointVertex, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(glPointColor, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setPointAttribute(glPointAttrib, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); + shader.setVertexAttribute(glPointVertex, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(glPointColor, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setPointAttribute(glPointAttrib, 2, PGL.FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPointIndex); - pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPointIndex); + pgl.drawElements(PGL.TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } shader.unbind(); @@ -4840,17 +4835,17 @@ public class PGraphicsOpenGL extends PGraphics { protected void backgroundImpl() { flush(); - pgl.glDepthMask(true); - pgl.glClearDepth(1); - pgl.glClear(PGL.GL_DEPTH_BUFFER_BIT); + pgl.depthMask(true); + pgl.clearDepth(1); + pgl.clear(PGL.DEPTH_BUFFER_BIT); if (hints[DISABLE_DEPTH_MASK]) { - pgl.glDepthMask(false); + pgl.depthMask(false); } else { - pgl.glDepthMask(true); + pgl.depthMask(true); } - pgl.glClearColor(backgroundR, backgroundG, backgroundB, backgroundA); - pgl.glClear(PGL.GL_COLOR_BUFFER_BIT); + pgl.clearColor(backgroundR, backgroundG, backgroundB, backgroundA); + pgl.clear(PGL.COLOR_BUFFER_BIT); if (0 < parent.frameCount) { clearColorBuffer = true; } @@ -4903,9 +4898,9 @@ public class PGraphicsOpenGL extends PGraphics { */ public void report(String where) { if (!hints[DISABLE_OPENGL_ERROR_REPORT]) { - int err = pgl.glGetError(); + int err = pgl.getError(); if (err != 0) { - String errString = pgl.glErrorString(err); + String errString = pgl.errorString(err); String msg = "OpenGL error " + err + " at " + where + ": " + errString; PGraphics.showWarning(msg); } @@ -4988,7 +4983,7 @@ public class PGraphicsOpenGL extends PGraphics { protected void readPixels() { beginPixelsOp(OP_READ); pixelBuffer.rewind(); - pgl.glReadPixels(0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixelBuffer); + pgl.readPixels(0, 0, width, height, PGL.RGBA, PGL.UNSIGNED_BYTE, pixelBuffer); endPixelsOp(); PGL.nativeToJavaARGB(pixels, width, height); @@ -5096,7 +5091,7 @@ public class PGraphicsOpenGL extends PGraphics { } beginPixelsOp(OP_READ); - pgl.glReadPixels(0, 0, width, height, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, nativePixelBuffer); + pgl.readPixels(0, 0, width, height, PGL.RGBA, PGL.UNSIGNED_BYTE, nativePixelBuffer); endPixelsOp(); texture.setNative(nativePixels, 0, 0, width, height); @@ -5114,10 +5109,10 @@ public class PGraphicsOpenGL extends PGraphics { pushFramebuffer(); setFramebuffer(offscreenFramebuffer); } - pgl.glColorMask(false, false, false, true); - pgl.glClearColor(0, 0, 0, 1); - pgl.glClear(PGL.GL_COLOR_BUFFER_BIT); - pgl.glColorMask(true, true, true, true); + pgl.colorMask(false, false, false, true); + pgl.clearColor(0, 0, 0, 1); + pgl.clear(PGL.COLOR_BUFFER_BIT); + pgl.colorMask(true, true, true, true); if (offscreenMultisample) { popFramebuffer(); } @@ -5316,10 +5311,10 @@ public class PGraphicsOpenGL extends PGraphics { // Disable writing to the depth buffer, so that after applying the filter we can // still use the depth information to keep adding geometry to the scene. - pgl.glDepthMask(false); + pgl.depthMask(false); // Also disabling depth testing so the texture is drawn on top of everything that // has been drawn before. - pgl.glDisable(PGL.GL_DEPTH_TEST); + pgl.disable(PGL.DEPTH_TEST); PolyTexShader prevTexShader = polyTexShader; polyTexShader = (PolyTexShader) shader; @@ -5351,10 +5346,10 @@ public class PGraphicsOpenGL extends PGraphics { polyTexShader = prevTexShader; if (!hints[DISABLE_DEPTH_TEST]) { - pgl.glEnable(PGL.GL_DEPTH_TEST); + pgl.enable(PGL.DEPTH_TEST); } if (!hints[DISABLE_DEPTH_MASK]) { - pgl.glDepthMask(true); + pgl.depthMask(true); } } @@ -5421,67 +5416,67 @@ public class PGraphicsOpenGL extends PGraphics { flush(); blendMode = mode; - pgl.glEnable(PGL.GL_BLEND); + pgl.enable(PGL.BLEND); if (mode == REPLACE) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_ONE, PGL.GL_ZERO); + pgl.blendFunc(PGL.ONE, PGL.ZERO); } else if (mode == BLEND) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_SRC_ALPHA, PGL.GL_ONE_MINUS_SRC_ALPHA); + pgl.blendFunc(PGL.SRC_ALPHA, PGL.ONE_MINUS_SRC_ALPHA); } else if (mode == ADD) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_SRC_ALPHA, PGL.GL_ONE); + pgl.blendFunc(PGL.SRC_ALPHA, PGL.ONE); } else if (mode == SUBTRACT) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_ONE_MINUS_DST_COLOR, PGL.GL_ZERO); + pgl.blendFunc(PGL.ONE_MINUS_DST_COLOR, PGL.ZERO); } else if (mode == LIGHTEST) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_MAX); + pgl.blendEquation(PGL.FUNC_MAX); } else { PGraphics.showWarning("This blend mode is not supported"); return; } - pgl.glBlendFunc(PGL.GL_SRC_ALPHA, PGL.GL_DST_ALPHA); + pgl.blendFunc(PGL.SRC_ALPHA, PGL.DST_ALPHA); } else if (mode == DARKEST) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_MIN); + pgl.blendEquation(PGL.FUNC_MIN); } else { PGraphics.showWarning("This blend mode is not supported"); return; } - pgl.glBlendFunc(PGL.GL_SRC_ALPHA, PGL.GL_DST_ALPHA); + pgl.blendFunc(PGL.SRC_ALPHA, PGL.DST_ALPHA); } else if (mode == DIFFERENCE) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_REVERSE_SUBTRACT); + pgl.blendEquation(PGL.FUNC_REVERSE_SUBTRACT); } else { PGraphics.showWarning("This blend mode is not supported"); return; } - pgl.glBlendFunc(PGL.GL_ONE, PGL.GL_ONE); + pgl.blendFunc(PGL.ONE, PGL.ONE); } else if (mode == EXCLUSION) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_ONE_MINUS_DST_COLOR, PGL.GL_ONE_MINUS_SRC_COLOR); + pgl.blendFunc(PGL.ONE_MINUS_DST_COLOR, PGL.ONE_MINUS_SRC_COLOR); } else if (mode == MULTIPLY) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_DST_COLOR, PGL.GL_SRC_COLOR); + pgl.blendFunc(PGL.DST_COLOR, PGL.SRC_COLOR); } else if (mode == SCREEN) { if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_ONE_MINUS_DST_COLOR, PGL.GL_ONE); + pgl.blendFunc(PGL.ONE_MINUS_DST_COLOR, PGL.ONE); } // HARD_LIGHT, SOFT_LIGHT, OVERLAY, DODGE, BURN modes cannot be implemented // in fixed-function pipeline because they require conditional blending and @@ -5492,11 +5487,11 @@ public class PGraphicsOpenGL extends PGraphics { protected void setDefaultBlend() { blendMode = BLEND; - pgl.glEnable(PGL.GL_BLEND); + pgl.enable(PGL.BLEND); if (blendEqSupported) { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); } - pgl.glBlendFunc(PGL.GL_SRC_ALPHA, PGL.GL_ONE_MINUS_SRC_ALPHA); + pgl.blendFunc(PGL.SRC_ALPHA, PGL.ONE_MINUS_SRC_ALPHA); } @@ -5695,11 +5690,11 @@ public class PGraphicsOpenGL extends PGraphics { protected void getGLParameters() { - OPENGL_VENDOR = pgl.glGetString(PGL.GL_VENDOR); - OPENGL_RENDERER = pgl.glGetString(PGL.GL_RENDERER); - OPENGL_VERSION = pgl.glGetString(PGL.GL_VERSION); - OPENGL_EXTENSIONS = pgl.glGetString(PGL.GL_EXTENSIONS); - GLSL_VERSION = pgl.glGetString(PGL.GL_SHADING_LANGUAGE_VERSION); + OPENGL_VENDOR = pgl.getString(PGL.VENDOR); + OPENGL_RENDERER = pgl.getString(PGL.RENDERER); + OPENGL_VERSION = pgl.getString(PGL.VERSION); + OPENGL_EXTENSIONS = pgl.getString(PGL.EXTENSIONS); + GLSL_VERSION = pgl.getString(PGL.SHADING_LANGUAGE_VERSION); npotTexSupported = -1 < OPENGL_EXTENSIONS.indexOf("texture_non_power_of_two"); autoMipmapGenSupported = -1 < OPENGL_EXTENSIONS.indexOf("generate_mipmap"); @@ -5707,7 +5702,7 @@ public class PGraphicsOpenGL extends PGraphics { packedDepthStencilSupported = -1 < OPENGL_EXTENSIONS.indexOf("packed_depth_stencil"); try { - pgl.glBlendEquation(PGL.GL_FUNC_ADD); + pgl.blendEquation(PGL.FUNC_ADD); blendEqSupported = true; } catch (Exception e) { blendEqSupported = false; @@ -5715,22 +5710,22 @@ public class PGraphicsOpenGL extends PGraphics { int temp[] = new int[2]; - pgl.glGetIntegerv(PGL.GL_MAX_TEXTURE_SIZE, temp, 0); + pgl.getIntegerv(PGL.MAX_TEXTURE_SIZE, temp, 0); maxTextureSize = temp[0]; - pgl.glGetIntegerv(PGL.GL_MAX_SAMPLES, temp, 0); + pgl.getIntegerv(PGL.MAX_SAMPLES, temp, 0); maxSamples = temp[0]; - pgl.glGetIntegerv(PGL.GL_ALIASED_LINE_WIDTH_RANGE, temp, 0); + pgl.getIntegerv(PGL.ALIASED_LINE_WIDTH_RANGE, temp, 0); maxLineWidth = temp[1]; - pgl.glGetIntegerv(PGL.GL_ALIASED_POINT_SIZE_RANGE, temp, 0); + pgl.getIntegerv(PGL.ALIASED_POINT_SIZE_RANGE, temp, 0); maxPointSize = temp[1]; - pgl.glGetIntegerv(PGL.GL_DEPTH_BITS, temp, 0); + pgl.getIntegerv(PGL.DEPTH_BITS, temp, 0); depthBits = temp[0]; - pgl.glGetIntegerv(PGL.GL_STENCIL_BITS, temp, 0); + pgl.getIntegerv(PGL.STENCIL_BITS, temp, 0); stencilBits = temp[0]; glParamsRead = true; @@ -6064,8 +6059,8 @@ public class PGraphicsOpenGL extends PGraphics { public void bind() { super.bind(); - if (-1 < inVertexLoc) pgl.glEnableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glEnableVertexAttribArray(inColorLoc); + if (-1 < inVertexLoc) pgl.enableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.enableVertexAttribArray(inColorLoc); if (pgCurrent != null) { if (-1 < projmodelviewMatrixLoc) { @@ -6086,10 +6081,10 @@ public class PGraphicsOpenGL extends PGraphics { } public void unbind() { - if (-1 < inVertexLoc) pgl.glDisableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glDisableVertexAttribArray(inColorLoc); + if (-1 < inVertexLoc) pgl.disableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.disableVertexAttribArray(inColorLoc); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); super.unbind(); } @@ -6190,14 +6185,14 @@ public class PGraphicsOpenGL extends PGraphics { public void bind() { super.bind(); - if (-1 < inVertexLoc) pgl.glEnableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glEnableVertexAttribArray(inColorLoc); - if (-1 < inNormalLoc) pgl.glEnableVertexAttribArray(inNormalLoc); + if (-1 < inVertexLoc) pgl.enableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.enableVertexAttribArray(inColorLoc); + if (-1 < inNormalLoc) pgl.enableVertexAttribArray(inNormalLoc); - if (-1 < inAmbientLoc) pgl.glEnableVertexAttribArray(inAmbientLoc); - if (-1 < inSpecularLoc) pgl.glEnableVertexAttribArray(inSpecularLoc); - if (-1 < inEmissiveLoc) pgl.glEnableVertexAttribArray(inEmissiveLoc); - if (-1 < inShineLoc) pgl.glEnableVertexAttribArray(inShineLoc); + if (-1 < inAmbientLoc) pgl.enableVertexAttribArray(inAmbientLoc); + if (-1 < inSpecularLoc) pgl.enableVertexAttribArray(inSpecularLoc); + if (-1 < inEmissiveLoc) pgl.enableVertexAttribArray(inEmissiveLoc); + if (-1 < inShineLoc) pgl.enableVertexAttribArray(inShineLoc); if (pgCurrent != null) { if (-1 < projmodelviewMatrixLoc) { @@ -6232,16 +6227,16 @@ public class PGraphicsOpenGL extends PGraphics { } public void unbind() { - if (-1 < inVertexLoc) pgl.glDisableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glDisableVertexAttribArray(inColorLoc); - if (-1 < inNormalLoc) pgl.glDisableVertexAttribArray(inNormalLoc); + if (-1 < inVertexLoc) pgl.disableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.disableVertexAttribArray(inColorLoc); + if (-1 < inNormalLoc) pgl.disableVertexAttribArray(inNormalLoc); - if (-1 < inAmbientLoc) pgl.glDisableVertexAttribArray(inAmbientLoc); - if (-1 < inSpecularLoc) pgl.glDisableVertexAttribArray(inSpecularLoc); - if (-1 < inEmissiveLoc) pgl.glDisableVertexAttribArray(inEmissiveLoc); - if (-1 < inShineLoc) pgl.glDisableVertexAttribArray(inShineLoc); + if (-1 < inAmbientLoc) pgl.disableVertexAttribArray(inAmbientLoc); + if (-1 < inSpecularLoc) pgl.disableVertexAttribArray(inSpecularLoc); + if (-1 < inEmissiveLoc) pgl.disableVertexAttribArray(inEmissiveLoc); + if (-1 < inShineLoc) pgl.disableVertexAttribArray(inShineLoc); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); super.unbind(); } @@ -6329,11 +6324,11 @@ public class PGraphicsOpenGL extends PGraphics { super.bind(); - if (-1 < inTexcoordLoc) pgl.glEnableVertexAttribArray(inTexcoordLoc); + if (-1 < inTexcoordLoc) pgl.enableVertexAttribArray(inTexcoordLoc); } public void unbind() { - if (-1 < inTexcoordLoc) pgl.glDisableVertexAttribArray(inTexcoordLoc); + if (-1 < inTexcoordLoc) pgl.disableVertexAttribArray(inTexcoordLoc); super.unbind(); } @@ -6421,11 +6416,11 @@ public class PGraphicsOpenGL extends PGraphics { super.bind(); - if (-1 < inTexcoordLoc) pgl.glEnableVertexAttribArray(inTexcoordLoc); + if (-1 < inTexcoordLoc) pgl.enableVertexAttribArray(inTexcoordLoc); } public void unbind() { - if (-1 < inTexcoordLoc) pgl.glDisableVertexAttribArray(inTexcoordLoc); + if (-1 < inTexcoordLoc) pgl.disableVertexAttribArray(inTexcoordLoc); super.unbind(); } @@ -6488,9 +6483,9 @@ public class PGraphicsOpenGL extends PGraphics { public void bind() { super.bind(); - if (-1 < inVertexLoc) pgl.glEnableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glEnableVertexAttribArray(inColorLoc); - if (-1 < inAttribLoc) pgl.glEnableVertexAttribArray(inAttribLoc); + if (-1 < inVertexLoc) pgl.enableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.enableVertexAttribArray(inColorLoc); + if (-1 < inAttribLoc) pgl.enableVertexAttribArray(inAttribLoc); if (pgCurrent != null) { if (-1 < projmodelviewMatrixLoc) { @@ -6533,11 +6528,11 @@ public class PGraphicsOpenGL extends PGraphics { } public void unbind() { - if (-1 < inVertexLoc) pgl.glDisableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glDisableVertexAttribArray(inColorLoc); - if (-1 < inAttribLoc) pgl.glDisableVertexAttribArray(inAttribLoc); + if (-1 < inVertexLoc) pgl.disableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.disableVertexAttribArray(inColorLoc); + if (-1 < inAttribLoc) pgl.disableVertexAttribArray(inAttribLoc); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); super.unbind(); } @@ -6592,9 +6587,9 @@ public class PGraphicsOpenGL extends PGraphics { public void bind() { super.bind(); - if (-1 < inVertexLoc) pgl.glEnableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glEnableVertexAttribArray(inColorLoc); - if (-1 < inPointLoc) pgl.glEnableVertexAttribArray(inPointLoc); + if (-1 < inVertexLoc) pgl.enableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.enableVertexAttribArray(inColorLoc); + if (-1 < inPointLoc) pgl.enableVertexAttribArray(inPointLoc); if (pgCurrent != null) { if (-1 < projmodelviewMatrixLoc) { @@ -6615,11 +6610,11 @@ public class PGraphicsOpenGL extends PGraphics { } public void unbind() { - if (-1 < inVertexLoc) pgl.glDisableVertexAttribArray(inVertexLoc); - if (-1 < inColorLoc) pgl.glDisableVertexAttribArray(inColorLoc); - if (-1 < inPointLoc) pgl.glDisableVertexAttribArray(inPointLoc); + if (-1 < inVertexLoc) pgl.disableVertexAttribArray(inVertexLoc); + if (-1 < inColorLoc) pgl.disableVertexAttribArray(inColorLoc); + if (-1 < inPointLoc) pgl.disableVertexAttribArray(inPointLoc); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); super.unbind(); } @@ -10708,10 +10703,10 @@ public class PGraphicsOpenGL extends PGraphics { if (solid) { // Using NONZERO winding rule for solid polygons. - gluTess.setWindingRule(PGL.GLU_TESS_WINDING_NONZERO); + gluTess.setWindingRule(PGL.TESS_WINDING_NONZERO); } else { // Using ODD winding rule to generate polygon with holes. - gluTess.setWindingRule(PGL.GLU_TESS_WINDING_ODD); + gluTess.setWindingRule(PGL.TESS_WINDING_ODD); } gluTess.beginContour(); @@ -10788,10 +10783,10 @@ public class PGraphicsOpenGL extends PGraphics { int rule = iter.getWindingRule(); switch(rule) { case LinePath.WIND_EVEN_ODD: - gluTess.setWindingRule(PGL.GLU_TESS_WINDING_ODD); + gluTess.setWindingRule(PGL.TESS_WINDING_ODD); break; case LinePath.WIND_NON_ZERO: - gluTess.setWindingRule(PGL.GLU_TESS_WINDING_NONZERO); + gluTess.setWindingRule(PGL.TESS_WINDING_NONZERO); break; } @@ -10876,13 +10871,13 @@ public class PGraphicsOpenGL extends PGraphics { vertCount = 0; switch (type) { - case PGL.GL_TRIANGLE_FAN: + case PGL.TRIANGLE_FAN: primitive = TRIANGLE_FAN; break; - case PGL.GL_TRIANGLE_STRIP: + case PGL.TRIANGLE_STRIP: primitive = TRIANGLE_STRIP; break; - case PGL.GL_TRIANGLES: + case PGL.TRIANGLES: primitive = TRIANGLES; break; } @@ -10992,7 +10987,7 @@ public class PGraphicsOpenGL extends PGraphics { } public void error(int errnum) { - String estring = pgl.gluErrorString(errnum); + String estring = pgl.tessError(errnum); PGraphics.showWarning("Tessellation Error: " + estring); } diff --git a/android/core/src/processing/opengl/PShader.java b/android/core/src/processing/opengl/PShader.java index 7bb85c5e2..5e7179eae 100644 --- a/android/core/src/processing/opengl/PShader.java +++ b/android/core/src/processing/opengl/PShader.java @@ -189,7 +189,7 @@ public class PShader { */ public void bind() { init(); - pgl.glUseProgram(glProgram); + pgl.useProgram(glProgram); bound = true; consumeUniforms(); bindTextures(); @@ -201,7 +201,7 @@ public class PShader { */ public void unbind() { unbindTextures(); - pgl.glUseProgram(0); + pgl.useProgram(0); bound = false; } @@ -345,7 +345,7 @@ public class PShader { */ protected int getAttributeLoc(String name) { init(); - return pgl.glGetAttribLocation(glProgram, name); + return pgl.getAttribLocation(glProgram, name); } @@ -357,69 +357,69 @@ public class PShader { */ protected int getUniformLoc(String name) { init(); - return pgl.glGetUniformLocation(glProgram, name); + return pgl.getUniformLocation(glProgram, name); } protected void setAttributeVBO(int loc, int vboId, int size, int type, boolean normalized, int stride, int offset) { if (-1 < loc) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, vboId); - pgl.glVertexAttribPointer(loc, size, type, normalized, stride, offset); + pgl.bindBuffer(PGL.ARRAY_BUFFER, vboId); + pgl.vertexAttribPointer(loc, size, type, normalized, stride, offset); } } protected void setUniformValue(int loc, int x) { if (-1 < loc) { - pgl.glUniform1i(loc, x); + pgl.uniform1i(loc, x); } } protected void setUniformValue(int loc, int x, int y) { if (-1 < loc) { - pgl.glUniform2i(loc, x, y); + pgl.uniform2i(loc, x, y); } } protected void setUniformValue(int loc, int x, int y, int z) { if (-1 < loc) { - pgl.glUniform3i(loc, x, y, z); + pgl.uniform3i(loc, x, y, z); } } protected void setUniformValue(int loc, int x, int y, int z, int w) { if (-1 < loc) { - pgl.glUniform4i(loc, x, y, z, w); + pgl.uniform4i(loc, x, y, z, w); } } protected void setUniformValue(int loc, float x) { if (-1 < loc) { - pgl.glUniform1f(loc, x); + pgl.uniform1f(loc, x); } } protected void setUniformValue(int loc, float x, float y) { if (-1 < loc) { - pgl.glUniform2f(loc, x, y); + pgl.uniform2f(loc, x, y); } } protected void setUniformValue(int loc, float x, float y, float z) { if (-1 < loc) { - pgl.glUniform3f(loc, x, y, z); + pgl.uniform3f(loc, x, y, z); } } protected void setUniformValue(int loc, float x, float y, float z, float w) { if (-1 < loc) { - pgl.glUniform4f(loc, x, y, z, w); + pgl.uniform4f(loc, x, y, z, w); } } @@ -427,13 +427,13 @@ public class PShader { protected void setUniformVector(int loc, int[] vec, int ncoords) { if (-1 < loc) { if (ncoords == 1) { - pgl.glUniform1iv(loc, vec.length, vec, 0); + pgl.uniform1iv(loc, vec.length, vec, 0); } else if (ncoords == 2) { - pgl.glUniform2iv(loc, vec.length / 2, vec, 0); + pgl.uniform2iv(loc, vec.length / 2, vec, 0); } else if (ncoords == 3) { - pgl.glUniform3iv(loc, vec.length / 3, vec, 0); + pgl.uniform3iv(loc, vec.length / 3, vec, 0); } else if (ncoords == 4) { - pgl.glUniform3iv(loc, vec.length / 4, vec, 0); + pgl.uniform3iv(loc, vec.length / 4, vec, 0); } } } @@ -442,13 +442,13 @@ public class PShader { protected void setUniformVector(int loc, float[] vec, int ncoords) { if (-1 < loc) { if (ncoords == 1) { - pgl.glUniform1fv(loc, vec.length, vec, 0); + pgl.uniform1fv(loc, vec.length, vec, 0); } else if (ncoords == 2) { - pgl.glUniform2fv(loc, vec.length / 2, vec, 0); + pgl.uniform2fv(loc, vec.length / 2, vec, 0); } else if (ncoords == 3) { - pgl.glUniform3fv(loc, vec.length / 3, vec, 0); + pgl.uniform3fv(loc, vec.length / 3, vec, 0); } else if (ncoords == 4) { - pgl.glUniform4fv(loc, vec.length / 4, vec, 0); + pgl.uniform4fv(loc, vec.length / 4, vec, 0); } } } @@ -457,11 +457,11 @@ public class PShader { protected void setUniformMatrix(int loc, float[] mat) { if (-1 < loc) { if (mat.length == 4) { - pgl.glUniformMatrix2fv(loc, 1, false, mat, 0); + pgl.uniformMatrix2fv(loc, 1, false, mat, 0); } else if (mat.length == 9) { - pgl.glUniformMatrix3fv(loc, 1, false, mat, 0); + pgl.uniformMatrix3fv(loc, 1, false, mat, 0); } else if (mat.length == 16) { - pgl.glUniformMatrix4fv(loc, 1, false, mat, 0); + pgl.uniformMatrix4fv(loc, 1, false, mat, 0); } } } @@ -521,65 +521,65 @@ public class PShader { UniformValue val = uniformValues.get(loc); if (val.type == UniformValue.INT1) { int[] v = ((int[])val.value); - pgl.glUniform1i(loc, v[0]); + pgl.uniform1i(loc, v[0]); } else if (val.type == UniformValue.INT2) { int[] v = ((int[])val.value); - pgl.glUniform2i(loc, v[0], v[1]); + pgl.uniform2i(loc, v[0], v[1]); } else if (val.type == UniformValue.INT3) { int[] v = ((int[])val.value); - pgl.glUniform3i(loc, v[0], v[1], v[2]); + pgl.uniform3i(loc, v[0], v[1], v[2]); } else if (val.type == UniformValue.INT4) { int[] v = ((int[])val.value); - pgl.glUniform4i(loc, v[0], v[1], v[2], v[4]); + pgl.uniform4i(loc, v[0], v[1], v[2], v[4]); } else if (val.type == UniformValue.FLOAT1) { float[] v = ((float[])val.value); - pgl.glUniform1f(loc, v[0]); + pgl.uniform1f(loc, v[0]); } else if (val.type == UniformValue.FLOAT2) { float[] v = ((float[])val.value); - pgl.glUniform2f(loc, v[0], v[1]); + pgl.uniform2f(loc, v[0], v[1]); } else if (val.type == UniformValue.FLOAT3) { float[] v = ((float[])val.value); - pgl.glUniform3f(loc, v[0], v[1], v[2]); + pgl.uniform3f(loc, v[0], v[1], v[2]); } else if (val.type == UniformValue.FLOAT4) { float[] v = ((float[])val.value); - pgl.glUniform4f(loc, v[0], v[1], v[2], v[3]); + pgl.uniform4f(loc, v[0], v[1], v[2], v[3]); } else if (val.type == UniformValue.INT1VEC) { int[] v = ((int[])val.value); - pgl.glUniform1iv(loc, v.length, v, 0); + pgl.uniform1iv(loc, v.length, v, 0); } else if (val.type == UniformValue.INT2VEC) { int[] v = ((int[])val.value); - pgl.glUniform2iv(loc, v.length / 2, v, 0); + pgl.uniform2iv(loc, v.length / 2, v, 0); } else if (val.type == UniformValue.INT3VEC) { int[] v = ((int[])val.value); - pgl.glUniform3iv(loc, v.length / 3, v, 0); + pgl.uniform3iv(loc, v.length / 3, v, 0); } else if (val.type == UniformValue.INT4VEC) { int[] v = ((int[])val.value); - pgl.glUniform4iv(loc, v.length / 4, v, 0); + pgl.uniform4iv(loc, v.length / 4, v, 0); } else if (val.type == UniformValue.FLOAT1VEC) { float[] v = ((float[])val.value); - pgl.glUniform1fv(loc, v.length, v, 0); + pgl.uniform1fv(loc, v.length, v, 0); } else if (val.type == UniformValue.FLOAT2VEC) { float[] v = ((float[])val.value); - pgl.glUniform2fv(loc, v.length / 2, v, 0); + pgl.uniform2fv(loc, v.length / 2, v, 0); } else if (val.type == UniformValue.FLOAT3VEC) { float[] v = ((float[])val.value); - pgl.glUniform3fv(loc, v.length / 3, v, 0); + pgl.uniform3fv(loc, v.length / 3, v, 0); } else if (val.type == UniformValue.FLOAT4VEC) { float[] v = ((float[])val.value); - pgl.glUniform4fv(loc, v.length / 4, v, 0); + pgl.uniform4fv(loc, v.length / 4, v, 0); } else if (val.type == UniformValue.MAT2) { float[] v = ((float[])val.value); - pgl.glUniformMatrix2fv(loc, 1, false, v, 0); + pgl.uniformMatrix2fv(loc, 1, false, v, 0); } else if (val.type == UniformValue.MAT3) { float[] v = ((float[])val.value); - pgl.glUniformMatrix3fv(loc, 1, false, v, 0); + pgl.uniformMatrix3fv(loc, 1, false, v, 0); } else if (val.type == UniformValue.MAT4) { float[] v = ((float[])val.value); - pgl.glUniformMatrix4fv(loc, 1, false, v, 0); + pgl.uniformMatrix4fv(loc, 1, false, v, 0); } else if (val.type == UniformValue.SAMPLER2D) { PImage img = (PImage)val.value; Texture tex = pgMain.getTexture(img); - pgl.glUniform1i(loc, texUnit); + pgl.uniform1i(loc, texUnit); if (textures == null) { textures = new HashMap(); } @@ -596,7 +596,7 @@ public class PShader { if (textures != null) { for (int unit: textures.keySet()) { Texture tex = textures.get(unit); - pgl.glActiveTexture(PGL.GL_TEXTURE0 + unit); + pgl.activeTexture(PGL.TEXTURE0 + unit); tex.bind(); } } @@ -607,10 +607,10 @@ public class PShader { if (textures != null) { for (int unit: textures.keySet()) { Texture tex = textures.get(unit); - pgl.glActiveTexture(PGL.GL_TEXTURE0 + unit); + pgl.activeTexture(PGL.TEXTURE0 + unit); tex.unbind(); } - pgl.glActiveTexture(PGL.GL_TEXTURE0); + pgl.activeTexture(PGL.TEXTURE0); } } @@ -650,25 +650,25 @@ public class PShader { if (vertRes && fragRes) { if (hasVert) { - pgl.glAttachShader(glProgram, glVertex); + pgl.attachShader(glProgram, glVertex); } if (hasFrag) { - pgl.glAttachShader(glProgram, glFragment); + pgl.attachShader(glProgram, glFragment); } - pgl.glLinkProgram(glProgram); + pgl.linkProgram(glProgram); int[] linked = new int[1]; - pgl.glGetProgramiv(glProgram, PGL.GL_LINK_STATUS, linked, 0); - if (linked[0] == PGL.GL_FALSE) { - PGraphics.showException("Cannot link shader program:\n" + pgl.glGetProgramInfoLog(glProgram)); + pgl.getProgramiv(glProgram, PGL.LINK_STATUS, linked, 0); + if (linked[0] == PGL.FALSE) { + PGraphics.showException("Cannot link shader program:\n" + pgl.getProgramInfoLog(glProgram)); } - pgl.glValidateProgram(glProgram); + pgl.validateProgram(glProgram); int[] validated = new int[1]; - pgl.glGetProgramiv(glProgram, PGL.GL_VALIDATE_STATUS, validated, 0); - if (validated[0] == PGL.GL_FALSE) { - PGraphics.showException("Cannot validate shader program:\n" + pgl.glGetProgramInfoLog(glProgram)); + pgl.getProgramiv(glProgram, PGL.VALIDATE_STATUS, validated, 0); + if (validated[0] == PGL.FALSE) { + PGraphics.showException("Cannot validate shader program:\n" + pgl.getProgramInfoLog(glProgram)); } } } @@ -750,13 +750,13 @@ public class PShader { protected boolean compileVertexShader() { glVertex = pgMain.createGLSLVertShaderObject(context.code()); - pgl.glShaderSource(glVertex, vertexShaderSource); - pgl.glCompileShader(glVertex); + pgl.shaderSource(glVertex, vertexShaderSource); + pgl.compileShader(glVertex); int[] compiled = new int[1]; - pgl.glGetShaderiv(glVertex, PGL.GL_COMPILE_STATUS, compiled, 0); - if (compiled[0] == PGL.GL_FALSE) { - PGraphics.showException("Cannot compile vertex shader:\n" + pgl.glGetShaderInfoLog(glVertex)); + pgl.getShaderiv(glVertex, PGL.COMPILE_STATUS, compiled, 0); + if (compiled[0] == PGL.FALSE) { + PGraphics.showException("Cannot compile vertex shader:\n" + pgl.getShaderInfoLog(glVertex)); return false; } else { return true; @@ -770,13 +770,13 @@ public class PShader { protected boolean compileFragmentShader() { glFragment = pgMain.createGLSLFragShaderObject(context.code()); - pgl.glShaderSource(glFragment, fragmentShaderSource); - pgl.glCompileShader(glFragment); + pgl.shaderSource(glFragment, fragmentShaderSource); + pgl.compileShader(glFragment); int[] compiled = new int[1]; - pgl.glGetShaderiv(glFragment, PGL.GL_COMPILE_STATUS, compiled, 0); - if (compiled[0] == PGL.GL_FALSE) { - PGraphics.showException("Cannot compile fragment shader:\n" + pgl.glGetShaderInfoLog(glFragment)); + pgl.getShaderiv(glFragment, PGL.COMPILE_STATUS, compiled, 0); + if (compiled[0] == PGL.FALSE) { + PGraphics.showException("Cannot compile fragment shader:\n" + pgl.getShaderInfoLog(glFragment)); return false; } else { return true; diff --git a/android/core/src/processing/opengl/PShapeOpenGL.java b/android/core/src/processing/opengl/PShapeOpenGL.java index cf7137859..6b0668763 100644 --- a/android/core/src/processing/opengl/PShapeOpenGL.java +++ b/android/core/src/processing/opengl/PShapeOpenGL.java @@ -3123,45 +3123,45 @@ public class PShapeOpenGL extends PShape { int sizei = size * PGL.SIZEOF_INT; glPolyVertex = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size), PGL.STATIC_DRAW); glPolyColor = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyColors, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyColors, 0, size), PGL.STATIC_DRAW); glPolyNormal = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormal); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal); + pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size), PGL.STATIC_DRAW); glPolyTexcoord = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoord); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord); + pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size), PGL.STATIC_DRAW); glPolyAmbient = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbient); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyAmbient, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyAmbient, 0, size), PGL.STATIC_DRAW); glPolySpecular = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecular); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polySpecular, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polySpecular, 0, size), PGL.STATIC_DRAW); glPolyEmissive = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissive); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyEmissive, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyEmissive, 0, size), PGL.STATIC_DRAW); glPolyShininess = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininess); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.polyShininess, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess); + pgl.bufferData(PGL.ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.polyShininess, 0, size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); glPolyIndex = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.polyIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.polyIndices, 0, tessGeo.polyIndexCount), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPolyIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, tessGeo.polyIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.polyIndices, 0, tessGeo.polyIndexCount), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } @@ -3171,25 +3171,25 @@ public class PShapeOpenGL extends PShape { int sizei = size * PGL.SIZEOF_INT; glLineVertex = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineVertices, 0, 4 * size), PGL.STATIC_DRAW); glLineColor = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.lineColors, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.lineColors, 0, size), PGL.STATIC_DRAW); glLineAttrib = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineAttrib); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineAttribs, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.lineAttribs, 0, 4 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); glLineIndex = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glLineIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.lineIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.lineIndices, 0, tessGeo.lineIndexCount), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glLineIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, tessGeo.lineIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.lineIndices, 0, tessGeo.lineIndexCount), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } @@ -3199,25 +3199,25 @@ public class PShapeOpenGL extends PShape { int sizei = size * PGL.SIZEOF_INT; glPointVertex = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointVertex); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.pointVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex); + pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.pointVertices, 0, 4 * size), PGL.STATIC_DRAW); glPointColor = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointColor); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.pointColors, 0, size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor); + pgl.bufferData(PGL.ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.pointColors, 0, size), PGL.STATIC_DRAW); glPointAttrib = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointAttrib); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.pointAttribs, 0, 2 * size), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib); + pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.pointAttribs, 0, 2 * size), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); glPointIndex = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPointIndex); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.pointIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.pointIndices, 0, tessGeo.pointIndexCount), PGL.GL_STATIC_DRAW); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, glPointIndex); + pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER, tessGeo.pointIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.pointIndices, 0, tessGeo.pointIndexCount), PGL.STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } @@ -3520,114 +3520,114 @@ public class PShapeOpenGL extends PShape { protected void copyPolyVertices(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertex); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyVertex); + pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.polyVertices, 4 * offset, 4 * size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPolyColors(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColor); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyColor); + pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.polyColors, offset, size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPolyNormals(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormal); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 3 * offset * PGL.SIZEOF_FLOAT, 3 * size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyNormal); + pgl.bufferSubData(PGL.ARRAY_BUFFER, 3 * offset * PGL.SIZEOF_FLOAT, 3 * size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.polyNormals, 3 * offset, 3 * size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPolyTexcoords(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoord); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT, 2 * size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyTexcoord); + pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT, 2 * size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.polyTexcoords, 2 * offset, 2 * size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPolyAmbient(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbient); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyAmbient); + pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.polyAmbient, offset, size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPolySpecular(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecular); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolySpecular); + pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.polySpecular, offset, size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPolyEmissive(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissive); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyEmissive); + pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.polyEmissive, offset, size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPolyShininess(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininess); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_FLOAT, size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPolyShininess); + pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_FLOAT, size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.polyShininess, offset, size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyLineVertices(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineVertex); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineVertex); + pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.lineVertices, 4 * offset, 4 * size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyLineColors(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineColor); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineColor); + pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.lineColors, offset, size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyLineAttributes(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glLineAttrib); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glLineAttrib); + pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.lineAttribs, 4 * offset, 4 * size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPointVertices(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointVertex); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointVertex); + pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.pointVertices, 4 * offset, 4 * size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPointColors(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointColor); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointColor); + pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, IntBuffer.wrap(tessGeo.pointColors, offset, size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } protected void copyPointAttributes(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPointAttrib); - pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT, 2 * size * PGL.SIZEOF_FLOAT, + pgl.bindBuffer(PGL.ARRAY_BUFFER, glPointAttrib); + pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT, 2 * size * PGL.SIZEOF_FLOAT, FloatBuffer.wrap(tessGeo.pointAttribs, 2 * offset, 2 * size)); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); } @@ -3957,25 +3957,25 @@ public class PShapeOpenGL extends PShape { int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(root.glPolyVertex, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(root.glPolyColor, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setVertexAttribute(root.glPolyVertex, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(root.glPolyColor, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); if (g.lights) { - shader.setNormalAttribute(root.glPolyNormal, 3, PGL.GL_FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); - shader.setAmbientAttribute(root.glPolyAmbient, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setSpecularAttribute(root.glPolySpecular, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setEmissiveAttribute(root.glPolyEmissive, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setShininessAttribute(root.glPolyShininess, 1, PGL.GL_FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); + shader.setNormalAttribute(root.glPolyNormal, 3, PGL.FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); + shader.setAmbientAttribute(root.glPolyAmbient, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setSpecularAttribute(root.glPolySpecular, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setEmissiveAttribute(root.glPolyEmissive, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setShininessAttribute(root.glPolyShininess, 1, PGL.FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); } if (tex != null) { - shader.setTexcoordAttribute(root.glPolyTexcoord, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); + shader.setTexcoordAttribute(root.glPolyTexcoord, 2, PGL.FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); shader.setTexture(tex); } - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, root.glPolyIndex); - pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, root.glPolyIndex); + pgl.drawElements(PGL.TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } if (shader != null && shader.bound()) { @@ -4087,13 +4087,13 @@ public class PShapeOpenGL extends PShape { int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(root.glLineVertex, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(root.glLineColor, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setLineAttribute(root.glLineAttrib, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setVertexAttribute(root.glLineVertex, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(root.glLineColor, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setLineAttribute(root.glLineAttrib, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, root.glLineIndex); - pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, root.glLineIndex); + pgl.drawElements(PGL.TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } shader.unbind(); @@ -4181,13 +4181,13 @@ public class PShapeOpenGL extends PShape { int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(root.glPointVertex, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(root.glPointColor, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setPointAttribute(root.glPointAttrib, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); + shader.setVertexAttribute(root.glPointVertex, 4, PGL.FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(root.glPointColor, 4, PGL.UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setPointAttribute(root.glPointAttrib, 2, PGL.FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, root.glPointIndex); - pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, root.glPointIndex); + pgl.drawElements(PGL.TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); + pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0); } shader.unbind(); diff --git a/android/core/src/processing/opengl/Texture.java b/android/core/src/processing/opengl/Texture.java index c79ffd541..84eb2328d 100644 --- a/android/core/src/processing/opengl/Texture.java +++ b/android/core/src/processing/opengl/Texture.java @@ -297,15 +297,15 @@ public class Texture implements PConstants { pgl.enableTexturing(glTarget); enabledTex = true; } - pgl.glBindTexture(glTarget, glName); + pgl.bindTexture(glTarget, glName); if (usingMipmaps) { if (PGraphicsOpenGL.autoMipmapGenSupported) { // Automatic mipmap generation. int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); - pgl.glGenerateMipmap(glTarget); + pgl.texSubImage2D(glTarget, 0, x, y, w, h, PGL.RGBA, PGL.UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); + pgl.generateMipmap(glTarget); rgbaPixels = null; } else { // TODO: finish manual mipmap generation, replacing Bitmap with AWT's BufferedImage, @@ -364,17 +364,17 @@ public class Texture implements PConstants { int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); + pgl.texSubImage2D(glTarget, 0, x, y, w, h, PGL.RGBA, PGL.UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); rgbaPixels = null; } } else { int[] rgbaPixels = new int[w * h]; convertToRGBA(pixels, rgbaPixels, format, w, h); - pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); + pgl.texSubImage2D(glTarget, 0, x, y, w, h, PGL.RGBA, PGL.UNSIGNED_BYTE, IntBuffer.wrap(rgbaPixels)); rgbaPixels = null; } - pgl.glBindTexture(glTarget, 0); + pgl.bindTexture(glTarget, 0); if (enabledTex) { pgl.disableTexturing(glTarget); } @@ -419,20 +419,20 @@ public class Texture implements PConstants { pgl.enableTexturing(glTarget); enabledTex = true; } - pgl.glBindTexture(glTarget, glName); + pgl.bindTexture(glTarget, glName); if (usingMipmaps) { if (PGraphicsOpenGL.autoMipmapGenSupported) { - pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixels); - pgl.glGenerateMipmap(glTarget); + pgl.texSubImage2D(glTarget, 0, x, y, w, h, PGL.RGBA, PGL.UNSIGNED_BYTE, pixels); + pgl.generateMipmap(glTarget); } else { - pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixels); + pgl.texSubImage2D(glTarget, 0, x, y, w, h, PGL.RGBA, PGL.UNSIGNED_BYTE, pixels); } } else { - pgl.glTexSubImage2D(glTarget, 0, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, pixels); + pgl.texSubImage2D(glTarget, 0, x, y, w, h, PGL.RGBA, PGL.UNSIGNED_BYTE, pixels); } - pgl.glBindTexture(glTarget, 0); + pgl.bindTexture(glTarget, 0); if (enabledTex) { pgl.disableTexturing(glTarget); } @@ -602,7 +602,7 @@ public class Texture implements PConstants { if (!pgl.texturingIsEnabled(glTarget)) { pgl.enableTexturing(glTarget); } - pgl.glBindTexture(glTarget, glName); + pgl.bindTexture(glTarget, glName); bound = true; } @@ -613,10 +613,10 @@ public class Texture implements PConstants { // that might be bound instead of this one. if (!pgl.texturingIsEnabled(glTarget)) { pgl.enableTexturing(glTarget); - pgl.glBindTexture(glTarget, 0); + pgl.bindTexture(glTarget, 0); pgl.disableTexturing(glTarget); } else { - pgl.glBindTexture(glTarget, 0); + pgl.bindTexture(glTarget, 0); } } bound = false; @@ -1086,20 +1086,20 @@ public class Texture implements PConstants { context = pgl.getCurrentContext(); glName = pg.createTextureObject(context.code()); - pgl.glBindTexture(glTarget, glName); - pgl.glTexParameteri(glTarget, PGL.GL_TEXTURE_MIN_FILTER, glMinFilter); - pgl.glTexParameteri(glTarget, PGL.GL_TEXTURE_MAG_FILTER, glMagFilter); - pgl.glTexParameteri(glTarget, PGL.GL_TEXTURE_WRAP_S, glWrapS); - pgl.glTexParameteri(glTarget, PGL.GL_TEXTURE_WRAP_T, glWrapT); + pgl.bindTexture(glTarget, glName); + pgl.texParameteri(glTarget, PGL.TEXTURE_MIN_FILTER, glMinFilter); + pgl.texParameteri(glTarget, PGL.TEXTURE_MAG_FILTER, glMagFilter); + pgl.texParameteri(glTarget, PGL.TEXTURE_WRAP_S, glWrapS); + pgl.texParameteri(glTarget, PGL.TEXTURE_WRAP_T, glWrapT); // 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.glTexImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, null); + pgl.texImage2D(glTarget, 0, glFormat, glWidth, glHeight, 0, PGL.RGBA, PGL.UNSIGNED_BYTE, null); // Makes sure that the texture buffer in video memory doesn't contain any garbage. - pgl.initTexture(glTarget, PGL.GL_RGBA, width, height); + pgl.initTexture(glTarget, PGL.RGBA, width, height); - pgl.glBindTexture(glTarget, 0); + pgl.bindTexture(glTarget, 0); if (enabledTex) { pgl.disableTexturing(glTarget); } @@ -1242,47 +1242,47 @@ public class Texture implements PConstants { public Parameters getParameters() { Parameters res = new Parameters(); - if (glTarget == PGL.GL_TEXTURE_2D) { + if (glTarget == PGL.TEXTURE_2D) { res.target = TEX2D; } - if (glFormat == PGL.GL_RGB) { + if (glFormat == PGL.RGB) { res.format = RGB; - } else if (glFormat == PGL.GL_RGBA) { + } else if (glFormat == PGL.RGBA) { res.format = ARGB; - } else if (glFormat == PGL.GL_ALPHA) { + } else if (glFormat == PGL.ALPHA) { res.format = ALPHA; } - if (glMagFilter == PGL.GL_NEAREST && glMinFilter == PGL.GL_NEAREST) { + if (glMagFilter == PGL.NEAREST && glMinFilter == PGL.NEAREST) { res.sampling = POINT; res.mipmaps = false; - } else if (glMagFilter == PGL.GL_NEAREST && glMinFilter == PGL.GL_LINEAR) { + } else if (glMagFilter == PGL.NEAREST && glMinFilter == PGL.LINEAR) { res.sampling = LINEAR; res.mipmaps = false; - } else if (glMagFilter == PGL.GL_NEAREST && glMinFilter == PGL.GL_LINEAR_MIPMAP_NEAREST) { + } else if (glMagFilter == PGL.NEAREST && glMinFilter == PGL.LINEAR_MIPMAP_NEAREST) { res.sampling = LINEAR; res.mipmaps = true; - } else if (glMagFilter == PGL.GL_LINEAR && glMinFilter == PGL.GL_LINEAR) { + } else if (glMagFilter == PGL.LINEAR && glMinFilter == PGL.LINEAR) { res.sampling = BILINEAR; res.mipmaps = false; - } else if (glMagFilter == PGL.GL_LINEAR && glMinFilter == PGL.GL_LINEAR_MIPMAP_NEAREST) { + } else if (glMagFilter == PGL.LINEAR && glMinFilter == PGL.LINEAR_MIPMAP_NEAREST) { res.sampling = BILINEAR; res.mipmaps = true; - } else if (glMagFilter == PGL.GL_LINEAR && glMinFilter == PGL.GL_LINEAR_MIPMAP_LINEAR) { + } else if (glMagFilter == PGL.LINEAR && glMinFilter == PGL.LINEAR_MIPMAP_LINEAR) { res.sampling = TRILINEAR; res.mipmaps = true; } - if (glWrapS == PGL.GL_CLAMP_TO_EDGE) { + if (glWrapS == PGL.CLAMP_TO_EDGE) { res.wrapU = CLAMP; - } else if (glWrapS == PGL.GL_REPEAT) { + } else if (glWrapS == PGL.REPEAT) { res.wrapU = REPEAT; } - if (glWrapT == PGL.GL_CLAMP_TO_EDGE) { + if (glWrapT == PGL.CLAMP_TO_EDGE) { res.wrapV = CLAMP; - } else if (glWrapT == PGL.GL_REPEAT) { + } else if (glWrapT == PGL.REPEAT) { res.wrapV = REPEAT; } @@ -1297,55 +1297,55 @@ public class Texture implements PConstants { */ protected void setParameters(Parameters params) { if (params.target == TEX2D) { - glTarget = PGL.GL_TEXTURE_2D; + glTarget = PGL.TEXTURE_2D; } else { throw new RuntimeException("Unknown texture target"); } if (params.format == RGB) { - glFormat = PGL.GL_RGB; + glFormat = PGL.RGB; } else if (params.format == ARGB) { - glFormat = PGL.GL_RGBA; + glFormat = PGL.RGBA; } else if (params.format == ALPHA) { - glFormat = PGL.GL_ALPHA; + glFormat = PGL.ALPHA; } else { throw new RuntimeException("Unknown texture format"); } if (params.sampling == POINT) { - glMagFilter = PGL.GL_NEAREST; - glMinFilter = PGL.GL_NEAREST; + glMagFilter = PGL.NEAREST; + glMinFilter = PGL.NEAREST; } else if (params.sampling == LINEAR) { - glMagFilter = PGL.GL_NEAREST; - glMinFilter = params.mipmaps && PGL.MIPMAPS_ENABLED ? PGL.GL_LINEAR_MIPMAP_NEAREST : PGL.GL_LINEAR; + glMagFilter = PGL.NEAREST; + glMinFilter = params.mipmaps && PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR; } else if (params.sampling == BILINEAR) { - glMagFilter = PGL.GL_LINEAR; - glMinFilter = params.mipmaps && PGL.MIPMAPS_ENABLED ? PGL.GL_LINEAR_MIPMAP_NEAREST : PGL.GL_LINEAR; + glMagFilter = PGL.LINEAR; + glMinFilter = params.mipmaps && PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_NEAREST : PGL.LINEAR; } else if (params.sampling == TRILINEAR) { - glMagFilter = PGL.GL_LINEAR; - glMinFilter = params.mipmaps && PGL.MIPMAPS_ENABLED ? PGL.GL_LINEAR_MIPMAP_LINEAR : PGL.GL_LINEAR; + glMagFilter = PGL.LINEAR; + glMinFilter = params.mipmaps && PGL.MIPMAPS_ENABLED ? PGL.LINEAR_MIPMAP_LINEAR : PGL.LINEAR; } else { throw new RuntimeException("Unknown texture filtering mode"); } if (params.wrapU == CLAMP) { - glWrapS = PGL.GL_CLAMP_TO_EDGE; + glWrapS = PGL.CLAMP_TO_EDGE; } else if (params.wrapU == REPEAT) { - glWrapS = PGL.GL_REPEAT; + glWrapS = PGL.REPEAT; } else { throw new RuntimeException("Unknown wrapping mode"); } if (params.wrapV == CLAMP) { - glWrapT = PGL.GL_CLAMP_TO_EDGE; + glWrapT = PGL.CLAMP_TO_EDGE; } else if (params.wrapV == REPEAT) { - glWrapT = PGL.GL_REPEAT; + glWrapT = PGL.REPEAT; } else { throw new RuntimeException("Unknown wrapping mode"); } - usingMipmaps = glMinFilter == PGL.GL_LINEAR_MIPMAP_NEAREST || - glMinFilter == PGL.GL_LINEAR_MIPMAP_LINEAR; + usingMipmaps = glMinFilter == PGL.LINEAR_MIPMAP_NEAREST || + glMinFilter == PGL.LINEAR_MIPMAP_LINEAR; flippedX = false; flippedY = false; diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index 12da1b767..3a97aa552 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -60,43 +60,43 @@ import com.jogamp.opengl.util.AnimatorBase; */ public class PGL { // The two windowing toolkits available to use in JOGL: - public static final int AWT = 0; // http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing - public static final int NEWT = 1; // http://jogamp.org/jogl/doc/NEWT-Overview.html + protected static final int AWT = 0; // http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing + protected static final int NEWT = 1; // http://jogamp.org/jogl/doc/NEWT-Overview.html /** Size of a short (in bytes). */ - public static final int SIZEOF_SHORT = Short.SIZE / 8; + protected static final int SIZEOF_SHORT = Short.SIZE / 8; /** Size of an int (in bytes). */ - public static final int SIZEOF_INT = Integer.SIZE / 8; + protected static final int SIZEOF_INT = Integer.SIZE / 8; /** Size of a float (in bytes). */ - public static final int SIZEOF_FLOAT = Float.SIZE / 8; + protected static final int SIZEOF_FLOAT = Float.SIZE / 8; /** Size of a byte (in bytes). */ - public static final int SIZEOF_BYTE = Byte.SIZE / 8; + protected static final int SIZEOF_BYTE = Byte.SIZE / 8; /** Size of a vertex index. */ - public static final int SIZEOF_INDEX = SIZEOF_SHORT; + protected static final int SIZEOF_INDEX = SIZEOF_SHORT; /** Type of a vertex index. */ - public static final int INDEX_TYPE = GL.GL_UNSIGNED_SHORT; + protected static final int INDEX_TYPE = GL.GL_UNSIGNED_SHORT; /** Initial sizes for arrays of input and tessellated data. */ - public static final int DEFAULT_IN_VERTICES = 64; - public static final int DEFAULT_IN_EDGES = 128; - public static final int DEFAULT_IN_TEXTURES = 64; - public static final int DEFAULT_TESS_VERTICES = 64; - public static final int DEFAULT_TESS_INDICES = 128; + protected static final int DEFAULT_IN_VERTICES = 64; + protected static final int DEFAULT_IN_EDGES = 128; + protected static final int DEFAULT_IN_TEXTURES = 64; + protected static final int DEFAULT_TESS_VERTICES = 64; + protected static final int DEFAULT_TESS_INDICES = 128; /** Maximum lights by default is 8, the minimum defined by OpenGL. */ - public static final int MAX_LIGHTS = 8; + protected static final int MAX_LIGHTS = 8; /** Maximum index value of a tessellated vertex. GLES restricts the vertex * indices to be of type unsigned short. Since Java only supports signed * shorts as primitive type we have 2^15 = 32768 as the maximum number of * vertices that can be referred to within a single VBO. */ - public static final int MAX_VERTEX_INDEX = 32767; - public static final int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1; + protected static final int MAX_VERTEX_INDEX = 32767; + protected static final int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1; /** Count of tessellated fill, line or point vertices that will * trigger a flush in the immediate mode. It doesn't necessarily @@ -104,20 +104,20 @@ public class PGL { * be effectively much large since the renderer uses offsets to * refer to vertices beyond the MAX_VERTEX_INDEX limit. */ - public static final int FLUSH_VERTEX_COUNT = MAX_VERTEX_INDEX1; + protected static final int FLUSH_VERTEX_COUNT = MAX_VERTEX_INDEX1; /** Maximum dimension of a texture used to hold font data. **/ - public static final int MAX_FONT_TEX_SIZE = 1024; + protected static final int MAX_FONT_TEX_SIZE = 1024; /** Minimum stroke weight needed to apply the full path stroking * algorithm that properly generates caps and joins. */ - public static final float MIN_CAPS_JOINS_WEIGHT = 1.5f; + protected static final float MIN_CAPS_JOINS_WEIGHT = 1.5f; /** Maximum length of linear paths to be stroked with the * full algorithm that generates accurate caps and joins. */ - public static final int MAX_CAPS_JOINS_LENGTH = 5000; + protected static final int MAX_CAPS_JOINS_LENGTH = 5000; /** Minimum array size to use arrayCopy method(). **/ protected static final int MIN_ARRAYCOPY_SIZE = 2; @@ -126,7 +126,7 @@ public class PGL { protected static final boolean MIPMAPS_ENABLED = true; /** Machine Epsilon for float precision. **/ - public static float FLOAT_EPS = Float.MIN_VALUE; + protected static float FLOAT_EPS = Float.MIN_VALUE; // Calculation of the Machine Epsilon for float precision. From: // http://en.wikipedia.org/wiki/Machine_epsilon#Approximation_using_Java static { @@ -143,7 +143,7 @@ public class PGL { * Set to true if the host system is big endian (PowerPC, MIPS, SPARC), false * if little endian (x86 Intel for Mac or PC). */ - public static boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; + protected static boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; protected static final String SHADER_PREPROCESSOR_DIRECTIVE = "#ifdef GL_ES\n" + "precision mediump float;\n" + @@ -307,38 +307,38 @@ public class PGL { /** Basic GL functionality, common to all profiles */ public GL gl; - /** GLES2 functionality (shaders, etc) */ - public GL2ES2 gl2; - - /** GL2 desktop functionality (blit framebuffer, map buffer range, multisampled renerbuffers) */ - public GL2 gl2x; - /** GLU interface **/ - public GLU glu; - - /** The PGraphics object using this interface */ - public PGraphicsOpenGL pg; - - /** Whether OpenGL has been initialized or not */ - public boolean initialized; - - /** Windowing toolkit */ - public static int toolkit = AWT; - - /** Selected GL profile */ - public GLProfile profile; - - /** The capabilities of the OpenGL rendering surface */ - public GLCapabilitiesImmutable capabilities; - - /** The rendering surface */ - public GLDrawable drawable; - + public GLU glu; + /** The rendering context (holds rendering state info) */ public GLContext context; /** The AWT canvas where OpenGL rendering takes place */ public Canvas canvas; + + /** GLES2 functionality (shaders, etc) */ + protected GL2ES2 gl2; + + /** GL2 desktop functionality (blit framebuffer, map buffer range, multisampled renerbuffers) */ + protected GL2 gl2x; + + /** The PGraphics object using this interface */ + protected PGraphicsOpenGL pg; + + /** Whether OpenGL has been initialized or not */ + protected boolean initialized; + + /** Windowing toolkit */ + protected static int toolkit = AWT; + + /** Selected GL profile */ + protected GLProfile profile; + + /** The capabilities of the OpenGL rendering surface */ + protected GLCapabilitiesImmutable capabilities; + + /** The rendering surface */ + protected GLDrawable drawable; /** The AWT-OpenGL canvas */ protected GLCanvas canvasAWT; @@ -491,7 +491,7 @@ public class PGL { } - public void setFrameRate(float framerate) { + protected void setFrameRate(float framerate) { if (targetFramerate != framerate) { if (60 < framerate) { // Disables v-sync @@ -514,15 +514,7 @@ public class PGL { } - public void setToolkit(int toolkit) { - if (PGL.toolkit != toolkit) { - PGL.toolkit = toolkit; - this.initialized = false; - } - } - - - public void initPrimarySurface(int antialias) { + protected void initPrimarySurface(int antialias) { if (ENABLE_OSX_SCREEN_FBO) { needScreenFBO = false; glColorFbo[0] = 0; @@ -621,7 +613,7 @@ public class PGL { } - public void initOffscreenSurface(PGL primary) { + protected void initOffscreenSurface(PGL primary) { context = primary.context; capabilities = primary.capabilities; drawable = null; @@ -629,7 +621,7 @@ public class PGL { } - public void updatePrimary() { + protected void updatePrimary() { if (!setFramerate) { setFrameRate(targetFramerate); } @@ -757,14 +749,14 @@ public class PGL { } - public void updateOffscreen(PGL primary) { + protected void updateOffscreen(PGL primary) { gl = primary.gl; gl2 = primary.gl2; gl2x = primary.gl2x; } - public boolean primaryIsDoubleBuffered() { + protected boolean primaryIsDoubleBuffered() { // When using the multisampled FBO, the color // FBO is single buffered as it has only one // texture bound to it. @@ -772,32 +764,32 @@ public class PGL { } - public boolean primaryIsFboBacked() { + protected boolean primaryIsFboBacked() { return glColorFbo[0] != 0; } - public int getFboTexTarget() { + protected int getFboTexTarget() { return GL.GL_TEXTURE_2D; } - public int getFboTexName() { + protected int getFboTexName() { return glColorTex[0]; } - public int getFboWidth() { + protected int getFboWidth() { return fboWidth; } - public int getFboHeight() { + protected int getFboHeight() { return fboHeight; } - public void bindPrimaryColorFBO() { + protected void bindPrimaryColorFBO() { if (multisample) { // Blit the contents of the multisampled FBO into the color FBO, // so the later is up to date. @@ -820,7 +812,7 @@ public class PGL { } - public void bindPrimaryMultiFBO() { + protected void bindPrimaryMultiFBO() { if (multisample) { gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, glMultiFbo[0]); PGraphicsOpenGL.screenFramebuffer.glFbo = glMultiFbo[0]; @@ -860,7 +852,7 @@ public class PGL { // Frame rendering - public void beginOnscreenDraw(boolean clear) { + protected void beginOnscreenDraw(boolean clear) { if (glColorFbo[0] != 0) { if (multisample) { // Render the scene to the mutisampled buffer... @@ -879,7 +871,7 @@ public class PGL { } - public void endOnscreenDraw(boolean clear0) { + protected void endOnscreenDraw(boolean clear0) { if (glColorFbo[0] != 0) { if (multisample) { // Blit the contents of the multisampled FBO into the color FBO: @@ -907,20 +899,20 @@ public class PGL { } - public void beginOffscreenDraw(boolean clear) { + protected void beginOffscreenDraw(boolean clear) { } - public void endOffscreenDraw(boolean clear0) { + protected void endOffscreenDraw(boolean clear0) { } - public boolean canDraw() { + protected boolean canDraw() { return initialized && pg.parent.isDisplayable(); } - public void requestDraw() { + protected void requestDraw() { if (initialized) { //animator.requestDisplay(); @@ -1560,17 +1552,17 @@ public class PGL { // Context interface - public Context createEmptyContext() { + protected Context createEmptyContext() { return new Context(); } - public Context getCurrentContext() { + protected Context getCurrentContext() { return new Context(context); } - public class Context { + protected class Context { protected GLContext glContext; Context() { @@ -1610,12 +1602,12 @@ public class PGL { // Tessellator interface - public Tessellator createTessellator(TessellatorCallback callback) { + protected Tessellator createTessellator(TessellatorCallback callback) { return new Tessellator(callback); } - public class Tessellator { + protected class Tessellator { protected GLUtessellator tess; protected TessellatorCallback callback; protected GLUCallback gluCallback; @@ -1684,7 +1676,7 @@ public class PGL { return glu.gluErrorString(err); } - public interface TessellatorCallback { + protected interface TessellatorCallback { public void begin(int type); public void end(); public void vertex(Object data); @@ -1699,12 +1691,12 @@ public class PGL { // Utility functions - public boolean contextIsCurrent(Context other) { + protected boolean contextIsCurrent(Context other) { return other == null || other.current(); } - public void enableTexturing(int target) { + protected void enableTexturing(int target) { enable(target); if (target == TEXTURE_2D) { texturingTargets[0] = true; @@ -1714,7 +1706,7 @@ public class PGL { } - public void disableTexturing(int target) { + protected void disableTexturing(int target) { disable(target); if (target == TEXTURE_2D) { texturingTargets[0] = false; @@ -1724,7 +1716,7 @@ public class PGL { } - public boolean texturingIsEnabled(int target) { + protected boolean texturingIsEnabled(int target) { if (target == TEXTURE_2D) { return texturingTargets[0]; } else if (target == TEXTURE_RECTANGLE) { @@ -1735,7 +1727,7 @@ public class PGL { } - public boolean textureIsBound(int target, int id) { + protected boolean textureIsBound(int target, int id) { if (target == TEXTURE_2D) { return boundTextures[0] == id; } else if (target == TEXTURE_RECTANGLE) { diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index 753cf5079..9717c28b9 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -501,11 +501,6 @@ public class PGraphicsOpenGL extends PGraphics { } - public void setToolkit(int toolkit) { - pgl.setToolkit(toolkit); - } - - public void setSize(int iwidth, int iheight) { resized = (0 < width && width != iwidth) || (0 < height && height != iwidth);