FileDocCategorySizeDatePackage
GL10Impl.javaAPI DocphoneME MR2 API (J2ME)104550Wed May 02 18:00:48 BST 2007com.sun.jsr239

GL10Impl

public class GL10Impl extends Object implements GL10, GL10Ext

Fields Summary
static final boolean
debugQueue
static final boolean
DEBUG_MEM
static EGL10
egl
EGLContext
context
context is the context the GL10 is created for.
int
pixelStorePackAlignment
int
pixelStoreUnpackAlignment
int
VERTEX_POINTER
int
COLOR_POINTER
int
NORMAL_POINTER
int
TEX_COORD_POINTER
int
POINT_SIZE_POINTER
int
MATRIX_INDEX_POINTER
int
WEIGHT_POINTER
Buffer[]
pointerBuffer
boolean[]
pointerEnabled
int[]
pointerSize
int[]
pointerType
int[]
pointerStride
int[]
pointerOffset
int[]
pointerRemaining
public static final int
CMD_ACTIVE_TEXTURE
public static final int
CMD_ALPHA_FUNC
public static final int
CMD_ALPHA_FUNCX
public static final int
CMD_BIND_BUFFER
public static final int
CMD_BIND_TEXTURE
public static final int
CMD_BLEND_FUNC
public static final int
CMD_BUFFER_DATA
public static final int
CMD_BUFFER_SUB_DATA
public static final int
CMD_CLEAR
public static final int
CMD_CLEAR_COLOR
public static final int
CMD_CLEAR_COLORX
public static final int
CMD_CLEAR_DEPTHF
public static final int
CMD_CLEAR_DEPTHX
public static final int
CMD_CLEAR_STENCIL
public static final int
CMD_CLIENT_ACTIVE_TEXTURE
public static final int
CMD_CLIP_PLANEF
public static final int
CMD_CLIP_PLANEFB
public static final int
CMD_CLIP_PLANEX
public static final int
CMD_CLIP_PLANEXB
public static final int
CMD_COLOR4F
public static final int
CMD_COLOR4X
public static final int
CMD_COLOR4UB
public static final int
CMD_COLOR_MASK
public static final int
CMD_COLOR_POINTER
public static final int
CMD_COLOR_POINTER_VBO
public static final int
CMD_COMPRESSED_TEX_IMAGE_2D
public static final int
CMD_COMPRESSED_TEX_SUB_IMAGE_2D
public static final int
CMD_COPY_TEX_IMAGE_2D
public static final int
CMD_COPY_TEX_SUB_IMAGE_2D
public static final int
CMD_CULL_FACE
public static final int
CMD_CURRENT_PALETTE_MATRIX
public static final int
CMD_DELETE_BUFFERS
public static final int
CMD_DELETE_BUFFERSB
public static final int
CMD_DELETE_TEXTURES
public static final int
CMD_DELETE_TEXTURESB
public static final int
CMD_DEPTH_FUNC
public static final int
CMD_DEPTH_MASK
public static final int
CMD_DEPTH_RANGEF
public static final int
CMD_DEPTH_RANGEX
public static final int
CMD_DISABLE
public static final int
CMD_DISABLE_CLIENT_STATE
public static final int
CMD_DRAW_ARRAYS
public static final int
CMD_DRAW_ELEMENTSB
public static final int
CMD_DRAW_ELEMENTS_VBO
public static final int
CMD_DRAW_TEXF
public static final int
CMD_DRAW_TEXFB
public static final int
CMD_DRAW_TEXI
public static final int
CMD_DRAW_TEXIB
public static final int
CMD_DRAW_TEXS
public static final int
CMD_DRAW_TEXSB
public static final int
CMD_DRAW_TEXX
public static final int
CMD_DRAW_TEXXB
public static final int
CMD_ENABLE
public static final int
CMD_ENABLE_CLIENT_STATE
public static final int
CMD_FOGF
public static final int
CMD_FOGFB
public static final int
CMD_FOGFV
public static final int
CMD_FOGX
public static final int
CMD_FOGXB
public static final int
CMD_FOGXV
public static final int
CMD_FRONT_FACE
public static final int
CMD_FRUSTUMF
public static final int
CMD_FRUSTUMX
public static final int
CMD_HINT
public static final int
CMD_LIGHTF
public static final int
CMD_LIGHTFB
public static final int
CMD_LIGHTFV
public static final int
CMD_LIGHTX
public static final int
CMD_LIGHTXB
public static final int
CMD_LIGHTXV
public static final int
CMD_LIGHT_MODELF
public static final int
CMD_LIGHT_MODELFB
public static final int
CMD_LIGHT_MODELFV
public static final int
CMD_LIGHT_MODELX
public static final int
CMD_LIGHT_MODELXB
public static final int
CMD_LIGHT_MODELXV
public static final int
CMD_LINE_WIDTH
public static final int
CMD_LINE_WIDTHX
public static final int
CMD_LOAD_IDENTITY
public static final int
CMD_LOAD_MATRIXF
public static final int
CMD_LOAD_MATRIXFB
public static final int
CMD_LOAD_MATRIXX
public static final int
CMD_LOAD_MATRIXXB
public static final int
CMD_LOAD_PALETTE_FROM_MODEL_VIEW_MATRIX
public static final int
CMD_LOGIC_OP
public static final int
CMD_MATERIALF
public static final int
CMD_MATERIALFB
public static final int
CMD_MATERIALFV
public static final int
CMD_MATERIALX
public static final int
CMD_MATERIALXB
public static final int
CMD_MATERIALXV
public static final int
CMD_MATRIX_INDEX_POINTER
public static final int
CMD_MATRIX_INDEX_POINTER_VBO
public static final int
CMD_MATRIX_MODE
public static final int
CMD_MULTI_TEXT_COORD4F
public static final int
CMD_MULTI_TEXT_COORD4X
public static final int
CMD_MULT_MATRIXF
public static final int
CMD_MULT_MATRIXFB
public static final int
CMD_MULT_MATRIXX
public static final int
CMD_MULT_MATRIXXB
public static final int
CMD_NORMAL3F
public static final int
CMD_NORMAL3X
public static final int
CMD_NORMAL_POINTER
public static final int
CMD_NORMAL_POINTER_VBO
public static final int
CMD_ORTHOF
public static final int
CMD_ORTHOX
public static final int
CMD_PIXEL_STOREI
public static final int
CMD_POINT_PARAMETERF
public static final int
CMD_POINT_PARAMETERFB
public static final int
CMD_POINT_PARAMETERFV
public static final int
CMD_POINT_PARAMETERX
public static final int
CMD_POINT_PARAMETERXB
public static final int
CMD_POINT_PARAMETERXV
public static final int
CMD_POINT_SIZE
public static final int
CMD_POINT_SIZEX
public static final int
CMD_POINT_SIZE_POINTER
public static final int
CMD_POINT_SIZE_POINTER_VBO
public static final int
CMD_POLYGON_OFFSET
public static final int
CMD_POLYGON_OFFSETX
public static final int
CMD_POP_MATRIX
public static final int
CMD_PUSH_MATRIX
public static final int
CMD_ROTATEF
public static final int
CMD_ROTATEX
public static final int
CMD_SAMPLE_COVERAGE
public static final int
CMD_SAMPLE_COVERAGEX
public static final int
CMD_SCALEF
public static final int
CMD_SCALEX
public static final int
CMD_SCISSOR
public static final int
CMD_SHADE_MODEL
public static final int
CMD_STENCIL_FUNC
public static final int
CMD_STENCIL_MASK
public static final int
CMD_STENCIL_OP
public static final int
CMD_TEX_COORD_POINTER
public static final int
CMD_TEX_COORD_POINTER_VBO
public static final int
CMD_TEX_ENVF
public static final int
CMD_TEX_ENVFB
public static final int
CMD_TEX_ENVFV
public static final int
CMD_TEX_ENVI
public static final int
CMD_TEX_ENVIB
public static final int
CMD_TEX_ENVIV
public static final int
CMD_TEX_ENVX
public static final int
CMD_TEX_ENVXB
public static final int
CMD_TEX_ENVXV
public static final int
CMD_TEX_IMAGE_2D
public static final int
CMD_TEX_PARAMETERF
public static final int
CMD_TEX_PARAMETERFB
public static final int
CMD_TEX_PARAMETERFV
public static final int
CMD_TEX_PARAMETERI
public static final int
CMD_TEX_PARAMETERIB
public static final int
CMD_TEX_PARAMETERIV
public static final int
CMD_TEX_PARAMETERX
public static final int
CMD_TEX_PARAMETERXB
public static final int
CMD_TEX_PARAMETERXV
public static final int
CMD_TEX_SUB_IMAGE_2D
public static final int
CMD_TRANSLATEF
public static final int
CMD_TRANSLATEX
public static final int
CMD_VERTEX_POINTER
public static final int
CMD_VERTEX_POINTER_VBO
public static final int
CMD_VIEWPORT
public static final int
CMD_WEIGHT_POINTER
public static final int
CMD_WEIGHT_POINTER_VBO
public static final int
CMD_FINISH
public static final int
CMD_FLUSH
public static final int
CMD_TEX_GENF
public static final int
CMD_TEX_GENI
public static final int
CMD_TEX_GENX
public static final int
CMD_TEX_GENFB
public static final int
CMD_TEX_GENIB
public static final int
CMD_TEX_GENXB
public static final int
CMD_TEX_GENFV
public static final int
CMD_TEX_GENIV
public static final int
CMD_TEX_GENXV
public static final int
CMD_BLEND_EQUATION
public static final int
CMD_BLEND_FUNC_SEPARATE
public static final int
CMD_BLEND_EQUATION_SEPARATE
public static final int
CMD_BIND_RENDERBUFFER
public static final int
CMD_DELETE_RENDERBUFFERS
public static final int
CMD_DELETE_RENDERBUFFERSB
public static final int
CMD_GEN_RENDERBUFFERSB
public static final int
CMD_RENDERBUFFER_STORAGE
public static final int
CMD_BIND_FRAMEBUFFER
public static final int
CMD_DELETE_FRAMEBUFFERS
public static final int
CMD_DELETE_FRAMEBUFFERSB
public static final int
CMD_GEN_FRAMEBUFFERSB
public static final int
CMD_FRAMEBUFFER_TEXTURE2D
public static final int
CMD_FRAMEBUFFER_RENDERBUFFER
public static final int
CMD_GENERATE_MIPMAP
public static final int
CMD_GEN_BUFFERSB
public static final int
CMD_GEN_TEXTURESB
static final String[]
commandStrings
int[]
queue
int
index
int
commandsLeft
public static EGLContext
currentContext
public static Hashtable
contextsByThread
IMPL_NOTE: contextsByThread may lead to the Java memory leaks (when a thread dies, an associated context will not be ever collected). As the possible workaround the following solution can be used: a private Hashtable member can be added for class Thread to keep a reference to the context. In this case the life span of a context will not be longer then that of a thread.
public int
cullFaceMode
int
VBOArrayBufferBound
int
VBOElementArrayBufferBound
Hashtable
bufferSize
Hashtable
bufferIndices
Hashtable
VBOBuffersTable
Hashtable
VBOBufferSizeTable
Hashtable
VBOBufferIndicesTable
Constructors Summary
public GL10Impl(EGLContext context)

        this.context = context;
    
