0001: /*
0002: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
0003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
0004: *
0005: * This program is free software; you can redistribute it and/or
0006: * modify it under the terms of the GNU General Public License version
0007: * 2 only, as published by the Free Software Foundation.
0008: *
0009: * This program is distributed in the hope that it will be useful, but
0010: * WITHOUT ANY WARRANTY; without even the implied warranty of
0011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0012: * General Public License version 2 for more details (a copy is
0013: * included at /legal/license.txt).
0014: *
0015: * You should have received a copy of the GNU General Public License
0016: * version 2 along with this work; if not, write to the Free Software
0017: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0018: * 02110-1301 USA
0019: *
0020: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0021: * Clara, CA 95054 or visit www.sun.com if you need additional
0022: * information or have any questions.
0023: */
0024:
0025: package com.sun.jsr239;
0026:
0027: import javax.microedition.khronos.egl.*;
0028: import javax.microedition.khronos.opengles.*;
0029: import java.nio.*;
0030:
0031: public class GL11Impl extends GL10Impl implements GL11, GL11Ext,
0032: GL11ExtensionPack {
0033:
0034: /**
0035: * Utility for common error checking.
0036: *
0037: * @exception <code>UnsupportedOperationException</code> if the
0038: * underlying engine does not support OpenGL ES 1.1.
0039: */
0040: void check_1_1() {
0041: if (!GLConfiguration.supportsGL11) {
0042: throw new UnsupportedOperationException(
0043: Errors.GL_GL11_UNSUPPORTED);
0044: }
0045: }
0046:
0047: // Begin GL methods
0048:
0049: // VBO Methods
0050:
0051: public synchronized void glGenBuffers(int n, int[] buffers,
0052: int offset) {
0053: checkThread();
0054: check_1_1();
0055: checkLength(buffers, n, offset);
0056:
0057: qflush();
0058: IglGenBuffers(n, buffers, offset);
0059: }
0060:
0061: public synchronized void glGenBuffers(int n, IntBuffer buffers) {
0062: checkThread();
0063: check_1_1();
0064: checkLength(buffers, n);
0065:
0066: qflush();
0067: if (isDirect(buffers)) {
0068: int[] b = new int[n];
0069:
0070: int pos = buffers.position();
0071:
0072: // Copy data out in case we don't write everything
0073: buffers.get(b);
0074:
0075: IglGenBuffers(n, b, 0);
0076:
0077: // Write new data to buffer
0078: buffers.position(pos);
0079: buffers.put(b);
0080:
0081: // Restore buffer position
0082: buffers.position(pos);
0083: } else {
0084: IglGenBuffers(n, buffers.array(), offset(buffers));
0085: }
0086: }
0087:
0088: void IglGenBuffers(int n, int[] buffers, int offset) {
0089: grabContext();
0090: _glGenBuffers(n, buffers, offset);
0091:
0092: // Need revisit - what if out of memory?
0093: // Then buffers not really created :-(
0094:
0095: // Record valid buffer IDs
0096: for (int i = 0; i < n; i++) {
0097: addBuffer(buffers[offset + i]);
0098: }
0099: }
0100:
0101: public synchronized void glDeleteBuffers(int n, int[] buffers,
0102: int offset) {
0103: checkThread();
0104: check_1_1();
0105: checkLength(buffers, n, offset);
0106:
0107: IglDeleteBuffers(n, buffers, offset);
0108: }
0109:
0110: public synchronized void glDeleteBuffers(int n, IntBuffer buffers) {
0111: checkThread();
0112: check_1_1();
0113: checkLength(buffers, n);
0114:
0115: if (buffers.isDirect()) {
0116: int[] b = new int[n];
0117: buffers.get(b, 0, n);
0118: IglDeleteBuffers(n, b, 0);
0119: } else {
0120: IglDeleteBuffers(n, buffers.array(), offset(buffers));
0121: }
0122: }
0123:
0124: void IglDeleteBuffers(int n, int[] buffers, int offset) {
0125: q(CMD_DELETE_BUFFERS, n + 1);
0126: q(n);
0127: for (int i = 0; i < n; i++) {
0128: q(buffers[offset + i]);
0129: }
0130: qflush();
0131:
0132: // Remove deleted buffer IDs
0133: for (int i = 0; i < n; i++) {
0134: removeBuffer(buffers[offset + i]);
0135: }
0136: }
0137:
0138: public synchronized void glBindBuffer(int target, int buffer) {
0139: checkThread();
0140: check_1_1();
0141:
0142: q(CMD_BIND_BUFFER, 2);
0143: q(target);
0144: q(buffer);
0145:
0146: qflush();
0147:
0148: if (target == GL_ARRAY_BUFFER) {
0149: VBOArrayBufferBound = buffer;
0150: } else if (target == GL_ELEMENT_ARRAY_BUFFER) {
0151: VBOElementArrayBufferBound = buffer;
0152: }
0153: }
0154:
0155: public synchronized void glBufferData(int target, int size,
0156: Buffer data, int usage) {
0157: checkThread();
0158: check_1_1();
0159: if (data != null && !isDirect(data)) {
0160: throw new IllegalArgumentException(Errors.GL_NOT_DIRECT);
0161: }
0162:
0163: if ((target == GL_ARRAY_BUFFER) && (VBOArrayBufferBound != 0)) {
0164: setBufferSize(target, size);
0165: } else if ((target == GL_ELEMENT_ARRAY_BUFFER)
0166: && (VBOElementArrayBufferBound != 0)) {
0167: setBufferSize(target, size);
0168: bufferIndexData(data, 0, size, true);
0169: }
0170:
0171: q(CMD_BUFFER_DATA, 4);
0172: q(target);
0173: q(size);
0174: q(data == null ? 0 : pointer(data));
0175: q(usage);
0176:
0177: qflush();
0178: }
0179:
0180: public synchronized void glBufferSubData(int target, int offset,
0181: int size, Buffer data) {
0182: checkThread();
0183: check_1_1();
0184: if (!isDirect(data)) {
0185: throw new IllegalArgumentException(Errors.GL_NOT_DIRECT);
0186: }
0187:
0188: if ((target == GL_ELEMENT_ARRAY_BUFFER)
0189: && (VBOElementArrayBufferBound != 0)) {
0190: bufferIndexData(data, offset, size, false);
0191: }
0192:
0193: q(CMD_BUFFER_SUB_DATA, 4);
0194: q(target);
0195: q(offset);
0196: q(size);
0197: q(data);
0198:
0199: qflush();
0200: }
0201:
0202: public synchronized void glGetBufferParameteriv(int target,
0203: int pname, int[] params, int offset) {
0204: checkThread();
0205: check_1_1();
0206: int length = GLConfiguration
0207: .glGetBufferParametervNumParams(pname);
0208: checkLength(params, length, offset);
0209:
0210: qflush();
0211: IglGetBufferParameteriv(target, pname, params, offset, length);
0212: }
0213:
0214: public synchronized void glGetBufferParameteriv(int target,
0215: int pname, IntBuffer params) {
0216: checkThread();
0217: check_1_1();
0218: int length = GLConfiguration
0219: .glGetBufferParametervNumParams(pname);
0220: checkLength(params, length);
0221:
0222: qflush();
0223: if (!params.isDirect()) {
0224: IglGetBufferParameteriv(target, pname, params.array(),
0225: offset(params), length);
0226: } else {
0227: IglGetBufferParameteriv(target, pname, null,
0228: pointer(params), length);
0229: }
0230: }
0231:
0232: void IglGetBufferParameteriv(int target, int pname, int[] params,
0233: int offset, int length) {
0234: grabContext();
0235: _glGetBufferParameteriv(target, pname, params, offset, length);
0236: }
0237:
0238: public synchronized void glColorPointer(int size, int type,
0239: int stride, int offset) {
0240: checkThread();
0241: if (VBOArrayBufferBound == 0) {
0242: throw new IllegalStateException("glColorPointer:"
0243: + Errors.VBO_ARRAY_BUFFER_UNBOUND);
0244: }
0245:
0246: int bufferSize = getBufferSize(GL11.GL_ARRAY_BUFFER);
0247: if (offset < 0 || offset >= bufferSize) {
0248: throw new ArrayIndexOutOfBoundsException(
0249: Errors.VBO_OFFSET_OOB);
0250: }
0251:
0252: // Only record details if this is a legal operation
0253: if ((size == 4)
0254: && (type == GL_UNSIGNED_BYTE || type == GL_FIXED || type == GL_FLOAT)
0255: && (stride >= 0)) {
0256: BufferManager.releaseBuffer(pointerBuffer[COLOR_POINTER]);
0257:
0258: pointerBuffer[COLOR_POINTER] = null;
0259: pointerSize[COLOR_POINTER] = size;
0260: pointerType[COLOR_POINTER] = type;
0261: pointerStride[COLOR_POINTER] = stride;
0262: pointerRemaining[COLOR_POINTER] = -1;
0263: pointerOffset[COLOR_POINTER] = offset;
0264: }
0265:
0266: q(CMD_COLOR_POINTER_VBO, 4);
0267: q(size);
0268: q(type);
0269: q(stride);
0270: q(offset);
0271:
0272: qflush();
0273: }
0274:
0275: public synchronized void glNormalPointer(int type, int stride,
0276: int offset) {
0277: checkThread();
0278: if (VBOArrayBufferBound == 0) {
0279: throw new IllegalStateException("glNormalPointer:"
0280: + Errors.VBO_ARRAY_BUFFER_UNBOUND);
0281: }
0282:
0283: int bufferSize = getBufferSize(GL11.GL_ARRAY_BUFFER);
0284: if (offset < 0 || offset >= bufferSize) {
0285: throw new ArrayIndexOutOfBoundsException(
0286: Errors.VBO_OFFSET_OOB);
0287: }
0288:
0289: if ((type == GL_BYTE || type == GL_SHORT || type == GL_FIXED || type == GL_FLOAT)
0290: && (stride >= 0)) {
0291: BufferManager.releaseBuffer(pointerBuffer[NORMAL_POINTER]);
0292:
0293: pointerBuffer[NORMAL_POINTER] = null;
0294: pointerSize[NORMAL_POINTER] = 3;
0295: pointerType[NORMAL_POINTER] = type;
0296: pointerStride[NORMAL_POINTER] = stride;
0297: pointerRemaining[NORMAL_POINTER] = -1;
0298: pointerOffset[NORMAL_POINTER] = offset;
0299: }
0300:
0301: q(CMD_NORMAL_POINTER_VBO, 3);
0302: q(type);
0303: q(stride);
0304: q(offset);
0305:
0306: qflush();
0307: }
0308:
0309: public synchronized void glTexCoordPointer(int size, int type,
0310: int stride, int offset) {
0311: checkThread();
0312: if (VBOArrayBufferBound == 0) {
0313: throw new IllegalStateException("glTexCoordPointer:"
0314: + Errors.VBO_ARRAY_BUFFER_UNBOUND);
0315: }
0316:
0317: int bufferSize = getBufferSize(GL11.GL_ARRAY_BUFFER);
0318: if (offset < 0 || offset >= bufferSize) {
0319: throw new ArrayIndexOutOfBoundsException(
0320: Errors.VBO_OFFSET_OOB);
0321: }
0322:
0323: if ((size >= 2 && size <= 4)
0324: && (type == GL_BYTE || type == GL_SHORT
0325: || type == GL_FIXED || type == GL_FLOAT)
0326: && (stride >= 0)) {
0327: BufferManager
0328: .releaseBuffer(pointerBuffer[TEX_COORD_POINTER]);
0329:
0330: pointerBuffer[TEX_COORD_POINTER] = null;
0331: pointerSize[TEX_COORD_POINTER] = size;
0332: pointerType[TEX_COORD_POINTER] = type;
0333: pointerStride[TEX_COORD_POINTER] = stride;
0334: pointerRemaining[TEX_COORD_POINTER] = -1;
0335: pointerOffset[TEX_COORD_POINTER] = offset;
0336: }
0337:
0338: q(CMD_TEX_COORD_POINTER_VBO, 4);
0339: q(size);
0340: q(type);
0341: q(stride);
0342: q(offset);
0343:
0344: qflush();
0345: }
0346:
0347: public synchronized void glVertexPointer(int size, int type,
0348: int stride, int offset) {
0349: checkThread();
0350: if (VBOArrayBufferBound == 0) {
0351: throw new IllegalStateException("glVertexPointer:"
0352: + Errors.VBO_ARRAY_BUFFER_UNBOUND);
0353: }
0354:
0355: int bufferSize = getBufferSize(GL11.GL_ARRAY_BUFFER);
0356: if (offset < 0 || offset >= bufferSize) {
0357: throw new ArrayIndexOutOfBoundsException(
0358: Errors.VBO_OFFSET_OOB);
0359: }
0360:
0361: // Only record details if this is a legal operation
0362: if ((size >= 2 && size <= 4)
0363: && (type == GL_BYTE || type == GL_SHORT
0364: || type == GL_FIXED || type == GL_FLOAT)
0365: && (stride >= 0)) {
0366: BufferManager.releaseBuffer(pointerBuffer[VERTEX_POINTER]);
0367:
0368: pointerBuffer[VERTEX_POINTER] = null;
0369: pointerSize[VERTEX_POINTER] = size;
0370: pointerType[VERTEX_POINTER] = type;
0371: pointerStride[VERTEX_POINTER] = stride;
0372: pointerRemaining[VERTEX_POINTER] = -1;
0373: pointerOffset[VERTEX_POINTER] = offset;
0374: }
0375:
0376: q(CMD_VERTEX_POINTER_VBO, 4);
0377: q(size);
0378: q(type);
0379: q(stride);
0380: q(offset);
0381:
0382: qflush();
0383: }
0384:
0385: // Point Size Array Extension
0386:
0387: public synchronized void glPointSizePointerOES(int type,
0388: int stride, Buffer pointer) {
0389: checkThread();
0390: if (VBOArrayBufferBound != 0) {
0391: throw new IllegalStateException("glPointSizePointerOES:"
0392: + Errors.VBO_ARRAY_BUFFER_BOUND);
0393: }
0394: if (pointer == null) {
0395: throwIAE(Errors.GL_POINTER_NULL);
0396: }
0397: if (!isDirect(pointer)) {
0398: throwIAE(Errors.GL_NOT_DIRECT);
0399: }
0400:
0401: // Only record details if this is a legal operation
0402: if ((type == GL_FIXED || type == GL_FLOAT) && (stride >= 0)) {
0403: BufferManager
0404: .releaseBuffer(pointerBuffer[POINT_SIZE_POINTER]);
0405: BufferManager.useBuffer(pointer);
0406:
0407: pointerBuffer[POINT_SIZE_POINTER] = pointer;
0408: pointerSize[POINT_SIZE_POINTER] = 1;
0409: pointerType[POINT_SIZE_POINTER] = type;
0410: pointerStride[POINT_SIZE_POINTER] = stride;
0411: int nbytes = bufferTypeSize(pointer);
0412: pointerRemaining[POINT_SIZE_POINTER] = pointer.remaining()
0413: * nbytes;
0414: pointerOffset[POINT_SIZE_POINTER] = 0;
0415: }
0416:
0417: q(CMD_POINT_SIZE_POINTER, 3);
0418: q(type);
0419: q(stride);
0420: q(pointer);
0421:
0422: qflush();
0423: }
0424:
0425: public synchronized void glPointSizePointerOES(int type,
0426: int stride, int offset) {
0427: checkThread();
0428: if (VBOArrayBufferBound == 0) {
0429: throw new IllegalStateException("glPointSizePointerOES:"
0430: + Errors.VBO_ARRAY_BUFFER_UNBOUND);
0431: }
0432:
0433: int bufferSize = getBufferSize(GL11.GL_ARRAY_BUFFER);
0434: if (offset < 0 || offset >= bufferSize) {
0435: throw new ArrayIndexOutOfBoundsException(
0436: Errors.VBO_OFFSET_OOB);
0437: }
0438:
0439: BufferManager.releaseBuffer(pointerBuffer[POINT_SIZE_POINTER]);
0440:
0441: pointerBuffer[POINT_SIZE_POINTER] = null;
0442: pointerSize[POINT_SIZE_POINTER] = 1;
0443: pointerType[POINT_SIZE_POINTER] = type;
0444: pointerStride[POINT_SIZE_POINTER] = stride;
0445: pointerRemaining[POINT_SIZE_POINTER] = -1;
0446: pointerOffset[POINT_SIZE_POINTER] = offset;
0447:
0448: q(CMD_POINT_SIZE_POINTER_VBO, 3);
0449: q(type);
0450: q(stride);
0451: q(offset);
0452: }
0453:
0454: public synchronized void glDrawElements(int mode, int count,
0455: int type, int offset) {
0456: checkThread();
0457: if (VBOElementArrayBufferBound == 0) {
0458: throw new IllegalStateException("glDrawElements:"
0459: + Errors.VBO_ELEMENT_ARRAY_BUFFER_UNBOUND);
0460: }
0461:
0462: // No need to bounds check indices if there will be a type error
0463: if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT) {
0464:
0465: byte[] bufferData = getBufferIndices();
0466: int nbytes = (type == GL_UNSIGNED_BYTE) ? 1 : 2;
0467:
0468: // System.out.println("offset = " + offset);
0469: // System.out.println("count = " + count);
0470: // System.out.println("nbytes = " + nbytes);
0471: // System.out.println("bufferData.length = " + bufferData.length);
0472:
0473: if (offset < 0
0474: || offset + count * nbytes > bufferData.length) {
0475: throw new ArrayIndexOutOfBoundsException(
0476: Errors.VBO_OFFSET_OOB);
0477: }
0478:
0479: // System.out.println("bufferData = ");
0480: // for (int i = 0; i < bufferData.length; i++) {
0481: // System.out.print((bufferData[i] & 0xff) + " ");
0482: // }
0483: // System.out.println();
0484:
0485: int[] indexArray = new int[count];
0486: boolean isBigEndian = GLConfiguration.IS_BIG_ENDIAN;
0487:
0488: if (type == GL_UNSIGNED_BYTE) {
0489: for (int i = 0; i < count; i++) {
0490: indexArray[i] = bufferData[i + offset] & 0xff;
0491: }
0492: } else if (type == GL_UNSIGNED_SHORT) {
0493: for (int i = 0; i < count; i++) {
0494: int b0 = bufferData[2 * i + offset] & 0xff;
0495: int b1 = bufferData[2 * i + offset + 1] & 0xff;
0496: if (isBigEndian) {
0497: indexArray[i] = (b0 << 8) | b1;
0498: } else {
0499: indexArray[i] = (b1 << 8) | b0;
0500: }
0501: }
0502: }
0503:
0504: checkIndices(indexArray);
0505: }
0506:
0507: q(CMD_DRAW_ELEMENTS_VBO, 4);
0508: q(mode);
0509: q(count);
0510: q(type);
0511: q(offset);
0512: }
0513:
0514: // Other Methods
0515:
0516: public synchronized void glClipPlanef(int plane, float[] equation,
0517: int offset) {
0518: checkThread();
0519: check_1_1();
0520: checkLength(equation, 4, offset);
0521:
0522: IglClipPlanef(plane, equation, offset);
0523: }
0524:
0525: public synchronized void glClipPlanef(int plane,
0526: FloatBuffer equation) {
0527: checkThread();
0528: check_1_1();
0529: checkLength(equation, 4);
0530:
0531: if (!equation.isDirect()) {
0532: IglClipPlanef(plane, equation.array(), offset(equation));
0533: return;
0534: }
0535:
0536: q(CMD_CLIP_PLANEFB, 2);
0537: q(plane);
0538: q(equation);
0539:
0540: qflush();
0541: }
0542:
0543: void IglClipPlanef(int plane, float[] equation, int offset) {
0544: q(CMD_CLIP_PLANEF, 5);
0545: q(plane);
0546: q(equation[offset]);
0547: q(equation[offset + 1]);
0548: q(equation[offset + 2]);
0549: q(equation[offset + 3]);
0550: }
0551:
0552: public synchronized void glClipPlanex(int plane, int[] equation,
0553: int offset) {
0554: checkThread();
0555: check_1_1();
0556: checkLength(equation, 4, offset);
0557:
0558: IglClipPlanex(plane, equation, offset);
0559: }
0560:
0561: public synchronized void glClipPlanex(int plane, IntBuffer equation) {
0562: checkThread();
0563: check_1_1();
0564: checkLength(equation, 4);
0565:
0566: if (!equation.isDirect()) {
0567: IglClipPlanex(plane, equation.array(), offset(equation));
0568: return;
0569: }
0570:
0571: q(CMD_CLIP_PLANEXB, 2);
0572: q(plane);
0573: q(equation);
0574:
0575: qflush();
0576: }
0577:
0578: void IglClipPlanex(int plane, int[] equation, int offset) {
0579: q(CMD_CLIP_PLANEX, 5);
0580: q(plane);
0581: q(equation[offset]);
0582: q(equation[offset + 1]);
0583: q(equation[offset + 2]);
0584: q(equation[offset + 3]);
0585: }
0586:
0587: public synchronized void glGetClipPlanef(int pname,
0588: float[] equation, int offset) {
0589: checkThread();
0590: check_1_1();
0591: checkLength(equation, 4, offset);
0592:
0593: qflush();
0594: IglGetClipPlanef(pname, equation, offset);
0595: }
0596:
0597: public synchronized void glGetClipPlanef(int pname,
0598: FloatBuffer equation) {
0599: checkThread();
0600: check_1_1();
0601: checkLength(equation, 4);
0602:
0603: qflush();
0604: if (!equation.isDirect()) {
0605: IglGetClipPlanef(pname, equation.array(), offset(equation));
0606: } else {
0607: IglGetClipPlanef(pname, null, pointer(equation));
0608: }
0609: }
0610:
0611: void IglGetClipPlanef(int pname, float[] equation, int offset) {
0612: grabContext();
0613: _glGetClipPlanef(pname, equation, offset);
0614: }
0615:
0616: public synchronized void glGetClipPlanex(int pname, int[] equation,
0617: int offset) {
0618: checkThread();
0619: check_1_1();
0620: checkLength(equation, 4, offset);
0621:
0622: qflush();
0623: IglGetClipPlanex(pname, equation, offset);
0624: }
0625:
0626: public synchronized void glGetClipPlanex(int pname,
0627: IntBuffer equation) {
0628: checkThread();
0629: check_1_1();
0630: checkLength(equation, 4);
0631:
0632: qflush();
0633:
0634: if (!equation.isDirect()) {
0635: IglGetClipPlanex(pname, equation.array(), offset(equation));
0636: } else {
0637: IglGetClipPlanex(pname, null, pointer(equation));
0638: }
0639: }
0640:
0641: void IglGetClipPlanex(int pname, int[] equation, int offset) {
0642: grabContext();
0643: _glGetClipPlanex(pname, equation, offset);
0644: }
0645:
0646: public synchronized void glGetFixedv(int pname, int[] params,
0647: int offset) {
0648: checkThread();
0649: check_1_1();
0650: int length = GLConfiguration.glGetNumParams(pname);
0651: checkLength(params, length, offset);
0652:
0653: qflush();
0654: IglGetFixedv(pname, params, offset, length);
0655: }
0656:
0657: public synchronized void glGetFixedv(int pname, IntBuffer params) {
0658: checkThread();
0659: check_1_1();
0660: int length = GLConfiguration.glGetNumParams(pname);
0661: checkLength(params, length);
0662:
0663: qflush();
0664: if (!params.isDirect()) {
0665: IglGetFixedv(pname, params.array(), offset(params), length);
0666: } else {
0667: IglGetFixedv(pname, null, pointer(params), length);
0668: }
0669: }
0670:
0671: void IglGetFixedv(int pname, int[] params, int offset, int length) {
0672: grabContext();
0673: _glGetFixedv(pname, params, offset, length);
0674: }
0675:
0676: public synchronized void glGetFloatv(int pname, float[] params,
0677: int offset) {
0678: checkThread();
0679: check_1_1();
0680: int length = GLConfiguration.glGetNumParams(pname);
0681: checkLength(params, length, offset);
0682:
0683: qflush();
0684: IglGetFloatv(pname, params, offset, length);
0685: }
0686:
0687: public synchronized void glGetFloatv(int pname, FloatBuffer params) {
0688: checkThread();
0689: check_1_1();
0690: int length = GLConfiguration.glGetNumParams(pname);
0691: checkLength(params, length);
0692:
0693: qflush();
0694: if (!params.isDirect()) {
0695: IglGetFloatv(pname, params.array(), offset(params), length);
0696: } else {
0697: IglGetFloatv(pname, null, pointer(params), length);
0698: }
0699: }
0700:
0701: void IglGetFloatv(int pname, float[] params, int offset, int length) {
0702: grabContext();
0703: _glGetFloatv(pname, params, offset, length);
0704: }
0705:
0706: public synchronized void glGetLightfv(int light, int pname,
0707: float[] params, int offset) {
0708: checkThread();
0709: check_1_1();
0710: int length = GLConfiguration.glLightNumParams(pname);
0711: checkLength(params, length, offset);
0712:
0713: qflush();
0714: IglGetLightfv(light, pname, params, offset, length);
0715: }
0716:
0717: public synchronized void glGetLightfv(int light, int pname,
0718: FloatBuffer params) {
0719: checkThread();
0720: check_1_1();
0721: int length = GLConfiguration.glLightNumParams(pname);
0722: checkLength(params, length);
0723:
0724: qflush();
0725: if (!params.isDirect()) {
0726: IglGetLightfv(light, pname, params.array(), offset(params),
0727: length);
0728: } else {
0729: IglGetLightfv(light, pname, null, pointer(params), length);
0730: }
0731: }
0732:
0733: void IglGetLightfv(int light, int pname, float[] params,
0734: int offset, int length) {
0735: grabContext();
0736: _glGetLightfv(light, pname, params, offset, length);
0737: }
0738:
0739: public synchronized void glGetLightxv(int light, int pname,
0740: int[] params, int offset) {
0741: checkThread();
0742: check_1_1();
0743: int length = GLConfiguration.glLightNumParams(pname);
0744: checkLength(params, length, offset);
0745:
0746: qflush();
0747: IglGetLightxv(light, pname, params, offset, length);
0748: }
0749:
0750: public synchronized void glGetLightxv(int light, int pname,
0751: IntBuffer params) {
0752: checkThread();
0753: check_1_1();
0754: int length = GLConfiguration.glLightNumParams(pname);
0755: checkLength(params, length);
0756:
0757: qflush();
0758: if (!params.isDirect()) {
0759: IglGetLightxv(light, pname, params.array(), offset(params),
0760: length);
0761: } else {
0762: IglGetLightxv(light, pname, null, pointer(params), length);
0763: }
0764: }
0765:
0766: void IglGetLightxv(int light, int pname, int[] params, int offset,
0767: int length) {
0768: grabContext();
0769: _glGetLightxv(light, pname, params, offset, length);
0770: }
0771:
0772: public synchronized void glGetMaterialfv(int face, int pname,
0773: float[] params, int offset) {
0774: checkThread();
0775: check_1_1();
0776: int length = GLConfiguration.glMaterialNumParams(pname);
0777: checkLength(params, length, offset);
0778:
0779: qflush();
0780: IglGetMaterialfv(face, pname, params, offset, length);
0781: }
0782:
0783: public synchronized void glGetMaterialfv(int face, int pname,
0784: FloatBuffer params) {
0785: checkThread();
0786: check_1_1();
0787: int length = GLConfiguration.glMaterialNumParams(pname);
0788: checkLength(params, length);
0789:
0790: qflush();
0791: if (!params.isDirect()) {
0792: IglGetMaterialfv(face, pname, params.array(),
0793: offset(params), length);
0794: } else {
0795: IglGetMaterialfv(face, pname, null, pointer(params), length);
0796: }
0797: }
0798:
0799: void IglGetMaterialfv(int face, int pname, float[] params,
0800: int offset, int length) {
0801: grabContext();
0802: _glGetMaterialfv(face, pname, params, offset, length);
0803: }
0804:
0805: public synchronized void glGetMaterialxv(int face, int pname,
0806: int[] params, int offset) {
0807: checkThread();
0808: check_1_1();
0809: int length = GLConfiguration.glMaterialNumParams(pname);
0810: checkLength(params, length, offset);
0811:
0812: qflush();
0813: IglGetMaterialxv(face, pname, params, offset, length);
0814: }
0815:
0816: public synchronized void glGetMaterialxv(int face, int pname,
0817: IntBuffer params) {
0818: checkThread();
0819: check_1_1();
0820: int length = GLConfiguration.glMaterialNumParams(pname);
0821: checkLength(params, length);
0822:
0823: qflush();
0824: if (!params.isDirect()) {
0825: IglGetMaterialxv(face, pname, params.array(),
0826: offset(params), length);
0827: } else {
0828: IglGetMaterialxv(face, pname, null, pointer(params), length);
0829: }
0830: }
0831:
0832: void IglGetMaterialxv(int face, int pname, int[] params,
0833: int offset, int length) {
0834: grabContext();
0835: _glGetMaterialxv(face, pname, params, offset, length);
0836: }
0837:
0838: public synchronized void glGetPointerv(int pname, Buffer[] params) {
0839: if (params == null || params.length < 1) {
0840: throw new IllegalArgumentException();
0841: }
0842:
0843: int pointer = -1;
0844: switch (pname) {
0845: case GL_VERTEX_ARRAY_POINTER:
0846: pointer = VERTEX_POINTER;
0847: break;
0848: case GL_COLOR_ARRAY_POINTER:
0849: pointer = COLOR_POINTER;
0850: break;
0851: case GL_NORMAL_ARRAY_POINTER:
0852: pointer = NORMAL_POINTER;
0853: break;
0854: case GL_TEXTURE_COORD_ARRAY_POINTER:
0855: pointer = TEX_COORD_POINTER;
0856: break;
0857: case GL11.GL_POINT_SIZE_ARRAY_POINTER_OES:
0858: pointer = POINT_SIZE_POINTER;
0859: break;
0860: case GL11Ext.GL_MATRIX_INDEX_ARRAY_POINTER_OES:
0861: pointer = MATRIX_INDEX_POINTER;
0862: break;
0863: case GL11Ext.GL_WEIGHT_ARRAY_POINTER_OES:
0864: pointer = WEIGHT_POINTER;
0865: break;
0866: }
0867:
0868: if (pointer != -1) {
0869: params[0] = pointerBuffer[pointer];
0870: } else {
0871: qflush();
0872: _glGenerateError(GL_INVALID_ENUM);
0873: }
0874: }
0875:
0876: public synchronized void glGetTexEnvfv(int env, int pname,
0877: float[] params, int offset) {
0878: checkThread();
0879: check_1_1();
0880: int length = GLConfiguration.glTexEnvNumParams(pname);
0881: checkLength(params, length, offset);
0882:
0883: qflush();
0884: IglGetTexEnvfv(env, pname, params, offset, length);
0885: }
0886:
0887: public synchronized void glGetTexEnvfv(int env, int pname,
0888: FloatBuffer params) {
0889: checkThread();
0890: check_1_1();
0891: int length = GLConfiguration.glTexEnvNumParams(pname);
0892: checkLength(params, length);
0893:
0894: qflush();
0895: if (!params.isDirect()) {
0896: IglGetTexEnvfv(env, pname, params.array(), offset(params),
0897: length);
0898: } else {
0899: IglGetTexEnvfv(env, pname, null, pointer(params), length);
0900: }
0901: }
0902:
0903: void IglGetTexEnvfv(int env, int pname, float[] params, int offset,
0904: int length) {
0905: grabContext();
0906: _glGetTexEnvfv(env, pname, params, offset, length);
0907: }
0908:
0909: public synchronized void glGetTexEnviv(int env, int pname,
0910: int[] params, int offset) {
0911: checkThread();
0912: check_1_1();
0913: int length = GLConfiguration.glTexEnvNumParams(pname);
0914: checkLength(params, length, offset);
0915:
0916: qflush();
0917: IglGetTexEnviv(env, pname, params, offset, length);
0918: }
0919:
0920: public synchronized void glGetTexEnviv(int env, int pname,
0921: IntBuffer params) {
0922: checkThread();
0923: check_1_1();
0924: int length = GLConfiguration.glTexEnvNumParams(pname);
0925: checkLength(params, length);
0926:
0927: qflush();
0928: if (!params.isDirect()) {
0929: IglGetTexEnviv(env, pname, params.array(), offset(params),
0930: length);
0931: } else {
0932: IglGetTexEnviv(env, pname, null, pointer(params), length);
0933: }
0934: }
0935:
0936: void IglGetTexEnviv(int env, int pname, int[] params, int offset,
0937: int length) {
0938: grabContext();
0939: _glGetTexEnviv(env, pname, params, offset, length);
0940: }
0941:
0942: public synchronized void glGetTexEnvxv(int env, int pname,
0943: int[] params, int offset) {
0944: checkThread();
0945: check_1_1();
0946: int length = GLConfiguration.glTexEnvNumParams(pname);
0947: checkLength(params, length, offset);
0948:
0949: qflush();
0950: IglGetTexEnvxv(env, pname, params, offset, length);
0951: }
0952:
0953: public synchronized void glGetTexEnvxv(int env, int pname,
0954: IntBuffer params) {
0955: checkThread();
0956: check_1_1();
0957: int length = GLConfiguration.glTexEnvNumParams(pname);
0958: checkLength(params, length);
0959:
0960: qflush();
0961: if (!params.isDirect()) {
0962: IglGetTexEnvxv(env, pname, params.array(), offset(params),
0963: length);
0964: } else {
0965: IglGetTexEnvxv(env, pname, null, pointer(params), length);
0966: }
0967: }
0968:
0969: void IglGetTexEnvxv(int env, int pname, int[] params, int offset,
0970: int length) {
0971: grabContext();
0972: _glGetTexEnvxv(env, pname, params, offset, length);
0973: }
0974:
0975: public synchronized void glGetTexParameterfv(int target, int pname,
0976: float[] params, int offset) {
0977: checkThread();
0978: check_1_1();
0979: int length = GLConfiguration.glTexParameterNumParams(pname);
0980: checkLength(params, length, offset);
0981:
0982: qflush();
0983: IglGetTexParameterfv(target, pname, params, offset, length);
0984: }
0985:
0986: public synchronized void glGetTexParameterfv(int target, int pname,
0987: FloatBuffer params) {
0988: checkThread();
0989: check_1_1();
0990: int length = GLConfiguration.glTexParameterNumParams(pname);
0991: checkLength(params, length);
0992:
0993: qflush();
0994: if (!params.isDirect()) {
0995: IglGetTexParameterfv(target, pname, params.array(),
0996: offset(params), length);
0997: } else {
0998: IglGetTexParameterfv(target, pname, null, pointer(params),
0999: length);
1000: }
1001: }
1002:
1003: void IglGetTexParameterfv(int target, int pname, float[] params,
1004: int offset, int length) {
1005: grabContext();
1006: _glGetTexParameterfv(target, pname, params, offset, length);
1007: }
1008:
1009: public synchronized void glGetTexParameteriv(int target, int pname,
1010: int[] params, int offset) {
1011: checkThread();
1012: check_1_1();
1013: int length = GLConfiguration.glTexParameterNumParams(pname);
1014: checkLength(params, length, offset);
1015:
1016: qflush();
1017: IglGetTexParameteriv(target, pname, params, offset, length);
1018: }
1019:
1020: public synchronized void glGetTexParameteriv(int target, int pname,
1021: IntBuffer params) {
1022: checkThread();
1023: check_1_1();
1024: int length = GLConfiguration.glTexParameterNumParams(pname);
1025: checkLength(params, length);
1026:
1027: qflush();
1028: if (!params.isDirect()) {
1029: IglGetTexParameteriv(target, pname, params.array(),
1030: offset(params), length);
1031: } else {
1032: IglGetTexParameteriv(target, pname, null, pointer(params),
1033: length);
1034: }
1035: }
1036:
1037: void IglGetTexParameteriv(int target, int pname, int[] params,
1038: int offset, int length) {
1039: grabContext();
1040: _glGetTexParameteriv(target, pname, params, offset, length);
1041: }
1042:
1043: public synchronized void glGetTexParameterxv(int target, int pname,
1044: int[] params, int offset) {
1045: checkThread();
1046: check_1_1();
1047: int length = GLConfiguration.glTexParameterNumParams(pname);
1048: checkLength(params, length, offset);
1049:
1050: qflush();
1051: IglGetTexParameterxv(target, pname, params, offset, length);
1052: }
1053:
1054: public synchronized void glGetTexParameterxv(int target, int pname,
1055: IntBuffer params) {
1056: checkThread();
1057: check_1_1();
1058: int length = GLConfiguration.glTexParameterNumParams(pname);
1059: checkLength(params, length);
1060:
1061: qflush();
1062: if (!params.isDirect()) {
1063: IglGetTexParameterxv(target, pname, params.array(),
1064: offset(params), length);
1065: } else {
1066: IglGetTexParameterxv(target, pname, null, pointer(params),
1067: length);
1068: }
1069: }
1070:
1071: void IglGetTexParameterxv(int target, int pname, int[] params,
1072: int offset, int length) {
1073: grabContext();
1074: _glGetTexParameterxv(target, pname, params, offset, length);
1075: }
1076:
1077: // Draw Texture Extension
1078:
1079: public synchronized void glDrawTexsOES(short x, short y, short z,
1080: short width, short height) {
1081: checkThread();
1082: if (!GLConfiguration.supports_OES_draw_texture) {
1083: throw new UnsupportedOperationException(
1084: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1085: }
1086: q(CMD_DRAW_TEXS, 5);
1087: q((int) x);
1088: q((int) y);
1089: q((int) z);
1090: q((int) width);
1091: q((int) height);
1092: }
1093:
1094: public synchronized void glDrawTexiOES(int x, int y, int z,
1095: int width, int height) {
1096: checkThread();
1097: if (!GLConfiguration.supports_OES_draw_texture) {
1098: throw new UnsupportedOperationException(
1099: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1100: }
1101: q(CMD_DRAW_TEXI, 5);
1102: q(x);
1103: q(y);
1104: q(z);
1105: q(width);
1106: q(height);
1107: }
1108:
1109: public synchronized void glDrawTexfOES(float x, float y, float z,
1110: float width, float height) {
1111: checkThread();
1112: if (!GLConfiguration.supports_OES_draw_texture) {
1113: throw new UnsupportedOperationException(
1114: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1115: }
1116: q(CMD_DRAW_TEXF, 5);
1117: q(x);
1118: q(y);
1119: q(z);
1120: q(width);
1121: q(height);
1122: }
1123:
1124: public synchronized void glDrawTexxOES(int x, int y, int z,
1125: int width, int height) {
1126: checkThread();
1127: if (!GLConfiguration.supports_OES_draw_texture) {
1128: throw new UnsupportedOperationException(
1129: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1130: }
1131: q(CMD_DRAW_TEXX, 5);
1132: q(x);
1133: q(y);
1134: q(z);
1135: q(width);
1136: q(height);
1137: }
1138:
1139: public synchronized void glDrawTexsvOES(short[] coords, int offset) {
1140: checkThread();
1141: if (!GLConfiguration.supports_OES_draw_texture) {
1142: throw new UnsupportedOperationException(
1143: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1144: }
1145: checkLength(coords, 5, offset);
1146:
1147: IglDrawTexsvOES(coords, offset);
1148: }
1149:
1150: public synchronized void glDrawTexsvOES(ShortBuffer coords) {
1151: checkThread();
1152: if (!GLConfiguration.supports_OES_draw_texture) {
1153: throw new UnsupportedOperationException(
1154: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1155: }
1156: checkLength(coords, 5);
1157:
1158: if (!coords.isDirect()) {
1159: IglDrawTexsvOES(coords.array(), offset(coords));
1160: return;
1161: }
1162:
1163: q(CMD_DRAW_TEXSB, 1);
1164: q(coords);
1165:
1166: qflush();
1167: }
1168:
1169: void IglDrawTexsvOES(short[] coords, int offset) {
1170: q(CMD_DRAW_TEXS, 5);
1171: q((int) coords[offset]);
1172: q((int) coords[offset + 1]);
1173: q((int) coords[offset + 2]);
1174: q((int) coords[offset + 3]);
1175: q((int) coords[offset + 4]);
1176: }
1177:
1178: public synchronized void glDrawTexivOES(int[] coords, int offset) {
1179: checkThread();
1180: if (!GLConfiguration.supports_OES_draw_texture) {
1181: throw new UnsupportedOperationException(
1182: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1183: }
1184: checkLength(coords, 5, offset);
1185:
1186: IglDrawTexivOES(coords, offset);
1187: }
1188:
1189: public synchronized void glDrawTexivOES(IntBuffer coords) {
1190: checkThread();
1191: if (!GLConfiguration.supports_OES_draw_texture) {
1192: throw new UnsupportedOperationException(
1193: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1194: }
1195: checkLength(coords, 5);
1196:
1197: if (!coords.isDirect()) {
1198: IglDrawTexivOES(coords.array(), offset(coords));
1199: return;
1200: }
1201:
1202: q(CMD_DRAW_TEXIB, 1);
1203: q(coords);
1204:
1205: qflush();
1206: }
1207:
1208: void IglDrawTexivOES(int[] coords, int offset) {
1209: q(CMD_DRAW_TEXI, 5);
1210: q(coords[offset]);
1211: q(coords[offset + 1]);
1212: q(coords[offset + 2]);
1213: q(coords[offset + 3]);
1214: q(coords[offset + 4]);
1215: }
1216:
1217: public synchronized void glDrawTexxvOES(int[] coords, int offset) {
1218: checkThread();
1219: if (!GLConfiguration.supports_OES_draw_texture) {
1220: throw new UnsupportedOperationException(
1221: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1222: }
1223: checkLength(coords, 5, offset);
1224:
1225: IglDrawTexxvOES(coords, offset);
1226: }
1227:
1228: public synchronized void glDrawTexxvOES(IntBuffer coords) {
1229: checkThread();
1230: if (!GLConfiguration.supports_OES_draw_texture) {
1231: throw new UnsupportedOperationException(
1232: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1233: }
1234: checkLength(coords, 5);
1235:
1236: if (!coords.isDirect()) {
1237: IglDrawTexxvOES(coords.array(), offset(coords));
1238: return;
1239: }
1240:
1241: q(CMD_DRAW_TEXXB, 1);
1242: q(coords);
1243:
1244: qflush();
1245: }
1246:
1247: void IglDrawTexxvOES(int[] coords, int offset) {
1248: q(CMD_DRAW_TEXX, 5);
1249: q(coords[offset]);
1250: q(coords[offset + 1]);
1251: q(coords[offset + 2]);
1252: q(coords[offset + 3]);
1253: q(coords[offset + 4]);
1254: }
1255:
1256: public synchronized void glDrawTexfvOES(float[] coords, int offset) {
1257: checkThread();
1258: if (!GLConfiguration.supports_OES_draw_texture) {
1259: throw new UnsupportedOperationException(
1260: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1261: }
1262: checkLength(coords, 5, offset);
1263:
1264: IglDrawTexfvOES(coords, offset);
1265: }
1266:
1267: public synchronized void glDrawTexfvOES(FloatBuffer coords) {
1268: checkThread();
1269: if (!GLConfiguration.supports_OES_draw_texture) {
1270: throw new UnsupportedOperationException(
1271: Errors.GL_DRAW_TEXTURE_UNSUPPORTED);
1272: }
1273: checkLength(coords, 5);
1274:
1275: if (!coords.isDirect()) {
1276: IglDrawTexfvOES(coords.array(), offset(coords));
1277: return;
1278: }
1279:
1280: q(CMD_DRAW_TEXFB, 1);
1281: q(coords);
1282:
1283: qflush();
1284: }
1285:
1286: void IglDrawTexfvOES(float[] coords, int offset) {
1287: q(CMD_DRAW_TEXF, 5);
1288: q(coords[offset]);
1289: q(coords[offset + 1]);
1290: q(coords[offset + 2]);
1291: q(coords[offset + 3]);
1292: q(coords[offset + 4]);
1293: }
1294:
1295: // Matrix Palette Extension
1296:
1297: public synchronized void glCurrentPaletteMatrixOES(
1298: int matrixpaletteindex) {
1299: checkThread();
1300: if (!GLConfiguration.supports_OES_matrix_palette) {
1301: throw new UnsupportedOperationException(
1302: Errors.GL_MATRIX_PALETTE_UNSUPPORTED);
1303: }
1304: q(CMD_CURRENT_PALETTE_MATRIX, 1);
1305: q(matrixpaletteindex);
1306: }
1307:
1308: public synchronized void glLoadPaletteFromModelViewMatrixOES() {
1309: checkThread();
1310: if (!GLConfiguration.supports_OES_matrix_palette) {
1311: throw new UnsupportedOperationException(
1312: Errors.GL_MATRIX_PALETTE_UNSUPPORTED);
1313: }
1314: q(CMD_LOAD_PALETTE_FROM_MODEL_VIEW_MATRIX, 0);
1315: }
1316:
1317: public synchronized void glMatrixIndexPointerOES(int size,
1318: int type, int stride, Buffer pointer) {
1319: checkThread();
1320: if (!GLConfiguration.supports_OES_matrix_palette) {
1321: throw new UnsupportedOperationException(
1322: Errors.GL_MATRIX_PALETTE_UNSUPPORTED);
1323: }
1324: if (VBOArrayBufferBound != 0) {
1325: throw new IllegalStateException("glMatrixIndexPointerOES:"
1326: + Errors.VBO_ARRAY_BUFFER_BOUND);
1327: }
1328: if (!isDirect(pointer)) {
1329: throw new ArrayIndexOutOfBoundsException(
1330: Errors.GL_NOT_DIRECT);
1331: }
1332:
1333: if ((size <= GLConfiguration.MAX_VERTEX_UNITS)
1334: && (type == GL_UNSIGNED_BYTE) && (stride >= 0)) {
1335: BufferManager
1336: .releaseBuffer(pointerBuffer[MATRIX_INDEX_POINTER]);
1337: BufferManager.useBuffer(pointer);
1338:
1339: pointerBuffer[MATRIX_INDEX_POINTER] = pointer;
1340: pointerSize[MATRIX_INDEX_POINTER] = size;
1341: pointerType[MATRIX_INDEX_POINTER] = type;
1342: pointerStride[MATRIX_INDEX_POINTER] = stride;
1343: int nbytes = bufferTypeSize(pointer);
1344: pointerRemaining[MATRIX_INDEX_POINTER] = pointer
1345: .remaining()
1346: * nbytes;
1347: pointerOffset[MATRIX_INDEX_POINTER] = 0;
1348: }
1349:
1350: q(CMD_MATRIX_INDEX_POINTER, 4);
1351: q(size);
1352: q(type);
1353: q(stride);
1354: q(pointer);
1355:
1356: qflush();
1357: }
1358:
1359: public synchronized void glMatrixIndexPointerOES(int size,
1360: int type, int stride, int offset) {
1361: checkThread();
1362: if (!GLConfiguration.supports_OES_matrix_palette) {
1363: throw new UnsupportedOperationException(
1364: Errors.GL_MATRIX_PALETTE_UNSUPPORTED);
1365: }
1366: if (VBOArrayBufferBound == 0) {
1367: throw new IllegalStateException("glMatrixIndexPointerOES:"
1368: + Errors.VBO_ARRAY_BUFFER_UNBOUND);
1369: }
1370:
1371: int bufferSize = getBufferSize(GL11.GL_ARRAY_BUFFER);
1372: if (offset < 0 || offset >= bufferSize) {
1373: throw new ArrayIndexOutOfBoundsException(
1374: Errors.VBO_OFFSET_OOB);
1375: }
1376:
1377: if ((size > 0) && (size <= GLConfiguration.MAX_VERTEX_UNITS)
1378: && (type == GL_UNSIGNED_BYTE) && (stride >= 0)) {
1379: BufferManager
1380: .releaseBuffer(pointerBuffer[MATRIX_INDEX_POINTER]);
1381:
1382: pointerBuffer[MATRIX_INDEX_POINTER] = null;
1383: pointerSize[MATRIX_INDEX_POINTER] = size;
1384: pointerType[MATRIX_INDEX_POINTER] = type;
1385: pointerStride[MATRIX_INDEX_POINTER] = stride;
1386: pointerRemaining[MATRIX_INDEX_POINTER] = -1;
1387: pointerOffset[MATRIX_INDEX_POINTER] = offset;
1388: }
1389:
1390: q(CMD_MATRIX_INDEX_POINTER_VBO, 4);
1391: q(size);
1392: q(type);
1393: q(stride);
1394: q(offset);
1395:
1396: qflush();
1397: }
1398:
1399: public synchronized void glWeightPointerOES(int size, int type,
1400: int stride, Buffer pointer) {
1401: checkThread();
1402: if (!GLConfiguration.supports_OES_matrix_palette) {
1403: throw new UnsupportedOperationException(
1404: Errors.GL_MATRIX_PALETTE_UNSUPPORTED);
1405: }
1406: if (VBOArrayBufferBound != 0) {
1407: throw new IllegalStateException("glWeightPointerOES:"
1408: + Errors.VBO_ARRAY_BUFFER_BOUND);
1409: }
1410: if (!isDirect(pointer)) {
1411: throw new IllegalArgumentException(Errors.GL_NOT_DIRECT);
1412: }
1413:
1414: if ((size <= GLConfiguration.MAX_VERTEX_UNITS)
1415: && (type == GL_FIXED || type == GL_FLOAT)
1416: && (stride >= 0)) {
1417: BufferManager.releaseBuffer(pointerBuffer[WEIGHT_POINTER]);
1418: BufferManager.useBuffer(pointer);
1419:
1420: pointerBuffer[WEIGHT_POINTER] = pointer;
1421: pointerSize[WEIGHT_POINTER] = size;
1422: pointerType[WEIGHT_POINTER] = type;
1423: pointerStride[WEIGHT_POINTER] = stride;
1424: int nbytes = bufferTypeSize(pointer);
1425: pointerRemaining[WEIGHT_POINTER] = pointer.remaining()
1426: * nbytes;
1427: pointerOffset[WEIGHT_POINTER] = 0;
1428: }
1429:
1430: q(CMD_WEIGHT_POINTER, 4);
1431: q(size);
1432: q(type);
1433: q(stride);
1434: q(pointer);
1435:
1436: qflush();
1437: }
1438:
1439: public synchronized void glWeightPointerOES(int size, int type,
1440: int stride, int offset) {
1441: checkThread();
1442: if (!GLConfiguration.supports_OES_matrix_palette) {
1443: throw new UnsupportedOperationException(
1444: Errors.GL_MATRIX_PALETTE_UNSUPPORTED);
1445: }
1446: if (VBOArrayBufferBound == 0) {
1447: throw new IllegalStateException("glWeightPointerOES:"
1448: + Errors.VBO_ARRAY_BUFFER_UNBOUND);
1449: }
1450:
1451: int bufferSize = getBufferSize(GL11.GL_ARRAY_BUFFER);
1452: if (offset < 0 || offset >= bufferSize) {
1453: throw new IllegalArgumentException(Errors.VBO_OFFSET_OOB);
1454: }
1455:
1456: if ((size >= 0) && (size <= GLConfiguration.MAX_VERTEX_UNITS)
1457: && (type == GL_FIXED || type == GL_FLOAT)
1458: && (stride >= 0)) {
1459: BufferManager.releaseBuffer(pointerBuffer[WEIGHT_POINTER]);
1460:
1461: pointerBuffer[WEIGHT_POINTER] = null;
1462: pointerSize[WEIGHT_POINTER] = size;
1463: pointerType[WEIGHT_POINTER] = type;
1464: pointerStride[WEIGHT_POINTER] = stride;
1465: pointerRemaining[WEIGHT_POINTER] = -1;
1466: pointerOffset[WEIGHT_POINTER] = offset;
1467: }
1468:
1469: q(CMD_WEIGHT_POINTER_VBO, 4);
1470: q(size);
1471: q(type);
1472: q(stride);
1473: q(offset);
1474:
1475: qflush();
1476: }
1477:
1478: // OES_texture_cube_map
1479:
1480: /**
1481: * Utility for common error checking.
1482: *
1483: * @exception <code>UnsupportedOperationException</code> if the
1484: * underlying engine does not support the
1485: * <code>OES_texture_cube_map</code> extension.
1486: */
1487: void check_texture_cube_map() {
1488: if (!GLConfiguration.supports_OES_texture_cube_map) {
1489: throw new UnsupportedOperationException(
1490: Errors.GL_TEXTURE_CUBE_MAP_UNSUPPORTED);
1491: }
1492: }
1493:
1494: public synchronized void glTexGenf(int coord, int pname, float param) {
1495: checkThread();
1496: check_texture_cube_map();
1497:
1498: q(CMD_TEX_GENF, 3);
1499: q(coord);
1500: q(pname);
1501: q(param);
1502: }
1503:
1504: public synchronized void glTexGeni(int coord, int pname, int param) {
1505: checkThread();
1506: check_texture_cube_map();
1507:
1508: q(CMD_TEX_GENI, 3);
1509: q(coord);
1510: q(pname);
1511: q(param);
1512: }
1513:
1514: public synchronized void glTexGenx(int coord, int pname, int param) {
1515: checkThread();
1516: check_texture_cube_map();
1517:
1518: q(CMD_TEX_GENX, 3);
1519: q(coord);
1520: q(pname);
1521: q(param);
1522: }
1523:
1524: public synchronized void glTexGenfv(int coord, int pname,
1525: float[] params, int offset) {
1526: checkThread();
1527: check_texture_cube_map();
1528: int length = GLConfiguration.glTexGenNumParams(pname);
1529: checkLength(params, length, offset);
1530:
1531: IglTexGenfv(coord, pname, params, offset);
1532: }
1533:
1534: public synchronized void glTexGenfv(int coord, int pname,
1535: FloatBuffer params) {
1536: checkThread();
1537: check_texture_cube_map();
1538: int length = GLConfiguration.glTexGenNumParams(pname);
1539: checkLength(params, length);
1540:
1541: if (!params.isDirect()) {
1542: glTexGenfv(coord, pname, params.array(), offset(params));
1543: return;
1544: }
1545:
1546: q(CMD_TEX_GENFB, 3);
1547: q(coord);
1548: q(pname);
1549: q(params);
1550:
1551: qflush();
1552: }
1553:
1554: void IglTexGenfv(int coord, int pname, float[] params, int offset) {
1555: int n = GLConfiguration.glTexGenNumParams(pname);
1556:
1557: q(CMD_TEX_GENFV, n + 3);
1558: q(n);
1559: q(coord);
1560: q(pname);
1561: for (int i = 0; i < n; i++) {
1562: q(params[offset + i]);
1563: }
1564: }
1565:
1566: public synchronized void glTexGeniv(int coord, int pname,
1567: int[] params, int offset) {
1568: checkThread();
1569: check_texture_cube_map();
1570: int length = GLConfiguration.glTexGenNumParams(pname);
1571: checkLength(params, length, offset);
1572: }
1573:
1574: public synchronized void glTexGeniv(int coord, int pname,
1575: IntBuffer params) {
1576: checkThread();
1577: check_texture_cube_map();
1578: int length = GLConfiguration.glTexGenNumParams(pname);
1579: checkLength(params, length);
1580:
1581: if (!params.isDirect()) {
1582: glTexGeniv(coord, pname, params.array(), offset(params));
1583: return;
1584: }
1585:
1586: q(CMD_TEX_GENIB, 3);
1587: q(coord);
1588: q(pname);
1589: q(params);
1590:
1591: qflush();
1592: }
1593:
1594: void IglTexGeniv(int coord, int pname, int[] params, int offset) {
1595: int n = GLConfiguration.glTexGenNumParams(pname);
1596:
1597: q(CMD_TEX_GENIV, n + 3);
1598: q(n);
1599: q(coord);
1600: q(pname);
1601: for (int i = 0; i < n; i++) {
1602: q(params[offset + i]);
1603: }
1604: }
1605:
1606: public synchronized void glTexGenxv(int coord, int pname,
1607: int[] params, int offset) {
1608: checkThread();
1609: check_texture_cube_map();
1610: int length = GLConfiguration.glTexGenNumParams(pname);
1611: checkLength(params, length, offset);
1612: }
1613:
1614: public synchronized void glTexGenxv(int coord, int pname,
1615: IntBuffer params) {
1616: checkThread();
1617: check_texture_cube_map();
1618: int length = GLConfiguration.glTexGenNumParams(pname);
1619: checkLength(params, length);
1620:
1621: if (!params.isDirect()) {
1622: glTexGenxv(coord, pname, params.array(), offset(params));
1623: return;
1624: }
1625:
1626: q(CMD_TEX_GENXB, 3);
1627: q(coord);
1628: q(pname);
1629: q(params);
1630:
1631: qflush();
1632: }
1633:
1634: void IglTexGenxv(int coord, int pname, int[] params, int offset) {
1635: int n = GLConfiguration.glTexGenNumParams(pname);
1636:
1637: q(CMD_TEX_GENXV, n + 3);
1638: q(n);
1639: q(coord);
1640: q(pname);
1641: for (int i = 0; i < n; i++) {
1642: q(params[offset + i]);
1643: }
1644: }
1645:
1646: public synchronized void glGetTexGenfv(int coord, int pname,
1647: float[] params, int offset) {
1648: checkThread();
1649: check_texture_cube_map();
1650: int length = GLConfiguration.glTexGenNumParams(pname);
1651: checkLength(params, length, offset);
1652:
1653: qflush();
1654: IglGetTexGenfv(coord, pname, params, offset, length);
1655: }
1656:
1657: public synchronized void glGetTexGenfv(int coord, int pname,
1658: FloatBuffer params) {
1659: checkThread();
1660: check_texture_cube_map();
1661: int length = GLConfiguration.glTexGenNumParams(pname);
1662: checkLength(params, length);
1663:
1664: qflush();
1665: if (!params.isDirect()) {
1666: IglGetTexGenfv(coord, pname, params.array(),
1667: offset(params), length);
1668: } else {
1669: IglGetTexGenfv(coord, pname, null, pointer(params), length);
1670: }
1671: }
1672:
1673: void IglGetTexGenfv(int coord, int pname, float[] params,
1674: int offset, int length) {
1675: grabContext();
1676: _glGetTexGenfv(coord, pname, params, offset, length);
1677: }
1678:
1679: public synchronized void glGetTexGeniv(int coord, int pname,
1680: int[] params, int offset) {
1681: checkThread();
1682: check_texture_cube_map();
1683: int length = GLConfiguration.glTexGenNumParams(pname);
1684: checkLength(params, length, offset);
1685:
1686: qflush();
1687: IglGetTexGeniv(coord, pname, params, offset, length);
1688: }
1689:
1690: public synchronized void glGetTexGeniv(int coord, int pname,
1691: IntBuffer params) {
1692: checkThread();
1693: check_texture_cube_map();
1694: int length = GLConfiguration.glTexGenNumParams(pname);
1695: checkLength(params, length);
1696:
1697: qflush();
1698: if (!params.isDirect()) {
1699: IglGetTexGeniv(coord, pname, params.array(),
1700: offset(params), length);
1701: } else {
1702: IglGetTexGeniv(coord, pname, null, pointer(params), length);
1703: }
1704: }
1705:
1706: void IglGetTexGeniv(int coord, int pname, int[] params, int offset,
1707: int length) {
1708: grabContext();
1709: _glGetTexGeniv(coord, pname, params, offset, length);
1710: }
1711:
1712: public synchronized void glGetTexGenxv(int coord, int pname,
1713: int[] params, int offset) {
1714: checkThread();
1715: check_texture_cube_map();
1716: int length = GLConfiguration.glTexGenNumParams(pname);
1717: checkLength(params, length, offset);
1718:
1719: qflush();
1720: IglGetTexGenxv(coord, pname, params, offset, length);
1721: }
1722:
1723: public synchronized void glGetTexGenxv(int coord, int pname,
1724: IntBuffer params) {
1725: checkThread();
1726: check_texture_cube_map();
1727: int length = GLConfiguration.glTexGenNumParams(pname);
1728: checkLength(params, length);
1729:
1730: qflush();
1731: if (!params.isDirect()) {
1732: IglGetTexGenxv(coord, pname, params.array(),
1733: offset(params), length);
1734: } else {
1735: IglGetTexGenxv(coord, pname, null, pointer(params), length);
1736: }
1737: }
1738:
1739: void IglGetTexGenxv(int coord, int pname, int[] params, int offset,
1740: int length) {
1741: grabContext();
1742: _glGetTexGenxv(coord, pname, params, offset, length);
1743: }
1744:
1745: // OES_blend_subtract
1746:
1747: public synchronized void glBlendEquation(int mode) {
1748: checkThread();
1749: if (!GLConfiguration.supports_OES_blend_subtract) {
1750: throw new UnsupportedOperationException(
1751: Errors.GL_BLEND_SUBTRACT_UNSUPPORTED);
1752: }
1753:
1754: q(CMD_BLEND_EQUATION, 1);
1755: q(mode);
1756: }
1757:
1758: // OES_blend_func_separate
1759:
1760: public synchronized void glBlendFuncSeparate(int srcRGB,
1761: int dstRGB, int srcAlpha, int dstAlpha) {
1762: checkThread();
1763: if (!GLConfiguration.supports_OES_blend_func_separate) {
1764: throw new UnsupportedOperationException(
1765: Errors.GL_BLEND_FUNC_SEPARATE_UNSUPPORTED);
1766: }
1767:
1768: q(CMD_BLEND_FUNC_SEPARATE, 4);
1769: q(srcRGB);
1770: q(dstRGB);
1771: q(srcAlpha);
1772: q(dstAlpha);
1773: }
1774:
1775: // OES_blend_equation_separate
1776:
1777: public synchronized void glBlendEquationSeparate(int modeRGB,
1778: int modeAlpha) {
1779: checkThread();
1780: if (!GLConfiguration.supports_OES_blend_equation_separate) {
1781: throw new UnsupportedOperationException(
1782: Errors.GL_BLEND_EQUATION_SEPARATE_UNSUPPORTED);
1783: }
1784:
1785: q(CMD_BLEND_EQUATION_SEPARATE, 2);
1786: q(modeRGB);
1787: q(modeAlpha);
1788: }
1789:
1790: // OES_framebuffer_object
1791:
1792: /**
1793: * Utility for common error checking.
1794: *
1795: * @exception <code>UnsupportedOperationException</code> if the
1796: * underlying engine does not support the
1797: * <code>OES_framebuffer_object</code> extension.
1798: */
1799: void check_fbo() {
1800: if (!GLConfiguration.supports_OES_framebuffer_object) {
1801: throw new UnsupportedOperationException(
1802: Errors.GL_FRAMEBUFFER_OBJECT_UNSUPPORTED);
1803: }
1804: }
1805:
1806: public synchronized boolean glIsRenderbufferOES(int renderbuffer) {
1807: checkThread();
1808: check_fbo();
1809:
1810: qflush();
1811:
1812: grabContext();
1813: boolean retval = GL_TRUE == _glIsRenderbufferOES(renderbuffer);
1814:
1815: return retval;
1816: }
1817:
1818: public synchronized void glBindRenderbufferOES(int target,
1819: int renderbuffer) {
1820: checkThread();
1821: check_fbo();
1822:
1823: q(CMD_BIND_RENDERBUFFER, 2);
1824: q(target);
1825: q(renderbuffer);
1826: }
1827:
1828: public synchronized void glDeleteRenderbuffersOES(int n,
1829: int[] renderbuffers, int offset) {
1830: checkThread();
1831: check_fbo();
1832: checkLength(renderbuffers, n, offset);
1833:
1834: IglDeleteRenderbuffersOES(n, renderbuffers, offset);
1835: }
1836:
1837: public synchronized void glDeleteRenderbuffersOES(int n,
1838: IntBuffer renderbuffers) {
1839: checkThread();
1840: check_fbo();
1841: checkLength(renderbuffers, n);
1842:
1843: if (!renderbuffers.isDirect()) {
1844: glDeleteRenderbuffersOES(n, renderbuffers.array(),
1845: offset(renderbuffers));
1846: return;
1847: }
1848:
1849: q(CMD_DELETE_RENDERBUFFERSB, 2);
1850: q(n);
1851: q(renderbuffers);
1852:
1853: qflush();
1854: }
1855:
1856: void IglDeleteRenderbuffersOES(int n, int[] renderbuffers,
1857: int offset) {
1858: q(CMD_DELETE_RENDERBUFFERS, n + 1);
1859: q(n);
1860: for (int i = 0; i < n; i++) {
1861: q(renderbuffers[offset + i]);
1862: }
1863: }
1864:
1865: public synchronized void glGenRenderbuffersOES(int n,
1866: int[] renderbuffers, int offset) {
1867: checkThread();
1868: check_fbo();
1869: checkLength(renderbuffers, n, offset);
1870:
1871: qflush();
1872: IglGenRenderbuffersOES(n, renderbuffers, offset);
1873: }
1874:
1875: public synchronized void glGenRenderbuffersOES(int n,
1876: IntBuffer renderbuffers) {
1877: checkThread();
1878: check_fbo();
1879: checkLength(renderbuffers, n);
1880:
1881: if (!renderbuffers.isDirect()) {
1882: IglGenRenderbuffersOES(n, renderbuffers.array(),
1883: offset(renderbuffers));
1884: return;
1885: }
1886:
1887: q(CMD_GEN_RENDERBUFFERSB, 2);
1888: q(n);
1889: q(renderbuffers);
1890:
1891: qflush();
1892: }
1893:
1894: void IglGenRenderbuffersOES(int n, int[] renderbuffers, int offset) {
1895: grabContext();
1896: _glGenRenderbuffersOES(n, renderbuffers, offset);
1897: }
1898:
1899: public synchronized void glRenderbufferStorageOES(int target,
1900: int internalformat, int width, int height) {
1901: checkThread();
1902: check_fbo();
1903:
1904: q(CMD_RENDERBUFFER_STORAGE, 4);
1905: q(target);
1906: q(internalformat);
1907: q(width);
1908: q(height);
1909: }
1910:
1911: public synchronized void glGetRenderbufferParameterivOES(
1912: int target, int pname, int[] params, int offset) {
1913: checkThread();
1914: check_fbo();
1915: int length = GLConfiguration
1916: .glRenderbufferParameterNumParams(pname);
1917: checkLength(params, length, offset);
1918:
1919: qflush();
1920: IglGetRenderbufferParameterivOES(target, pname, params, offset,
1921: length);
1922: }
1923:
1924: public synchronized void glGetRenderbufferParameterivOES(
1925: int target, int pname, IntBuffer params) {
1926: checkThread();
1927: check_fbo();
1928: int length = GLConfiguration
1929: .glRenderbufferParameterNumParams(pname);
1930: checkLength(params, length);
1931:
1932: qflush();
1933: if (!params.isDirect()) {
1934: IglGetRenderbufferParameterivOES(target, pname, params
1935: .array(), offset(params), length);
1936: } else {
1937: IglGetRenderbufferParameterivOES(target, pname, null,
1938: pointer(params), length);
1939: }
1940: }
1941:
1942: void IglGetRenderbufferParameterivOES(int target, int pname,
1943: int[] params, int offset, int length) {
1944: grabContext();
1945: _glGetRenderbufferParameterivOES(target, pname, params, offset,
1946: length);
1947: }
1948:
1949: public synchronized boolean glIsFramebufferOES(int framebuffer) {
1950: checkThread();
1951: check_fbo();
1952:
1953: qflush();
1954:
1955: grabContext();
1956: boolean retval = GL_TRUE == _glIsFramebufferOES(framebuffer);
1957: return retval;
1958: }
1959:
1960: public synchronized void glBindFramebufferOES(int target,
1961: int framebuffer) {
1962: checkThread();
1963: check_fbo();
1964: }
1965:
1966: public synchronized void glDeleteFramebuffersOES(int n,
1967: int[] framebuffers, int offset) {
1968: checkThread();
1969: check_fbo();
1970: checkLength(framebuffers, n, offset);
1971:
1972: IglDeleteFramebuffersOES(n, framebuffers, offset);
1973: }
1974:
1975: public synchronized void glDeleteFramebuffersOES(int n,
1976: IntBuffer framebuffers) {
1977: checkThread();
1978: check_fbo();
1979: checkLength(framebuffers, n);
1980:
1981: if (!framebuffers.isDirect()) {
1982: glDeleteFramebuffersOES(n, framebuffers.array(),
1983: offset(framebuffers));
1984: return;
1985: }
1986:
1987: q(CMD_DELETE_FRAMEBUFFERSB, 2);
1988: q(n);
1989: q(framebuffers);
1990:
1991: qflush();
1992: }
1993:
1994: void IglDeleteFramebuffersOES(int n, int[] framebuffers, int offset) {
1995: q(CMD_DELETE_FRAMEBUFFERS, n + 1);
1996: q(n);
1997: for (int i = 0; i < n; i++) {
1998: q(framebuffers[offset + i]);
1999: }
2000: }
2001:
2002: public synchronized void glGenFramebuffersOES(int n,
2003: int[] framebuffers, int offset) {
2004: checkThread();
2005: check_fbo();
2006: checkLength(framebuffers, n, offset);
2007:
2008: qflush();
2009: IglGenFramebuffersOES(n, framebuffers, offset);
2010: }
2011:
2012: public synchronized void glGenFramebuffersOES(int n,
2013: IntBuffer framebuffers) {
2014: checkThread();
2015: check_fbo();
2016: checkLength(framebuffers, n);
2017:
2018: if (!framebuffers.isDirect()) {
2019: IglGenRenderbuffersOES(n, framebuffers.array(),
2020: offset(framebuffers));
2021: return;
2022: }
2023:
2024: q(CMD_GEN_FRAMEBUFFERSB, 2);
2025: q(n);
2026: q(framebuffers);
2027:
2028: qflush();
2029: }
2030:
2031: void IglGenFramebuffersOES(int n, int[] framebuffers, int offset) {
2032: grabContext();
2033: _glGenFramebuffersOES(n, framebuffers, offset);
2034: }
2035:
2036: public synchronized int glCheckFramebufferStatusOES(int target) {
2037: checkThread();
2038: check_fbo();
2039:
2040: qflush();
2041:
2042: grabContext();
2043: int retval = _glCheckFramebufferStatusOES(target);
2044: return retval;
2045: }
2046:
2047: public synchronized void glFramebufferTexture2DOES(int target,
2048: int attachment, int textarget, int texture, int level) {
2049: checkThread();
2050: check_fbo();
2051:
2052: q(CMD_FRAMEBUFFER_TEXTURE2D, 5);
2053: q(target);
2054: q(attachment);
2055: q(textarget);
2056: q(textarget);
2057: q(level);
2058: }
2059:
2060: public synchronized void glFramebufferRenderbufferOES(int target,
2061: int attachment, int renderbuffertarget, int renderbuffer) {
2062: checkThread();
2063: check_fbo();
2064:
2065: q(CMD_FRAMEBUFFER_RENDERBUFFER, 4);
2066: q(target);
2067: q(attachment);
2068: q(renderbuffertarget);
2069: q(renderbuffer);
2070: }
2071:
2072: public synchronized void glGetFramebufferAttachmentParameterivOES(
2073: int target, int attachment, int pname, int[] params,
2074: int offset) {
2075: checkThread();
2076: check_fbo();
2077: int length = GLConfiguration
2078: .glFramebufferAttachmentParameterNumParams(pname);
2079: checkLength(params, length, offset);
2080:
2081: qflush();
2082: IglGetFramebufferAttachmentParameterivOES(target, attachment,
2083: pname, params, offset, length);
2084: }
2085:
2086: public synchronized void glGetFramebufferAttachmentParameterivOES(
2087: int target, int attachment, int pname, IntBuffer params) {
2088: checkThread();
2089: check_fbo();
2090: int length = GLConfiguration
2091: .glFramebufferAttachmentParameterNumParams(pname);
2092: checkLength(params, length);
2093:
2094: qflush();
2095: if (!params.isDirect()) {
2096: IglGetFramebufferAttachmentParameterivOES(target,
2097: attachment, pname, params.array(), offset(params),
2098: length);
2099: } else {
2100: IglGetFramebufferAttachmentParameterivOES(target,
2101: attachment, pname, null, pointer(params), length);
2102: }
2103: }
2104:
2105: void IglGetFramebufferAttachmentParameterivOES(int target,
2106: int attachment, int pname, int[] params, int offset,
2107: int length) {
2108: grabContext();
2109: _glGetFramebufferAttachmentParameterivOES(target, attachment,
2110: pname, params, offset, length);
2111: }
2112:
2113: public synchronized void glGenerateMipmapOES(int target) {
2114: checkThread();
2115: check_fbo();
2116:
2117: q(CMD_GENERATE_MIPMAP, 1);
2118: q(target);
2119: }
2120:
2121: public GL11Impl(EGLContext context) {
2122: super(context);
2123: }
2124: }
|