diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index 4e4e78a31..0c0d496f6 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -361,6 +361,19 @@ public class PGL { protected float[] projMatrix; protected float[] mvMatrix; + /////////////////////////////////////////////////////////// + + // Error messages + + protected static final String MISSING_FBO_ERROR = + "Framebuffer objects are not supported by this hardware (or driver)"; + + protected static final String MISSING_GLSL_ERROR = + "GLSL shaders are not supported by this hardware (or driver)"; + + protected static final String MISSING_GLFUNC_ERROR = + "GL function %1$s is not available on this hardware (or driver)"; + /////////////////////////////////////////////////////////// @@ -2450,10 +2463,10 @@ public class PGL { gl = context.getGL(); if (!hasFBOs()) { - throw new RuntimeException("Framebuffer objects are not supported by this hardware (or driver)"); + throw new RuntimeException(MISSING_FBO_ERROR); } if (!hasShaders()) { - throw new RuntimeException("GLSL shaders are not supported by this hardware (or driver)"); + throw new RuntimeException(MISSING_GLSL_ERROR); } } @@ -2631,17 +2644,28 @@ public class PGL { public static final int FALSE = GL.GL_FALSE; public static final int TRUE = GL.GL_TRUE; - public static final int INT = GL2.GL_INT; - public static final int BYTE = GL.GL_BYTE; - public static final int SHORT = GL.GL_SHORT; + public static final int INT = GL2.GL_INT; + public static final int BYTE = GL.GL_BYTE; + public static final int SHORT = GL.GL_SHORT; public static final int FLOAT = GL.GL_FLOAT; + public static final int BOOL = GL2.GL_BOOL; public static final int UNSIGNED_INT = GL.GL_UNSIGNED_INT; public static final int UNSIGNED_BYTE = GL.GL_UNSIGNED_BYTE; public static final int UNSIGNED_SHORT = GL.GL_UNSIGNED_SHORT; - public static final int RGB = GL.GL_RGB; - public static final int RGBA = GL.GL_RGBA; - public static final int ALPHA = GL.GL_ALPHA; + public static final int RGB = GL.GL_RGB; + public static final int RGBA = GL.GL_RGBA; + public static final int ALPHA = GL.GL_ALPHA; + public static final int LUMINANCE = GL.GL_LUMINANCE; + public static final int LUMINANCE_ALPHA = GL.GL_LUMINANCE_ALPHA; + + public static final int UNSIGNED_SHORT_5_6_5 = GL.GL_UNSIGNED_SHORT_5_6_5; + public static final int UNSIGNED_SHORT_4_4_4_4 = GL.GL_UNSIGNED_SHORT_4_4_4_4; + public static final int UNSIGNED_SHORT_5_5_5_1 = GL.GL_UNSIGNED_SHORT_5_5_5_1; + + public static final int RGBA4 = GL2.GL_RGBA4; + public static final int RGB5_A1 = GL2.GL_RGB5_A1; + public static final int RGB565 = GL2.GL_RGB565; public static final int READ_ONLY = GL2.GL_READ_ONLY; public static final int WRITE_ONLY = GL2.GL_WRITE_ONLY; @@ -2651,32 +2675,35 @@ public class PGL { public static final int TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD; public static final int GENERATE_MIPMAP_HINT = GL.GL_GENERATE_MIPMAP_HINT; - public static final int FASTEST = GL.GL_FASTEST; - public static final int NICEST = GL.GL_NICEST; - public static final int DONT_CARE = GL.GL_DONT_CARE; + public static final int FASTEST = GL.GL_FASTEST; + public static final int NICEST = GL.GL_NICEST; + public static final int DONT_CARE = GL.GL_DONT_CARE; public static final int VENDOR = GL.GL_VENDOR; public static final int RENDERER = GL.GL_RENDERER; public static final int VERSION = GL.GL_VERSION; public static final int EXTENSIONS = GL.GL_EXTENSIONS; - public static final int SHADING_LANGUAGE_VERSION = - GL2ES2.GL_SHADING_LANGUAGE_VERSION; + public static final int SHADING_LANGUAGE_VERSION = GL2ES2.GL_SHADING_LANGUAGE_VERSION; - public static final int ALIASED_LINE_WIDTH_RANGE = - GL.GL_ALIASED_LINE_WIDTH_RANGE; - public static final int ALIASED_POINT_SIZE_RANGE = - GL.GL_ALIASED_POINT_SIZE_RANGE; - public static final int DEPTH_BITS = GL.GL_DEPTH_BITS; + public static final int MAX_SAMPLES = GL2.GL_MAX_SAMPLES; + public static final int SAMPLES = GL.GL_SAMPLES; + + public static final int ALIASED_LINE_WIDTH_RANGE = GL.GL_ALIASED_LINE_WIDTH_RANGE; + public static final int ALIASED_POINT_SIZE_RANGE = GL.GL_ALIASED_POINT_SIZE_RANGE; + + public static final int DEPTH_BITS = GL.GL_DEPTH_BITS; public static final int STENCIL_BITS = GL.GL_STENCIL_BITS; - public static final int CCW = GL.GL_CCW; - public static final int CW = GL.GL_CW; + public static final int CCW = GL.GL_CCW; + public static final int CW = GL.GL_CW; + public static final int VIEWPORT = GL.GL_VIEWPORT; - public static final int SAMPLES = GL.GL_SAMPLES; public static final int ARRAY_BUFFER = GL.GL_ARRAY_BUFFER; public static final int ELEMENT_ARRAY_BUFFER = GL.GL_ELEMENT_ARRAY_BUFFER; + public static final int MAX_VERTEX_ATTRIBS = GL2.GL_MAX_VERTEX_ATTRIBS; + public static final int STATIC_DRAW = GL.GL_STATIC_DRAW; public static final int DYNAMIC_DRAW = GL.GL_DYNAMIC_DRAW; public static final int STREAM_DRAW = GL2.GL_STREAM_DRAW; @@ -2684,16 +2711,14 @@ public class PGL { public static final int BUFFER_SIZE = GL.GL_BUFFER_SIZE; public static final int BUFFER_USAGE = GL.GL_BUFFER_USAGE; - public static final int POINTS = GL.GL_POINTS; - public static final int LINE_STRIP = GL.GL_LINE_STRIP; - public static final int LINE_LOOP = GL.GL_LINE_LOOP; - public static final int LINES = GL.GL_LINES; + public static final int POINTS = GL.GL_POINTS; + public static final int LINE_STRIP = GL.GL_LINE_STRIP; + public static final int LINE_LOOP = GL.GL_LINE_LOOP; + public static final int LINES = GL.GL_LINES; public static final int TRIANGLE_FAN = GL.GL_TRIANGLE_FAN; public static final int TRIANGLE_STRIP = GL.GL_TRIANGLE_STRIP; public static final int TRIANGLES = GL.GL_TRIANGLES; - public static final int MAX_VERTEX_ATTRIBS = GL2.GL_MAX_VERTEX_ATTRIBS; - public static final int CULL_FACE = GL.GL_CULL_FACE; public static final int FRONT = GL.GL_FRONT; public static final int BACK = GL.GL_BACK; @@ -2702,27 +2727,26 @@ public class PGL { public static final int POLYGON_OFFSET_FILL = GL.GL_POLYGON_OFFSET_FILL; public static final int UNPACK_ALIGNMENT = GL.GL_UNPACK_ALIGNMENT; - public static final int PACK_ALIGNMENT = GL.GL_PACK_ALIGNMENT; + public static final int PACK_ALIGNMENT = GL.GL_PACK_ALIGNMENT; public static final int TEXTURE_2D = GL.GL_TEXTURE_2D; public static final int TEXTURE_RECTANGLE = GL2.GL_TEXTURE_RECTANGLE; public static final int TEXTURE_BINDING_2D = GL.GL_TEXTURE_BINDING_2D; - public static final int TEXTURE_BINDING_RECTANGLE = - GL2.GL_TEXTURE_BINDING_RECTANGLE; + public static final int TEXTURE_BINDING_RECTANGLE = GL2.GL_TEXTURE_BINDING_RECTANGLE; - public static final int MAX_TEXTURE_SIZE = GL.GL_MAX_TEXTURE_SIZE; + public static final int MAX_TEXTURE_SIZE = GL.GL_MAX_TEXTURE_SIZE; + public static final int TEXTURE_MAX_ANISOTROPY = GL.GL_TEXTURE_MAX_ANISOTROPY_EXT; + public static final int MAX_TEXTURE_MAX_ANISOTROPY = GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; + + public static final int MAX_VERTEX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS; + public static final int MAX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS; public static final int NEAREST = GL.GL_NEAREST; public static final int LINEAR = GL.GL_LINEAR; public static final int LINEAR_MIPMAP_NEAREST = GL.GL_LINEAR_MIPMAP_NEAREST; public static final int LINEAR_MIPMAP_LINEAR = GL.GL_LINEAR_MIPMAP_LINEAR; - public static final int TEXTURE_MAX_ANISOTROPY = - GL.GL_TEXTURE_MAX_ANISOTROPY_EXT; - public static final int MAX_TEXTURE_MAX_ANISOTROPY = - GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; - public static final int CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE; public static final int REPEAT = GL.GL_REPEAT; @@ -2735,32 +2759,13 @@ public class PGL { public static final int TEXTURE_WRAP_S = GL.GL_TEXTURE_WRAP_S; public static final int TEXTURE_WRAP_T = GL.GL_TEXTURE_WRAP_T; - public static final int MAX_VERTEX_TEXTURE_IMAGE_UNITS = - GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS; - public static final int MAX_TEXTURE_IMAGE_UNITS = - GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS; - - public static final int TEXTURE_CUBE_MAP_POSITIVE_X = - GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X; - public static final int TEXTURE_CUBE_MAP_POSITIVE_Y = - GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y; - public static final int TEXTURE_CUBE_MAP_POSITIVE_Z = - GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z; - public static final int TEXTURE_CUBE_MAP_NEGATIVE_X = - GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X; - public static final int TEXTURE_CUBE_MAP_NEGATIVE_Y = - GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y; - public static final int TEXTURE_CUBE_MAP_NEGATIVE_Z = - GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; - - public static final int LUMINANCE = GL.GL_LUMINANCE; - public static final int LUMINANCE_ALPHA = GL.GL_LUMINANCE_ALPHA; - - public static final int UNSIGNED_SHORT_5_6_5 = GL.GL_UNSIGNED_SHORT_5_6_5; - public static final int UNSIGNED_SHORT_4_4_4_4 = GL.GL_UNSIGNED_SHORT_4_4_4_4; - public static final int UNSIGNED_SHORT_5_5_5_1 = GL.GL_UNSIGNED_SHORT_5_5_5_1; - public static final int TEXTURE_CUBE_MAP = GL.GL_TEXTURE_CUBE_MAP; + public static final int TEXTURE_CUBE_MAP_POSITIVE_X = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X; + public static final int TEXTURE_CUBE_MAP_POSITIVE_Y = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y; + public static final int TEXTURE_CUBE_MAP_POSITIVE_Z = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z; + public static final int TEXTURE_CUBE_MAP_NEGATIVE_X = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X; + public static final int TEXTURE_CUBE_MAP_NEGATIVE_Y = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y; + public static final int TEXTURE_CUBE_MAP_NEGATIVE_Z = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; public static final int VERTEX_SHADER = GL2.GL_VERTEX_SHADER; public static final int FRAGMENT_SHADER = GL2.GL_FRAGMENT_SHADER; @@ -2769,41 +2774,39 @@ public class PGL { public static final int COMPILE_STATUS = GL2.GL_COMPILE_STATUS; public static final int LINK_STATUS = GL2.GL_LINK_STATUS; public static final int VALIDATE_STATUS = GL2.GL_VALIDATE_STATUS; + public static final int SHADER_TYPE = GL2.GL_SHADER_TYPE; + public static final int DELETE_STATUS = GL2.GL_DELETE_STATUS; - public static final int FLOAT_VEC2 = GL2.GL_FLOAT_VEC2; - public static final int FLOAT_VEC3 = GL2.GL_FLOAT_VEC3; - public static final int FLOAT_VEC4 = GL2.GL_FLOAT_VEC4; - public static final int FLOAT_MAT2 = GL2.GL_FLOAT_MAT2; - public static final int FLOAT_MAT3 = GL2.GL_FLOAT_MAT3; - public static final int FLOAT_MAT4 = GL2.GL_FLOAT_MAT4; - public static final int INT_VEC2 = GL2.GL_INT_VEC2; - public static final int INT_VEC3 = GL2.GL_INT_VEC3; - public static final int INT_VEC4 = GL2.GL_INT_VEC4; - public static final int BOOL = GL2.GL_BOOL; - public static final int BOOL_VEC2 = GL2.GL_BOOL_VEC2; - public static final int BOOL_VEC3 = GL2.GL_BOOL_VEC3; - public static final int BOOL_VEC4 = GL2.GL_BOOL_VEC4; - public static final int SAMPLER_2D = GL2.GL_SAMPLER_2D; + public static final int FLOAT_VEC2 = GL2.GL_FLOAT_VEC2; + public static final int FLOAT_VEC3 = GL2.GL_FLOAT_VEC3; + public static final int FLOAT_VEC4 = GL2.GL_FLOAT_VEC4; + public static final int FLOAT_MAT2 = GL2.GL_FLOAT_MAT2; + public static final int FLOAT_MAT3 = GL2.GL_FLOAT_MAT3; + public static final int FLOAT_MAT4 = GL2.GL_FLOAT_MAT4; + public static final int INT_VEC2 = GL2.GL_INT_VEC2; + public static final int INT_VEC3 = GL2.GL_INT_VEC3; + public static final int INT_VEC4 = GL2.GL_INT_VEC4; + public static final int BOOL_VEC2 = GL2.GL_BOOL_VEC2; + public static final int BOOL_VEC3 = GL2.GL_BOOL_VEC3; + public static final int BOOL_VEC4 = GL2.GL_BOOL_VEC4; + public static final int SAMPLER_2D = GL2.GL_SAMPLER_2D; public static final int SAMPLER_CUBE = GL2.GL_SAMPLER_CUBE; - public static final int SHADER_TYPE = GL2.GL_SHADER_TYPE; - public static final int DELETE_STATUS = GL2.GL_DELETE_STATUS; - - public static final int LOW_FLOAT = GL2.GL_LOW_FLOAT; + public static final int LOW_FLOAT = GL2.GL_LOW_FLOAT; public static final int MEDIUM_FLOAT = GL2.GL_MEDIUM_FLOAT; - public static final int HIGH_FLOAT = GL2.GL_HIGH_FLOAT; - public static final int LOW_INT = GL2.GL_LOW_INT; - public static final int MEDIUM_INT = GL2.GL_MEDIUM_INT; - public static final int HIGH_INT = GL2.GL_HIGH_INT; + public static final int HIGH_FLOAT = GL2.GL_HIGH_FLOAT; + public static final int LOW_INT = GL2.GL_LOW_INT; + public static final int MEDIUM_INT = GL2.GL_MEDIUM_INT; + public static final int HIGH_INT = GL2.GL_HIGH_INT; public static final int CURRENT_VERTEX_ATTRIB = GL2.GL_CURRENT_VERTEX_ATTRIB; public static final int VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = GL2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING; - public static final int VERTEX_ATTRIB_ARRAY_ENABLED = GL2.GL_VERTEX_ATTRIB_ARRAY_ENABLED; - public static final int VERTEX_ATTRIB_ARRAY_SIZE = GL2.GL_VERTEX_ATTRIB_ARRAY_SIZE; - public static final int VERTEX_ATTRIB_ARRAY_STRIDE = GL2.GL_VERTEX_ATTRIB_ARRAY_STRIDE; - public static final int VERTEX_ATTRIB_ARRAY_TYPE = GL2.GL_VERTEX_ATTRIB_ARRAY_TYPE; - public static final int VERTEX_ATTRIB_ARRAY_NORMALIZED = GL2.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED; + public static final int VERTEX_ATTRIB_ARRAY_ENABLED = GL2.GL_VERTEX_ATTRIB_ARRAY_ENABLED; + public static final int VERTEX_ATTRIB_ARRAY_SIZE = GL2.GL_VERTEX_ATTRIB_ARRAY_SIZE; + public static final int VERTEX_ATTRIB_ARRAY_STRIDE = GL2.GL_VERTEX_ATTRIB_ARRAY_STRIDE; + public static final int VERTEX_ATTRIB_ARRAY_TYPE = GL2.GL_VERTEX_ATTRIB_ARRAY_TYPE; + public static final int VERTEX_ATTRIB_ARRAY_NORMALIZED = GL2.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED; public static final int BLEND = GL.GL_BLEND; public static final int ONE = GL.GL_ONE; @@ -2817,43 +2820,43 @@ public class PGL { public static final int SRC_COLOR = GL.GL_SRC_COLOR; public static final int SAMPLE_ALPHA_TO_COVERAGE = GL.GL_SAMPLE_ALPHA_TO_COVERAGE; - public static final int SAMPLE_COVERAGE = GL.GL_SAMPLE_COVERAGE; + public static final int SAMPLE_COVERAGE = GL.GL_SAMPLE_COVERAGE; - public static final int KEEP = GL.GL_KEEP; - public static final int REPLACE = GL.GL_REPLACE; - public static final int INCR = GL.GL_INCR; - public static final int DECR = GL.GL_DECR; - public static final int INVERT = GL.GL_INVERT; + public static final int KEEP = GL.GL_KEEP; + public static final int REPLACE = GL.GL_REPLACE; + public static final int INCR = GL.GL_INCR; + public static final int DECR = GL.GL_DECR; + public static final int INVERT = GL.GL_INVERT; public static final int INCR_WRAP = GL.GL_INCR_WRAP; public static final int DECR_WRAP = GL.GL_DECR_WRAP; - public static final int NEVER = GL.GL_NEVER; - public static final int ALWAYS = GL.GL_ALWAYS; + public static final int NEVER = GL.GL_NEVER; + public static final int ALWAYS = GL.GL_ALWAYS; - public static final int EQUAL = GL.GL_EQUAL; - public static final int LESS = GL.GL_LESS; - public static final int LEQUAL = GL.GL_LEQUAL; - public static final int GREATER = GL.GL_GREATER; - public static final int GEQUAL = GL.GL_GEQUAL; + public static final int EQUAL = GL.GL_EQUAL; + public static final int LESS = GL.GL_LESS; + public static final int LEQUAL = GL.GL_LEQUAL; + public static final int GREATER = GL.GL_GREATER; + public static final int GEQUAL = GL.GL_GEQUAL; public static final int NOTEQUAL = GL.GL_NOTEQUAL; public static final int FUNC_ADD = GL.GL_FUNC_ADD; public static final int FUNC_MIN = GL2.GL_MIN; public static final int FUNC_MAX = GL2.GL_MAX; public static final int FUNC_REVERSE_SUBTRACT = GL.GL_FUNC_REVERSE_SUBTRACT; - public static final int FUNC_SUBTRACT = GL.GL_FUNC_SUBTRACT; + public static final int FUNC_SUBTRACT = GL.GL_FUNC_SUBTRACT; public static final int DITHER = GL.GL_DITHER; - public static final int CONSTANT_COLOR = GL2.GL_CONSTANT_COLOR; - public static final int CONSTANT_ALPHA = GL2.GL_CONSTANT_ALPHA; + public static final int CONSTANT_COLOR = GL2.GL_CONSTANT_COLOR; + public static final int CONSTANT_ALPHA = GL2.GL_CONSTANT_ALPHA; public static final int ONE_MINUS_CONSTANT_COLOR = GL2.GL_ONE_MINUS_CONSTANT_COLOR; public static final int ONE_MINUS_CONSTANT_ALPHA = GL2.GL_ONE_MINUS_CONSTANT_ALPHA; - public static final int SRC_ALPHA_SATURATE = GL.GL_SRC_ALPHA_SATURATE; + public static final int SRC_ALPHA_SATURATE = GL.GL_SRC_ALPHA_SATURATE; public static final int SCISSOR_TEST = GL.GL_SCISSOR_TEST; public static final int DEPTH_TEST = GL.GL_DEPTH_TEST; public static final int DEPTH_WRITEMASK = GL.GL_DEPTH_WRITEMASK; - public static final int ALPHA_TEST = GL2.GL_ALPHA_TEST; + public static final int ALPHA_TEST = GL2.GL_ALPHA_TEST; public static final int COLOR_BUFFER_BIT = GL.GL_COLOR_BUFFER_BIT; public static final int DEPTH_BUFFER_BIT = GL.GL_DEPTH_BUFFER_BIT; @@ -2883,44 +2886,30 @@ public class PGL { public static final int STENCIL_INDEX4 = GL.GL_STENCIL_INDEX4; public static final int STENCIL_INDEX8 = GL.GL_STENCIL_INDEX8; - public static final int FRAMEBUFFER_COMPLETE = - GL.GL_FRAMEBUFFER_COMPLETE; - public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = - GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = - GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; - public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = - GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; - public static final int FRAMEBUFFER_INCOMPLETE_FORMATS = - GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS; - public static final int FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = - GL2.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER; - public static final int FRAMEBUFFER_INCOMPLETE_READ_BUFFER = - GL2.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER; - public static final int FRAMEBUFFER_UNSUPPORTED = - GL.GL_FRAMEBUFFER_UNSUPPORTED; + public static final int FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE; + public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; + public static final int FRAMEBUFFER_INCOMPLETE_FORMATS = GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS; + public static final int FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL2.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER; + public static final int FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL2.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER; + public static final int FRAMEBUFFER_UNSUPPORTED = GL.GL_FRAMEBUFFER_UNSUPPORTED; - public static final int FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = GL2.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE; - public static final int FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = GL2.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME; - public static final int FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = GL2.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL; + public static final int FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = GL2.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE; + public static final int FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = GL2.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME; + public static final int FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = GL2.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL; public static final int FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = GL2.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE; - public static final int RENDERBUFFER_WIDTH = GL2.GL_RENDERBUFFER_WIDTH; - public static final int RENDERBUFFER_HEIGHT = GL2.GL_RENDERBUFFER_HEIGHT; - public static final int RENDERBUFFER_RED_SIZE = GL2.GL_RENDERBUFFER_RED_SIZE; - public static final int RENDERBUFFER_GREEN_SIZE = GL2.GL_RENDERBUFFER_GREEN_SIZE; - public static final int RENDERBUFFER_BLUE_SIZE = GL2.GL_RENDERBUFFER_BLUE_SIZE; - public static final int RENDERBUFFER_ALPHA_SIZE = GL2.GL_RENDERBUFFER_ALPHA_SIZE; - public static final int RENDERBUFFER_DEPTH_SIZE = GL2.GL_RENDERBUFFER_DEPTH_SIZE; - public static final int RENDERBUFFER_STENCIL_SIZE = GL2.GL_RENDERBUFFER_STENCIL_SIZE; + public static final int RENDERBUFFER_WIDTH = GL2.GL_RENDERBUFFER_WIDTH; + public static final int RENDERBUFFER_HEIGHT = GL2.GL_RENDERBUFFER_HEIGHT; + public static final int RENDERBUFFER_RED_SIZE = GL2.GL_RENDERBUFFER_RED_SIZE; + public static final int RENDERBUFFER_GREEN_SIZE = GL2.GL_RENDERBUFFER_GREEN_SIZE; + public static final int RENDERBUFFER_BLUE_SIZE = GL2.GL_RENDERBUFFER_BLUE_SIZE; + public static final int RENDERBUFFER_ALPHA_SIZE = GL2.GL_RENDERBUFFER_ALPHA_SIZE; + public static final int RENDERBUFFER_DEPTH_SIZE = GL2.GL_RENDERBUFFER_DEPTH_SIZE; + public static final int RENDERBUFFER_STENCIL_SIZE = GL2.GL_RENDERBUFFER_STENCIL_SIZE; public static final int RENDERBUFFER_INTERNAL_FORMAT = GL2.GL_RENDERBUFFER_INTERNAL_FORMAT; - public static final int RGBA4 = GL2.GL_RGBA4; - public static final int RGB5_A1 = GL2.GL_RGB5_A1; - public static final int RGB565 = GL2.GL_RGB565; - - public static final int MAX_SAMPLES = GL2.GL_MAX_SAMPLES; - public static final int MULTISAMPLE = GL.GL_MULTISAMPLE; public static final int POINT_SMOOTH = GL2.GL_POINT_SMOOTH; public static final int LINE_SMOOTH = GL.GL_LINE_SMOOTH; @@ -3044,8 +3033,7 @@ public class PGL { return gl2.glMapBuffer(target, access); } - public ByteBuffer mapBufferRange(int target, int offset, int length, - int access) { + public ByteBuffer mapBufferRange(int target, int offset, int length, int access) { if (gl2x != null) { return gl2x.glMapBufferRange(target, offset, length, access); } else { @@ -3073,8 +3061,7 @@ public class PGL { // Reading Pixels - public void readPixels(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) { gl.glReadPixels(x, y, width, height, format, type, buffer); } @@ -3090,13 +3077,11 @@ public class PGL { gl2.glVertexAttrib2f(index, value0, value1); } - public void vertexAttrib3f(int index, float value0, float value1, - float value2){ + public void vertexAttrib3f(int index, float value0, float value1, float value2) { gl2.glVertexAttrib3f(index, value0, value1, value2); } - public void vertexAttrib4f(int index, float value0, float value1, - float value2, float value3) { + public void vertexAttrib4f(int index, float value0, float value1, float value2, float value3) { gl2.glVertexAttrib4f(index, value0, value1, value2, value3); } @@ -3116,13 +3101,11 @@ public class PGL { gl2.glVertexAttrib4fv(index, values); } - public void vertexAttribPointer(int index, int size, int type, - boolean normalized, int stride, int offset) { + public void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, int offset) { gl2.glVertexAttribPointer(index, size, type, normalized, stride, offset); } - public void vertexAttribPointer(int index, int size, int type, - boolean normalized, int stride, Buffer data) { + public void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, Buffer data) { gl2.glVertexAttribPointer(index, size, type, normalized, stride, data); } @@ -3182,45 +3165,28 @@ public class PGL { gl.glActiveTexture(texture); } - public void texImage2D(int target, int level, int internalFormat, - int width, int height, int border, int format, - int type, Buffer data) { - gl.glTexImage2D(target, level, internalFormat, - width, height, border, format, type, data); + public void texImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer data) { + gl.glTexImage2D(target, level, internalFormat, width, height, border, format, type, data); } - public void copyTexImage2D(int target, int level, int internalFormat, - int x, int y, int width, int height, int border) { - gl.glCopyTexImage2D(target, level, internalFormat, - x, y, width, height, border); + public void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border) { + gl.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border); } - public void texSubImage2D(int target, int level, int xOffset, int yOffset, - int width, int height, int format, - int type, Buffer data) { - gl.glTexSubImage2D(target, level, xOffset, yOffset, - width, height, format, type, data); + public void texSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, Buffer data) { + gl.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, data); } - public void copyTexSubImage2D(int target, int level, int xOffset, int yOffset, - int x, int y, int width, int height) { - gl.glCopyTexSubImage2D(target, level, x, y, xOffset, xOffset, - width, height); + public void copyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width, int height) { + gl.glCopyTexSubImage2D(target, level, x, y, xOffset, xOffset, width, height); } - public void compressedTexImage2D(int target, int level, int internalFormat, - int width, int height, int border, - int imageSize, Buffer data) { - gl.glCompressedTexImage2D(target, level, internalFormat, - width, height, border, imageSize, data); + public void compressedTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int imageSize, Buffer data) { + gl.glCompressedTexImage2D(target, level, internalFormat, width, height, border, imageSize, data); } - public void compressedTexSubImage2D(int target, int level, - int xOffset, int yOffset, - int width, int height, int format, - int imageSize, Buffer data) { - gl.glCompressedTexSubImage2D(target, level, xOffset, yOffset, - width, height, format, imageSize, data); + public void compressedTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int imageSize, Buffer data) { + gl.glCompressedTexSubImage2D(target, level, xOffset, yOffset, width, height, format, imageSize, data); } public void texParameteri(int target, int pname, int param) { @@ -3280,24 +3246,23 @@ public class PGL { return gl2.glCreateShader(type); } - public void shaderSource(int id, String source) { - gl2.glShaderSource(id, 1, new String[] { source }, (int[]) null, 0); + public void shaderSource(int shader, String source) { + gl2.glShaderSource(shader, 1, new String[] { source }, (int[]) null, 0); } - public void compileShader(int id) { - gl2.glCompileShader(id); + public void compileShader(int shader) { + gl2.glCompileShader(shader); } public void releaseShaderCompiler() { gl2.glReleaseShaderCompiler(); } - public void deleteShader(int id) { - gl2.glDeleteShader(id); + public void deleteShader(int shader) { + gl2.glDeleteShader(shader); } - public void shaderBinary(int count, IntBuffer shaders, int binaryFormat, - Buffer binary, int length) { + public void shaderBinary(int count, IntBuffer shaders, int binaryFormat, Buffer binary, int length) { gl2.glShaderBinary(count, shaders, binaryFormat, binary, length); } @@ -3325,28 +3290,34 @@ public class PGL { gl2.glDeleteProgram(program); } - public void getActiveAttrib(int program, int index, int bufSize, - IntBuffer length, IntBuffer size, IntBuffer type, - ByteBuffer name) { - gl2.glGetActiveAttrib(program, index, bufSize, length, size, type, name); + public void getActiveAttrib(int program, int index, int[] size, int[] type, String[] name) { + int[] tmp = {0, 0, 0}; + byte[] namebuf = new byte[1024]; + gl2.glGetActiveAttrib(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0); + if (size != null && size.length != 0) size[0] = tmp[1]; + if (type != null && type.length != 0) type[0] = tmp[2]; + if (name != null && name.length != 0) name[0] = new String(namebuf, 0, tmp[0]); } - public int getAttribLocation(int prog, String name) { - return gl2.glGetAttribLocation(prog, name); + public int getAttribLocation(int program, String name) { + return gl2.glGetAttribLocation(program, name); } public void bindAttribLocation(int program, int index, String name) { gl2.glBindAttribLocation(program, index, name); } - public int getUniformLocation(int prog, String name) { - return gl2.glGetUniformLocation(prog, name); + public int getUniformLocation(int program, String name) { + return gl2.glGetUniformLocation(program, name); } - public void getActiveUniform(int program, int index, int bufSize, - IntBuffer length, IntBuffer size, IntBuffer type, - ByteBuffer name) { - gl2.glGetActiveUniform(program, index, bufSize, length, size, type, name); + public void getActiveUniform(int program, int index, int[] size,int[] type, String[] name) { + int[] tmp= {0, 0, 0}; + byte[] namebuf = new byte[1024]; + gl2.glGetActiveUniform(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0); + if (size != null && size.length != 0) size[0] = tmp[1]; + if (type != null && type.length != 0) type[0] = tmp[2]; + if (name != null && name.length != 0) name[0] = new String(namebuf, 0, tmp[0]); } public void uniform1i(int location, int value) { @@ -3361,8 +3332,7 @@ public class PGL { gl2.glUniform3i(location, value0, value1, value2); } - public void uniform4i(int location, int value0, int value1, int value2, - int value3) { + public void uniform4i(int location, int value0, int value1, int value2, int value3) { gl2.glUniform4i(location, value0, value1, value2, value3); } @@ -3374,13 +3344,11 @@ public class PGL { gl2.glUniform2f(location, value0, value1); } - public void uniform3f(int location, float value0, float value1, - float value2) { + public void uniform3f(int location, float value0, float value1, float value2) { gl2.glUniform3f(location, value0, value1, value2); } - public void uniform4f(int location, float value0, float value1, float value2, - float value3) { + public void uniform4f(int location, float value0, float value1, float value2, float value3) { gl2.glUniform4f(location, value0, value1, value2, value3); } @@ -3416,23 +3384,20 @@ public class PGL { gl2.glUniform4fv(location, count, v); } - public void uniformMatrix2fv(int location, int count, boolean transpose, - FloatBuffer mat) { + public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer mat) { gl2.glUniformMatrix2fv(location, count, transpose, mat); } - public void uniformMatrix3fv(int location, int count, boolean transpose, - FloatBuffer mat) { + public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer mat) { gl2.glUniformMatrix3fv(location, count, transpose, mat); } - public void uniformMatrix4fv(int location, int count, boolean transpose, - FloatBuffer mat) { + public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer mat) { gl2.glUniformMatrix4fv(location, count, transpose, mat); } - public void validateProgram(int prog) { - gl2.glValidateProgram(prog); + public void validateProgram(int program) { + gl2.glValidateProgram(program); } public boolean isShader(int shader) { @@ -3443,8 +3408,7 @@ public class PGL { gl2.glGetShaderiv(shader, pname, params); } - public void getAttachedShaders(int program, int maxCount, IntBuffer count, - IntBuffer shaders) { + public void getAttachedShaders(int program, int maxCount, IntBuffer count, IntBuffer shaders) { gl2.glGetAttachedShaders(program, maxCount, count, shaders); } @@ -3458,13 +3422,14 @@ public class PGL { return new String(log); } - public void getShaderSource(int shader, int bufSize, IntBuffer length, - ByteBuffer source) { - gl2.glGetShaderSource(shader, bufSize, length, source); + public String getShaderSource(int shader) { + int[] len = {0}; + byte[] buf = new byte[1024]; + gl2.glGetShaderSource(shader, 1024, len, 0, buf, 0); + return new String(buf, 0, len[0]); } - public void getShaderPrecisionFormat(int shaderType, int precisionType, - IntBuffer range, IntBuffer precision) { + public void getShaderPrecisionFormat(int shaderType, int precisionType, IntBuffer range, IntBuffer precision) { gl2.glGetShaderPrecisionFormat(shaderType, precisionType, range, precision); } @@ -3477,7 +3442,7 @@ public class PGL { } public void getVertexAttribPointerv() { - throw new RuntimeException("Function glGetVertexAttribPointerv() is not available"); + throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glGetVertexAttribPointerv()")); } public void getUniformfv(int program, int location, FloatBuffer params) { @@ -3492,18 +3457,18 @@ public class PGL { return gl2.glIsProgram(program); } - public void getProgramiv(int prog, int pname, IntBuffer params) { - gl2.glGetProgramiv(prog, pname, params); + public void getProgramiv(int program, int pname, IntBuffer params) { + gl2.glGetProgramiv(program, pname, params); } - public String getProgramInfoLog(int prog) { + public String getProgramInfoLog(int program) { int[] val = { 0 }; - gl2.glGetShaderiv(prog, GL2.GL_INFO_LOG_LENGTH, val, 0); + gl2.glGetShaderiv(program, GL2.GL_INFO_LOG_LENGTH, val, 0); int length = val[0]; if (0 < length) { byte[] log = new byte[length]; - gl2.glGetProgramInfoLog(prog, length, val, 0, log, 0); + gl2.glGetProgramInfoLog(program, length, val, 0, log, 0); return new String(log); } else { return "Unknow error"; @@ -3554,8 +3519,7 @@ public class PGL { gl.glBlendFunc(src, dst); } - public void blendFuncSeparate(int srcRGB, int dstRGB, - int srcAlpha, int dstAlpha) { + public void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) { gl.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); } @@ -3633,19 +3597,15 @@ public class PGL { gl.glGenRenderbuffers(n, renderbuffers); } - public void renderbufferStorage(int target, int internalFormat, - int width, int height) { + public void renderbufferStorage(int target, int internalFormat, int width, int height) { gl.glRenderbufferStorage(target, internalFormat, width, height); } - public void framebufferRenderbuffer(int target, int attachment, - int rendbuferfTarget, int renderbuffer) { - gl.glFramebufferRenderbuffer(target, attachment, rendbuferfTarget, - renderbuffer); + public void framebufferRenderbuffer(int target, int attachment, int rendbuferfTarget, int renderbuffer) { + gl.glFramebufferRenderbuffer(target, attachment, rendbuferfTarget, renderbuffer); } - public void framebufferTexture2D(int target, int attachment, int texTarget, - int texture, int level) { + public void framebufferTexture2D(int target, int attachment, int texTarget, int texture, int level) { gl.glFramebufferTexture2D(target, attachment, texTarget, texture, level); } @@ -3657,35 +3617,27 @@ public class PGL { return gl2.glIsFramebuffer(framebuffer); } - public void getFramebufferAttachmentParameteriv(int target, int attachment, - int pname, IntBuffer params) { - gl2.glGetFramebufferAttachmentParameteriv(target, attachment, pname, - params); + public void getFramebufferAttachmentParameteriv(int target, int attachment, int pname, IntBuffer params) { + gl2.glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); } public boolean isRenderbuffer(int renderbuffer) { return gl2.glIsRenderbuffer(renderbuffer); } - public void getRenderbufferParameteriv(int target, int pname, - IntBuffer params) { + public void getRenderbufferParameteriv(int target, int pname, IntBuffer params) { gl2.glGetRenderbufferParameteriv(target, pname, params); } - public void blitFramebuffer(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) { if (gl2x != null) { - gl2x.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, mask, filter); + gl2x.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); } } - public void renderbufferStorageMultisample(int target, int samples, - int format, int width, int height){ + public void renderbufferStorageMultisample(int target, int samples, int format, int width, int height) { if (gl2x != null) { - gl2x.glRenderbufferStorageMultisample(target, samples, format, - width, height); + gl2x.glRenderbufferStorageMultisample(target, samples, format, width, height); } } diff --git a/java/libraries/lwjgl/src/processing/lwjgl/PGL.java b/java/libraries/lwjgl/src/processing/lwjgl/PGL.java index 338a18d54..1792399d9 100644 --- a/java/libraries/lwjgl/src/processing/lwjgl/PGL.java +++ b/java/libraries/lwjgl/src/processing/lwjgl/PGL.java @@ -77,15 +77,24 @@ import processing.opengl.Texture; */ @SuppressWarnings("static-access") public class PGL extends processing.opengl.PGL { + /////////////////////////////////////////////////////////// + // Public members to access the underlying GL objects and context + + /** GLU interface **/ + public static GLU glu; + + /** The canvas where OpenGL rendering takes place */ + public static Canvas canvas; + /////////////////////////////////////////////////////////// // Parameters - public static boolean FORCE_SCREEN_FBO = false; - public static final boolean USE_DIRECT_BUFFERS = true; - public static final int MIN_DIRECT_BUFFER_SIZE = 16; - public static final boolean SAVE_SURFACE_TO_PIXELS = true; + protected static boolean FORCE_SCREEN_FBO = false; + protected static final boolean USE_DIRECT_BUFFERS = true; + protected static final int MIN_DIRECT_BUFFER_SIZE = 16; + protected static final boolean SAVE_SURFACE_TO_PIXELS = true; /** Enables/disables mipmap use. **/ protected static final boolean MIPMAPS_ENABLED = true; @@ -173,183 +182,6 @@ public class PGL extends processing.opengl.PGL { "precision mediump int;\n" + "#endif\n"; - /////////////////////////////////////////////////////////// - - // OpenGL constants - - public static final int FALSE = GL11.GL_FALSE; - public static final int TRUE = GL11.GL_TRUE; - - public static final int LESS = GL11.GL_LESS; - public static final int LEQUAL = GL11.GL_LEQUAL; - - public static final int CCW = GL11.GL_CCW; - public static final int CW = GL11.GL_CW; - - public static final int CULL_FACE = GL11.GL_CULL_FACE; - public static final int FRONT = GL11.GL_FRONT; - public static final int BACK = GL11.GL_BACK; - public static final int FRONT_AND_BACK = GL11.GL_FRONT_AND_BACK; - - public static final int VIEWPORT = GL11.GL_VIEWPORT; - - public static final int SCISSOR_TEST = GL11.GL_SCISSOR_TEST; - public static final int DEPTH_TEST = GL11.GL_DEPTH_TEST; - public static final int DEPTH_WRITEMASK = GL11.GL_DEPTH_WRITEMASK; - - public static final int COLOR_BUFFER_BIT = GL11.GL_COLOR_BUFFER_BIT; - public static final int DEPTH_BUFFER_BIT = GL11.GL_DEPTH_BUFFER_BIT; - public static final int STENCIL_BUFFER_BIT = GL11.GL_STENCIL_BUFFER_BIT; - - public static final int FUNC_ADD = GL14.GL_FUNC_ADD; - public static final int FUNC_MIN = GL14.GL_MIN; - public static final int FUNC_MAX = GL14.GL_MAX; - public static final int FUNC_REVERSE_SUBTRACT = GL14.GL_FUNC_REVERSE_SUBTRACT; - - public static final int TEXTURE_2D = GL11.GL_TEXTURE_2D; - public static final int TEXTURE_RECTANGLE = GL31.GL_TEXTURE_RECTANGLE; - - public static final int TEXTURE_BINDING_2D = GL11.GL_TEXTURE_BINDING_2D; - public static final int TEXTURE_BINDING_RECTANGLE = - GL31.GL_TEXTURE_BINDING_RECTANGLE; - - public static final int RGB = GL11.GL_RGB; - public static final int RGBA = GL11.GL_RGBA; - public static final int ALPHA = GL11.GL_ALPHA; - public static final int UNSIGNED_INT = GL11.GL_UNSIGNED_INT; - public static final int UNSIGNED_BYTE = GL11.GL_UNSIGNED_BYTE; - public static final int UNSIGNED_SHORT = GL11.GL_UNSIGNED_SHORT; - public static final int FLOAT = GL11.GL_FLOAT; - - public static final int NEAREST = GL11.GL_NEAREST; - public static final int LINEAR = GL11.GL_LINEAR; - public static final int LINEAR_MIPMAP_NEAREST = GL11.GL_LINEAR_MIPMAP_NEAREST; - public static final int LINEAR_MIPMAP_LINEAR = GL11.GL_LINEAR_MIPMAP_LINEAR; - - public static final int TEXTURE_MAX_ANISOTROPY = - EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT; - public static final int MAX_TEXTURE_MAX_ANISOTROPY = - EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; - - public static final int CLAMP_TO_EDGE = GL12.GL_CLAMP_TO_EDGE; - public static final int REPEAT = GL11.GL_REPEAT; - - public static final int RGBA8 = GL11.GL_RGBA8; - public static final int DEPTH24_STENCIL8 = GL30.GL_DEPTH24_STENCIL8; - - public static final int DEPTH_COMPONENT = GL11.GL_DEPTH_COMPONENT; - public static final int DEPTH_COMPONENT16 = GL14.GL_DEPTH_COMPONENT16; - public static final int DEPTH_COMPONENT24 = GL14.GL_DEPTH_COMPONENT24; - public static final int DEPTH_COMPONENT32 = GL14.GL_DEPTH_COMPONENT32; - - public static final int STENCIL_INDEX = GL11.GL_STENCIL_INDEX; - public static final int STENCIL_INDEX1 = GL30.GL_STENCIL_INDEX1; - public static final int STENCIL_INDEX4 = GL30.GL_STENCIL_INDEX4; - public static final int STENCIL_INDEX8 = GL30.GL_STENCIL_INDEX8; - - public static final int ARRAY_BUFFER = GL15.GL_ARRAY_BUFFER; - public static final int ELEMENT_ARRAY_BUFFER = GL15.GL_ELEMENT_ARRAY_BUFFER; - - public static final int SAMPLES = GL13.GL_SAMPLES; - - public static final int FRAMEBUFFER_COMPLETE = - GL30.GL_FRAMEBUFFER_COMPLETE; - public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = - GL30.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = - GL30.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; - public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = - EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; - public static final int FRAMEBUFFER_INCOMPLETE_FORMATS = - EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; - public static final int FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = - GL30.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER; - public static final int FRAMEBUFFER_INCOMPLETE_READ_BUFFER = - GL30.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER; - public static final int FRAMEBUFFER_UNSUPPORTED = - GL30.GL_FRAMEBUFFER_UNSUPPORTED; - - public static final int STATIC_DRAW = GL15.GL_STATIC_DRAW; - public static final int DYNAMIC_DRAW = GL15.GL_DYNAMIC_DRAW; - public static final int STREAM_DRAW = GL15.GL_STREAM_DRAW; - - public static final int READ_ONLY = GL15.GL_READ_ONLY; - public static final int WRITE_ONLY = GL15.GL_WRITE_ONLY; - public static final int READ_WRITE = GL15.GL_READ_WRITE; - - public static final int TRIANGLE_FAN = GL11.GL_TRIANGLE_FAN; - public static final int TRIANGLE_STRIP = GL11.GL_TRIANGLE_STRIP; - public static final int TRIANGLES = GL11.GL_TRIANGLES; - - public static final int VENDOR = GL11.GL_VENDOR; - public static final int RENDERER = GL11.GL_RENDERER; - public static final int VERSION = GL11.GL_VERSION; - public static final int EXTENSIONS = GL11.GL_EXTENSIONS; - public static final int SHADING_LANGUAGE_VERSION = - GL20.GL_SHADING_LANGUAGE_VERSION; - - public static final int MAX_TEXTURE_SIZE = GL11.GL_MAX_TEXTURE_SIZE; - public static final int MAX_SAMPLES = GL30.GL_MAX_SAMPLES; - public static final int ALIASED_LINE_WIDTH_RANGE = - GL12.GL_ALIASED_LINE_WIDTH_RANGE; - public static final int ALIASED_POINT_SIZE_RANGE = - GL12.GL_ALIASED_POINT_SIZE_RANGE; - public static final int DEPTH_BITS = GL11.GL_DEPTH_BITS; - public static final int STENCIL_BITS = GL11.GL_STENCIL_BITS; - - public static final int TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO; - public static final int TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD; - - public static final int TEXTURE0 = GL13.GL_TEXTURE0; - public static final int TEXTURE1 = GL13.GL_TEXTURE1; - public static final int TEXTURE2 = GL13.GL_TEXTURE2; - public static final int TEXTURE3 = GL13.GL_TEXTURE3; - public static final int TEXTURE_MIN_FILTER = GL11.GL_TEXTURE_MIN_FILTER; - public static final int TEXTURE_MAG_FILTER = GL11.GL_TEXTURE_MAG_FILTER; - public static final int TEXTURE_WRAP_S = GL11.GL_TEXTURE_WRAP_S; - public static final int TEXTURE_WRAP_T = GL11.GL_TEXTURE_WRAP_T; - - public static final int BLEND = GL11.GL_BLEND; - public static final int ONE = GL11.GL_ONE; - public static final int ZERO = GL11.GL_ZERO; - public static final int SRC_ALPHA = GL11.GL_SRC_ALPHA; - public static final int DST_ALPHA = GL11.GL_DST_ALPHA; - public static final int ONE_MINUS_SRC_ALPHA = GL11.GL_ONE_MINUS_SRC_ALPHA; - public static final int ONE_MINUS_DST_COLOR = GL11.GL_ONE_MINUS_DST_COLOR; - public static final int ONE_MINUS_SRC_COLOR = GL11.GL_ONE_MINUS_SRC_COLOR; - public static final int DST_COLOR = GL11.GL_DST_COLOR; - public static final int SRC_COLOR = GL11.GL_SRC_COLOR; - - public static final int FRAMEBUFFER = GL30.GL_FRAMEBUFFER; - public static final int COLOR_ATTACHMENT0 = GL30.GL_COLOR_ATTACHMENT0; - public static final int COLOR_ATTACHMENT1 = GL30.GL_COLOR_ATTACHMENT1; - public static final int COLOR_ATTACHMENT2 = GL30.GL_COLOR_ATTACHMENT2; - public static final int COLOR_ATTACHMENT3 = GL30.GL_COLOR_ATTACHMENT3; - public static final int RENDERBUFFER = GL30.GL_RENDERBUFFER; - public static final int DEPTH_ATTACHMENT = GL30.GL_DEPTH_ATTACHMENT; - public static final int STENCIL_ATTACHMENT = GL30.GL_STENCIL_ATTACHMENT; - public static final int READ_FRAMEBUFFER = GL30.GL_READ_FRAMEBUFFER; - public static final int DRAW_FRAMEBUFFER = GL30.GL_DRAW_FRAMEBUFFER; - - public static final int VERTEX_SHADER = GL20.GL_VERTEX_SHADER; - public static final int FRAGMENT_SHADER = GL20.GL_FRAGMENT_SHADER; - public static final int INFO_LOG_LENGTH = GL20.GL_INFO_LOG_LENGTH; - public static final int SHADER_SOURCE_LENGTH = GL20.GL_SHADER_SOURCE_LENGTH; - public static final int COMPILE_STATUS = GL20.GL_COMPILE_STATUS; - public static final int LINK_STATUS = GL20.GL_LINK_STATUS; - public static final int VALIDATE_STATUS = GL20.GL_VALIDATE_STATUS; - - public static final int MULTISAMPLE = GL13.GL_MULTISAMPLE; - public static final int POINT_SMOOTH = GL11.GL_POINT_SMOOTH; - public static final int LINE_SMOOTH = GL11.GL_LINE_SMOOTH; - public static final int POLYGON_SMOOTH = GL11.GL_POLYGON_SMOOTH; - - /** GLU interface **/ - public static GLU glu; - - /** The canvas where OpenGL rendering takes place */ - public static Canvas canvas; - /** OpenGL thread */ protected static Thread glThread; @@ -464,10 +296,25 @@ public class PGL extends processing.opengl.PGL { protected ByteBuffer stencilBuffer; + /////////////////////////////////////////////////////////// + + // Error messages + + protected static final String MISSING_FBO_ERROR = + "Framebuffer objects are not supported by this hardware (or driver)"; + + protected static final String MISSING_GLSL_ERROR = + "GLSL shaders are not supported by this hardware (or driver)"; + + protected static final String MISSING_GLFUNC_ERROR = + "GL function %1$s is not available on this hardware (or driver)"; + + /////////////////////////////////////////////////////////// // Initialization, finalization + public PGL(PGraphicsOpenGL pg) { this.pg = pg; if (glu == null) { @@ -1023,681 +870,6 @@ public class PGL extends processing.opengl.PGL { } - ////////////////////////////////////////////////////////////////////////////// - - // Caps query - - - public String getString(int name) { - return GL11.glGetString(name); - } - - - public void getIntegerv(int name, IntBuffer values) { - if (-1 < name) { - GL11.glGetInteger(name, values); - } else { - fillIntBuffer(values, 0, values.capacity() - 1, 0); - } - } - - - public void getFloatv(int name, FloatBuffer values) { - if (-1 < name) { - GL11.glGetFloat(name, values); - } else { - fillFloatBuffer(values, 0, values.capacity() - 1, 0); - } - } - - - public void getBooleanv(int name, IntBuffer values) { - if (-1 < name) { - if (byteBuffer.capacity() < values.capacity()) { - byteBuffer = allocateDirectByteBuffer(values.capacity()); - } - GL11.glGetBoolean(name, byteBuffer); - for (int i = 0; i < values.capacity(); i++) { - values.put(i, byteBuffer.get(i)); - } - } else { - fillIntBuffer(values, 0, values.capacity() - 1, 0); - } - } - - - /////////////////////////////////////////////////////////// - - // Enable/disable caps - - - public void enable(int cap) { - if (-1 < cap) { - GL11.glEnable(cap); - } - } - - - public void disable(int cap) { - if (-1 < cap) { - GL11.glDisable(cap); - } - } - - - /////////////////////////////////////////////////////////// - - // Render control - - - public void flush() { - GL11.glFlush(); - } - - - public void finish() { - GL11.glFinish(); - } - - - /////////////////////////////////////////////////////////// - - // Error handling - - - public int getError() { - return GL11.glGetError(); - } - - - public String errorString(int err) { - return glu.gluErrorString(err); - } - - - /////////////////////////////////////////////////////////// - - // Rendering options - - - public void frontFace(int mode) { - GL11.glFrontFace(mode); - } - - - public void cullFace(int mode) { - GL11.glCullFace(mode); - } - - - public void depthMask(boolean flag) { - GL11.glDepthMask(flag); - } - - - public void depthFunc(int func) { - GL11.glDepthFunc(func); - } - - - /////////////////////////////////////////////////////////// - - // Textures - - - public void genTextures(int n, IntBuffer ids) { - GL11.glGenTextures(ids); - } - - - public void deleteTextures(int n, IntBuffer ids) { - GL11.glDeleteTextures(ids); - } - - - public void activeTexture(int unit) { - GL13.glActiveTexture(unit); - } - - - public void bindTexture(int target, int id) { - GL11.glBindTexture(target, id); - if (target == TEXTURE_2D) { - boundTextures[0] = id; - } else if (target == TEXTURE_RECTANGLE) { - boundTextures[1] = id; - } - } - - - public void texImage2D(int target, int level, int internalFormat, - int width, int height, int border, int format, - int type, Buffer data) { - GL11.glTexImage2D(target, level, internalFormat, - width, height, border, format, type, (IntBuffer)data); - } - - - public void texSubImage2D(int target, int level, int xOffset, int yOffset, - int width, int height, int format, - int type, Buffer data) { - GL11.glTexSubImage2D(target, level, xOffset, yOffset, - width, height, format, type, (IntBuffer)data); - } - - - public void texParameteri(int target, int param, int value) { - GL11.glTexParameteri(target, param, value); - } - - - public void texParameterf(int target, int param, float value) { - GL11.glTexParameterf(target, param, value); - } - - - public void getTexParameteriv(int target, int param, IntBuffer values) { - GL11.glGetTexParameter(target, param, values); - } - - - public void generateMipmap(int target) { - GL30.glGenerateMipmap(target); - } - - - /////////////////////////////////////////////////////////// - - // Vertex Buffers - - - public void genBuffers(int n, IntBuffer ids) { - GL15.glGenBuffers(ids); - } - - - public void deleteBuffers(int n, IntBuffer ids) { - GL15.glDeleteBuffers(ids); - } - - - public void bindBuffer(int target, int id) { - GL15.glBindBuffer(target, id); - } - - - public void bufferData(int target, int size, Buffer data, int usage) { - if (data == null) { - FloatBuffer empty = BufferUtils.createFloatBuffer(size); - GL15.glBufferData(target, empty, usage); - } else { - if (data instanceof ByteBuffer) { - GL15.glBufferData(target, (ByteBuffer)data, usage); - } else if (data instanceof ShortBuffer) { - GL15.glBufferData(target, (ShortBuffer)data, usage); - } else if (data instanceof IntBuffer) { - GL15.glBufferData(target, (IntBuffer)data, usage); - } else if (data instanceof FloatBuffer) { - GL15.glBufferData(target, (FloatBuffer)data, usage); - } - } - } - - - public void bufferSubData(int target, int offset, int size, Buffer data) { - if (data instanceof ByteBuffer) { - GL15.glBufferSubData(target, offset, (ByteBuffer)data); - } else if (data instanceof ShortBuffer) { - GL15.glBufferSubData(target, offset, (ShortBuffer)data); - } else if (data instanceof IntBuffer) { - GL15.glBufferSubData(target, offset, (IntBuffer)data); - } else if (data instanceof FloatBuffer) { - GL15.glBufferSubData(target, offset, (FloatBuffer)data); - } - } - - - public void drawArrays(int mode, int first, int count) { - GL11.glDrawArrays(mode, first, count); - } - - - public void drawElements(int mode, int count, int type, int offset) { - GL11.glDrawElements(mode, count, type, offset); - } - - - public void enableVertexAttribArray(int loc) { - GL20.glEnableVertexAttribArray(loc); - } - - - public void disableVertexAttribArray(int loc) { - GL20.glDisableVertexAttribArray(loc); - } - - - public void vertexAttribPointer(int loc, int size, int type, - boolean normalized, int stride, int offset) { - GL20.glVertexAttribPointer(loc, size, type, normalized, stride, offset); - } - - - public void vertexAttribPointer(int loc, int size, int type, - boolean normalized, int stride, Buffer data) { - if (type == UNSIGNED_INT) { - GL20.glVertexAttribPointer(loc, size, true, normalized, stride, (IntBuffer)data); - } else if (type == UNSIGNED_BYTE) { - GL20.glVertexAttribPointer(loc, size, true, normalized, stride, (ByteBuffer)data); - } else if (type == UNSIGNED_SHORT) { - GL20.glVertexAttribPointer(loc, size, true, normalized, stride, (ShortBuffer)data); - } else if (type == FLOAT) { - GL20.glVertexAttribPointer(loc, size, normalized, stride, (FloatBuffer)data); - } - } - - - public ByteBuffer mapBuffer(int target, int access) { - return GL15.glMapBuffer(target, access, null); - } - - - public ByteBuffer mapBufferRange(int target, int offset, int length, - int access) { - return GL30.glMapBufferRange(target, offset, length, access, null); - } - - - public void unmapBuffer(int target) { - GL15.glUnmapBuffer(target); - } - - - /////////////////////////////////////////////////////////// - - // Framebuffers, renderbuffers - - - public void genFramebuffers(int n, IntBuffer ids) { - GL30.glGenFramebuffers(ids); - } - - - public void deleteFramebuffers(int n, IntBuffer ids) { - GL30.glDeleteFramebuffers(ids); - } - - - public void genRenderbuffers(int n, IntBuffer ids) { - GL30.glGenRenderbuffers(ids); - } - - - public void deleteRenderbuffers(int n, IntBuffer ids) { - GL30.glDeleteRenderbuffers(ids); - } - - - public void bindFramebuffer(int target, int id) { - GL30.glBindFramebuffer(target, id); - } - - - public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, - int dstX0, int dstY0, int dstX1, int dstY1, - int mask, int filter) { - GL30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, mask, filter); - } - - - public void framebufferTexture2D(int target, int attachment, int texTarget, - int texId, int level) { - GL30.glFramebufferTexture2D(target, attachment, texTarget, texId, level); - } - - - public void bindRenderbuffer(int target, int id) { - GL30.glBindRenderbuffer(target, id); - } - - - public void renderbufferStorageMultisample(int target, int samples, - int format, int width, int height){ - GL30.glRenderbufferStorageMultisample(target, samples, format, - width, height); - } - - - public void renderbufferStorage(int target, int format, - int width, int height) { - GL30.glRenderbufferStorage(target, format, width, height); - } - - - public void framebufferRenderbuffer(int target, int attachment, - int rendbufTarget, int rendbufId) { - GL30.glFramebufferRenderbuffer(target, attachment, rendbufTarget, rendbufId); - } - - - public int checkFramebufferStatus(int target) { - return GL30.glCheckFramebufferStatus(target); - } - - - /////////////////////////////////////////////////////////// - - // Shaders - - - public int createProgram() { - return GL20.glCreateProgram(); - } - - - public void deleteProgram(int id) { - GL20.glDeleteProgram(id); - } - - - public int createShader(int type) { - return GL20.glCreateShader(type); - } - - - public void deleteShader(int id) { - GL20.glDeleteShader(id); - } - - - public void linkProgram(int prog) { - GL20.glLinkProgram(prog); - } - - - public void validateProgram(int prog) { - GL20.glValidateProgram(prog); - } - - - public void useProgram(int prog) { - GL20.glUseProgram(prog); - } - - - public int getAttribLocation(int prog, String name) { - return GL20.glGetAttribLocation(prog, name); - } - - - public int getUniformLocation(int prog, String name) { - return GL20.glGetUniformLocation(prog, name); - } - - - public void uniform1i(int loc, int value) { - GL20.glUniform1i(loc, value); - } - - - public void uniform2i(int loc, int value0, int value1) { - GL20.glUniform2i(loc, value0, value1); - } - - - public void uniform3i(int loc, int value0, int value1, int value2) { - GL20.glUniform3i(loc, value0, value1, value2); - } - - - public void uniform4i(int loc, int value0, int value1, int value2, - int value3) { - GL20.glUniform4i(loc, value0, value1, value2, value3); - } - - - public void uniform1f(int loc, float value) { - GL20.glUniform1f(loc, value); - } - - - public void uniform2f(int loc, float value0, float value1) { - GL20.glUniform2f(loc, value0, value1); - } - - - public void uniform3f(int loc, float value0, float value1, float value2) { - GL20.glUniform3f(loc, value0, value1, value2); - } - - - public void uniform4f(int loc, float value0, float value1, float value2, - float value3) { - GL20.glUniform4f(loc, value0, value1, value2, value3); - } - - - public void uniform1iv(int loc, int count, IntBuffer v) { - v.limit(count); - GL20.glUniform1(loc, v); - v.clear(); - } - - - public void uniform2iv(int loc, int count, IntBuffer v) { - v.limit(2 * count); - GL20.glUniform2(loc, v); - v.clear(); - } - - - public void uniform3iv(int loc, int count, IntBuffer v) { - v.limit(3 * count); - GL20.glUniform3(loc, v); - v.clear(); - } - - - public void uniform4iv(int loc, int count, IntBuffer v) { - v.limit(4 * count); - GL20.glUniform4(loc, v); - v.clear(); - } - - - public void uniform1fv(int loc, int count, FloatBuffer v) { - v.limit(count); - GL20.glUniform1(loc, v); - v.clear(); - } - - - public void uniform2fv(int loc, int count, FloatBuffer v) { - v.limit(2 * count); - GL20.glUniform2(loc, v); - v.clear(); - } - - - public void uniform3fv(int loc, int count, FloatBuffer v) { - v.limit(3 * count); - GL20.glUniform3(loc, v); - v.clear(); - } - - - public void uniform4fv(int loc, int count, FloatBuffer v) { - v.limit(4 * count); - GL20.glUniform4(loc, v); - v.clear(); - } - - - public void uniformMatrix2fv(int loc, int count, boolean transpose, - FloatBuffer mat) { - mat.limit(4); - GL20.glUniformMatrix2(loc, transpose, mat); - mat.clear(); - } - - - public void uniformMatrix3fv(int loc, int count, boolean transpose, - FloatBuffer mat) { - mat.limit(9); - GL20.glUniformMatrix3(loc, transpose, mat); - mat.clear(); - } - - - public void uniformMatrix4fv(int loc, int count, boolean transpose, - FloatBuffer mat) { - mat.limit(16); - GL20.glUniformMatrix4(loc, transpose, mat); - mat.clear(); - } - - - public void vertexAttrib1f(int loc, float value) { - GL20.glVertexAttrib1f(loc, value); - } - - - public void vertexAttrib2f(int loc, float value0, float value1) { - GL20.glVertexAttrib2f(loc, value0, value1); - } - - - public void vertexAttrib3f(int loc, float value0, float value1, float value2){ - GL20.glVertexAttrib3f(loc, value0, value1, value2); - } - - - public void vertexAttrib4f(int loc, float value0, float value1, float value2, - float value3) { - GL20.glVertexAttrib4f(loc, value0, value1, value2, value3); - } - - - public void shaderSource(int id, String source) { - GL20.glShaderSource(id, source); - } - - - public void compileShader(int id) { - GL20.glCompileShader(id); - } - - - public void attachShader(int prog, int shader) { - GL20.glAttachShader(prog, shader); - } - - - public void getShaderiv(int shader, int pname, IntBuffer params) { - GL20.glGetShader(shader, pname, params); - } - - - public String getShaderInfoLog(int shader) { - int len = GL20.glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH); - return GL20.glGetShaderInfoLog(shader, len); - } - - - public void getProgramiv(int prog, int pname, IntBuffer params) { - GL20.glGetProgram(prog, pname, params); - } - - - public String getProgramInfoLog(int prog) { - int len = GL20.glGetProgrami(prog, GL20.GL_INFO_LOG_LENGTH); - return GL20.glGetProgramInfoLog(prog, len); - } - - - /////////////////////////////////////////////////////////// - - // Viewport - - - public void viewport(int x, int y, int width, int height) { - GL11.glViewport(x, y, width, height); - } - - - /////////////////////////////////////////////////////////// - - // Clipping (scissor test) - - - public void scissor(int x, int y, int w, int h) { - GL11.glScissor(x, y, w, h); - } - - - /////////////////////////////////////////////////////////// - - // Blending - - - public void blendEquation(int eq) { - GL14.glBlendEquation(eq); - } - - - public void blendFunc(int srcFactor, int dstFactor) { - GL11.glBlendFunc(srcFactor, dstFactor); - } - - - /////////////////////////////////////////////////////////// - - // Pixels - - - public void readBuffer(int buf) { - GL11.glReadBuffer(buf); - } - - - public void readPixels(int x, int y, int width, int height, int format, - int type, Buffer buffer) { - - GL11.glReadPixels(x, y, width, height, format, type, (IntBuffer)buffer); - } - - - public void drawBuffer(int buf) { - GL11.glDrawBuffer(buf); - } - - - public void clearDepth(float d) { - GL11.glClearDepth(d); - } - - - public void clearStencil(int s) { - GL11.glClearStencil(s); - } - - - public void colorMask(boolean wr, boolean wg, boolean wb, boolean wa) { - GL11.glColorMask(wr, wg, wb, wa); - } - - - public void clearColor(float r, float g, float b, float a) { - GL11.glClearColor(r, g, b, a); - } - - - public void clear(int mask) { - GL11.glClear(mask); - } - - /////////////////////////////////////////////////////////// // Context interface @@ -3346,4 +2518,856 @@ public class PGL extends processing.opengl.PGL { return 0; } } + + + + + // OPENGL API: Still need to add all the missing functions to expose the entire + // GLES 2.0 API + + /////////////////////////////////////////////////////////// + + // OpenGL constants + + public static final int FALSE = GL11.GL_FALSE; + public static final int TRUE = GL11.GL_TRUE; + + public static final int LESS = GL11.GL_LESS; + public static final int LEQUAL = GL11.GL_LEQUAL; + + public static final int CCW = GL11.GL_CCW; + public static final int CW = GL11.GL_CW; + + public static final int CULL_FACE = GL11.GL_CULL_FACE; + public static final int FRONT = GL11.GL_FRONT; + public static final int BACK = GL11.GL_BACK; + public static final int FRONT_AND_BACK = GL11.GL_FRONT_AND_BACK; + + public static final int VIEWPORT = GL11.GL_VIEWPORT; + + public static final int SCISSOR_TEST = GL11.GL_SCISSOR_TEST; + public static final int DEPTH_TEST = GL11.GL_DEPTH_TEST; + public static final int DEPTH_WRITEMASK = GL11.GL_DEPTH_WRITEMASK; + + public static final int COLOR_BUFFER_BIT = GL11.GL_COLOR_BUFFER_BIT; + public static final int DEPTH_BUFFER_BIT = GL11.GL_DEPTH_BUFFER_BIT; + public static final int STENCIL_BUFFER_BIT = GL11.GL_STENCIL_BUFFER_BIT; + + public static final int FUNC_ADD = GL14.GL_FUNC_ADD; + public static final int FUNC_MIN = GL14.GL_MIN; + public static final int FUNC_MAX = GL14.GL_MAX; + public static final int FUNC_REVERSE_SUBTRACT = GL14.GL_FUNC_REVERSE_SUBTRACT; + + public static final int TEXTURE_2D = GL11.GL_TEXTURE_2D; + public static final int TEXTURE_RECTANGLE = GL31.GL_TEXTURE_RECTANGLE; + + public static final int TEXTURE_BINDING_2D = GL11.GL_TEXTURE_BINDING_2D; + public static final int TEXTURE_BINDING_RECTANGLE = + GL31.GL_TEXTURE_BINDING_RECTANGLE; + + public static final int RGB = GL11.GL_RGB; + public static final int RGBA = GL11.GL_RGBA; + public static final int ALPHA = GL11.GL_ALPHA; + public static final int UNSIGNED_INT = GL11.GL_UNSIGNED_INT; + public static final int UNSIGNED_BYTE = GL11.GL_UNSIGNED_BYTE; + public static final int UNSIGNED_SHORT = GL11.GL_UNSIGNED_SHORT; + public static final int FLOAT = GL11.GL_FLOAT; + + public static final int NEAREST = GL11.GL_NEAREST; + public static final int LINEAR = GL11.GL_LINEAR; + public static final int LINEAR_MIPMAP_NEAREST = GL11.GL_LINEAR_MIPMAP_NEAREST; + public static final int LINEAR_MIPMAP_LINEAR = GL11.GL_LINEAR_MIPMAP_LINEAR; + + public static final int TEXTURE_MAX_ANISOTROPY = + EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT; + public static final int MAX_TEXTURE_MAX_ANISOTROPY = + EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; + + public static final int CLAMP_TO_EDGE = GL12.GL_CLAMP_TO_EDGE; + public static final int REPEAT = GL11.GL_REPEAT; + + public static final int RGBA8 = GL11.GL_RGBA8; + public static final int DEPTH24_STENCIL8 = GL30.GL_DEPTH24_STENCIL8; + + public static final int DEPTH_COMPONENT = GL11.GL_DEPTH_COMPONENT; + public static final int DEPTH_COMPONENT16 = GL14.GL_DEPTH_COMPONENT16; + public static final int DEPTH_COMPONENT24 = GL14.GL_DEPTH_COMPONENT24; + public static final int DEPTH_COMPONENT32 = GL14.GL_DEPTH_COMPONENT32; + + public static final int STENCIL_INDEX = GL11.GL_STENCIL_INDEX; + public static final int STENCIL_INDEX1 = GL30.GL_STENCIL_INDEX1; + public static final int STENCIL_INDEX4 = GL30.GL_STENCIL_INDEX4; + public static final int STENCIL_INDEX8 = GL30.GL_STENCIL_INDEX8; + + public static final int ARRAY_BUFFER = GL15.GL_ARRAY_BUFFER; + public static final int ELEMENT_ARRAY_BUFFER = GL15.GL_ELEMENT_ARRAY_BUFFER; + + public static final int SAMPLES = GL13.GL_SAMPLES; + + public static final int FRAMEBUFFER_COMPLETE = + GL30.GL_FRAMEBUFFER_COMPLETE; + public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = + GL30.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = + GL30.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = + EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; + public static final int FRAMEBUFFER_INCOMPLETE_FORMATS = + EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT; + public static final int FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = + GL30.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER; + public static final int FRAMEBUFFER_INCOMPLETE_READ_BUFFER = + GL30.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER; + public static final int FRAMEBUFFER_UNSUPPORTED = + GL30.GL_FRAMEBUFFER_UNSUPPORTED; + + public static final int STATIC_DRAW = GL15.GL_STATIC_DRAW; + public static final int DYNAMIC_DRAW = GL15.GL_DYNAMIC_DRAW; + public static final int STREAM_DRAW = GL15.GL_STREAM_DRAW; + + public static final int READ_ONLY = GL15.GL_READ_ONLY; + public static final int WRITE_ONLY = GL15.GL_WRITE_ONLY; + public static final int READ_WRITE = GL15.GL_READ_WRITE; + + public static final int TRIANGLE_FAN = GL11.GL_TRIANGLE_FAN; + public static final int TRIANGLE_STRIP = GL11.GL_TRIANGLE_STRIP; + public static final int TRIANGLES = GL11.GL_TRIANGLES; + + public static final int VENDOR = GL11.GL_VENDOR; + public static final int RENDERER = GL11.GL_RENDERER; + public static final int VERSION = GL11.GL_VERSION; + public static final int EXTENSIONS = GL11.GL_EXTENSIONS; + public static final int SHADING_LANGUAGE_VERSION = + GL20.GL_SHADING_LANGUAGE_VERSION; + + public static final int MAX_TEXTURE_SIZE = GL11.GL_MAX_TEXTURE_SIZE; + public static final int MAX_SAMPLES = GL30.GL_MAX_SAMPLES; + public static final int ALIASED_LINE_WIDTH_RANGE = + GL12.GL_ALIASED_LINE_WIDTH_RANGE; + public static final int ALIASED_POINT_SIZE_RANGE = + GL12.GL_ALIASED_POINT_SIZE_RANGE; + public static final int DEPTH_BITS = GL11.GL_DEPTH_BITS; + public static final int STENCIL_BITS = GL11.GL_STENCIL_BITS; + + public static final int TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO; + public static final int TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD; + + public static final int TEXTURE0 = GL13.GL_TEXTURE0; + public static final int TEXTURE1 = GL13.GL_TEXTURE1; + public static final int TEXTURE2 = GL13.GL_TEXTURE2; + public static final int TEXTURE3 = GL13.GL_TEXTURE3; + public static final int TEXTURE_MIN_FILTER = GL11.GL_TEXTURE_MIN_FILTER; + public static final int TEXTURE_MAG_FILTER = GL11.GL_TEXTURE_MAG_FILTER; + public static final int TEXTURE_WRAP_S = GL11.GL_TEXTURE_WRAP_S; + public static final int TEXTURE_WRAP_T = GL11.GL_TEXTURE_WRAP_T; + + public static final int BLEND = GL11.GL_BLEND; + public static final int ONE = GL11.GL_ONE; + public static final int ZERO = GL11.GL_ZERO; + public static final int SRC_ALPHA = GL11.GL_SRC_ALPHA; + public static final int DST_ALPHA = GL11.GL_DST_ALPHA; + public static final int ONE_MINUS_SRC_ALPHA = GL11.GL_ONE_MINUS_SRC_ALPHA; + public static final int ONE_MINUS_DST_COLOR = GL11.GL_ONE_MINUS_DST_COLOR; + public static final int ONE_MINUS_SRC_COLOR = GL11.GL_ONE_MINUS_SRC_COLOR; + public static final int DST_COLOR = GL11.GL_DST_COLOR; + public static final int SRC_COLOR = GL11.GL_SRC_COLOR; + + public static final int FRAMEBUFFER = GL30.GL_FRAMEBUFFER; + public static final int COLOR_ATTACHMENT0 = GL30.GL_COLOR_ATTACHMENT0; + public static final int COLOR_ATTACHMENT1 = GL30.GL_COLOR_ATTACHMENT1; + public static final int COLOR_ATTACHMENT2 = GL30.GL_COLOR_ATTACHMENT2; + public static final int COLOR_ATTACHMENT3 = GL30.GL_COLOR_ATTACHMENT3; + public static final int RENDERBUFFER = GL30.GL_RENDERBUFFER; + public static final int DEPTH_ATTACHMENT = GL30.GL_DEPTH_ATTACHMENT; + public static final int STENCIL_ATTACHMENT = GL30.GL_STENCIL_ATTACHMENT; + public static final int READ_FRAMEBUFFER = GL30.GL_READ_FRAMEBUFFER; + public static final int DRAW_FRAMEBUFFER = GL30.GL_DRAW_FRAMEBUFFER; + + public static final int VERTEX_SHADER = GL20.GL_VERTEX_SHADER; + public static final int FRAGMENT_SHADER = GL20.GL_FRAGMENT_SHADER; + public static final int INFO_LOG_LENGTH = GL20.GL_INFO_LOG_LENGTH; + public static final int SHADER_SOURCE_LENGTH = GL20.GL_SHADER_SOURCE_LENGTH; + public static final int COMPILE_STATUS = GL20.GL_COMPILE_STATUS; + public static final int LINK_STATUS = GL20.GL_LINK_STATUS; + public static final int VALIDATE_STATUS = GL20.GL_VALIDATE_STATUS; + + public static final int MULTISAMPLE = GL13.GL_MULTISAMPLE; + public static final int POINT_SMOOTH = GL11.GL_POINT_SMOOTH; + public static final int LINE_SMOOTH = GL11.GL_LINE_SMOOTH; + public static final int POLYGON_SMOOTH = GL11.GL_POLYGON_SMOOTH; + + + ////////////////////////////////////////////////////////////////////////////// + + // Caps query + + + public String getString(int name) { + return GL11.glGetString(name); + } + + + public void getIntegerv(int name, IntBuffer values) { + if (-1 < name) { + GL11.glGetInteger(name, values); + } else { + fillIntBuffer(values, 0, values.capacity() - 1, 0); + } + } + + + public void getFloatv(int name, FloatBuffer values) { + if (-1 < name) { + GL11.glGetFloat(name, values); + } else { + fillFloatBuffer(values, 0, values.capacity() - 1, 0); + } + } + + + public void getBooleanv(int name, IntBuffer values) { + if (-1 < name) { + if (byteBuffer.capacity() < values.capacity()) { + byteBuffer = allocateDirectByteBuffer(values.capacity()); + } + GL11.glGetBoolean(name, byteBuffer); + for (int i = 0; i < values.capacity(); i++) { + values.put(i, byteBuffer.get(i)); + } + } else { + fillIntBuffer(values, 0, values.capacity() - 1, 0); + } + } + + + /////////////////////////////////////////////////////////// + + // Enable/disable caps + + + public void enable(int cap) { + if (-1 < cap) { + GL11.glEnable(cap); + } + } + + + public void disable(int cap) { + if (-1 < cap) { + GL11.glDisable(cap); + } + } + + + /////////////////////////////////////////////////////////// + + // Render control + + + public void flush() { + GL11.glFlush(); + } + + + public void finish() { + GL11.glFinish(); + } + + + /////////////////////////////////////////////////////////// + + // Error handling + + + public int getError() { + return GL11.glGetError(); + } + + + public String errorString(int err) { + return glu.gluErrorString(err); + } + + + /////////////////////////////////////////////////////////// + + // Rendering options + + + public void frontFace(int mode) { + GL11.glFrontFace(mode); + } + + + public void cullFace(int mode) { + GL11.glCullFace(mode); + } + + + public void depthMask(boolean flag) { + GL11.glDepthMask(flag); + } + + + public void depthFunc(int func) { + GL11.glDepthFunc(func); + } + + + /////////////////////////////////////////////////////////// + + // Textures + + + public void genTextures(int n, IntBuffer ids) { + GL11.glGenTextures(ids); + } + + + public void deleteTextures(int n, IntBuffer ids) { + GL11.glDeleteTextures(ids); + } + + + public void activeTexture(int unit) { + GL13.glActiveTexture(unit); + } + + + public void bindTexture(int target, int id) { + GL11.glBindTexture(target, id); + if (target == TEXTURE_2D) { + boundTextures[0] = id; + } else if (target == TEXTURE_RECTANGLE) { + boundTextures[1] = id; + } + } + + + public void texImage2D(int target, int level, int internalFormat, + int width, int height, int border, int format, + int type, Buffer data) { + GL11.glTexImage2D(target, level, internalFormat, + width, height, border, format, type, (IntBuffer)data); + } + + + public void texSubImage2D(int target, int level, int xOffset, int yOffset, + int width, int height, int format, + int type, Buffer data) { + GL11.glTexSubImage2D(target, level, xOffset, yOffset, + width, height, format, type, (IntBuffer)data); + } + + + public void texParameteri(int target, int param, int value) { + GL11.glTexParameteri(target, param, value); + } + + + public void texParameterf(int target, int param, float value) { + GL11.glTexParameterf(target, param, value); + } + + + public void getTexParameteriv(int target, int param, IntBuffer values) { + GL11.glGetTexParameter(target, param, values); + } + + + public void generateMipmap(int target) { + GL30.glGenerateMipmap(target); + } + + + /////////////////////////////////////////////////////////// + + // Vertex Buffers + + + public void genBuffers(int n, IntBuffer ids) { + GL15.glGenBuffers(ids); + } + + + public void deleteBuffers(int n, IntBuffer ids) { + GL15.glDeleteBuffers(ids); + } + + + public void bindBuffer(int target, int id) { + GL15.glBindBuffer(target, id); + } + + + public void bufferData(int target, int size, Buffer data, int usage) { + if (data == null) { + FloatBuffer empty = BufferUtils.createFloatBuffer(size); + GL15.glBufferData(target, empty, usage); + } else { + if (data instanceof ByteBuffer) { + GL15.glBufferData(target, (ByteBuffer)data, usage); + } else if (data instanceof ShortBuffer) { + GL15.glBufferData(target, (ShortBuffer)data, usage); + } else if (data instanceof IntBuffer) { + GL15.glBufferData(target, (IntBuffer)data, usage); + } else if (data instanceof FloatBuffer) { + GL15.glBufferData(target, (FloatBuffer)data, usage); + } + } + } + + + public void bufferSubData(int target, int offset, int size, Buffer data) { + if (data instanceof ByteBuffer) { + GL15.glBufferSubData(target, offset, (ByteBuffer)data); + } else if (data instanceof ShortBuffer) { + GL15.glBufferSubData(target, offset, (ShortBuffer)data); + } else if (data instanceof IntBuffer) { + GL15.glBufferSubData(target, offset, (IntBuffer)data); + } else if (data instanceof FloatBuffer) { + GL15.glBufferSubData(target, offset, (FloatBuffer)data); + } + } + + + public void drawArrays(int mode, int first, int count) { + GL11.glDrawArrays(mode, first, count); + } + + + public void drawElements(int mode, int count, int type, int offset) { + GL11.glDrawElements(mode, count, type, offset); + } + + + public void enableVertexAttribArray(int loc) { + GL20.glEnableVertexAttribArray(loc); + } + + + public void disableVertexAttribArray(int loc) { + GL20.glDisableVertexAttribArray(loc); + } + + + public void vertexAttribPointer(int loc, int size, int type, + boolean normalized, int stride, int offset) { + GL20.glVertexAttribPointer(loc, size, type, normalized, stride, offset); + } + + + public void vertexAttribPointer(int loc, int size, int type, + boolean normalized, int stride, Buffer data) { + if (type == UNSIGNED_INT) { + GL20.glVertexAttribPointer(loc, size, true, normalized, stride, (IntBuffer)data); + } else if (type == UNSIGNED_BYTE) { + GL20.glVertexAttribPointer(loc, size, true, normalized, stride, (ByteBuffer)data); + } else if (type == UNSIGNED_SHORT) { + GL20.glVertexAttribPointer(loc, size, true, normalized, stride, (ShortBuffer)data); + } else if (type == FLOAT) { + GL20.glVertexAttribPointer(loc, size, normalized, stride, (FloatBuffer)data); + } + } + + + public ByteBuffer mapBuffer(int target, int access) { + return GL15.glMapBuffer(target, access, null); + } + + + public ByteBuffer mapBufferRange(int target, int offset, int length, + int access) { + return GL30.glMapBufferRange(target, offset, length, access, null); + } + + + public void unmapBuffer(int target) { + GL15.glUnmapBuffer(target); + } + + + /////////////////////////////////////////////////////////// + + // Framebuffers, renderbuffers + + + public void genFramebuffers(int n, IntBuffer ids) { + GL30.glGenFramebuffers(ids); + } + + + public void deleteFramebuffers(int n, IntBuffer ids) { + GL30.glDeleteFramebuffers(ids); + } + + + public void genRenderbuffers(int n, IntBuffer ids) { + GL30.glGenRenderbuffers(ids); + } + + + public void deleteRenderbuffers(int n, IntBuffer ids) { + GL30.glDeleteRenderbuffers(ids); + } + + + public void bindFramebuffer(int target, int id) { + GL30.glBindFramebuffer(target, id); + } + + + public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, + int dstX0, int dstY0, int dstX1, int dstY1, + int mask, int filter) { + GL30.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, mask, filter); + } + + + public void framebufferTexture2D(int target, int attachment, int texTarget, + int texId, int level) { + GL30.glFramebufferTexture2D(target, attachment, texTarget, texId, level); + } + + + public void bindRenderbuffer(int target, int id) { + GL30.glBindRenderbuffer(target, id); + } + + + public void renderbufferStorageMultisample(int target, int samples, + int format, int width, int height){ + GL30.glRenderbufferStorageMultisample(target, samples, format, + width, height); + } + + + public void renderbufferStorage(int target, int format, + int width, int height) { + GL30.glRenderbufferStorage(target, format, width, height); + } + + + public void framebufferRenderbuffer(int target, int attachment, + int rendbufTarget, int rendbufId) { + GL30.glFramebufferRenderbuffer(target, attachment, rendbufTarget, rendbufId); + } + + + public int checkFramebufferStatus(int target) { + return GL30.glCheckFramebufferStatus(target); + } + + + /////////////////////////////////////////////////////////// + + // Shaders + + + public int createProgram() { + return GL20.glCreateProgram(); + } + + + public void deleteProgram(int id) { + GL20.glDeleteProgram(id); + } + + + public int createShader(int type) { + return GL20.glCreateShader(type); + } + + + public void deleteShader(int id) { + GL20.glDeleteShader(id); + } + + + public void linkProgram(int prog) { + GL20.glLinkProgram(prog); + } + + + public void validateProgram(int prog) { + GL20.glValidateProgram(prog); + } + + + public void useProgram(int prog) { + GL20.glUseProgram(prog); + } + + + public int getAttribLocation(int prog, String name) { + return GL20.glGetAttribLocation(prog, name); + } + + + public int getUniformLocation(int prog, String name) { + return GL20.glGetUniformLocation(prog, name); + } + + + public void uniform1i(int loc, int value) { + GL20.glUniform1i(loc, value); + } + + + public void uniform2i(int loc, int value0, int value1) { + GL20.glUniform2i(loc, value0, value1); + } + + + public void uniform3i(int loc, int value0, int value1, int value2) { + GL20.glUniform3i(loc, value0, value1, value2); + } + + + public void uniform4i(int loc, int value0, int value1, int value2, + int value3) { + GL20.glUniform4i(loc, value0, value1, value2, value3); + } + + + public void uniform1f(int loc, float value) { + GL20.glUniform1f(loc, value); + } + + + public void uniform2f(int loc, float value0, float value1) { + GL20.glUniform2f(loc, value0, value1); + } + + + public void uniform3f(int loc, float value0, float value1, float value2) { + GL20.glUniform3f(loc, value0, value1, value2); + } + + + public void uniform4f(int loc, float value0, float value1, float value2, + float value3) { + GL20.glUniform4f(loc, value0, value1, value2, value3); + } + + + public void uniform1iv(int loc, int count, IntBuffer v) { + v.limit(count); + GL20.glUniform1(loc, v); + v.clear(); + } + + + public void uniform2iv(int loc, int count, IntBuffer v) { + v.limit(2 * count); + GL20.glUniform2(loc, v); + v.clear(); + } + + + public void uniform3iv(int loc, int count, IntBuffer v) { + v.limit(3 * count); + GL20.glUniform3(loc, v); + v.clear(); + } + + + public void uniform4iv(int loc, int count, IntBuffer v) { + v.limit(4 * count); + GL20.glUniform4(loc, v); + v.clear(); + } + + + public void uniform1fv(int loc, int count, FloatBuffer v) { + v.limit(count); + GL20.glUniform1(loc, v); + v.clear(); + } + + + public void uniform2fv(int loc, int count, FloatBuffer v) { + v.limit(2 * count); + GL20.glUniform2(loc, v); + v.clear(); + } + + + public void uniform3fv(int loc, int count, FloatBuffer v) { + v.limit(3 * count); + GL20.glUniform3(loc, v); + v.clear(); + } + + + public void uniform4fv(int loc, int count, FloatBuffer v) { + v.limit(4 * count); + GL20.glUniform4(loc, v); + v.clear(); + } + + + public void uniformMatrix2fv(int loc, int count, boolean transpose, + FloatBuffer mat) { + mat.limit(4); + GL20.glUniformMatrix2(loc, transpose, mat); + mat.clear(); + } + + + public void uniformMatrix3fv(int loc, int count, boolean transpose, + FloatBuffer mat) { + mat.limit(9); + GL20.glUniformMatrix3(loc, transpose, mat); + mat.clear(); + } + + + public void uniformMatrix4fv(int loc, int count, boolean transpose, + FloatBuffer mat) { + mat.limit(16); + GL20.glUniformMatrix4(loc, transpose, mat); + mat.clear(); + } + + + public void vertexAttrib1f(int loc, float value) { + GL20.glVertexAttrib1f(loc, value); + } + + + public void vertexAttrib2f(int loc, float value0, float value1) { + GL20.glVertexAttrib2f(loc, value0, value1); + } + + + public void vertexAttrib3f(int loc, float value0, float value1, float value2){ + GL20.glVertexAttrib3f(loc, value0, value1, value2); + } + + + public void vertexAttrib4f(int loc, float value0, float value1, float value2, + float value3) { + GL20.glVertexAttrib4f(loc, value0, value1, value2, value3); + } + + + public void shaderSource(int id, String source) { + GL20.glShaderSource(id, source); + } + + + public void compileShader(int id) { + GL20.glCompileShader(id); + } + + + public void attachShader(int prog, int shader) { + GL20.glAttachShader(prog, shader); + } + + + public void getShaderiv(int shader, int pname, IntBuffer params) { + GL20.glGetShader(shader, pname, params); + } + + + public String getShaderInfoLog(int shader) { + int len = GL20.glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH); + return GL20.glGetShaderInfoLog(shader, len); + } + + + public void getProgramiv(int prog, int pname, IntBuffer params) { + GL20.glGetProgram(prog, pname, params); + } + + + public String getProgramInfoLog(int prog) { + int len = GL20.glGetProgrami(prog, GL20.GL_INFO_LOG_LENGTH); + return GL20.glGetProgramInfoLog(prog, len); + } + + + /////////////////////////////////////////////////////////// + + // Viewport + + + public void viewport(int x, int y, int width, int height) { + GL11.glViewport(x, y, width, height); + } + + + /////////////////////////////////////////////////////////// + + // Clipping (scissor test) + + + public void scissor(int x, int y, int w, int h) { + GL11.glScissor(x, y, w, h); + } + + + /////////////////////////////////////////////////////////// + + // Blending + + + public void blendEquation(int eq) { + GL14.glBlendEquation(eq); + } + + + public void blendFunc(int srcFactor, int dstFactor) { + GL11.glBlendFunc(srcFactor, dstFactor); + } + + + /////////////////////////////////////////////////////////// + + // Pixels + + + public void readBuffer(int buf) { + GL11.glReadBuffer(buf); + } + + + public void readPixels(int x, int y, int width, int height, int format, + int type, Buffer buffer) { + + GL11.glReadPixels(x, y, width, height, format, type, (IntBuffer)buffer); + } + + + public void drawBuffer(int buf) { + GL11.glDrawBuffer(buf); + } + + + public void clearDepth(float d) { + GL11.glClearDepth(d); + } + + + public void clearStencil(int s) { + GL11.glClearStencil(s); + } + + + public void colorMask(boolean wr, boolean wg, boolean wb, boolean wa) { + GL11.glColorMask(wr, wg, wb, wa); + } + + + public void clearColor(float r, float g, float b, float a) { + GL11.glClearColor(r, g, b, a); + } + + + public void clear(int mask) { + GL11.glClear(mask); + } }