Methods Summary
voidIglClipPlanef(int plane, float[] equation, int offset)

        q(CMD_CLIP_PLANEF, 5);
        q(plane);
        q(equation[offset]);
        q(equation[offset + 1]);
        q(equation[offset + 2]);
        q(equation[offset + 3]);
    
voidIglClipPlanex(int plane, int[] equation, int offset)

        q(CMD_CLIP_PLANEX, 5);
        q(plane);
        q(equation[offset]);
        q(equation[offset + 1]);
        q(equation[offset + 2]);
        q(equation[offset + 3]);
    
voidIglDeleteTextures(int n, int[] textures, int offset)

        q(CMD_DELETE_TEXTURES, n + 1);
        q(n);
        for (int i = 0; i < n; i++) {
            q(textures[i + offset]);
        }
    
voidIglFogfv(int pname, float[] params, int offset)

        int n = GLConfiguration.glFogNumParams(pname);

        q(CMD_FOGFV, n + 2);
        q(n);
        q(pname);
        for (int i = 0; i < n; i++) { 
            q(params[i + offset]);
        }
    
voidIglFogxv(int pname, int[] params, int offset)

        int n = GLConfiguration.glFogNumParams(pname);

        q(CMD_FOGXV, n + 2);
        q(n);
        q(pname);
        for (int i = 0; i < n; i++) { 
            q(params[i + offset]);
        }
    
voidIglGenTextures(int n, int[] textures, int offset)

        grabContext();
        _glGenTextures(n, textures, offset);
    
voidIglGetBooleanv(int pname, int[] params, int offset, int length)

        grabContext();
        _glGetBooleanv(pname, params, offset, length);
    
voidIglGetIntegerv(int pname, int[] params, int offset, int length)

        grabContext();
        _glGetIntegerv(pname, params, offset, length);
    
voidIglLightModelfv(int pname, float[] params, int offset)

        int n = GLConfiguration.glLightModelNumParams(pname);

        q(CMD_LIGHT_MODELFV, n + 2);
        q(n);
        q(pname);
        for (int i = 0; i < n; i++) { 
            q(params[i + offset]);
        }
    
voidIglLightModelxv(int pname, int[] params, int offset)

        int n = GLConfiguration.glLightModelNumParams(pname);

        q(CMD_LIGHT_MODELXV, n + 2);
        q(n);
        q(pname);
        for (int i = 0; i < n; i++) { 
            q(params[i + offset]);
        }
    
voidIglLightfv(int light, int pname, float[] params, int offset)

        int n = GLConfiguration.glLightNumParams(pname);

        q(CMD_LIGHTFV, n + 3);
        q(n);
        q(light);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglLightxv(int light, int pname, int[] params, int offset)

        int n = GLConfiguration.glLightNumParams(pname);

        q(CMD_LIGHTXV, n + 3);
        q(n);
        q(light);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglLoadMatrixf(float[] m, int offset)

        q(CMD_LOAD_MATRIXF, 16);
        for (int i = 0; i < 16; i++) {
            q(m[i + offset]);
        }
    
voidIglLoadMatrixx(int[] m, int offset)

        q(CMD_LOAD_MATRIXX, 16);
        for (int i = 0; i < 16; i++) {
            q(m[i + offset]);
        }
    
voidIglMaterialfv(int face, int pname, float[] params, int offset)

        int n = GLConfiguration.glMaterialNumParams(pname);

        q(CMD_MATERIALFV, n + 3);
        q(n);
        q(face);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglMaterialxv(int face, int pname, int[] params, int offset)

        int n = GLConfiguration.glMaterialNumParams(pname);

        q(CMD_MATERIALXV, n + 3);
        q(n);
        q(face);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglMultMatrixf(float[] m, int offset)

        q(CMD_MULT_MATRIXF, 16);
        for (int i = 0; i < 16; i++) {
            q(m[i + offset]);
        }
    
voidIglMultMatrixx(int[] m, int offset)

        q(CMD_MULT_MATRIXX, 16);
        for (int i = 0; i < 16; i++) {
            q(m[i + offset]);
        }
    
voidIglPointParameterfv(int pname, float[] params, int offset)

        int n = GLConfiguration.glPointParameterNumParams(pname);

        q(CMD_POINT_PARAMETERFV, n + 2);
        q(n);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglPointParameterxv(int pname, int[] params, int offset)

        int n = GLConfiguration.glPointParameterNumParams(pname);

        q(CMD_POINT_PARAMETERXV, n + 2);
        q(n);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglTexEnvfv(int target, int pname, float[] params, int offset)

        int n = GLConfiguration.glTexEnvNumParams(pname);

        q(CMD_TEX_ENVFV, n + 3);
        q(n);
        q(target);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglTexEnviv(int target, int pname, int[] params, int offset)

        int n = GLConfiguration.glTexEnvNumParams(pname);

        q(CMD_TEX_ENVIV, n + 3);
        q(n);
        q(target);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglTexEnvxv(int target, int pname, int[] params, int offset)

        int n = GLConfiguration.glTexEnvNumParams(pname);

        q(CMD_TEX_ENVXV, n + 3);
        q(n);
        q(target);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglTexParameterfv(int target, int pname, float[] params, int offset)

        int n = GLConfiguration.glTexParameterNumParams(pname);

        q(CMD_TEX_PARAMETERFV, n + 3);
        q(n);
        q(target);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglTexParameteriv(int target, int pname, int[] params, int offset)

        int n = GLConfiguration.glTexParameterNumParams(pname);

        q(CMD_TEX_PARAMETERIV, n + 3);
        q(n);
        q(target);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
voidIglTexParameterxv(int target, int pname, int[] params, int offset)

        int n = GLConfiguration.glTexParameterNumParams(pname);

        q(CMD_TEX_PARAMETERXV, n + 3);
        q(n);
        q(target);
        q(pname);
        for (int i = 0; i < n; i++) {
            q(params[i + offset]);
        }
    
native void_execute(int[] queue, int count)

static native int_getNativeAddress(java.nio.Buffer buffer, int offset)

native int_glCheckFramebufferStatusOES(int target)

native void_glGenBuffers(int n, int[] buffers, int offset)

native void_glGenFramebuffersOES(int n, int[] framebuffers, int offset)

native void_glGenRenderbuffersOES(int n, int[] renderbuffers, int offset)

native void_glGenTextures(int n, int[] textures, int offset)

native void_glGenerateError(int error)

native void_glGetBooleanv(int pname, int[] params, int offset, int length)

native void_glGetBufferParameteriv(int target, int pname, int[] params, int offset, int length)

native void_glGetClipPlanef(int pname, float[] eqn, int offset)

native void_glGetClipPlanex(int pname, int[] eqn, int offset)

native int_glGetError()

native void_glGetFixedv(int pname, int[] params, int offset, int length)

native void_glGetFloatv(int pname, float[] params, int offset, int length)

native void_glGetFramebufferAttachmentParameterivOES(int target, int attachment, int pname, int[] params, int offset, int length)

native void_glGetIntegerv(int pname, int[] params, int offset, int length)

native void_glGetLightfv(int light, int pname, float[] params, int offset, int length)

native void_glGetLightxv(int light, int pname, int[] params, int offset, int length)

native void_glGetMaterialfv(int face, int pname, float[] params, int offset, int length)

native void_glGetMaterialxv(int face, int pname, int[] params, int offset, int length)

native void_glGetRenderbufferParameterivOES(int target, int pname, int[] params, int offset, int length)

native java.lang.String_glGetString(int name)

native void_glGetTexEnvfv(int env, int pname, float[] params, int offset, int length)

native void_glGetTexEnviv(int env, int pname, int[] params, int offset, int length)

native void_glGetTexEnvxv(int env, int pname, int[] params, int offset, int length)

native int_glGetTexGenfv(int coord, int pname, float[] params, int offset, int length)

native int_glGetTexGeniv(int coord, int pname, int[] params, int offset, int length)

native int_glGetTexGenxv(int coord, int pname, int[] params, int offset, int length)

native void_glGetTexParameterfv(int target, int pname, float[] params, int offset, int length)

