156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall/*
256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* Copyright (C) 2011 The Android Open Source Project
356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall*
456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* Licensed under the Apache License, Version 2.0 (the "License");
556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* you may not use this file except in compliance with the License.
656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* You may obtain a copy of the License at
756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall*
856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* http://www.apache.org/licenses/LICENSE-2.0
956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall*
1056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* Unless required by applicable law or agreed to in writing, software
1156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* distributed under the License is distributed on an "AS IS" BASIS,
1256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* See the License for the specific language governing permissions and
1456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall* limitations under the License.
1556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall*/
1656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#ifndef _GL_CLIENT_STATE_H_
1756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#define _GL_CLIENT_STATE_H_
1856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
1956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#define GL_API
2056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#ifndef ANDROID
2156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#define GL_APIENTRY
2256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#define GL_APIENTRYP
2356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#endif
2456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
2556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include <GLES/gl.h>
2656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include <GLES/glext.h>
2756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include <GLES2/gl2.h>
2856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include <GLES2/gl2ext.h>
2956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
3056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include <stdio.h>
3156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include <stdlib.h>
3256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include "ErrorLog.h"
3356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall#include "codec_defs.h"
3456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
3556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hallclass GLClientState {
3656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hallpublic:
3756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    typedef enum {
3856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        VERTEX_LOCATION = 0,
3956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        NORMAL_LOCATION = 1,
4056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        COLOR_LOCATION = 2,
4156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        POINTSIZE_LOCATION = 3,
4256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD0_LOCATION = 4,
4356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD1_LOCATION = 5,
4456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD2_LOCATION = 6,
4556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD3_LOCATION = 7,
4656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD4_LOCATION = 8,
4756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD5_LOCATION = 9,
4856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD6_LOCATION = 10,
4956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXCOORD7_LOCATION = 11,
5056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        MATRIXINDEX_LOCATION = 12,
5156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        WEIGHT_LOCATION = 13,
5256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        LAST_LOCATION = 14
5356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    } StateLocation;
5456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
5556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    typedef struct {
5656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLint enabled;
5756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLint size;
5856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLenum type;
5956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLsizei stride;
6056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        void *data;
6156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLuint bufferObject;
6256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLenum glConst;
6356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        unsigned int elementSize;
6456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        bool enableDirty;  // true if any enable state has changed since last draw
6556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        bool normalized;
6656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    } VertexAttribState;
6756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
6856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    typedef struct {
6956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        int unpack_alignment;
7056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        int pack_alignment;
7156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    } PixelStoreState;
7256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
7356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    enum {
7456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        MAX_TEXTURE_UNITS = 32,
7556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    };
7656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
7756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hallpublic:
7856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLClientState(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES);
7956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    ~GLClientState();
8056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int nLocations() { return m_nLocations; }
8156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    const PixelStoreState *pixelStoreState() { return &m_pixelStore; }
8256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int setPixelStore(GLenum param, GLint value);
8356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLuint currentArrayVbo() { return m_currentArrayVbo; }
8456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLuint currentIndexVbo() { return m_currentIndexVbo; }
8556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void enable(int location, int state);
8656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void setState(int  location, int size, GLenum type, GLboolean normalized, GLsizei stride, const void *data);
8756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void setBufferObject(int location, GLuint id);
8856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    const VertexAttribState  *getState(int location);
8956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    const VertexAttribState  *getStateAndEnableDirty(int location, bool *enableChanged);
9056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int getLocation(GLenum loc);
9156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void setActiveTexture(int texUnit) {m_activeTexture = texUnit; };
9256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int getActiveTexture() const { return m_activeTexture; }
9356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
9456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int bindBuffer(GLenum target, GLuint id)
9556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    {
9656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        int err = 0;
9756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        switch(target) {
9856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        case GL_ARRAY_BUFFER:
9956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall            m_currentArrayVbo = id;
10056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall            break;
10156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        case GL_ELEMENT_ARRAY_BUFFER:
10256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall            m_currentIndexVbo = id;
10356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall            break;
10456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        default:
10556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall            err = -1;
10656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        }
10756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        return err;
10856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    }
10956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
11056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int getBuffer(GLenum target)
11156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    {
11256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall      int ret=0;
11356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall      switch (target) {
11456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall      case GL_ARRAY_BUFFER:
11556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall          ret = m_currentArrayVbo;
11656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall          break;
11756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall      case GL_ELEMENT_ARRAY_BUFFER:
11856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall          ret = m_currentIndexVbo;
11956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall          break;
12056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall      default:
12156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall          ret = -1;
12256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall      }
12356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall      return ret;
12456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    }
12556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const;
12656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
12756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void setCurrentProgram(GLint program) { m_currentProgram = program; }
12856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLint currentProgram() const { return m_currentProgram; }
12956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
13056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    /* OES_EGL_image_external
13156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     *
13256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     * These functions manipulate GL state which interacts with the
13356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     * OES_EGL_image_external extension, to support client-side emulation on
13456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     * top of host implementations that don't have it.
13556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     *
13656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     * Most of these calls should only be used with TEXTURE_2D or
13756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     * TEXTURE_EXTERNAL_OES texture targets; TEXTURE_CUBE_MAP or other extension
13856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     * targets should bypass this. An exception is bindTexture(), which should
13956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     * see all glBindTexture() calls for any target.
14056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall     */
14156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
14256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // glActiveTexture(GL_TEXTURE0 + i)
14356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // Sets the active texture unit. Up to MAX_TEXTURE_UNITS are supported.
14456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLenum setActiveTextureUnit(GLenum texture);
14556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLenum getActiveTextureUnit() const;
14656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
14756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // glEnable(GL_TEXTURE_(2D|EXTERNAL_OES))
14856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void enableTextureTarget(GLenum target);
14956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
15056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // glDisable(GL_TEXTURE_(2D|EXTERNAL_OES))
15156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void disableTextureTarget(GLenum target);
15256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
15356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // Implements the target priority logic:
15456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // * Return GL_TEXTURE_EXTERNAL_OES if enabled, else
15556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // * Return GL_TEXTURE_2D if enabled, else
15656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // * Return the allDisabled value.
15756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // For some cases passing GL_TEXTURE_2D for allDisabled makes callee code
15856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // simpler; for other cases passing a recognizable enum like GL_ZERO or
15956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // GL_INVALID_ENUM is appropriate.
16056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLenum getPriorityEnabledTarget(GLenum allDisabled) const;
16156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
16256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // glBindTexture(GL_TEXTURE_*, ...)
16356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // Set the target binding of the active texture unit to texture. Returns
16456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // GL_NO_ERROR on success or GL_INVALID_OPERATION if the texture has
16556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // previously been bound to a different target. If firstUse is not NULL,
16656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // it is set to indicate whether this is the first use of the texture.
16756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // For accurate error detection, bindTexture should be called for *all*
16856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // targets, not just 2D and EXTERNAL_OES.
16956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLenum bindTexture(GLenum target, GLuint texture, GLboolean* firstUse);
17056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
17156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // Return the texture currently bound to GL_TEXTURE_(2D|EXTERNAL_OES).
17256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLuint getBoundTexture(GLenum target) const;
17356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
17456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // glDeleteTextures(...)
17556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    // Remove references to the to-be-deleted textures.
17656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void deleteTextures(GLsizei n, const GLuint* textures);
17756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
17856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hallprivate:
17956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    PixelStoreState m_pixelStore;
18056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    VertexAttribState *m_states;
18156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int m_nLocations;
18256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLuint m_currentArrayVbo;
18356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLuint m_currentIndexVbo;
18456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int m_activeTexture;
18556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    GLint m_currentProgram;
18656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
18756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    bool validLocation(int location) { return (location >= 0 && location < m_nLocations); }
18856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
18956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    enum TextureTarget {
19056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXTURE_2D = 0,
19156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXTURE_EXTERNAL = 1,
19256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TEXTURE_TARGET_COUNT
19356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    };
19456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    struct TextureUnit {
19556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        unsigned int enables;
19656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLuint texture[TEXTURE_TARGET_COUNT];
19756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    };
19856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    struct TextureRec {
19956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLuint id;
20056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLenum target;
20156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    };
20256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    struct TextureState {
20356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TextureUnit unit[MAX_TEXTURE_UNITS];
20456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TextureUnit* activeUnit;
20556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        TextureRec* textures;
20656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLuint numTextures;
20756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall        GLuint allocTextures;
20856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    };
20956513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    TextureState m_tex;
21056513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
21156513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    static int compareTexId(const void* pid, const void* prec);
21256513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    TextureRec* addTextureRec(GLuint id, GLenum target);
21356513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
21456513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hallpublic:
21556513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    void getClientStatePointer(GLenum pname, GLvoid** params);
21656513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall
21756513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    template <class T>
21856513f5ff4f3e851c5f0cb38dc8851d18616b3c0Jesse Hall    int getVertexAttribParameter(GLuint index, GLenum param, T *ptr)
219