aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl/system/GLESv2_enc
diff options
context:
space:
mode:
Diffstat (limited to 'emulator/opengl/system/GLESv2_enc')
-rw-r--r--emulator/opengl/system/GLESv2_enc/Android.mk18
-rw-r--r--emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp1197
-rw-r--r--emulator/opengl/system/GLESv2_enc/GL2Encoder.h216
-rw-r--r--emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp39
-rw-r--r--emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.h24
-rw-r--r--emulator/opengl/system/GLESv2_enc/gl2.attrib590
-rw-r--r--emulator/opengl/system/GLESv2_enc/gl2.in214
-rw-r--r--emulator/opengl/system/GLESv2_enc/gl2.types37
-rw-r--r--emulator/opengl/system/GLESv2_enc/gl2_types.h21
9 files changed, 2356 insertions, 0 deletions
diff --git a/emulator/opengl/system/GLESv2_enc/Android.mk b/emulator/opengl/system/GLESv2_enc/Android.mk
new file mode 100644
index 0000000..2a4d2f4
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/Android.mk
@@ -0,0 +1,18 @@
+LOCAL_PATH := $(call my-dir)
+
+### GLESv2_enc Encoder ###########################################
+$(call emugl-begin-shared-library,libGLESv2_enc)
+
+LOCAL_SRC_FILES := \
+ GL2EncoderUtils.cpp \
+ GL2Encoder.cpp
+
+LOCAL_CFLAGS += -DLOG_TAG=\"emuglGLESv2_enc\"
+
+$(call emugl-gen-encoder,$(LOCAL_PATH),gl2)
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+$(call emugl-import,libOpenglCodecCommon)
+
+$(call emugl-end-module)
+
+
diff --git a/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp b/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp
new file mode 100644
index 0000000..d8fedf3
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/GL2Encoder.cpp
@@ -0,0 +1,1197 @@
+/*
+* Copyright (C) 2011 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.
+*/
+
+#include "GL2Encoder.h"
+#include <assert.h>
+#include <ctype.h>
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+static GLubyte *gVendorString= (GLubyte *) "Android";
+static GLubyte *gRendererString= (GLubyte *) "Android HW-GLES 2.0";
+static GLubyte *gVersionString= (GLubyte *) "OpenGL ES 2.0";
+static GLubyte *gExtensionsString= (GLubyte *) ""; // no extensions at this point;
+
+#define SET_ERROR_IF(condition,err) if((condition)) { \
+ ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+ ctx->setError(err); \
+ return; \
+ }
+
+
+#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) { \
+ ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
+ ctx->setError(err); \
+ return ret; \
+ }
+
+
+GL2Encoder::GL2Encoder(IOStream *stream) : gl2_encoder_context_t(stream)
+{
+ m_initialized = false;
+ m_state = NULL;
+ m_error = GL_NO_ERROR;
+ m_num_compressedTextureFormats = 0;
+ m_compressedTextureFormats = NULL;
+ //overrides
+ m_glFlush_enc = set_glFlush(s_glFlush);
+ m_glPixelStorei_enc = set_glPixelStorei(s_glPixelStorei);
+ m_glGetString_enc = set_glGetString(s_glGetString);
+ m_glBindBuffer_enc = set_glBindBuffer(s_glBindBuffer);
+ m_glBufferData_enc = set_glBufferData(s_glBufferData);
+ m_glBufferSubData_enc = set_glBufferSubData(s_glBufferSubData);
+ m_glDeleteBuffers_enc = set_glDeleteBuffers(s_glDeleteBuffers);
+ m_glDrawArrays_enc = set_glDrawArrays(s_glDrawArrays);
+ m_glDrawElements_enc = set_glDrawElements(s_glDrawElements);
+ m_glGetIntegerv_enc = set_glGetIntegerv(s_glGetIntegerv);
+ m_glGetFloatv_enc = set_glGetFloatv(s_glGetFloatv);
+ m_glGetBooleanv_enc = set_glGetBooleanv(s_glGetBooleanv);
+ m_glVertexAttribPointer_enc = set_glVertexAttribPointer(s_glVertexAtrribPointer);
+ m_glEnableVertexAttribArray_enc = set_glEnableVertexAttribArray(s_glEnableVertexAttribArray);
+ m_glDisableVertexAttribArray_enc = set_glDisableVertexAttribArray(s_glDisableVertexAttribArray);
+ m_glGetVertexAttribiv_enc = set_glGetVertexAttribiv(s_glGetVertexAttribiv);
+ m_glGetVertexAttribfv_enc = set_glGetVertexAttribfv(s_glGetVertexAttribfv);
+ m_glGetVertexAttribPointerv = set_glGetVertexAttribPointerv(s_glGetVertexAttribPointerv);
+ set_glShaderSource(s_glShaderSource);
+ set_glFinish(s_glFinish);
+ m_glGetError_enc = set_glGetError(s_glGetError);
+ m_glLinkProgram_enc = set_glLinkProgram(s_glLinkProgram);
+ m_glDeleteProgram_enc = set_glDeleteProgram(s_glDeleteProgram);
+ m_glGetUniformiv_enc = set_glGetUniformiv(s_glGetUniformiv);
+ m_glGetUniformfv_enc = set_glGetUniformfv(s_glGetUniformfv);
+ m_glCreateProgram_enc = set_glCreateProgram(s_glCreateProgram);
+ m_glCreateShader_enc = set_glCreateShader(s_glCreateShader);
+ m_glDeleteShader_enc = set_glDeleteShader(s_glDeleteShader);
+ m_glAttachShader_enc = set_glAttachShader(s_glAttachShader);
+ m_glDetachShader_enc = set_glDetachShader(s_glDetachShader);
+ m_glGetUniformLocation_enc = set_glGetUniformLocation(s_glGetUniformLocation);
+ m_glUseProgram_enc = set_glUseProgram(s_glUseProgram);
+
+ m_glUniform1f_enc = set_glUniform1f(s_glUniform1f);
+ m_glUniform1fv_enc = set_glUniform1fv(s_glUniform1fv);
+ m_glUniform1i_enc = set_glUniform1i(s_glUniform1i);
+ m_glUniform1iv_enc = set_glUniform1iv(s_glUniform1iv);
+ m_glUniform2f_enc = set_glUniform2f(s_glUniform2f);
+ m_glUniform2fv_enc = set_glUniform2fv(s_glUniform2fv);
+ m_glUniform2i_enc = set_glUniform2i(s_glUniform2i);
+ m_glUniform2iv_enc = set_glUniform2iv(s_glUniform2iv);
+ m_glUniform3f_enc = set_glUniform3f(s_glUniform3f);
+ m_glUniform3fv_enc = set_glUniform3fv(s_glUniform3fv);
+ m_glUniform3i_enc = set_glUniform3i(s_glUniform3i);
+ m_glUniform3iv_enc = set_glUniform3iv(s_glUniform3iv);
+ m_glUniform4f_enc = set_glUniform4f(s_glUniform4f);
+ m_glUniform4fv_enc = set_glUniform4fv(s_glUniform4fv);
+ m_glUniform4i_enc = set_glUniform4i(s_glUniform4i);
+ m_glUniform4iv_enc = set_glUniform4iv(s_glUniform4iv);
+ m_glUniformMatrix2fv_enc = set_glUniformMatrix2fv(s_glUniformMatrix2fv);
+ m_glUniformMatrix3fv_enc = set_glUniformMatrix3fv(s_glUniformMatrix3fv);
+ m_glUniformMatrix4fv_enc = set_glUniformMatrix4fv(s_glUniformMatrix4fv);
+
+ m_glActiveTexture_enc = set_glActiveTexture(s_glActiveTexture);
+ m_glBindTexture_enc = set_glBindTexture(s_glBindTexture);
+ m_glDeleteTextures_enc = set_glDeleteTextures(s_glDeleteTextures);
+ m_glGetTexParameterfv_enc = set_glGetTexParameterfv(s_glGetTexParameterfv);
+ m_glGetTexParameteriv_enc = set_glGetTexParameteriv(s_glGetTexParameteriv);
+ m_glTexParameterf_enc = set_glTexParameterf(s_glTexParameterf);
+ m_glTexParameterfv_enc = set_glTexParameterfv(s_glTexParameterfv);
+ m_glTexParameteri_enc = set_glTexParameteri(s_glTexParameteri);
+ m_glTexParameteriv_enc = set_glTexParameteriv(s_glTexParameteriv);
+}
+
+GL2Encoder::~GL2Encoder()
+{
+ delete m_compressedTextureFormats;
+}
+
+GLenum GL2Encoder::s_glGetError(void * self)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ GLenum err = ctx->getError();
+ if(err != GL_NO_ERROR) {
+ ctx->setError(GL_NO_ERROR);
+ return err;
+ }
+
+ return ctx->m_glGetError_enc(self);
+
+}
+
+void GL2Encoder::s_glFlush(void *self)
+{
+ GL2Encoder *ctx = (GL2Encoder *) self;
+ ctx->m_glFlush_enc(self);
+ ctx->m_stream->flush();
+}
+
+const GLubyte *GL2Encoder::s_glGetString(void *self, GLenum name)
+{
+ GLubyte *retval = (GLubyte *) "";
+ switch(name) {
+ case GL_VENDOR:
+ retval = gVendorString;
+ break;
+ case GL_RENDERER:
+ retval = gRendererString;
+ break;
+ case GL_VERSION:
+ retval = gVersionString;
+ break;
+ case GL_EXTENSIONS:
+ retval = gExtensionsString;
+ break;
+ }
+ return retval;
+}
+
+void GL2Encoder::s_glPixelStorei(void *self, GLenum param, GLint value)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ ctx->m_glPixelStorei_enc(ctx, param, value);
+ assert(ctx->m_state != NULL);
+ ctx->m_state->setPixelStore(param, value);
+}
+
+
+void GL2Encoder::s_glBindBuffer(void *self, GLenum target, GLuint id)
+{
+ GL2Encoder *ctx = (GL2Encoder *) self;
+ assert(ctx->m_state != NULL);
+ ctx->m_state->bindBuffer(target, id);
+ // TODO set error state if needed;
+ ctx->m_glBindBuffer_enc(self, target, id);
+}
+
+void GL2Encoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage)
+{
+ GL2Encoder *ctx = (GL2Encoder *) self;
+ GLuint bufferId = ctx->m_state->getBuffer(target);
+ SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
+ SET_ERROR_IF(size<0, GL_INVALID_VALUE);
+
+ ctx->m_shared->updateBufferData(bufferId, size, (void*)data);
+ ctx->m_glBufferData_enc(self, target, size, data, usage);
+}
+
+void GL2Encoder::s_glBufferSubData(void * self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data)
+{
+ GL2Encoder *ctx = (GL2Encoder *) self;
+ GLuint bufferId = ctx->m_state->getBuffer(target);
+ SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION);
+
+ GLenum res = ctx->m_shared->subUpdateBufferData(bufferId, offset, size, (void*)data);
+ SET_ERROR_IF(res, res);
+
+ ctx->m_glBufferSubData_enc(self, target, offset, size, data);
+}
+
+void GL2Encoder::s_glDeleteBuffers(void * self, GLsizei n, const GLuint * buffers)
+{
+ GL2Encoder *ctx = (GL2Encoder *) self;
+ SET_ERROR_IF(n<0, GL_INVALID_VALUE);
+ for (int i=0; i<n; i++) {
+ ctx->m_shared->deleteBufferData(buffers[i]);
+ ctx->m_glDeleteBuffers_enc(self,1,&buffers[i]);
+ }
+}
+
+void GL2Encoder::s_glVertexAtrribPointer(void *self, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * ptr)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state != NULL);
+ ctx->m_state->setState(indx, size, type, normalized, stride, ptr);
+}
+
+void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr)
+{
+ GL2Encoder *ctx = (GL2Encoder *) self;
+ assert(ctx->m_state != NULL);
+ GLClientState* state = ctx->m_state;
+
+ switch (param) {
+ case GL_NUM_SHADER_BINARY_FORMATS:
+ *ptr = 0;
+ break;
+ case GL_SHADER_BINARY_FORMATS:
+ // do nothing
+ break;
+
+ case GL_COMPRESSED_TEXTURE_FORMATS: {
+ GLint *compressedTextureFormats = ctx->getCompressedTextureFormats();
+ if (ctx->m_num_compressedTextureFormats > 0 &&
+ compressedTextureFormats != NULL) {
+ memcpy(ptr, compressedTextureFormats,
+ ctx->m_num_compressedTextureFormats * sizeof(GLint));
+ }
+ break;
+ }
+
+ case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
+ case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
+ case GL_MAX_TEXTURE_IMAGE_UNITS:
+ ctx->m_glGetIntegerv_enc(self, param, ptr);
+ *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS);
+ break;
+
+ case GL_TEXTURE_BINDING_2D:
+ *ptr = state->getBoundTexture(GL_TEXTURE_2D);
+ break;
+ case GL_TEXTURE_BINDING_EXTERNAL_OES:
+ *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES);
+ break;
+
+ default:
+ if (!ctx->m_state->getClientStateParameter<GLint>(param, ptr)) {
+ ctx->m_glGetIntegerv_enc(self, param, ptr);
+ }
+ break;
+ }
+}
+
+
+void GL2Encoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state != NULL);
+ GLClientState* state = ctx->m_state;
+
+ switch (param) {
+ case GL_NUM_SHADER_BINARY_FORMATS:
+ *ptr = 0;
+ break;
+ case GL_SHADER_BINARY_FORMATS:
+ // do nothing
+ break;
+
+ case GL_COMPRESSED_TEXTURE_FORMATS: {
+ GLint *compressedTextureFormats = ctx->getCompressedTextureFormats();
+ if (ctx->m_num_compressedTextureFormats > 0 &&
+ compressedTextureFormats != NULL) {
+ for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) {
+ ptr[i] = (GLfloat) compressedTextureFormats[i];
+ }
+ }
+ break;
+ }
+
+ case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
+ case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
+ case GL_MAX_TEXTURE_IMAGE_UNITS:
+ ctx->m_glGetFloatv_enc(self, param, ptr);
+ *ptr = MIN(*ptr, (GLfloat)GLClientState::MAX_TEXTURE_UNITS);
+ break;
+
+ case GL_TEXTURE_BINDING_2D:
+ *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_2D);
+ break;
+ case GL_TEXTURE_BINDING_EXTERNAL_OES:
+ *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES);
+ break;
+
+ default:
+ if (!ctx->m_state->getClientStateParameter<GLfloat>(param, ptr)) {
+ ctx->m_glGetFloatv_enc(self, param, ptr);
+ }
+ break;
+ }
+}
+
+
+void GL2Encoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state != NULL);
+ GLClientState* state = ctx->m_state;
+
+ switch (param) {
+ case GL_NUM_SHADER_BINARY_FORMATS:
+ *ptr = GL_FALSE;
+ break;
+ case GL_SHADER_BINARY_FORMATS:
+ // do nothing
+ break;
+
+ case GL_COMPRESSED_TEXTURE_FORMATS: {
+ GLint *compressedTextureFormats = ctx->getCompressedTextureFormats();
+ if (ctx->m_num_compressedTextureFormats > 0 &&
+ compressedTextureFormats != NULL) {
+ for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) {
+ ptr[i] = compressedTextureFormats[i] != 0 ? GL_TRUE : GL_FALSE;
+ }
+ }
+ break;
+ }
+
+ case GL_TEXTURE_BINDING_2D:
+ *ptr = state->getBoundTexture(GL_TEXTURE_2D) != 0 ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_TEXTURE_BINDING_EXTERNAL_OES:
+ *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES) != 0
+ ? GL_TRUE : GL_FALSE;
+ break;
+
+ default:
+ if (!ctx->m_state->getClientStateParameter<GLboolean>(param, ptr)) {
+ ctx->m_glGetBooleanv_enc(self, param, ptr);
+ }
+ break;
+ }
+}
+
+
+void GL2Encoder::s_glEnableVertexAttribArray(void *self, GLuint index)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state);
+ ctx->m_state->enable(index, 1);
+}
+
+void GL2Encoder::s_glDisableVertexAttribArray(void *self, GLuint index)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state);
+ ctx->m_state->enable(index, 0);
+}
+
+
+void GL2Encoder::s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state);
+
+ if (!ctx->m_state->getVertexAttribParameter<GLint>(index, pname, params)) {
+ ctx->m_glGetVertexAttribiv_enc(self, index, pname, params);
+ }
+}
+
+void GL2Encoder::s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state);
+
+ if (!ctx->m_state->getVertexAttribParameter<GLfloat>(index, pname, params)) {
+ ctx->m_glGetVertexAttribfv_enc(self, index, pname, params);
+ }
+}
+
+void GL2Encoder::s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ if (ctx->m_state == NULL) return;
+
+ const GLClientState::VertexAttribState *va_state = ctx->m_state->getState(index);
+ if (va_state != NULL) {
+ *pointer = va_state->data;
+ }
+}
+
+
+void GL2Encoder::sendVertexAttributes(GLint first, GLsizei count)
+{
+ assert(m_state);
+
+ for (int i = 0; i < m_state->nLocations(); i++) {
+ bool enableDirty;
+ const GLClientState::VertexAttribState *state = m_state->getStateAndEnableDirty(i, &enableDirty);
+
+ if (!state) {
+ continue;
+ }
+
+ if (!enableDirty && !state->enabled) {
+ continue;
+ }
+
+
+ if (state->enabled) {
+ m_glEnableVertexAttribArray_enc(this, i);
+
+ unsigned int datalen = state->elementSize * count;
+ int stride = state->stride == 0 ? state->elementSize : state->stride;
+ int firstIndex = stride * first;
+
+ if (state->bufferObject == 0) {
+ this->glVertexAttribPointerData(this, i, state->size, state->type, state->normalized, state->stride,
+ (unsigned char *)state->data + firstIndex, datalen);
+ } else {
+ this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject);
+ this->glVertexAttribPointerOffset(this, i, state->size, state->type, state->normalized, state->stride,
+ (GLuint) state->data + firstIndex);
+ this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo());
+ }
+ } else {
+ this->m_glDisableVertexAttribArray_enc(this, i);
+ }
+ }
+}
+
+void GL2Encoder::s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ ctx->sendVertexAttributes(first, count);
+ ctx->m_glDrawArrays_enc(ctx, mode, 0, count);
+}
+
+
+void GL2Encoder::s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices)
+{
+
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert(ctx->m_state != NULL);
+ SET_ERROR_IF(count<0, GL_INVALID_VALUE);
+
+ bool has_immediate_arrays = false;
+ bool has_indirect_arrays = false;
+ int nLocations = ctx->m_state->nLocations();
+
+ for (int i = 0; i < nLocations; i++) {
+ const GLClientState::VertexAttribState *state = ctx->m_state->getState(i);
+ if (state->enabled) {
+ if (state->bufferObject != 0) {
+ has_indirect_arrays = true;
+ } else {
+ has_immediate_arrays = true;
+ }
+ }
+ }
+
+ if (!has_immediate_arrays && !has_indirect_arrays) {
+ ALOGE("glDrawElements: no data bound to the command - ignoring\n");
+ return;
+ }
+
+ bool adjustIndices = true;
+ if (ctx->m_state->currentIndexVbo() != 0) {
+ if (!has_immediate_arrays) {
+ ctx->sendVertexAttributes(0, count);
+ ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, ctx->m_state->currentIndexVbo());
+ ctx->glDrawElementsOffset(ctx, mode, count, type, (GLuint)indices);
+ adjustIndices = false;
+ } else {
+ BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo());
+ ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, 0);
+ indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices);
+ }
+ }
+ if (adjustIndices) {
+ void *adjustedIndices = (void*)indices;
+ int minIndex = 0, maxIndex = 0;
+
+ switch(type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ GLUtils::minmax<unsigned char>((unsigned char *)indices, count, &minIndex, &maxIndex);
+ if (minIndex != 0) {
+ adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+ GLUtils::shiftIndices<unsigned char>((unsigned char *)indices,
+ (unsigned char *)adjustedIndices,
+ count, -minIndex);
+ }
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ GLUtils::minmax<unsigned short>((unsigned short *)indices, count, &minIndex, &maxIndex);
+ if (minIndex != 0) {
+ adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count);
+ GLUtils::shiftIndices<unsigned short>((unsigned short *)indices,
+ (unsigned short *)adjustedIndices,
+ count, -minIndex);
+ }
+ break;
+ default:
+ ALOGE("unsupported index buffer type %d\n", type);
+ }
+ if (has_indirect_arrays || 1) {
+ ctx->sendVertexAttributes(minIndex, maxIndex - minIndex + 1);
+ ctx->glDrawElementsData(ctx, mode, count, type, adjustedIndices,
+ count * glSizeof(type));
+ // XXX - OPTIMIZATION (see the other else branch) should be implemented
+ if(!has_indirect_arrays) {
+ //ALOGD("unoptimized drawelements !!!\n");
+ }
+ } else {
+ // we are all direct arrays and immidate mode index array -
+ // rebuild the arrays and the index array;
+ ALOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n");
+ }
+ }
+}
+
+
+GLint * GL2Encoder::getCompressedTextureFormats()
+{
+ if (m_compressedTextureFormats == NULL) {
+ this->glGetIntegerv(this, GL_NUM_COMPRESSED_TEXTURE_FORMATS,
+ &m_num_compressedTextureFormats);
+ if (m_num_compressedTextureFormats > 0) {
+ // get number of texture formats;
+ m_compressedTextureFormats = new GLint[m_num_compressedTextureFormats];
+ this->glGetCompressedTextureFormats(this, m_num_compressedTextureFormats, m_compressedTextureFormats);
+ }
+ }
+ return m_compressedTextureFormats;
+}
+
+// Replace uses of samplerExternalOES with sampler2D, recording the names of
+// modified shaders in data. Also remove
+// #extension GL_OES_EGL_image_external : require
+// statements.
+//
+// This implementation assumes the input has already been pre-processed. If not,
+// a few cases will be mishandled:
+//
+// 1. "mySampler" will be incorrectly recorded as being a samplerExternalOES in
+// the following code:
+// #if 1
+// uniform sampler2D mySampler;
+// #else
+// uniform samplerExternalOES mySampler;
+// #endif
+//
+// 2. Comments that look like sampler declarations will be incorrectly modified
+// and recorded:
+// // samplerExternalOES hahaFooledYou
+//
+// 3. However, GLSL ES does not have a concatentation operator, so things like
+// this (valid in C) are invalid and not a problem:
+// #define SAMPLER(TYPE, NAME) uniform sampler#TYPE NAME
+// SAMPLER(ExternalOES, mySampler);
+//
+static bool replaceSamplerExternalWith2D(char* const str, ShaderData* const data)
+{
+ static const char STR_HASH_EXTENSION[] = "#extension";
+ static const char STR_GL_OES_EGL_IMAGE_EXTERNAL[] = "GL_OES_EGL_image_external";
+ static const char STR_SAMPLER_EXTERNAL_OES[] = "samplerExternalOES";
+ static const char STR_SAMPLER2D_SPACE[] = "sampler2D ";
+
+ // -- overwrite all "#extension GL_OES_EGL_image_external : xxx" statements
+ char* c = str;
+ while ((c = strstr(c, STR_HASH_EXTENSION))) {
+ char* start = c;
+ c += sizeof(STR_HASH_EXTENSION)-1;
+ while (isspace(*c) && *c != '\0') {
+ c++;
+ }
+ if (strncmp(c, STR_GL_OES_EGL_IMAGE_EXTERNAL,
+ sizeof(STR_GL_OES_EGL_IMAGE_EXTERNAL)-1) == 0)
+ {
+ // #extension statements are terminated by end of line
+ c = start;
+ while (*c != '\0' && *c != '\r' && *c != '\n') {
+ *c++ = ' ';
+ }
+ }
+ }
+
+ // -- replace "samplerExternalOES" with "sampler2D" and record name
+ c = str;
+ while ((c = strstr(c, STR_SAMPLER_EXTERNAL_OES))) {
+ // Make sure "samplerExternalOES" isn't a substring of a larger token
+ if (c == str || !isspace(*(c-1))) {
+ c++;
+ continue;
+ }
+ char* sampler_start = c;
+ c += sizeof(STR_SAMPLER_EXTERNAL_OES)-1;
+ if (!isspace(*c) && *c != '\0') {
+ continue;
+ }
+
+ // capture sampler name
+ while (isspace(*c) && *c != '\0') {
+ c++;
+ }
+ if (!isalpha(*c) && *c != '_') {
+ // not an identifier
+ return false;
+ }
+ char* name_start = c;
+ do {
+ c++;
+ } while (isalnum(*c) || *c == '_');
+ data->samplerExternalNames.push_back(
+ android::String8(name_start, c - name_start));
+
+ // memcpy instead of strcpy since we don't want the NUL terminator
+ memcpy(sampler_start, STR_SAMPLER2D_SPACE, sizeof(STR_SAMPLER2D_SPACE)-1);
+ }
+
+ return true;
+}
+
+void GL2Encoder::s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar **string, const GLint *length)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ ShaderData* shaderData = ctx->m_shared->getShaderData(shader);
+ SET_ERROR_IF(!shaderData, GL_INVALID_VALUE);
+
+ int len = glUtilsCalcShaderSourceLen((char**)string, (GLint*)length, count);
+ char *str = new char[len + 1];
+ glUtilsPackStrings(str, (char**)string, (GLint*)length, count);
+
+ // TODO: pre-process str before calling replaceSamplerExternalWith2D().
+ // Perhaps we can borrow Mesa's pre-processor?
+
+ if (!replaceSamplerExternalWith2D(str, shaderData)) {
+ delete str;
+ ctx->setError(GL_OUT_OF_MEMORY);
+ return;
+ }
+
+ ctx->glShaderString(ctx, shader, str, len + 1);
+ delete str;
+}
+
+void GL2Encoder::s_glFinish(void *self)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ ctx->glFinishRoundTrip(self);
+}
+
+void GL2Encoder::s_glLinkProgram(void * self, GLuint program)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ ctx->m_glLinkProgram_enc(self, program);
+
+ GLint linkStatus = 0;
+ ctx->glGetProgramiv(self,program,GL_LINK_STATUS,&linkStatus);
+ if (!linkStatus)
+ return;
+
+ //get number of active uniforms in the program
+ GLint numUniforms=0;
+ ctx->glGetProgramiv(self, program, GL_ACTIVE_UNIFORMS, &numUniforms);
+ ctx->m_shared->initProgramData(program,numUniforms);
+
+ //get the length of the longest uniform name
+ GLint maxLength=0;
+ ctx->glGetProgramiv(self, program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength);
+
+ GLint size;
+ GLenum type;
+ GLchar *name = new GLchar[maxLength+1];
+ GLint location;
+ //for each active uniform, get its size and starting location.
+ for (GLint i=0 ; i<numUniforms ; ++i)
+ {
+ ctx->glGetActiveUniform(self, program, i, maxLength, NULL, &size, &type, name);
+ location = ctx->m_glGetUniformLocation_enc(self, program, name);
+ ctx->m_shared->setProgramIndexInfo(program, i, location, size, type, name);
+ }
+ ctx->m_shared->setupLocationShiftWAR(program);
+
+ delete[] name;
+}
+
+void GL2Encoder::s_glDeleteProgram(void *self, GLuint program)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ ctx->m_glDeleteProgram_enc(self, program);
+
+ ctx->m_shared->deleteProgramData(program);
+}
+
+void GL2Encoder::s_glGetUniformiv(void *self, GLuint program, GLint location, GLint* params)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ SET_ERROR_IF(!ctx->m_shared->isProgram(program), GL_INVALID_VALUE);
+ SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION);
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(program, location);
+ SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION);
+ ctx->m_glGetUniformiv_enc(self, program, hostLoc, params);
+}
+void GL2Encoder::s_glGetUniformfv(void *self, GLuint program, GLint location, GLfloat* params)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ SET_ERROR_IF(!ctx->m_shared->isProgram(program), GL_INVALID_VALUE);
+ SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION);
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(program,location);
+ SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION);
+ ctx->m_glGetUniformfv_enc(self, program, hostLoc, params);
+}
+
+GLuint GL2Encoder::s_glCreateProgram(void * self)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLuint program = ctx->m_glCreateProgram_enc(self);
+ if (program!=0)
+ ctx->m_shared->addProgramData(program);
+ return program;
+}
+
+GLuint GL2Encoder::s_glCreateShader(void *self, GLenum shaderType)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLuint shader = ctx->m_glCreateShader_enc(self, shaderType);
+ if (shader != 0) {
+ if (!ctx->m_shared->addShaderData(shader)) {
+ ctx->m_glDeleteShader_enc(self, shader);
+ return 0;
+ }
+ }
+ return shader;
+}
+
+void GL2Encoder::s_glDeleteShader(void *self, GLenum shader)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ ctx->m_glDeleteShader_enc(self,shader);
+ ctx->m_shared->unrefShaderData(shader);
+}
+
+void GL2Encoder::s_glAttachShader(void *self, GLuint program, GLuint shader)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ ctx->m_glAttachShader_enc(self, program, shader);
+ ctx->m_shared->attachShader(program, shader);
+}
+
+void GL2Encoder::s_glDetachShader(void *self, GLuint program, GLuint shader)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ ctx->m_glDetachShader_enc(self, program, shader);
+ ctx->m_shared->detachShader(program, shader);
+}
+
+int GL2Encoder::s_glGetUniformLocation(void *self, GLuint program, const GLchar *name)
+{
+ if (!name) return -1;
+
+ GL2Encoder *ctx = (GL2Encoder*)self;
+
+ // if we need the uniform location WAR
+ // parse array index from the end of the name string
+ int arrIndex = 0;
+ bool needLocationWAR = ctx->m_shared->needUniformLocationWAR(program);
+ if (needLocationWAR) {
+ int namelen = strlen(name);
+ if (name[namelen-1] == ']') {
+ char *brace = strrchr(name,'[');
+ if (!brace || sscanf(brace+1,"%d",&arrIndex) != 1) {
+ return -1;
+ }
+
+ }
+ }
+
+ int hostLoc = ctx->m_glGetUniformLocation_enc(self, program, name);
+ if (hostLoc >= 0 && needLocationWAR) {
+ return ctx->m_shared->locationWARHostToApp(program, hostLoc, arrIndex);
+ }
+ return hostLoc;
+}
+
+bool GL2Encoder::updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget)
+{
+ if (newTarget != GL_TEXTURE_2D && newTarget != GL_TEXTURE_EXTERNAL_OES)
+ return false;
+
+ m_state->setActiveTextureUnit(texUnit);
+
+ GLenum oldTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+ if (newTarget != oldTarget) {
+ if (newTarget == GL_TEXTURE_EXTERNAL_OES) {
+ m_state->disableTextureTarget(GL_TEXTURE_2D);
+ m_state->enableTextureTarget(GL_TEXTURE_EXTERNAL_OES);
+ } else {
+ m_state->disableTextureTarget(GL_TEXTURE_EXTERNAL_OES);
+ m_state->enableTextureTarget(GL_TEXTURE_2D);
+ }
+ m_glActiveTexture_enc(this, texUnit);
+ m_glBindTexture_enc(this, GL_TEXTURE_2D,
+ m_state->getBoundTexture(newTarget));
+ return true;
+ }
+
+ return false;
+}
+
+void GL2Encoder::s_glUseProgram(void *self, GLuint program)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLClientState* state = ctx->m_state;
+ GLSharedGroupPtr shared = ctx->m_shared;
+
+ ctx->m_glUseProgram_enc(self, program);
+ ctx->m_state->setCurrentProgram(program);
+
+ GLenum origActiveTexture = state->getActiveTextureUnit();
+ GLenum hostActiveTexture = origActiveTexture;
+ GLint samplerIdx = -1;
+ GLint samplerVal;
+ GLenum samplerTarget;
+ while ((samplerIdx = shared->getNextSamplerUniform(program, samplerIdx, &samplerVal, &samplerTarget)) != -1) {
+ if (samplerVal < 0 || samplerVal >= GLClientState::MAX_TEXTURE_UNITS)
+ continue;
+ if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + samplerVal,
+ samplerTarget))
+ {
+ hostActiveTexture = GL_TEXTURE0 + samplerVal;
+ }
+ }
+ state->setActiveTextureUnit(origActiveTexture);
+ if (hostActiveTexture != origActiveTexture) {
+ ctx->m_glActiveTexture_enc(self, origActiveTexture);
+ }
+}
+
+void GL2Encoder::s_glUniform1f(void *self , GLint location, GLfloat x)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform1f_enc(self, hostLoc, x);
+}
+
+void GL2Encoder::s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform1fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform1i(void *self , GLint location, GLint x)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLClientState* state = ctx->m_state;
+ GLSharedGroupPtr shared = ctx->m_shared;
+
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform1i_enc(self, hostLoc, x);
+
+ GLenum target;
+ if (shared->setSamplerUniform(state->currentProgram(), location, x, &target)) {
+ GLenum origActiveTexture = state->getActiveTextureUnit();
+ if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + x, target)) {
+ ctx->m_glActiveTexture_enc(self, origActiveTexture);
+ }
+ state->setActiveTextureUnit(origActiveTexture);
+ }
+}
+
+void GL2Encoder::s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform1iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform2f_enc(self, hostLoc, x, y);
+}
+
+void GL2Encoder::s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform2fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform2i(void *self , GLint location, GLint x, GLint y)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform2i_enc(self, hostLoc, x, y);
+}
+
+void GL2Encoder::s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform2iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform3f_enc(self, hostLoc, x, y, z);
+}
+
+void GL2Encoder::s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform3fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform3i_enc(self, hostLoc, x, y, z);
+}
+
+void GL2Encoder::s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform3iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform4f_enc(self, hostLoc, x, y, z, w);
+}
+
+void GL2Encoder::s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform4fv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform4i_enc(self, hostLoc, x, y, z, w);
+}
+
+void GL2Encoder::s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniform4iv_enc(self, hostLoc, count, v);
+}
+
+void GL2Encoder::s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniformMatrix2fv_enc(self, hostLoc, count, transpose, value);
+}
+
+void GL2Encoder::s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniformMatrix3fv_enc(self, hostLoc, count, transpose, value);
+}
+
+void GL2Encoder::s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+{
+ GL2Encoder *ctx = (GL2Encoder*)self;
+ GLint hostLoc = ctx->m_shared->locationWARAppToHost(ctx->m_state->currentProgram(),location);
+ ctx->m_glUniformMatrix4fv_enc(self, hostLoc, count, transpose, value);
+}
+
+void GL2Encoder::s_glActiveTexture(void* self, GLenum texture)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ GLClientState* state = ctx->m_state;
+ GLenum err;
+
+ SET_ERROR_IF((err = state->setActiveTextureUnit(texture)) != GL_NO_ERROR, err);
+
+ ctx->m_glActiveTexture_enc(ctx, texture);
+}
+
+void GL2Encoder::s_glBindTexture(void* self, GLenum target, GLuint texture)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ GLClientState* state = ctx->m_state;
+ GLenum err;
+ GLboolean firstUse;
+
+ SET_ERROR_IF((err = state->bindTexture(target, texture, &firstUse)) != GL_NO_ERROR, err);
+
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
+ ctx->m_glBindTexture_enc(ctx, target, texture);
+ return;
+ }
+
+ GLenum priorityTarget = state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+
+ if (target == GL_TEXTURE_EXTERNAL_OES && firstUse) {
+ ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture);
+ ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ if (target != priorityTarget) {
+ ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D,
+ state->getBoundTexture(GL_TEXTURE_2D));
+ }
+ }
+
+ if (target == priorityTarget) {
+ ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture);
+ }
+}
+
+void GL2Encoder::s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ GLClientState* state = ctx->m_state;
+
+ state->deleteTextures(n, textures);
+ ctx->m_glDeleteTextures_enc(ctx, n, textures);
+}
+
+void GL2Encoder::s_glGetTexParameterfv(void* self,
+ GLenum target, GLenum pname, GLfloat* params)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ const GLClientState* state = ctx->m_state;
+
+ if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+ ctx->override2DTextureTarget(target);
+ ctx->m_glGetTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params);
+ ctx->restore2DTextureTarget();
+ } else {
+ ctx->m_glGetTexParameterfv_enc(ctx, target, pname, params);
+ }
+}
+
+void GL2Encoder::s_glGetTexParameteriv(void* self,
+ GLenum target, GLenum pname, GLint* params)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ const GLClientState* state = ctx->m_state;
+
+ switch (pname) {
+ case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
+ *params = 1;
+ break;
+
+ default:
+ if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+ ctx->override2DTextureTarget(target);
+ ctx->m_glGetTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params);
+ ctx->restore2DTextureTarget();
+ } else {
+ ctx->m_glGetTexParameteriv_enc(ctx, target, pname, params);
+ }
+ break;
+ }
+}
+
+static bool isValidTextureExternalParam(GLenum pname, GLenum param)
+{
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ return param == GL_NEAREST || param == GL_LINEAR;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ return param == GL_CLAMP_TO_EDGE;
+
+ default:
+ return true;
+ }
+}
+
+void GL2Encoder::s_glTexParameterf(void* self,
+ GLenum target, GLenum pname, GLfloat param)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ const GLClientState* state = ctx->m_state;
+
+ SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+ !isValidTextureExternalParam(pname, (GLenum)param)),
+ GL_INVALID_ENUM);
+
+ if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+ ctx->override2DTextureTarget(target);
+ ctx->m_glTexParameterf_enc(ctx, GL_TEXTURE_2D, pname, param);
+ ctx->restore2DTextureTarget();
+ } else {
+ ctx->m_glTexParameterf_enc(ctx, target, pname, param);
+ }
+}
+
+void GL2Encoder::s_glTexParameterfv(void* self,
+ GLenum target, GLenum pname, const GLfloat* params)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ const GLClientState* state = ctx->m_state;
+
+ SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+ !isValidTextureExternalParam(pname, (GLenum)params[0])),
+ GL_INVALID_ENUM);
+
+ if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+ ctx->override2DTextureTarget(target);
+ ctx->m_glTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params);
+ ctx->restore2DTextureTarget();
+ } else {
+ ctx->m_glTexParameterfv_enc(ctx, target, pname, params);
+ }
+}
+
+void GL2Encoder::s_glTexParameteri(void* self,
+ GLenum target, GLenum pname, GLint param)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ const GLClientState* state = ctx->m_state;
+
+ SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+ !isValidTextureExternalParam(pname, (GLenum)param)),
+ GL_INVALID_ENUM);
+
+ if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+ ctx->override2DTextureTarget(target);
+ ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, pname, param);
+ ctx->restore2DTextureTarget();
+ } else {
+ ctx->m_glTexParameteri_enc(ctx, target, pname, param);
+ }
+}
+
+void GL2Encoder::s_glTexParameteriv(void* self,
+ GLenum target, GLenum pname, const GLint* params)
+{
+ GL2Encoder* ctx = (GL2Encoder*)self;
+ const GLClientState* state = ctx->m_state;
+
+ SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES &&
+ !isValidTextureExternalParam(pname, (GLenum)params[0])),
+ GL_INVALID_ENUM);
+
+ if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) {
+ ctx->override2DTextureTarget(target);
+ ctx->m_glTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params);
+ ctx->restore2DTextureTarget();
+ } else {
+ ctx->m_glTexParameteriv_enc(ctx, target, pname, params);
+ }
+}
+
+void GL2Encoder::override2DTextureTarget(GLenum target)
+{
+ if ((target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) &&
+ target != m_state->getPriorityEnabledTarget(GL_TEXTURE_2D)) {
+ m_glBindTexture_enc(this, GL_TEXTURE_2D,
+ m_state->getBoundTexture(target));
+ }
+}
+
+void GL2Encoder::restore2DTextureTarget()
+{
+ GLenum priorityTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D);
+ m_glBindTexture_enc(this, GL_TEXTURE_2D,
+ m_state->getBoundTexture(priorityTarget));
+}
diff --git a/emulator/opengl/system/GLESv2_enc/GL2Encoder.h b/emulator/opengl/system/GLESv2_enc/GL2Encoder.h
new file mode 100644
index 0000000..f9235d7
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/GL2Encoder.h
@@ -0,0 +1,216 @@
+/*
+* Copyright (C) 2011 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.
+*/
+#ifndef _GL2_ENCODER_H_
+#define _GL2_ENCODER_H_
+
+#include "gl2_enc.h"
+#include "GLClientState.h"
+#include "GLSharedGroup.h"
+#include "FixedBuffer.h"
+
+
+class GL2Encoder : public gl2_encoder_context_t {
+public:
+ GL2Encoder(IOStream *stream);
+ virtual ~GL2Encoder();
+ void setClientState(GLClientState *state) {
+ m_state = state;
+ }
+ void setSharedGroup(GLSharedGroupPtr shared){ m_shared = shared; }
+ const GLClientState *state() { return m_state; }
+ const GLSharedGroupPtr shared() { return m_shared; }
+ void flush() { m_stream->flush(); }
+
+ void setInitialized(){ m_initialized = true; };
+ bool isInitialized(){ return m_initialized; };
+
+ virtual void setError(GLenum error){ m_error = error; };
+ virtual GLenum getError() { return m_error; };
+
+ void override2DTextureTarget(GLenum target);
+ void restore2DTextureTarget();
+
+private:
+
+ bool m_initialized;
+ GLClientState *m_state;
+ GLSharedGroupPtr m_shared;
+ GLenum m_error;
+
+ GLint *m_compressedTextureFormats;
+ GLint m_num_compressedTextureFormats;
+ GLint *getCompressedTextureFormats();
+
+ FixedBuffer m_fixedBuffer;
+
+ void sendVertexAttributes(GLint first, GLsizei count);
+ bool updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget);
+
+ glGetError_client_proc_t m_glGetError_enc;
+ static GLenum s_glGetError(void * self);
+
+ glFlush_client_proc_t m_glFlush_enc;
+ static void s_glFlush(void * self);
+
+ glPixelStorei_client_proc_t m_glPixelStorei_enc;
+ static void s_glPixelStorei(void *self, GLenum param, GLint value);
+
+ glGetString_client_proc_t m_glGetString_enc;
+ static const GLubyte * s_glGetString(void *self, GLenum name);
+
+ glBindBuffer_client_proc_t m_glBindBuffer_enc;
+ static void s_glBindBuffer(void *self, GLenum target, GLuint id);
+
+
+ glBufferData_client_proc_t m_glBufferData_enc;
+ static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
+ glBufferSubData_client_proc_t m_glBufferSubData_enc;
+ static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
+ glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
+ static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
+
+ glDrawArrays_client_proc_t m_glDrawArrays_enc;
+ static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
+
+ glDrawElements_client_proc_t m_glDrawElements_enc;
+ static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
+
+
+ glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
+ static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
+
+ glGetFloatv_client_proc_t m_glGetFloatv_enc;
+ static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
+
+ glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
+ static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
+
+ glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
+ static void s_glVertexAtrribPointer(void *self, GLuint indx, GLint size, GLenum type,
+ GLboolean normalized, GLsizei stride, const GLvoid * ptr);
+
+ glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc;
+ static void s_glEnableVertexAttribArray(void *self, GLuint index);
+
+ glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc;
+ static void s_glDisableVertexAttribArray(void *self, GLuint index);
+
+ glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc;
+ static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params);
+
+ glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc;
+ static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params);
+
+ glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv;
+ static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer);
+
+ static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
+
+ static void s_glFinish(void *self);
+
+ glLinkProgram_client_proc_t m_glLinkProgram_enc;
+ static void s_glLinkProgram(void *self, GLuint program);
+
+ glDeleteProgram_client_proc_t m_glDeleteProgram_enc;
+ static void s_glDeleteProgram(void * self, GLuint program);
+
+ glGetUniformiv_client_proc_t m_glGetUniformiv_enc;
+ static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params);
+
+ glGetUniformfv_client_proc_t m_glGetUniformfv_enc;
+ static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params);
+
+ glCreateProgram_client_proc_t m_glCreateProgram_enc;
+ static GLuint s_glCreateProgram(void *self);
+
+ glCreateShader_client_proc_t m_glCreateShader_enc;
+ static GLuint s_glCreateShader(void *self, GLenum shaderType);
+
+ glDeleteShader_client_proc_t m_glDeleteShader_enc;
+ static void s_glDeleteShader(void *self, GLuint shader);
+
+ glAttachShader_client_proc_t m_glAttachShader_enc;
+ static void s_glAttachShader(void *self, GLuint program, GLuint shader);
+
+ glDetachShader_client_proc_t m_glDetachShader_enc;
+ static void s_glDetachShader(void *self, GLuint program, GLuint shader);
+
+ glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc;
+ static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name);
+ glUseProgram_client_proc_t m_glUseProgram_enc;
+
+ glUniform1f_client_proc_t m_glUniform1f_enc;
+ glUniform1fv_client_proc_t m_glUniform1fv_enc;
+ glUniform1i_client_proc_t m_glUniform1i_enc;
+ glUniform1iv_client_proc_t m_glUniform1iv_enc;
+ glUniform2f_client_proc_t m_glUniform2f_enc;
+ glUniform2fv_client_proc_t m_glUniform2fv_enc;
+ glUniform2i_client_proc_t m_glUniform2i_enc;
+ glUniform2iv_client_proc_t m_glUniform2iv_enc;
+ glUniform3f_client_proc_t m_glUniform3f_enc;
+ glUniform3fv_client_proc_t m_glUniform3fv_enc;
+ glUniform3i_client_proc_t m_glUniform3i_enc;
+ glUniform3iv_client_proc_t m_glUniform3iv_enc;
+ glUniform4f_client_proc_t m_glUniform4f_enc;
+ glUniform4fv_client_proc_t m_glUniform4fv_enc;
+ glUniform4i_client_proc_t m_glUniform4i_enc;
+ glUniform4iv_client_proc_t m_glUniform4iv_enc;
+ glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc;
+ glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc;
+ glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc;
+
+ static void s_glUseProgram(void *self, GLuint program);
+ static void s_glUniform1f(void *self , GLint location, GLfloat x);
+ static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+ static void s_glUniform1i(void *self , GLint location, GLint x);
+ static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v);
+ static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y);
+ static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+ static void s_glUniform2i(void *self , GLint location, GLint x, GLint y);
+ static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v);
+ static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
+ static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+ static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z);
+ static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v);
+ static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+ static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v);
+ static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
+ static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v);
+ static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+ static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+
+ glActiveTexture_client_proc_t m_glActiveTexture_enc;
+ glBindTexture_client_proc_t m_glBindTexture_enc;
+ glDeleteTextures_client_proc_t m_glDeleteTextures_enc;
+ glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc;
+ glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc;
+ glTexParameterf_client_proc_t m_glTexParameterf_enc;
+ glTexParameterfv_client_proc_t m_glTexParameterfv_enc;
+ glTexParameteri_client_proc_t m_glTexParameteri_enc;
+ glTexParameteriv_client_proc_t m_glTexParameteriv_enc;
+
+ static void s_glActiveTexture(void* self, GLenum texture);
+ static void s_glBindTexture(void* self, GLenum target, GLuint texture);
+ static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures);
+ static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params);
+ static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params);
+ static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param);
+ static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params);
+ static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param);
+ static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params);
+};
+#endif
diff --git a/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp b/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp
new file mode 100644
index 0000000..57d65c0
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2011 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.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include "GL2Encoder.h"
+#include <assert.h>
+
+size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack)
+{
+ GL2Encoder *ctx = (GL2Encoder *)self;
+ assert (ctx->state() != NULL);
+ return ctx->state()->pixelDataSize(width, height, format, type, pack);
+}
+
+size_t pixelDataSize3D(void *self, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack)
+{
+ size_t layerSize = pixelDataSize(self, width, height, format, type, pack);
+ return layerSize * depth;
+}
+
+GLenum uniformType(void * self, GLuint program, GLint location)
+{
+ GL2Encoder * ctx = (GL2Encoder *) self;
+ assert (ctx->shared() != NULL);
+ return ctx->shared()->getProgramUniformType(program, location);
+}
diff --git a/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.h b/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.h
new file mode 100644
index 0000000..8e91aeb
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/GL2EncoderUtils.h
@@ -0,0 +1,24 @@
+/*
+* Copyright (C) 2011 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.
+*/
+#ifndef GL2_ENCODER_UTILS_H
+#define GL2_ENCLODER_UTILS_H
+
+extern "C" {
+ size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
+ size_t pixelDataSize3D(void *self, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack);
+ GLenum uniformType(void * self, GLuint program, GLint location);
+};
+#endif
diff --git a/emulator/opengl/system/GLESv2_enc/gl2.attrib b/emulator/opengl/system/GLESv2_enc/gl2.attrib
new file mode 100644
index 0000000..7fe9a66
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/gl2.attrib
@@ -0,0 +1,590 @@
+GLOBAL
+ base_opcode 2048
+ encoder_headers <string.h> "glUtils.h" "GL2EncoderUtils.h"
+
+#void glBindAttribLocation(GLuint program, GLuint index, GLchar *name)
+glBindAttribLocation
+ len name (strlen(name) + 1)
+
+#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage)
+glBufferData
+ len data size
+ var_flag data nullAllowed isLarge
+
+#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)
+glBufferSubData
+ len data size
+ var_flag data isLarge
+
+#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data)
+glCompressedTexImage2D
+ len data imageSize
+ var_flag data nullAllowed isLarge
+
+#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data)
+glCompressedTexSubImage2D
+ len data imageSize
+ var_flag data isLarge
+
+#void glDeleteBuffers(GLsizei n, GLuint *buffers)
+glDeleteBuffers
+ len buffers (n * sizeof(GLuint))
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers)
+glDeleteFramebuffers
+ len framebuffers (n * sizeof(GLuint))
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers)
+glDeleteRenderbuffers
+ len renderbuffers (n * sizeof(GLuint))
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glDeleteTextures(GLsizei n, GLuint *textures)
+glDeleteTextures
+ len textures (n * sizeof(GLuint))
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices)
+glDrawElements
+ flag unsupported
+
+#void glGenBuffers(GLsizei n, GLuint *buffers)
+glGenBuffers
+ len buffers (n * sizeof(GLuint))
+ dir buffers out
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glGenFramebuffers(GLsizei n, GLuint *framebuffers)
+glGenFramebuffers
+ len framebuffers (n * sizeof(GLuint))
+ dir framebuffers out
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
+glGenRenderbuffers
+ len renderbuffers (n * sizeof(GLuint))
+ dir renderbuffers out
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glGenTextures(GLsizei n, GLuint *textures)
+glGenTextures
+ len textures (n * sizeof(GLuint))
+ dir textures out
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
+glGetActiveAttrib
+ len name bufsize
+ dir name out
+ var_flag name nullAllowed
+ dir length out
+ len length (sizeof(GLsizei))
+ var_flag length nullAllowed
+ dir size out
+ len size (sizeof(GLint))
+ dir type out
+ len type (sizeof(GLenum))
+
+#void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
+glGetActiveUniform
+ len name bufsize
+ dir name out
+ var_flag name nullAllowed
+ dir length out
+ len length (sizeof(GLsizei))
+ var_flag length nullAllowed
+ dir size out
+ len size (sizeof(GLint))
+ dir type out
+ len type (sizeof(GLenum))
+
+
+#void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders)
+glGetAttachedShaders
+ len shaders (maxcount*sizeof(GLuint))
+ dir shaders out
+ dir count out
+ var_flag count nullAllowed
+ len count (sizeof(GLsizei))
+
+#int glGetAttribLocation(GLuint program, GLchar *name)
+glGetAttribLocation
+ len name (strlen(name) + 1)
+
+#void glGetBooleanv(GLenum pname, GLboolean *params)
+glGetBooleanv
+ dir params out
+ len params (glUtilsParamSize(pname) * sizeof(GLboolean))
+
+#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
+glGetBufferParameteriv
+ len params (sizeof(GLint))
+ dir params out
+
+#void glGetFloatv(GLenum pname, GLfloat *params)
+glGetFloatv
+ dir params out
+ len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params)
+glGetFramebufferAttachmentParameteriv
+ dir params out
+ len params (sizeof(GLint))
+
+#void glGetIntegerv(GLenum pname, GLint *params)
+glGetIntegerv
+ dir params out
+ len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glGetProgramiv(GLuint program, GLenum pname, GLint *params)
+glGetProgramiv
+ dir params out
+ len params sizeof(GLint)
+#XXX - might change if extension constants that return more then one value
+
+
+#void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog)
+glGetProgramInfoLog
+ dir infolog out
+ len infolog bufsize
+ dir length out
+ len length sizeof(GLsizei)
+
+#void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
+glGetRenderbufferParameteriv
+ dir params out
+ len params sizeof(GLint)
+# XXX - might change if pname with value larger then one is added
+
+#void glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
+glGetShaderiv
+ dir params out
+ len params sizeof(GLint)
+# XXX - might change if pname with value larger then one is added
+
+#void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog)
+glGetShaderInfoLog
+ dir length out
+ len length (sizeof(GLsizei))
+ var_flag length nullAllowed
+ dir infolog out
+ len infolog bufsize
+
+
+#void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision)
+glGetShaderPrecisionFormat
+ dir range out
+ len range (2 * sizeof(GLint))
+ dir precision out
+ len precision (sizeof(GLint))
+
+#void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source)
+glGetShaderSource
+ dir length out
+ len length (sizeof(GLsizei))
+ var_flag length nullAllowed
+ dir source out
+ len source bufsize
+
+#GLubyte* glGetString(GLenum name)
+glGetString
+ flag unsupported
+
+#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+glGetTexParameterfv
+ dir params out
+ len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
+glGetTexParameteriv
+ dir params out
+ len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glGetUniformfv(GLuint program, GLint location, GLfloat *params)
+glGetUniformfv
+ dir params out
+ len params glSizeof(uniformType(self, program, location))
+
+#void glGetUniformiv(GLuint program, GLint location, GLint *params)
+glGetUniformiv
+ dir params out
+ len params glSizeof(uniformType(self, program, location))
+
+#int glGetUniformLocation(GLuint program, GLchar *name)
+glGetUniformLocation
+ len name (strlen(name) + 1)
+
+# client-state shall be handled locally by the encoder in most cases.
+# however, GL_CURRENT_VERTEX_ATTRIB and potential others are handled by the server side,
+# thus we still need to implement it.
+#void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
+glGetVertexAttribfv
+ dir params out
+ len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+
+#see glGetVertexAttribfv for comments
+#void glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
+glGetVertexAttribiv
+ dir params out
+ len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+
+
+#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+glReadPixels
+ dir pixels out
+ len pixels pixelDataSize(self, width, height, format, type, 1)
+
+#void glShaderBinary(GLsizei n, GLuint *shaders, GLenum binaryformat, GLvoid *binary, GLsizei length)
+glShaderBinary
+ flag unsupported
+
+#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels)
+glTexImage2D
+ dir pixels in
+ len pixels pixelDataSize(self, width, height, format, type, 0)
+ var_flag pixels nullAllowed isLarge
+
+#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
+glTexParameterfv
+ len params (glUtilsParamSize(pname) * sizeof(GLfloat))
+#void glTexParameteriv(GLenum target, GLenum pname, GLint *params)
+glTexParameteriv
+ len params (glUtilsParamSize(pname) * sizeof(GLint))
+
+#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
+glTexSubImage2D
+ len pixels pixelDataSize(self, width, height, format, type, 0)
+ var_flag pixels isLarge
+
+#void glUniform1fv(GLint location, GLsizei count, GLfloat *v)
+glUniform1fv
+ len v (count * sizeof(GLfloat))
+
+#void glUniform1iv(GLint location, GLsizei count, GLint *v)
+glUniform1iv
+ len v (count * sizeof(GLint))
+
+#void glUniform2fv(GLint location, GLsizei count, GLfloat *v)
+glUniform2fv
+ len v (count * 2 * sizeof(GLfloat))
+
+#void glUniform2iv(GLint location, GLsizei count, GLint *v)
+glUniform2iv
+ len v (count * 2 * sizeof(GLint))
+
+#void glUniform3fv(GLint location, GLsizei count, GLfloat *v)
+glUniform3fv
+ len v (count * 3 * sizeof(GLfloat))
+
+#void glUniform3iv(GLint location, GLsizei count, GLint *v)
+glUniform3iv
+ len v (3 * count * sizeof(GLint))
+
+#void glUniform4fv(GLint location, GLsizei count, GLfloat *v)
+glUniform4fv
+ len v (4 * count * sizeof(GLfloat))
+
+#void glUniform4iv(GLint location, GLsizei count, GLint *v)
+glUniform4iv
+ len v (4 * count * sizeof(GLint))
+
+#void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value)
+glUniformMatrix2fv
+ len value (count * 4 * sizeof(GLfloat))
+
+#void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value)
+glUniformMatrix3fv
+ len value (count * 9 * sizeof(GLfloat))
+
+#void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value)
+glUniformMatrix4fv
+ len value (count * 16 * sizeof(GLfloat))
+
+#void glVertexAttrib1fv(GLuint indx, GLfloat *values)
+glVertexAttrib1fv
+ len values (sizeof(GLfloat))
+#void glVertexAttrib2fv(GLuint indx, GLfloat *values)
+glVertexAttrib2fv
+ len values (2 * sizeof(GLfloat))
+
+#void glVertexAttrib3fv(GLuint indx, GLfloat *values)
+glVertexAttrib3fv
+ len values (3 * sizeof(GLfloat))
+
+#void glVertexAttrib4fv(GLuint indx, GLfloat *values)
+glVertexAttrib4fv
+ len values (4 * sizeof(GLfloat))
+
+#void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *ptr)
+glVertexAttribPointer
+ flag unsupported
+
+#void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
+glGetProgramBinaryOES
+ flag unsupported
+
+#void glProgramBinaryOES(GLuint program, GLenum binaryFormat, GLvoid *binary, GLint length)
+glProgramBinaryOES
+ flag unsupported
+
+#void* glMapBufferOES(GLenum target, GLenum access)
+glMapBufferOES
+ flag unsupported
+
+#void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid *pixels)
+glTexImage3DOES
+ len pixels pixelDataSize3D(self, width, height, depth, format, type, 0)
+ var_flag pixels nullAllowed isLarge
+
+#void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *pixels)
+glTexSubImage3DOES
+ len pixels pixelDataSize3D(self, width, height, depth, format, type, 0)
+ var_flag pixels isLarge
+
+#void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLvoid *data)
+glCompressedTexImage3DOES
+ len data imageSize
+ var_flag data isLarge
+
+#void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLvoid *data)
+glCompressedTexSubImage3DOES
+ len data imageSize
+ var_flag data isLarge
+
+#void glDeleteVertexArraysOES(GLsizei n, GLuint *arrays)
+glDeleteVertexArraysOES
+ len arrays (n * sizeof(GLuint))
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+#void glGenVertexArraysOES(GLsizei n, GLuint *arrays)
+glGenVertexArraysOES
+ len arrays (n * sizeof(GLuint))
+ dir arrays out
+ param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
+
+
+#void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, GLenum *attachments)
+glDiscardFramebufferEXT
+ len attachments (numAttachments * sizeof(GLenum))
+
+#void glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
+glMultiDrawArraysEXT
+ flag unsupported
+#void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, GLvoid *indices, GLsizei primcount)
+glMultiDrawElementsEXT
+ flag unsupported
+
+
+# handled by encoder
+#void glShaderSource(GLuint shader, GLsizei count, GLstr *string, const GLint *length)
+glShaderSource
+ flag unsupported
+
+
+
+#void glGetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize, GLuint *groups)
+glGetPerfMonitorGroupsAMD
+ flag unsupported
+
+#void glGetPerfMonitorCountersAMD(GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters)
+glGetPerfMonitorCountersAMD
+ flag unsupported
+
+#void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString)
+glGetPerfMonitorGroupStringAMD
+ flag unsupported
+
+#void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString)
+glGetPerfMonitorCounterStringAMD
+ flag unsupported
+
+#void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid *data)
+glGetPerfMonitorCounterInfoAMD
+ flag unsupported
+
+#void glGenPerfMonitorsAMD(GLsizei n, GLuint *monitors)
+glGenPerfMonitorsAMD
+ flag unsupported
+
+#void glDeletePerfMonitorsAMD(GLsizei n, GLuint *monitors)
+glDeletePerfMonitorsAMD
+ flag unsupported
+
+#void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList)
+glSelectPerfMonitorCountersAMD
+ flag unsupported
+
+#void glBeginPerfMonitorAMD(GLuint monitor)
+glBeginPerfMonitorAMD
+ flag unsupported
+
+#void glEndPerfMonitorAMD(GLuint monitor)
+glEndPerfMonitorAMD
+ flag unsupported
+
+#void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten)
+glGetPerfMonitorCounterDataAMD
+ flag unsupported
+
+#void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+glRenderbufferStorageMultisampleIMG
+ flag unsupported
+
+#void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+glFramebufferTexture2DMultisampleIMG
+ flag unsupported
+
+#void glDeleteFencesNV(GLsizei n, GLuint *fences)
+glDeleteFencesNV
+ flag unsupported
+
+#void glGenFencesNV(GLsizei n, GLuint *fences)
+glGenFencesNV
+ flag unsupported
+
+#GLboolean glIsFenceNV(GLuint fence)
+glIsFenceNV
+ flag unsupported
+
+#GLboolean glTestFenceNV(GLuint fence)
+glTestFenceNV
+ flag unsupported
+
+#void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
+glGetFenceivNV
+ flag unsupported
+
+#void glFinishFenceNV(GLuint fence)
+glFinishFenceNV
+ flag unsupported
+
+#void glSetFenceNV(GLuint fence, GLenum condition)
+glSetFenceNV
+ flag unsupported
+
+#void glCoverageMaskNV(GLboolean mask)
+glCoverageMaskNV
+ flag unsupported
+
+#void glCoverageOperationNV(GLenum operation)
+glCoverageOperationNV
+ flag unsupported
+
+#void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls)
+glGetDriverControlsQCOM
+ flag unsupported
+
+#void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
+glGetDriverControlStringQCOM
+ flag unsupported
+
+#void glEnableDriverControlQCOM(GLuint driverControl)
+glEnableDriverControlQCOM
+ flag unsupported
+
+#void glDisableDriverControlQCOM(GLuint driverControl)
+glDisableDriverControlQCOM
+ flag unsupported
+
+#void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures)
+glExtGetTexturesQCOM
+ flag unsupported
+
+#void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
+glExtGetBuffersQCOM
+ flag unsupported
+
+#void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers)
+glExtGetRenderbuffersQCOM
+ flag unsupported
+
+#void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
+glExtGetFramebuffersQCOM
+ flag unsupported
+
+#void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
+glExtGetTexLevelParameterivQCOM
+ flag unsupported
+
+#void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param)
+glExtTexObjectStateOverrideiQCOM
+ flag unsupported
+
+#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
+glExtGetTexSubImageQCOM
+ flag unsupported
+
+#void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr *params)
+glExtGetBufferPointervQCOM
+ flag unsupported
+
+#void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders)
+glExtGetShadersQCOM
+ flag unsupported
+
+#void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms)
+glExtGetProgramsQCOM
+ flag unsupported
+
+#GLboolean glExtIsProgramBinaryQCOM(GLuint program)
+glExtIsProgramBinaryQCOM
+ flag unsupported
+
+#void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length)
+glExtGetProgramBinarySourceQCOM
+ flag unsupported
+
+#void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
+glStartTilingQCOM
+ flag unsupported
+
+#void glEndTilingQCOM(GLbitfield preserveMask)
+glEndTilingQCOM
+ flag unsupported
+
+
+#void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen)
+glVertexAttribPointerData
+ len data datalen
+ custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
+ flag custom_decoder
+ flag not_api
+
+glVertexAttribPointerOffset
+ flag custom_decoder
+ flag not_api
+
+#client-state, handled by the encoder
+#GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer)
+glGetVertexAttribPointerv
+ flag unsupported
+
+glDrawElementsData
+ len data datalen
+ flag custom_decoder
+ flag not_api
+
+glDrawElementsOffset
+ flag custom_decoder
+ flag not_api
+
+#GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats)
+glGetCompressedTextureFormats
+ dir formats out
+ len formats (count * sizeof(GLint))
+ flag custom_decoder
+ flag not_api
+
+#GL_ENTRY(void, glShaderString, GLuint shader, GLchar *string, GLsizei len)
+glShaderString
+ len string len
+ flag custom_decoder
+ flag not_api
+
+glFinishRoundTrip
+ flag custom_decoder
+ flag not_api
+
diff --git a/emulator/opengl/system/GLESv2_enc/gl2.in b/emulator/opengl/system/GLESv2_enc/gl2.in
new file mode 100644
index 0000000..916153b
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/gl2.in
@@ -0,0 +1,214 @@
+GL_ENTRY(void, glActiveTexture, GLenum texture)
+GL_ENTRY(void, glAttachShader, GLuint program, GLuint shader)
+GL_ENTRY(void, glBindAttribLocation, GLuint program, GLuint index, const GLchar* name)
+GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer)
+GL_ENTRY(void, glBindFramebuffer, GLenum target, GLuint framebuffer)
+GL_ENTRY(void, glBindRenderbuffer, GLenum target, GLuint renderbuffer)
+GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture)
+GL_ENTRY(void, glBlendColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+GL_ENTRY(void, glBlendEquation, GLenum mode )
+GL_ENTRY(void, glBlendEquationSeparate, GLenum modeRGB, GLenum modeAlpha)
+GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor)
+GL_ENTRY(void, glBlendFuncSeparate, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
+GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
+GL_ENTRY(GLenum, glCheckFramebufferStatus, GLenum target)
+GL_ENTRY(void, glClear, GLbitfield mask)
+GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+GL_ENTRY(void, glClearDepthf, GLclampf depth)
+GL_ENTRY(void, glClearStencil, GLint s)
+GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+GL_ENTRY(void, glCompileShader, GLuint shader)
+GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
+GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data)
+GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(GLuint, glCreateProgram, void)
+GL_ENTRY(GLuint, glCreateShader, GLenum type)
+GL_ENTRY(void, glCullFace, GLenum mode)
+GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint* buffers)
+GL_ENTRY(void, glDeleteFramebuffers, GLsizei n, const GLuint* framebuffers)
+GL_ENTRY(void, glDeleteProgram, GLuint program)
+GL_ENTRY(void, glDeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers)
+GL_ENTRY(void, glDeleteShader, GLuint shader)
+GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint* textures)
+GL_ENTRY(void, glDepthFunc, GLenum func)
+GL_ENTRY(void, glDepthMask, GLboolean flag)
+GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar)
+GL_ENTRY(void, glDetachShader, GLuint program, GLuint shader)
+GL_ENTRY(void, glDisable, GLenum cap)
+GL_ENTRY(void, glDisableVertexAttribArray, GLuint index)
+GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count)
+GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
+GL_ENTRY(void, glEnable, GLenum cap)
+GL_ENTRY(void, glEnableVertexAttribArray, GLuint index)
+GL_ENTRY(void, glFinish, void)
+GL_ENTRY(void, glFlush, void)
+GL_ENTRY(void, glFramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+GL_ENTRY(void, glFramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+GL_ENTRY(void, glFrontFace, GLenum mode)
+GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint* buffers)
+GL_ENTRY(void, glGenerateMipmap, GLenum target)
+GL_ENTRY(void, glGenFramebuffers, GLsizei n, GLuint* framebuffers)
+GL_ENTRY(void, glGenRenderbuffers, GLsizei n, GLuint* renderbuffers)
+GL_ENTRY(void, glGenTextures, GLsizei n, GLuint* textures)
+GL_ENTRY(void, glGetActiveAttrib, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
+GL_ENTRY(void, glGetActiveUniform, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
+GL_ENTRY(void, glGetAttachedShaders, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
+GL_ENTRY(int, glGetAttribLocation, GLuint program, const GLchar* name)
+GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean* params)
+GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint* params)
+GL_ENTRY(GLenum, glGetError, void)
+GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat* params)
+GL_ENTRY(void, glGetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetProgramiv, GLuint program, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetProgramInfoLog, GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+GL_ENTRY(void, glGetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetShaderiv, GLuint shader, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetShaderInfoLog, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+GL_ENTRY(void, glGetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
+GL_ENTRY(void, glGetShaderSource, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
+GL_ENTRY(const GLubyte*, glGetString, GLenum name)
+GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat* params)
+GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetUniformfv, GLuint program, GLint location, GLfloat* params)
+GL_ENTRY(void, glGetUniformiv, GLuint program, GLint location, GLint* params)
+GL_ENTRY(int, glGetUniformLocation, GLuint program, const GLchar* name)
+GL_ENTRY(void, glGetVertexAttribfv, GLuint index, GLenum pname, GLfloat* params)
+GL_ENTRY(void, glGetVertexAttribiv, GLuint index, GLenum pname, GLint* params)
+GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer)
+GL_ENTRY(void, glHint, GLenum target, GLenum mode)
+GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer)
+GL_ENTRY(GLboolean, glIsEnabled, GLenum cap)
+GL_ENTRY(GLboolean, glIsFramebuffer, GLuint framebuffer)
+GL_ENTRY(GLboolean, glIsProgram, GLuint program)
+GL_ENTRY(GLboolean, glIsRenderbuffer, GLuint renderbuffer)
+GL_ENTRY(GLboolean, glIsShader, GLuint shader)
+GL_ENTRY(GLboolean, glIsTexture, GLuint texture)
+GL_ENTRY(void, glLineWidth, GLfloat width)
+GL_ENTRY(void, glLinkProgram, GLuint program)
+GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param)
+GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units)
+GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
+GL_ENTRY(void, glReleaseShaderCompiler, void)
+GL_ENTRY(void, glRenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert)
+GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glShaderBinary, GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
+GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar** string, const GLint* length)
+GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask)
+GL_ENTRY(void, glStencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask)
+GL_ENTRY(void, glStencilMask, GLuint mask)
+GL_ENTRY(void, glStencilMaskSeparate, GLenum face, GLuint mask)
+GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass)
+GL_ENTRY(void, glStencilOpSeparate, GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param)
+GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat* params)
+GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param)
+GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint* params)
+GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
+GL_ENTRY(void, glUniform1f, GLint location, GLfloat x)
+GL_ENTRY(void, glUniform1fv, GLint location, GLsizei count, const GLfloat* v)
+GL_ENTRY(void, glUniform1i, GLint location, GLint x)
+GL_ENTRY(void, glUniform1iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniform2f, GLint location, GLfloat x, GLfloat y)
+GL_ENTRY(void, glUniform2fv, GLint location, GLsizei count, const GLfloat* v)
+GL_ENTRY(void, glUniform2i, GLint location, GLint x, GLint y)
+GL_ENTRY(void, glUniform2iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniform3f, GLint location, GLfloat x, GLfloat y, GLfloat z)
+GL_ENTRY(void, glUniform3fv, GLint location, GLsizei count, const GLfloat* v)
+GL_ENTRY(void, glUniform3i, GLint location, GLint x, GLint y, GLint z)
+GL_ENTRY(void, glUniform3iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniform4f, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+GL_ENTRY(void, glUniform4fv, GLint location, GLsizei count, const GLfloat* v)
+GL_ENTRY(void, glUniform4i, GLint location, GLint x, GLint y, GLint z, GLint w)
+GL_ENTRY(void, glUniform4iv, GLint location, GLsizei count, const GLint* v)
+GL_ENTRY(void, glUniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+GL_ENTRY(void, glUniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+GL_ENTRY(void, glUniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
+GL_ENTRY(void, glUseProgram, GLuint program)
+GL_ENTRY(void, glValidateProgram, GLuint program)
+GL_ENTRY(void, glVertexAttrib1f, GLuint indx, GLfloat x)
+GL_ENTRY(void, glVertexAttrib1fv, GLuint indx, const GLfloat* values)
+GL_ENTRY(void, glVertexAttrib2f, GLuint indx, GLfloat x, GLfloat y)
+GL_ENTRY(void, glVertexAttrib2fv, GLuint indx, const GLfloat* values)
+GL_ENTRY(void, glVertexAttrib3f, GLuint indx, GLfloat x, GLfloat y, GLfloat z)
+GL_ENTRY(void, glVertexAttrib3fv, GLuint indx, const GLfloat* values)
+GL_ENTRY(void, glVertexAttrib4f, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+GL_ENTRY(void, glVertexAttrib4fv, GLuint indx, const GLfloat* values)
+GL_ENTRY(void, glVertexAttribPointer, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
+GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image)
+GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image)
+GL_ENTRY(void, glGetProgramBinaryOES, GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
+GL_ENTRY(void, glProgramBinaryOES, GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
+GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access)
+GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target)
+#GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid** params)
+GL_ENTRY(void, glTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
+GL_ENTRY(void, glTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
+GL_ENTRY(void, glCopyTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+GL_ENTRY(void, glCompressedTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
+GL_ENTRY(void, glCompressedTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
+GL_ENTRY(void, glFramebufferTexture3DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
+GL_ENTRY(void, glBindVertexArrayOES, GLuint array)
+GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays)
+GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays)
+GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array)
+GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments)
+GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
+GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount)
+
+#not supported
+GL_ENTRY(void, glGetPerfMonitorGroupsAMD, GLint *numGroups, GLsizei groupsSize, GLuint *groups)
+GL_ENTRY(void, glGetPerfMonitorCountersAMD, GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters)
+GL_ENTRY(void, glGetPerfMonitorGroupStringAMD, GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString)
+GL_ENTRY(void, glGetPerfMonitorCounterStringAMD, GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString)
+GL_ENTRY(void, glGetPerfMonitorCounterInfoAMD, GLuint group, GLuint counter, GLenum pname, GLvoid *data)
+GL_ENTRY(void, glGenPerfMonitorsAMD, GLsizei n, GLuint *monitors)
+GL_ENTRY(void, glDeletePerfMonitorsAMD, GLsizei n, GLuint *monitors)
+GL_ENTRY(void, glSelectPerfMonitorCountersAMD, GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList)
+GL_ENTRY(void, glBeginPerfMonitorAMD, GLuint monitor)
+GL_ENTRY(void, glEndPerfMonitorAMD, GLuint monitor)
+GL_ENTRY(void, glGetPerfMonitorCounterDataAMD, GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten)
+
+GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
+GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
+GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences)
+GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences)
+GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence)
+GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence)
+GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params)
+GL_ENTRY(void, glFinishFenceNV, GLuint fence)
+GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition)
+GL_ENTRY(void, glCoverageMaskNV, GLboolean mask)
+GL_ENTRY(void, glCoverageOperationNV, GLenum operation)
+GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls)
+GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
+GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl)
+GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl)
+GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures)
+GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
+GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers)
+GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
+GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
+GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param)
+GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
+GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoidptr *params)
+GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders)
+GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms)
+GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program)
+GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length)
+GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
+GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask)
+
+# add-ons
+GL_ENTRY(void, glVertexAttribPointerData, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen)
+GL_ENTRY(void, glVertexAttribPointerOffset, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset)
+GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset)
+GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen)
+GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats)
+GL_ENTRY(void, glShaderString, GLuint shader, const GLchar* string, GLsizei len)
+GL_ENTRY(int, glFinishRoundTrip, void)
diff --git a/emulator/opengl/system/GLESv2_enc/gl2.types b/emulator/opengl/system/GLESv2_enc/gl2.types
new file mode 100644
index 0000000..4cee99e
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/gl2.types
@@ -0,0 +1,37 @@
+GLbitfield 32 0x%08x false
+GLboolean 8 %d false
+GLclampf 32 %f false
+GLclampx 32 0x%08x false
+GLeglImageOES 32 %p false
+GLenum 32 0x%08x false
+GLfixed 32 0x%08x false
+GLfloat 32 %f false
+GLint 32 %d false
+GLintptr 32 %p false
+GLshort 16 %d false
+GLsizei 32 %d false
+GLsizeiptr 32 %p false
+GLubyte 8 0x%02x false
+GLuint 32 %u false
+GLvoid 0 %x false
+GLchar 8 %d false
+GLenum* 32 0x%08x true
+GLboolean* 32 0x%08x true
+GLclampf* 32 0x%08x true
+GLclampx* 32 0x%08x true
+GLeglImageOES* 32 0x%08x true
+GLfixed* 32 0x%08x true
+GLfloat* 32 0x%08x true
+GLint* 32 0x%08x true
+GLshort* 32 0x%08x true
+GLsizei* 32 0x%08x true
+GLubyte* 32 0x%08x true
+GLuint* 32 0x%08x true
+GLvoid* 32 0x%08x true
+GLchar* 32 0x%08x true
+GLchar** 32 0x%08x true
+GLvoid** 32 0x%08x true
+void* 32 0x%08x true
+GLstr 32 %s true
+GLstr* 32 0x%08x true
+GLvoidptr* 32 0x%08x true \ No newline at end of file
diff --git a/emulator/opengl/system/GLESv2_enc/gl2_types.h b/emulator/opengl/system/GLESv2_enc/gl2_types.h
new file mode 100644
index 0000000..bfff61d
--- /dev/null
+++ b/emulator/opengl/system/GLESv2_enc/gl2_types.h
@@ -0,0 +1,21 @@
+/*
+* Copyright (C) 2011 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.
+*/
+#ifndef _GL_2_TYPES_H_
+#define _GL_2_TYPES_H_
+#include "gl_base_types.h"
+
+typedef void *GLvoidptr;
+#endif