native void_glGetTexParameteriv(int target, int pname, int[] params, int offset, int length)

native void_glGetTexParameterxv(int target, int pname, int[] params, int offset, int length)

native int_glIsBuffer(int buffer)

native int_glIsEnabled(int cap)

native int_glIsFramebufferOES(int framebuffer)

native int_glIsRenderbufferOES(int renderbuffer)

native int_glIsTexture(int texture)

native int_glQueryMatrixxOES(int[] mantissa, int mantissaOffset, int[] exponent, int exponentOffset)

native void_glReadPixelsByte(int x, int y, int width, int height, int format, int type, byte[] array, int offset)

native void_glReadPixelsInt(int x, int y, int width, int height, int format, int type, int[] array, int offset)

native void_glReadPixelsPtr(int x, int y, int width, int height, int format, int type, int pointer)

voidaddBuffer(int buffer)


    // Adds an entry for a buffer, initially with size 0
       
        if (DEBUG_MEM) {
            System.out.println("addBuffer " + buffer);
        }
        if (buffer != 0) {
            Integer key = new Integer(buffer);
            VBOBuffersTable.put(key, new Object());
            VBOBufferSizeTable.put(key, new Integer(0));
            VBOBufferIndicesTable.put(key, new byte[0]);
        }
    
booleanbufferExists(int buffer)

        return (buffer == 0) ||
            VBOBuffersTable.containsKey(new Integer(buffer));
    
voidbufferIndexData(java.nio.Buffer data, int offset, int size, boolean removeOldData)

        Integer key = new Integer(VBOElementArrayBufferBound);
        byte[] array;

        Object o = VBOBufferIndicesTable.get(key);
        if (o == null || removeOldData) {
            array = new byte[offset + size];
        } else {
            array = (byte[])o;
            if (array.length < offset + size) {
                byte[] narray = new byte[offset + size];
                System.arraycopy(narray, 0, array, 0, offset + size);
                array = narray;
            }
        }
        
        // Copy bytes from 'data' into 'array'
        BufferManager.getBytes(data, offset, array, offset, size);
        // (Re-)store the index data
        VBOBufferIndicesTable.put(key, array);
    
intbufferTypeSize(java.nio.Buffer pointer)

        if (pointer instanceof ByteBuffer) {
            return 1;
        } else if (pointer instanceof ShortBuffer) {
            return 2;
        } else if (pointer instanceof IntBuffer ||
                   pointer instanceof FloatBuffer) {
            return 4;
        } else {
            throw new IllegalArgumentException("Unknown Buffer subclass!");
        }
    
voidcheckBounds(int last)

        for (int ptr = VERTEX_POINTER; ptr <= WEIGHT_POINTER; ptr++) {
            if (pointerEnabled[ptr]) {
                final int remaining = (pointerBuffer[ptr] != null)
                        ? pointerRemaining[ptr]
                        : getBufferSize(GL11.GL_ARRAY_BUFFER);
                final int size = pointerSize[ptr];
                final int type = pointerType[ptr];
                final int offset = pointerOffset[ptr];
                final int sizeOfType = GLConfiguration.sizeOfType(type);
                final int stride = pointerStride[ptr] == 0 ? sizeOfType :
                        pointerStride[ptr];
                final int elementSize = size * sizeOfType;

                final int lastByte = offset + last * stride + elementSize;

                if (lastByte > remaining) {
                    throw new ArrayIndexOutOfBoundsException(
                            String.valueOf(lastByte));
                }
            }
        }
    
voidcheckDrawElementsBounds(byte[] indices)

    
voidcheckIndices(int[] indices)

        int count = indices.length;

//         System.out.println("checkIndices:");
//         System.out.println("  indices = ");
//         for (int i = 0; i < indices.length; i++) {
//             System.out.print(indices[i] + " ");
//         }
//         System.out.println();
            
        for (int ptr = VERTEX_POINTER; ptr <= WEIGHT_POINTER; ptr++) {
//             System.out.println("ptr = " + ptr);
            if (pointerEnabled[ptr]) {
                int size, type, stride, offset, remaining;

                if (pointerBuffer[ptr] != null) {
                    remaining = pointerRemaining[ptr];
                } else {
                    remaining = getBufferSize(GL11.GL_ARRAY_BUFFER);
                }
//                 System.out.println("remaining = " + remaining);
                size = pointerSize[ptr];
                type = pointerType[ptr];
                stride = pointerStride[ptr];
                offset = pointerOffset[ptr];

//                 System.out.println("size = " + size);
//                 System.out.println("type = " + type);
//                 System.out.println("stride = " + stride);
//                 System.out.println("offset = " + offset);
                
                int elementSize = size*GLConfiguration.sizeOfType(type);
//                 System.out.println("elementSize = " + elementSize);
                
                for (int i = 0; i < count; i++) {
                    int idx = indices[i];
                    int bidx =
                        offset + idx*(elementSize + stride) + elementSize;
                    
//                     System.out.println("bidx[" + i + "] = " + bidx);
                    if (bidx > remaining) {
                        throw new ArrayIndexOutOfBoundsException("" +
                                                                 bidx);
                    }
                }
            }
        }
    
voidcheckLength(boolean[] params, int length, int offset)
Utility for common error checking.

exception
IllegalArgumentException if param is null or shorter than length.

        if (params == null) {
            throwIAE(Errors.GL_PARAMS_NULL);
        }
        if (offset < 0) {
            throwIAE(Errors.GL_OFFSET_NEGATIVE);
        }
        if (params.length - offset < length) {
            throwIAE(Errors.GL_BAD_LENGTH);
        }
    
voidcheckLength(short[] params, int length, int offset)
Utility for common error checking.

exception
IllegalArgumentException if param is null or shorter than length.

        if (params == null) {
            throwIAE(Errors.GL_PARAMS_NULL);
        }
        if (offset < 0) {
            throwIAE(Errors.GL_OFFSET_NEGATIVE);
        }
        if (params.length - offset < length) {
            throwIAE(Errors.GL_BAD_LENGTH);
        }
    
voidcheckLength(int[] params, int length, int offset)
Utility for common error checking.

exception
IllegalArgumentException if param is null or shorter than length.

        if (params == null) {
            throwIAE(Errors.GL_PARAMS_NULL);
        }
        if (offset < 0) {
            throwIAE(Errors.GL_OFFSET_NEGATIVE);
        }
        if (params.length - offset < length) {
            throwIAE(Errors.GL_BAD_LENGTH);
        }
    
voidcheckLength(float[] params, int length, int offset)
Utility for common error checking.

exception
IllegalArgumentException if param is null or shorter than length.

        if (params == null) {
            throwIAE(Errors.GL_PARAMS_NULL);
        }
        if (offset < 0) {
            throwIAE(Errors.GL_OFFSET_NEGATIVE);
        }
        if (params.length - offset < length) {
            throwIAE(Errors.GL_BAD_LENGTH);
        }
    
voidcheckLength(java.nio.Buffer params, int length)
Utility for common error checking.

exception
IllegalArgumentException if param is null or shorter than length.

        if (params == null) {
            throwIAE(Errors.GL_PARAMS_NULL);
        }
        if (params.remaining() < length) {
            throwIAE(Errors.GL_BAD_LENGTH);
        }    
    
voidcheckThread()


        Thread boundThread = ((ContextAccess)context).getBoundThread();
        if (Thread.currentThread() != boundThread) {
            throw new IllegalStateException("GL call from improper thread");
        }
    
java.nio.BuffercreateDirectCopy(java.nio.Buffer data)

        int length = data.remaining();
    
        ByteBuffer direct;
        if (data instanceof ByteBuffer) {
            direct = ByteBuffer.allocateDirect(length);
            direct.put((ByteBuffer)data);
            return direct;
        } else if (data instanceof ShortBuffer) {
            direct = ByteBuffer.allocateDirect(2*length);
            ShortBuffer directShort = direct.asShortBuffer();
            directShort.put((ShortBuffer)data);
            return directShort;
        } else if (data instanceof IntBuffer) {
            direct = ByteBuffer.allocateDirect(4*length);
            IntBuffer directInt = direct.asIntBuffer();
            directInt.put((IntBuffer)data);
            return directInt;
        } else if (data instanceof FloatBuffer) {
            direct = ByteBuffer.allocateDirect(4*length);
            FloatBuffer directFloat = direct.asFloatBuffer();
            directFloat.put((FloatBuffer)data);
            return directFloat;
        } else {
            throw new IllegalArgumentException(Errors.GL_UNKNOWN_BUFFER);
        }
    
public synchronized voiddispose()

        glFinish();
        this.context = null;
    
intfloatToIntBits(float f)

        int i = Float.floatToIntBits(f);
        if (GLConfiguration.SWAP_FLOAT_BYTES) {
            // Start: AABBCCDD
            // End:   DDCCBBAA
            i = (((i << 24) & 0xff000000) |
                 ((i <<  8) & 0x00ff0000) |
                 ((i >>  8) & 0x0000ff00) |
                 ((i >> 24) & 0x000000ff));
        }
        return i;
    
byte[]getBufferIndices()

        Integer key = key(GL11.GL_ELEMENT_ARRAY_BUFFER);

        Object o = VBOBufferIndicesTable.get(key);
        if (o != null) {
            return (byte[])o;
        } else {
            throw new IllegalStateException("No VBO active for target!");
        }
    
intgetBufferSize(int target)

        Integer key = key(target);

        Object o = VBOBufferSizeTable.get(key);
        if (o != null) {
            return ((Integer)o).intValue();
        } else {
            throw new IllegalStateException("No VBO active for target!");
        }
    
public synchronized voidglActiveTexture(int texture)

        checkThread();
        q(CMD_ACTIVE_TEXTURE, 1);
        q(texture);
    
