⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrixtrackinggl.java

📁 android 例子中的确良ApiDemos。很有代表意义
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.example.android.apis.graphics.spritetext;import android.util.Log;import java.nio.Buffer;import java.nio.ByteBuffer;import java.nio.ByteOrder;import java.nio.FloatBuffer;import java.nio.IntBuffer;import java.nio.ShortBuffer;import javax.microedition.khronos.opengles.GL;import javax.microedition.khronos.opengles.GL10;import javax.microedition.khronos.opengles.GL10Ext;import javax.microedition.khronos.opengles.GL11;import javax.microedition.khronos.opengles.GL11Ext;/** * Allows retrieving the current matrix even if the current OpenGL ES * driver does not support retrieving the current matrix. * * Note: the actual matrix may differ from the retrieved matrix, due * to differences in the way the math is implemented by GLMatrixWrapper * as compared to the way the math is implemented by the OpenGL ES * driver. */class MatrixTrackingGL implements GL, GL10, GL10Ext, GL11, GL11Ext {    private GL10 mgl;    private GL10Ext mgl10Ext;    private GL11 mgl11;    private GL11Ext mgl11Ext;    private int mMatrixMode;    private MatrixStack mCurrent;    private MatrixStack mModelView;    private MatrixStack mTexture;    private MatrixStack mProjection;    private final static boolean _check = false;    ByteBuffer mByteBuffer;    FloatBuffer mFloatBuffer;    float[] mCheckA;    float[] mCheckB;    public MatrixTrackingGL(GL gl) {        mgl = (GL10) gl;        if (gl instanceof GL10Ext) {            mgl10Ext = (GL10Ext) gl;        }        if (gl instanceof GL11) {            mgl11 = (GL11) gl;        }        if (gl instanceof GL11Ext) {            mgl11Ext = (GL11Ext) gl;        }        mModelView = new MatrixStack();        mProjection = new MatrixStack();        mTexture = new MatrixStack();        mCurrent = mModelView;        mMatrixMode = GL10.GL_MODELVIEW;    }    // ---------------------------------------------------------------------    // GL10 methods:    public void glActiveTexture(int texture) {        mgl.glActiveTexture(texture);    }    public void glAlphaFunc(int func, float ref) {        mgl.glAlphaFunc(func, ref);    }    public void glAlphaFuncx(int func, int ref) {        mgl.glAlphaFuncx(func, ref);    }    public void glBindTexture(int target, int texture) {        mgl.glBindTexture(target, texture);    }    public void glBlendFunc(int sfactor, int dfactor) {        mgl.glBlendFunc(sfactor, dfactor);    }    public void glClear(int mask) {        mgl.glClear(mask);    }    public void glClearColor(float red, float green, float blue, float alpha) {        mgl.glClearColor(red, green, blue, alpha);    }    public void glClearColorx(int red, int green, int blue, int alpha) {        mgl.glClearColorx(red, green, blue, alpha);    }    public void glClearDepthf(float depth) {        mgl.glClearDepthf(depth);    }    public void glClearDepthx(int depth) {        mgl.glClearDepthx(depth);    }    public void glClearStencil(int s) {        mgl.glClearStencil(s);    }    public void glClientActiveTexture(int texture) {        mgl.glClientActiveTexture(texture);    }    public void glColor4f(float red, float green, float blue, float alpha) {        mgl.glColor4f(red, green, blue, alpha);    }    public void glColor4x(int red, int green, int blue, int alpha) {        mgl.glColor4x(red, green, blue, alpha);    }    public void glColorMask(boolean red, boolean green, boolean blue,            boolean alpha) {        mgl.glColorMask(red, green, blue, alpha);    }    public void glColorPointer(int size, int type, int stride, Buffer pointer) {        mgl.glColorPointer(size, type, stride, pointer);    }    public void glCompressedTexImage2D(int target, int level,            int internalformat, int width, int height, int border,            int imageSize, Buffer data) {        mgl.glCompressedTexImage2D(target, level, internalformat, width,                height, border, imageSize, data);    }    public void glCompressedTexSubImage2D(int target, int level, int xoffset,            int yoffset, int width, int height, int format, int imageSize,            Buffer data) {        mgl.glCompressedTexSubImage2D(target, level, xoffset, yoffset, width,                height, format, imageSize, data);    }    public void glCopyTexImage2D(int target, int level, int internalformat,            int x, int y, int width, int height, int border) {        mgl.glCopyTexImage2D(target, level, internalformat, x, y, width,                height, border);    }    public void glCopyTexSubImage2D(int target, int level, int xoffset,            int yoffset, int x, int y, int width, int height) {        mgl.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width,                height);    }    public void glCullFace(int mode) {        mgl.glCullFace(mode);    }    public void glDeleteTextures(int n, int[] textures, int offset) {        mgl.glDeleteTextures(n, textures, offset);    }    public void glDeleteTextures(int n, IntBuffer textures) {        mgl.glDeleteTextures(n, textures);    }    public void glDepthFunc(int func) {        mgl.glDepthFunc(func);    }    public void glDepthMask(boolean flag) {        mgl.glDepthMask(flag);    }    public void glDepthRangef(float near, float far) {        mgl.glDepthRangef(near, far);    }    public void glDepthRangex(int near, int far) {        mgl.glDepthRangex(near, far);    }    public void glDisable(int cap) {        mgl.glDisable(cap);    }    public void glDisableClientState(int array) {        mgl.glDisableClientState(array);    }    public void glDrawArrays(int mode, int first, int count) {        mgl.glDrawArrays(mode, first, count);    }    public void glDrawElements(int mode, int count, int type, Buffer indices) {        mgl.glDrawElements(mode, count, type, indices);    }    public void glEnable(int cap) {        mgl.glEnable(cap);    }    public void glEnableClientState(int array) {        mgl.glEnableClientState(array);    }    public void glFinish() {        mgl.glFinish();    }    public void glFlush() {        mgl.glFlush();    }    public void glFogf(int pname, float param) {        mgl.glFogf(pname, param);    }    public void glFogfv(int pname, float[] params, int offset) {        mgl.glFogfv(pname, params, offset);    }    public void glFogfv(int pname, FloatBuffer params) {        mgl.glFogfv(pname, params);    }    public void glFogx(int pname, int param) {        mgl.glFogx(pname, param);    }    public void glFogxv(int pname, int[] params, int offset) {        mgl.glFogxv(pname, params, offset);    }    public void glFogxv(int pname, IntBuffer params) {        mgl.glFogxv(pname, params);    }    public void glFrontFace(int mode) {        mgl.glFrontFace(mode);    }    public void glFrustumf(float left, float right, float bottom, float top,            float near, float far) {        mCurrent.glFrustumf(left, right, bottom, top, near, far);        mgl.glFrustumf(left, right, bottom, top, near, far);        if ( _check) check();    }    public void glFrustumx(int left, int right, int bottom, int top, int near,            int far) {        mCurrent.glFrustumx(left, right, bottom, top, near, far);        mgl.glFrustumx(left, right, bottom, top, near, far);        if ( _check) check();    }    public void glGenTextures(int n, int[] textures, int offset) {        mgl.glGenTextures(n, textures, offset);    }    public void glGenTextures(int n, IntBuffer textures) {        mgl.glGenTextures(n, textures);    }    public int glGetError() {        int result = mgl.glGetError();        return result;    }    public void glGetIntegerv(int pname, int[] params, int offset) {        mgl.glGetIntegerv(pname, params, offset);    }    public void glGetIntegerv(int pname, IntBuffer params) {        mgl.glGetIntegerv(pname, params);    }    public String glGetString(int name) {        String result = mgl.glGetString(name);        return result;    }    public void glHint(int target, int mode) {        mgl.glHint(target, mode);    }    public void glLightModelf(int pname, float param) {        mgl.glLightModelf(pname, param);    }    public void glLightModelfv(int pname, float[] params, int offset) {        mgl.glLightModelfv(pname, params, offset);    }    public void glLightModelfv(int pname, FloatBuffer params) {        mgl.glLightModelfv(pname, params);    }    public void glLightModelx(int pname, int param) {        mgl.glLightModelx(pname, param);    }    public void glLightModelxv(int pname, int[] params, int offset) {        mgl.glLightModelxv(pname, params, offset);    }    public void glLightModelxv(int pname, IntBuffer params) {        mgl.glLightModelxv(pname, params);    }    public void glLightf(int light, int pname, float param) {        mgl.glLightf(light, pname, param);    }    public void glLightfv(int light, int pname, float[] params, int offset) {        mgl.glLightfv(light, pname, params, offset);    }    public void glLightfv(int light, int pname, FloatBuffer params) {        mgl.glLightfv(light, pname, params);    }    public void glLightx(int light, int pname, int param) {        mgl.glLightx(light, pname, param);    }    public void glLightxv(int light, int pname, int[] params, int offset) {        mgl.glLightxv(light, pname, params, offset);    }    public void glLightxv(int light, int pname, IntBuffer params) {        mgl.glLightxv(light, pname, params);    }    public void glLineWidth(float width) {        mgl.glLineWidth(width);    }    public void glLineWidthx(int width) {        mgl.glLineWidthx(width);    }    public void glLoadIdentity() {        mCurrent.glLoadIdentity();        mgl.glLoadIdentity();        if ( _check) check();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -