1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.opengl;
18
19import java.nio.Buffer;
20import java.nio.FloatBuffer;
21import java.nio.IntBuffer;
22import java.nio.ShortBuffer;
23
24import javax.microedition.khronos.opengles.GL;
25
26/**
27 * Implement an error checking wrapper. The wrapper will automatically call
28     * glError after each GL operation, and throw a GLException if an error
29     * occurs. (By design, calling glError itself will not cause an exception
30     * to be thrown.) Enabling error checking is an alternative to manually
31     *  calling glError after every GL operation.
32 */
33class GLErrorWrapper extends GLWrapperBase {
34    boolean mCheckError;
35    boolean mCheckThread;
36    Thread mOurThread;
37
38    public GLErrorWrapper(GL gl, int configFlags) {
39        super(gl);
40        mCheckError = (configFlags & GLDebugHelper.CONFIG_CHECK_GL_ERROR) != 0;
41        mCheckThread = (configFlags & GLDebugHelper.CONFIG_CHECK_THREAD) != 0;
42    }
43
44    private void checkThread() {
45        if (mCheckThread) {
46            Thread currentThread = Thread.currentThread();
47            if (mOurThread == null) {
48                mOurThread = currentThread;
49            } else {
50                if (!mOurThread.equals(currentThread)) {
51                    throw new GLException(GLDebugHelper.ERROR_WRONG_THREAD,
52                            "OpenGL method called from wrong thread.");
53                }
54            }
55        }
56    }
57
58    private void checkError() {
59        if (mCheckError) {
60            int glError;
61            if ((glError = mgl.glGetError()) != 0) {
62                throw new GLException(glError);
63            }
64        }
65    }
66
67    // ---------------------------------------------------------------------
68    // GL10 methods:
69
70    public void glActiveTexture(int texture) {
71        checkThread();
72        mgl.glActiveTexture(texture);
73        checkError();
74    }
75
76    public void glAlphaFunc(int func, float ref) {
77        checkThread();
78        mgl.glAlphaFunc(func, ref);
79        checkError();
80    }
81
82    public void glAlphaFuncx(int func, int ref) {
83        checkThread();
84        mgl.glAlphaFuncx(func, ref);
85        checkError();
86    }
87
88    public void glBindTexture(int target, int texture) {
89        checkThread();
90        mgl.glBindTexture(target, texture);
91        checkError();
92    }
93
94    public void glBlendFunc(int sfactor, int dfactor) {
95        checkThread();
96        mgl.glBlendFunc(sfactor, dfactor);
97        checkError();
98    }
99
100    public void glClear(int mask) {
101        checkThread();
102        mgl.glClear(mask);
103        checkError();
104    }
105
106    public void glClearColor(float red, float green, float blue, float alpha) {
107        checkThread();
108        mgl.glClearColor(red, green, blue, alpha);
109        checkError();
110    }
111
112    public void glClearColorx(int red, int green, int blue, int alpha) {
113        checkThread();
114        mgl.glClearColorx(red, green, blue, alpha);
115        checkError();
116    }
117
118    public void glClearDepthf(float depth) {
119        checkThread();
120        mgl.glClearDepthf(depth);
121        checkError();
122    }
123
124    public void glClearDepthx(int depth) {
125        checkThread();
126        mgl.glClearDepthx(depth);
127        checkError();
128    }
129
130    public void glClearStencil(int s) {
131        checkThread();
132        mgl.glClearStencil(s);
133        checkError();
134    }
135
136    public void glClientActiveTexture(int texture) {
137        checkThread();
138        mgl.glClientActiveTexture(texture);
139        checkError();
140    }
141
142    public void glColor4f(float red, float green, float blue, float alpha) {
143        checkThread();
144        mgl.glColor4f(red, green, blue, alpha);
145        checkError();
146    }
147
148    public void glColor4x(int red, int green, int blue, int alpha) {
149        checkThread();
150        mgl.glColor4x(red, green, blue, alpha);
151        checkError();
152    }
153
154    public void glColorMask(boolean red, boolean green, boolean blue,
155            boolean alpha) {
156        checkThread();
157        mgl.glColorMask(red, green, blue, alpha);
158        checkError();
159    }
160
161    public void glColorPointer(int size, int type, int stride, Buffer pointer) {
162        checkThread();
163        mgl.glColorPointer(size, type, stride, pointer);
164        checkError();
165    }
166
167    public void glCompressedTexImage2D(int target, int level,
168            int internalformat, int width, int height, int border,
169            int imageSize, Buffer data) {
170        checkThread();
171        mgl.glCompressedTexImage2D(target, level, internalformat, width,
172                height, border, imageSize, data);
173        checkError();
174    }
175
176    public void glCompressedTexSubImage2D(int target, int level, int xoffset,
177            int yoffset, int width, int height, int format, int imageSize,
178            Buffer data) {
179        checkThread();
180        mgl.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width,
181                height, format, imageSize, data);
182        checkError();
183    }
184
185    public void glCopyTexImage2D(int target, int level, int internalformat,
186            int x, int y, int width, int height, int border) {
187        checkThread();
188        mgl.glCopyTexImage2D(target, level, internalformat, x, y, width,
189                height, border);
190        checkError();
191    }
192
193    public void glCopyTexSubImage2D(int target, int level, int xoffset,
194            int yoffset, int x, int y, int width, int height) {
195        checkThread();
196        mgl.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width,
197                height);
198        checkError();
199    }
200
201    public void glCullFace(int mode) {
202        checkThread();
203        mgl.glCullFace(mode);
204        checkError();
205    }
206
207    public void glDeleteTextures(int n, int[] textures, int offset) {
208        checkThread();
209        mgl.glDeleteTextures(n, textures, offset);
210        checkError();
211    }
212
213    public void glDeleteTextures(int n, IntBuffer textures) {
214        checkThread();
215        mgl.glDeleteTextures(n, textures);
216        checkError();
217    }
218
219    public void glDepthFunc(int func) {
220        checkThread();
221        mgl.glDepthFunc(func);
222        checkError();
223    }
224
225    public void glDepthMask(boolean flag) {
226        checkThread();
227        mgl.glDepthMask(flag);
228        checkError();
229    }
230
231    public void glDepthRangef(float near, float far) {
232        checkThread();
233        mgl.glDepthRangef(near, far);
234        checkError();
235    }
236
237    public void glDepthRangex(int near, int far) {
238        checkThread();
239        mgl.glDepthRangex(near, far);
240        checkError();
241    }
242
243    public void glDisable(int cap) {
244        checkThread();
245        mgl.glDisable(cap);
246        checkError();
247    }
248
249    public void glDisableClientState(int array) {
250        checkThread();
251        mgl.glDisableClientState(array);
252        checkError();
253    }
254
255    public void glDrawArrays(int mode, int first, int count) {
256        checkThread();
257        mgl.glDrawArrays(mode, first, count);
258        checkError();
259    }
260
261    public void glDrawElements(int mode, int count, int type, Buffer indices) {
262        checkThread();
263        mgl.glDrawElements(mode, count, type, indices);
264        checkError();
265    }
266
267    public void glEnable(int cap) {
268        checkThread();
269        mgl.glEnable(cap);
270        checkError();
271    }
272
273    public void glEnableClientState(int array) {
274        checkThread();
275        mgl.glEnableClientState(array);
276        checkError();
277    }
278
279    public void glFinish() {
280        checkThread();
281        mgl.glFinish();
282        checkError();
283    }
284
285    public void glFlush() {
286        checkThread();
287        mgl.glFlush();
288        checkError();
289    }
290
291    public void glFogf(int pname, float param) {
292        checkThread();
293        mgl.glFogf(pname, param);
294        checkError();
295    }
296
297    public void glFogfv(int pname, float[] params, int offset) {
298        checkThread();
299        mgl.glFogfv(pname, params, offset);
300        checkError();
301    }
302
303    public void glFogfv(int pname, FloatBuffer params) {
304        checkThread();
305        mgl.glFogfv(pname, params);
306        checkError();
307    }
308
309    public void glFogx(int pname, int param) {
310        checkThread();
311        mgl.glFogx(pname, param);
312        checkError();
313    }
314
315    public void glFogxv(int pname, int[] params, int offset) {
316        checkThread();
317        mgl.glFogxv(pname, params, offset);
318        checkError();
319    }
320
321    public void glFogxv(int pname, IntBuffer params) {
322        checkThread();
323        mgl.glFogxv(pname, params);
324        checkError();
325    }
326
327    public void glFrontFace(int mode) {
328        checkThread();
329        mgl.glFrontFace(mode);
330        checkError();
331    }
332
333    public void glFrustumf(float left, float right, float bottom, float top,
334            float near, float far) {
335        checkThread();
336        mgl.glFrustumf(left, right, bottom, top, near, far);
337        checkError();
338    }
339
340    public void glFrustumx(int left, int right, int bottom, int top, int near,
341            int far) {
342        checkThread();
343        mgl.glFrustumx(left, right, bottom, top, near, far);
344        checkError();
345    }
346
347    public void glGenTextures(int n, int[] textures, int offset) {
348        checkThread();
349        mgl.glGenTextures(n, textures, offset);
350        checkError();
351    }
352
353    public void glGenTextures(int n, IntBuffer textures) {
354        checkThread();
355        mgl.glGenTextures(n, textures);
356        checkError();
357    }
358
359    public int glGetError() {
360        checkThread();
361        int result = mgl.glGetError();
362        return result;
363    }
364
365    public void glGetIntegerv(int pname, int[] params, int offset) {
366        checkThread();
367        mgl.glGetIntegerv(pname, params, offset);
368        checkError();
369    }
370
371    public void glGetIntegerv(int pname, IntBuffer params) {
372        checkThread();
373        mgl.glGetIntegerv(pname, params);
374        checkError();
375    }
376
377    public String glGetString(int name) {
378        checkThread();
379        String result = mgl.glGetString(name);
380        checkError();
381        return result;
382    }
383
384    public void glHint(int target, int mode) {
385        checkThread();
386        mgl.glHint(target, mode);
387        checkError();
388    }
389
390    public void glLightModelf(int pname, float param) {
391        checkThread();
392        mgl.glLightModelf(pname, param);
393        checkError();
394    }
395
396    public void glLightModelfv(int pname, float[] params, int offset) {
397        checkThread();
398        mgl.glLightModelfv(pname, params, offset);
399        checkError();
400    }
401
402    public void glLightModelfv(int pname, FloatBuffer params) {
403        checkThread();
404        mgl.glLightModelfv(pname, params);
405        checkError();
406    }
407
408    public void glLightModelx(int pname, int param) {
409        checkThread();
410        mgl.glLightModelx(pname, param);
411        checkError();
412    }
413
414    public void glLightModelxv(int pname, int[] params, int offset) {
415        checkThread();
416        mgl.glLightModelxv(pname, params, offset);
417        checkError();
418    }
419
420    public void glLightModelxv(int pname, IntBuffer params) {
421        checkThread();
422        mgl.glLightModelxv(pname, params);
423        checkError();
424    }
425
426    public void glLightf(int light, int pname, float param) {
427        checkThread();
428        mgl.glLightf(light, pname, param);
429        checkError();
430    }
431
432    public void glLightfv(int light, int pname, float[] params, int offset) {
433        checkThread();
434        mgl.glLightfv(light, pname, params, offset);
435        checkError();
436    }
437
438    public void glLightfv(int light, int pname, FloatBuffer params) {
439        checkThread();
440        mgl.glLightfv(light, pname, params);
441        checkError();
442    }
443
444    public void glLightx(int light, int pname, int param) {
445        checkThread();
446        mgl.glLightx(light, pname, param);
447        checkError();
448    }
449
450    public void glLightxv(int light, int pname, int[] params, int offset) {
451        checkThread();
452        mgl.glLightxv(light, pname, params, offset);
453        checkError();
454    }
455
456    public void glLightxv(int light, int pname, IntBuffer params) {
457        checkThread();
458        mgl.glLightxv(light, pname, params);
459        checkError();
460    }
461
462    public void glLineWidth(float width) {
463        checkThread();
464        mgl.glLineWidth(width);
465        checkError();
466    }
467
468    public void glLineWidthx(int width) {
469        checkThread();
470        mgl.glLineWidthx(width);
471        checkError();
472    }
473
474    public void glLoadIdentity() {
475        checkThread();
476        mgl.glLoadIdentity();
477        checkError();
478    }
479
480    public void glLoadMatrixf(float[] m, int offset) {
481        checkThread();
482        mgl.glLoadMatrixf(m, offset);
483        checkError();
484    }
485
486    public void glLoadMatrixf(FloatBuffer m) {
487        checkThread();
488        mgl.glLoadMatrixf(m);
489        checkError();
490    }
491
492    public void glLoadMatrixx(int[] m, int offset) {
493        checkThread();
494        mgl.glLoadMatrixx(m, offset);
495        checkError();
496    }
497
498    public void glLoadMatrixx(IntBuffer m) {
499        checkThread();
500        mgl.glLoadMatrixx(m);
501        checkError();
502    }
503
504    public void glLogicOp(int opcode) {
505        checkThread();
506        mgl.glLogicOp(opcode);
507        checkError();
508    }
509
510    public void glMaterialf(int face, int pname, float param) {
511        checkThread();
512        mgl.glMaterialf(face, pname, param);
513        checkError();
514    }
515
516    public void glMaterialfv(int face, int pname, float[] params, int offset) {
517        checkThread();
518        mgl.glMaterialfv(face, pname, params, offset);
519        checkError();
520    }
521
522    public void glMaterialfv(int face, int pname, FloatBuffer params) {
523        checkThread();
524        mgl.glMaterialfv(face, pname, params);
525        checkError();
526    }
527
528    public void glMaterialx(int face, int pname, int param) {
529        checkThread();
530        mgl.glMaterialx(face, pname, param);
531        checkError();
532    }
533
534    public void glMaterialxv(int face, int pname, int[] params, int offset) {
535        checkThread();
536        mgl.glMaterialxv(face, pname, params, offset);
537        checkError();
538    }
539
540    public void glMaterialxv(int face, int pname, IntBuffer params) {
541        checkThread();
542        mgl.glMaterialxv(face, pname, params);
543        checkError();
544    }
545
546    public void glMatrixMode(int mode) {
547        checkThread();
548        mgl.glMatrixMode(mode);
549        checkError();
550    }
551
552    public void glMultMatrixf(float[] m, int offset) {
553        checkThread();
554        mgl.glMultMatrixf(m, offset);
555        checkError();
556    }
557
558    public void glMultMatrixf(FloatBuffer m) {
559        checkThread();
560        mgl.glMultMatrixf(m);
561        checkError();
562    }
563
564    public void glMultMatrixx(int[] m, int offset) {
565        checkThread();
566        mgl.glMultMatrixx(m, offset);
567        checkError();
568    }
569
570    public void glMultMatrixx(IntBuffer m) {
571        checkThread();
572        mgl.glMultMatrixx(m);
573        checkError();
574    }
575
576    public void glMultiTexCoord4f(int target,
577            float s, float t, float r, float q) {
578        checkThread();
579        mgl.glMultiTexCoord4f(target, s, t, r, q);
580        checkError();
581    }
582
583    public void glMultiTexCoord4x(int target, int s, int t, int r, int q) {
584        checkThread();
585        mgl.glMultiTexCoord4x(target, s, t, r, q);
586        checkError();
587    }
588
589    public void glNormal3f(float nx, float ny, float nz) {
590        checkThread();
591        mgl.glNormal3f(nx, ny, nz);
592        checkError();
593    }
594
595    public void glNormal3x(int nx, int ny, int nz) {
596        checkThread();
597        mgl.glNormal3x(nx, ny, nz);
598        checkError();
599    }
600
601    public void glNormalPointer(int type, int stride, Buffer pointer) {
602        checkThread();
603        mgl.glNormalPointer(type, stride, pointer);
604        checkError();
605    }
606
607    public void glOrthof(float left, float right, float bottom, float top,
608            float near, float far) {
609        checkThread();
610        mgl.glOrthof(left, right, bottom, top, near, far);
611        checkError();
612    }
613
614    public void glOrthox(int left, int right, int bottom, int top, int near,
615            int far) {
616        checkThread();
617        mgl.glOrthox(left, right, bottom, top, near, far);
618        checkError();
619    }
620
621    public void glPixelStorei(int pname, int param) {
622        checkThread();
623        mgl.glPixelStorei(pname, param);
624        checkError();
625    }
626
627    public void glPointSize(float size) {
628        checkThread();
629        mgl.glPointSize(size);
630        checkError();
631    }
632
633    public void glPointSizex(int size) {
634        checkThread();
635        mgl.glPointSizex(size);
636        checkError();
637    }
638
639    public void glPolygonOffset(float factor, float units) {
640        checkThread();
641        mgl.glPolygonOffset(factor, units);
642        checkError();
643    }
644
645    public void glPolygonOffsetx(int factor, int units) {
646        checkThread();
647        mgl.glPolygonOffsetx(factor, units);
648        checkError();
649    }
650
651    public void glPopMatrix() {
652        checkThread();
653        mgl.glPopMatrix();
654        checkError();
655    }
656
657    public void glPushMatrix() {
658        checkThread();
659        mgl.glPushMatrix();
660        checkError();
661    }
662
663    public void glReadPixels(int x, int y, int width, int height, int format,
664            int type, Buffer pixels) {
665        checkThread();
666        mgl.glReadPixels(x, y, width, height, format, type, pixels);
667        checkError();
668    }
669
670    public void glRotatef(float angle, float x, float y, float z) {
671        checkThread();
672        mgl.glRotatef(angle, x, y, z);
673        checkError();
674    }
675
676    public void glRotatex(int angle, int x, int y, int z) {
677        checkThread();
678        mgl.glRotatex(angle, x, y, z);
679        checkError();
680    }
681
682    public void glSampleCoverage(float value, boolean invert) {
683        checkThread();
684        mgl.glSampleCoverage(value, invert);
685        checkError();
686    }
687
688    public void glSampleCoveragex(int value, boolean invert) {
689        checkThread();
690        mgl.glSampleCoveragex(value, invert);
691        checkError();
692    }
693
694    public void glScalef(float x, float y, float z) {
695        checkThread();
696        mgl.glScalef(x, y, z);
697        checkError();
698    }
699
700    public void glScalex(int x, int y, int z) {
701        checkThread();
702        mgl.glScalex(x, y, z);
703        checkError();
704    }
705
706    public void glScissor(int x, int y, int width, int height) {
707        checkThread();
708        mgl.glScissor(x, y, width, height);
709        checkError();
710    }
711
712    public void glShadeModel(int mode) {
713        checkThread();
714        mgl.glShadeModel(mode);
715        checkError();
716    }
717
718    public void glStencilFunc(int func, int ref, int mask) {
719        checkThread();
720        mgl.glStencilFunc(func, ref, mask);
721        checkError();
722    }
723
724    public void glStencilMask(int mask) {
725        checkThread();
726        mgl.glStencilMask(mask);
727        checkError();
728    }
729
730    public void glStencilOp(int fail, int zfail, int zpass) {
731        checkThread();
732        mgl.glStencilOp(fail, zfail, zpass);
733        checkError();
734    }
735
736    public void glTexCoordPointer(int size, int type,
737            int stride, Buffer pointer) {
738        checkThread();
739        mgl.glTexCoordPointer(size, type, stride, pointer);
740        checkError();
741    }
742
743    public void glTexEnvf(int target, int pname, float param) {
744        checkThread();
745        mgl.glTexEnvf(target, pname, param);
746        checkError();
747    }
748
749    public void glTexEnvfv(int target, int pname, float[] params, int offset) {
750        checkThread();
751        mgl.glTexEnvfv(target, pname, params, offset);
752        checkError();
753    }
754
755    public void glTexEnvfv(int target, int pname, FloatBuffer params) {
756        checkThread();
757        mgl.glTexEnvfv(target, pname, params);
758        checkError();
759    }
760
761    public void glTexEnvx(int target, int pname, int param) {
762        checkThread();
763        mgl.glTexEnvx(target, pname, param);
764        checkError();
765    }
766
767    public void glTexEnvxv(int target, int pname, int[] params, int offset) {
768        checkThread();
769        mgl.glTexEnvxv(target, pname, params, offset);
770        checkError();
771    }
772
773    public void glTexEnvxv(int target, int pname, IntBuffer params) {
774        checkThread();
775        mgl.glTexEnvxv(target, pname, params);
776        checkError();
777    }
778
779    public void glTexImage2D(int target, int level, int internalformat,
780            int width, int height, int border, int format, int type,
781            Buffer pixels) {
782        checkThread();
783        mgl.glTexImage2D(target, level, internalformat, width, height, border,
784                format, type, pixels);
785        checkError();
786    }
787
788    public void glTexParameterf(int target, int pname, float param) {
789        checkThread();
790        mgl.glTexParameterf(target, pname, param);
791        checkError();
792    }
793
794    public void glTexParameterx(int target, int pname, int param) {
795        checkThread();
796        mgl.glTexParameterx(target, pname, param);
797        checkError();
798    }
799
800    public void glTexParameteriv(int target, int pname, int[] params, int offset) {
801        checkThread();
802        mgl11.glTexParameteriv(target, pname, params, offset);
803        checkError();
804    }
805
806    public void glTexParameteriv(int target, int pname, IntBuffer params) {
807        checkThread();
808        mgl11.glTexParameteriv(target, pname, params);
809        checkError();
810    }
811
812    public void glTexSubImage2D(int target, int level, int xoffset,
813            int yoffset, int width, int height, int format, int type,
814            Buffer pixels) {
815        checkThread();
816        mgl.glTexSubImage2D(target, level, xoffset, yoffset, width, height,
817                format, type, pixels);
818        checkError();
819    }
820
821    public void glTranslatef(float x, float y, float z) {
822        checkThread();
823        mgl.glTranslatef(x, y, z);
824        checkError();
825    }
826
827    public void glTranslatex(int x, int y, int z) {
828        checkThread();
829        mgl.glTranslatex(x, y, z);
830        checkError();
831    }
832
833    public void glVertexPointer(int size, int type,
834            int stride, Buffer pointer) {
835        checkThread();
836        mgl.glVertexPointer(size, type, stride, pointer);
837        checkError();
838    }
839
840    public void glViewport(int x, int y, int width, int height) {
841        checkThread();
842        mgl.glViewport(x, y, width, height);
843        checkError();
844    }
845
846    public void glClipPlanef(int plane, float[] equation, int offset) {
847        checkThread();
848        mgl11.glClipPlanef(plane, equation, offset);
849        checkError();
850    }
851
852    public void glClipPlanef(int plane, FloatBuffer equation) {
853        checkThread();
854        mgl11.glClipPlanef(plane, equation);
855        checkError();
856    }
857
858    public void glClipPlanex(int plane, int[] equation, int offset) {
859        checkThread();
860        mgl11.glClipPlanex(plane, equation, offset);
861        checkError();
862    }
863
864    public void glClipPlanex(int plane, IntBuffer equation) {
865        checkThread();
866        mgl11.glClipPlanex(plane, equation);
867        checkError();
868    }
869
870    // Draw Texture Extension
871
872    public void glDrawTexfOES(float x, float y, float z,
873        float width, float height) {
874        checkThread();
875        mgl11Ext.glDrawTexfOES(x, y, z, width, height);
876        checkError();
877    }
878
879    public void glDrawTexfvOES(float[] coords, int offset) {
880        checkThread();
881        mgl11Ext.glDrawTexfvOES(coords, offset);
882        checkError();
883    }
884
885    public void glDrawTexfvOES(FloatBuffer coords) {
886        checkThread();
887        mgl11Ext.glDrawTexfvOES(coords);
888        checkError();
889    }
890
891    public void glDrawTexiOES(int x, int y, int z, int width, int height) {
892        checkThread();
893        mgl11Ext.glDrawTexiOES(x, y, z, width, height);
894        checkError();
895    }
896
897    public void glDrawTexivOES(int[] coords, int offset) {
898        checkThread();
899        mgl11Ext.glDrawTexivOES(coords, offset);
900        checkError();
901    }
902
903    public void glDrawTexivOES(IntBuffer coords) {
904        checkThread();
905        mgl11Ext.glDrawTexivOES(coords);
906        checkError();
907    }
908
909    public void glDrawTexsOES(short x, short y, short z,
910        short width, short height) {
911        checkThread();
912        mgl11Ext.glDrawTexsOES(x, y, z, width, height);
913        checkError();
914    }
915
916    public void glDrawTexsvOES(short[] coords, int offset) {
917        checkThread();
918        mgl11Ext.glDrawTexsvOES(coords, offset);
919        checkError();
920    }
921
922    public void glDrawTexsvOES(ShortBuffer coords) {
923        checkThread();
924        mgl11Ext.glDrawTexsvOES(coords);
925        checkError();
926    }
927
928    public void glDrawTexxOES(int x, int y, int z, int width, int height) {
929        checkThread();
930        mgl11Ext.glDrawTexxOES(x, y, z, width, height);
931        checkError();
932    }
933
934    public void glDrawTexxvOES(int[] coords, int offset) {
935        checkThread();
936        mgl11Ext.glDrawTexxvOES(coords, offset);
937        checkError();
938    }
939
940    public void glDrawTexxvOES(IntBuffer coords) {
941        checkThread();
942        mgl11Ext.glDrawTexxvOES(coords);
943        checkError();
944    }
945
946    public int glQueryMatrixxOES(int[] mantissa, int mantissaOffset,
947        int[] exponent, int exponentOffset) {
948        checkThread();
949        int valid = mgl10Ext.glQueryMatrixxOES(mantissa, mantissaOffset,
950            exponent, exponentOffset);
951        checkError();
952        return valid;
953    }
954
955    public int glQueryMatrixxOES(IntBuffer mantissa, IntBuffer exponent) {
956        checkThread();
957        int valid = mgl10Ext.glQueryMatrixxOES(mantissa, exponent);
958        checkError();
959        return valid;
960    }
961
962    public void glBindBuffer(int target, int buffer) {
963        checkThread();
964        mgl11.glBindBuffer(target, buffer);
965        checkError();
966    }
967
968    public void glBufferData(int target, int size, Buffer data, int usage) {
969        checkThread();
970        mgl11.glBufferData(target, size, data, usage);
971        checkError();
972    }
973
974    public void glBufferSubData(int target, int offset, int size, Buffer data) {
975        checkThread();
976        mgl11.glBufferSubData(target, offset, size, data);
977        checkError();
978    }
979
980    public void glColor4ub(byte red, byte green, byte blue, byte alpha) {
981        checkThread();
982        mgl11.glColor4ub(red, green, blue, alpha);
983        checkError();    }
984
985    public void glColorPointer(int size, int type, int stride, int offset) {
986        checkThread();
987        mgl11.glColorPointer(size, type, stride, offset);
988        checkError();
989    }
990
991    public void glDeleteBuffers(int n, int[] buffers, int offset) {
992        checkThread();
993        mgl11.glDeleteBuffers(n, buffers, offset);
994        checkError();
995    }
996
997    public void glDeleteBuffers(int n, IntBuffer buffers) {
998        checkThread();
999        mgl11.glDeleteBuffers(n, buffers);
1000        checkError();
1001    }
1002
1003    public void glDrawElements(int mode, int count, int type, int offset) {
1004        checkThread();
1005        mgl11.glDrawElements(mode, count, type, offset);
1006        checkError();
1007    }
1008
1009    public void glGenBuffers(int n, int[] buffers, int offset) {
1010        checkThread();
1011        mgl11.glGenBuffers(n, buffers, offset);
1012        checkError();
1013    }
1014
1015    public void glGenBuffers(int n, IntBuffer buffers) {
1016        checkThread();
1017        mgl11.glGenBuffers(n, buffers);
1018        checkError();
1019    }
1020
1021    public void glGetBooleanv(int pname, boolean[] params, int offset) {
1022        checkThread();
1023        mgl11.glGetBooleanv(pname, params, offset);
1024        checkError();
1025    }
1026
1027    public void glGetBooleanv(int pname, IntBuffer params) {
1028        checkThread();
1029        mgl11.glGetBooleanv(pname, params);
1030        checkError();
1031    }
1032
1033    public void glGetBufferParameteriv(int target, int pname, int[] params,
1034            int offset) {
1035        checkThread();
1036        mgl11.glGetBufferParameteriv(target, pname, params, offset);
1037        checkError();
1038    }
1039
1040    public void glGetBufferParameteriv(int target, int pname, IntBuffer params) {
1041        checkThread();
1042        mgl11.glGetBufferParameteriv(target, pname, params);
1043        checkError();
1044    }
1045
1046    public void glGetClipPlanef(int pname, float[] eqn, int offset) {
1047        checkThread();
1048        mgl11.glGetClipPlanef(pname, eqn, offset);
1049        checkError();
1050    }
1051
1052    public void glGetClipPlanef(int pname, FloatBuffer eqn) {
1053        checkThread();
1054        mgl11.glGetClipPlanef(pname, eqn);
1055        checkError();
1056    }
1057
1058    public void glGetClipPlanex(int pname, int[] eqn, int offset) {
1059        checkThread();
1060        mgl11.glGetClipPlanex(pname, eqn, offset);
1061        checkError();
1062    }
1063
1064    public void glGetClipPlanex(int pname, IntBuffer eqn) {
1065        checkThread();
1066        mgl11.glGetClipPlanex(pname, eqn);
1067        checkError();
1068    }
1069
1070    public void glGetFixedv(int pname, int[] params, int offset) {
1071        checkThread();
1072        mgl11.glGetFixedv(pname, params, offset);
1073        checkError();
1074    }
1075
1076    public void glGetFixedv(int pname, IntBuffer params) {
1077        checkThread();
1078        mgl11.glGetFixedv(pname, params);
1079        checkError();
1080    }
1081
1082    public void glGetFloatv(int pname, float[] params, int offset) {
1083        checkThread();
1084        mgl11.glGetFloatv(pname, params, offset);
1085        checkError();
1086    }
1087
1088    public void glGetFloatv(int pname, FloatBuffer params) {
1089        checkThread();
1090        mgl11.glGetFloatv(pname, params);
1091        checkError();
1092    }
1093
1094    public void glGetLightfv(int light, int pname, float[] params, int offset) {
1095        checkThread();
1096        mgl11.glGetLightfv(light, pname, params, offset);
1097        checkError();
1098    }
1099
1100    public void glGetLightfv(int light, int pname, FloatBuffer params) {
1101        checkThread();
1102        mgl11.glGetLightfv(light, pname, params);
1103        checkError();
1104    }
1105
1106    public void glGetLightxv(int light, int pname, int[] params, int offset) {
1107        checkThread();
1108        mgl11.glGetLightxv(light, pname, params, offset);
1109        checkError();
1110    }
1111
1112    public void glGetLightxv(int light, int pname, IntBuffer params) {
1113        checkThread();
1114        mgl11.glGetLightxv(light, pname, params);
1115        checkError();
1116    }
1117
1118    public void glGetMaterialfv(int face, int pname, float[] params, int offset) {
1119        checkThread();
1120        mgl11.glGetMaterialfv(face, pname, params, offset);
1121        checkError();
1122    }
1123
1124    public void glGetMaterialfv(int face, int pname, FloatBuffer params) {
1125        checkThread();
1126        mgl11.glGetMaterialfv(face, pname, params);
1127        checkError();
1128    }
1129
1130    public void glGetMaterialxv(int face, int pname, int[] params, int offset) {
1131        checkThread();
1132        mgl11.glGetMaterialxv(face, pname, params, offset);
1133        checkError();
1134    }
1135
1136    public void glGetMaterialxv(int face, int pname, IntBuffer params) {
1137        checkThread();
1138        mgl11.glGetMaterialxv(face, pname, params);
1139        checkError();
1140    }
1141
1142    public void glGetPointerv(int pname, Buffer[] params) {
1143        checkThread();
1144        mgl11.glGetPointerv(pname, params);
1145        checkError();
1146    }
1147
1148    public void glGetTexEnviv(int env, int pname, int[] params, int offset) {
1149        checkThread();
1150        mgl11.glGetTexEnviv(env, pname, params, offset);
1151        checkError();
1152    }
1153
1154    public void glGetTexEnviv(int env, int pname, IntBuffer params) {
1155        checkThread();
1156        mgl11.glGetTexEnviv(env, pname, params);
1157        checkError();
1158    }
1159
1160    public void glGetTexEnvxv(int env, int pname, int[] params, int offset) {
1161        checkThread();
1162        mgl11.glGetTexEnvxv(env, pname, params, offset);
1163        checkError();
1164    }
1165
1166    public void glGetTexEnvxv(int env, int pname, IntBuffer params) {
1167        checkThread();
1168        mgl11.glGetTexEnvxv(env, pname, params);
1169        checkError();
1170    }
1171
1172    public void glGetTexParameterfv(int target, int pname, float[] params,
1173            int offset) {
1174        checkThread();
1175        mgl11.glGetTexParameterfv(target, pname, params, offset);
1176        checkError();
1177    }
1178
1179    public void glGetTexParameterfv(int target, int pname, FloatBuffer params) {
1180        checkThread();
1181        mgl11.glGetTexParameterfv(target, pname, params);
1182        checkError();
1183    }
1184
1185    public void glGetTexParameteriv(int target, int pname, int[] params,
1186            int offset) {
1187        checkThread();
1188        mgl11.glGetTexParameteriv(target, pname, params, offset);
1189        checkError();
1190    }
1191
1192    public void glGetTexParameteriv(int target, int pname, IntBuffer params) {
1193        checkThread();
1194        mgl11.glGetTexParameteriv(target, pname, params);
1195        checkError();
1196    }
1197
1198    public void glGetTexParameterxv(int target, int pname, int[] params,
1199            int offset) {
1200        checkThread();
1201        mgl11.glGetTexParameterxv(target, pname, params, offset);
1202        checkError();
1203    }
1204
1205    public void glGetTexParameterxv(int target, int pname, IntBuffer params) {
1206        checkThread();
1207        mgl11.glGetTexParameterxv(target, pname, params);
1208        checkError();
1209    }
1210
1211    public boolean glIsBuffer(int buffer) {
1212        checkThread();
1213        boolean valid = mgl11.glIsBuffer(buffer);
1214        checkError();
1215        return valid;
1216    }
1217
1218    public boolean glIsEnabled(int cap) {
1219        checkThread();
1220        boolean valid = mgl11.glIsEnabled(cap);
1221        checkError();
1222        return valid;
1223    }
1224
1225    public boolean glIsTexture(int texture) {
1226        checkThread();
1227        boolean valid = mgl11.glIsTexture(texture);
1228        checkError();
1229        return valid;
1230    }
1231
1232    public void glNormalPointer(int type, int stride, int offset) {
1233        checkThread();
1234        mgl11.glNormalPointer(type, stride, offset);
1235        checkError();
1236    }
1237
1238    public void glPointParameterf(int pname, float param) {
1239        checkThread();
1240        mgl11.glPointParameterf(pname, param);
1241        checkError();
1242    }
1243
1244    public void glPointParameterfv(int pname, float[] params, int offset) {
1245        checkThread();
1246        mgl11.glPointParameterfv(pname, params, offset);
1247        checkError();
1248    }
1249
1250    public void glPointParameterfv(int pname, FloatBuffer params) {
1251        checkThread();
1252        mgl11.glPointParameterfv(pname, params);
1253        checkError();
1254    }
1255
1256    public void glPointParameterx(int pname, int param) {
1257        checkThread();
1258        mgl11.glPointParameterx(pname, param);
1259        checkError();
1260    }
1261
1262    public void glPointParameterxv(int pname, int[] params, int offset) {
1263        checkThread();
1264        mgl11.glPointParameterxv(pname, params, offset);
1265        checkError();
1266    }
1267
1268    public void glPointParameterxv(int pname, IntBuffer params) {
1269        checkThread();
1270        mgl11.glPointParameterxv(pname, params);
1271        checkError();
1272    }
1273
1274    public void glPointSizePointerOES(int type, int stride, Buffer pointer) {
1275        checkThread();
1276        mgl11.glPointSizePointerOES(type, stride, pointer);
1277        checkError();
1278    }
1279
1280    public void glTexCoordPointer(int size, int type, int stride, int offset) {
1281        checkThread();
1282        mgl11.glTexCoordPointer(size, type, stride, offset);
1283        checkError();
1284    }
1285
1286    public void glTexEnvi(int target, int pname, int param) {
1287        checkThread();
1288        mgl11.glTexEnvi(target, pname, param);
1289        checkError();
1290    }
1291
1292    public void glTexEnviv(int target, int pname, int[] params, int offset) {
1293        checkThread();
1294        mgl11.glTexEnviv(target, pname, params, offset);
1295        checkError();
1296    }
1297
1298    public void glTexEnviv(int target, int pname, IntBuffer params) {
1299        checkThread();
1300        mgl11.glTexEnviv(target, pname, params);
1301        checkError();
1302    }
1303
1304    public void glTexParameterfv(int target, int pname, float[] params,
1305            int offset) {
1306        checkThread();
1307        mgl11.glTexParameterfv(target, pname, params, offset);
1308        checkError();
1309    }
1310
1311    public void glTexParameterfv(int target, int pname, FloatBuffer params) {
1312        checkThread();
1313        mgl11.glTexParameterfv(target, pname, params);
1314        checkError();
1315    }
1316
1317    public void glTexParameteri(int target, int pname, int param) {
1318        checkThread();
1319        mgl11.glTexParameteri(target, pname, param);
1320        checkError();
1321    }
1322
1323    public void glTexParameterxv(int target, int pname, int[] params, int offset) {
1324        checkThread();
1325        mgl11.glTexParameterxv(target, pname, params, offset);
1326        checkError();
1327    }
1328
1329    public void glTexParameterxv(int target, int pname, IntBuffer params) {
1330        checkThread();
1331        mgl11.glTexParameterxv(target, pname, params);
1332        checkError();
1333    }
1334
1335    public void glVertexPointer(int size, int type, int stride, int offset) {
1336        checkThread();
1337        mgl11.glVertexPointer(size, type, stride, offset);
1338        checkError();
1339    }
1340
1341    public void glCurrentPaletteMatrixOES(int matrixpaletteindex) {
1342        checkThread();
1343        mgl11Ext.glCurrentPaletteMatrixOES(matrixpaletteindex);
1344        checkError();
1345    }
1346
1347    public void glLoadPaletteFromModelViewMatrixOES() {
1348        checkThread();
1349        mgl11Ext.glLoadPaletteFromModelViewMatrixOES();
1350        checkError();
1351    }
1352
1353    public void glMatrixIndexPointerOES(int size, int type, int stride,
1354            Buffer pointer) {
1355        checkThread();
1356        mgl11Ext.glMatrixIndexPointerOES(size, type, stride, pointer);
1357        checkError();
1358    }
1359
1360    public void glMatrixIndexPointerOES(int size, int type, int stride,
1361            int offset) {
1362        checkThread();
1363        mgl11Ext.glMatrixIndexPointerOES(size, type, stride, offset);
1364        checkError();
1365    }
1366
1367    public void glWeightPointerOES(int size, int type, int stride,
1368            Buffer pointer) {
1369        checkThread();
1370        mgl11Ext.glWeightPointerOES(size, type, stride, pointer);
1371        checkError();
1372    }
1373
1374    public void glWeightPointerOES(int size, int type, int stride, int offset) {
1375        checkThread();
1376        mgl11Ext.glWeightPointerOES(size, type, stride, offset);
1377        checkError();
1378    }
1379
1380
1381}
1382