public synchronized voidglAlphaFunc(int func, float ref)

        checkThread();
        q(CMD_ALPHA_FUNC, 2);
        q(func);
        q(ref);
    
public synchronized voidglAlphaFuncx(int func, int ref)

        checkThread();
        q(CMD_ALPHA_FUNCX, 2);
        q(func);
        q(ref);
    
public synchronized voidglBindTexture(int target, int texture)

        checkThread();
        q(CMD_BIND_TEXTURE, 2);
        q(target);
        q(texture);
    
public synchronized voidglBlendFunc(int sfactor, int dfactor)

        checkThread();
        q(CMD_BLEND_FUNC, 2);
        q(sfactor);
        q(dfactor);
    
public synchronized voidglClear(int mask)

        checkThread();
        q(CMD_CLEAR, 1);
        q(mask);
    
public synchronized voidglClearColor(float red, float green, float blue, float alpha)

        checkThread();
        q(CMD_CLEAR_COLOR, 4);
        q(red);
        q(green);
        q(blue);
        q(alpha);
    
public synchronized voidglClearColorx(int red, int green, int blue, int alpha)

        checkThread();
        q(CMD_CLEAR_COLORX, 4);
        q(red);
        q(green);
        q(blue);
        q(alpha);
    
public synchronized voidglClearDepthf(float depth)

        checkThread();
        q(CMD_CLEAR_DEPTHF, 1);
        q(depth);
    
public synchronized voidglClearDepthx(int depth)

        checkThread();
        q(CMD_CLEAR_DEPTHX, 1);
        q(depth);
    
public synchronized voidglClearStencil(int s)

        checkThread();
        q(CMD_CLEAR_STENCIL, 1);
        q(s);
    
public synchronized voidglClientActiveTexture(int texture)

        checkThread();
        q(CMD_CLIENT_ACTIVE_TEXTURE, 1);
        q(texture);
    
public synchronized voidglColor4f(float red, float green, float blue, float alpha)

        checkThread();
        q(CMD_COLOR4F, 4);
        q(red);
        q(green);
        q(blue);
        q(alpha);
    
public synchronized voidglColor4ub(byte red, byte green, byte blue, byte alpha)

        checkThread();
        q(CMD_COLOR4UB, 4);
        q((int)red);
        q((int)green);
        q((int)blue);
        q((int)alpha);
    
public synchronized voidglColor4x(int red, int green, int blue, int alpha)

        checkThread();
        q(CMD_COLOR4X, 4);
        q(red);
        q(green);
        q(blue);
        q(alpha);
    
public synchronized voidglColorMask(boolean red, boolean green, boolean blue, boolean alpha)

        checkThread();
        q(CMD_COLOR_MASK, 4);
        q(red ? 1 : 0);
        q(green ? 1 : 0);
        q(blue ? 1 : 0);
        q(alpha ? 1 : 0);
    
public synchronized voidglColorPointer(int size, int type, int stride, java.nio.Buffer pointer)

        checkThread();
        if (VBOArrayBufferBound != 0) {
            throw new IllegalStateException("glColorPointer:" +
                                            Errors.VBO_ARRAY_BUFFER_BOUND);
        }
        if (pointer == null) {
            throwIAE(Errors.GL_POINTER_NULL);
        }
        if (!isDirect(pointer)) {
            throwIAE(Errors.GL_NOT_DIRECT);
        }

        // Only record details if this is a legal operation
        if ((size == 4) && 
            (type == GL_UNSIGNED_BYTE ||
             type == GL_FIXED ||
             type == GL_FLOAT) &&
            (stride >= 0)) {
            BufferManager.releaseBuffer(pointerBuffer[COLOR_POINTER]);
            BufferManager.useBuffer(pointer);
            
            pointerBuffer[COLOR_POINTER] = pointer;
            pointerSize[COLOR_POINTER] = size;
            pointerType[COLOR_POINTER] = type;
            pointerStride[COLOR_POINTER] = stride;
            int nbytes = bufferTypeSize(pointer);
            pointerRemaining[COLOR_POINTER] = pointer.remaining()*nbytes;
            pointerOffset[COLOR_POINTER] = 0;
        }

        q(CMD_COLOR_POINTER, 4);
        q(size);
        q(type);
        q(stride);
        q(pointer);

        qflush();
    
public synchronized voidglCompressedTexImage2D(int target, int level, int internalformat, int width, int height, int border, int imageSize, java.nio.Buffer data)

        checkThread();
        checkLength(data, imageSize);

        boolean isReadOnly = false;
        if (!isDirect(data)) {
            data = createDirectCopy(data);
            isReadOnly = true;
        }

        // Need revisit: BufferManager stuff

        q(CMD_COMPRESSED_TEX_IMAGE_2D, 8);
        q(target);
        q(level);
        q(internalformat);
        q(width);
        q(height);
        q(border);
        q(imageSize);
        q(data);
    
        if (!isReadOnly) {
            qflush();
        }
    
public synchronized voidglCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int imageSize, java.nio.Buffer data)

        checkThread();
        checkLength(data, imageSize);

        boolean isReadOnly = false;
        if (!isDirect(data)) {
            data = createDirectCopy(data);
            isReadOnly = true;
        }

        // Need revisit: BufferManager stuff

        q(CMD_COMPRESSED_TEX_SUB_IMAGE_2D, 9);
        q(target);
        q(level);
        q(xoffset);
        q(yoffset);
        q(width);
        q(height);
        q(format);
        q(imageSize);
        q(data);
    
        if (!isReadOnly) {
            qflush();
        }
    
public synchronized voidglCopyTexImage2D(int target, int level, int internalformat, int x, int y, int width, int height, int border)

        checkThread();
        q(CMD_COPY_TEX_IMAGE_2D, 8);
        q(target);
        q(level);
        q(internalformat);
        q(x);
        q(y);
        q(width);
        q(height);
        q(border);
    
public synchronized voidglCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, int width, int height)

        checkThread();
        q(CMD_COPY_TEX_SUB_IMAGE_2D, 8);
        q(target);
        q(level);
        q(xoffset);
        q(yoffset);
        q(x);
        q(y);
        q(width);
        q(height);
    
public synchronized voidglCullFace(int mode)

        checkThread();
        q(CMD_CULL_FACE, 1);
        q(mode);

        // Workaround for Gerbera bug, CR 6401385
        cullFaceMode = mode;
    
public synchronized voidglDeleteTextures(int n, int[] textures, int offset)

        checkThread();
        checkLength(textures, n, offset);

        IglDeleteTextures(n, textures, offset);
    
public synchronized voidglDeleteTextures(int n, java.nio.IntBuffer textures)

        checkThread();
        // Need revisit: defend against race condition
        checkLength(textures, n);

        if (!textures.isDirect()) {
            IglDeleteTextures(n, textures.array(), offset(textures));
            return;
        }

        // Queue pointer
        q(CMD_DELETE_TEXTURESB, 2);
        q(n);
        q(textures);

        qflush();
    
public synchronized voidglDepthFunc(int func)

        checkThread();
        q(CMD_DEPTH_FUNC, 1);
        q(func);
    
public synchronized voidglDepthMask(boolean flag)

        checkThread();
        q(CMD_DEPTH_MASK, 1);
        q(flag ? 1 : 0);
    
public synchronized voidglDepthRangef(float zNear, float zFar)

        checkThread();
        q(CMD_DEPTH_RANGEF, 2);
        q(zNear);
        q(zFar);
    
public synchronized voidglDepthRangex(int zNear, int zFar)

        checkThread();
        q(CMD_DEPTH_RANGEX, 2);
        q(zNear);
        q(zFar);
    
public synchronized voidglDisable(int cap)

        checkThread();
        q(CMD_DISABLE, 1);
        q(cap);
    
public synchronized voidglDisableClientState(int array)

        checkThread();

        switch (array) {
        case GL_VERTEX_ARRAY:
            pointerEnabled[VERTEX_POINTER] = false;
            break;
        case GL_COLOR_ARRAY:
            pointerEnabled[COLOR_POINTER] = false;
            break;
        case GL_NORMAL_ARRAY:
            pointerEnabled[NORMAL_POINTER] = false;
            break;
        case GL_TEXTURE_COORD_ARRAY:
            pointerEnabled[TEX_COORD_POINTER] = false;
            break;
        case GL11.GL_POINT_SIZE_ARRAY_OES:
            pointerEnabled[POINT_SIZE_POINTER] = false;
            break;
        case GL11Ext.GL_MATRIX_INDEX_ARRAY_OES:
            pointerEnabled[MATRIX_INDEX_POINTER] = false;
            break;
        case GL11Ext.GL_WEIGHT_ARRAY_OES:
            pointerEnabled[WEIGHT_POINTER] = false;
            break;
        }

        q(CMD_DISABLE_CLIENT_STATE, 1);
        q(array);
    
public synchronized voidglDrawArrays(int mode, int first, int count)

        checkThread();

        checkBounds(first + count - 1);

        q(CMD_DRAW_ARRAYS, 3);
        q(mode);
        q(first);
        q(count);
    
