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 17 package com.example.android.apis.graphics.spritetext; 18 19 import android.util.Log; 20 21 import java.nio.Buffer; 22 import java.nio.ByteBuffer; 23 import java.nio.ByteOrder; 24 import java.nio.FloatBuffer; 25 import java.nio.IntBuffer; 26 import java.nio.ShortBuffer; 27 28 import javax.microedition.khronos.opengles.GL; 29 import javax.microedition.khronos.opengles.GL10; 30 import javax.microedition.khronos.opengles.GL10Ext; 31 import javax.microedition.khronos.opengles.GL11; 32 import javax.microedition.khronos.opengles.GL11Ext; 33 34 /** 35 * Allows retrieving the current matrix even if the current OpenGL ES 36 * driver does not support retrieving the current matrix. 37 * 38 * Note: the actual matrix may differ from the retrieved matrix, due 39 * to differences in the way the math is implemented by GLMatrixWrapper 40 * as compared to the way the math is implemented by the OpenGL ES 41 * driver. 42 */ 43 class MatrixTrackingGL implements GL, GL10, GL10Ext, GL11, GL11Ext { 44 private GL10 mgl; 45 private GL10Ext mgl10Ext; 46 private GL11 mgl11; 47 private GL11Ext mgl11Ext; 48 private int mMatrixMode; 49 private MatrixStack mCurrent; 50 private MatrixStack mModelView; 51 private MatrixStack mTexture; 52 private MatrixStack mProjection; 53 54 private final static boolean _check = false; 55 ByteBuffer mByteBuffer; 56 FloatBuffer mFloatBuffer; 57 float[] mCheckA; 58 float[] mCheckB; 59 60 public MatrixTrackingGL(GL gl) { 61 mgl = (GL10) gl; 62 if (gl instanceof GL10Ext) { 63 mgl10Ext = (GL10Ext) gl; 64 } 65 if (gl instanceof GL11) { 66 mgl11 = (GL11) gl; 67 } 68 if (gl instanceof GL11Ext) { 69 mgl11Ext = (GL11Ext) gl; 70 } 71 mModelView = new MatrixStack(); 72 mProjection = new MatrixStack(); 73 mTexture = new MatrixStack(); 74 mCurrent = mModelView; 75 mMatrixMode = GL10.GL_MODELVIEW; 76 } 77 78 // --------------------------------------------------------------------- 79 // GL10 methods: 80 81 public void glActiveTexture(int texture) { 82 mgl.glActiveTexture(texture); 83 } 84 85 public void glAlphaFunc(int func, float ref) { 86 mgl.glAlphaFunc(func, ref); 87 } 88 89 public void glAlphaFuncx(int func, int ref) { 90 mgl.glAlphaFuncx(func, ref); 91 } 92 93 public void glBindTexture(int target, int texture) { 94 mgl.glBindTexture(target, texture); 95 } 96 97 public void glBlendFunc(int sfactor, int dfactor) { 98 mgl.glBlendFunc(sfactor, dfactor); 99 } 100 101 public void glClear(int mask) { 102 mgl.glClear(mask); 103 } 104 105 public void glClearColor(float red, float green, float blue, float alpha) { 106 mgl.glClearColor(red, green, blue, alpha); 107 } 108 109 public void glClearColorx(int red, int green, int blue, int alpha) { 110 mgl.glClearColorx(red, green, blue, alpha); 111 } 112 113 public void glClearDepthf(float depth) { 114 mgl.glClearDepthf(depth); 115 } 116 117 public void glClearDepthx(int depth) { 118 mgl.glClearDepthx(depth); 119 } 120 121 public void glClearStencil(int s) { 122 mgl.glClearStencil(s); 123 } 124 125 public void glClientActiveTexture(int texture) { 126 mgl.glClientActiveTexture(texture); 127 } 128 129 public void glColor4f(float red, float green, float blue, float alpha) { 130 mgl.glColor4f(red, green, blue, alpha); 131 } 132 133 public void glColor4x(int red, int green, int blue, int alpha) { 134 mgl.glColor4x(red, green, blue, alpha); 135 } 136 137 public void glColorMask(boolean red, boolean green, boolean blue, 138 boolean alpha) { 139 mgl.glColorMask(red, green, blue, alpha); 140 } 141 142 public void glColorPointer(int size, int type, int stride, Buffer pointer) { 143 mgl.glColorPointer(size, type, stride, pointer); 144 } 145 146 public void glCompressedTexImage2D(int target, int level, 147 int internalformat, int width, int height, int border, 148 int imageSize, Buffer data) { 149 mgl.glCompressedTexImage2D(target, level, internalformat, width, 150 height, border, imageSize, data); 151 } 152 153 public void glCompressedTexSubImage2D(int target, int level, int xoffset, 154 int yoffset, int width, int height, int format, int imageSize, 155 Buffer data) { 156 mgl.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, 157 height, format, imageSize, data); 158 } 159 160 public void glCopyTexImage2D(int target, int level, int internalformat, 161 int x, int y, int width, int height, int border) { 162 mgl.glCopyTexImage2D(target, level, internalformat, x, y, width, 163 height, border); 164 } 165 166 public void glCopyTexSubImage2D(int target, int level, int xoffset, 167 int yoffset, int x, int y, int width, int height) { 168 mgl.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, 169 height); 170 } 171 172 public void glCullFace(int mode) { 173 mgl.glCullFace(mode); 174 } 175 176 public void glDeleteTextures(int n, int[] textures, int offset) { 177 mgl.glDeleteTextures(n, textures, offset); 178 } 179 180 public void glDeleteTextures(int n, IntBuffer textures) { 181 mgl.glDeleteTextures(n, textures); 182 } 183 184 public void glDepthFunc(int func) { 185 mgl.glDepthFunc(func); 186 } 187 188 public void glDepthMask(boolean flag) { 189 mgl.glDepthMask(flag); 190 } 191 192 public void glDepthRangef(float near, float far) { 193 mgl.glDepthRangef(near, far); 194 } 195 196 public void glDepthRangex(int near, int far) { 197 mgl.glDepthRangex(near, far); 198 } 199 200 public void glDisable(int cap) { 201 mgl.glDisable(cap); 202 } 203 204 public void glDisableClientState(int array) { 205 mgl.glDisableClientState(array); 206 } 207 208 public void glDrawArrays(int mode, int first, int count) { 209 mgl.glDrawArrays(mode, first, count); 210 } 211 212 public void glDrawElements(int mode, int count, int type, Buffer indices) { 213 mgl.glDrawElements(mode, count, type, indices); 214 } 215 216 public void glEnable(int cap) { 217 mgl.glEnable(cap); 218 } 219 220 public void glEnableClientState(int array) { 221 mgl.glEnableClientState(array); 222 } 223 224 public void glFinish() { 225 mgl.glFinish(); 226 } 227 228 public void glFlush() { 229 mgl.glFlush(); 230 } 231 232 public void glFogf(int pname, float param) { 233 mgl.glFogf(pname, param); 234 } 235 236 public void glFogfv(int pname, float[] params, int offset) { 237 mgl.glFogfv(pname, params, offset); 238 } 239 240 public void glFogfv(int pname, FloatBuffer params) { 241 mgl.glFogfv(pname, params); 242 } 243 244 public void glFogx(int pname, int param) { 245 mgl.glFogx(pname, param); 246 } 247 248 public void glFogxv(int pname, int[] params, int offset) { 249 mgl.glFogxv(pname, params, offset); 250 } 251 252 public void glFogxv(int pname, IntBuffer params) { 253 mgl.glFogxv(pname, params); 254 } 255 256 public void glFrontFace(int mode) { 257 mgl.glFrontFace(mode); 258 } 259 260 public void glFrustumf(float left, float right, float bottom, float top, 261 float near, float far) { 262 mCurrent.glFrustumf(left, right, bottom, top, near, far); 263 mgl.glFrustumf(left, right, bottom, top, near, far); 264 if ( _check) check(); 265 } 266 267 public void glFrustumx(int left, int right, int bottom, int top, int near, 268 int far) { 269 mCurrent.glFrustumx(left, right, bottom, top, near, far); 270 mgl.glFrustumx(left, right, bottom, top, near, far); 271 if ( _check) check(); 272 } 273 274 public void glGenTextures(int n, int[] textures, int offset) { 275 mgl.glGenTextures(n, textures, offset); 276 } 277 278 public void glGenTextures(int n, IntBuffer textures) { 279 mgl.glGenTextures(n, textures); 280 } 281 282 public int glGetError() { 283 int result = mgl.glGetError(); 284 return result; 285 } 286 287 public void glGetIntegerv(int pname, int[] params, int offset) { 288 mgl.glGetIntegerv(pname, params, offset); 289 } 290 291 public void glGetIntegerv(int pname, IntBuffer params) { 292 mgl.glGetIntegerv(pname, params); 293 } 294 295 public String glGetString(int name) { 296 String result = mgl.glGetString(name); 297 return result; 298 } 299 300 public void glHint(int target, int mode) { 301 mgl.glHint(target, mode); 302 } 303 304 public void glLightModelf(int pname, float param) { 305 mgl.glLightModelf(pname, param); 306 } 307 308 public void glLightModelfv(int pname, float[] params, int offset) { 309 mgl.glLightModelfv(pname, params, offset); 310 } 311 312 public void glLightModelfv(int pname, FloatBuffer params) { 313 mgl.glLightModelfv(pname, params); 314 } 315 316 public void glLightModelx(int pname, int param) { 317 mgl.glLightModelx(pname, param); 318 } 319 320 public void glLightModelxv(int pname, int[] params, int offset) { 321 mgl.glLightModelxv(pname, params, offset); 322 } 323 324 public void glLightModelxv(int pname, IntBuffer params) { 325 mgl.glLightModelxv(pname, params); 326 } 327 328 public void glLightf(int light, int pname, float param) { 329 mgl.glLightf(light, pname, param); 330 } 331 332 public void glLightfv(int light, int pname, float[] params, int offset) { 333 mgl.glLightfv(light, pname, params, offset); 334 } 335 336 public void glLightfv(int light, int pname, FloatBuffer params) { 337 mgl.glLightfv(light, pname, params); 338 } 339 340 public void glLightx(int light, int pname, int param) { 341 mgl.glLightx(light, pname, param); 342 } 343 344 public void glLightxv(int light, int pname, int[] params, int offset) { 345 mgl.glLightxv(light, pname, params, offset); 346 } 347 348 public void glLightxv(int light, int pname, IntBuffer params) { 349 mgl.glLightxv(light, pname, params); 350 } 351 352 public void glLineWidth(float width) { 353 mgl.glLineWidth(width); 354 } 355 356 public void glLineWidthx(int width) { 357 mgl.glLineWidthx(width); 358 } 359 360 public void glLoadIdentity() { 361 mCurrent.glLoadIdentity(); 362 mgl.glLoadIdentity(); 363 if ( _check) check(); 364 } 365 366 public void glLoadMatrixf(float[] m, int offset) { 367 mCurrent.glLoadMatrixf(m, offset); 368 mgl.glLoadMatrixf(m, offset); 369 if ( _check) check(); 370 } 371 372 public void glLoadMatrixf(FloatBuffer m) { 373 int position = m.position(); 374 mCurrent.glLoadMatrixf(m); 375 m.position(position); 376 mgl.glLoadMatrixf(m); 377 if ( _check) check(); 378 } 379 380 public void glLoadMatrixx(int[] m, int offset) { 381 mCurrent.glLoadMatrixx(m, offset); 382 mgl.glLoadMatrixx(m, offset); 383 if ( _check) check(); 384 } 385 386 public void glLoadMatrixx(IntBuffer m) { 387 int position = m.position(); 388 mCurrent.glLoadMatrixx(m); 389 m.position(position); 390 mgl.glLoadMatrixx(m); 391 if ( _check) check(); 392 } 393 394 public void glLogicOp(int opcode) { 395 mgl.glLogicOp(opcode); 396 } 397 398 public void glMaterialf(int face, int pname, float param) { 399 mgl.glMaterialf(face, pname, param); 400 } 401 402 public void glMaterialfv(int face, int pname, float[] params, int offset) { 403 mgl.glMaterialfv(face, pname, params, offset); 404 } 405 406 public void glMaterialfv(int face, int pname, FloatBuffer params) { 407 mgl.glMaterialfv(face, pname, params); 408 } 409 410 public void glMaterialx(int face, int pname, int param) { 411 mgl.glMaterialx(face, pname, param); 412 } 413 414 public void glMaterialxv(int face, int pname, int[] params, int offset) { 415 mgl.glMaterialxv(face, pname, params, offset); 416 } 417 418 public void glMaterialxv(int face, int pname, IntBuffer params) { 419 mgl.glMaterialxv(face, pname, params); 420 } 421 422 public void glMatrixMode(int mode) { 423 switch (mode) { 424 case GL10.GL_MODELVIEW: 425 mCurrent = mModelView; 426 break; 427 case GL10.GL_TEXTURE: 428 mCurrent = mTexture; 429 break; 430 case GL10.GL_PROJECTION: 431 mCurrent = mProjection; 432 break; 433 default: 434 throw new IllegalArgumentException("Unknown matrix mode: " + mode); 435 } 436 mgl.glMatrixMode(mode); 437 mMatrixMode = mode; 438 if ( _check) check(); 439 } 440 441 public void glMultMatrixf(float[] m, int offset) { 442 mCurrent.glMultMatrixf(m, offset); 443 mgl.glMultMatrixf(m, offset); 444 if ( _check) check(); 445 } 446 447 public void glMultMatrixf(FloatBuffer m) { 448 int position = m.position(); 449 mCurrent.glMultMatrixf(m); 450 m.position(position); 451 mgl.glMultMatrixf(m); 452 if ( _check) check(); 453 } 454 455 public void glMultMatrixx(int[] m, int offset) { 456 mCurrent.glMultMatrixx(m, offset); 457 mgl.glMultMatrixx(m, offset); 458 if ( _check) check(); 459 } 460 461 public void glMultMatrixx(IntBuffer m) { 462 int position = m.position(); 463 mCurrent.glMultMatrixx(m); 464 m.position(position); 465 mgl.glMultMatrixx(m); 466 if ( _check) check(); 467 } 468 469 public void glMultiTexCoord4f(int target, 470 float s, float t, float r, float q) { 471 mgl.glMultiTexCoord4f(target, s, t, r, q); 472 } 473 474 public void glMultiTexCoord4x(int target, int s, int t, int r, int q) { 475 mgl.glMultiTexCoord4x(target, s, t, r, q); 476 } 477 478 public void glNormal3f(float nx, float ny, float nz) { 479 mgl.glNormal3f(nx, ny, nz); 480 } 481 482 public void glNormal3x(int nx, int ny, int nz) { 483 mgl.glNormal3x(nx, ny, nz); 484 } 485 486 public void glNormalPointer(int type, int stride, Buffer pointer) { 487 mgl.glNormalPointer(type, stride, pointer); 488 } 489 490 public void glOrthof(float left, float right, float bottom, float top, 491 float near, float far) { 492 mCurrent.glOrthof(left, right, bottom, top, near, far); 493 mgl.glOrthof(left, right, bottom, top, near, far); 494 if ( _check) check(); 495 } 496 497 public void glOrthox(int left, int right, int bottom, int top, int near, 498 int far) { 499 mCurrent.glOrthox(left, right, bottom, top, near, far); 500 mgl.glOrthox(left, right, bottom, top, near, far); 501 if ( _check) check(); 502 } 503 504 public void glPixelStorei(int pname, int param) { 505 mgl.glPixelStorei(pname, param); 506 } 507 508 public void glPointSize(float size) { 509 mgl.glPointSize(size); 510 } 511 512 public void glPointSizex(int size) { 513 mgl.glPointSizex(size); 514 } 515 516 public void glPolygonOffset(float factor, float units) { 517 mgl.glPolygonOffset(factor, units); 518 } 519 520 public void glPolygonOffsetx(int factor, int units) { 521 mgl.glPolygonOffsetx(factor, units); 522 } 523 524 public void glPopMatrix() { 525 mCurrent.glPopMatrix(); 526 mgl.glPopMatrix(); 527 if ( _check) check(); 528 } 529 530 public void glPushMatrix() { 531 mCurrent.glPushMatrix(); 532 mgl.glPushMatrix(); 533 if ( _check) check(); 534 } 535 536 public void glReadPixels(int x, int y, int width, int height, int format, 537 int type, Buffer pixels) { 538 mgl.glReadPixels(x, y, width, height, format, type, pixels); 539 } 540 541 public void glRotatef(float angle, float x, float y, float z) { 542 mCurrent.glRotatef(angle, x, y, z); 543 mgl.glRotatef(angle, x, y, z); 544 if ( _check) check(); 545 } 546 547 public void glRotatex(int angle, int x, int y, int z) { 548 mCurrent.glRotatex(angle, x, y, z); 549 mgl.glRotatex(angle, x, y, z); 550 if ( _check) check(); 551 } 552 553 public void glSampleCoverage(float value, boolean invert) { 554 mgl.glSampleCoverage(value, invert); 555 } 556 557 public void glSampleCoveragex(int value, boolean invert) { 558 mgl.glSampleCoveragex(value, invert); 559 } 560 561 public void glScalef(float x, float y, float z) { 562 mCurrent.glScalef(x, y, z); 563 mgl.glScalef(x, y, z); 564 if ( _check) check(); 565 } 566 567 public void glScalex(int x, int y, int z) { 568 mCurrent.glScalex(x, y, z); 569 mgl.glScalex(x, y, z); 570 if ( _check) check(); 571 } 572 573 public void glScissor(int x, int y, int width, int height) { 574 mgl.glScissor(x, y, width, height); 575 } 576 577 public void glShadeModel(int mode) { 578 mgl.glShadeModel(mode); 579 } 580 581 public void glStencilFunc(int func, int ref, int mask) { 582 mgl.glStencilFunc(func, ref, mask); 583 } 584 585 public void glStencilMask(int mask) { 586 mgl.glStencilMask(mask); 587 } 588 589 public void glStencilOp(int fail, int zfail, int zpass) { 590 mgl.glStencilOp(fail, zfail, zpass); 591 } 592 593 public void glTexCoordPointer(int size, int type, 594 int stride, Buffer pointer) { 595 mgl.glTexCoordPointer(size, type, stride, pointer); 596 } 597 598 public void glTexEnvf(int target, int pname, float param) { 599 mgl.glTexEnvf(target, pname, param); 600 } 601 602 public void glTexEnvfv(int target, int pname, float[] params, int offset) { 603 mgl.glTexEnvfv(target, pname, params, offset); 604 } 605 606 public void glTexEnvfv(int target, int pname, FloatBuffer params) { 607 mgl.glTexEnvfv(target, pname, params); 608 } 609 610 public void glTexEnvx(int target, int pname, int param) { 611 mgl.glTexEnvx(target, pname, param); 612 } 613 614 public void glTexEnvxv(int target, int pname, int[] params, int offset) { 615 mgl.glTexEnvxv(target, pname, params, offset); 616 } 617 618 public void glTexEnvxv(int target, int pname, IntBuffer params) { 619 mgl.glTexEnvxv(target, pname, params); 620 } 621 622 public void glTexImage2D(int target, int level, int internalformat, 623 int width, int height, int border, int format, int type, 624 Buffer pixels) { 625 mgl.glTexImage2D(target, level, internalformat, width, height, border, 626 format, type, pixels); 627 } 628 629 public void glTexParameterf(int target, int pname, float param) { 630 mgl.glTexParameterf(target, pname, param); 631 } 632 633 public void glTexParameterx(int target, int pname, int param) { 634 mgl.glTexParameterx(target, pname, param); 635 } 636 637 public void glTexParameteriv(int target, int pname, int[] params, int offset) { 638 mgl11.glTexParameteriv(target, pname, params, offset); 639 } 640 641 public void glTexParameteriv(int target, int pname, IntBuffer params) { 642 mgl11.glTexParameteriv(target, pname, params); 643 } 644 645 public void glTexSubImage2D(int target, int level, int xoffset, 646 int yoffset, int width, int height, int format, int type, 647 Buffer pixels) { 648 mgl.glTexSubImage2D(target, level, xoffset, yoffset, width, height, 649 format, type, pixels); 650 } 651 652 public void glTranslatef(float x, float y, float z) { 653 mCurrent.glTranslatef(x, y, z); 654 mgl.glTranslatef(x, y, z); 655 if ( _check) check(); 656 } 657 658 public void glTranslatex(int x, int y, int z) { 659 mCurrent.glTranslatex(x, y, z); 660 mgl.glTranslatex(x, y, z); 661 if ( _check) check(); 662 } 663 664 public void glVertexPointer(int size, int type, 665 int stride, Buffer pointer) { 666 mgl.glVertexPointer(size, type, stride, pointer); 667 } 668 669 public void glViewport(int x, int y, int width, int height) { 670 mgl.glViewport(x, y, width, height); 671 } 672 673 public void glClipPlanef(int plane, float[] equation, int offset) { 674 mgl11.glClipPlanef(plane, equation, offset); 675 } 676 677 public void glClipPlanef(int plane, FloatBuffer equation) { 678 mgl11.glClipPlanef(plane, equation); 679 } 680 681 public void glClipPlanex(int plane, int[] equation, int offset) { 682 mgl11.glClipPlanex(plane, equation, offset); 683 } 684 685 public void glClipPlanex(int plane, IntBuffer equation) { 686 mgl11.glClipPlanex(plane, equation); 687 } 688 689 // Draw Texture Extension 690 691 public void glDrawTexfOES(float x, float y, float z, 692 float width, float height) { 693 mgl11Ext.glDrawTexfOES(x, y, z, width, height); 694 } 695 696 public void glDrawTexfvOES(float[] coords, int offset) { 697 mgl11Ext.glDrawTexfvOES(coords, offset); 698 } 699 700 public void glDrawTexfvOES(FloatBuffer coords) { 701 mgl11Ext.glDrawTexfvOES(coords); 702 } 703 704 public void glDrawTexiOES(int x, int y, int z, int width, int height) { 705 mgl11Ext.glDrawTexiOES(x, y, z, width, height); 706 } 707 708 public void glDrawTexivOES(int[] coords, int offset) { 709 mgl11Ext.glDrawTexivOES(coords, offset); 710 } 711 712 public void glDrawTexivOES(IntBuffer coords) { 713 mgl11Ext.glDrawTexivOES(coords); 714 } 715 716 public void glDrawTexsOES(short x, short y, short z, 717 short width, short height) { 718 mgl11Ext.glDrawTexsOES(x, y, z, width, height); 719 } 720 721 public void glDrawTexsvOES(short[] coords, int offset) { 722 mgl11Ext.glDrawTexsvOES(coords, offset); 723 } 724 725 public void glDrawTexsvOES(ShortBuffer coords) { 726 mgl11Ext.glDrawTexsvOES(coords); 727 } 728 729 public void glDrawTexxOES(int x, int y, int z, int width, int height) { 730 mgl11Ext.glDrawTexxOES(x, y, z, width, height); 731 } 732 733 public void glDrawTexxvOES(int[] coords, int offset) { 734 mgl11Ext.glDrawTexxvOES(coords, offset); 735 } 736 737 public void glDrawTexxvOES(IntBuffer coords) { 738 mgl11Ext.glDrawTexxvOES(coords); 739 } 740 741 public int glQueryMatrixxOES(int[] mantissa, int mantissaOffset, 742 int[] exponent, int exponentOffset) { 743 return mgl10Ext.glQueryMatrixxOES(mantissa, mantissaOffset, 744 exponent, exponentOffset); 745 } 746 747 public int glQueryMatrixxOES(IntBuffer mantissa, IntBuffer exponent) { 748 return mgl10Ext.glQueryMatrixxOES(mantissa, exponent); 749 } 750 751 // Unsupported GL11 methods 752 753 public void glBindBuffer(int target, int buffer) { 754 throw new UnsupportedOperationException(); 755 } 756 757 public void glBufferData(int target, int size, Buffer data, int usage) { 758 throw new UnsupportedOperationException(); 759 } 760 761 public void glBufferSubData(int target, int offset, int size, Buffer data) { 762 throw new UnsupportedOperationException(); 763 } 764 765 public void glColor4ub(byte red, byte green, byte blue, byte alpha) { 766 throw new UnsupportedOperationException(); 767 } 768 769 public void glDeleteBuffers(int n, int[] buffers, int offset) { 770 throw new UnsupportedOperationException(); 771 } 772 773 public void glDeleteBuffers(int n, IntBuffer buffers) { 774 throw new UnsupportedOperationException(); 775 } 776 777 public void glGenBuffers(int n, int[] buffers, int offset) { 778 throw new UnsupportedOperationException(); 779 } 780 781 public void glGenBuffers(int n, IntBuffer buffers) { 782 throw new UnsupportedOperationException(); 783 } 784 785 public void glGetBooleanv(int pname, boolean[] params, int offset) { 786 throw new UnsupportedOperationException(); 787 } 788 789 public void glGetBooleanv(int pname, IntBuffer params) { 790 throw new UnsupportedOperationException(); 791 } 792 793 public void glGetBufferParameteriv(int target, int pname, int[] params, int offset) { 794 throw new UnsupportedOperationException(); 795 } 796 797 public void glGetBufferParameteriv(int target, int pname, IntBuffer params) { 798 throw new UnsupportedOperationException(); 799 } 800 801 public void glGetClipPlanef(int pname, float[] eqn, int offset) { 802 throw new UnsupportedOperationException(); 803 } 804 805 public void glGetClipPlanef(int pname, FloatBuffer eqn) { 806 throw new UnsupportedOperationException(); 807 } 808 809 public void glGetClipPlanex(int pname, int[] eqn, int offset) { 810 throw new UnsupportedOperationException(); 811 } 812 813 public void glGetClipPlanex(int pname, IntBuffer eqn) { 814 throw new UnsupportedOperationException(); 815 } 816 817 public void glGetFixedv(int pname, int[] params, int offset) { 818 throw new UnsupportedOperationException(); 819 } 820 821 public void glGetFixedv(int pname, IntBuffer params) { 822 throw new UnsupportedOperationException(); 823 } 824 825 public void glGetFloatv(int pname, float[] params, int offset) { 826 throw new UnsupportedOperationException(); 827 } 828 829 public void glGetFloatv(int pname, FloatBuffer params) { 830 throw new UnsupportedOperationException(); 831 } 832 833 public void glGetLightfv(int light, int pname, float[] params, int offset) { 834 throw new UnsupportedOperationException(); 835 } 836 837 public void glGetLightfv(int light, int pname, FloatBuffer params) { 838 throw new UnsupportedOperationException(); 839 } 840 841 public void glGetLightxv(int light, int pname, int[] params, int offset) { 842 throw new UnsupportedOperationException(); 843 } 844 845 public void glGetLightxv(int light, int pname, IntBuffer params) { 846 throw new UnsupportedOperationException(); 847 } 848 849 public void glGetMaterialfv(int face, int pname, float[] params, int offset) { 850 throw new UnsupportedOperationException(); 851 } 852 853 public void glGetMaterialfv(int face, int pname, FloatBuffer params) { 854 throw new UnsupportedOperationException(); 855 } 856 857 public void glGetMaterialxv(int face, int pname, int[] params, int offset) { 858 throw new UnsupportedOperationException(); 859 } 860 861 public void glGetMaterialxv(int face, int pname, IntBuffer params) { 862 throw new UnsupportedOperationException(); 863 } 864 865 public void glGetTexEnviv(int env, int pname, int[] params, int offset) { 866 throw new UnsupportedOperationException(); 867 } 868 869 public void glGetTexEnviv(int env, int pname, IntBuffer params) { 870 throw new UnsupportedOperationException(); 871 } 872 873 public void glGetTexEnvxv(int env, int pname, int[] params, int offset) { 874 throw new UnsupportedOperationException(); 875 } 876 877 public void glGetTexEnvxv(int env, int pname, IntBuffer params) { 878 throw new UnsupportedOperationException(); 879 } 880 881 public void glGetTexParameterfv(int target, int pname, float[] params, int offset) { 882 throw new UnsupportedOperationException(); 883 } 884 885 public void glGetTexParameterfv(int target, int pname, FloatBuffer params) { 886 throw new UnsupportedOperationException(); 887 } 888 889 public void glGetTexParameteriv(int target, int pname, int[] params, int offset) { 890 throw new UnsupportedOperationException(); 891 } 892 893 public void glGetTexParameteriv(int target, int pname, IntBuffer params) { 894 throw new UnsupportedOperationException(); 895 } 896 897 public void glGetTexParameterxv(int target, int pname, int[] params, int offset) { 898 throw new UnsupportedOperationException(); 899 } 900 901 public void glGetTexParameterxv(int target, int pname, IntBuffer params) { 902 throw new UnsupportedOperationException(); 903 } 904 905 public boolean glIsBuffer(int buffer) { 906 throw new UnsupportedOperationException(); 907 } 908 909 public boolean glIsEnabled(int cap) { 910 throw new UnsupportedOperationException(); 911 } 912 913 public boolean glIsTexture(int texture) { 914 throw new UnsupportedOperationException(); 915 } 916 917 public void glPointParameterf(int pname, float param) { 918 throw new UnsupportedOperationException(); 919 } 920 921 public void glPointParameterfv(int pname, float[] params, int offset) { 922 throw new UnsupportedOperationException(); 923 } 924 925 public void glPointParameterfv(int pname, FloatBuffer params) { 926 throw new UnsupportedOperationException(); 927 } 928 929 public void glPointParameterx(int pname, int param) { 930 throw new UnsupportedOperationException(); 931 } 932 933 public void glPointParameterxv(int pname, int[] params, int offset) { 934 throw new UnsupportedOperationException(); 935 } 936 937 public void glPointParameterxv(int pname, IntBuffer params) { 938 throw new UnsupportedOperationException(); 939 } 940 941 public void glPointSizePointerOES(int type, int stride, Buffer pointer) { 942 throw new UnsupportedOperationException(); 943 } 944 945 public void glTexEnvi(int target, int pname, int param) { 946 throw new UnsupportedOperationException(); 947 } 948 949 public void glTexEnviv(int target, int pname, int[] params, int offset) { 950 throw new UnsupportedOperationException(); 951 } 952 953 public void glTexEnviv(int target, int pname, IntBuffer params) { 954 throw new UnsupportedOperationException(); 955 } 956 957 public void glTexParameterfv(int target, int pname, float[] params, int offset) { 958 throw new UnsupportedOperationException(); 959 } 960 961 public void glTexParameterfv(int target, int pname, FloatBuffer params) { 962 throw new UnsupportedOperationException(); 963 } 964 965 public void glTexParameteri(int target, int pname, int param) { 966 throw new UnsupportedOperationException(); 967 } 968 969 public void glTexParameterxv(int target, int pname, int[] params, int offset) { 970 throw new UnsupportedOperationException(); 971 } 972 973 public void glTexParameterxv(int target, int pname, IntBuffer params) { 974 throw new UnsupportedOperationException(); 975 } 976 977 public void glColorPointer(int size, int type, int stride, int offset) { 978 throw new UnsupportedOperationException(); 979 } 980 981 public void glDrawElements(int mode, int count, int type, int offset) { 982 throw new UnsupportedOperationException(); 983 } 984 985 public void glGetPointerv(int pname, Buffer[] params) { 986 throw new UnsupportedOperationException(); 987 } 988 989 public void glNormalPointer(int type, int stride, int offset) { 990 throw new UnsupportedOperationException(); 991 } 992 993 public void glTexCoordPointer(int size, int type, int stride, int offset) { 994 throw new UnsupportedOperationException(); 995 } 996 997 public void glVertexPointer(int size, int type, int stride, int offset) { 998 throw new UnsupportedOperationException(); 999 } 1000 1001 public void glCurrentPaletteMatrixOES(int matrixpaletteindex) { 1002 throw new UnsupportedOperationException(); 1003 } 1004 1005 public void glLoadPaletteFromModelViewMatrixOES() { 1006 throw new UnsupportedOperationException(); 1007 } 1008 1009 public void glMatrixIndexPointerOES(int size, int type, int stride, 1010 Buffer pointer) { 1011 throw new UnsupportedOperationException(); 1012 } 1013 1014 public void glMatrixIndexPointerOES(int size, int type, int stride, 1015 int offset) { 1016 throw new UnsupportedOperationException(); 1017 } 1018 1019 public void glWeightPointerOES(int size, int type, int stride, 1020 Buffer pointer) { 1021 throw new UnsupportedOperationException(); 1022 } 1023 1024 public void glWeightPointerOES(int size, int type, int stride, int offset) { 1025 throw new UnsupportedOperationException(); 1026 } 1027 1028 /** 1029 * Get the current matrix 1030 */ 1031 1032 public void getMatrix(float[] m, int offset) { 1033 mCurrent.getMatrix(m, offset); 1034 } 1035 1036 /** 1037 * Get the current matrix mode 1038 */ 1039 1040 public int getMatrixMode() { 1041 return mMatrixMode; 1042 } 1043 1044 private void check() { 1045 int oesMode; 1046 switch (mMatrixMode) { 1047 case GL_MODELVIEW: 1048 oesMode = GL11.GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES; 1049 break; 1050 case GL_PROJECTION: 1051 oesMode = GL11.GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES; 1052 break; 1053 case GL_TEXTURE: 1054 oesMode = GL11.GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES; 1055 break; 1056 default: 1057 throw new IllegalArgumentException("Unknown matrix mode"); 1058 } 1059 1060 if ( mByteBuffer == null) { 1061 mCheckA = new float[16]; 1062 mCheckB = new float[16]; 1063 mByteBuffer = ByteBuffer.allocateDirect(64); 1064 mByteBuffer.order(ByteOrder.nativeOrder()); 1065 mFloatBuffer = mByteBuffer.asFloatBuffer(); 1066 } 1067 mgl.glGetIntegerv(oesMode, mByteBuffer.asIntBuffer()); 1068 for(int i = 0; i < 16; i++) { 1069 mCheckB[i] = mFloatBuffer.get(i); 1070 } 1071 mCurrent.getMatrix(mCheckA, 0); 1072 1073 boolean fail = false; 1074 for(int i = 0; i < 16; i++) { 1075 if (mCheckA[i] != mCheckB[i]) { 1076 Log.d("GLMatWrap", "i:" + i + " a:" + mCheckA[i] 1077 + " a:" + mCheckB[i]); 1078 fail = true; 1079 } 1080 } 1081 if (fail) { 1082 throw new IllegalArgumentException("Matrix math difference."); 1083 } 1084 } 1085 1086 } 1087