public synchronized voidglDrawElements(int mode, int count, int type, java.nio.Buffer indices)

        checkThread();
        if (VBOElementArrayBufferBound != 0) {
            throw new IllegalStateException("glDrawElements:" +
                                        Errors.VBO_ELEMENT_ARRAY_BUFFER_BOUND);
        }
        if (indices == null) {
            throwIAE(Errors.GL_INDICES_NULL);
        }

        boolean isReadOnly = false;
        if (!isDirect(indices)) {
            indices = createDirectCopy(indices);
            isReadOnly = true;
        }

        // No need to bounds check if there will be a type error
        if (type == GL_UNSIGNED_BYTE ||
            type == GL_UNSIGNED_SHORT) {
            int nbytes = (type == GL_UNSIGNED_BYTE) ? 1 : 2;

            if (count > indices.remaining()) {
                throw new ArrayIndexOutOfBoundsException(
                                                        Errors.VBO_OFFSET_OOB);
            }
            
            if (DEBUG_MEM) {
                System.out.print("glDrawElements: Allocating bufferData " +
                                 count*nbytes);
            }
            byte[] bufferData = new byte[count*nbytes];
            BufferManager.getBytes(indices, 0, bufferData, 0, count*nbytes);

            if (DEBUG_MEM) {
                System.out.println(": done");
                System.out.print("glDrawElements: Allocating indexArray " +
                                 count);
            }
            int[] indexArray = new int[count];
            boolean isBigEndian = GLConfiguration.IS_BIG_ENDIAN;
            if (DEBUG_MEM) {
                System.out.println(": done");
            }

            if (type == GL_UNSIGNED_BYTE) {
                for (int i = 0; i < count; i++) {
                    indexArray[i] = bufferData[i] & 0xff;
                }
            } else if (type == GL_UNSIGNED_SHORT) {
                for (int i = 0; i < count; i++) {
                    int b0 = bufferData[2*i] & 0xff;
                    int b1 = bufferData[2*i + 1] & 0xff;
                    if (isBigEndian) {
                        indexArray[i] = (b0 << 8) | b1;
                    } else {
                        indexArray[i] = (b1 << 8) | b0;
                    }
                }
            }

            checkIndices(indexArray);
        }

        q(CMD_DRAW_ELEMENTSB, 4);
        q(mode);
        q(count);
        q(type);
        q(indices);
    
        if (!isReadOnly) {
            qflush();
        }
    
public synchronized voidglEnable(int cap)

        checkThread();
        q(CMD_ENABLE, 1);
        q(cap);
    
public synchronized voidglEnableClientState(int array)

        checkThread();

        switch (array) {
        case GL_VERTEX_ARRAY:
            pointerEnabled[VERTEX_POINTER] = true;
            break;
        case GL_COLOR_ARRAY:
            pointerEnabled[COLOR_POINTER] = true;
            break;
        case GL_NORMAL_ARRAY:
            pointerEnabled[NORMAL_POINTER] = true;
            break;
        case GL_TEXTURE_COORD_ARRAY:
            pointerEnabled[TEX_COORD_POINTER] = true;
            break;
        case GL11.GL_POINT_SIZE_ARRAY_OES:
            pointerEnabled[POINT_SIZE_POINTER] = true;
            break;
        case GL11Ext.GL_MATRIX_INDEX_ARRAY_OES:
            pointerEnabled[MATRIX_INDEX_POINTER] = true;
            break;
        case GL11Ext.GL_WEIGHT_ARRAY_OES:
            pointerEnabled[WEIGHT_POINTER] = true;
            break;
        }

        q(CMD_ENABLE_CLIENT_STATE, 1);
        q(array);
    
public synchronized voidglFinish()

        checkThread();
        q(CMD_FINISH, 0);
        qflush();
    
public synchronized voidglFlush()

        checkThread();
        q(CMD_FLUSH, 0);
        qflush();
    
public synchronized voidglFogf(int pname, float param)

        checkThread();
        q(CMD_FOGF, 2);
        q(pname);
        q(param);
    
public synchronized voidglFogfv(int pname, float[] params, int offset)

        checkThread();
        int length = GLConfiguration.glFogNumParams(pname);
        checkLength(params, length, offset);

        IglFogfv(pname, params, offset);
    
public synchronized voidglFogfv(int pname, java.nio.FloatBuffer params)

        checkThread();
        int length = GLConfiguration.glFogNumParams(pname);
        checkLength(params, length);

        if (!isDirect(params)) {
            IglFogfv(pname, params.array(), offset(params));
            return;
        }

        q(CMD_FOGFB, 2);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglFogx(int pname, int param)

        checkThread();
        q(CMD_FOGX, 2);
        q(pname);
        q(param);
    
public synchronized voidglFogxv(int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glFogNumParams(pname);
        checkLength(params, length, offset);

        IglFogxv(pname, params, offset);
    
public synchronized voidglFogxv(int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glFogNumParams(pname);
        checkLength(params, length);

        if (!isDirect(params)) {
            IglFogxv(pname, params.array(), offset(params));
            return;
        }

        q(CMD_FOGXB, 2);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglFrontFace(int mode)

        checkThread();
        q(CMD_FRONT_FACE, 1);
        q(mode);
    
public synchronized voidglFrustumf(float left, float right, float bottom, float top, float zNear, float zFar)

        checkThread();
        q(CMD_FRUSTUMF, 6);
        q(left);
        q(right);
        q(bottom);
        q(top);
        q(zNear);
        q(zFar);
    
public synchronized voidglFrustumx(int left, int right, int bottom, int top, int zNear, int zFar)

        checkThread();
        q(CMD_FRUSTUMX, 6);
        q(left);
        q(right);
        q(bottom);
        q(top);
        q(zNear);
        q(zFar);
    
public synchronized voidglGenTextures(int n, int[] textures, int offset)

        checkThread();
        checkLength(textures, n, offset);

        qflush();
        IglGenTextures(n, textures, offset);
    
public synchronized voidglGenTextures(int n, java.nio.IntBuffer textures)

        checkThread();
        checkLength(textures, n);

        qflush();
        if (!isDirect(textures)) {
            IglGenTextures(n, textures.array(), offset(textures));
            return;
        }

        q(CMD_GEN_TEXTURESB, 2);
        q(n);
        q(textures);

        qflush();
    
public synchronized voidglGetBooleanv(int pname, boolean[] params, int offset)

        checkThread();
        int length = GLConfiguration.glGetNumParams(pname);
        checkLength(params, length, offset);

        qflush();

        int[] iparams = new int[length];
        IglGetBooleanv(pname, iparams, 0, length);
        for (int i = 0; i < length; i++) {
            params[offset + i] = (iparams[i] == 1);
        }
    
public synchronized voidglGetBooleanv(int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glGetNumParams(pname);
        checkLength(params, length);

        qflush();
        if (!params.isDirect()) {
            IglGetBooleanv(pname, params.array(), offset(params), length);
        } else {
            IglGetBooleanv(pname, null, pointer(params), length);
        }
    
public synchronized intglGetError()

        checkThread();
        qflush();
        
        grabContext();
        int error = _glGetError();
        return error;
    
public synchronized voidglGetIntegerv(int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glGetNumParams(pname);
        checkLength(params, length, offset);

        qflush();
        IglGetIntegerv(pname, params, offset, length);

        // Workaround for Gerbera bug, CR 6401385
        if (pname == GL_CULL_FACE) {
            params[offset] = cullFaceMode;
        }
    
public synchronized voidglGetIntegerv(int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glGetNumParams(pname);
        checkLength(params, length);

        qflush();
        if (!params.isDirect()) {
            int[] array = params.array();
            int offset = offset(params);

            IglGetIntegerv(pname, array, offset, length);

            // Workaround for Gerbera bug, CR 6401385
            if (pname == GL_CULL_FACE) {
                array[offset] = cullFaceMode;
            }
        } else {
            IglGetIntegerv(pname, null, pointer(params), length);

            // Workaround for Gerbera bug, CR 6401385
            if (pname == GL_CULL_FACE) {
                params.put(params.position(), cullFaceMode);
            }
        }
    
public synchronized java.lang.StringglGetString(int name)

        checkThread();
        qflush();

        grabContext();
        String s = _glGetString(name);
        return s;
    
public synchronized voidglHint(int target, int mode)

        checkThread();
        q(CMD_HINT, 2);
        q(target);
        q(mode);
    
public synchronized booleanglIsBuffer(int buffer)

        checkThread();
        qflush();

        grabContext();
        boolean retval = GL_TRUE == _glIsBuffer(buffer);
        return retval;
    
public synchronized booleanglIsEnabled(int cap)

        checkThread();
        qflush();

        grabContext();
        boolean retval = GL_TRUE == _glIsEnabled(cap);
        return retval;
    
public synchronized booleanglIsTexture(int texture)

        checkThread();
        qflush();

        grabContext();
        boolean retval = false;

        // Woraround for Gerbera bug, see CR 6401677
        if (texture != 0) {
            retval = GL_TRUE == _glIsTexture(texture);
        }
        return retval;
    
public synchronized voidglLightModelf(int pname, float param)

        checkThread();
        q(CMD_LIGHT_MODELF, 2);
        q(pname);
        q(param);
    
public synchronized voidglLightModelfv(int pname, float[] params, int offset)

        checkThread();
        int length = GLConfiguration.glLightModelNumParams(pname);
        checkLength(params, length, offset);

        IglLightModelfv(pname, params, offset);
    
public synchronized voidglLightModelfv(int pname, java.nio.FloatBuffer params)

        checkThread();
        int length = GLConfiguration.glLightModelNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglLightModelfv(pname, params.array(), offset(params));
            return;
        }

        q(CMD_LIGHT_MODELFB, 2);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglLightModelx(int pname, int param)

        checkThread();
        q(CMD_LIGHT_MODELX, 2);
        q(pname);
        q(param);
    
public synchronized voidglLightModelxv(int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glLightModelNumParams(pname);
        checkLength(params, length, offset);

        IglLightModelxv(pname, params, offset);
    
public synchronized voidglLightModelxv(int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glLightModelNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglLightModelxv(pname, params.array(), offset(params));
            return;
        }

        q(CMD_LIGHT_MODELXB, 2);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglLightf(int light, int pname, float param)

        checkThread();
        q(CMD_LIGHTF, 3);
        q(light);
        q(pname);
        q(param);
    
public synchronized voidglLightfv(int light, int pname, float[] params, int offset)

        checkThread();
        int length = GLConfiguration.glLightNumParams(pname);
        checkLength(params, length, offset);
    
        IglLightfv(light, pname, params, offset);
    
public synchronized voidglLightfv(int light, int pname, java.nio.FloatBuffer params)

        checkThread();
        int length = GLConfiguration.glLightNumParams(pname);
        checkLength(params, length);
    
        if (!params.isDirect()) {
            IglLightfv(light, pname, params.array(), offset(params));
            return;
        }

        q(CMD_LIGHTFB, 3);
        q(light);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglLightx(int light, int pname, int param)

        checkThread();
        q(CMD_LIGHTX, 3);
        q(light);
        q(pname);
        q(param);
    
public synchronized voidglLightxv(int light, int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glLightNumParams(pname);
        checkLength(params, length, offset);
    
        IglLightxv(light, pname, params, offset);
    
public synchronized voidglLightxv(int light, int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glLightNumParams(pname);
        checkLength(params, length);
    
        if (!params.isDirect()) {
            IglLightxv(light, pname, params.array(), offset(params));
            return;
        }

        q(CMD_LIGHTXB, 3);
        q(light);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglLineWidth(float width)

        checkThread();
        q(CMD_LINE_WIDTH, 1);
        q(width);
    
public synchronized voidglLineWidthx(int width)

        checkThread();
        q(CMD_LINE_WIDTHX, 1);
        q(width);
    
public synchronized voidglLoadIdentity()

        checkThread();
        q(CMD_LOAD_IDENTITY, 0);
    
public synchronized voidglLoadMatrixf(float[] m, int offset)

        checkThread();
        checkLength(m, 16, offset);

        IglLoadMatrixf(m, offset);
    
public synchronized voidglLoadMatrixf(java.nio.FloatBuffer m)

        checkThread();
        checkLength(m, 16);

        if (!m.isDirect()) {
            IglLoadMatrixf(m.array(), offset(m));
            return;
        }
        
        q(CMD_LOAD_MATRIXFB, 1);
        q(m);
        
        qflush();
    
public synchronized voidglLoadMatrixx(int[] m, int offset)

        checkThread();
        checkLength(m, 16, offset);

        IglLoadMatrixx(m, offset);
    
public synchronized voidglLoadMatrixx(java.nio.IntBuffer m)

        checkThread();
        checkLength(m, 16);

        if (!m.isDirect()) {
            IglLoadMatrixx(m.array(), offset(m));
            return;
        }

        q(CMD_LOAD_MATRIXXB, 1);
        q(m);
        
        qflush();
    
public synchronized voidglLogicOp(int opcode)

        checkThread();
        q(CMD_LOGIC_OP, 1);
        q(opcode);
    
public synchronized voidglMaterialf(int face, int pname, float param)

        checkThread();
        q(CMD_MATERIALF, 3);
        q(face);
        q(pname);
        q(param);
    
public synchronized voidglMaterialfv(int face, int pname, float[] params, int offset)

        checkThread();
        int length = GLConfiguration.glMaterialNumParams(pname);
        checkLength(params, length, offset);

        IglMaterialfv(face, pname, params, offset);
    
public synchronized voidglMaterialfv(int face, int pname, java.nio.FloatBuffer params)

        checkThread();
        int length = GLConfiguration.glMaterialNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglMaterialfv(face, pname, params.array(), offset(params));
            return;
        }

        q(CMD_MATERIALFB, 3);
        q(face);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglMaterialx(int face, int pname, int param)

        checkThread();
        q(CMD_MATERIALX, 3);
        q(face);
        q(pname);
        q(param);
    
public synchronized voidglMaterialxv(int face, int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glMaterialNumParams(pname);
        checkLength(params, length, offset);

        IglMaterialxv(face, pname, params, offset);
    
public synchronized voidglMaterialxv(int face, int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glMaterialNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglMaterialxv(face, pname, params.array(), offset(params));
            return;
        }

        q(CMD_MATERIALXB, 3);
        q(face);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglMatrixMode(int mode)

        checkThread();
        q(CMD_MATRIX_MODE, 1);
        q(mode);
    
public synchronized voidglMultMatrixf(float[] m, int offset)

        checkThread();
        checkLength(m, 16, offset);

        IglMultMatrixf(m, offset);
    
public synchronized voidglMultMatrixf(java.nio.FloatBuffer m)

        checkThread();
        checkLength(m, 16);

        if (!m.isDirect()) {
            IglMultMatrixf(m.array(), offset(m));
            return;
        }

        q(CMD_MULT_MATRIXFB, 1);
        q(m);
        
        qflush();
    
public synchronized voidglMultMatrixx(int[] m, int offset)

        checkThread();
        checkLength(m, 16, offset);

        IglMultMatrixx(m, offset);
    
public synchronized voidglMultMatrixx(java.nio.IntBuffer m)

        checkThread();
        checkLength(m, 16);

        if (!m.isDirect()) {
            IglMultMatrixx(m.array(), offset(m));
            return;
        }
        
        q(CMD_MULT_MATRIXXB, 1);
        q(m);
        
        qflush();
    
public synchronized voidglMultiTexCoord4f(int target, float s, float t, float r, float q)

        checkThread();
        q(CMD_MULTI_TEXT_COORD4F, 5);
        q(target);
        q(s);
        q(t);
        q(r);
        q(q);
    
public synchronized voidglMultiTexCoord4x(int target, int s, int t, int r, int q)

        checkThread();
        q(CMD_MULTI_TEXT_COORD4X, 5);
        q(target);
        q(s);
        q(t);
        q(r);
        q(q);
    
public synchronized voidglNormal3f(float nx, float ny, float nz)

        checkThread();
        q(CMD_NORMAL3F, 3);
        q(nx);
        q(ny);
        q(nz);
    
public synchronized voidglNormal3x(int nx, int ny, int nz)

        checkThread();
        q(CMD_NORMAL3X, 3);
        q(nx);
        q(ny);
        q(nz);
    
public synchronized voidglNormalPointer(int type, int stride, java.nio.Buffer pointer)

        checkThread();
        if (VBOArrayBufferBound != 0) {
            throw new IllegalStateException("glNormalPointer:" +
                                            Errors.VBO_ARRAY_BUFFER_BOUND);
        }
        if (!isDirect(pointer)) {
            throwIAE(Errors.GL_NOT_DIRECT);
        }

        if ((type == GL_BYTE ||
             type == GL_SHORT ||
             type == GL_FIXED ||
             type == GL_FLOAT) &&
            (stride >= 0)) {
            BufferManager.releaseBuffer(pointerBuffer[NORMAL_POINTER]);
            BufferManager.useBuffer(pointer);

            pointerBuffer[NORMAL_POINTER] = pointer;
            pointerSize[NORMAL_POINTER] = 3;
            pointerType[NORMAL_POINTER] = type;
            pointerStride[NORMAL_POINTER] = stride;
            int nbytes = bufferTypeSize(pointer);
            pointerRemaining[NORMAL_POINTER] = pointer.remaining()*nbytes;
            pointerOffset[NORMAL_POINTER] = 0;
        }

        q(CMD_NORMAL_POINTER, 3);
        q(type);
        q(stride);
        q(pointer);

        qflush();
    
public synchronized voidglOrthof(float left, float right, float bottom, float top, float zNear, float zFar)

        checkThread();
        q(CMD_ORTHOF, 6);
        q(left);
        q(right);
        q(bottom);
        q(top);
        q(zNear);
        q(zFar);
    
public synchronized voidglOrthox(int left, int right, int bottom, int top, int zNear, int zFar)

        checkThread();
        q(CMD_ORTHOX, 6);
        q(left);
        q(right);
        q(bottom);
        q(top);
        q(zNear);
        q(zFar);
    
public synchronized voidglPixelStorei(int pname, int param)

        checkThread();
        q(CMD_PIXEL_STOREI, 3);
        q(pname);
        q(param);

        /* Only update local copy if we know command will succeed */
        if (param == 1 || param == 2 || param == 4 || param == 8) {
            if (pname == GL_PACK_ALIGNMENT) {
                pixelStorePackAlignment = param;
            } else if (pname == GL_UNPACK_ALIGNMENT) {
                pixelStoreUnpackAlignment = param;
            }
        }
    
public synchronized voidglPointParameterf(int pname, float param)

        checkThread();
        q(CMD_POINT_PARAMETERF, 2);
        q(pname);
        q(param);
    
public synchronized voidglPointParameterfv(int pname, float[] params, int offset)

        checkThread();
        int length = GLConfiguration.glPointParameterNumParams(pname);
        checkLength(params, length, offset);

        IglPointParameterfv(pname, params, offset);
    
public synchronized voidglPointParameterfv(int pname, java.nio.FloatBuffer params)

        checkThread();
        int length = GLConfiguration.glPointParameterNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglPointParameterfv(pname, params.array(), offset(params));
            return;
        }

        q(CMD_POINT_PARAMETERFB, 2);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglPointParameterx(int pname, int param)

        checkThread();
        q(CMD_POINT_PARAMETERX, 2);
        q(pname);
        q(param);
    
public synchronized voidglPointParameterxv(int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glPointParameterNumParams(pname);
        checkLength(params, length, offset);

        IglPointParameterxv(pname, params, offset);
    
public synchronized voidglPointParameterxv(int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glPointParameterNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglPointParameterxv(pname, params.array(), offset(params));
            return;
        }

        q(CMD_POINT_PARAMETERXB, 2);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglPointSize(float size)

        checkThread();
        q(CMD_POINT_SIZE, 1);
        q(size);
    
public synchronized voidglPointSizex(int size)

        checkThread();
        q(CMD_POINT_SIZEX, 1);
        q(size);
    
public synchronized voidglPolygonOffset(float factor, float units)

        checkThread();
        q(CMD_POLYGON_OFFSET, 2);
        q(factor);
        q(units);
    
public synchronized voidglPolygonOffsetx(int factor, int units)

        checkThread();
        q(CMD_POLYGON_OFFSETX, 2);
        q(factor);
        q(units);
    
public synchronized voidglPopMatrix()

        checkThread();
        q(CMD_POP_MATRIX, 0);
    
public synchronized voidglPushMatrix()

        checkThread();
        q(CMD_PUSH_MATRIX, 0);
    
public synchronized intglQueryMatrixxOES(int[] mantissa, int mantissaOffset, int[] exponent, int exponentOffset)

        checkThread();
        if (!GLConfiguration.supports_OES_query_matrix) {
            throw new UnsupportedOperationException(
                                           Errors.GL_QUERY_MATRIX_UNSUPPORTED);
        }
        checkLength(mantissa, 16, mantissaOffset);
        checkLength(exponent, 16, exponentOffset);

        qflush();

        grabContext();
        int retval = _glQueryMatrixxOES(mantissa, mantissaOffset,
                                        exponent, exponentOffset);
        return retval;
    
public synchronized voidglReadPixels(int x, int y, int width, int height, int format, int type, java.nio.Buffer pixels)

        checkThread();
        qflush();

        if (pixels == null) {
            throwIAE(Errors.GL_PIXELS_NULL);
        }
        int remaining = pixels.remaining()*bufferTypeSize(pixels);
        int needed = rasterBytes(width, height, format, type,
                                 pixelStorePackAlignment);
        if (needed > remaining) {
            throwIAE(Errors.NOT_ENOUGH_ROOM);
        }

        if (isDirect(pixels)) {
            grabContext();
            _glReadPixelsPtr(x, y, width, height, format,
                             type, pointer(pixels));
        } else {
            if (pixels instanceof ByteBuffer) {
                ByteBuffer p = (ByteBuffer)pixels;
                grabContext();
                _glReadPixelsByte(x, y, width, height, format, type,
                                  p.array(), offset(p));
            } else if (pixels instanceof IntBuffer) {
                IntBuffer p = (IntBuffer)pixels;
                grabContext();
                _glReadPixelsInt(x, y, width, height, format, type,
                                 p.array(), offset(p));
            } else {
                throwIAE(Errors.GL_UNKNOWN_BUFFER);
            }
        }
    
public synchronized voidglRotatef(float angle, float x, float y, float z)

        checkThread();
        q(CMD_ROTATEF, 4);
        q(angle);
        q(x);
        q(y);
        q(z);
    
public synchronized voidglRotatex(int angle, int x, int y, int z)

        checkThread();
        q(CMD_ROTATEX, 4);
        q(angle);
        q(x);
        q(y);
        q(z);
    
public synchronized voidglSampleCoverage(float value, boolean invert)

        checkThread();
        q(CMD_SAMPLE_COVERAGE, 2);
        q(value);
        q(invert ? 1 : 0);
    
public synchronized voidglSampleCoveragex(int value, boolean invert)

        checkThread();
        q(CMD_SAMPLE_COVERAGEX, 2);
        q(value);
        q(invert ? 1 : 0);
    
public synchronized voidglScalef(float x, float y, float z)

        checkThread();
        q(CMD_SCALEF, 3);
        q(x);
        q(y);
        q(z);
    
public synchronized voidglScalex(int x, int y, int z)

        checkThread();
        q(CMD_SCALEX, 3);
        q(x);
        q(y);
        q(z);
    
public synchronized voidglScissor(int x, int y, int width, int height)

        checkThread();
        q(CMD_SCISSOR, 4);
        q(x);
        q(y);
        q(width);
        q(height);
    
public synchronized voidglShadeModel(int mode)

        checkThread();
        q(CMD_SHADE_MODEL, 1);
        q(mode);
    
public synchronized voidglStencilFunc(int func, int ref, int mask)

        checkThread();
        q(CMD_STENCIL_FUNC, 3);
        q(func);
        q(ref);
        q(mask);
    
public synchronized voidglStencilMask(int mask)

        checkThread();
        q(CMD_STENCIL_MASK, 2);
        q(mask);
    
public synchronized voidglStencilOp(int fail, int zfail, int zpass)

        checkThread();
        q(CMD_STENCIL_OP, 3);
        q(fail);
        q(zfail);
        q(zpass);
    
public synchronized voidglTexCoordPointer(int size, int type, int stride, java.nio.Buffer pointer)

        checkThread();
        if (VBOArrayBufferBound != 0) {
            throw new IllegalStateException("glTexCoordPointer:" +
                                            Errors.VBO_ARRAY_BUFFER_BOUND);
        }
        if (!isDirect(pointer)) {
            throwIAE(Errors.GL_NOT_DIRECT);
        }

        if ((size >= 2 && size <= 4) && 
            (type == GL_BYTE ||
             type == GL_SHORT ||
             type == GL_FIXED ||
             type == GL_FLOAT) &&
            (stride >= 0)) {
            BufferManager.releaseBuffer(pointerBuffer[TEX_COORD_POINTER]);
            BufferManager.useBuffer(pointer);

            pointerBuffer[TEX_COORD_POINTER] = pointer;
            pointerSize[TEX_COORD_POINTER] = size;
            pointerType[TEX_COORD_POINTER] = type;
            pointerStride[TEX_COORD_POINTER] = stride;
            int nbytes = bufferTypeSize(pointer);
            pointerRemaining[TEX_COORD_POINTER] = pointer.remaining()*nbytes;
            pointerOffset[TEX_COORD_POINTER] = 0;
        }

        q(CMD_TEX_COORD_POINTER, 4);
        q(size);
        q(type);
        q(stride);
        q(pointer);
        
        qflush();
    
public synchronized voidglTexEnvf(int target, int pname, float param)

        checkThread();
        q(CMD_TEX_ENVF, 3);
        q(target);
        q(pname);
        q(param);
    
public synchronized voidglTexEnvfv(int target, int pname, float[] params, int offset)

        checkThread();
        int length = GLConfiguration.glTexEnvNumParams(pname);
        checkLength(params, length, offset);

        IglTexEnvfv(target, pname, params, offset);
    
public synchronized voidglTexEnvfv(int target, int pname, java.nio.FloatBuffer params)

        checkThread();
        int length = GLConfiguration.glTexEnvNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglTexEnvfv(target, pname, params.array(), offset(params));
            return;
        }

        q(CMD_TEX_ENVFB, 3);
        q(target);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglTexEnvi(int target, int pname, int param)

        checkThread();
        q(CMD_TEX_ENVI, 3);
        q(target);
        q(pname);
        q(param);
    
public synchronized voidglTexEnviv(int target, int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glTexEnvNumParams(pname);
        checkLength(params, length, offset);
    
        IglTexEnviv(target, pname, params, offset);
    
public synchronized voidglTexEnviv(int target, int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glTexEnvNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglTexEnviv(target, pname, params.array(), offset(params));
            return;
        }

        q(CMD_TEX_ENVIB, 3);
        q(target);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglTexEnvx(int target, int pname, int param)

        checkThread();
        q(CMD_TEX_ENVX, 3);
        q(target);
        q(pname);
        q(param);
    
public synchronized voidglTexEnvxv(int target, int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glTexEnvNumParams(pname);
        checkLength(params, length, offset);

        IglTexEnvxv(target, pname, params, offset);
    
public synchronized voidglTexEnvxv(int target, int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glTexEnvNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglTexEnvxv(target, pname, params.array(), offset(params));
            return;
        }

        q(CMD_TEX_ENVXB, 3);
        q(target);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, java.nio.Buffer pixels)

        checkThread();
        boolean isReadOnly = false;
        if (!isDirect(pixels)) {
            pixels = createDirectCopy(pixels);
            isReadOnly = true;
        }

        int remaining = pixels.remaining()*bufferTypeSize(pixels);
        int needed = rasterBytes(width, height, format, type,
                                 pixelStoreUnpackAlignment);
        if (needed > remaining) {
            throwIAE(Errors.NOT_ENOUGH_ROOM);
        }

        q(CMD_TEX_IMAGE_2D, 9);
        q(target);
        q(level);
        q(internalformat);
        q(width);
        q(height);
        q(border);
        q(format);
        q(type);
        q(pixels);
    
        if (!isReadOnly) {
            qflush();
        }
    
public synchronized voidglTexParameterf(int target, int pname, float param)

        checkThread();
        q(CMD_TEX_PARAMETERF, 3);
        q(target);
        q(pname);
        q(param);
    
public synchronized voidglTexParameterfv(int target, int pname, float[] params, int offset)

        checkThread();
        int length = GLConfiguration.glTexParameterNumParams(pname);
        checkLength(params, length, offset);

        IglTexParameterfv(target, pname, params, offset);
    
public synchronized voidglTexParameterfv(int target, int pname, java.nio.FloatBuffer params)

        checkThread();
        int length = GLConfiguration.glTexParameterNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglTexParameterfv(target, pname, params.array(), offset(params));
            return;
        }

        q(CMD_TEX_PARAMETERFB, 3);
        q(target);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglTexParameteri(int target, int pname, int param)

        checkThread();
        q(CMD_TEX_PARAMETERI, 3);
        q(target);
        q(pname);
        q(param);
    
public synchronized voidglTexParameteriv(int target, int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glTexParameterNumParams(pname);
        checkLength(params, length, offset);

        IglTexParameteriv(target, pname, params, offset);
    
public synchronized voidglTexParameteriv(int target, int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glTexParameterNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglTexParameteriv(target, pname, params.array(), offset(params));
            return;
        }

        q(CMD_TEX_PARAMETERIB, 3);
        q(target);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglTexParameterx(int target, int pname, int param)

        checkThread();
        q(CMD_TEX_PARAMETERX, 3);
        q(target);
        q(pname);
        q(param);
    
public synchronized voidglTexParameterxv(int target, int pname, int[] params, int offset)

        checkThread();
        int length = GLConfiguration.glTexParameterNumParams(pname);
        checkLength(params, length, offset);

        IglTexParameterxv(target, pname, params, offset);
    
public synchronized voidglTexParameterxv(int target, int pname, java.nio.IntBuffer params)

        checkThread();
        int length = GLConfiguration.glTexParameterNumParams(pname);
        checkLength(params, length);

        if (!params.isDirect()) {
            IglTexParameterxv(target, pname, params.array(), offset(params));
            return;
        }

        q(CMD_TEX_PARAMETERXB, 3);
        q(target);
        q(pname);
        q(params);

        qflush();
    
public synchronized voidglTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, java.nio.Buffer pixels)

        checkThread();
        if ((pixels instanceof ShortBuffer) ||
            (pixels instanceof IntBuffer)) {
            throwIAE(Errors.GL_PIXELS_NOT_SHORT_OR_INT);
        }

        boolean isReadOnly = false;
        if (!isDirect(pixels)) {
            pixels = createDirectCopy(pixels);
            isReadOnly = true;
        }

        int remaining = pixels.remaining()*bufferTypeSize(pixels);
        int needed = rasterBytes(width, height, format, type,
                                 pixelStoreUnpackAlignment);
        if (needed > remaining) {
            throwIAE(Errors.NOT_ENOUGH_ROOM);
        }

        q(CMD_TEX_SUB_IMAGE_2D, 9);
        q(target);
        q(level);
        q(xoffset);
        q(yoffset);
        q(width);
        q(height);
        q(format);
        q(type);
        q(pixels);
    
        if (!isReadOnly) {
            qflush();
        }
    
public synchronized voidglTranslatef(float x, float y, float z)

        checkThread();
        q(CMD_TRANSLATEF, 3);
        q(x);
        q(y);
        q(z);
    
public synchronized voidglTranslatex(int x, int y, int z)

        checkThread();
        q(CMD_TRANSLATEX, 3);
        q(x);
        q(y);
        q(z);
    
public synchronized voidglVertexPointer(int size, int type, int stride, java.nio.Buffer pointer)

        checkThread();
        if (VBOArrayBufferBound != 0) {
            throw new IllegalStateException("glVertexPointer:" +
                                            Errors.VBO_ARRAY_BUFFER_BOUND);
        }
        if (!isDirect(pointer)) {
            throwIAE(Errors.GL_NOT_DIRECT);
        }

        // Only record details if this is a legal operation
        if ((size >= 2 && size <= 4) && 
            (type == GL_BYTE ||
             type == GL_SHORT ||
             type == GL_FIXED ||
             type == GL_FLOAT) &&
            (stride >= 0)) {
            BufferManager.releaseBuffer(pointerBuffer[VERTEX_POINTER]);
            BufferManager.useBuffer(pointer);

            pointerBuffer[VERTEX_POINTER] = pointer;
            pointerSize[VERTEX_POINTER] = size;
            pointerType[VERTEX_POINTER] = type;
            pointerStride[VERTEX_POINTER] = stride;
            int nbytes = bufferTypeSize(pointer);
            pointerRemaining[VERTEX_POINTER] = pointer.remaining()*nbytes;
            pointerOffset[VERTEX_POINTER] = 0;
        }

        q(CMD_VERTEX_POINTER, 4);
        q(size);
        q(type);
        q(stride);
        q(pointer);

        qflush();
    
public synchronized voidglViewport(int x, int y, int width, int height)

        checkThread();
        q(CMD_VIEWPORT, 4);
        q(x);
        q(y);
        q(width);
        q(height);
    
public static voidgrabContext()
Set the context associated with the current Java thread as the native context. This is only necessary if we are on a single-threaded VM and the context is not already current.


                                         
        
        if (!GLConfiguration.singleThreaded) {
            return;
        }

        // Locate the desired context for this Java thread
        Thread currentThread = Thread.currentThread();
        EGLContext newContext =
                (EGLContext)contextsByThread.get(currentThread); 
        if (newContext == GL10Impl.currentContext) {
            return;
        }

        if (newContext != null) {
            EGLDisplay display = ((ContextAccess) newContext).getDisplay();

            EGLSurface draw = ((ContextAccess) newContext).getDrawSurface();

            EGLSurface read = ((ContextAccess) newContext).getReadSurface();

            egl.eglMakeCurrent(display, draw, read, newContext);

            GL10Impl.currentContext = newContext;
        }
    
booleanisDirect(java.nio.Buffer buf)

        if (buf instanceof ByteBuffer) {
            return ((ByteBuffer)buf).isDirect();
        } else if (buf instanceof ShortBuffer) {
            return ((ShortBuffer)buf).isDirect();
        } else if (buf instanceof IntBuffer) {
            return ((IntBuffer)buf).isDirect();
        } else if (buf instanceof FloatBuffer) {
            return ((FloatBuffer)buf).isDirect();
        } else {
            throw new IllegalArgumentException(Errors.GL_UNKNOWN_BUFFER);
        }
    
private java.lang.Integerkey(int target)

        if (target == GL11.GL_ARRAY_BUFFER) {
            return new Integer(VBOArrayBufferBound);
        } else if (target == GL11.GL_ELEMENT_ARRAY_BUFFER) {
            return new Integer(VBOElementArrayBufferBound);
        } else {
            throw new IllegalArgumentException("target = " + target);
        }
    
intoffset(java.nio.ByteBuffer buffer)

        return buffer.arrayOffset() + buffer.position();
    
intoffset(java.nio.ShortBuffer buffer)

        return buffer.arrayOffset() + buffer.position();
    
intoffset(java.nio.IntBuffer buffer)

        return buffer.arrayOffset() + buffer.position();
    
intoffset(java.nio.FloatBuffer buffer)

        return buffer.arrayOffset() + buffer.position();
    
intpointer(java.nio.Buffer buffer)

        int offset = buffer.position();
        int nativeAddress = _getNativeAddress(buffer, offset);

        return nativeAddress;
    
voidq(int cmd, int count)

        if (index + count + 1 >= GLConfiguration.COMMAND_QUEUE_SIZE) {
            qflush();
        }
        if (debugQueue) {
            System.out.println("Queueing command " + 
                               commandStrings[cmd] + " with " +
                               count + " args from thread " +
                               Thread.currentThread());
        }
        queue[index++] = cmd;
        commandsLeft = count;
    
voidq(int i)

        queue[index++] = i;
    
        if (debugQueue) {
            System.out.println("Queueing integer " + i +
                               " from thread " +
                               Thread.currentThread());
        }

        if (GLConfiguration.flushQueueAfterEachCommand &&
            (--commandsLeft == 0)) {
            if (debugQueue) {
                System.out.println("Last arg for command, flushing");
            }
            qflush();
        }
    
voidq(float f)

        int i = floatToIntBits(f);
        queue[index++] = i;

        if (debugQueue) {
            System.out.println("Queueing float " + f +
                               " from thread " +
                               Thread.currentThread());
        }

        if (GLConfiguration.flushQueueAfterEachCommand &&
            (--commandsLeft == 0)) {
            if (debugQueue) {
                System.out.println("Last arg for command, flushing");
            }
            qflush();
        }
    
voidq(java.nio.Buffer buf)

        q(pointer(buf));

        if (debugQueue) {
            System.out.println("Queueing buffer pointer " + pointer(buf) +
                               " from thread " +
                               Thread.currentThread());
        }

        if (GLConfiguration.flushQueueAfterEachCommand &&
            (--commandsLeft == 0)) {
            if (debugQueue) {
                System.out.println("Last arg for command, flushing");
            }
            qflush();
        }
    
public voidqflush()

        if (debugQueue) {
            System.out.println("Flushing the queue, index = " + index);
        }
        grabContext();
        _execute(queue, index);
        index = 0;

        // Ensure GL does not starve other threads
        Thread.yield();
    
private intrasterBytes(int width, int height, int format, int type, int pad)

        int bytesPerPixel = GLConfiguration.formatChannels(format)*
            GLConfiguration.sizeOfType(type);
        int rowWidth = width*bytesPerPixel;
        // stride = rowWidth rounded up to a multiple of 'pad' bytes
        int stride = (rowWidth + pad - 1) & ~(pad - 1);
    
        return stride*(height - 1) + rowWidth;
    
voidremoveBuffer(int buffer)

        if (DEBUG_MEM) {
            System.out.println("removeBuffer " + buffer);
        }
        if (buffer != 0) {
            Integer key = new Integer(buffer);
            VBOBuffersTable.remove(key);
            VBOBufferSizeTable.remove(key);
            VBOBufferIndicesTable.remove(key);
        }
    
voidsetBufferSize(int target, int size)

        if (DEBUG_MEM) {
            System.out.println("setBufferSize " + target + " " + size);
        }

        Integer key = key(target);
        if (target == GL11.GL_ELEMENT_ARRAY_BUFFER) {
            if (DEBUG_MEM) {
                System.out.print("setBufferSize: allocating " + size);
            }            
            VBOBufferIndicesTable.put(key, new byte[size]);
            if (DEBUG_MEM) {
                System.out.println(": done");
            }            
        }
        VBOBufferSizeTable.put(key, new Integer(size));
    
voidthrowIAE(java.lang.String message)


       
        throw new IllegalArgumentException(message);