Code drop from //branches/cupcake/...@124589
diff --git a/opengl/libGLES_CM/gl_wrapper.cpp b/opengl/libGLES_CM/gl_wrapper.cpp
index 5da4f9a..3b7f45e 100644
--- a/opengl/libGLES_CM/gl_wrapper.cpp
+++ b/opengl/libGLES_CM/gl_wrapper.cpp
@@ -373,6 +373,7 @@
static sp<GPURevokeRequester> gRevokerCallback;
+
static request_gpu_t* gpu_acquire(void* user)
{
sp<ISurfaceComposer> server( getSurfaceFlinger() );
@@ -383,7 +384,10 @@
}
ISurfaceComposer::gpu_info_t info;
- gRevokerCallback = new GPURevokeRequester();
+
+ if (gRevokerCallback == 0)
+ gRevokerCallback = new GPURevokeRequester();
+
status_t err = server->requestGPU(gRevokerCallback, &info);
if (err != NO_ERROR) {
LOGD("requestGPU returned %d", err);
@@ -549,6 +553,21 @@
return -1;
}
+static EGLint configToUniqueId(egl_display_t const* dp, int i, int index)
+{
+ // NOTE: this mapping works only if we have no more than two EGLimpl
+ return (i>0 ? dp->numConfigs[0] : 0) + index;
+}
+
+static void uniqueIdToConfig(egl_display_t const* dp, EGLint configId,
+ int& i, int& index)
+{
+ // NOTE: this mapping works only if we have no more than two EGLimpl
+ size_t numConfigs = dp->numConfigs[0];
+ i = configId / numConfigs;
+ index = configId % numConfigs;
+}
+
static int cmp_configs(const void* a, const void *b)
{
EGLConfig c0 = *(EGLConfig const *)a;
@@ -557,7 +576,7 @@
}
static char const * const gVendorString = "Android";
-static char const * const gVersionString = "1.2 Android META-EGL";
+static char const * const gVersionString = "1.3 Android META-EGL";
static char const * const gClientApiString = "OpenGL ES";
struct extention_map_t {
@@ -834,7 +853,13 @@
property_get("debug.egl.hw", value, "1");
if (atoi(value) != 0) {
cnx->hooks = &gHooks[IMPL_HARDWARE];
- cnx->dso = load_driver("libhgl.so", cnx->hooks);
+ property_get("debug.egl.profiler", value, "0");
+ if (atoi(value) == 0) {
+ cnx->dso = load_driver("libhgl.so", cnx->hooks);
+ } else {
+ LOGW("Using instrumented h/w OpenGL ES library");
+ cnx->dso = load_driver("libhgld.so", cnx->hooks);
+ }
} else {
LOGD("3D hardware acceleration is disabled");
}
@@ -864,6 +889,8 @@
d->dpys[IMPL_HARDWARE] = cnx->hooks->egl.eglGetDisplay(display);
if (d->dpys[IMPL_HARDWARE] == EGL_NO_DISPLAY) {
+ LOGE("h/w accelerated eglGetDisplay() failed (%s)",
+ egl_strerror(cnx->hooks->egl.eglGetError()));
dlclose((void*)cnx->dso);
cnx->dso = 0;
// in case of failure, we want to make sure we don't try again
@@ -900,7 +927,10 @@
egl_connection_t* const cnx = &gEGLImpl[i];
cnx->major = -1;
cnx->minor = -1;
- if (cnx->dso && cnx->hooks->egl.eglInitialize(
+ if (!cnx->dso)
+ continue;
+
+ if (cnx->hooks->egl.eglInitialize(
dp->dpys[i], &cnx->major, &cnx->minor)) {
//LOGD("initialized %d dpy=%p, ver=%d.%d, cnx=%p",
@@ -912,10 +942,10 @@
dp->queryString[i].version =
cnx->hooks->egl.eglQueryString(dp->dpys[i], EGL_VERSION);
dp->queryString[i].extensions = strdup(
- cnx->hooks->egl.eglQueryString(dp->dpys[i], EGL_EXTENSIONS));
+ cnx->hooks->egl.eglQueryString(dp->dpys[i], EGL_EXTENSIONS));
dp->queryString[i].clientApi =
cnx->hooks->egl.eglQueryString(dp->dpys[i], EGL_CLIENT_APIS);
-
+
// Dynamically insert extensions we know about
if (cnx->hooks->egl.eglSwapRectangleANDROID)
add_extension(dp, dp->queryString[i].extensions,
@@ -924,12 +954,15 @@
if (cnx->hooks->egl.eglQueryStringConfigANDROID)
add_extension(dp, dp->queryString[i].extensions,
"EGL_ANDROID_query_string_config");
+ } else {
+ LOGD("%d: eglInitialize() failed (%s)",
+ i, egl_strerror(cnx->hooks->egl.eglGetError()));
}
}
-
+
// Build the extension list that depends on the current config.
// It is the intersection of our extension list and the
- // underlaying EGL's extensions list
+ // underlying EGL's extensions list
EGLBoolean res = EGL_FALSE;
for (int i=0 ; i<2 ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
@@ -951,10 +984,10 @@
} while (*p);
free((void*)our_extensions_org);
- // remove the trailling white space
+ // remove the trailing white space
if (extensions_config[0] != 0) {
size_t l = strlen(extensions_config) - 1; // new size
- extensions_config[l] = 0; // remove the trailling white space
+ extensions_config[l] = 0; // remove the trailing white space
extensions_config = (char*)realloc(extensions_config, l+1);
} else {
extensions_config = (char*)realloc(extensions_config, 1);
@@ -1065,15 +1098,74 @@
return EGL_TRUE;
}
+ EGLint n;
EGLBoolean res = EGL_FALSE;
*num_config = 0;
+
+
+ // It is unfortunate, but we need to remap the EGL_CONFIG_IDs,
+ // to do this, we have to go through the attrib_list array once
+ // to figure out both its size and if it contains an EGL_CONFIG_ID
+ // key. If so, the full array is copied and patched.
+ // NOTE: we assume that there can be only one occurrence
+ // of EGL_CONFIG_ID.
+
+ EGLint patch_index = -1;
+ GLint attr;
+ size_t size = 0;
+ while ((attr=attrib_list[size])) {
+ if (attr == EGL_CONFIG_ID)
+ patch_index = size;
+ size += 2;
+ }
+ if (patch_index >= 0) {
+ size += 2; // we need copy the sentinel as well
+ EGLint* new_list = (EGLint*)malloc(size*sizeof(EGLint));
+ if (new_list == 0)
+ return setError(EGL_BAD_ALLOC, EGL_FALSE);
+ memcpy(new_list, attrib_list, size*sizeof(EGLint));
+
+ // patch the requested EGL_CONFIG_ID
+ int i, index;
+ EGLint& configId(new_list[patch_index+1]);
+ uniqueIdToConfig(dp, configId, i, index);
+
+ egl_connection_t* const cnx = &gEGLImpl[i];
+ if (cnx->dso) {
+ cnx->hooks->egl.eglGetConfigAttrib(
+ dp->dpys[i], dp->configs[i][index],
+ EGL_CONFIG_ID, &configId);
+
+ // and switch to the new list
+ attrib_list = const_cast<const EGLint *>(new_list);
+
+ // At this point, the only configuration that can match is
+ // dp->configs[i][index], however, we don't know if it would be
+ // rejected because of the other attributes, so we do have to call
+ // cnx->hooks->egl.eglChooseConfig() -- but we don't have to loop
+ // through all the EGLimpl[].
+ // We also know we can only get a single config back, and we know
+ // which one.
+
+ res = cnx->hooks->egl.eglChooseConfig(
+ dp->dpys[i], attrib_list, configs, config_size, &n);
+ if (res && n>0) {
+ // n has to be 0 or 1, by construction, and we already know
+ // which config it will return (since there can be only one).
+ configs[0] = MAKE_CONFIG(i, index);
+ *num_config = 1;
+ }
+ }
+
+ free(const_cast<EGLint *>(attrib_list));
+ return res;
+ }
+
for (int i=0 ; i<2 ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- EGLint n;
if (cnx->hooks->egl.eglChooseConfig(
- dp->dpys[i], attrib_list, configs, config_size, &n))
- {
+ dp->dpys[i], attrib_list, configs, config_size, &n)) {
// now we need to convert these client EGLConfig to our
// internal EGLConfig format. This is done in O(n log n).
for (int j=0 ; j<n ; j++) {
@@ -1102,6 +1194,13 @@
int i=0, index=0;
egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
if (!cnx) return EGL_FALSE;
+
+ if (attribute == EGL_CONFIG_ID) {
+ // EGL_CONFIG_IDs must be unique, just use the order of the selected
+ // EGLConfig.
+ *value = configToUniqueId(dp, i, index);
+ return EGL_TRUE;
+ }
return cnx->hooks->egl.eglGetConfigAttrib(
dp->dpys[i], dp->configs[i][index], attribute, value);
}
diff --git a/opengl/libagl/TextureObjectManager.cpp b/opengl/libagl/TextureObjectManager.cpp
index 12fae63..ce31854 100644
--- a/opengl/libagl/TextureObjectManager.cpp
+++ b/opengl/libagl/TextureObjectManager.cpp
@@ -129,7 +129,7 @@
// so for now, we just loose it.
memset(crop_rect, 0, sizeof(crop_rect));
- // it would be nice id we could keep the generate_mipmap flag
+ // it would be nice if we could keep the generate_mipmap flag,
// we would have to generate them right now though.
generate_mipmap = GL_FALSE;
@@ -286,7 +286,7 @@
void EGLSurfaceManager::deleteTextures(GLsizei n, const GLuint *tokens)
{
- // free all texures
+ // free all textures
Mutex::Autolock _l(mLock);
for (GLsizei i=0 ; i<n ; i++) {
const GLuint t(*tokens++);
diff --git a/opengl/libagl/array.cpp b/opengl/libagl/array.cpp
index 1f6757d..8fa7566 100644
--- a/opengl/libagl/array.cpp
+++ b/opengl/libagl/array.cpp
@@ -1116,8 +1116,8 @@
if (enables & GGL_ENABLE_TMUS) { // needs texture transforms
want |= transform_state_t::TEXTURE;
}
- if (c->clipPlanes.enable) { // needs eye coords
- want |= transform_state_t::MODELVIEW;
+ if (c->clipPlanes.enable || (enables & GGL_ENABLE_FOG)) {
+ want |= transform_state_t::MODELVIEW; // needs eye coords
}
ogles_validate_transform(c, want);
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 854a49e..3e8dca9 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -36,6 +36,7 @@
#include <GLES/egl.h>
#include <pixelflinger/format.h>
+#include <pixelflinger/pixelflinger.h>
#include "context.h"
#include "state.h"
@@ -57,7 +58,7 @@
#ifndef HAVE_ANDROID_OS
namespace gl {
pthread_key_t gGLKey = -1;
-}; // namspace gl
+}; // namespace gl
#endif
template<typename T>
@@ -156,7 +157,7 @@
egl_surface_t::egl_surface_t(EGLDisplay dpy,
EGLConfig config,
int32_t depthFormat)
- : magic(0x31415265), dpy(dpy), config(config), ctx(0)
+ : magic(MAGIC), dpy(dpy), config(config), ctx(0)
{
depth.version = sizeof(GGLSurface);
depth.data = 0;
@@ -240,7 +241,7 @@
{
uint32_t flags = nativeWindow->swapBuffers(nativeWindow);
if (flags & EGL_NATIVES_FLAG_SIZE_CHANGED) {
- // TODO: we probaly should reset the swap rect here
+ // TODO: we probably should reset the swap rect here
// if the window size has changed
// window->setSwapRectangle(Rect(info.w, info.h));
if (depth.data) {
@@ -402,12 +403,13 @@
{
size_t size = w*h;
switch (f) {
- case GGL_PIXEL_FORMAT_RGB_565: size *= 2; break;
- case GGL_PIXEL_FORMAT_RGBA_8888: size *= 4; break;
- default:
- LOGE("incompatible pixel format for pbuffer (format=%d)", f);
- pbuffer.data = 0;
- break;
+ case GGL_PIXEL_FORMAT_A_8: size *= 1; break;
+ case GGL_PIXEL_FORMAT_RGB_565: size *= 2; break;
+ case GGL_PIXEL_FORMAT_RGBA_8888: size *= 4; break;
+ default:
+ LOGE("incompatible pixel format for pbuffer (format=%d)", f);
+ pbuffer.data = 0;
+ break;
}
pbuffer.version = sizeof(GGLSurface);
pbuffer.width = w;
@@ -488,28 +490,28 @@
};
static const extention_map_t gExtentionMap[] = {
- { "eglSwapRectangleANDROID", (void(*)())&eglSwapRectangleANDROID },
- { "glDrawTexsOES", (void(*)())&glDrawTexsOES },
- { "glDrawTexiOES", (void(*)())&glDrawTexiOES },
- { "glDrawTexfOES", (void(*)())&glDrawTexfOES },
- { "glDrawTexxOES", (void(*)())&glDrawTexxOES },
- { "glDrawTexsvOES", (void(*)())&glDrawTexsvOES },
- { "glDrawTexivOES", (void(*)())&glDrawTexivOES },
- { "glDrawTexfvOES", (void(*)())&glDrawTexfvOES },
- { "glDrawTexxvOES", (void(*)())&glDrawTexxvOES },
- { "glQueryMatrixxOES", (void(*)())&glQueryMatrixxOES },
- { "glClipPlanef", (void(*)())&glClipPlanef },
- { "glClipPlanex", (void(*)())&glClipPlanex },
- { "glBindBuffer", (void(*)())&glBindBuffer },
- { "glBufferData", (void(*)())&glBufferData },
- { "glBufferSubData", (void(*)())&glBufferSubData },
- { "glDeleteBuffers", (void(*)())&glDeleteBuffers },
- { "glGenBuffers", (void(*)())&glGenBuffers },
+ { "eglSwapRectangleANDROID", (void(*)())&eglSwapRectangleANDROID },
+ { "glDrawTexsOES", (void(*)())&glDrawTexsOES },
+ { "glDrawTexiOES", (void(*)())&glDrawTexiOES },
+ { "glDrawTexfOES", (void(*)())&glDrawTexfOES },
+ { "glDrawTexxOES", (void(*)())&glDrawTexxOES },
+ { "glDrawTexsvOES", (void(*)())&glDrawTexsvOES },
+ { "glDrawTexivOES", (void(*)())&glDrawTexivOES },
+ { "glDrawTexfvOES", (void(*)())&glDrawTexfvOES },
+ { "glDrawTexxvOES", (void(*)())&glDrawTexxvOES },
+ { "glQueryMatrixxOES", (void(*)())&glQueryMatrixxOES },
+ { "glClipPlanef", (void(*)())&glClipPlanef },
+ { "glClipPlanex", (void(*)())&glClipPlanex },
+ { "glBindBuffer", (void(*)())&glBindBuffer },
+ { "glBufferData", (void(*)())&glBufferData },
+ { "glBufferSubData", (void(*)())&glBufferSubData },
+ { "glDeleteBuffers", (void(*)())&glDeleteBuffers },
+ { "glGenBuffers", (void(*)())&glGenBuffers },
};
/*
* In the lists below, attributes names MUST be sorted.
- * Additinnaly, all configs must be sorted according to
+ * Additionally, all configs must be sorted according to
* the EGL specification.
*/
@@ -517,9 +519,10 @@
{ EGL_STENCIL_SIZE, 0 },
{ EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG },
{ EGL_LEVEL, 0 },
- { EGL_MAX_PBUFFER_HEIGHT, 0 },
- { EGL_MAX_PBUFFER_PIXELS, 0 },
- { EGL_MAX_PBUFFER_WIDTH, 0 },
+ { EGL_MAX_PBUFFER_HEIGHT, GGL_MAX_VIEWPORT_DIMS },
+ { EGL_MAX_PBUFFER_PIXELS,
+ GGL_MAX_VIEWPORT_DIMS*GGL_MAX_VIEWPORT_DIMS },
+ { EGL_MAX_PBUFFER_WIDTH, GGL_MAX_VIEWPORT_DIMS },
{ EGL_NATIVE_RENDERABLE, EGL_TRUE },
{ EGL_NATIVE_VISUAL_ID, 0 },
{ EGL_NATIVE_VISUAL_TYPE, GGL_PIXEL_FORMAT_RGB_565 },
@@ -536,49 +539,72 @@
};
// These configs can override the base attribute list
+// NOTE: when adding a config here, don't forget to update eglCreate*Surface()
static config_pair_t const config_0_attribute_list[] = {
- { EGL_BUFFER_SIZE, 16 },
- { EGL_ALPHA_SIZE, 0 },
- { EGL_BLUE_SIZE, 5 },
- { EGL_GREEN_SIZE, 6 },
- { EGL_RED_SIZE, 5 },
- { EGL_DEPTH_SIZE, 0 },
- { EGL_CONFIG_ID, 0 },
- { EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT },
+ { EGL_BUFFER_SIZE, 16 },
+ { EGL_ALPHA_SIZE, 0 },
+ { EGL_BLUE_SIZE, 5 },
+ { EGL_GREEN_SIZE, 6 },
+ { EGL_RED_SIZE, 5 },
+ { EGL_DEPTH_SIZE, 0 },
+ { EGL_CONFIG_ID, 0 },
+ { EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT },
};
static config_pair_t const config_1_attribute_list[] = {
- { EGL_BUFFER_SIZE, 16 },
- { EGL_ALPHA_SIZE, 0 },
- { EGL_BLUE_SIZE, 5 },
- { EGL_GREEN_SIZE, 6 },
- { EGL_RED_SIZE, 5 },
- { EGL_DEPTH_SIZE, 16 },
- { EGL_CONFIG_ID, 1 },
- { EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT },
+ { EGL_BUFFER_SIZE, 16 },
+ { EGL_ALPHA_SIZE, 0 },
+ { EGL_BLUE_SIZE, 5 },
+ { EGL_GREEN_SIZE, 6 },
+ { EGL_RED_SIZE, 5 },
+ { EGL_DEPTH_SIZE, 16 },
+ { EGL_CONFIG_ID, 1 },
+ { EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT },
};
static config_pair_t const config_2_attribute_list[] = {
- { EGL_BUFFER_SIZE, 32 },
- { EGL_ALPHA_SIZE, 8 },
- { EGL_BLUE_SIZE, 8 },
- { EGL_GREEN_SIZE, 8 },
- { EGL_RED_SIZE, 8 },
- { EGL_DEPTH_SIZE, 0 },
- { EGL_CONFIG_ID, 2 },
- { EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT },
+ { EGL_BUFFER_SIZE, 32 },
+ { EGL_ALPHA_SIZE, 8 },
+ { EGL_BLUE_SIZE, 8 },
+ { EGL_GREEN_SIZE, 8 },
+ { EGL_RED_SIZE, 8 },
+ { EGL_DEPTH_SIZE, 0 },
+ { EGL_CONFIG_ID, 2 },
+ { EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT },
};
static config_pair_t const config_3_attribute_list[] = {
- { EGL_BUFFER_SIZE, 32 },
- { EGL_ALPHA_SIZE, 8 },
- { EGL_BLUE_SIZE, 8 },
- { EGL_GREEN_SIZE, 8 },
- { EGL_RED_SIZE, 8 },
- { EGL_DEPTH_SIZE, 16 },
- { EGL_CONFIG_ID, 3 },
- { EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PIXMAP_BIT },
+ { EGL_BUFFER_SIZE, 32 },
+ { EGL_ALPHA_SIZE, 8 },
+ { EGL_BLUE_SIZE, 8 },
+ { EGL_GREEN_SIZE, 8 },
+ { EGL_RED_SIZE, 8 },
+ { EGL_DEPTH_SIZE, 16 },
+ { EGL_CONFIG_ID, 3 },
+ { EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT },
+};
+
+static config_pair_t const config_4_attribute_list[] = {
+ { EGL_BUFFER_SIZE, 8 },
+ { EGL_ALPHA_SIZE, 8 },
+ { EGL_BLUE_SIZE, 0 },
+ { EGL_GREEN_SIZE, 0 },
+ { EGL_RED_SIZE, 0 },
+ { EGL_DEPTH_SIZE, 0 },
+ { EGL_CONFIG_ID, 4 },
+ { EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT },
+};
+
+static config_pair_t const config_5_attribute_list[] = {
+ { EGL_BUFFER_SIZE, 8 },
+ { EGL_ALPHA_SIZE, 8 },
+ { EGL_BLUE_SIZE, 0 },
+ { EGL_GREEN_SIZE, 0 },
+ { EGL_RED_SIZE, 0 },
+ { EGL_DEPTH_SIZE, 16 },
+ { EGL_CONFIG_ID, 5 },
+ { EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_PBUFFER_BIT|EGL_PIXMAP_BIT },
};
static configs_t const gConfigs[] = {
@@ -586,6 +612,8 @@
{ config_1_attribute_list, NELEM(config_1_attribute_list) },
{ config_2_attribute_list, NELEM(config_2_attribute_list) },
{ config_3_attribute_list, NELEM(config_3_attribute_list) },
+ { config_4_attribute_list, NELEM(config_4_attribute_list) },
+ { config_5_attribute_list, NELEM(config_5_attribute_list) },
};
static config_management_t const gConfigManagement[] = {
@@ -669,7 +697,7 @@
return 1;
}
} else {
- // attribute nont found. this should NEVER happen.
+ // attribute not found. this should NEVER happen.
}
} else {
// error, this attribute doesn't exist
@@ -779,11 +807,19 @@
pixelFormat = GGL_PIXEL_FORMAT_RGBA_8888;
depthFormat = GGL_PIXEL_FORMAT_Z_16;
break;
+ case 4:
+ pixelFormat = GGL_PIXEL_FORMAT_A_8;
+ depthFormat = 0;
+ break;
+ case 5:
+ pixelFormat = GGL_PIXEL_FORMAT_A_8;
+ depthFormat = GGL_PIXEL_FORMAT_Z_16;
+ break;
default:
return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
}
- // XXX: we don't have access to the pixelFormat here just yet.
+ // FIXME: we don't have access to the pixelFormat here just yet.
// (it's possible that the surface is not fully initialized)
// maybe this should be done after the page-flip
//if (EGLint(info.format) != pixelFormat)
@@ -840,6 +876,14 @@
pixelFormat = GGL_PIXEL_FORMAT_RGBA_8888;
depthFormat = GGL_PIXEL_FORMAT_Z_16;
break;
+ case 4:
+ pixelFormat = GGL_PIXEL_FORMAT_A_8;
+ depthFormat = 0;
+ break;
+ case 5:
+ pixelFormat = GGL_PIXEL_FORMAT_A_8;
+ depthFormat = GGL_PIXEL_FORMAT_Z_16;
+ break;
default:
return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
}
@@ -896,6 +940,14 @@
pixelFormat = GGL_PIXEL_FORMAT_RGBA_8888;
depthFormat = GGL_PIXEL_FORMAT_Z_16;
break;
+ case 4:
+ pixelFormat = GGL_PIXEL_FORMAT_A_8;
+ depthFormat = 0;
+ break;
+ case 5:
+ pixelFormat = GGL_PIXEL_FORMAT_A_8;
+ depthFormat = GGL_PIXEL_FORMAT_Z_16;
+ break;
default:
return setError(EGL_BAD_MATCH, EGL_NO_SURFACE);
}
@@ -979,7 +1031,7 @@
EGLBoolean res = EGL_TRUE;
egl_display_t& d = egl_display_t::get_display(dpy);
if (android_atomic_dec(&d.initialized) == 1) {
- // TODO: destroy all resources (surfaces, contextes, etc...)
+ // TODO: destroy all resources (surfaces, contexts, etc...)
//pthread_mutex_lock(&gInitMutex);
//pthread_mutex_unlock(&gInitMutex);
}
@@ -1105,11 +1157,7 @@
EGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list)
{
- // none of our configs support pbuffers
- // (in fact it's working but since we can't use them as
- // textures yet, it's not useful at all)
- //createPbufferSurface(dpy, config, attrib_list);
- return EGL_NO_SURFACE;
+ return createPbufferSurface(dpy, config, attrib_list);
}
EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface eglSurface)
@@ -1231,6 +1279,13 @@
}
EGLContext current_ctx = EGL_NO_CONTEXT;
+
+ if ((read == EGL_NO_SURFACE && draw == EGL_NO_SURFACE) && (ctx != EGL_NO_CONTEXT))
+ return setError(EGL_BAD_MATCH, EGL_FALSE);
+
+ if ((read != EGL_NO_SURFACE || draw != EGL_NO_SURFACE) && (ctx == EGL_NO_CONTEXT))
+ return setError(EGL_BAD_MATCH, EGL_FALSE);
+
if (ctx == EGL_NO_CONTEXT) {
// if we're detaching, we need the current context
current_ctx = (EGLContext)getGlThreadSpecific();
@@ -1486,7 +1541,7 @@
}
// ----------------------------------------------------------------------------
-// Android extentions
+// Android extensions
// ----------------------------------------------------------------------------
void (*eglGetProcAddress (const char *procname))()
diff --git a/opengl/libagl/light.cpp b/opengl/libagl/light.cpp
index 87725cb..25c41d0 100644
--- a/opengl/libagl/light.cpp
+++ b/opengl/libagl/light.cpp
@@ -117,11 +117,11 @@
}
static GLfixed fog_linear(ogles_context_t* c, GLfixed z) {
- return clampF(gglMulx((c->fog.end - z), c->fog.invEndMinusStart));
+ return clampF(gglMulx((c->fog.end - ((z<0)?-z:z)), c->fog.invEndMinusStart));
}
static GLfixed fog_exp(ogles_context_t* c, GLfixed z) {
- const float e = fixedToFloat(gglMulx(c->fog.density, z));
+ const float e = fixedToFloat(gglMulx(c->fog.density, ((z<0)?-z:z)));
return clampF(gglFloatToFixed(fastexpf(-e)));
}
@@ -556,11 +556,11 @@
ogles_error(c, GL_INVALID_VALUE);
break;
case GL_FOG_START:
- c->fog.start = gglClampx(param);
+ c->fog.start = param;
c->fog.invEndMinusStart = gglRecip(c->fog.end - c->fog.start);
break;
case GL_FOG_END:
- c->fog.end = gglClampx(param);
+ c->fog.end = param;
c->fog.invEndMinusStart = gglRecip(c->fog.end - c->fog.start);
break;
case GL_FOG_MODE:
diff --git a/opengl/libagl/matrix.cpp b/opengl/libagl/matrix.cpp
index 441da38..f175cda 100644
--- a/opengl/libagl/matrix.cpp
+++ b/opengl/libagl/matrix.cpp
@@ -98,8 +98,9 @@
c->arrays.perspective = (c->clipPlanes.enable) ?
ogles_vertex_clipAllPerspective3D : ogles_vertex_perspective3D;
if (enables & (GGL_ENABLE_DEPTH_TEST|GGL_ENABLE_FOG)) {
- c->arrays.perspective = (c->clipPlanes.enable) ?
- ogles_vertex_clipAllPerspective3DZ : ogles_vertex_perspective3DZ;
+ c->arrays.perspective = ogles_vertex_perspective3DZ;
+ if (c->clipPlanes.enable || (enables&GGL_ENABLE_FOG))
+ c->arrays.perspective = ogles_vertex_clipAllPerspective3DZ;
}
if ((c->arrays.vertex.size != 4) &&
(c->transforms.mvp4.flags & transform_t::FLAGS_2D_PROJECTION)) {
diff --git a/opengl/libagl/primitives.cpp b/opengl/libagl/primitives.cpp
index 20e8d37..f164c02 100644
--- a/opengl/libagl/primitives.cpp
+++ b/opengl/libagl/primitives.cpp
@@ -133,7 +133,7 @@
{
if (!(v->flags & vertex_t::LIT)) {
v->flags |= vertex_t::LIT;
- v->fog = c->fog.fog(c, v->window.z);
+ v->fog = c->fog.fog(c, v->eye.z);
const GLvoid* cp = c->arrays.color.element(
v->index & vertex_cache_t::INDEX_MASK);
c->arrays.color.fetch(c, v->color.v, cp);
@@ -144,14 +144,14 @@
{
if (!(v->flags & vertex_t::LIT)) {
v->flags |= vertex_t::LIT;
- v->fog = c->fog.fog(c, v->window.z);
+ v->fog = c->fog.fog(c, v->eye.z);
}
}
static inline
void lightVertexSmoothFog(ogles_context_t* c, vertex_t* v)
{
if (!(v->flags & vertex_t::LIT)) {
- v->fog = c->fog.fog(c, v->window.z);
+ v->fog = c->fog.fog(c, v->eye.z);
c->lighting.lightVertex(c, v);
}
}
@@ -243,12 +243,20 @@
m_area = m_dx01*m_dy02 + (-m_dy10)*m_dx20;
}
+void compute_iterators_t::initLine(
+ vertex_t const* v0, vertex_t const* v1)
+{
+ m_dx01 = m_dy02 = v1->window.x - v0->window.x;
+ m_dy10 = m_dx20 = v0->window.y - v1->window.y;
+ m_area = m_dx01*m_dy02 + (-m_dy10)*m_dx20;
+}
+
void compute_iterators_t::initLerp(vertex_t const* v0, uint32_t enables)
{
m_x0 = v0->window.x;
m_y0 = v0->window.y;
const GGLcoord area = (m_area + TRI_HALF) >> TRI_FRACTION_BITS;
- const GGLcoord minArea = 2; // cannot be inversed
+ const GGLcoord minArea = 2; // cannot be inverted
// triangles with an area smaller than 1.0 are not smooth-shaded
int q=0, s=0, d=0;
@@ -336,6 +344,20 @@
it[2] = dcdy;
}
+void compute_iterators_t::iterators0032(int64_t* it,
+ int32_t c0, int32_t c1, int32_t c2) const
+{
+ const int s = m_area_scale - 16;
+ int32_t dc01 = (c1 - c0)>>s;
+ int32_t dc02 = (c2 - c0)>>s;
+ // 16.16 x 16.16 == 32.32
+ int64_t dcdx = gglMulii(dc01, m_dy02) + gglMulii(dc02, m_dy10);
+ int64_t dcdy = gglMulii(dc02, m_dx01) + gglMulii(dc01, m_dx20);
+ it[ 0] = (c0<<16) - ((dcdx*m_x0 + dcdy*m_y0)>>4);
+ it[ 1] = dcdx;
+ it[ 2] = dcdy;
+}
+
#if defined(__arm__) && !defined(__thumb__)
inline void compute_iterators_t::iterators0032(int32_t* it,
int32_t c0, int32_t c1, int32_t c2) const
@@ -346,16 +368,11 @@
void compute_iterators_t::iterators0032(int32_t* it,
int32_t c0, int32_t c1, int32_t c2) const
{
- const int s = m_area_scale - 16;
- int32_t dc01 = (c1 - c0)>>s;
- int32_t dc02 = (c2 - c0)>>s;
- // 16.16 x 16.16 == 32.32
- int64_t dcdx = gglMulii(dc01, m_dy02) + gglMulii(dc02, m_dy10);
- int64_t dcdy = gglMulii(dc02, m_dx01) + gglMulii(dc01, m_dx20);
- int32_t c = (c0<<16) - ((dcdx*m_x0 + dcdy*m_y0)>>4);
- it[ 0] = c;
- it[ 1] = dcdx;
- it[ 2] = dcdy;
+ int64_t it64[3];
+ iterators0032(it, c0, c1, c2);
+ it[0] = it64[0];
+ it[1] = it64[1];
+ it[2] = it64[2];
}
#endif
@@ -454,7 +471,7 @@
c->arrays.color.fetch(c, v->color.v, cp);
}
if (enables & GGL_ENABLE_FOG) {
- v->fog = c->fog.fog(c, v->window.z);
+ v->fog = c->fog.fog(c, v->eye.z);
}
}
@@ -514,22 +531,12 @@
void primitive_line(ogles_context_t* c, vertex_t* v0, vertex_t* v1)
{
- // This is a cheezy implementation of line drawing that
- // uses 2 triangles per line.
- // That said, how often line drawing is used?
-
// get texture coordinates
fetch_texcoord(c, v0, v1, v1);
// light/shade the vertices first (they're copied below)
c->lighting.lightTriangle(c, v0, v1, v1);
- vertex_t v[4];
- v[0] = *v0;
- v[1] = *v1;
- v0 = &v[0];
- v1 = &v[1];
-
// clip the line if needed
if (ggl_unlikely((v0->flags | v1->flags) & vertex_t::CLIP_ALL)) {
unsigned int count = clip_line(c, v0, v1);
@@ -546,8 +553,8 @@
GGL_ENABLE_DEPTH_TEST;
if (ggl_unlikely(enables & mask)) {
- c->lerp.initTriangle(v0, v1, v1);
- lerp_triangle(c, v0, v1, v1);
+ c->lerp.initLine(v0, v1);
+ lerp_triangle(c, v0, v1, v0);
}
// render our line
@@ -654,17 +661,26 @@
const int32_t v0z = clampZ(v0->window.z);
const int32_t v1z = clampZ(v1->window.z);
const int32_t v2z = clampZ(v2->window.z);
- lerp.iterators0032(itz, v0z, v1z, v2z);
if (ggl_unlikely(c->polygonOffset.enable)) {
+ const int32_t units = (c->polygonOffset.units << 16);
const GLfixed factor = c->polygonOffset.factor;
- const GLfixed units = c->polygonOffset.units;
- int32_t maxDepthSlope = max(abs(itz[1]), abs(itz[2]));
- int32_t offset = (int64_t(maxDepthSlope)*factor +
- (int64_t(units) << 16)) >> 16;
- itz[0] += offset; // XXX: this can cause overflows
+ if (factor) {
+ int64_t itz64[3];
+ lerp.iterators0032(itz64, v0z, v1z, v2z);
+ int64_t maxDepthSlope = max(itz64[1], itz64[2]);
+ itz[0] = uint32_t(itz64[0])
+ + uint32_t((maxDepthSlope*factor)>>16) + units;
+ itz[1] = uint32_t(itz64[1]);
+ itz[2] = uint32_t(itz64[2]);
+ } else {
+ lerp.iterators0032(itz, v0z, v1z, v2z);
+ itz[0] += units;
+ }
+ } else {
+ lerp.iterators0032(itz, v0z, v1z, v2z);
}
c->rasterizer.procs.zGrad3xv(c, itz);
- }
+ }
if (ggl_unlikely(enables & GGL_ENABLE_FOG)) {
GLfixed itf[3];
@@ -880,11 +896,11 @@
vertex_t** output = ovl;
unsigned int oc = 0;
unsigned int sentinel = 0;
- // previous vertice, compute distance to the plane
+ // previous vertex, compute distance to the plane
vertex_t* s = ivl[ic-1];
const vec4_t& equation = c->clipPlanes.plane[plane].equation;
GLfixed sd = dot4(equation.v, s->eye.v);
- // clip each vertice against this plane...
+ // clip each vertex against this plane...
for (unsigned int i=0 ; i<ic ; i++) {
vertex_t* p = ivl[i];
const GLfixed pd = dot4(equation.v, p->eye.v);
@@ -946,10 +962,10 @@
vertex_t** output = ovl;
unsigned int oc = 0;
unsigned int sentinel = 0;
- // previous vertice, compute distance to the plane
+ // previous vertex, compute distance to the plane
vertex_t* s = ivl[ic-1];
GLfixed sd = frustumPlaneDist(plane, s->clip);
- // clip each vertice against this plane...
+ // clip each vertex against this plane...
for (unsigned int i=0 ; i<ic ; i++) {
vertex_t* p = ivl[i];
const GLfixed pd = frustumPlaneDist(plane, p->clip);
diff --git a/opengl/libagl/vertex.cpp b/opengl/libagl/vertex.cpp
index 5bcc9dc..dad04d6 100644
--- a/opengl/libagl/vertex.cpp
+++ b/opengl/libagl/vertex.cpp
@@ -99,7 +99,7 @@
c->arrays.cull &= clip;
if (ggl_likely(!clip)) {
- // if the vertice is clipped, we don't do the perspective
+ // if the vertex is clipped, we don't do the perspective
// divide, since we don't need its window coordinates.
perspective(c, v, enables);
}
diff --git a/opengl/tests/Android.mk b/opengl/tests/Android.mk
new file mode 100644
index 0000000..5053e7d
--- /dev/null
+++ b/opengl/tests/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/opengl/tests/angeles/Android.mk b/opengl/tests/angeles/Android.mk
new file mode 100644
index 0000000..41673cb
--- /dev/null
+++ b/opengl/tests/angeles/Android.mk
@@ -0,0 +1,17 @@
+# Copyright 2006 The Android Open Source Project
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES:= app-linux.c demo.c.arm
+LOCAL_SHARED_LIBRARIES := libGLES_CM libui
+LOCAL_MODULE:= angeles
+LOCAL_MODULE_TAGS := tests
+include $(BUILD_EXECUTABLE)
+
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES:= gpustate.c
+LOCAL_SHARED_LIBRARIES := libGLES_CM
+LOCAL_MODULE:= gpustate
+LOCAL_MODULE_TAGS := tests
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/angeles/MODULE_LICENSE_BSD_OR_LGPL b/opengl/tests/angeles/MODULE_LICENSE_BSD_OR_LGPL
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/opengl/tests/angeles/MODULE_LICENSE_BSD_OR_LGPL
diff --git a/opengl/tests/angeles/README.txt b/opengl/tests/angeles/README.txt
new file mode 100644
index 0000000..38b8a4a
--- /dev/null
+++ b/opengl/tests/angeles/README.txt
@@ -0,0 +1,77 @@
+------------------------------------------------------------------------
+San Angeles Observation OpenGL ES version example
+Copyright 2004-2005 Jetro Lauha
+Web: http://iki.fi/jetro/
+See file license.txt for licensing information.
+------------------------------------------------------------------------
+
+This is an OpenGL ES port of the small self-running demonstration
+called "San Angeles Observation", which was first presented in the
+Assembly'2004 event. It won the first place in the 4 KB intro
+competition category.
+
+The demonstration features a sightseeing of a futuristic city
+having many different kind of buildings and items. Everything is
+flat shaded with three different lights.
+
+The original version was made for desktop with OpenGL. It was
+naturally heavily size optimized in order to fit it in the size
+limit. For this OpenGL ES version example much of the code is
+cleaned up and the sound is removed. Also detail level is lowered,
+although it still contains over 60000 faces.
+
+The Win32 (2000/XP) binary package of original version is
+available from this address: http://jet.ro/files/angeles.zip
+
+First version of this OpenGL ES port was submitted to the Khronos
+OpenGL ES Coding Challenge held in 2004-2005.
+
+As a code example, this source shows the following:
+ * How to create a minimal and portable ad hoc framework
+ for small testing/demonstration programs. This framework
+ compiles for both desktop and PocketPC Win32 environment,
+ and a separate source is included for Linux with X11.
+ * How to dynamically find and use the OpenGL ES DLL or
+ shared object, so that the library is not needed at
+ the compile/link stage.
+ * How to use the basic features of OpenGL ES 1.0/1.1
+ Common Lite, such as vertex arrays, color arrays and
+ lighting.
+ * How to create a self contained small demonstration
+ application with objects generated using procedural
+ algorithms.
+
+As the original version was optimized for size instead of
+performance, that holds true for this OpenGL ES version as
+well. Thus the performance could be significantly increased,
+for example by changing the code to use glDrawElements
+instead of glDrawArrays. The code uses only OpenGL ES 1.0
+Common Lite -level function calls without any extensions.
+
+The reference OpenGL ES implementations used for this application:
+ * Hybrid's OpenGL ES API Implementation (Gerbera) version 2.0.4
+ Prebuilt Win32 PC executable: SanOGLES-Gerbera.exe
+ * PowerVR MBX SDK, OpenGL ES Windows PC Emulation version 1.04.14.0170
+ Prebuilt Win32 PC executable: SanOGLES-PVRSDK.exe
+
+Note that DISABLE_IMPORTGL preprocessor macro can be used
+to specify not to use dynamic runtime binding of the library.
+You also need to define preprocessor macro PVRSDK to compile
+the source with PowerVR OpenGL ES SDK.
+
+The demo application is briefly tested with a few other OpenGL ES
+implementations as well (e.g. Vincent, GLESonGL on Linux, Dell
+Axim X50v). Most of these other implementations rendered the demo
+erroneously in some aspect. This may indicate that the demo source
+could still have some work to do with compatibility and correct
+API usage, although the non-conforming implementations are most
+probably unfinished as well.
+
+Thanks and Acknowledgements:
+
+* Toni Lönnberg (!Cube) created the music for original version, which
+ is not featured in this OpenGL ES port.
+* Sara Kapli (st Rana) for additional camera work.
+* Paul Bourke for information about the supershapes.
+
+------------------------------------------------------------------------
diff --git a/opengl/tests/angeles/app-linux.c b/opengl/tests/angeles/app-linux.c
new file mode 100644
index 0000000..d439eb2
--- /dev/null
+++ b/opengl/tests/angeles/app-linux.c
@@ -0,0 +1,222 @@
+/* San Angeles Observation OpenGL ES version example
+ * Copyright 2004-2005 Jetro Lauha
+ * All rights reserved.
+ * Web: http://iki.fi/jetro/
+ *
+ * This source is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER:
+ * (1) The GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version. The text of the GNU Lesser
+ * General Public License is included with this source in the
+ * file LICENSE-LGPL.txt.
+ * (2) The BSD-style license that is included with this source in
+ * the file LICENSE-BSD.txt.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
+ *
+ * $Id: app-linux.c,v 1.4 2005/02/08 18:42:48 tonic Exp $
+ * $Revision: 1.4 $
+ *
+ * Parts of this source file is based on test/example code from
+ * GLESonGL implementation by David Blythe. Here is copy of the
+ * license notice from that source:
+ *
+ * Copyright (C) 2003 David Blythe All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * DAVID BLYTHE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/time.h>
+
+#include <GLES/egl.h>
+
+#include "app.h"
+
+
+int gAppAlive = 1;
+
+static const char sAppName[] =
+ "San Angeles Observation OpenGL ES version example (Linux)";
+
+static int sWindowWidth = WINDOW_DEFAULT_WIDTH;
+static int sWindowHeight = WINDOW_DEFAULT_HEIGHT;
+static EGLDisplay sEglDisplay = EGL_NO_DISPLAY;
+static EGLContext sEglContext = EGL_NO_CONTEXT;
+static EGLSurface sEglSurface = EGL_NO_SURFACE;
+
+const char *egl_strerror(unsigned err)
+{
+ switch(err){
+ case EGL_SUCCESS: return "SUCCESS";
+ case EGL_NOT_INITIALIZED: return "NOT INITIALIZED";
+ case EGL_BAD_ACCESS: return "BAD ACCESS";
+ case EGL_BAD_ALLOC: return "BAD ALLOC";
+ case EGL_BAD_ATTRIBUTE: return "BAD_ATTRIBUTE";
+ case EGL_BAD_CONFIG: return "BAD CONFIG";
+ case EGL_BAD_CONTEXT: return "BAD CONTEXT";
+ case EGL_BAD_CURRENT_SURFACE: return "BAD CURRENT SURFACE";
+ case EGL_BAD_DISPLAY: return "BAD DISPLAY";
+ case EGL_BAD_MATCH: return "BAD MATCH";
+ case EGL_BAD_NATIVE_PIXMAP: return "BAD NATIVE PIXMAP";
+ case EGL_BAD_NATIVE_WINDOW: return "BAD NATIVE WINDOW";
+ case EGL_BAD_PARAMETER: return "BAD PARAMETER";
+ case EGL_BAD_SURFACE: return "BAD_SURFACE";
+// case EGL_CONTEXT_LOST: return "CONTEXT LOST";
+ default: return "UNKNOWN";
+ }
+}
+
+void egl_error(const char *name)
+{
+ unsigned err = eglGetError();
+ if(err != EGL_SUCCESS) {
+ fprintf(stderr,"%s(): egl error 0x%x (%s)\n",
+ name, err, egl_strerror(err));
+ }
+}
+
+static void checkGLErrors()
+{
+ GLenum error = glGetError();
+ if (error != GL_NO_ERROR)
+ fprintf(stderr, "GL Error: 0x%04x\n", (int)error);
+}
+
+
+static void checkEGLErrors()
+{
+ EGLint error = eglGetError();
+ // GLESonGL seems to be returning 0 when there is no errors?
+ if (error && error != EGL_SUCCESS)
+ fprintf(stderr, "EGL Error: 0x%04x\n", (int)error);
+}
+
+static int initGraphics()
+{
+ EGLint s_configAttribs[] = {
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ #if 1
+ EGL_DEPTH_SIZE, 16,
+ EGL_STENCIL_SIZE, 0,
+ #else
+ EGL_ALPHA_SIZE, EGL_DONT_CARE,
+ EGL_DEPTH_SIZE, EGL_DONT_CARE,
+ EGL_STENCIL_SIZE, EGL_DONT_CARE,
+ EGL_SURFACE_TYPE, EGL_DONT_CARE,
+ #endif
+ EGL_NONE
+ };
+
+ EGLint numConfigs = -1;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLConfig config;
+ EGLContext context;
+ EGLSurface surface;
+
+ EGLDisplay dpy;
+
+ dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ egl_error("eglGetDisplay");
+ fprintf(stderr,"dpy = 0x%08x\n", (unsigned) dpy);
+
+ eglInitialize(dpy, &majorVersion, &minorVersion);
+ egl_error("eglInitialize");
+
+ eglGetConfigs(dpy, NULL, 0, &numConfigs);
+ egl_error("eglGetConfigs");
+ fprintf(stderr,"num configs %d\n", numConfigs);
+
+ eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+ egl_error("eglChooseConfig");
+
+ surface = eglCreateWindowSurface(dpy, config,
+ android_createDisplaySurface(), NULL);
+ egl_error("eglMapWindowSurface");
+
+ fprintf(stderr,"surface = %p\n", surface);
+
+ context = eglCreateContext(dpy, config, NULL, NULL);
+ egl_error("eglCreateContext");
+ fprintf(stderr,"context = %p\n", context);
+
+ eglMakeCurrent(dpy, surface, surface, context);
+ egl_error("eglMakeCurrent");
+
+ eglQuerySurface(dpy, surface, EGL_WIDTH, &sWindowWidth);
+ eglQuerySurface(dpy, surface, EGL_HEIGHT, &sWindowHeight);
+
+ sEglDisplay = dpy;
+ sEglSurface = surface;
+ sEglContext = context;
+
+ return EGL_TRUE;
+}
+
+
+static void deinitGraphics()
+{
+ eglMakeCurrent(sEglDisplay, NULL, NULL, NULL);
+ eglDestroyContext(sEglDisplay, sEglContext);
+ eglDestroySurface(sEglDisplay, sEglSurface);
+ eglTerminate(sEglDisplay);
+}
+
+
+int main(int argc, char *argv[])
+{
+ // not referenced:
+ argc = argc;
+ argv = argv;
+
+ if (!initGraphics())
+ {
+ fprintf(stderr, "Graphics initialization failed.\n");
+ return EXIT_FAILURE;
+ }
+
+ appInit();
+
+ while (gAppAlive)
+ {
+ struct timeval timeNow;
+
+ if (gAppAlive)
+ {
+ gettimeofday(&timeNow, NULL);
+ appRender(timeNow.tv_sec * 1000 + timeNow.tv_usec / 1000,
+ sWindowWidth, sWindowHeight);
+ checkGLErrors();
+ eglSwapBuffers(sEglDisplay, sEglSurface);
+ checkEGLErrors();
+ }
+ }
+
+ appDeinit();
+ deinitGraphics();
+
+ return EXIT_SUCCESS;
+}
diff --git a/opengl/tests/angeles/app.h b/opengl/tests/angeles/app.h
new file mode 100644
index 0000000..70ebd35
--- /dev/null
+++ b/opengl/tests/angeles/app.h
@@ -0,0 +1,56 @@
+/* San Angeles Observation OpenGL ES version example
+ * Copyright 2004-2005 Jetro Lauha
+ * All rights reserved.
+ * Web: http://iki.fi/jetro/
+ *
+ * This source is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER:
+ * (1) The GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version. The text of the GNU Lesser
+ * General Public License is included with this source in the
+ * file LICENSE-LGPL.txt.
+ * (2) The BSD-style license that is included with this source in
+ * the file LICENSE-BSD.txt.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
+ *
+ * $Id: app.h,v 1.14 2005/02/06 21:13:54 tonic Exp $
+ * $Revision: 1.14 $
+ */
+
+#ifndef APP_H_INCLUDED
+#define APP_H_INCLUDED
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define WINDOW_DEFAULT_WIDTH 640
+#define WINDOW_DEFAULT_HEIGHT 480
+
+#define WINDOW_BPP 16
+
+
+// The simple framework expects the application code to define these functions.
+extern void appInit();
+extern void appDeinit();
+extern void appRender(long tick, int width, int height);
+
+/* Value is non-zero when application is alive, and 0 when it is closing.
+ * Defined by the application framework.
+ */
+extern int gAppAlive;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // !APP_H_INCLUDED
diff --git a/opengl/tests/angeles/cams.h b/opengl/tests/angeles/cams.h
new file mode 100644
index 0000000..2b1acb3
--- /dev/null
+++ b/opengl/tests/angeles/cams.h
@@ -0,0 +1,65 @@
+/* San Angeles Observation OpenGL ES version example
+ * Copyright 2004-2005 Jetro Lauha
+ * All rights reserved.
+ * Web: http://iki.fi/jetro/
+ *
+ * This source is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER:
+ * (1) The GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version. The text of the GNU Lesser
+ * General Public License is included with this source in the
+ * file LICENSE-LGPL.txt.
+ * (2) The BSD-style license that is included with this source in
+ * the file LICENSE-BSD.txt.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
+ *
+ * $Id: cams.h,v 1.7 2005/01/31 22:15:15 tonic Exp $
+ * $Revision: 1.7 $
+ */
+
+#ifndef CAMS_H_INCLUDED
+#define CAMS_H_INCLUDED
+
+
+/* Length in milliseconds of one camera track base unit.
+ * The value originates from the music synchronization.
+ */
+#define CAMTRACK_LEN 5442
+
+
+// Camera track definition for one camera trucking shot.
+typedef struct
+{
+ /* Five parameters of src[5] and dest[5]:
+ * eyeX, eyeY, eyeZ, viewAngle, viewHeightOffs
+ */
+ short src[5], dest[5];
+ unsigned char dist; // if >0, cam rotates around eye xy on dist * 0.1
+ unsigned char len; // length multiplier
+} CAMTRACK;
+
+static CAMTRACK sCamTracks[] =
+{
+ { { 4500, 2700, 100, 70, -30 }, { 50, 50, -90, -100, 0 }, 20, 1 },
+ { { -1448, 4294, 25, 363, 0 }, { -136, 202, 125, -98, 100 }, 0, 1 },
+ { { 1437, 4930, 200, -275, -20 }, { 1684, 0, 0, 9, 0 }, 0, 1 },
+ { { 1800, 3609, 200, 0, 675 }, { 0, 0, 0, 300, 0 }, 0, 1 },
+ { { 923, 996, 50, 2336, -80 }, { 0, -20, -50, 0, 170 }, 0, 1 },
+ { { -1663, -43, 600, 2170, 0 }, { 20, 0, -600, 0, 100 }, 0, 1 },
+ { { 1049, -1420, 175, 2111, -17 }, { 0, 0, 0, -334, 0 }, 0, 2 },
+ { { 0, 0, 50, 300, 25 }, { 0, 0, 0, 300, 0 }, 70, 2 },
+ { { -473, -953, 3500, -353, -350 }, { 0, 0, -2800, 0, 0 }, 0, 2 },
+ { { 191, 1938, 35, 1139, -17 }, { 1205, -2909, 0, 0, 0 }, 0, 2 },
+ { { -1449, -2700, 150, 0, 0 }, { 0, 2000, 0, 0, 0 }, 0, 2 },
+ { { 5273, 4992, 650, 373, -50 }, { -4598, -3072, 0, 0, 0 }, 0, 2 },
+ { { 3223, -3282, 1075, -393, -25 }, { 1649, -1649, 0, 0, 0 }, 0, 2 }
+};
+#define CAMTRACK_COUNT (sizeof(camTracks) / sizeof(camTracks[0]))
+
+
+#endif // !CAMS_H_INCLUDED
diff --git a/opengl/tests/angeles/demo.c b/opengl/tests/angeles/demo.c
new file mode 100644
index 0000000..802f398
--- /dev/null
+++ b/opengl/tests/angeles/demo.c
@@ -0,0 +1,792 @@
+/* San Angeles Observation OpenGL ES version example
+ * Copyright 2004-2005 Jetro Lauha
+ * All rights reserved.
+ * Web: http://iki.fi/jetro/
+ *
+ * This source is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER:
+ * (1) The GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version. The text of the GNU Lesser
+ * General Public License is included with this source in the
+ * file LICENSE-LGPL.txt.
+ * (2) The BSD-style license that is included with this source in
+ * the file LICENSE-BSD.txt.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
+ *
+ * $Id: demo.c,v 1.10 2005/02/08 20:54:39 tonic Exp $
+ * $Revision: 1.10 $
+ */
+
+#include <stdlib.h>
+#include <math.h>
+#include <float.h>
+#include <assert.h>
+
+#include <GLES/gl.h>
+
+#include "app.h"
+#include "shapes.h"
+#include "cams.h"
+
+
+// Total run length is 20 * camera track base unit length (see cams.h).
+#define RUN_LENGTH (20 * CAMTRACK_LEN)
+#undef PI
+#define PI 3.1415926535897932f
+#define RANDOM_UINT_MAX 65535
+
+
+static unsigned long sRandomSeed = 0;
+
+static void seedRandom(unsigned long seed)
+{
+ sRandomSeed = seed;
+}
+
+static unsigned long randomUInt()
+{
+ sRandomSeed = sRandomSeed * 0x343fd + 0x269ec3;
+ return sRandomSeed >> 16;
+}
+
+
+// Capped conversion from float to fixed.
+static long floatToFixed(float value)
+{
+ if (value < -32768) value = -32768;
+ if (value > 32767) value = 32767;
+ return (long)(value * 65536);
+}
+
+#define FIXED(value) floatToFixed(value)
+
+
+// Definition of one GL object in this demo.
+typedef struct {
+ /* Vertex array and color array are enabled for all objects, so their
+ * pointers must always be valid and non-NULL. Normal array is not
+ * used by the ground plane, so when its pointer is NULL then normal
+ * array usage is disabled.
+ *
+ * Vertex array is supposed to use GL_FIXED datatype and stride 0
+ * (i.e. tightly packed array). Color array is supposed to have 4
+ * components per color with GL_UNSIGNED_BYTE datatype and stride 0.
+ * Normal array is supposed to use GL_FIXED datatype and stride 0.
+ */
+ GLfixed *vertexArray;
+ GLubyte *colorArray;
+ GLfixed *normalArray;
+ GLint vertexComponents;
+ GLsizei count;
+} GLOBJECT;
+
+
+static long sStartTick = 0;
+static long sTick = 0;
+
+static int sCurrentCamTrack = 0;
+static long sCurrentCamTrackStartTick = 0;
+static long sNextCamTrackStartTick = 0x7fffffff;
+
+static GLOBJECT *sSuperShapeObjects[SUPERSHAPE_COUNT] = { NULL };
+static GLOBJECT *sGroundPlane = NULL;
+
+
+typedef struct {
+ float x, y, z;
+} VECTOR3;
+
+
+static void freeGLObject(GLOBJECT *object)
+{
+ if (object == NULL)
+ return;
+ free(object->normalArray);
+ free(object->colorArray);
+ free(object->vertexArray);
+ free(object);
+}
+
+
+static GLOBJECT * newGLObject(long vertices, int vertexComponents,
+ int useNormalArray)
+{
+ GLOBJECT *result;
+ result = (GLOBJECT *)malloc(sizeof(GLOBJECT));
+ if (result == NULL)
+ return NULL;
+ result->count = vertices;
+ result->vertexComponents = vertexComponents;
+ result->vertexArray = (GLfixed *)malloc(vertices * vertexComponents *
+ sizeof(GLfixed));
+ result->colorArray = (GLubyte *)malloc(vertices * 4 * sizeof(GLubyte));
+ if (useNormalArray)
+ {
+ result->normalArray = (GLfixed *)malloc(vertices * 3 *
+ sizeof(GLfixed));
+ }
+ else
+ result->normalArray = NULL;
+ if (result->vertexArray == NULL ||
+ result->colorArray == NULL ||
+ (useNormalArray && result->normalArray == NULL))
+ {
+ freeGLObject(result);
+ return NULL;
+ }
+ return result;
+}
+
+
+static void drawGLObject(GLOBJECT *object)
+{
+ assert(object != NULL);
+
+ glVertexPointer(object->vertexComponents, GL_FIXED,
+ 0, object->vertexArray);
+ glColorPointer(4, GL_UNSIGNED_BYTE, 0, object->colorArray);
+
+ // Already done in initialization:
+ //glEnableClientState(GL_VERTEX_ARRAY);
+ //glEnableClientState(GL_COLOR_ARRAY);
+
+ if (object->normalArray)
+ {
+ glNormalPointer(GL_FIXED, 0, object->normalArray);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ }
+ else
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDrawArrays(GL_TRIANGLES, 0, object->count);
+}
+
+
+static void vector3Sub(VECTOR3 *dest, VECTOR3 *v1, VECTOR3 *v2)
+{
+ dest->x = v1->x - v2->x;
+ dest->y = v1->y - v2->y;
+ dest->z = v1->z - v2->z;
+}
+
+
+static void superShapeMap(VECTOR3 *point, float r1, float r2, float t, float p)
+{
+ // sphere-mapping of supershape parameters
+ point->x = (float)(cos(t) * cos(p) / r1 / r2);
+ point->y = (float)(sin(t) * cos(p) / r1 / r2);
+ point->z = (float)(sin(p) / r2);
+}
+
+
+static float ssFunc(const float t, const float *p)
+{
+ return (float)(pow(pow(fabs(cos(p[0] * t / 4)) / p[1], p[4]) +
+ pow(fabs(sin(p[0] * t / 4)) / p[2], p[5]), 1 / p[3]));
+}
+
+
+// Creates and returns a supershape object.
+// Based on Paul Bourke's POV-Ray implementation.
+// http://astronomy.swin.edu.au/~pbourke/povray/supershape/
+static GLOBJECT * createSuperShape(const float *params)
+{
+ const int resol1 = (int)params[SUPERSHAPE_PARAMS - 3];
+ const int resol2 = (int)params[SUPERSHAPE_PARAMS - 2];
+ // latitude 0 to pi/2 for no mirrored bottom
+ // (latitudeBegin==0 for -pi/2 to pi/2 originally)
+ const int latitudeBegin = resol2 / 4;
+ const int latitudeEnd = resol2 / 2; // non-inclusive
+ const int longitudeCount = resol1;
+ const int latitudeCount = latitudeEnd - latitudeBegin;
+ const long triangleCount = longitudeCount * latitudeCount * 2;
+ const long vertices = triangleCount * 3;
+ GLOBJECT *result;
+ float baseColor[3];
+ int a, longitude, latitude;
+ long currentVertex, currentQuad;
+
+ result = newGLObject(vertices, 3, 1);
+ if (result == NULL)
+ return NULL;
+
+ for (a = 0; a < 3; ++a)
+ baseColor[a] = ((randomUInt() % 155) + 100) / 255.f;
+
+ currentQuad = 0;
+ currentVertex = 0;
+
+ // longitude -pi to pi
+ for (longitude = 0; longitude < longitudeCount; ++longitude)
+ {
+
+ // latitude 0 to pi/2
+ for (latitude = latitudeBegin; latitude < latitudeEnd; ++latitude)
+ {
+ float t1 = -PI + longitude * 2 * PI / resol1;
+ float t2 = -PI + (longitude + 1) * 2 * PI / resol1;
+ float p1 = -PI / 2 + latitude * 2 * PI / resol2;
+ float p2 = -PI / 2 + (latitude + 1) * 2 * PI / resol2;
+ float r0, r1, r2, r3;
+
+ r0 = ssFunc(t1, params);
+ r1 = ssFunc(p1, ¶ms[6]);
+ r2 = ssFunc(t2, params);
+ r3 = ssFunc(p2, ¶ms[6]);
+
+ if (r0 != 0 && r1 != 0 && r2 != 0 && r3 != 0)
+ {
+ VECTOR3 pa, pb, pc, pd;
+ VECTOR3 v1, v2, n;
+ float ca;
+ int i;
+ //float lenSq, invLenSq;
+
+ superShapeMap(&pa, r0, r1, t1, p1);
+ superShapeMap(&pb, r2, r1, t2, p1);
+ superShapeMap(&pc, r2, r3, t2, p2);
+ superShapeMap(&pd, r0, r3, t1, p2);
+
+ // kludge to set lower edge of the object to fixed level
+ if (latitude == latitudeBegin + 1)
+ pa.z = pb.z = 0;
+
+ vector3Sub(&v1, &pb, &pa);
+ vector3Sub(&v2, &pd, &pa);
+
+ // Calculate normal with cross product.
+ /* i j k i j
+ * v1.x v1.y v1.z | v1.x v1.y
+ * v2.x v2.y v2.z | v2.x v2.y
+ */
+
+ n.x = v1.y * v2.z - v1.z * v2.y;
+ n.y = v1.z * v2.x - v1.x * v2.z;
+ n.z = v1.x * v2.y - v1.y * v2.x;
+
+ /* Pre-normalization of the normals is disabled here because
+ * they will be normalized anyway later due to automatic
+ * normalization (GL_NORMALIZE). It is enabled because the
+ * objects are scaled with glScale.
+ */
+ /*
+ lenSq = n.x * n.x + n.y * n.y + n.z * n.z;
+ invLenSq = (float)(1 / sqrt(lenSq));
+ n.x *= invLenSq;
+ n.y *= invLenSq;
+ n.z *= invLenSq;
+ */
+
+ ca = pa.z + 0.5f;
+
+ for (i = currentVertex * 3;
+ i < (currentVertex + 6) * 3;
+ i += 3)
+ {
+ result->normalArray[i] = FIXED(n.x);
+ result->normalArray[i + 1] = FIXED(n.y);
+ result->normalArray[i + 2] = FIXED(n.z);
+ }
+ for (i = currentVertex * 4;
+ i < (currentVertex + 6) * 4;
+ i += 4)
+ {
+ int a, color[3];
+ for (a = 0; a < 3; ++a)
+ {
+ color[a] = (int)(ca * baseColor[a] * 255);
+ if (color[a] > 255) color[a] = 255;
+ }
+ result->colorArray[i] = (GLubyte)color[0];
+ result->colorArray[i + 1] = (GLubyte)color[1];
+ result->colorArray[i + 2] = (GLubyte)color[2];
+ result->colorArray[i + 3] = 0;
+ }
+ result->vertexArray[currentVertex * 3] = FIXED(pa.x);
+ result->vertexArray[currentVertex * 3 + 1] = FIXED(pa.y);
+ result->vertexArray[currentVertex * 3 + 2] = FIXED(pa.z);
+ ++currentVertex;
+ result->vertexArray[currentVertex * 3] = FIXED(pb.x);
+ result->vertexArray[currentVertex * 3 + 1] = FIXED(pb.y);
+ result->vertexArray[currentVertex * 3 + 2] = FIXED(pb.z);
+ ++currentVertex;
+ result->vertexArray[currentVertex * 3] = FIXED(pd.x);
+ result->vertexArray[currentVertex * 3 + 1] = FIXED(pd.y);
+ result->vertexArray[currentVertex * 3 + 2] = FIXED(pd.z);
+ ++currentVertex;
+ result->vertexArray[currentVertex * 3] = FIXED(pb.x);
+ result->vertexArray[currentVertex * 3 + 1] = FIXED(pb.y);
+ result->vertexArray[currentVertex * 3 + 2] = FIXED(pb.z);
+ ++currentVertex;
+ result->vertexArray[currentVertex * 3] = FIXED(pc.x);
+ result->vertexArray[currentVertex * 3 + 1] = FIXED(pc.y);
+ result->vertexArray[currentVertex * 3 + 2] = FIXED(pc.z);
+ ++currentVertex;
+ result->vertexArray[currentVertex * 3] = FIXED(pd.x);
+ result->vertexArray[currentVertex * 3 + 1] = FIXED(pd.y);
+ result->vertexArray[currentVertex * 3 + 2] = FIXED(pd.z);
+ ++currentVertex;
+ } // r0 && r1 && r2 && r3
+ ++currentQuad;
+ } // latitude
+ } // longitude
+
+ // Set number of vertices in object to the actual amount created.
+ result->count = currentVertex;
+
+ return result;
+}
+
+
+static GLOBJECT * createGroundPlane()
+{
+ const int scale = 4;
+ const int yBegin = -15, yEnd = 15; // ends are non-inclusive
+ const int xBegin = -15, xEnd = 15;
+ const long triangleCount = (yEnd - yBegin) * (xEnd - xBegin) * 2;
+ const long vertices = triangleCount * 3;
+ GLOBJECT *result;
+ int x, y;
+ long currentVertex, currentQuad;
+
+ result = newGLObject(vertices, 2, 0);
+ if (result == NULL)
+ return NULL;
+
+ currentQuad = 0;
+ currentVertex = 0;
+
+ for (y = yBegin; y < yEnd; ++y)
+ {
+ for (x = xBegin; x < xEnd; ++x)
+ {
+ GLubyte color;
+ int i, a;
+ color = (GLubyte)((randomUInt() & 0x5f) + 81); // 101 1111
+ for (i = currentVertex * 4; i < (currentVertex + 6) * 4; i += 4)
+ {
+ result->colorArray[i] = color;
+ result->colorArray[i + 1] = color;
+ result->colorArray[i + 2] = color;
+ result->colorArray[i + 3] = 0;
+ }
+
+ // Axis bits for quad triangles:
+ // x: 011100 (0x1c), y: 110001 (0x31) (clockwise)
+ // x: 001110 (0x0e), y: 100011 (0x23) (counter-clockwise)
+ for (a = 0; a < 6; ++a)
+ {
+ const int xm = x + ((0x1c >> a) & 1);
+ const int ym = y + ((0x31 >> a) & 1);
+ const float m = (float)(cos(xm * 2) * sin(ym * 4) * 0.75f);
+ result->vertexArray[currentVertex * 2] =
+ FIXED(xm * scale + m);
+ result->vertexArray[currentVertex * 2 + 1] =
+ FIXED(ym * scale + m);
+ ++currentVertex;
+ }
+ ++currentQuad;
+ }
+ }
+ return result;
+}
+
+
+static void drawGroundPlane()
+{
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+ glDisable(GL_LIGHTING);
+
+ drawGLObject(sGroundPlane);
+
+ glEnable(GL_LIGHTING);
+ glDisable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+}
+
+
+static void drawFadeQuad()
+{
+ static const GLfixed quadVertices[] = {
+ -0x10000, -0x10000,
+ 0x10000, -0x10000,
+ -0x10000, 0x10000,
+ 0x10000, -0x10000,
+ 0x10000, 0x10000,
+ -0x10000, 0x10000
+ };
+
+ const int beginFade = sTick - sCurrentCamTrackStartTick;
+ const int endFade = sNextCamTrackStartTick - sTick;
+ const int minFade = beginFade < endFade ? beginFade : endFade;
+
+ if (minFade < 1024)
+ {
+ const GLfixed fadeColor = minFade << 6;
+ glColor4x(fadeColor, fadeColor, fadeColor, 0);
+
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+ glDisable(GL_LIGHTING);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glVertexPointer(2, GL_FIXED, 0, quadVertices);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+
+ glEnableClientState(GL_COLOR_ARRAY);
+
+ glMatrixMode(GL_MODELVIEW);
+
+ glEnable(GL_LIGHTING);
+ glDisable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+ }
+}
+
+
+// Called from the app framework.
+void appInit()
+{
+ int a;
+
+ glEnable(GL_NORMALIZE);
+ glEnable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glShadeModel(GL_FLAT);
+
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+ glEnable(GL_LIGHT1);
+ glEnable(GL_LIGHT2);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+
+ seedRandom(15);
+
+ for (a = 0; a < SUPERSHAPE_COUNT; ++a)
+ {
+ sSuperShapeObjects[a] = createSuperShape(sSuperShapeParams[a]);
+ assert(sSuperShapeObjects[a] != NULL);
+ }
+ sGroundPlane = createGroundPlane();
+ assert(sGroundPlane != NULL);
+}
+
+
+// Called from the app framework.
+void appDeinit()
+{
+ int a;
+ for (a = 0; a < SUPERSHAPE_COUNT; ++a)
+ freeGLObject(sSuperShapeObjects[a]);
+ freeGLObject(sGroundPlane);
+}
+
+
+static void gluPerspective(GLfloat fovy, GLfloat aspect,
+ GLfloat zNear, GLfloat zFar)
+{
+ GLfloat xmin, xmax, ymin, ymax;
+
+ ymax = zNear * (GLfloat)tan(fovy * PI / 360);
+ ymin = -ymax;
+ xmin = ymin * aspect;
+ xmax = ymax * aspect;
+
+ glFrustumx((GLfixed)(xmin * 65536), (GLfixed)(xmax * 65536),
+ (GLfixed)(ymin * 65536), (GLfixed)(ymax * 65536),
+ (GLfixed)(zNear * 65536), (GLfixed)(zFar * 65536));
+}
+
+
+static void prepareFrame(int width, int height)
+{
+ glViewport(0, 0, width, height);
+
+ glClearColorx((GLfixed)(0.1f * 65536),
+ (GLfixed)(0.2f * 65536),
+ (GLfixed)(0.3f * 65536), 0x10000);
+ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(45, (float)width / height, 0.5f, 150);
+
+ glMatrixMode(GL_MODELVIEW);
+
+ glLoadIdentity();
+}
+
+
+static void configureLightAndMaterial()
+{
+ static GLfixed light0Position[] = { -0x40000, 0x10000, 0x10000, 0 };
+ static GLfixed light0Diffuse[] = { 0x10000, 0x6666, 0, 0x10000 };
+ static GLfixed light1Position[] = { 0x10000, -0x20000, -0x10000, 0 };
+ static GLfixed light1Diffuse[] = { 0x11eb, 0x23d7, 0x5999, 0x10000 };
+ static GLfixed light2Position[] = { -0x10000, 0, -0x40000, 0 };
+ static GLfixed light2Diffuse[] = { 0x11eb, 0x2b85, 0x23d7, 0x10000 };
+ static GLfixed materialSpecular[] = { 0x10000, 0x10000, 0x10000, 0x10000 };
+
+ glLightxv(GL_LIGHT0, GL_POSITION, light0Position);
+ glLightxv(GL_LIGHT0, GL_DIFFUSE, light0Diffuse);
+ glLightxv(GL_LIGHT1, GL_POSITION, light1Position);
+ glLightxv(GL_LIGHT1, GL_DIFFUSE, light1Diffuse);
+ glLightxv(GL_LIGHT2, GL_POSITION, light2Position);
+ glLightxv(GL_LIGHT2, GL_DIFFUSE, light2Diffuse);
+ glMaterialxv(GL_FRONT_AND_BACK, GL_SPECULAR, materialSpecular);
+
+ glMaterialx(GL_FRONT_AND_BACK, GL_SHININESS, 60 << 16);
+ glEnable(GL_COLOR_MATERIAL);
+}
+
+
+static void drawModels(float zScale)
+{
+ const int translationScale = 9;
+ int x, y;
+
+ seedRandom(9);
+
+ glScalex(1 << 16, 1 << 16, (GLfixed)(zScale * 65536));
+
+ for (y = -5; y <= 5; ++y)
+ {
+ for (x = -5; x <= 5; ++x)
+ {
+ float buildingScale;
+ GLfixed fixedScale;
+
+ int curShape = randomUInt() % SUPERSHAPE_COUNT;
+ buildingScale = sSuperShapeParams[curShape][SUPERSHAPE_PARAMS - 1];
+ fixedScale = (GLfixed)(buildingScale * 65536);
+
+ glPushMatrix();
+ glTranslatex((x * translationScale) * 65536,
+ (y * translationScale) * 65536,
+ 0);
+ glRotatex((GLfixed)((randomUInt() % 360) << 16), 0, 0, 1 << 16);
+ glScalex(fixedScale, fixedScale, fixedScale);
+
+ drawGLObject(sSuperShapeObjects[curShape]);
+ glPopMatrix();
+ }
+ }
+
+ for (x = -2; x <= 2; ++x)
+ {
+ const int shipScale100 = translationScale * 500;
+ const int offs100 = x * shipScale100 + (sTick % shipScale100);
+ float offs = offs100 * 0.01f;
+ GLfixed fixedOffs = (GLfixed)(offs * 65536);
+ glPushMatrix();
+ glTranslatex(fixedOffs, -4 * 65536, 2 << 16);
+ drawGLObject(sSuperShapeObjects[SUPERSHAPE_COUNT - 1]);
+ glPopMatrix();
+ glPushMatrix();
+ glTranslatex(-4 * 65536, fixedOffs, 4 << 16);
+ glRotatex(90 << 16, 0, 0, 1 << 16);
+ drawGLObject(sSuperShapeObjects[SUPERSHAPE_COUNT - 1]);
+ glPopMatrix();
+ }
+}
+
+
+/* Following gluLookAt implementation is adapted from the
+ * Mesa 3D Graphics library. http://www.mesa3d.org
+ */
+static void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez,
+ GLfloat centerx, GLfloat centery, GLfloat centerz,
+ GLfloat upx, GLfloat upy, GLfloat upz)
+{
+ GLfloat m[16];
+ GLfloat x[3], y[3], z[3];
+ GLfloat mag;
+
+ /* Make rotation matrix */
+
+ /* Z vector */
+ z[0] = eyex - centerx;
+ z[1] = eyey - centery;
+ z[2] = eyez - centerz;
+ mag = (float)sqrt(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
+ if (mag) { /* mpichler, 19950515 */
+ z[0] /= mag;
+ z[1] /= mag;
+ z[2] /= mag;
+ }
+
+ /* Y vector */
+ y[0] = upx;
+ y[1] = upy;
+ y[2] = upz;
+
+ /* X vector = Y cross Z */
+ x[0] = y[1] * z[2] - y[2] * z[1];
+ x[1] = -y[0] * z[2] + y[2] * z[0];
+ x[2] = y[0] * z[1] - y[1] * z[0];
+
+ /* Recompute Y = Z cross X */
+ y[0] = z[1] * x[2] - z[2] * x[1];
+ y[1] = -z[0] * x[2] + z[2] * x[0];
+ y[2] = z[0] * x[1] - z[1] * x[0];
+
+ /* mpichler, 19950515 */
+ /* cross product gives area of parallelogram, which is < 1.0 for
+ * non-perpendicular unit-length vectors; so normalize x, y here
+ */
+
+ mag = (float)sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
+ if (mag) {
+ x[0] /= mag;
+ x[1] /= mag;
+ x[2] /= mag;
+ }
+
+ mag = (float)sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
+ if (mag) {
+ y[0] /= mag;
+ y[1] /= mag;
+ y[2] /= mag;
+ }
+
+#define M(row,col) m[col*4+row]
+ M(0, 0) = x[0];
+ M(0, 1) = x[1];
+ M(0, 2) = x[2];
+ M(0, 3) = 0.0;
+ M(1, 0) = y[0];
+ M(1, 1) = y[1];
+ M(1, 2) = y[2];
+ M(1, 3) = 0.0;
+ M(2, 0) = z[0];
+ M(2, 1) = z[1];
+ M(2, 2) = z[2];
+ M(2, 3) = 0.0;
+ M(3, 0) = 0.0;
+ M(3, 1) = 0.0;
+ M(3, 2) = 0.0;
+ M(3, 3) = 1.0;
+#undef M
+ {
+ int a;
+ GLfixed fixedM[16];
+ for (a = 0; a < 16; ++a)
+ fixedM[a] = (GLfixed)(m[a] * 65536);
+ glMultMatrixx(fixedM);
+ }
+
+ /* Translate Eye to Origin */
+ glTranslatex((GLfixed)(-eyex * 65536),
+ (GLfixed)(-eyey * 65536),
+ (GLfixed)(-eyez * 65536));
+}
+
+
+static void camTrack()
+{
+ float lerp[5];
+ float eX, eY, eZ, cX, cY, cZ;
+ float trackPos;
+ CAMTRACK *cam;
+ long currentCamTick;
+ int a;
+
+ if (sNextCamTrackStartTick <= sTick)
+ {
+ ++sCurrentCamTrack;
+ sCurrentCamTrackStartTick = sNextCamTrackStartTick;
+ }
+ sNextCamTrackStartTick = sCurrentCamTrackStartTick +
+ sCamTracks[sCurrentCamTrack].len * CAMTRACK_LEN;
+
+ cam = &sCamTracks[sCurrentCamTrack];
+ currentCamTick = sTick - sCurrentCamTrackStartTick;
+ trackPos = (float)currentCamTick / (CAMTRACK_LEN * cam->len);
+
+ for (a = 0; a < 5; ++a)
+ lerp[a] = (cam->src[a] + cam->dest[a] * trackPos) * 0.01f;
+
+ if (cam->dist)
+ {
+ float dist = cam->dist * 0.1f;
+ cX = lerp[0];
+ cY = lerp[1];
+ cZ = lerp[2];
+ eX = cX - (float)cos(lerp[3]) * dist;
+ eY = cY - (float)sin(lerp[3]) * dist;
+ eZ = cZ - lerp[4];
+ }
+ else
+ {
+ eX = lerp[0];
+ eY = lerp[1];
+ eZ = lerp[2];
+ cX = eX + (float)cos(lerp[3]);
+ cY = eY + (float)sin(lerp[3]);
+ cZ = eZ + lerp[4];
+ }
+ gluLookAt(eX, eY, eZ, cX, cY, cZ, 0, 0, 1);
+}
+
+
+// Called from the app framework.
+/* The tick is current time in milliseconds, width and height
+ * are the image dimensions to be rendered.
+ */
+void appRender(long tick, int width, int height)
+{
+ if (sStartTick == 0)
+ sStartTick = tick;
+ if (!gAppAlive)
+ return;
+
+ // Actual tick value is "blurred" a little bit.
+ sTick = (sTick + tick - sStartTick) >> 1;
+
+ // Terminate application after running through the demonstration once.
+ if (sTick >= RUN_LENGTH)
+ {
+ gAppAlive = 0;
+ return;
+ }
+
+ // Prepare OpenGL ES for rendering of the frame.
+ prepareFrame(width, height);
+
+ // Update the camera position and set the lookat.
+ camTrack();
+
+ // Configure environment.
+ configureLightAndMaterial();
+
+ // Draw the reflection by drawing models with negated Z-axis.
+ glPushMatrix();
+ drawModels(-1);
+ glPopMatrix();
+
+ // Blend the ground plane to the window.
+ drawGroundPlane();
+
+ // Draw all the models normally.
+ drawModels(1);
+
+ // Draw fade quad over whole window (when changing cameras).
+ drawFadeQuad();
+}
diff --git a/opengl/tests/angeles/gpustate.c b/opengl/tests/angeles/gpustate.c
new file mode 100644
index 0000000..3c540c9
--- /dev/null
+++ b/opengl/tests/angeles/gpustate.c
@@ -0,0 +1,39 @@
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+static void *map_memory(const char *fn, unsigned base, unsigned size)
+{
+ int fd;
+ void *ptr;
+
+ fd = open(fn, O_RDWR | O_SYNC);
+ if(fd < 0) {
+ perror("cannot open %s for mapping");
+ return MAP_FAILED;
+ }
+
+ ptr = mmap(0, size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, base);
+ close(fd);
+
+ if(ptr == MAP_FAILED) {
+ fprintf(stderr,"cannot map %s (@%08x,%08x)\n", fn, base, size);
+ }
+ return ptr;
+}
+
+
+int main(int argc, char** argv)
+{
+ void *grp_regs = map_memory("/dev/hw3d", 0, 1024 * 1024);
+ printf("GPU base mapped at %p\n", grp_regs);
+ int state_offset = 0x10140;
+ printf("GPU state = %08lx\n",
+ *((long*)((char*)grp_regs + state_offset)) );
+
+ return 0;
+}
diff --git a/opengl/tests/angeles/include/GLES/egl.h b/opengl/tests/angeles/include/GLES/egl.h
new file mode 100644
index 0000000..cdf8410
--- /dev/null
+++ b/opengl/tests/angeles/include/GLES/egl.h
@@ -0,0 +1,229 @@
+#ifndef __egl_h_
+#define __egl_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.0 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+
+#include <GLES/gl.h>
+#include <GLES/egltypes.h>
+
+/*
+** egltypes.h is platform dependent. It defines:
+**
+** - EGL types and resources
+** - Native types
+** - EGL and native handle values
+**
+** EGL types and resources are to be typedef'ed with appropriate platform
+** dependent resource handle types. EGLint must be an integer of at least
+** 32-bit.
+**
+** NativeDisplayType, NativeWindowType and NativePixmapType are to be
+** replaced with corresponding types of the native window system in egl.h.
+**
+** EGL and native handle values must match their types.
+**
+** Example egltypes.h:
+*/
+
+#if 0
+
+#include <sys/types.h>
+#include <native_window_system.h>
+
+/*
+** Types and resources
+*/
+typedef int EGLBoolean;
+typedef int32_t EGLint;
+typedef void *EGLDisplay;
+typedef void *EGLConfig;
+typedef void *EGLSurface;
+typedef void *EGLContext;
+
+/*
+** EGL and native handle values
+*/
+#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
+#define EGL_NO_CONTEXT ((EGLContext)0)
+#define EGL_NO_DISPLAY ((EGLDisplay)0)
+#define EGL_NO_SURFACE ((EGLSurface)0)
+
+#endif
+
+/*
+** Versioning and extensions
+*/
+#define EGL_VERSION_1_0 1
+
+/*
+** Boolean
+*/
+#define EGL_FALSE 0
+#define EGL_TRUE 1
+
+/*
+** Errors
+*/
+#define EGL_SUCCESS 0x3000
+#define EGL_NOT_INITIALIZED 0x3001
+#define EGL_BAD_ACCESS 0x3002
+#define EGL_BAD_ALLOC 0x3003
+#define EGL_BAD_ATTRIBUTE 0x3004
+#define EGL_BAD_CONFIG 0x3005
+#define EGL_BAD_CONTEXT 0x3006
+#define EGL_BAD_CURRENT_SURFACE 0x3007
+#define EGL_BAD_DISPLAY 0x3008
+#define EGL_BAD_MATCH 0x3009
+#define EGL_BAD_NATIVE_PIXMAP 0x300A
+#define EGL_BAD_NATIVE_WINDOW 0x300B
+#define EGL_BAD_PARAMETER 0x300C
+#define EGL_BAD_SURFACE 0x300D
+/* 0x300E - 0x301F reserved for additional errors. */
+
+/*
+** Config attributes
+*/
+#define EGL_BUFFER_SIZE 0x3020
+#define EGL_ALPHA_SIZE 0x3021
+#define EGL_BLUE_SIZE 0x3022
+#define EGL_GREEN_SIZE 0x3023
+#define EGL_RED_SIZE 0x3024
+#define EGL_DEPTH_SIZE 0x3025
+#define EGL_STENCIL_SIZE 0x3026
+#define EGL_CONFIG_CAVEAT 0x3027
+#define EGL_CONFIG_ID 0x3028
+#define EGL_LEVEL 0x3029
+#define EGL_MAX_PBUFFER_HEIGHT 0x302A
+#define EGL_MAX_PBUFFER_PIXELS 0x302B
+#define EGL_MAX_PBUFFER_WIDTH 0x302C
+#define EGL_NATIVE_RENDERABLE 0x302D
+#define EGL_NATIVE_VISUAL_ID 0x302E
+#define EGL_NATIVE_VISUAL_TYPE 0x302F
+/*#define EGL_PRESERVED_RESOURCES 0x3030*/
+#define EGL_SAMPLES 0x3031
+#define EGL_SAMPLE_BUFFERS 0x3032
+#define EGL_SURFACE_TYPE 0x3033
+#define EGL_TRANSPARENT_TYPE 0x3034
+#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
+#define EGL_TRANSPARENT_RED_VALUE 0x3037
+
+/*
+** Config attribute and value
+*/
+#define EGL_NONE 0x3038
+/* 0x3039 - 0x304F reserved for additional config attributes. */
+
+/*
+** Config values
+*/
+#define EGL_DONT_CARE ((EGLint) -1)
+#define EGL_PBUFFER_BIT 0x01
+#define EGL_PIXMAP_BIT 0x02
+#define EGL_WINDOW_BIT 0x04
+#define EGL_SLOW_CONFIG 0x3050
+#define EGL_NON_CONFORMANT_CONFIG 0x3051
+#define EGL_TRANSPARENT_RGB 0x3052
+
+/*
+** String names
+*/
+#define EGL_VENDOR 0x3053
+#define EGL_VERSION 0x3054
+#define EGL_EXTENSIONS 0x3055
+
+/*
+** Surface attributes
+*/
+#define EGL_HEIGHT 0x3056
+#define EGL_WIDTH 0x3057
+#define EGL_LARGEST_PBUFFER 0x3058
+
+/*
+** Current surfaces
+*/
+#define EGL_DRAW 0x3059
+#define EGL_READ 0x305A
+
+/*
+** Engines
+*/
+#define EGL_CORE_NATIVE_ENGINE 0x305B
+
+/* 0x305C-0x3FFFF reserved for future use */
+
+/*
+** Functions
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+GLAPI EGLint APIENTRY eglGetError (void);
+
+GLAPI EGLDisplay APIENTRY eglGetDisplay (NativeDisplayType display);
+GLAPI EGLBoolean APIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
+GLAPI EGLBoolean APIENTRY eglTerminate (EGLDisplay dpy);
+GLAPI const char * APIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
+GLAPI void (* APIENTRY eglGetProcAddress (const char *procname))();
+
+GLAPI EGLBoolean APIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+GLAPI EGLBoolean APIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+GLAPI EGLBoolean APIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+
+GLAPI EGLSurface APIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
+GLAPI EGLSurface APIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list);
+GLAPI EGLSurface APIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+GLAPI EGLBoolean APIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
+GLAPI EGLBoolean APIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+
+GLAPI EGLContext APIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
+GLAPI EGLBoolean APIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
+GLAPI EGLBoolean APIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+GLAPI EGLContext APIENTRY eglGetCurrentContext (void);
+GLAPI EGLSurface APIENTRY eglGetCurrentSurface (EGLint readdraw);
+GLAPI EGLDisplay APIENTRY eglGetCurrentDisplay (void);
+GLAPI EGLBoolean APIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+
+GLAPI EGLBoolean APIENTRY eglWaitGL (void);
+GLAPI EGLBoolean APIENTRY eglWaitNative (EGLint engine);
+GLAPI EGLBoolean APIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface draw);
+GLAPI EGLBoolean APIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ___egl_h_ */
diff --git a/opengl/tests/angeles/include/GLES/egltypes.h b/opengl/tests/angeles/include/GLES/egltypes.h
new file mode 100644
index 0000000..9db36c9
--- /dev/null
+++ b/opengl/tests/angeles/include/GLES/egltypes.h
@@ -0,0 +1,20 @@
+/*
+** Types and resources
+*/
+typedef int EGLBoolean;
+typedef long EGLint;
+typedef void *EGLDisplay;
+typedef void *EGLConfig;
+typedef void *EGLSurface;
+typedef void *EGLContext;
+typedef void *NativeDisplayType;
+typedef void *NativeWindowType;
+typedef void *NativePixmapType;
+
+/*
+** EGL and native handle values
+*/
+#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
+#define EGL_NO_CONTEXT ((EGLContext)0)
+#define EGL_NO_DISPLAY ((EGLDisplay)0)
+#define EGL_NO_SURFACE ((EGLSurface)0)
diff --git a/opengl/tests/angeles/include/GLES/gl.h b/opengl/tests/angeles/include/GLES/gl.h
new file mode 100644
index 0000000..4154822
--- /dev/null
+++ b/opengl/tests/angeles/include/GLES/gl.h
@@ -0,0 +1,584 @@
+#ifndef __gl_h_
+#define __gl_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.0 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef int GLint;
+typedef int GLsizei;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned int GLuint;
+typedef float GLfloat;
+typedef float GLclampf;
+typedef void GLvoid;
+typedef int GLintptrARB;
+typedef int GLsizeiptrARB;
+typedef int GLfixed;
+typedef int GLclampx;
+/* Internal convenience typedefs */
+typedef void (*_GLfuncptr)();
+
+/*************************************************************/
+
+/* Extensions */
+#define GL_OES_VERSION_1_0 1
+#define GL_OES_read_format 1
+#define GL_OES_compressed_paletted_texture 1
+
+/* ClearBufferMask */
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_COLOR_BUFFER_BIT 0x00004000
+
+/* Boolean */
+#define GL_FALSE 0
+#define GL_TRUE 1
+
+/* BeginMode */
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+
+/* AlphaFunction */
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_EQUAL 0x0202
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+
+/* BlendingFactorDest */
+#define GL_ZERO 0
+#define GL_ONE 1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+
+/* BlendingFactorSrc */
+/* GL_ZERO */
+/* GL_ONE */
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+/* GL_SRC_ALPHA */
+/* GL_ONE_MINUS_SRC_ALPHA */
+/* GL_DST_ALPHA */
+/* GL_ONE_MINUS_DST_ALPHA */
+
+/* ColorMaterialFace */
+/* GL_FRONT_AND_BACK */
+
+/* ColorMaterialParameter */
+/* GL_AMBIENT_AND_DIFFUSE */
+
+/* ColorPointerType */
+/* GL_UNSIGNED_BYTE */
+/* GL_FLOAT */
+/* GL_FIXED */
+
+/* CullFaceMode */
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_FRONT_AND_BACK 0x0408
+
+/* DepthFunction */
+/* GL_NEVER */
+/* GL_LESS */
+/* GL_EQUAL */
+/* GL_LEQUAL */
+/* GL_GREATER */
+/* GL_NOTEQUAL */
+/* GL_GEQUAL */
+/* GL_ALWAYS */
+
+/* EnableCap */
+#define GL_FOG 0x0B60
+#define GL_LIGHTING 0x0B50
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_CULL_FACE 0x0B44
+#define GL_ALPHA_TEST 0x0BC0
+#define GL_BLEND 0x0BE2
+#define GL_COLOR_LOGIC_OP 0x0BF2
+#define GL_DITHER 0x0BD0
+#define GL_STENCIL_TEST 0x0B90
+#define GL_DEPTH_TEST 0x0B71
+/* GL_LIGHT0 */
+/* GL_LIGHT1 */
+/* GL_LIGHT2 */
+/* GL_LIGHT3 */
+/* GL_LIGHT4 */
+/* GL_LIGHT5 */
+/* GL_LIGHT6 */
+/* GL_LIGHT7 */
+#define GL_POINT_SMOOTH 0x0B10
+#define GL_LINE_SMOOTH 0x0B20
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_COLOR_MATERIAL 0x0B57
+#define GL_NORMALIZE 0x0BA1
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_VERTEX_ARRAY 0x8074
+#define GL_NORMAL_ARRAY 0x8075
+#define GL_COLOR_ARRAY 0x8076
+#define GL_TEXTURE_COORD_ARRAY 0x8078
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+
+/* ErrorCode */
+#define GL_NO_ERROR 0
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVALID_OPERATION 0x0502
+#define GL_STACK_OVERFLOW 0x0503
+#define GL_STACK_UNDERFLOW 0x0504
+#define GL_OUT_OF_MEMORY 0x0505
+
+/* FogMode */
+/* GL_LINEAR */
+#define GL_EXP 0x0800
+#define GL_EXP2 0x0801
+
+/* FogParameter */
+#define GL_FOG_DENSITY 0x0B62
+#define GL_FOG_START 0x0B63
+#define GL_FOG_END 0x0B64
+#define GL_FOG_MODE 0x0B65
+#define GL_FOG_COLOR 0x0B66
+
+/* FrontFaceDirection */
+#define GL_CW 0x0900
+#define GL_CCW 0x0901
+
+/* GetPName */
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#define GL_MAX_LIGHTS 0x0D31
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
+#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_MAX_TEXTURE_UNITS 0x84E2
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_RED_BITS 0x0D52
+#define GL_GREEN_BITS 0x0D53
+#define GL_BLUE_BITS 0x0D54
+#define GL_ALPHA_BITS 0x0D55
+#define GL_DEPTH_BITS 0x0D56
+#define GL_STENCIL_BITS 0x0D57
+
+/* HintMode */
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+
+/* HintTarget */
+#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
+#define GL_POINT_SMOOTH_HINT 0x0C51
+#define GL_LINE_SMOOTH_HINT 0x0C52
+#define GL_POLYGON_SMOOTH_HINT 0x0C53
+#define GL_FOG_HINT 0x0C54
+
+/* LightModelParameter */
+#define GL_LIGHT_MODEL_AMBIENT 0x0B53
+#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
+
+/* LightParameter */
+#define GL_AMBIENT 0x1200
+#define GL_DIFFUSE 0x1201
+#define GL_SPECULAR 0x1202
+#define GL_POSITION 0x1203
+#define GL_SPOT_DIRECTION 0x1204
+#define GL_SPOT_EXPONENT 0x1205
+#define GL_SPOT_CUTOFF 0x1206
+#define GL_CONSTANT_ATTENUATION 0x1207
+#define GL_LINEAR_ATTENUATION 0x1208
+#define GL_QUADRATIC_ATTENUATION 0x1209
+
+/* DataType */
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_FLOAT 0x1406
+#define GL_FIXED 0x140C
+
+/* LogicOp */
+#define GL_CLEAR 0x1500
+#define GL_AND 0x1501
+#define GL_AND_REVERSE 0x1502
+#define GL_COPY 0x1503
+#define GL_AND_INVERTED 0x1504
+#define GL_NOOP 0x1505
+#define GL_XOR 0x1506
+#define GL_OR 0x1507
+#define GL_NOR 0x1508
+#define GL_EQUIV 0x1509
+#define GL_INVERT 0x150A
+#define GL_OR_REVERSE 0x150B
+#define GL_COPY_INVERTED 0x150C
+#define GL_OR_INVERTED 0x150D
+#define GL_NAND 0x150E
+#define GL_SET 0x150F
+
+/* MaterialFace */
+/* GL_FRONT_AND_BACK */
+
+/* MaterialParameter */
+#define GL_EMISSION 0x1600
+#define GL_SHININESS 0x1601
+#define GL_AMBIENT_AND_DIFFUSE 0x1602
+/* GL_AMBIENT */
+/* GL_DIFFUSE */
+/* GL_SPECULAR */
+
+/* MatrixMode */
+#define GL_MODELVIEW 0x1700
+#define GL_PROJECTION 0x1701
+#define GL_TEXTURE 0x1702
+
+/* NormalPointerType */
+/* GL_BYTE */
+/* GL_SHORT */
+/* GL_FLOAT */
+/* GL_FIXED */
+
+/* PixelFormat */
+#define GL_ALPHA 0x1906
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE_ALPHA 0x190A
+
+/* PixelStoreParameter */
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_PACK_ALIGNMENT 0x0D05
+
+/* PixelType */
+/* GL_UNSIGNED_BYTE */
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+
+/* ShadingModel */
+#define GL_FLAT 0x1D00
+#define GL_SMOOTH 0x1D01
+
+/* StencilFunction */
+/* GL_NEVER */
+/* GL_LESS */
+/* GL_EQUAL */
+/* GL_LEQUAL */
+/* GL_GREATER */
+/* GL_NOTEQUAL */
+/* GL_GEQUAL */
+/* GL_ALWAYS */
+
+/* StencilOp */
+/* GL_ZERO */
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+/* GL_INVERT */
+
+/* StringName */
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+
+/* TexCoordPointerType */
+/* GL_SHORT */
+/* GL_FLOAT */
+/* GL_FIXED */
+/* GL_BYTE */
+
+/* TextureEnvMode */
+#define GL_MODULATE 0x2100
+#define GL_DECAL 0x2101
+/* GL_BLEND */
+#define GL_ADD 0x0104
+/* GL_REPLACE */
+
+/* TextureEnvParameter */
+#define GL_TEXTURE_ENV_MODE 0x2200
+#define GL_TEXTURE_ENV_COLOR 0x2201
+
+/* TextureEnvTarget */
+#define GL_TEXTURE_ENV 0x2300
+
+/* TextureMagFilter */
+#define GL_NEAREST 0x2600
+#define GL_LINEAR 0x2601
+
+/* TextureMinFilter */
+/* GL_NEAREST */
+/* GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+
+/* TextureParameterName */
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+
+/* TextureTarget */
+/* GL_TEXTURE_2D */
+
+/* TextureUnit */
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+
+/* TextureWrapMode */
+#define GL_REPEAT 0x2901
+#define GL_CLAMP_TO_EDGE 0x812F
+
+/* PixelInternalFormat */
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
+
+/* VertexPointerType */
+/* GL_SHORT */
+/* GL_FLOAT */
+/* GL_FIXED */
+/* GL_BYTE */
+
+/* LightName */
+#define GL_LIGHT0 0x4000
+#define GL_LIGHT1 0x4001
+#define GL_LIGHT2 0x4002
+#define GL_LIGHT3 0x4003
+#define GL_LIGHT4 0x4004
+#define GL_LIGHT5 0x4005
+#define GL_LIGHT6 0x4006
+#define GL_LIGHT7 0x4007
+
+
+/*************************************************************/
+
+GLAPI void APIENTRY glActiveTexture (GLenum texture);
+GLAPI void APIENTRY glAlphaFunc (GLenum func, GLclampf ref);
+GLAPI void APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
+GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture);
+GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GLAPI void APIENTRY glClear (GLbitfield mask);
+GLAPI void APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GLAPI void APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+GLAPI void APIENTRY glClearDepthf (GLclampf depth);
+GLAPI void APIENTRY glClearDepthx (GLclampx depth);
+GLAPI void APIENTRY glClearStencil (GLint s);
+GLAPI void APIENTRY glClientActiveTexture (GLenum texture);
+GLAPI void APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GLAPI void APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GLAPI void APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+GLAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glCullFace (GLenum mode);
+GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
+GLAPI void APIENTRY glDepthFunc (GLenum func);
+GLAPI void APIENTRY glDepthMask (GLboolean flag);
+GLAPI void APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
+GLAPI void APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
+GLAPI void APIENTRY glDisable (GLenum cap);
+GLAPI void APIENTRY glDisableClientState (GLenum array);
+GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+GLAPI void APIENTRY glEnable (GLenum cap);
+GLAPI void APIENTRY glEnableClientState (GLenum array);
+GLAPI void APIENTRY glFinish (void);
+GLAPI void APIENTRY glFlush (void);
+GLAPI void APIENTRY glFogf (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glFogfv (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glFogx (GLenum pname, GLfixed param);
+GLAPI void APIENTRY glFogxv (GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glFrontFace (GLenum mode);
+GLAPI void APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GLAPI void APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures);
+GLAPI GLenum APIENTRY glGetError (void);
+GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *params);
+GLAPI const GLubyte * APIENTRY glGetString (GLenum name);
+GLAPI void APIENTRY glHint (GLenum target, GLenum mode);
+GLAPI void APIENTRY glLightModelf (GLenum pname, GLfloat param);
+GLAPI void APIENTRY glLightModelfv (GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glLightModelx (GLenum pname, GLfixed param);
+GLAPI void APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glLineWidth (GLfloat width);
+GLAPI void APIENTRY glLineWidthx (GLfixed width);
+GLAPI void APIENTRY glLoadIdentity (void);
+GLAPI void APIENTRY glLoadMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glLoadMatrixx (const GLfixed *m);
+GLAPI void APIENTRY glLogicOp (GLenum opcode);
+GLAPI void APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glMatrixMode (GLenum mode);
+GLAPI void APIENTRY glMultMatrixf (const GLfloat *m);
+GLAPI void APIENTRY glMultMatrixx (const GLfixed *m);
+GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+GLAPI void APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);
+GLAPI void APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
+GLAPI void APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GLAPI void APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param);
+GLAPI void APIENTRY glPointSize (GLfloat size);
+GLAPI void APIENTRY glPointSizex (GLfixed size);
+GLAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GLAPI void APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
+GLAPI void APIENTRY glPopMatrix (void);
+GLAPI void APIENTRY glPushMatrix (void);
+GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+GLAPI void APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
+GLAPI void APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
+GLAPI void APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI void APIENTRY glShadeModel (GLenum mode);
+GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GLAPI void APIENTRY glStencilMask (GLuint mask);
+GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GLAPI void APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);
+GLAPI void APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
+GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GLAPI void APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
+GLAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GLAPI void APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);
+GLAPI void APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
+GLAPI void APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl_h_ */
diff --git a/opengl/tests/angeles/license-BSD.txt b/opengl/tests/angeles/license-BSD.txt
new file mode 100644
index 0000000..8924e3c
--- /dev/null
+++ b/opengl/tests/angeles/license-BSD.txt
@@ -0,0 +1,34 @@
+This is the BSD-style license for the "San Angeles Observation"
+OpenGL ES version example source code
+---------------------------------------------------------------
+
+San Angeles Observation OpenGL ES version example
+Copyright (c) 2004-2005, Jetro Lauha
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of the software product's copyright owner nor
+ the names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/opengl/tests/angeles/license-LGPL.txt b/opengl/tests/angeles/license-LGPL.txt
new file mode 100644
index 0000000..b1e3f5a
--- /dev/null
+++ b/opengl/tests/angeles/license-LGPL.txt
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/opengl/tests/angeles/license.txt b/opengl/tests/angeles/license.txt
new file mode 100644
index 0000000..620841e
--- /dev/null
+++ b/opengl/tests/angeles/license.txt
@@ -0,0 +1,19 @@
+San Angeles Observation OpenGL ES version example
+Copyright 2004-2005 Jetro Lauha
+All rights reserved.
+Web: http://iki.fi/jetro/
+
+This source is free software; you can redistribute it and/or
+modify it under the terms of EITHER:
+ (1) The GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at
+ your option) any later version. The text of the GNU Lesser
+ General Public License is included with this source in the
+ file LICENSE-LGPL.txt.
+ (2) The BSD-style license that is included with this source in
+ the file LICENSE-BSD.txt.
+
+This source is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
diff --git a/opengl/tests/angeles/shapes.h b/opengl/tests/angeles/shapes.h
new file mode 100644
index 0000000..25ffae8
--- /dev/null
+++ b/opengl/tests/angeles/shapes.h
@@ -0,0 +1,59 @@
+/* San Angeles Observation OpenGL ES version example
+ * Copyright 2004-2005 Jetro Lauha
+ * All rights reserved.
+ * Web: http://iki.fi/jetro/
+ *
+ * This source is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER:
+ * (1) The GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version. The text of the GNU Lesser
+ * General Public License is included with this source in the
+ * file LICENSE-LGPL.txt.
+ * (2) The BSD-style license that is included with this source in
+ * the file LICENSE-BSD.txt.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
+ *
+ * $Id: shapes.h,v 1.6 2005/01/31 22:15:30 tonic Exp $
+ * $Revision: 1.6 $
+ */
+
+#ifndef SHAPES_H_INCLUDED
+#define SHAPES_H_INCLUDED
+
+
+#define SUPERSHAPE_PARAMS 15
+
+static const float sSuperShapeParams[][SUPERSHAPE_PARAMS] =
+{
+ // m a b n1 n2 n3 m a b n1 n2 n3 res1 res2 scale (org.res1,res2)
+ { 10, 1, 2, 90, 1, -45, 8, 1, 1, -1, 1, -0.4f, 20, 30, 2 }, // 40, 60
+ { 10, 1, 2, 90, 1, -45, 4, 1, 1, 10, 1, -0.4f, 20, 20, 4 }, // 40, 40
+ { 10, 1, 2, 60, 1, -10, 4, 1, 1, -1, -2, -0.4f, 41, 41, 1 }, // 82, 82
+ { 6, 1, 1, 60, 1, -70, 8, 1, 1, 0.4f, 3, 0.25f, 20, 20, 1 }, // 40, 40
+ { 4, 1, 1, 30, 1, 20, 12, 1, 1, 0.4f, 3, 0.25f, 10, 30, 1 }, // 20, 60
+ { 8, 1, 1, 30, 1, -4, 8, 2, 1, -1, 5, 0.5f, 25, 26, 1 }, // 60, 60
+ { 13, 1, 1, 30, 1, -4, 13, 1, 1, 1, 5, 1, 30, 30, 6 }, // 60, 60
+ { 10, 1, 1.1f, -0.5f, 0.1f, 70, 60, 1, 1, -90, 0, -0.25f, 20, 60, 8 }, // 60, 180
+ { 7, 1, 1, 20, -0.3f, -3.5f, 6, 1, 1, -1, 4.5f, 0.5f, 10, 20, 4 }, // 60, 80
+ { 4, 1, 1, 10, 10, 10, 4, 1, 1, 10, 10, 10, 10, 20, 1 }, // 20, 40
+ { 4, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 10, 10, 2 }, // 10, 10
+ { 1, 1, 1, 38, -0.25f, 19, 4, 1, 1, 10, 10, 10, 10, 15, 2 }, // 20, 40
+ { 2, 1, 1, 0.7f, 0.3f, 0.2f, 3, 1, 1, 100, 100, 100, 10, 25, 2 }, // 20, 50
+ { 6, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 30, 30, 2 }, // 60, 60
+ { 3, 1, 1, 1, 1, 1, 6, 1, 1, 2, 1, 1, 10, 20, 2 }, // 20, 40
+ { 6, 1, 1, 6, 5.5f, 100, 6, 1, 1, 25, 10, 10, 30, 20, 2 }, // 60, 40
+ { 3, 1, 1, 0.5f, 1.7f, 1.7f, 2, 1, 1, 10, 10, 10, 20, 20, 2 }, // 40, 40
+ { 5, 1, 1, 0.1f, 1.7f, 1.7f, 1, 1, 1, 0.3f, 0.5f, 0.5f, 20, 20, 4 }, // 40, 40
+ { 2, 1, 1, 6, 5.5f, 100, 6, 1, 1, 4, 10, 10, 10, 22, 1 }, // 40, 40
+ { 6, 1, 1, -1, 70, 0.1f, 9, 1, 0.5f, -98, 0.05f, -45, 20, 30, 4 }, // 60, 91
+ { 6, 1, 1, -1, 90, -0.1f, 7, 1, 1, 90, 1.3f, 34, 13, 16, 1 }, // 32, 60
+};
+#define SUPERSHAPE_COUNT (sizeof(sSuperShapeParams) / sizeof(sSuperShapeParams[0]))
+
+
+#endif // !SHAPES_H_INCLUDED
diff --git a/opengl/tests/filter/Android.mk b/opengl/tests/filter/Android.mk
new file mode 100644
index 0000000..1c4253c
--- /dev/null
+++ b/opengl/tests/filter/Android.mk
@@ -0,0 +1,16 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ filter.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libGLES_CM \
+ libui
+
+LOCAL_MODULE:= test-opengl-filter
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/filter/filter.c b/opengl/tests/filter/filter.c
new file mode 100644
index 0000000..c8bac06
--- /dev/null
+++ b/opengl/tests/filter/filter.c
@@ -0,0 +1,125 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <GLES/egl.h>
+
+int main(int argc, char** argv)
+{
+ if (argc!=2 && argc!=3) {
+ printf("usage: %s <0-6> [pbuffer]\n", argv[0]);
+ return 0;
+ }
+
+ const int test = atoi(argv[1]);
+ int usePbuffer = argc==3 && !strcmp(argv[2], "pbuffer");
+ EGLint s_configAttribs[] = {
+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT|EGL_WINDOW_BIT,
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_NONE
+ };
+
+ EGLint numConfigs = -1;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLConfig config;
+ EGLContext context;
+ EGLSurface surface;
+ EGLint w, h;
+
+ EGLDisplay dpy;
+
+ dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ eglInitialize(dpy, &majorVersion, &minorVersion);
+ eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+ if (!usePbuffer) {
+ surface = eglCreateWindowSurface(dpy, config,
+ android_createDisplaySurface(), NULL);
+ } else {
+ printf("using pbuffer\n");
+ EGLint attribs[] = { EGL_WIDTH, 320, EGL_HEIGHT, 480, EGL_NONE };
+ surface = eglCreatePbufferSurface(dpy, config, attribs);
+ }
+ context = eglCreateContext(dpy, config, NULL, NULL);
+ eglMakeCurrent(dpy, surface, surface, context);
+ eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
+ eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
+ GLint dim = w<h ? w : h;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ GLint crop[4] = { 0, 4, 4, -4 };
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glEnable(GL_TEXTURE_2D);
+ glColor4f(1,1,1,1);
+
+ // packing is always 4
+ uint8_t t8[] = {
+ 0x00, 0x55, 0x00, 0x55,
+ 0xAA, 0xFF, 0xAA, 0xFF,
+ 0x00, 0x55, 0x00, 0x55,
+ 0xAA, 0xFF, 0xAA, 0xFF };
+
+ uint16_t t16[] = {
+ 0x0000, 0x5555, 0x0000, 0x5555,
+ 0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF,
+ 0x0000, 0x5555, 0x0000, 0x5555,
+ 0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF };
+
+ uint16_t t5551[] = {
+ 0x0000, 0xFFFF, 0x0000, 0xFFFF,
+ 0xFFFF, 0x0000, 0xFFFF, 0x0000,
+ 0x0000, 0xFFFF, 0x0000, 0xFFFF,
+ 0xFFFF, 0x0000, 0xFFFF, 0x0000 };
+
+ uint32_t t32[] = {
+ 0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFFFF0000,
+ 0xFF00FF00, 0xFFFF0000, 0xFF000000, 0xFF0000FF,
+ 0xFF00FFFF, 0xFF00FF00, 0x00FF00FF, 0xFFFFFF00,
+ 0xFF000000, 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFFFF
+ };
+
+ switch(test)
+ {
+ case 1:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
+ 4, 4, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, t8);
+ break;
+ case 2:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ 4, 4, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, t16);
+ break;
+ case 3:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, t16);
+ break;
+ case 4:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
+ 4, 4, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, t16);
+ break;
+ case 5:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, t5551);
+ break;
+ case 6:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, t32);
+ break;
+ }
+
+ glDrawTexiOES(0, 0, 0, dim, dim);
+
+ if (!usePbuffer) {
+ eglSwapBuffers(dpy, surface);
+ } else {
+ glFinish();
+ }
+
+ eglTerminate(dpy);
+ return 0;
+}
diff --git a/opengl/tests/finish/Android.mk b/opengl/tests/finish/Android.mk
new file mode 100644
index 0000000..f7b95ed
--- /dev/null
+++ b/opengl/tests/finish/Android.mk
@@ -0,0 +1,16 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ finish.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libGLES_CM \
+ libui
+
+LOCAL_MODULE:= test-opengl-finish
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/finish/finish.c b/opengl/tests/finish/finish.c
new file mode 100644
index 0000000..3afe227
--- /dev/null
+++ b/opengl/tests/finish/finish.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <sched.h>
+#include <sys/resource.h>
+
+#include <GLES/egl.h>
+
+long long systemTime()
+{
+ struct timespec t;
+ t.tv_sec = t.tv_nsec = 0;
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ return (long long)(t.tv_sec)*1000000000LL + t.tv_nsec;
+}
+
+int main(int argc, char** argv)
+{
+ EGLint s_configAttribs[] = {
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_NONE
+ };
+
+ EGLint numConfigs = -1;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLConfig config;
+ EGLContext context;
+ EGLSurface surface;
+ EGLint w, h;
+
+ EGLDisplay dpy;
+
+ dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ eglInitialize(dpy, &majorVersion, &minorVersion);
+ eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+ surface = eglCreateWindowSurface(dpy, config,
+ android_createDisplaySurface(), NULL);
+ context = eglCreateContext(dpy, config, NULL, NULL);
+ eglMakeCurrent(dpy, surface, surface, context);
+ eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
+ eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
+ GLint dim = w<h ? w : h;
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glEnable(GL_TEXTURE_2D);
+ glColor4f(1,1,1,1);
+ glDisable(GL_DITHER);
+ glShadeModel(GL_FLAT);
+
+ long long now, t;
+ int i;
+
+ char* texels = malloc(512*512*2);
+ memset(texels,0xFF,512*512*2);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ 512, 512, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texels);
+
+ char* dst = malloc(320*480*2);
+ memset(dst, 0, 320*480*2);
+ printf("307200 bytes memcpy\n");
+ for (i=0 ; i<4 ; i++) {
+ now = systemTime();
+ memcpy(dst, texels, 320*480*2);
+ t = systemTime();
+ printf("memcpy() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ }
+ free(dst);
+
+ free(texels);
+
+ setpriority(PRIO_PROCESS, 0, -20);
+
+ printf("512x512 unmodified texture, 512x512 blit:\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ GLint crop[4] = { 0, 512, 512, -512 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 512, 512);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ eglSwapBuffers(dpy, surface);
+ }
+
+ printf("512x512 unmodified texture, 1x1 blit:\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ GLint crop[4] = { 0, 1, 1, -1 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 1, 1);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ eglSwapBuffers(dpy, surface);
+ }
+
+ printf("512x512 unmodified texture, 512x512 blit (x2):\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ GLint crop[4] = { 0, 512, 512, -512 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 512, 512);
+ glDrawTexiOES(0, 0, 0, 512, 512);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ eglSwapBuffers(dpy, surface);
+ }
+
+ printf("512x512 unmodified texture, 1x1 blit (x2):\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ GLint crop[4] = { 0, 1, 1, -1 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 1, 1);
+ glDrawTexiOES(0, 0, 0, 1, 1);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ eglSwapBuffers(dpy, surface);
+ }
+
+
+ printf("512x512 (1x1 texel MODIFIED texture), 512x512 blit:\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ uint16_t green = 0x7E0;
+ GLint crop[4] = { 0, 512, 512, -512 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, &green);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 512, 512);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ eglSwapBuffers(dpy, surface);
+ }
+
+
+ int16_t texel = 0xF800;
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, &texel);
+
+ printf("1x1 unmodified texture, 1x1 blit:\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ GLint crop[4] = { 0, 1, 1, -1 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 1, 1);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ eglSwapBuffers(dpy, surface);
+ }
+
+ printf("1x1 unmodified texture, 512x512 blit:\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ GLint crop[4] = { 0, 1, 1, -1 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 512, 512);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ eglSwapBuffers(dpy, surface);
+ }
+
+ printf("1x1 (1x1 texel MODIFIED texture), 512x512 blit:\n");
+ glClear(GL_COLOR_BUFFER_BIT);
+ for (i=0 ; i<4 ; i++) {
+ uint16_t green = 0x7E0;
+ GLint crop[4] = { 0, 1, 1, -1 };
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, &green);
+ now = systemTime();
+ glDrawTexiOES(0, 0, 0, 1, 1);
+ glFinish();
+ t = systemTime();
+ printf("glFinish() time = %llu us\n", (t-now)/1000);
+ fflush(stdout);
+ eglSwapBuffers(dpy, surface);
+ }
+
+ return 0;
+}
diff --git a/opengl/tests/sfsim/Android.mk b/opengl/tests/sfsim/Android.mk
new file mode 100644
index 0000000..8a1a03c
--- /dev/null
+++ b/opengl/tests/sfsim/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ egl_surface.cpp \
+ sfsim.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libGLES_CM
+
+LOCAL_MODULE:= test-opengl-sfsim
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/sfsim/egl_surface.cpp b/opengl/tests/sfsim/egl_surface.cpp
new file mode 100644
index 0000000..b0777f8
--- /dev/null
+++ b/opengl/tests/sfsim/egl_surface.cpp
@@ -0,0 +1,346 @@
+/*
+ **
+ ** Copyright 2008 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 <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+
+#include <GLES/egl.h>
+
+#include "egl_surface.h"
+
+#define LOGI(x...) do { printf("INFO: " x); } while (0)
+#define LOGW(x...) do { printf("WARN: " x); } while (0)
+#define LOGE(x...) do { printf("ERR: " x); } while (0)
+
+// ----------------------------------------------------------------------------
+
+egl_native_window_t* android_createDisplaySurface()
+{
+ egl_native_window_t* s = new android::EGLDisplaySurface();
+ s->memory_type = NATIVE_MEMORY_TYPE_GPU;
+ return s;
+}
+
+#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
+#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+EGLDisplaySurface::EGLDisplaySurface()
+ : EGLNativeSurface<EGLDisplaySurface>()
+{
+ egl_native_window_t::version = sizeof(egl_native_window_t);
+ egl_native_window_t::ident = 0;
+ egl_native_window_t::incRef = &EGLDisplaySurface::hook_incRef;
+ egl_native_window_t::decRef = &EGLDisplaySurface::hook_decRef;
+ egl_native_window_t::swapBuffers = &EGLDisplaySurface::hook_swapBuffers;
+ egl_native_window_t::setSwapRectangle = &EGLDisplaySurface::hook_setSwapRectangle;
+ egl_native_window_t::nextBuffer = &EGLDisplaySurface::hook_nextBuffer;
+ egl_native_window_t::connect = 0;
+ egl_native_window_t::disconnect = 0;
+
+ mFb[0].data = 0;
+ mFb[1].data = 0;
+ egl_native_window_t::fd = mapFrameBuffer();
+ if (egl_native_window_t::fd >= 0) {
+ const float in2mm = 25.4f;
+ float refreshRate = 1000000000000000LLU / (
+ float( mInfo.upper_margin + mInfo.lower_margin + mInfo.yres )
+ * ( mInfo.left_margin + mInfo.right_margin + mInfo.xres )
+ * mInfo.pixclock);
+
+ const GGLSurface& buffer = mFb[1 - mIndex];
+ egl_native_window_t::width = buffer.width;
+ egl_native_window_t::height = buffer.height;
+ egl_native_window_t::stride = buffer.stride;
+ egl_native_window_t::format = buffer.format;
+ egl_native_window_t::base = intptr_t(mFb[0].data);
+ egl_native_window_t::offset =
+ intptr_t(buffer.data) - egl_native_window_t::base;
+ egl_native_window_t::flags = 0;
+ egl_native_window_t::xdpi = (mInfo.xres * in2mm) / mInfo.width;
+ egl_native_window_t::ydpi = (mInfo.yres * in2mm) / mInfo.height;
+ egl_native_window_t::fps = refreshRate;
+ egl_native_window_t::memory_type = NATIVE_MEMORY_TYPE_FB;
+ // no error, set the magic word
+ egl_native_window_t::magic = 0x600913;
+ }
+ mSwapCount = -1;
+ mPageFlipCount = 0;
+}
+
+EGLDisplaySurface::~EGLDisplaySurface()
+{
+ magic = 0;
+ close(egl_native_window_t::fd);
+ munmap(mFb[0].data, mSize);
+ if (!(mFlags & PAGE_FLIP))
+ free((void*)mFb[1].data);
+}
+
+void EGLDisplaySurface::hook_incRef(NativeWindowType window) {
+ EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
+ that->incStrong(that);
+}
+void EGLDisplaySurface::hook_decRef(NativeWindowType window) {
+ EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
+ that->decStrong(that);
+}
+uint32_t EGLDisplaySurface::hook_swapBuffers(NativeWindowType window) {
+ EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
+ return that->swapBuffers();
+}
+uint32_t EGLDisplaySurface::hook_nextBuffer(NativeWindowType window) {
+ EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
+ return that->nextBuffer();
+}
+void EGLDisplaySurface::hook_setSwapRectangle(NativeWindowType window,
+ int l, int t, int w, int h) {
+ EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
+ that->setSwapRectangle(l, t, w, h);
+}
+
+void EGLDisplaySurface::setSwapRectangle(int l, int t, int w, int h)
+{
+ mInfo.reserved[0] = 0x54445055; // "UPDT";
+ mInfo.reserved[1] = (uint16_t)l | ((uint32_t)t << 16);
+ mInfo.reserved[2] = (uint16_t)(l+w) | ((uint32_t)(t+h) << 16);
+}
+
+uint32_t EGLDisplaySurface::swapBuffers()
+{
+ if (!(mFlags & PAGE_FLIP))
+ return 0;
+
+ // do the actual flip
+ mIndex = 1 - mIndex;
+ mInfo.activate = FB_ACTIVATE_VBL;
+ mInfo.yoffset = mIndex ? mInfo.yres : 0;
+ if (ioctl(egl_native_window_t::fd, FBIOPUT_VSCREENINFO, &mInfo) == -1) {
+ LOGE("FBIOPUT_VSCREENINFO failed");
+ return 0;
+ }
+
+ /*
+ * this is a monstruous hack: Because the h/w accelerator is not able
+ * to render directly into the framebuffer, we need to copy its
+ * internal framebuffer out to the fb. the base address of the internal fb
+ * is given in oem[0].
+ * All this is needed only in standalone mode, in SurfaceFlinger mode
+ * we control where the GPU renders.
+ */
+ if (egl_native_window_t::memory_type == NATIVE_MEMORY_TYPE_GPU && oem[0]) {
+ // could use MDP here, but that's tricky because we need
+ // /dev/pmem_gpu* filedescriptor
+ const GGLSurface& buffer = mFb[mIndex];
+ memcpy( buffer.data,
+ (void*)(oem[0] + egl_native_window_t::offset),
+ buffer.stride*buffer.height*2);
+ }
+
+ // update the address of the buffer to draw to next
+ const GGLSurface& buffer = mFb[1 - mIndex];
+ egl_native_window_t::offset =
+ intptr_t(buffer.data) - egl_native_window_t::base;
+
+ mPageFlipCount++;
+
+ // We don't support screen-size changes for now
+ return 0;
+}
+
+int32_t EGLDisplaySurface::getPageFlipCount() const
+{
+ return mPageFlipCount;
+}
+
+uint32_t EGLDisplaySurface::nextBuffer()
+{
+ // update the address of the buffer to draw to next
+ const GGLSurface& buffer = mFb[mIndex];
+ egl_native_window_t::offset =
+ intptr_t(buffer.data) - egl_native_window_t::base;
+ return 0;
+}
+
+int EGLDisplaySurface::mapFrameBuffer()
+{
+ char const * const device_template[] = {
+ "/dev/graphics/fb%u",
+ "/dev/fb%u",
+ 0 };
+ int fd = -1;
+ int i=0;
+ char name[64];
+ while ((fd==-1) && device_template[i]) {
+ snprintf(name, 64, device_template[i], 0);
+ fd = open(name, O_RDWR, 0);
+ i++;
+ }
+ if (fd < 0)
+ return -errno;
+
+ struct fb_fix_screeninfo finfo;
+ if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1)
+ return -errno;
+
+ struct fb_var_screeninfo info;
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1)
+ return -errno;
+
+ info.reserved[0] = 0;
+ info.reserved[1] = 0;
+ info.reserved[2] = 0;
+ info.xoffset = 0;
+ info.yoffset = 0;
+ info.yres_virtual = info.yres * 2;
+ info.bits_per_pixel = 16;
+ info.activate = FB_ACTIVATE_NOW;
+
+ uint32_t flags = PAGE_FLIP;
+ if (ioctl(fd, FBIOPUT_VSCREENINFO, &info) == -1) {
+ info.yres_virtual = info.yres;
+ flags &= ~PAGE_FLIP;
+ LOGW("FBIOPUT_VSCREENINFO failed, page flipping not supported");
+ }
+
+ if (info.yres_virtual < info.yres * 2) {
+ info.yres_virtual = info.yres;
+ flags &= ~PAGE_FLIP;
+ LOGW("page flipping not supported (yres_virtual=%d, requested=%d)",
+ info.yres_virtual, info.yres*2);
+ }
+
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1)
+ return -errno;
+
+ int refreshRate = 1000000000000000LLU /
+ (
+ uint64_t( info.upper_margin + info.lower_margin + info.yres )
+ * ( info.left_margin + info.right_margin + info.xres )
+ * info.pixclock
+ );
+
+ if (refreshRate == 0) {
+ // bleagh, bad info from the driver
+ refreshRate = 60*1000; // 60 Hz
+ }
+
+ if (int(info.width) <= 0 || int(info.height) <= 0) {
+ // stupid driver, doesn't return that information
+ // default to Sooner's screen size (160 dpi)
+ info.width = 51;
+ info.height = 38;
+ }
+
+ float xdpi = (info.xres * 25.4f) / info.width;
+ float ydpi = (info.yres * 25.4f) / info.height;
+ float fps = refreshRate / 1000.0f;
+
+ LOGI( "using (fd=%d)\n"
+ "id = %s\n"
+ "xres = %d px\n"
+ "yres = %d px\n"
+ "xres_virtual = %d px\n"
+ "yres_virtual = %d px\n"
+ "bpp = %d\n"
+ "r = %2u:%u\n"
+ "g = %2u:%u\n"
+ "b = %2u:%u\n",
+ fd,
+ finfo.id,
+ info.xres,
+ info.yres,
+ info.xres_virtual,
+ info.yres_virtual,
+ info.bits_per_pixel,
+ info.red.offset, info.red.length,
+ info.green.offset, info.green.length,
+ info.blue.offset, info.blue.length
+ );
+
+ LOGI( "width = %d mm (%f dpi)\n"
+ "height = %d mm (%f dpi)\n"
+ "refresh rate = %.2f Hz\n",
+ info.width, xdpi,
+ info.height, ydpi,
+ fps
+ );
+
+
+ if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1)
+ return -errno;
+
+ if (finfo.smem_len <= 0)
+ return -errno;
+
+ /*
+ * Open and map the display.
+ */
+
+ void* buffer = (uint16_t*) mmap(
+ 0, finfo.smem_len,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ fd, 0);
+
+ if (buffer == MAP_FAILED)
+ return -errno;
+
+ // at least for now, always clear the fb
+ memset(buffer, 0, finfo.smem_len);
+
+ uint8_t* offscreen[2];
+ offscreen[0] = (uint8_t*)buffer;
+ if (flags & PAGE_FLIP) {
+ offscreen[1] = (uint8_t*)buffer + finfo.line_length*info.yres;
+ } else {
+ offscreen[1] = (uint8_t*)malloc(finfo.smem_len);
+ if (offscreen[1] == 0) {
+ munmap(buffer, finfo.smem_len);
+ return -ENOMEM;
+ }
+ }
+
+ mFlags = flags;
+ mInfo = info;
+ mFinfo = finfo;
+ mSize = finfo.smem_len;
+ mIndex = 0;
+ for (int i=0 ; i<2 ; i++) {
+ mFb[i].version = sizeof(GGLSurface);
+ mFb[i].width = info.xres;
+ mFb[i].height = info.yres;
+ mFb[i].stride = finfo.line_length / (info.bits_per_pixel >> 3);
+ mFb[i].data = (uint8_t*)(offscreen[i]);
+ mFb[i].format = NATIVE_PIXEL_FORMAT_RGB_565;
+ }
+ return fd;
+}
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+// ----------------------------------------------------------------------------
diff --git a/opengl/tests/sfsim/egl_surface.h b/opengl/tests/sfsim/egl_surface.h
new file mode 100644
index 0000000..70a94fc
--- /dev/null
+++ b/opengl/tests/sfsim/egl_surface.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2008 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 ANDROID_SIM_EGL_SURFACE_H
+#define ANDROID_SIM_EGL_SURFACE_H
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#include <GLES/eglnatives.h>
+
+#include <linux/fb.h>
+
+typedef struct {
+ ssize_t version; // always set to sizeof(GGLSurface)
+ uint32_t width; // width in pixels
+ uint32_t height; // height in pixels
+ int32_t stride; // stride in pixels
+ uint8_t* data; // pointer to the bits
+ uint8_t format; // pixel format
+ uint8_t rfu[3]; // must be zero
+ void* reserved;
+} GGLSurface;
+
+// ---------------------------------------------------------------------------
+namespace android {
+// ---------------------------------------------------------------------------
+
+template <class TYPE>
+class EGLNativeSurface : public egl_native_window_t
+{
+public:
+ EGLNativeSurface() : mCount(0) {
+ memset(egl_native_window_t::reserved, 0,
+ sizeof(egl_native_window_t::reserved));
+ memset(egl_native_window_t::reserved_proc, 0,
+ sizeof(egl_native_window_t::reserved_proc));
+ memset(egl_native_window_t::oem, 0,
+ sizeof(egl_native_window_t::oem));
+ }
+ inline void incStrong(void*) const {
+ /* in a real implementation, the inc must be atomic */
+ mCount++;
+ }
+ inline void decStrong(void*) const {
+ /* in a real implementation, the dec must be atomic */
+ if (--mCount == 1) {
+ delete static_cast<const TYPE*>(this);
+ }
+ }
+protected:
+ EGLNativeSurface& operator = (const EGLNativeSurface& rhs);
+ EGLNativeSurface(const EGLNativeSurface& rhs);
+ inline ~EGLNativeSurface() { };
+ mutable volatile int32_t mCount;
+};
+
+
+class EGLDisplaySurface : public EGLNativeSurface<EGLDisplaySurface>
+{
+public:
+ EGLDisplaySurface();
+ ~EGLDisplaySurface();
+
+ int32_t getPageFlipCount() const;
+
+private:
+ static void hook_incRef(NativeWindowType window);
+ static void hook_decRef(NativeWindowType window);
+ static uint32_t hook_swapBuffers(NativeWindowType window);
+ static void hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h);
+ static uint32_t hook_nextBuffer(NativeWindowType window);
+
+ uint32_t swapBuffers();
+ uint32_t nextBuffer();
+ void setSwapRectangle(int l, int t, int w, int h);
+
+ int mapFrameBuffer();
+
+ enum {
+ PAGE_FLIP = 0x00000001
+ };
+ GGLSurface mFb[2];
+ int mIndex;
+ uint32_t mFlags;
+ size_t mSize;
+ fb_var_screeninfo mInfo;
+ fb_fix_screeninfo mFinfo;
+ int32_t mPageFlipCount;
+ int32_t mSwapCount;
+ uint32_t mFeatureFlags;
+};
+
+// ---------------------------------------------------------------------------
+}; // namespace android
+// ---------------------------------------------------------------------------
+
+#endif // ANDROID_SIM_EGL_SURFACE_H
+
diff --git a/opengl/tests/sfsim/sfsim.c b/opengl/tests/sfsim/sfsim.c
new file mode 100644
index 0000000..14ba490
--- /dev/null
+++ b/opengl/tests/sfsim/sfsim.c
@@ -0,0 +1,112 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <GLES/egl.h>
+
+int main(int argc, char** argv)
+{
+ if (argc != 2) {
+ printf("usage: %s <0-6>\n", argv[0]);
+ return 0;
+ }
+
+ const int test = atoi(argv[1]);
+
+ EGLint s_configAttribs[] = {
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_NONE
+ };
+
+ EGLint numConfigs = -1;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLConfig config;
+ EGLContext context;
+ EGLSurface surface;
+ EGLint w, h;
+
+ EGLDisplay dpy;
+
+ dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ eglInitialize(dpy, &majorVersion, &minorVersion);
+ eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+ surface = eglCreateWindowSurface(dpy, config,
+ android_createDisplaySurface(), NULL);
+ context = eglCreateContext(dpy, config, NULL, NULL);
+ eglMakeCurrent(dpy, surface, surface, context);
+ eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
+ eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
+ GLint dim = w<h ? w : h;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ GLint crop[4] = { 0, 4, 4, -4 };
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glEnable(GL_TEXTURE_2D);
+ glColor4f(1,1,1,1);
+
+ // packing is always 4
+ uint8_t t8[] = {
+ 0x00, 0x55, 0x00, 0x55,
+ 0xAA, 0xFF, 0xAA, 0xFF,
+ 0x00, 0x55, 0x00, 0x55,
+ 0xAA, 0xFF, 0xAA, 0xFF };
+
+ uint16_t t16[] = {
+ 0x0000, 0x5555, 0x0000, 0x5555,
+ 0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF,
+ 0x0000, 0x5555, 0x0000, 0x5555,
+ 0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF };
+
+ uint16_t t5551[] = {
+ 0x0000, 0xFFFF, 0x0000, 0xFFFF,
+ 0xFFFF, 0x0000, 0xFFFF, 0x0000,
+ 0x0000, 0xFFFF, 0x0000, 0xFFFF,
+ 0xFFFF, 0x0000, 0xFFFF, 0x0000 };
+
+ uint32_t t32[] = {
+ 0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFFFF0000,
+ 0xFF00FF00, 0xFFFF0000, 0xFF000000, 0xFF0000FF,
+ 0xFF00FFFF, 0xFF00FF00, 0x00FF00FF, 0xFFFFFF00,
+ 0xFF000000, 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFFFF
+ };
+
+ switch(test)
+ {
+ case 1:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
+ 4, 4, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, t8);
+ break;
+ case 2:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+ 4, 4, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, t16);
+ break;
+ case 3:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, t16);
+ break;
+ case 4:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
+ 4, 4, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, t16);
+ break;
+ case 5:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, t5551);
+ break;
+ case 6:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, t32);
+ break;
+ }
+
+ glDrawTexiOES(0, 0, 0, dim, dim);
+
+ eglSwapBuffers(dpy, surface);
+ return 0;
+}
diff --git a/opengl/tests/textures/Android.mk b/opengl/tests/textures/Android.mk
new file mode 100644
index 0000000..b0c9021
--- /dev/null
+++ b/opengl/tests/textures/Android.mk
@@ -0,0 +1,16 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ textures.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libGLES_CM \
+ libui
+
+LOCAL_MODULE:= test-opengl-textures
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/textures/textures.c b/opengl/tests/textures/textures.c
new file mode 100644
index 0000000..98e3be1
--- /dev/null
+++ b/opengl/tests/textures/textures.c
@@ -0,0 +1,107 @@
+/*
+**
+** Copyright 2006, 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 <stdlib.h>
+#include <stdio.h>
+
+#include <GLES/egl.h>
+
+int main(int argc, char** argv)
+{
+ EGLint s_configAttribs[] = {
+ EGL_RED_SIZE, 5,
+ EGL_GREEN_SIZE, 6,
+ EGL_BLUE_SIZE, 5,
+ EGL_NONE
+ };
+
+ EGLint numConfigs = -1;
+ EGLint majorVersion;
+ EGLint minorVersion;
+ EGLConfig config;
+ EGLContext context;
+ EGLSurface surface;
+ EGLint w, h;
+
+ EGLDisplay dpy;
+
+ dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ eglInitialize(dpy, &majorVersion, &minorVersion);
+ eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+ surface = eglCreateWindowSurface(dpy, config,
+ android_createDisplaySurface(), NULL);
+ context = eglCreateContext(dpy, config, NULL, NULL);
+ eglMakeCurrent(dpy, surface, surface, context);
+ eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
+ eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
+ GLint dim = w<h ? w : h;
+
+
+ GLint crop[4] = { 0, 4, 4, -4 };
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glEnable(GL_TEXTURE_2D);
+ glColor4f(1,1,1,1);
+
+ // packing is always 4
+ uint8_t t8[] = {
+ 0x00, 0x55, 0x00, 0x55,
+ 0xAA, 0xFF, 0xAA, 0xFF,
+ 0x00, 0x55, 0x00, 0x55,
+ 0xAA, 0xFF, 0xAA, 0xFF };
+
+ uint16_t t16[] = {
+ 0x0000, 0x5555, 0x0000, 0x5555,
+ 0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF,
+ 0x0000, 0x5555, 0x0000, 0x5555,
+ 0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF };
+
+ uint16_t t5551[] = {
+ 0x0000, 0xFFFF, 0x0000, 0xFFFF,
+ 0xFFFF, 0x0000, 0xFFFF, 0x0000,
+ 0x0000, 0xFFFF, 0x0000, 0xFFFF,
+ 0xFFFF, 0x0000, 0xFFFF, 0x0000 };
+
+ uint32_t t32[] = {
+ 0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFFFF0000,
+ 0xFF00FF00, 0xFFFF0000, 0xFF000000, 0xFF0000FF,
+ 0xFF00FFFF, 0xFF00FF00, 0x00FF00FF, 0xFFFFFF00,
+ 0xFF000000, 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFFFF
+ };
+
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 4, 4, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, t8);
+ glDrawTexiOES(0, 0, 0, dim/2, dim/2);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, t16);
+ glDrawTexiOES(dim/2, 0, 0, dim/2, dim/2);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, t16);
+ glDrawTexiOES(0, dim/2, 0, dim/2, dim/2);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, t32);
+ glDrawTexiOES(dim/2, dim/2, 0, dim/2, dim/2);
+
+ eglSwapBuffers(dpy, surface);
+ return 0;
+}
diff --git a/opengl/tests/tritex/Android.mk b/opengl/tests/tritex/Android.mk
new file mode 100644
index 0000000..4edac4c
--- /dev/null
+++ b/opengl/tests/tritex/Android.mk
@@ -0,0 +1,16 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ tritex.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libGLES_CM \
+ libui
+
+LOCAL_MODULE:= test-opengl-tritex
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/tritex/tritex.c b/opengl/tests/tritex/tritex.c
new file mode 100644
index 0000000..8ebe7d4
--- /dev/null
+++ b/opengl/tests/tritex/tritex.c
@@ -0,0 +1,271 @@
+// Calls glDrawElements() the number of times specified by
+// ITERATIONS. Should draw a checkerboard on the screen after
+// a few seconds.
+//
+// Ported from a Java version by Google.
+
+#include <GLES/egl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+EGLDisplay eglDisplay;
+EGLSurface eglSurface;
+EGLContext eglContext;
+GLuint texture;
+
+#define FIXED_ONE 0x10000
+#define ITERATIONS 50
+
+int init_gl_surface(void);
+void free_gl_surface(void);
+void init_scene(void);
+void render(int quads);
+void create_texture(void);
+int readTimer(void);
+
+static void gluLookAt(float eyeX, float eyeY, float eyeZ,
+ float centerX, float centerY, float centerZ, float upX, float upY,
+ float upZ)
+{
+ // See the OpenGL GLUT documentation for gluLookAt for a description
+ // of the algorithm. We implement it in a straightforward way:
+
+ float fx = centerX - eyeX;
+ float fy = centerY - eyeY;
+ float fz = centerZ - eyeZ;
+
+ // Normalize f
+ float rlf = 1.0f / sqrtf(fx*fx + fy*fy + fz*fz);
+ fx *= rlf;
+ fy *= rlf;
+ fz *= rlf;
+
+ // Normalize up
+ float rlup = 1.0f / sqrtf(upX*upX + upY*upY + upZ*upZ);
+ upX *= rlup;
+ upY *= rlup;
+ upZ *= rlup;
+
+ // compute s = f x up (x means "cross product")
+
+ float sx = fy * upZ - fz * upY;
+ float sy = fz * upX - fx * upZ;
+ float sz = fx * upY - fy * upX;
+
+ // compute u = s x f
+ float ux = sy * fz - sz * fy;
+ float uy = sz * fx - sx * fz;
+ float uz = sx * fy - sy * fx;
+
+ float m[16] ;
+ m[0] = sx;
+ m[1] = ux;
+ m[2] = -fx;
+ m[3] = 0.0f;
+
+ m[4] = sy;
+ m[5] = uy;
+ m[6] = -fy;
+ m[7] = 0.0f;
+
+ m[8] = sz;
+ m[9] = uz;
+ m[10] = -fz;
+ m[11] = 0.0f;
+
+ m[12] = 0.0f;
+ m[13] = 0.0f;
+ m[14] = 0.0f;
+ m[15] = 1.0f;
+
+ glMultMatrixf(m);
+ glTranslatef(-eyeX, -eyeY, -eyeZ);
+}
+
+int main(int argc, char **argv)
+{
+ int q;
+ int start, end;
+
+ printf("Initializing EGL...\n");
+
+ if(!init_gl_surface())
+ {
+ printf("GL initialisation failed - exiting\n");
+ return 0;
+ }
+
+ init_scene();
+
+ create_texture();
+
+ printf("Start test...\n");
+
+ render(argc==2 ? atoi(argv[1]) : ITERATIONS);
+
+ free_gl_surface();
+
+ return 0;
+}
+
+int init_gl_surface(void)
+{
+ EGLint numConfigs = 1;
+ EGLConfig myConfig = {0};
+ EGLint attrib[] =
+ {
+ EGL_DEPTH_SIZE, 16,
+ EGL_NONE
+ };
+
+ if ( (eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY )
+ {
+ printf("eglGetDisplay failed\n");
+ return 0;
+ }
+
+ if ( eglInitialize(eglDisplay, NULL, NULL) != EGL_TRUE )
+ {
+ printf("eglInitialize failed\n");
+ return 0;
+ }
+
+ if ( eglChooseConfig(eglDisplay, attrib, &myConfig, 1, &numConfigs) != EGL_TRUE )
+ {
+ printf("eglChooseConfig failed\n");
+ return 0;
+ }
+
+ if ( (eglSurface = eglCreateWindowSurface(eglDisplay, myConfig,
+ android_createDisplaySurface(), 0)) == EGL_NO_SURFACE )
+ {
+ printf("eglCreateWindowSurface failed\n");
+ return 0;
+ }
+
+ if ( (eglContext = eglCreateContext(eglDisplay, myConfig, 0, 0)) == EGL_NO_CONTEXT )
+ {
+ printf("eglCreateContext failed\n");
+ return 0;
+ }
+
+ if ( eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext) != EGL_TRUE )
+ {
+ printf("eglMakeCurrent failed\n");
+ return 0;
+ }
+
+ return 1;
+}
+
+void free_gl_surface(void)
+{
+ if (eglDisplay != EGL_NO_DISPLAY)
+ {
+ eglMakeCurrent( EGL_NO_DISPLAY, EGL_NO_SURFACE,
+ EGL_NO_SURFACE, EGL_NO_CONTEXT );
+ eglDestroyContext( eglDisplay, eglContext );
+ eglDestroySurface( eglDisplay, eglSurface );
+ eglTerminate( eglDisplay );
+ eglDisplay = EGL_NO_DISPLAY;
+ }
+}
+
+void init_scene(void)
+{
+ glDisable(GL_DITHER);
+ glEnable(GL_CULL_FACE);
+
+ float ratio = 320.0f / 480.0f;
+ glViewport(0, 0, 320, 480);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustumf(-ratio, ratio, -1, 1, 1, 10);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ gluLookAt(
+ 0, 0, 3, // eye
+ 0, 0, 0, // center
+ 0, 1, 0); // up
+
+ glEnable(GL_TEXTURE_2D);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+}
+
+void create_texture(void)
+{
+ const unsigned int on = 0xff0000ff;
+ const unsigned int off = 0xffffffff;
+ const unsigned int pixels[] =
+ {
+ on, off, on, off, on, off, on, off,
+ off, on, off, on, off, on, off, on,
+ on, off, on, off, on, off, on, off,
+ off, on, off, on, off, on, off, on,
+ on, off, on, off, on, off, on, off,
+ off, on, off, on, off, on, off, on,
+ on, off, on, off, on, off, on, off,
+ off, on, off, on, off, on, off, on,
+ };
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+}
+
+void render(int quads)
+{
+ int i, j;
+
+ const GLfloat vertices[] = {
+ -1, -1, 0,
+ 1, -1, 0,
+ 1, 1, 0,
+ -1, 1, 0
+ };
+
+ const GLfixed texCoords[] = {
+ 0, 0,
+ FIXED_ONE, 0,
+ FIXED_ONE, FIXED_ONE,
+ 0, FIXED_ONE
+ };
+
+ const GLushort template[] = { 0, 1, 2, 0, 2, 3 };
+
+
+ GLushort* indices = (GLushort*)malloc(quads*sizeof(template));
+ for (i=0 ; i<quads ; i++)
+ memcpy(indices+(sizeof(template)/sizeof(indices[0]))*i, template, sizeof(template));
+
+ glVertexPointer(3, GL_FLOAT, 0, vertices);
+ glTexCoordPointer(2, GL_FIXED, 0, texCoords);
+
+ // make sure to do a couple eglSwapBuffers to make sure there are
+ // no problems with the very first ones (who knows)
+ glClearColor(0.4, 0.4, 0.4, 0.4);
+ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
+ eglSwapBuffers(eglDisplay, eglSurface);
+ glClearColor(0.6, 0.6, 0.6, 0.6);
+ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
+ eglSwapBuffers(eglDisplay, eglSurface);
+ glClearColor(1.0, 1.0, 1.0, 1.0);
+
+ for (j=0 ; j<10 ; j++) {
+ printf("loop %d / 10 (%d quads / loop)\n", j, quads);
+
+ int nelem = sizeof(template)/sizeof(template[0]);
+ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
+ glDrawElements(GL_TRIANGLES, nelem*quads, GL_UNSIGNED_SHORT, indices);
+ eglSwapBuffers(eglDisplay, eglSurface);
+ }
+
+ free(indices);
+}
+
diff --git a/opengl/tools/glgen/gen b/opengl/tools/glgen/gen
new file mode 100755
index 0000000..1c49861
--- /dev/null
+++ b/opengl/tools/glgen/gen
@@ -0,0 +1,99 @@
+#!/bin/sh
+rm -rf out generated
+
+mkdir out
+mkdir -p out/javax/microedition/khronos/opengles
+mkdir -p out/com/google/android/gles_jni
+mkdir -p out/android/graphics
+
+echo "package android.graphics;" > out/android/graphics/Canvas.java
+echo "public interface Canvas {}" >> out/android/graphics/Canvas.java
+
+GLFILE=out/javax/microedition/khronos/opengles/GL.java
+cp stubs/GLHeader.java-if $GLFILE
+
+GLGEN_FILES="CFunc.java CType.java CodeEmitter.java GenerateGL.java JFunc.java JType.java JniCodeEmitter.java ParameterChecker.java"
+
+pushd src > /dev/null
+javac ${GLGEN_FILES}
+popd > /dev/null
+java -classpath src GenerateGL -c glspec-1.0 glspec-1.0ext glspec-1.1 glspec-1.1ext glspec-1.1extpack glspec-checks
+
+pushd out > /dev/null
+mkdir classes
+javac -d classes com/google/android/gles_jni/GLImpl.java javax/microedition/khronos/opengles/GL10.java javax/microedition/khronos/opengles/GL10Ext.java javax/microedition/khronos/opengles/GL11.java javax/microedition/khronos/opengles/GL11Ext.java javax/microedition/khronos/opengles/GL11ExtensionPack.java
+popd > /dev/null
+
+rm -rf generated
+mkdir -p generated/C
+cp out/com_google_android_gles_jni_GLImpl.cpp generated/C
+cp -r out/com generated
+cp -r out/javax generated
+
+rm -rf out
+
+# com_google_android_gles_jni_GLImpl.cpp
+if cmp ../../../frameworks/base/core/jni/com_google_android_gles_jni_GLImpl.cpp generated/C/com_google_android_gles_jni_GLImpl.cpp ; then
+echo com_google_android_gles_jni_GLImpl.cpp unchanged
+else
+echo Please edit ../../../frameworks/base/core/jni/com_google_android_gles_jni_GLImpl.cpp
+echo Please cp generated/C/com_google_android_gles_jni_GLImpl.cpp ../../../frameworks/base/core/jni
+fi
+
+# GLImpl.java
+if cmp ../../java/com/google/android/gles_jni/GLImpl.java generated/com/google/android/gles_jni/GLImpl.java ; then
+echo GLImpl.java unchanged
+else
+echo Please edit ../../java/com/google/android/gles_jni/GLImpl.java
+echo Please cp generated/com/google/android/gles_jni/GLImpl.java ../../java/com/google/android/gles_jni
+fi
+
+# GL.java
+if cmp ../../java/javax/microedition/khronos/opengles/GL.java generated/javax/microedition/khronos/opengles/GL.java ; then
+echo GL.java unchanged
+else
+echo Please edit ../../java/javax/microedition/khronos/opengles/GL.java
+echo Please cp generated/javax/microedition/khronos/opengles/GL.java ../../java/javax/microedition/khronos/opengles/GL.java
+fi
+
+# GL10.java
+if cmp ../../java/javax/microedition/khronos/opengles/GL10.java generated/javax/microedition/khronos/opengles/GL10.java ; then
+echo GL10.java unchanged
+else
+echo Please edit ../../java/javax/microedition/khronos/opengles/GL10.java
+echo Please cp generated/javax/microedition/khronos/opengles/GL10.java ../../java/javax/microedition/khronos/opengles/GL10.java
+fi
+
+# GL10Ext.java
+if cmp ../../java/javax/microedition/khronos/opengles/GL10Ext.java generated/javax/microedition/khronos/opengles/GL10Ext.java ; then
+echo GL10Ext.java unchanged
+else
+echo Please edit ../../java/javax/microedition/khronos/opengles/GL10Ext.java
+echo Please cp generated/javax/microedition/khronos/opengles/GL10Ext.java ../../java/javax/microedition/khronos/opengles/GL10Ext.java
+fi
+
+# GL11.java
+if cmp ../../java/javax/microedition/khronos/opengles/GL11.java generated/javax/microedition/khronos/opengles/GL11.java ; then
+echo GL11.java unchanged
+else
+echo Please edit ../../java/javax/microedition/khronos/opengles/GL11.java
+echo Please cp generated/javax/microedition/khronos/opengles/GL11.java ../../java/javax/microedition/khronos/opengles/GL11.java
+fi
+
+# GL11Ext.java
+if cmp ../../java/javax/microedition/khronos/opengles/GL11Ext.java generated/javax/microedition/khronos/opengles/GL11Ext.java ; then
+echo GL11Ext.java unchanged
+else
+echo Please edit ../../java/javax/microedition/khronos/opengles/GL11Ext.java
+echo Please cp generated/javax/microedition/khronos/opengles/GL11Ext.java ../../java/javax/microedition/khronos/opengles/GL11Ext.java
+fi
+
+# GL11ExtensionPack.java
+if cmp ../../java/javax/microedition/khronos/opengles/GL11ExtensionPack.java generated/javax/microedition/khronos/opengles/GL11ExtensionPack.java ; then
+echo GL11ExtensionPack.java unchanged
+else
+echo Please edit ../../java/javax/microedition/khronos/opengles/GL11ExtensionPack.java
+echo Please cp generated/javax/microedition/khronos/opengles/GL11ExtensionPack.java ../../java/javax/microedition/khronos/opengles/GL11ExtensionPack.java
+fi
+
+rm -rf generated
diff --git a/opengl/tools/glgen/glspec-1.0 b/opengl/tools/glgen/glspec-1.0
new file mode 100644
index 0000000..c442320
--- /dev/null
+++ b/opengl/tools/glgen/glspec-1.0
@@ -0,0 +1,106 @@
+void glActiveTexture ( GLenum texture )
+void glAlphaFunc ( GLenum func, GLclampf ref )
+void glAlphaFuncx ( GLenum func, GLclampx ref )
+void glBindTexture ( GLenum target, GLuint texture )
+void glBlendFunc ( GLenum sfactor, GLenum dfactor )
+void glClear ( GLbitfield mask )
+void glClearColor ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
+void glClearColorx ( GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha )
+void glClearDepthf ( GLclampf depth )
+void glClearDepthx ( GLclampx depth )
+void glClearStencil ( GLint s )
+void glClientActiveTexture ( GLenum texture )
+void glColor4f ( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
+void glColor4x ( GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha )
+void glColorMask ( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha )
+void glColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
+void glCompressedTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data )
+void glCompressedTexSubImage2D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data )
+void glCopyTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
+void glCopyTexSubImage2D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
+void glCullFace ( GLenum mode )
+void glDeleteTextures ( GLsizei n, const GLuint *textures )
+void glDepthFunc ( GLenum func )
+void glDepthMask ( GLboolean flag )
+void glDepthRangef ( GLclampf zNear, GLclampf zFar )
+void glDepthRangex ( GLclampx zNear, GLclampx zFar )
+void glDisable ( GLenum cap )
+void glDisableClientState ( GLenum array )
+void glDrawArrays ( GLenum mode, GLint first, GLsizei count )
+void glDrawElements ( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
+void glEnable ( GLenum cap )
+void glEnableClientState ( GLenum array )
+void glFinish ( void )
+void glFlush ( void )
+void glFogf ( GLenum pname, GLfloat param )
+void glFogfv ( GLenum pname, const GLfloat *params )
+void glFogx ( GLenum pname, GLfixed param )
+void glFogxv ( GLenum pname, const GLfixed *params )
+void glFrontFace ( GLenum mode )
+void glFrustumf ( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
+void glFrustumx ( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar )
+void glGenTextures ( GLsizei n, GLuint *textures )
+GLenum glGetError ( void )
+void glGetIntegerv ( GLenum pname, GLint *params )
+const GLubyte * glGetString ( GLenum name )
+void glHint ( GLenum target, GLenum mode )
+void glLightModelf ( GLenum pname, GLfloat param )
+void glLightModelfv ( GLenum pname, const GLfloat *params )
+void glLightModelx ( GLenum pname, GLfixed param )
+void glLightModelxv ( GLenum pname, const GLfixed *params )
+void glLightf ( GLenum light, GLenum pname, GLfloat param )
+void glLightfv ( GLenum light, GLenum pname, const GLfloat *params )
+void glLightx ( GLenum light, GLenum pname, GLfixed param )
+void glLightxv ( GLenum light, GLenum pname, const GLfixed *params )
+void glLineWidth ( GLfloat width )
+void glLineWidthx ( GLfixed width )
+void glLoadIdentity ( void )
+void glLoadMatrixf ( const GLfloat *m )
+void glLoadMatrixx ( const GLfixed *m )
+void glLogicOp ( GLenum opcode )
+void glMaterialf ( GLenum face, GLenum pname, GLfloat param )
+void glMaterialfv ( GLenum face, GLenum pname, const GLfloat *params )
+void glMaterialx ( GLenum face, GLenum pname, GLfixed param )
+void glMaterialxv ( GLenum face, GLenum pname, const GLfixed *params )
+void glMatrixMode ( GLenum mode )
+void glMultMatrixf ( const GLfloat *m )
+void glMultMatrixx ( const GLfixed *m )
+void glMultiTexCoord4f ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q )
+void glMultiTexCoord4x ( GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q )
+void glNormal3f ( GLfloat nx, GLfloat ny, GLfloat nz )
+void glNormal3x ( GLfixed nx, GLfixed ny, GLfixed nz )
+void glNormalPointer ( GLenum type, GLsizei stride, const GLvoid *pointer )
+void glOrthof ( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
+void glOrthox ( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar )
+void glPixelStorei ( GLenum pname, GLint param )
+void glPointSize ( GLfloat size )
+void glPointSizex ( GLfixed size )
+void glPolygonOffset ( GLfloat factor, GLfloat units )
+void glPolygonOffsetx ( GLfixed factor, GLfixed units )
+void glPopMatrix ( void )
+void glPushMatrix ( void )
+void glReadPixels ( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels )
+void glRotatef ( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
+void glRotatex ( GLfixed angle, GLfixed x, GLfixed y, GLfixed z )
+void glSampleCoverage ( GLclampf value, GLboolean invert )
+void glSampleCoveragex ( GLclampx value, GLboolean invert )
+void glScalef ( GLfloat x, GLfloat y, GLfloat z )
+void glScalex ( GLfixed x, GLfixed y, GLfixed z )
+void glScissor ( GLint x, GLint y, GLsizei width, GLsizei height )
+void glShadeModel ( GLenum mode )
+void glStencilFunc ( GLenum func, GLint ref, GLuint mask )
+void glStencilMask ( GLuint mask )
+void glStencilOp ( GLenum fail, GLenum zfail, GLenum zpass )
+void glTexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
+void glTexEnvf ( GLenum target, GLenum pname, GLfloat param )
+void glTexEnvfv ( GLenum target, GLenum pname, const GLfloat *params )
+void glTexEnvx ( GLenum target, GLenum pname, GLfixed param )
+void glTexEnvxv ( GLenum target, GLenum pname, const GLfixed *params )
+void glTexImage2D ( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
+void glTexParameterf ( GLenum target, GLenum pname, GLfloat param )
+void glTexParameterx ( GLenum target, GLenum pname, GLfixed param )
+void glTexSubImage2D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
+void glTranslatef ( GLfloat x, GLfloat y, GLfloat z )
+void glTranslatex ( GLfixed x, GLfixed y, GLfixed z )
+void glVertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
+void glViewport ( GLint x, GLint y, GLsizei width, GLsizei height )
diff --git a/opengl/tools/glgen/glspec-1.0ext b/opengl/tools/glgen/glspec-1.0ext
new file mode 100644
index 0000000..7d19758
--- /dev/null
+++ b/opengl/tools/glgen/glspec-1.0ext
@@ -0,0 +1 @@
+GLbitfield glQueryMatrixxOES ( GLfixed *mantissa, GLint *exponent )
diff --git a/opengl/tools/glgen/glspec-1.1 b/opengl/tools/glgen/glspec-1.1
new file mode 100644
index 0000000..9149a7f
--- /dev/null
+++ b/opengl/tools/glgen/glspec-1.1
@@ -0,0 +1,42 @@
+void glBindBuffer ( GLenum target, GLuint buffer )
+void glBufferData ( GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage )
+void glBufferSubData ( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data )
+void glClipPlanef ( GLenum plane, const GLfloat *equation )
+void glClipPlanex ( GLenum plane, const GLfixed *equation )
+void glColor4ub ( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
+void glColorPointer ( GLint size, GLenum type, GLsizei stride, GLint offset )
+void glDeleteBuffers ( GLsizei n, const GLuint *buffers )
+void glDrawElements ( GLenum mode, GLsizei count, GLenum type, GLint offset )
+void glGenBuffers ( GLsizei n, GLuint *buffers )
+void glGetBooleanv ( GLenum pname, GLboolean *params )
+void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params )
+void glGetClipPlanef ( GLenum pname, GLfloat *eqn )
+void glGetClipPlanex ( GLenum pname, GLfixed *eqn )
+void glGetFixedv ( GLenum pname, GLfixed *params )
+void glGetFloatv ( GLenum pname, GLfloat *params )
+void glGetLightfv ( GLenum light, GLenum pname, GLfloat *params )
+void glGetLightxv ( GLenum light, GLenum pname, GLfixed *params )
+void glGetMaterialfv ( GLenum face, GLenum pname, GLfloat *params )
+void glGetMaterialxv ( GLenum face, GLenum pname, GLfixed *params )
+void glGetTexEnviv ( GLenum env, GLenum pname, GLint *params )
+void glGetTexEnvxv ( GLenum env, GLenum pname, GLfixed *params )
+void glGetTexParameterfv ( GLenum target, GLenum pname, GLfloat *params )
+void glGetTexParameteriv ( GLenum target, GLenum pname, GLint *params )
+void glGetTexParameterxv ( GLenum target, GLenum pname, GLfixed *params )
+GLboolean glIsBuffer ( GLuint buffer )
+GLboolean glIsEnabled ( GLenum cap )
+GLboolean glIsTexture ( GLuint texture )
+void glNormalPointer ( GLenum type, GLsizei stride, GLint offset )
+void glPointParameterf ( GLenum pname, GLfloat param )
+void glPointParameterfv ( GLenum pname, const GLfloat *params )
+void glPointParameterx ( GLenum pname, GLfixed param )
+void glPointParameterxv ( GLenum pname, const GLfixed *params )
+void glPointSizePointerOES ( GLenum type, GLsizei stride, const GLvoid *pointer )
+void glTexCoordPointer ( GLint size, GLenum type, GLsizei stride, GLint offset )
+void glTexEnvi ( GLenum target, GLenum pname, GLint param )
+void glTexEnviv ( GLenum target, GLenum pname, const GLint *params )
+void glTexParameterfv ( GLenum target, GLenum pname, const GLfloat *params )
+void glTexParameteri ( GLenum target, GLenum pname, GLint param )
+void glTexParameteriv ( GLenum target, GLenum pname, const GLint *params )
+void glTexParameterxv ( GLenum target, GLenum pname, const GLfixed *params )
+void glVertexPointer ( GLint size, GLenum type, GLsizei stride, GLint offset )
diff --git a/opengl/tools/glgen/glspec-1.1ext b/opengl/tools/glgen/glspec-1.1ext
new file mode 100644
index 0000000..cc08c73
--- /dev/null
+++ b/opengl/tools/glgen/glspec-1.1ext
@@ -0,0 +1,16 @@
+void glCurrentPaletteMatrixOES ( GLuint matrixpaletteindex )
+void glDrawTexfOES ( GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height )
+void glDrawTexfvOES ( const GLfloat *coords )
+void glDrawTexiOES ( GLint x, GLint y, GLint z, GLint width, GLint height )
+void glDrawTexivOES ( const GLint *coords )
+void glDrawTexsOES ( GLshort x, GLshort y, GLshort z, GLshort width, GLshort height )
+void glDrawTexsvOES ( const GLshort *coords )
+void glDrawTexxOES ( GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height )
+void glDrawTexxvOES ( const GLfixed *coords )
+void glEnable ( GLenum cap )
+void glEnableClientState ( GLenum array )
+void glLoadPaletteFromModelViewMatrixOES ( void )
+void glMatrixIndexPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
+void glMatrixIndexPointerOES ( GLint size, GLenum type, GLsizei stride, GLint offset )
+void glWeightPointerOES ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
+void glWeightPointerOES ( GLint size, GLenum type, GLsizei stride, GLint offset )
diff --git a/opengl/tools/glgen/glspec-1.1extpack b/opengl/tools/glgen/glspec-1.1extpack
new file mode 100644
index 0000000..ca9e6d2
--- /dev/null
+++ b/opengl/tools/glgen/glspec-1.1extpack
@@ -0,0 +1,38 @@
+void glBindFramebufferOES ( GLint target, GLint framebuffer )
+void glBindRenderbufferOES ( GLint target, GLint renderbuffer )
+void glBindTexture ( GLint target, GLint texture )
+void glBlendEquation ( GLint mode )
+void glBlendEquationSeparate ( GLint modeRGB, GLint modeAlpha )
+void glBlendFuncSeparate ( GLint srcRGB, GLint dstRGB, GLint srcAlpha, GLint dstAlpha )
+GLint glCheckFramebufferStatusOES ( GLint target )
+void glCompressedTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data )
+void glCopyTexImage2D ( GLint target, GLint level, GLint internalformat, GLint x, GLint y, GLint width, GLint height, GLint border )
+void glDeleteFramebuffersOES ( GLint n, GLint *framebuffers )
+void glDeleteRenderbuffersOES ( GLint n, GLint *renderbuffers )
+void glEnable ( GLint cap )
+void glFramebufferRenderbufferOES ( GLint target, GLint attachment, GLint renderbuffertarget, GLint renderbuffer )
+void glFramebufferTexture2DOES ( GLint target, GLint attachment, GLint textarget, GLint texture, GLint level )
+void glGenerateMipmapOES ( GLint target )
+void glGenFramebuffersOES ( GLint n, GLint *framebuffers )
+void glGenRenderbuffersOES ( GLint n, GLint *renderbuffers )
+void glGetFramebufferAttachmentParameterivOES ( GLint target, GLint attachment, GLint pname, GLint *params )
+void glGetIntegerv ( GLint pname, GLint *params )
+void glGetRenderbufferParameterivOES ( GLint target, GLint pname, GLint *params )
+void glGetTexGenfv ( GLint coord, GLint pname, GLfloat *params )
+void glGetTexGeniv ( GLint coord, GLint pname, GLint *params )
+void glGetTexGenxv ( GLint coord, GLint pname, GLint *params )
+GLboolean glIsFramebufferOES ( GLint framebuffer )
+GLboolean glIsRenderbufferOES ( GLint renderbuffer )
+void glRenderbufferStorageOES ( GLint target, GLint internalformat, GLint width, GLint height )
+void glStencilOp ( GLint fail, GLint zfail, GLint zpass )
+void glTexEnvf ( GLint target, GLint pname, GLfloat param )
+void glTexEnvfv ( GLint target, GLint pname, GLfloat *params )
+void glTexEnvx ( GLint target, GLint pname, GLint param )
+void glTexEnvxv ( GLint target, GLint pname, GLint *params )
+void glTexGenf ( GLint coord, GLint pname, GLfloat param )
+void glTexGenfv ( GLint coord, GLint pname, GLfloat *params )
+void glTexGeni ( GLint coord, GLint pname, GLint param )
+void glTexGeniv ( GLint coord, GLint pname, GLint *params )
+void glTexGenx ( GLint coord, GLint pname, GLint param )
+void glTexGenxv ( GLint coord, GLint pname, GLint *params )
+void glTexParameterf ( GLint target, GLint pname, GLfloat param )
diff --git a/opengl/tools/glgen/glspec-checks b/opengl/tools/glgen/glspec-checks
new file mode 100644
index 0000000..a84ed65
--- /dev/null
+++ b/opengl/tools/glgen/glspec-checks
@@ -0,0 +1,59 @@
+glClipPlanef check equation 4
+glClipPlanex check equation 4
+glDeleteBuffers check buffers n
+glDeleteTextures check textures n
+glDrawElements check_AIOOBE indices count
+glFog ifcheck params 1 pname GL_FOG_MODE,GL_FOG_DENSITY,GL_FOG_START,GL_FOG_END ifcheck params 4 pname GL_FOG_COLOR
+glGenBuffers check buffers n
+glGenTextures check textures n
+glGetClipPlane check eqn 4
+glGetIntegerv ifcheck params 1 pname GL_ALPHA_BITS,GL_ALPHA_TEST_FUNC,GL_ALPHA_TEST_REF,GL_BLEND_DST,GL_BLUE_BITS,GL_COLOR_ARRAY_BUFFER_BINDING,GL_COLOR_ARRAY_SIZE,GL_COLOR_ARRAY_STRIDE,GL_COLOR_ARRAY_TYPE,GL_CULL_FACE,GL_DEPTH_BITS,GL_DEPTH_CLEAR_VALUE,GL_DEPTH_FUNC,GL_DEPTH_WRITEMASK,GL_FOG_DENSITY,GL_FOG_END,GL_FOG_MODE,GL_FOG_START,GL_FRONT_FACE,GL_GREEN_BITS,GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES,GL_IMPLEMENTATION_COLOR_READ_TYPE_OES,GL_LIGHT_MODEL_TWO_SIDE,GL_LINE_SMOOTH_HINT,GL_LINE_WIDTH,GL_LOGIC_OP_MODE,GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES,GL_MATRIX_INDEX_ARRAY_SIZE_OES,GL_MATRIX_INDEX_ARRAY_STRIDE_OES,GL_MATRIX_INDEX_ARRAY_TYPE_OES,GL_MATRIX_MODE,GL_MAX_CLIP_PLANES,GL_MAX_ELEMENTS_INDICES,GL_MAX_ELEMENTS_VERTICES,GL_MAX_LIGHTS,GL_MAX_MODELVIEW_STACK_DEPTH,GL_MAX_PALETTE_MATRICES_OES,GL_MAX_PROJECTION_STACK_DEPTH,GL_MAX_TEXTURE_SIZE,GL_MAX_TEXTURE_STACK_DEPTH,GL_MAX_TEXTURE_UNITS,GL_MAX_VERTEX_UNITS_OES,GL_MODELVIEW_STACK_DEPTH,GL_NORMAL_ARRAY_BUFFER_BINDING,GL_NORMAL_ARRAY_STRIDE,GL_NORMAL_ARRAY_TYPE,GL_NUM_COMPRESSED_TEXTURE_FORMATS,GL_PACK_ALIGNMENT,GL_PERSPECTIVE_CORRECTION_HINT,GL_POINT_SIZE,GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES,GL_POINT_SIZE_ARRAY_STRIDE_OES,GL_POINT_SIZE_ARRAY_TYPE_OES,GL_POINT_SMOOTH_HINT,GL_POLYGON_OFFSET_FACTOR,GL_POLYGON_OFFSET_UNITS,GL_PROJECTION_STACK_DEPTH,GL_RED_BITS,GL_SHADE_MODEL,GL_STENCIL_BITS,GL_STENCIL_CLEAR_VALUE,GL_STENCIL_FAIL,GL_STENCIL_FUNC,GL_STENCIL_PASS_DEPTH_FAIL,GL_STENCIL_PASS_DEPTH_PASS,GL_STENCIL_REF,GL_STENCIL_VALUE_MASK,GL_STENCIL_WRITEMASK,GL_SUBPIXEL_BITS,GL_TEXTURE_BINDING_2D,GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING,GL_TEXTURE_COORD_ARRAY_SIZE,GL_TEXTURE_COORD_ARRAY_STRIDE,GL_TEXTURE_COORD_ARRAY_TYPE,GL_TEXTURE_STACK_DEPTH,GL_UNPACK_ALIGNMENT,GL_VERTEX_ARRAY_BUFFER_BINDING,GL_VERTEX_ARRAY_SIZE,GL_VERTEX_ARRAY_STRIDE,GL_VERTEX_ARRAY_TYPE,GL_WEIGHT_ARRAY_BUFFER_BINDING_OES,GL_WEIGHT_ARRAY_SIZE_OES,GL_WEIGHT_ARRAY_STRIDE_OES,GL_WEIGHT_ARRAY_TYPE_OES ifcheck params 2 pname GL_ALIASED_POINT_SIZE_RANGE,GL_ALIASED_LINE_WIDTH_RANGE,GL_DEPTH_RANGE,GL_MAX_VIEWPORT_DIMS,GL_SMOOTH_LINE_WIDTH_RANGE,GL_SMOOTH_POINT_SIZE_RANGE ifcheck params 4 pname GL_COLOR_CLEAR_VALUE,GL_COLOR_WRITEMASK,GL_SCISSOR_BOX,GL_VIEWPORT ifcheck params 16 pname GL_MODELVIEW_MATRIX,GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES,GL_PROJECTION_MATRIX,GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES,GL_TEXTURE_MATRIX,GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES ifcheck params _NUM_COMPRESSED_TEXTURE_FORMATS pname GL_COMPRESSED_TEXTURE_FORMATS,GL_FOG_COLOR,GL_LIGHT_MODEL_AMBIENT
+glGetLight ifcheck params 1 pname GL_SPOT_EXPONENT,GL_SPOT_CUTOFF,GL_CONSTANT_ATTENUATION,GL_LINEAR_ATTENUATION,GL_QUADRATIC_ATTENUATION ifcheck params 3 pname GL_SPOT_DIRECTION ifcheck params 4 pname GL_AMBIENT,GL_DIFFUSE,GL_SPECULAR,GL_EMISSION
+glGetMaterial ifcheck params 1 pname GL_SHININESS ifcheck params 4 pname GL_AMBIENT,GL_DIFFUSE,GL_SPECULAR,GL_EMISSION,GL_AMBIENT_AND_DIFFUSE
+glGetTexEnv ifcheck params 1 pname GL_TEXTURE_ENV_MODE,GL_COMBINE_RGB,GL_COMBINE_ALPHA ifcheck params 4 pname GL_TEXTURE_ENV_COLOR
+glGetTexParameter check params 1
+glLightModel ifcheck params 1 pname GL_LIGHT_MODEL_TWO_SIDE ifcheck params 4 pname GL_LIGHT_MODEL_AMBIENT
+glLight ifcheck params 1 pname GL_SPOT_EXPONENT,GL_SPOT_CUTOFF,GL_CONSTANT_ATTENUATION,GL_LINEAR_ATTENUATION,GL_QUADRATIC_ATTENUATION ifcheck params 3 pname GL_SPOT_DIRECTION ifcheck params 4 pname GL_AMBIENT,GL_DIFFUSE,GL_SPECULAR,GL_EMISSION
+glLoadMatrix check m 16
+glMaterial ifcheck params 1 pname GL_SHININESS ifcheck params 4 pname GL_AMBIENT,GL_DIFFUSE,GL_SPECULAR,GL_EMISSION,GL_AMBIENT_AND_DIFFUSE
+glMultMatrix check m 16
+glPointParameter check params 1
+glTexEnv ifcheck params 1 pname GL_TEXTURE_ENV_MODE,GL_COMBINE_RGB,GL_COMBINE_ALPHA ifcheck params 4 pname GL_TEXTURE_ENV_COLOR
+glTexImage2D nullAllowed
+glTexSubImage2D nullAllowed
+glBufferData nullAllowed
+glTexParameter check params 1
+glQueryMatrixxOES check mantissa 16 check exponent 16 return -1
+glDrawTexfvOES check coords 5
+glDrawTexivOES check coords 5
+glDrawTexsvOES check coords 5
+glDrawTexxvOES check coords 5
+glBindFramebufferOES unsupported
+glBindRenderbufferOES unsupported
+glBlendEquation unsupported
+glBlendEquationSeparate unsupported
+glBlendFuncSeparate unsupported
+glCheckFramebufferStatusOES unsupported return 0
+glCurrentPaletteMatrixOES unsupported
+glDeleteFramebuffersOES unsupported
+glDeleteRenderbuffersOES unsupported
+glFramebufferRenderbufferOES unsupported
+glFramebufferStorageOES unsupported
+glFramebufferTexture2DOES unsupported
+glGenFramebuffersOES unsupported
+glGenRenderbuffersOES unsupported
+glGenerateMipmapOES unsupported
+glGetBufferParameter unsupported
+glGetFramebufferAttachmentParameterivOES unsupported
+glGetRenderbufferParameterivOES unsupported
+glGetTexGen unsupported
+glIsFramebufferOES unsupported return JNI_FALSE
+glIsRenderbufferOES unsupported return JNI_FALSE
+glLoadPaletteFromModelViewMatrixOES unsupported
+glMatrixIndexPointerOES unsupported
+glRenderbufferStorageOES unsupported return false
+glTexGen unsupported
+glTexGenf unsupported
+glTexGeni unsupported
+glTexGenx unsupported
+glWeightPointerOES unsupported
diff --git a/opengl/tools/glgen/src/CFunc.java b/opengl/tools/glgen/src/CFunc.java
new file mode 100644
index 0000000..0794f41
--- /dev/null
+++ b/opengl/tools/glgen/src/CFunc.java
@@ -0,0 +1,155 @@
+
+import java.util.*;
+
+public class CFunc {
+
+ String original;
+
+ CType ftype;
+ String fname;
+
+ List<String> argNames = new ArrayList<String>();
+ List<CType> argTypes = new ArrayList<CType>();
+
+ boolean hasPointerArg = false;
+ boolean hasTypedPointerArg = false;
+
+ public CFunc(String original) {
+ this.original = original;
+ }
+
+ public String getOriginal() {
+ return original;
+ }
+
+ public void setName(String fname) {
+ this.fname = fname;
+ }
+
+ public String getName() {
+ return fname;
+ }
+
+ public void setType(CType ftype) {
+ this.ftype = ftype;
+ }
+
+ public CType getType() {
+ return ftype;
+ }
+
+ public void addArgument(String argName, CType argType) {
+ argNames.add(argName);
+ argTypes.add(argType);
+
+ if (argType.isPointer()) {
+ hasPointerArg = true;
+ }
+ if (argType.isTypedPointer()) {
+ hasTypedPointerArg = true;
+ }
+ }
+
+ public int getNumArgs() {
+ return argNames.size();
+ }
+
+ public int getArgIndex(String name) {
+ int len = argNames.size();
+ for (int i = 0; i < len; i++) {
+ if (name.equals(argNames.get(i))) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public String getArgName(int index) {
+ return argNames.get(index);
+ }
+
+ public CType getArgType(int index) {
+ return argTypes.get(index);
+ }
+
+ public boolean hasPointerArg() {
+ return hasPointerArg;
+ }
+
+ public boolean hasTypedPointerArg() {
+ return hasTypedPointerArg;
+ }
+
+ public String toString() {
+ String s = "Function " + fname + " returns " + ftype + ": ";
+ for (int i = 0; i < argNames.size(); i++) {
+ if (i > 0) {
+ s += ", ";
+ }
+ s += argTypes.get(i) + " " + argNames.get(i);
+ }
+ return s;
+ }
+
+ public static CFunc parseCFunc(String s) {
+ CFunc cfunc = new CFunc(s);
+ String[] tokens = s.split("\\s");
+
+ int i = 0;
+ CType ftype = new CType();
+ String ftypeName = tokens[i++];
+ if (ftypeName.equals("const")) {
+ ftype.setIsConst(true);
+ ftypeName = tokens[i++];
+ }
+ ftype.setBaseType(ftypeName);
+
+ String fname = tokens[i++];
+ if (fname.equals("*")) {
+ ftype.setIsPointer(true);
+ fname = tokens[i++];
+ }
+
+ cfunc.setName(fname);
+ cfunc.setType(ftype);
+
+ while (i < tokens.length) {
+ String tok = tokens[i++];
+
+ if (tok.equals("(")) {
+ continue;
+ }
+ if (tok.equals(")")) {
+ break;
+ }
+
+ CType argType = new CType();
+
+ String argTypeName = tok;
+ String argName = "";
+
+ if (argTypeName.equals("const")) {
+ argType.setIsConst(true);
+ argTypeName = tokens[i++];
+ }
+ argType.setBaseType(argTypeName);
+
+ if (argTypeName.equals("void")) {
+ break;
+ }
+
+ argName = tokens[i++];
+ if (argName.startsWith("*")) {
+ argType.setIsPointer(true);
+ argName = argName.substring(1, argName.length());
+ }
+ if (argName.endsWith(",")) {
+ argName = argName.substring(0, argName.length() - 1);
+ }
+
+ cfunc.addArgument(argName, argType);
+ }
+
+ return cfunc;
+ }
+}
diff --git a/opengl/tools/glgen/src/CType.java b/opengl/tools/glgen/src/CType.java
new file mode 100644
index 0000000..331ec62
--- /dev/null
+++ b/opengl/tools/glgen/src/CType.java
@@ -0,0 +1,85 @@
+
+public class CType {
+
+ String baseType;
+ boolean isConst;
+ boolean isPointer;
+
+ public CType() {
+ }
+
+ public CType(String baseType) {
+ setBaseType(baseType);
+ }
+
+ public CType(String baseType, boolean isConst, boolean isPointer) {
+ setBaseType(baseType);
+ setIsConst(isConst);
+ setIsPointer(isPointer);
+ }
+
+ public String getDeclaration() {
+ return baseType + (isPointer ? " *" : "");
+ }
+
+ public void setIsConst(boolean isConst) {
+ this.isConst = isConst;
+ }
+
+ public boolean isConst() {
+ return isConst;
+ }
+
+ public void setIsPointer(boolean isPointer) {
+ this.isPointer = isPointer;
+ }
+
+ public boolean isPointer() {
+ return isPointer;
+ }
+
+ boolean isVoid() {
+ String baseType = getBaseType();
+ return baseType.equals("GLvoid") ||
+ baseType.equals("void");
+ }
+
+ public boolean isTypedPointer() {
+ return isPointer() && !isVoid();
+ }
+
+ public void setBaseType(String baseType) {
+ this.baseType = baseType;
+ }
+
+ public String getBaseType() {
+ return baseType;
+ }
+
+ public String toString() {
+ String s = "";
+ if (isConst()) {
+ s += "const ";
+ }
+ s += baseType;
+ if (isPointer()) {
+ s += "*";
+ }
+
+ return s;
+ }
+
+ public int hashCode() {
+ return baseType.hashCode() ^ (isPointer ? 2 : 0) ^ (isConst ? 1 : 0);
+ }
+
+ public boolean equals(Object o) {
+ if (o != null && o instanceof CType) {
+ CType c = (CType)o;
+ return baseType.equals(c.baseType) &&
+ isPointer() == c.isPointer() &&
+ isConst() == c.isConst();
+ }
+ return false;
+ }
+}
diff --git a/opengl/tools/glgen/src/CodeEmitter.java b/opengl/tools/glgen/src/CodeEmitter.java
new file mode 100644
index 0000000..3e9b90a
--- /dev/null
+++ b/opengl/tools/glgen/src/CodeEmitter.java
@@ -0,0 +1,8 @@
+
+public interface CodeEmitter {
+
+ void setVersion(int version, boolean ext, boolean pack);
+ void emitCode(CFunc cfunc, String original);
+ void addNativeRegistration(String fname);
+ void emitNativeRegistration();
+}
diff --git a/opengl/tools/glgen/src/GenerateGL.java b/opengl/tools/glgen/src/GenerateGL.java
new file mode 100644
index 0000000..657ee6e
--- /dev/null
+++ b/opengl/tools/glgen/src/GenerateGL.java
@@ -0,0 +1,164 @@
+
+import java.io.*;
+import java.util.*;
+
+public class GenerateGL {
+
+ static void copy(String filename, PrintStream out) throws IOException {
+ BufferedReader br = new BufferedReader(new FileReader(filename));
+ String s;
+ while ((s = br.readLine()) != null) {
+ out.println(s);
+ }
+ }
+
+ private static void emit(int version, boolean ext, boolean pack,
+ CodeEmitter emitter,
+ BufferedReader specReader,
+ PrintStream glStream,
+ PrintStream glImplStream,
+ PrintStream cStream) throws Exception {
+ String s = null;
+ int counter = 0;
+ while ((s = specReader.readLine()) != null) {
+ if (s.trim().startsWith("//")) {
+ continue;
+ }
+
+ CFunc cfunc = CFunc.parseCFunc(s);
+
+ String fname = cfunc.getName();
+ File f = new File("stubs/" + fname +
+ ".java-1" + version + "-if");
+ if (f.exists()) {
+ System.out.println("Special-casing function " + fname);
+ copy("stubs/" + fname +
+ ".java-1" + version + "-if", glStream);
+ copy("stubs/" + fname + ".java-impl", glImplStream);
+ copy("stubs/" + fname + ".cpp", cStream);
+
+ // Register native function names
+ // This should be improved to require fewer discrete files
+ String filename = "stubs/" + fname + ".nativeReg";
+ BufferedReader br =
+ new BufferedReader(new FileReader(filename));
+ String nfunc;
+ while ((nfunc = br.readLine()) != null) {
+ emitter.addNativeRegistration(nfunc);
+ }
+ } else {
+ emitter.setVersion(version, ext, pack);
+ emitter.emitCode(cfunc, s);
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ String classPathName = "com/google/android/gles_jni/GLImpl";
+ boolean useContextPointer = true;
+
+ int aidx = 0;
+ while (args[aidx].charAt(0) == '-') {
+ switch (args[aidx].charAt(1)) {
+ case 'c':
+ useContextPointer = false;
+ break;
+
+ default:
+ System.err.println("Unknown flag: " + args[aidx]);
+ System.exit(1);
+ }
+
+ aidx++;
+ }
+
+ System.out.println("useContextPointer = " + useContextPointer);
+
+ BufferedReader spec10Reader =
+ new BufferedReader(new FileReader(args[aidx++]));
+ BufferedReader spec10ExtReader =
+ new BufferedReader(new FileReader(args[aidx++]));
+ BufferedReader spec11Reader =
+ new BufferedReader(new FileReader(args[aidx++]));
+ BufferedReader spec11ExtReader =
+ new BufferedReader(new FileReader(args[aidx++]));
+ BufferedReader spec11ExtPackReader =
+ new BufferedReader(new FileReader(args[aidx++]));
+ BufferedReader checksReader =
+ new BufferedReader(new FileReader(args[aidx++]));
+
+ String gl10Filename = "javax/microedition/khronos/opengles/GL10.java";
+ String gl10ExtFilename =
+ "javax/microedition/khronos/opengles/GL10Ext.java";
+ String gl11Filename = "javax/microedition/khronos/opengles/GL11.java";
+ String gl11ExtFilename =
+ "javax/microedition/khronos/opengles/GL11Ext.java";
+ String gl11ExtPackFilename =
+ "javax/microedition/khronos/opengles/GL11ExtensionPack.java";
+ String glImplFilename = "com/google/android/gles_jni/GLImpl.java";
+ String cFilename = "com_google_android_gles_jni_GLImpl.cpp";
+
+ PrintStream gl10Stream =
+ new PrintStream(new FileOutputStream("out/" + gl10Filename));
+ PrintStream gl10ExtStream =
+ new PrintStream(new FileOutputStream("out/" + gl10ExtFilename));
+ PrintStream gl11Stream =
+ new PrintStream(new FileOutputStream("out/" + gl11Filename));
+ PrintStream gl11ExtStream =
+ new PrintStream(new FileOutputStream("out/" + gl11ExtFilename));
+ PrintStream gl11ExtPackStream =
+ new PrintStream(new FileOutputStream("out/" + gl11ExtPackFilename));
+ PrintStream glImplStream =
+ new PrintStream(new FileOutputStream("out/" + glImplFilename));
+ PrintStream cStream =
+ new PrintStream(new FileOutputStream("out/" + cFilename));
+
+ ParameterChecker checker = new ParameterChecker(checksReader);
+
+ CodeEmitter emitter =
+ new JniCodeEmitter(classPathName,
+ checker,
+ gl10Stream, gl10ExtStream,
+ gl11Stream, gl11ExtStream, gl11ExtPackStream,
+ glImplStream, cStream,
+ useContextPointer);
+
+ gl10Stream.println("/* //device/java/android/" + gl10Filename);
+ gl10ExtStream.println("/* //device/java/android/" + gl10ExtFilename);
+ gl11Stream.println("/* //device/java/android/" + gl11Filename);
+ gl11ExtStream.println("/* //device/java/android/" + gl11ExtFilename);
+ gl11ExtPackStream.println("/* //device/java/android/" +
+ gl11ExtPackFilename);
+ glImplStream.println("/* //device/java/android/" + glImplFilename);
+ cStream.println("/* //device/libs/android_runtime/" + cFilename);
+
+ copy("stubs/GL10Header.java-if", gl10Stream);
+ copy("stubs/GL10ExtHeader.java-if", gl10ExtStream);
+ copy("stubs/GL11Header.java-if", gl11Stream);
+ copy("stubs/GL11ExtHeader.java-if", gl11ExtStream);
+ copy("stubs/GL11ExtensionPackHeader.java-if", gl11ExtPackStream);
+ copy("stubs/GLImplHeader.java-impl", glImplStream);
+ copy("stubs/GLCHeader.cpp", cStream);
+
+ emit(0, false, false,
+ emitter, spec10Reader, gl10Stream, glImplStream, cStream);
+ emit(0, true, false,
+ emitter, spec10ExtReader, gl10ExtStream, glImplStream, cStream);
+ emit(1, false, false,
+ emitter, spec11Reader, gl11Stream, glImplStream, cStream);
+ emit(1, true, false,
+ emitter, spec11ExtReader, gl11ExtStream, glImplStream, cStream);
+ emit(1, true, true,
+ emitter, spec11ExtPackReader, gl11ExtPackStream, glImplStream,
+ cStream);
+
+ emitter.emitNativeRegistration();
+
+ gl10Stream.println("}");
+ gl10ExtStream.println("}");
+ gl11Stream.println("}");
+ gl11ExtStream.println("}");
+ gl11ExtPackStream.println("}");
+ glImplStream.println("}");
+ }
+}
diff --git a/opengl/tools/glgen/src/JFunc.java b/opengl/tools/glgen/src/JFunc.java
new file mode 100644
index 0000000..42d466c
--- /dev/null
+++ b/opengl/tools/glgen/src/JFunc.java
@@ -0,0 +1,148 @@
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class JFunc {
+
+ String className = "com.google.android.gles_jni.GL11Impl";
+
+ CFunc cfunc;
+ JType ftype;
+ String fname;
+
+ List<String> argNames = new ArrayList<String>();
+ List<JType> argTypes = new ArrayList<JType>();
+ List<Integer> argCIndices = new ArrayList<Integer>();
+
+ boolean hasBufferArg = false;
+ boolean hasTypedBufferArg = false;
+ ArrayList<String> bufferArgNames = new ArrayList<String>();
+
+ public JFunc(CFunc cfunc) {
+ this.cfunc = cfunc;
+ }
+
+ public CFunc getCFunc() {
+ return cfunc;
+ }
+
+ public void setName(String fname) {
+ this.fname = fname;
+ }
+
+ public String getName() {
+ return fname;
+ }
+
+ public void setType(JType ftype) {
+ this.ftype = ftype;
+ }
+
+ public JType getType() {
+ return ftype;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public boolean hasBufferArg() {
+ return hasBufferArg;
+ }
+
+ public boolean hasTypedBufferArg() {
+ return hasTypedBufferArg;
+ }
+
+ public String getBufferArgName(int index) {
+ return bufferArgNames.get(index);
+ }
+
+ public void addArgument(String argName, JType argType, int cindex) {
+ argNames.add(argName);
+ argTypes.add(argType);
+ argCIndices.add(new Integer(cindex));
+
+ if (argType.isBuffer()) {
+ hasBufferArg = true;
+ bufferArgNames.add(argName);
+ }
+ if (argType.isTypedBuffer()) {
+ hasTypedBufferArg = true;
+ bufferArgNames.add(argName);
+ }
+ }
+
+ public int getNumArgs() {
+ return argNames.size();
+ }
+
+ public int getArgIndex(String name) {
+ int len = argNames.size();
+ for (int i = 0; i < len; i++) {
+ if (name.equals(argNames.get(i))) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public String getArgName(int index) {
+ return argNames.get(index);
+ }
+
+ public JType getArgType(int index) {
+ return argTypes.get(index);
+ }
+
+ public int getArgCIndex(int index) {
+ return argCIndices.get(index).intValue();
+ }
+
+ public static JFunc convert(CFunc cfunc, boolean useArray) {
+ JFunc jfunc = new JFunc(cfunc);
+ jfunc.setName(cfunc.getName());
+ jfunc.setType(JType.convert(cfunc.getType(), false));
+
+ int numArgs = cfunc.getNumArgs();
+ int numOffsets = 0;
+ for (int i = 0; i < numArgs; i++) {
+ CType cArgType = cfunc.getArgType(i);
+ if (cArgType.isTypedPointer() && useArray) {
+ ++numOffsets;
+ }
+ }
+
+ for (int i = 0; i < numArgs; i++) {
+ String cArgName = cfunc.getArgName(i);
+ CType cArgType = cfunc.getArgType(i);
+
+ jfunc.addArgument(cArgName, JType.convert(cArgType, useArray), i);
+ if (cArgType.isTypedPointer() && useArray) {
+ if (numOffsets > 1) {
+ jfunc.addArgument(cArgName + "Offset", new JType("int"), i);
+ } else {
+ jfunc.addArgument("offset", new JType("int"), i);
+ }
+ }
+ }
+
+ return jfunc;
+ }
+
+ public String toString() {
+ String s = "Function " + fname + " returns " + ftype + ": ";
+ for (int i = 0; i < argNames.size(); i++) {
+ if (i > 0) {
+ s += ", ";
+ }
+ s += argTypes.get(i) + " " + argNames.get(i);
+ }
+ return s;
+ }
+
+}
diff --git a/opengl/tools/glgen/src/JType.java b/opengl/tools/glgen/src/JType.java
new file mode 100644
index 0000000..a16d440
--- /dev/null
+++ b/opengl/tools/glgen/src/JType.java
@@ -0,0 +1,139 @@
+
+import java.util.HashMap;
+
+public class JType {
+
+ String baseType;
+ boolean isArray;
+ boolean isClass;
+
+ static HashMap<CType,JType> typeMapping = new HashMap<CType,JType>();
+ static HashMap<CType,JType> arrayTypeMapping = new HashMap<CType,JType>();
+
+ static {
+ // Primitive types
+ typeMapping.put(new CType("GLbitfield"), new JType("int"));
+ typeMapping.put(new CType("GLboolean"), new JType("boolean"));
+ typeMapping.put(new CType("GLclampf"), new JType("float"));
+ typeMapping.put(new CType("GLclampx"), new JType("int"));
+ typeMapping.put(new CType("GLenum"), new JType("int"));
+ typeMapping.put(new CType("GLfloat"), new JType("float"));
+ typeMapping.put(new CType("GLfixed"), new JType("int"));
+ typeMapping.put(new CType("GLint"), new JType("int"));
+ typeMapping.put(new CType("GLintptr"), new JType("int"));
+ typeMapping.put(new CType("GLshort"), new JType("short"));
+ typeMapping.put(new CType("GLsizei"), new JType("int"));
+ typeMapping.put(new CType("GLsizeiptr"), new JType("int"));
+ typeMapping.put(new CType("GLubyte"), new JType("byte"));
+ typeMapping.put(new CType("GLuint"), new JType("int"));
+ typeMapping.put(new CType("void"), new JType("void"));
+ typeMapping.put(new CType("GLubyte", true, true), new JType("String"));
+
+ // Untyped pointers map to untyped Buffers
+ typeMapping.put(new CType("GLvoid", true, true),
+ new JType("java.nio.Buffer", true, false));
+ typeMapping.put(new CType("GLvoid", false, true),
+ new JType("java.nio.Buffer", true, false));
+ typeMapping.put(new CType("void", false, true),
+ new JType("java.nio.Buffer", true, false));
+
+ // Typed pointers map to typed Buffers
+ typeMapping.put(new CType("GLboolean", false, true),
+ new JType("java.nio.IntBuffer", true, false));
+ typeMapping.put(new CType("GLfixed", false, true),
+ new JType("java.nio.IntBuffer", true, false));
+ typeMapping.put(new CType("GLfixed", true, true),
+ new JType("java.nio.IntBuffer", true, false));
+ typeMapping.put(new CType("GLfloat", false, true),
+ new JType("java.nio.FloatBuffer", true, false));
+ typeMapping.put(new CType("GLfloat", true, true),
+ new JType("java.nio.FloatBuffer", true, false));
+ typeMapping.put(new CType("GLint", false, true),
+ new JType("java.nio.IntBuffer", true, false));
+ typeMapping.put(new CType("GLint", true, true),
+ new JType("java.nio.IntBuffer", true, false));
+ typeMapping.put(new CType("GLuint", false, true),
+ new JType("java.nio.IntBuffer", true, false));
+ typeMapping.put(new CType("GLuint", true, true),
+ new JType("java.nio.IntBuffer", true, false));
+ typeMapping.put(new CType("GLshort", true, true),
+ new JType("java.nio.ShortBuffer", true, false));
+
+ // Typed pointers map to arrays + offsets
+ arrayTypeMapping.put(new CType("GLboolean", false, true),
+ new JType("boolean", false, true));
+ arrayTypeMapping.put(new CType("GLfixed", true, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("GLfixed", false, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("GLfloat", false, true), new JType("float", false, true));
+ arrayTypeMapping.put(new CType("GLfloat", true, true), new JType("float", false, true));
+ arrayTypeMapping.put(new CType("GLint", false, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("GLint", true, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("GLshort", true, true), new JType("short", false, true));
+ arrayTypeMapping.put(new CType("GLuint", false, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("GLuint", true, true), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("GLintptr"), new JType("int", false, true));
+ arrayTypeMapping.put(new CType("GLsizeiptr"), new JType("int", false, true));
+ }
+
+ public JType() {
+ }
+
+ public JType(String primitiveTypeName) {
+ this.baseType = primitiveTypeName;
+ this.isClass = false;
+ this.isArray = false;
+ }
+
+ public JType(String primitiveTypeName, boolean isClass, boolean isArray) {
+ this.baseType = primitiveTypeName;
+ this.isClass = isClass;
+ this.isArray = isArray;
+ }
+
+ public String getBaseType() {
+ return baseType;
+ }
+
+ public String toString() {
+ return baseType + (isArray ? "[]" : "");
+ }
+
+ public boolean isArray() {
+ return isArray;
+ }
+
+ public boolean isClass() {
+ return isClass;
+ }
+
+ public boolean isPrimitive() {
+ return !isClass() && !isArray();
+ }
+
+ public boolean isVoid() {
+ return baseType.equals("void");
+ }
+
+ public boolean isBuffer() {
+ return baseType.indexOf("Buffer") != -1;
+ }
+
+ public boolean isTypedBuffer() {
+ return !baseType.equals("java.nio.Buffer") &&
+ (baseType.indexOf("Buffer") != -1);
+ }
+
+ public static JType convert(CType ctype, boolean useArray) {
+ JType javaType = null;
+ if (useArray) {
+ javaType = arrayTypeMapping.get(ctype);
+ }
+ if (javaType == null) {
+ javaType = typeMapping.get(ctype);
+ }
+ if (javaType == null) {
+ throw new RuntimeException("Unsupported C type: " + ctype);
+ }
+ return javaType;
+ }
+}
diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java
new file mode 100644
index 0000000..33b9a3e
--- /dev/null
+++ b/opengl/tools/glgen/src/JniCodeEmitter.java
@@ -0,0 +1,1086 @@
+import java.io.PrintStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Emits a Java interface and Java & C implementation for a C function.
+ *
+ * <p> The Java interface will have Buffer and array variants for functions that
+ * have a typed pointer argument. The array variant will convert a single "<type> *data"
+ * argument to a pair of arguments "<type>[] data, int offset".
+ */
+public class JniCodeEmitter implements CodeEmitter {
+
+ // If true, use C++ style for calling through a JNIEnv *:
+ // env->Func(...)
+ // If false, use C style:
+ // (*env)->Func(env, ...)
+ static final boolean mUseCPlusPlus = true;
+
+ boolean mUseContextPointer = true;
+
+ String mClassPathName;
+
+ ParameterChecker mChecker;
+ PrintStream mJava10InterfaceStream;
+ PrintStream mJava10ExtInterfaceStream;
+ PrintStream mJava11InterfaceStream;
+ PrintStream mJava11ExtInterfaceStream;
+ PrintStream mJava11ExtPackInterfaceStream;
+ PrintStream mJavaImplStream;
+ PrintStream mCStream;
+
+ PrintStream mJavaInterfaceStream;
+
+ List<String> nativeRegistrations = new ArrayList<String>();
+
+ boolean needsExit;
+
+ static String indent = " ";
+
+ HashSet<String> mFunctionsEmitted = new HashSet<String>();
+
+ /**
+ * @param java10InterfaceStream the PrintStream to which to emit the Java interface for GL 1.0 functions
+ * @param java10ExtInterfaceStream the PrintStream to which to emit the Java interface for GL 1.0 extension functions
+ * @param java11InterfaceStream the PrintStream to which to emit the Java interface for GL 1.1 functions
+ * @param java11ExtInterfaceStream the PrintStream to which to emit the Java interface for GL 1.1 Extension functions
+ * @param java11ExtPackInterfaceStream the PrintStream to which to emit the Java interface for GL 1.1 Extension Pack functions
+ * @param javaImplStream the PrintStream to which to emit the Java implementation
+ * @param cStream the PrintStream to which to emit the C implementation
+ */
+ public JniCodeEmitter(String classPathName,
+ ParameterChecker checker,
+ PrintStream java10InterfaceStream,
+ PrintStream java10ExtInterfaceStream,
+ PrintStream java11InterfaceStream,
+ PrintStream java11ExtInterfaceStream,
+ PrintStream java11ExtPackInterfaceStream,
+ PrintStream javaImplStream,
+ PrintStream cStream,
+ boolean useContextPointer) {
+ mClassPathName = classPathName;
+ mChecker = checker;
+ mJava10InterfaceStream = java10InterfaceStream;
+ mJava10ExtInterfaceStream = java10ExtInterfaceStream;
+ mJava11InterfaceStream = java11InterfaceStream;
+ mJava11ExtInterfaceStream = java11ExtInterfaceStream;
+ mJava11ExtPackInterfaceStream = java11ExtPackInterfaceStream;
+ mJavaImplStream = javaImplStream;
+ mCStream = cStream;
+ mUseContextPointer = useContextPointer;
+ }
+
+ public void setVersion(int version, boolean ext, boolean pack) {
+ if (version == 0) {
+ mJavaInterfaceStream = ext ? mJava10ExtInterfaceStream :
+ mJava10InterfaceStream;
+ } else if (version == 1) {
+ mJavaInterfaceStream = ext ?
+ (pack ? mJava11ExtPackInterfaceStream :
+ mJava11ExtInterfaceStream) :
+ mJava11InterfaceStream;
+ } else {
+ throw new RuntimeException("Bad version: " + version);
+ }
+ }
+
+ public void emitCode(CFunc cfunc, String original) {
+ JFunc jfunc;
+ String signature;
+ boolean duplicate;
+
+ if (cfunc.hasTypedPointerArg()) {
+ jfunc = JFunc.convert(cfunc, true);
+
+ // Don't emit duplicate functions
+ // These may appear because they are defined in multiple
+ // Java interfaces (e.g., GL11/GL11ExtensionPack)
+ signature = jfunc.toString();
+ duplicate = false;
+ if (mFunctionsEmitted.contains(signature)) {
+ duplicate = true;
+ } else {
+ mFunctionsEmitted.add(signature);
+ }
+
+ if (!duplicate) {
+ emitNativeDeclaration(jfunc, mJavaImplStream);
+ emitJavaCode(jfunc, mJavaImplStream);
+ }
+ emitJavaInterfaceCode(jfunc, mJavaInterfaceStream);
+ if (!duplicate) {
+ emitJniCode(jfunc, mCStream);
+ }
+ }
+
+ jfunc = JFunc.convert(cfunc, false);
+
+ signature = jfunc.toString();
+ duplicate = false;
+ if (mFunctionsEmitted.contains(signature)) {
+ duplicate = true;
+ } else {
+ mFunctionsEmitted.add(signature);
+ }
+
+ if (!duplicate) {
+ emitNativeDeclaration(jfunc, mJavaImplStream);
+ }
+ emitJavaInterfaceCode(jfunc, mJavaInterfaceStream);
+ if (!duplicate) {
+ emitJavaCode(jfunc, mJavaImplStream);
+ emitJniCode(jfunc, mCStream);
+ }
+ }
+
+ public void emitNativeDeclaration(JFunc jfunc, PrintStream out) {
+ out.println(" // C function " + jfunc.getCFunc().getOriginal());
+ out.println();
+
+ emitFunction(jfunc, out, true, false);
+ }
+
+ public void emitJavaInterfaceCode(JFunc jfunc, PrintStream out) {
+ emitFunction(jfunc, out, false, true);
+ }
+
+ public void emitJavaCode(JFunc jfunc, PrintStream out) {
+ emitFunction(jfunc, out, false, false);
+ }
+
+ void emitFunctionCall(JFunc jfunc, PrintStream out, String iii, boolean grabArray ) {
+ boolean isVoid = jfunc.getType().isVoid();
+ boolean isPointerFunc = jfunc.getName().endsWith("Pointer") &&
+ jfunc.getCFunc().hasPointerArg();
+
+ if (!isVoid) {
+ out.println(iii +
+ jfunc.getType() + " _returnValue;");
+ }
+ out.println(iii +
+ (isVoid ? "" : "_returnValue = ") +
+ jfunc.getName() +
+ (isPointerFunc ? "Bounds" : "" ) +
+ "(");
+
+ int numArgs = jfunc.getNumArgs();
+ for (int i = 0; i < numArgs; i++) {
+ String argName = jfunc.getArgName(i);
+ JType argType = jfunc.getArgType(i);
+
+ if (grabArray && argType.isTypedBuffer()) {
+ String typeName = argType.getBaseType();
+ typeName = typeName.substring(9, typeName.length() - 6);
+ out.println(iii + indent + "get" + typeName + "Array(" + argName + "),");
+ out.print(iii + indent + "getOffset(" + argName + ")");
+ } else {
+ out.print(iii + indent + argName);
+ }
+ if (i == numArgs - 1) {
+ if (isPointerFunc) {
+ out.println(",");
+ out.println(iii + indent + argName + ".remaining()");
+ } else {
+ out.println();
+ }
+ } else {
+ out.println(",");
+ }
+ }
+
+ out.println(iii + ");");
+ }
+
+ void printIfcheckPostamble(PrintStream out, boolean isBuffer,
+ boolean emitExceptionCheck, String iii) {
+ printIfcheckPostamble(out, isBuffer, emitExceptionCheck,
+ "offset", "_remaining", iii);
+ }
+
+ void printIfcheckPostamble(PrintStream out, boolean isBuffer,
+ boolean emitExceptionCheck,
+ String offset, String remaining, String iii) {
+ out.println(iii + " default:");
+ out.println(iii + " _needed = 0;");
+ out.println(iii + " break;");
+ out.println(iii + "}");
+
+ out.println(iii + "if (" + remaining + " < _needed) {");
+ if (emitExceptionCheck) {
+ out.println(iii + indent + "_exception = 1;");
+ }
+ out.println(iii + indent +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->ThrowNew(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ "IAEClass, " +
+ "\"" +
+ (isBuffer ?
+ "remaining()" : "length - " + offset) +
+ " < needed\");");
+ out.println(iii + indent + "goto exit;");
+ needsExit = true;
+ out.println(iii + "}");
+ }
+
+ boolean isNullAllowed(CFunc cfunc) {
+ String[] checks = mChecker.getChecks(cfunc.getName());
+ int index = 1;
+ if (checks != null) {
+ while (index < checks.length) {
+ if (checks[index].equals("return")) {
+ index += 2;
+ } else if (checks[index].startsWith("check")) {
+ index += 3;
+ } else if (checks[index].equals("ifcheck")) {
+ index += 5;
+ } else if (checks[index].equals("unsupported")) {
+ index += 1;
+ } else if (checks[index].equals("nullAllowed")) {
+ return true;
+ } else {
+ System.out.println("Error: unknown keyword \"" +
+ checks[index] + "\"");
+ System.exit(0);
+ }
+ }
+ }
+ return false;
+ }
+
+ String getErrorReturnValue(CFunc cfunc) {
+ CType returnType = cfunc.getType();
+ boolean isVoid = returnType.isVoid();
+ if (isVoid) {
+ return null;
+ }
+
+ String[] checks = mChecker.getChecks(cfunc.getName());
+
+ int index = 1;
+ if (checks != null) {
+ while (index < checks.length) {
+ if (checks[index].equals("return")) {
+ return checks[index + 1];
+ } else if (checks[index].startsWith("check")) {
+ index += 3;
+ } else if (checks[index].equals("ifcheck")) {
+ index += 5;
+ } else if (checks[index].equals("unsupported")) {
+ index += 1;
+ } else if (checks[index].equals("nullAllowed")) {
+ index += 1;
+ } else {
+ System.out.println("Error: unknown keyword \"" +
+ checks[index] + "\"");
+ System.exit(0);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ boolean isUnsupportedFunc(CFunc cfunc) {
+ String[] checks = mChecker.getChecks(cfunc.getName());
+ int index = 1;
+ if (checks != null) {
+ while (index < checks.length) {
+ if (checks[index].equals("unsupported")) {
+ return true;
+ } else if (checks[index].equals("return")) {
+ index += 2;
+ } else if (checks[index].startsWith("check")) {
+ index += 3;
+ } else if (checks[index].equals("ifcheck")) {
+ index += 5;
+ } else if (checks[index].equals("nullAllowed")) {
+ index += 1;
+ } else {
+ System.out.println("Error: unknown keyword \"" +
+ checks[index] + "\"");
+ System.exit(0);
+ }
+ }
+ }
+ return false;
+ }
+
+ void emitNativeBoundsChecks(CFunc cfunc, String cname, PrintStream out,
+ boolean isBuffer, boolean emitExceptionCheck,
+ String offset, String remaining, String iii) {
+ CType returnType = cfunc.getType();
+ boolean isVoid = returnType.isVoid();
+
+ String[] checks = mChecker.getChecks(cfunc.getName());
+ String checkVar;
+ String retval = getErrorReturnValue(cfunc);
+
+ boolean lastWasIfcheck = false;
+
+ int index = 1;
+ if (checks != null) {
+ boolean remainingDeclared = false;
+ boolean nullCheckDeclared = false;
+ boolean offsetChecked = false;
+ while (index < checks.length) {
+ if (checks[index].startsWith("check")) {
+ if (lastWasIfcheck) {
+ printIfcheckPostamble(out, isBuffer, emitExceptionCheck,
+ offset, remaining, iii);
+ }
+ lastWasIfcheck = false;
+ if (cname != null && !cname.equals(checks[index + 1])) {
+ index += 3;
+ continue;
+ }
+ out.println(iii + "if (" + remaining + " < " +
+ checks[index + 2] +
+ ") {");
+ if (emitExceptionCheck) {
+ out.println(iii + indent + "_exception = 1;");
+ }
+ String exceptionClassName = "IAEClass";
+ // If the "check" keyword was of the form
+ // "check_<class name>", use the class name in the
+ // exception to be thrown
+ int underscore = checks[index].indexOf('_');
+ if (underscore >= 0) {
+ exceptionClassName = checks[index].substring(underscore + 1) + "Class";
+ }
+ out.println(iii + indent +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->ThrowNew(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ exceptionClassName + ", " +
+ "\"" +
+ (isBuffer ?
+ "remaining()" : "length - " + offset) +
+ " < " + checks[index + 2] +
+ "\");");
+
+ out.println(iii + indent + "goto exit;");
+ needsExit = true;
+ out.println(iii + "}");
+
+ index += 3;
+ } else if (checks[index].equals("ifcheck")) {
+ String[] matches = checks[index + 4].split(",");
+
+ if (!lastWasIfcheck) {
+ out.println(iii + "int _needed;");
+ out.println(iii +
+ "switch (" +
+ checks[index + 3] +
+ ") {");
+ }
+
+ for (int i = 0; i < matches.length; i++) {
+ out.println("#if defined(" + matches[i] + ")");
+ out.println(iii +
+ " case " +
+ matches[i] +
+ ":");
+ out.println("#endif // defined(" + matches[i] + ")");
+ }
+ out.println(iii +
+ " _needed = " +
+ checks[index + 2] +
+ ";");
+ out.println(iii +
+ " break;");
+
+ lastWasIfcheck = true;
+ index += 5;
+ } else if (checks[index].equals("return")) {
+ // ignore
+ index += 2;
+ } else if (checks[index].equals("unsupported")) {
+ // ignore
+ index += 1;
+ } else if (checks[index].equals("nullAllowed")) {
+ // ignore
+ index += 1;
+ } else {
+ System.out.println("Error: unknown keyword \"" +
+ checks[index] + "\"");
+ System.exit(0);
+ }
+ }
+ }
+
+ if (lastWasIfcheck) {
+ printIfcheckPostamble(out, isBuffer, emitExceptionCheck, iii);
+ }
+ }
+
+ boolean hasNonConstArg(JFunc jfunc, CFunc cfunc,
+ List<Integer> nonPrimitiveArgs) {
+ if (nonPrimitiveArgs.size() > 0) {
+ for (int i = nonPrimitiveArgs.size() - 1; i >= 0; i--) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+ int cIndex = jfunc.getArgCIndex(idx);
+ if (jfunc.getArgType(idx).isArray()) {
+ if (!cfunc.getArgType(cIndex).isConst()) {
+ return true;
+ }
+ } else if (jfunc.getArgType(idx).isBuffer()) {
+ if (!cfunc.getArgType(cIndex).isConst()) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Emit a function in several variants:
+ *
+ * if nativeDecl: public native <returntype> func(args);
+ *
+ * if !nativeDecl:
+ * if interfaceDecl: public <returntype> func(args);
+ * if !interfaceDecl: public <returntype> func(args) { body }
+ */
+ void emitFunction(JFunc jfunc,
+ PrintStream out,
+ boolean nativeDecl, boolean interfaceDecl) {
+ boolean isPointerFunc =
+ jfunc.getName().endsWith("Pointer") &&
+ jfunc.getCFunc().hasPointerArg();
+
+ if (!nativeDecl && !interfaceDecl && !isPointerFunc) {
+ // If it's not a pointer function, we've already emitted it
+ // with nativeDecl == true
+ return;
+ }
+
+ if (isPointerFunc) {
+ out.println(indent +
+ (nativeDecl ? "private native " :
+ (interfaceDecl ? "" : "public ")) +
+ jfunc.getType() + " " +
+ jfunc.getName() +
+ (nativeDecl ? "Bounds" : "") +
+ "(");
+ } else {
+ out.println(indent +
+ (nativeDecl ? "public native " :
+ (interfaceDecl ? "" : "public ")) +
+ jfunc.getType() + " " +
+ jfunc.getName() +
+ "(");
+ }
+
+ int numArgs = jfunc.getNumArgs();
+ for (int i = 0; i < numArgs; i++) {
+ String argName = jfunc.getArgName(i);
+ JType argType = jfunc.getArgType(i);
+
+ out.print(indent + indent + argType + " " + argName);
+ if (i == numArgs - 1) {
+ if (isPointerFunc && nativeDecl) {
+ out.println(",");
+ out.println(indent + indent + "int remaining");
+ } else {
+ out.println();
+ }
+ } else {
+ out.println(",");
+ }
+ }
+
+ if (nativeDecl || interfaceDecl) {
+ out.println(indent + ");");
+ } else {
+ out.println(indent + ") {");
+
+ String iii = indent + indent;
+
+ String fname = jfunc.getName();
+ if (isPointerFunc) {
+ // TODO - deal with VBO variants
+ if (fname.equals("glColorPointer")) {
+ out.println(iii + "if ((size == 4) &&");
+ out.println(iii + " ((type == GL_FLOAT) ||");
+ out.println(iii + " (type == GL_UNSIGNED_BYTE) ||");
+ out.println(iii + " (type == GL_FIXED)) &&");
+ out.println(iii + " (stride >= 0)) {");
+ out.println(iii + indent + "_colorPointer = pointer;");
+ out.println(iii + "}");
+ } else if (fname.equals("glNormalPointer")) {
+ out.println(iii + "if (((type == GL_FLOAT) ||");
+ out.println(iii + " (type == GL_BYTE) ||");
+ out.println(iii + " (type == GL_SHORT) ||");
+ out.println(iii + " (type == GL_FIXED)) &&");
+ out.println(iii + " (stride >= 0)) {");
+ out.println(iii + indent + "_normalPointer = pointer;");
+ out.println(iii + "}");
+ } else if (fname.equals("glTexCoordPointer")) {
+ out.println(iii + "if (((size == 2) ||");
+ out.println(iii + " (size == 3) ||");
+ out.println(iii + " (size == 4)) &&");
+ out.println(iii + " ((type == GL_FLOAT) ||");
+ out.println(iii + " (type == GL_BYTE) ||");
+ out.println(iii + " (type == GL_SHORT) ||");
+ out.println(iii + " (type == GL_FIXED)) &&");
+ out.println(iii + " (stride >= 0)) {");
+ out.println(iii + indent + "_texCoordPointer = pointer;");
+ out.println(iii + "}");
+ } else if (fname.equals("glVertexPointer")) {
+ out.println(iii + "if (((size == 2) ||");
+ out.println(iii + " (size == 3) ||");
+ out.println(iii + " (size == 4)) &&");
+ out.println(iii + " ((type == GL_FLOAT) ||");
+ out.println(iii + " (type == GL_BYTE) ||");
+ out.println(iii + " (type == GL_SHORT) ||");
+ out.println(iii + " (type == GL_FIXED)) &&");
+ out.println(iii + " (stride >= 0)) {");
+ out.println(iii + indent + "_vertexPointer = pointer;");
+ out.println(iii + "}");
+ }
+ }
+
+ // emitBoundsChecks(jfunc, out, iii);
+ emitFunctionCall(jfunc, out, iii, false);
+
+ boolean isVoid = jfunc.getType().isVoid();
+
+ if (!isVoid) {
+ out.println(indent + indent + "return _returnValue;");
+ }
+ out.println(indent + "}");
+ }
+ out.println();
+ }
+
+ public static String getJniName(JType jType) {
+ String jniName = "";
+ if (jType.isClass()) {
+ return "L" + jType.getBaseType() + ";";
+ } else if (jType.isArray()) {
+ jniName = "[";
+ }
+
+ String baseType = jType.getBaseType();
+ if (baseType.equals("int")) {
+ jniName += "I";
+ } else if (baseType.equals("float")) {
+ jniName += "F";
+ } else if (baseType.equals("boolean")) {
+ jniName += "Z";
+ } else if (baseType.equals("short")) {
+ jniName += "S";
+ } else if (baseType.equals("long")) {
+ jniName += "L";
+ } else if (baseType.equals("byte")) {
+ jniName += "B";
+ }
+ return jniName;
+ }
+
+ String getJniType(JType jType) {
+ if (jType.isVoid()) {
+ return "void";
+ }
+
+ String baseType = jType.getBaseType();
+ if (jType.isPrimitive()) {
+ if (baseType.equals("String")) {
+ return "jstring";
+ } else {
+ return "j" + baseType;
+ }
+ } else if (jType.isArray()) {
+ return "j" + baseType + "Array";
+ } else {
+ return "jobject";
+ }
+ }
+
+ String getJniMangledName(String name) {
+ name = name.replaceAll("_", "_1");
+ name = name.replaceAll(";", "_2");
+ name = name.replaceAll("\\[", "_3");
+ return name;
+ }
+
+ public void emitJniCode(JFunc jfunc, PrintStream out) {
+ CFunc cfunc = jfunc.getCFunc();
+
+ // Emit comment identifying original C function
+ //
+ // Example:
+ //
+ // /* void glClipPlanef ( GLenum plane, const GLfloat *equation ) */
+ //
+ out.println("/* " + cfunc.getOriginal() + " */");
+
+ // Emit JNI signature (name)
+ //
+ // Example:
+ //
+ // void
+ // android_glClipPlanef__I_3FI
+ //
+
+ String outName = "android_" + jfunc.getName();
+ boolean isPointerFunc = outName.endsWith("Pointer") &&
+ jfunc.getCFunc().hasPointerArg();
+ boolean isVBOPointerFunc = (outName.endsWith("Pointer") ||
+ outName.endsWith("DrawElements")) &&
+ !jfunc.getCFunc().hasPointerArg();
+ if (isPointerFunc) {
+ outName += "Bounds";
+ }
+
+ out.print("static ");
+ out.println(getJniType(jfunc.getType()));
+ out.print(outName);
+
+ String rsignature = getJniName(jfunc.getType());
+
+ String signature = "";
+ int numArgs = jfunc.getNumArgs();
+ for (int i = 0; i < numArgs; i++) {
+ JType argType = jfunc.getArgType(i);
+ signature += getJniName(argType);
+ }
+ if (isPointerFunc) {
+ signature += "I";
+ }
+
+ // Append signature to function name
+ String sig = getJniMangledName(signature).replace('.', '_');
+ out.print("__" + sig);
+ outName += "__" + sig;
+
+ signature = signature.replace('.', '/');
+ rsignature = rsignature.replace('.', '/');
+
+ out.println();
+ if (rsignature.length() == 0) {
+ rsignature = "V";
+ }
+
+ String s = "{\"" +
+ jfunc.getName() +
+ (isPointerFunc ? "Bounds" : "") +
+ "\", \"(" + signature +")" +
+ rsignature +
+ "\", (void *) " +
+ outName +
+ " },";
+ nativeRegistrations.add(s);
+
+ List<Integer> nonPrimitiveArgs = new ArrayList<Integer>();
+ int numBufferArgs = 0;
+ List<String> bufferArgNames = new ArrayList<String>();
+
+ // Emit JNI signature (arguments)
+ //
+ // Example:
+ //
+ // (JNIEnv *_env, jobject this, jint plane, jfloatArray equation_ref, jint offset) {
+ //
+ out.print(" (JNIEnv *_env, jobject _this");
+ for (int i = 0; i < numArgs; i++) {
+ out.print(", ");
+ JType argType = jfunc.getArgType(i);
+ String suffix;
+ if (!argType.isPrimitive()) {
+ if (argType.isArray()) {
+ suffix = "_ref";
+ } else {
+ suffix = "_buf";
+ }
+ nonPrimitiveArgs.add(new Integer(i));
+ if (jfunc.getArgType(i).isBuffer()) {
+ int cIndex = jfunc.getArgCIndex(i);
+ String cname = cfunc.getArgName(cIndex);
+ bufferArgNames.add(cname);
+ numBufferArgs++;
+ }
+ } else {
+ suffix = "";
+ }
+
+ out.print(getJniType(argType) + " " + jfunc.getArgName(i) + suffix);
+ }
+ if (isPointerFunc) {
+ out.print(", jint remaining");
+ }
+ out.println(") {");
+
+ int numArrays = 0;
+ int numBuffers = 0;
+ for (int i = 0; i < nonPrimitiveArgs.size(); i++) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+ int cIndex = jfunc.getArgCIndex(idx);
+ String cname = cfunc.getArgName(cIndex);
+ if (jfunc.getArgType(idx).isArray()) {
+ ++numArrays;
+ }
+ if (jfunc.getArgType(idx).isBuffer()) {
+ ++numBuffers;
+ }
+ }
+
+ // Emit method body
+
+ // Emit local variable declarations for _exception and _returnValue
+ //
+ // Example:
+ //
+ // android::gl::ogles_context_t *ctx;
+ //
+ // jint _exception;
+ // GLenum _returnValue;
+ //
+ CType returnType = cfunc.getType();
+ boolean isVoid = returnType.isVoid();
+
+ boolean isUnsupported = isUnsupportedFunc(cfunc);
+ if (isUnsupported) {
+ out.println(indent +
+ "_env->ThrowNew(UOEClass,");
+ out.println(indent +
+ " \"" + cfunc.getName() + "\");");
+ if (!isVoid) {
+ String retval = getErrorReturnValue(cfunc);
+ out.println(indent + "return " + retval + ";");
+ }
+ out.println("}");
+ out.println();
+ return;
+ }
+
+ if (mUseContextPointer) {
+ out.println(indent +
+ "android::gl::ogles_context_t *ctx = getContext(_env, _this);");
+ }
+
+ boolean emitExceptionCheck = (numArrays > 0 || numBuffers > 0) &&
+ hasNonConstArg(jfunc, cfunc, nonPrimitiveArgs);
+ // mChecker.getChecks(cfunc.getName()) != null
+
+ // Emit an _exeption variable if there will be error checks
+ if (emitExceptionCheck) {
+ out.println(indent + "jint _exception = 0;");
+ }
+
+ // Emit a single _array or multiple _XXXArray variables
+ if (numBufferArgs == 1) {
+ out.println(indent + "jarray _array = (jarray) 0;");
+ } else {
+ for (int i = 0; i < numBufferArgs; i++) {
+ out.println(indent + "jarray _" + bufferArgNames.get(i) +
+ "Array = (jarray) 0;");
+ }
+ }
+ if (!isVoid) {
+ String retval = getErrorReturnValue(cfunc);
+ if (retval != null) {
+ out.println(indent + returnType.getDeclaration() +
+ " _returnValue = " + retval + ";");
+ } else {
+ out.println(indent + returnType.getDeclaration() +
+ " _returnValue;");
+ }
+ }
+
+ // Emit local variable declarations for pointer arguments
+ //
+ // Example:
+ //
+ // GLfixed *eqn_base;
+ // GLfixed *eqn;
+ //
+ String offset = "offset";
+ String remaining = "_remaining";
+ if (nonPrimitiveArgs.size() > 0) {
+ for (int i = 0; i < nonPrimitiveArgs.size(); i++) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+ int cIndex = jfunc.getArgCIndex(idx);
+ String cname = cfunc.getArgName(cIndex);
+
+ CType type = cfunc.getArgType(jfunc.getArgCIndex(idx));
+ String decl = type.getDeclaration();
+ if (jfunc.getArgType(idx).isArray()) {
+ out.println(indent +
+ decl +
+ (decl.endsWith("*") ? "" : " ") +
+ jfunc.getArgName(idx) +
+ "_base = (" + decl + ") 0;");
+ }
+ remaining = (numArrays <= 1 && numBuffers <= 1) ? "_remaining" :
+ "_" + cname + "Remaining";
+ out.println(indent +
+ "jint " + remaining + ";");
+ out.println(indent +
+ decl +
+ (decl.endsWith("*") ? "" : " ") +
+ jfunc.getArgName(idx) +
+ " = (" + decl + ") 0;");
+ }
+
+ out.println();
+ }
+
+ String retval = isVoid ? "" : " _returnValue";
+
+ // Emit 'GetPrimitiveArrayCritical' for arrays
+ // Emit 'GetPointer' calls for Buffer pointers
+ int bufArgIdx = 0;
+ if (nonPrimitiveArgs.size() > 0) {
+ for (int i = 0; i < nonPrimitiveArgs.size(); i++) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+ int cIndex = jfunc.getArgCIndex(idx);
+
+ String cname = cfunc.getArgName(cIndex);
+ offset = numArrays <= 1 ? "offset" :
+ cname + "Offset";
+ remaining = (numArrays <= 1 && numBuffers <= 1) ? "_remaining" :
+ "_" + cname + "Remaining";
+
+ if (jfunc.getArgType(idx).isArray()) {
+ out.println(indent +
+ "if (!" +
+ cname +
+ "_ref) {");
+ if (emitExceptionCheck) {
+ out.println(indent + indent + "_exception = 1;");
+ }
+ out.println(indent + " " +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->ThrowNew(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ "IAEClass, " +
+ "\"" + cname +
+ " == null\");");
+ out.println(indent + " goto exit;");
+ needsExit = true;
+ out.println(indent + "}");
+
+ out.println(indent + "if (" + offset + " < 0) {");
+ if (emitExceptionCheck) {
+ out.println(indent + indent + "_exception = 1;");
+ }
+ out.println(indent + " " +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->ThrowNew(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ "IAEClass, " +
+ "\"" + offset + " < 0\");");
+ out.println(indent + " goto exit;");
+ needsExit = true;
+ out.println(indent + "}");
+
+ out.println(indent + remaining + " = " +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->GetArrayLength(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ cname + "_ref) - " + offset + ";");
+
+ emitNativeBoundsChecks(cfunc, cname, out, false,
+ emitExceptionCheck,
+ offset, remaining, " ");
+
+ out.println(indent +
+ cname +
+ "_base = (" +
+ cfunc.getArgType(cIndex).getDeclaration() +
+ ")");
+ out.println(indent + " " +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->GetPrimitiveArrayCritical(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ jfunc.getArgName(idx) +
+ "_ref, (jboolean *)0);");
+ out.println(indent +
+ cname + " = " + cname + "_base + " + offset +
+ ";");
+ out.println();
+ } else {
+ String array = numBufferArgs <= 1 ? "_array" :
+ "_" + bufferArgNames.get(bufArgIdx++) + "Array";
+
+ boolean nullAllowed = isNullAllowed(cfunc);
+ if (nullAllowed) {
+ out.println(indent + "if (" + cname + "_buf) {");
+ out.print(indent);
+ }
+
+ out.println(indent +
+ cname +
+ " = (" +
+ cfunc.getArgType(cIndex).getDeclaration() +
+ ")getPointer(_env, " +
+ cname +
+ "_buf, &" + array + ", &" + remaining + ");");
+
+ if (nullAllowed) {
+ out.println(indent + "}");
+ }
+
+ emitNativeBoundsChecks(cfunc, cname, out, true,
+ emitExceptionCheck,
+ offset, remaining, " ");
+ }
+ }
+ }
+
+ if (!isVoid) {
+ out.print(indent + "_returnValue = ");
+ } else {
+ out.print(indent);
+ }
+ String name = cfunc.getName();
+
+ if (mUseContextPointer) {
+ name = name.substring(2, name.length()); // Strip off 'gl' prefix
+ name = name.substring(0, 1).toLowerCase() +
+ name.substring(1, name.length());
+ out.print("ctx->procs.");
+ }
+
+ out.print(name + (isPointerFunc ? "Bounds" : "") + "(");
+
+ numArgs = cfunc.getNumArgs();
+ if (numArgs == 0) {
+ if (mUseContextPointer) {
+ out.println("ctx);");
+ } else {
+ out.println(");");
+ }
+ } else {
+ if (mUseContextPointer) {
+ out.println("ctx,");
+ } else {
+ out.println();
+ }
+ for (int i = 0; i < numArgs; i++) {
+ String typecast;
+ if (i == numArgs - 1 && isVBOPointerFunc) {
+ typecast = "const GLvoid *";
+ } else {
+ typecast = cfunc.getArgType(i).getDeclaration();
+ }
+ out.print(indent + indent +
+ "(" +
+ typecast +
+ ")" +
+ cfunc.getArgName(i));
+
+ if (i == numArgs - 1) {
+ if (isPointerFunc) {
+ out.println(",");
+ out.println(indent + indent + "(GLsizei)remaining");
+ } else {
+ out.println();
+ }
+ } else {
+ out.println(",");
+ }
+ }
+ out.println(indent + ");");
+ }
+
+ if (needsExit) {
+ out.println();
+ out.println("exit:");
+ needsExit = false;
+ }
+
+ bufArgIdx = 0;
+ if (nonPrimitiveArgs.size() > 0) {
+ for (int i = nonPrimitiveArgs.size() - 1; i >= 0; i--) {
+ int idx = nonPrimitiveArgs.get(i).intValue();
+
+ int cIndex = jfunc.getArgCIndex(idx);
+ if (jfunc.getArgType(idx).isArray()) {
+
+ // If the argument is 'const', GL will not write to it.
+ // In this case, we can use the 'JNI_ABORT' flag to avoid
+ // the need to write back to the Java array
+ out.println(indent +
+ "if (" + jfunc.getArgName(idx) + "_base) {");
+ out.println(indent + indent +
+ (mUseCPlusPlus ? "_env" : "(*_env)") +
+ "->ReleasePrimitiveArrayCritical(" +
+ (mUseCPlusPlus ? "" : "_env, ") +
+ jfunc.getArgName(idx) + "_ref, " +
+ cfunc.getArgName(cIndex) +
+ "_base,");
+ out.println(indent + indent + indent +
+ (cfunc.getArgType(cIndex).isConst() ?
+ "JNI_ABORT" :
+ "_exception ? JNI_ABORT: 0") +
+ ");");
+ out.println(indent + "}");
+ } else if (jfunc.getArgType(idx).isBuffer()) {
+ String array = numBufferArgs <= 1 ? "_array" :
+ "_" + bufferArgNames.get(bufArgIdx++) + "Array";
+ out.println(indent + "if (" + array + ") {");
+ out.println(indent + indent +
+ "releasePointer(_env, " + array + ", " +
+ cfunc.getArgName(cIndex) +
+ ", " +
+ (cfunc.getArgType(cIndex).isConst() ?
+ "JNI_FALSE" : "_exception ? JNI_FALSE : JNI_TRUE") +
+ ");");
+ out.println(indent + "}");
+ }
+ }
+ }
+
+ if (!isVoid) {
+ out.println(indent + "return _returnValue;");
+ }
+
+ out.println("}");
+ out.println();
+ }
+
+ public void addNativeRegistration(String s) {
+ nativeRegistrations.add(s);
+ }
+
+ public void emitNativeRegistration() {
+ mCStream.println("static const char *classPathName = \"" +
+ mClassPathName +
+ "\";");
+ mCStream.println();
+
+ mCStream.println("static JNINativeMethod methods[] = {");
+
+ mCStream.println("{\"_nativeClassInit\", \"()V\", (void*)nativeClassInit },");
+
+ Iterator<String> i = nativeRegistrations.iterator();
+ while (i.hasNext()) {
+ mCStream.println(i.next());
+ }
+
+ mCStream.println("};");
+ mCStream.println();
+
+
+ mCStream.println("int register_com_google_android_gles_jni_GLImpl(JNIEnv *_env)");
+ mCStream.println("{");
+ mCStream.println(indent +
+ "int err;");
+
+ mCStream.println(indent +
+ "err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));");
+
+ mCStream.println(indent + "return err;");
+ mCStream.println("}");
+ }
+}
diff --git a/opengl/tools/glgen/src/ParameterChecker.java b/opengl/tools/glgen/src/ParameterChecker.java
new file mode 100644
index 0000000..df26acd
--- /dev/null
+++ b/opengl/tools/glgen/src/ParameterChecker.java
@@ -0,0 +1,28 @@
+
+import java.io.BufferedReader;
+import java.util.HashMap;
+
+public class ParameterChecker {
+
+ HashMap<String,String[]> map = new HashMap<String,String[]>();
+
+ public ParameterChecker(BufferedReader reader) throws Exception {
+ String s;
+ while ((s = reader.readLine()) != null) {
+ String[] tokens = s.split("\\s");
+ map.put(tokens[0], tokens);
+ }
+ }
+
+ public String[] getChecks(String functionName) {
+ String[] checks = map.get(functionName);
+ if (checks == null &&
+ (functionName.endsWith("fv") ||
+ functionName.endsWith("xv") ||
+ functionName.endsWith("iv"))) {
+ functionName = functionName.substring(0, functionName.length() - 2);
+ checks = map.get(functionName);
+ }
+ return checks;
+ }
+}
diff --git a/opengl/tools/glgen/stubs/GL10ExtHeader.java-if b/opengl/tools/glgen/stubs/GL10ExtHeader.java-if
new file mode 100644
index 0000000..b0999c2
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GL10ExtHeader.java-if
@@ -0,0 +1,22 @@
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+// This source file is automatically generated
+
+package javax.microedition.khronos.opengles;
+
+public interface GL10Ext extends GL {
+
diff --git a/opengl/tools/glgen/stubs/GL10Header.java-if b/opengl/tools/glgen/stubs/GL10Header.java-if
new file mode 100644
index 0000000..8392821
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GL10Header.java-if
@@ -0,0 +1,259 @@
+**
+** Copyright 2006, 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.
+*/
+
+// This source file is automatically generated
+
+package javax.microedition.khronos.opengles;
+
+public interface GL10 extends GL {
+ int GL_ADD = 0x0104;
+ int GL_ALIASED_LINE_WIDTH_RANGE = 0x846E;
+ int GL_ALIASED_POINT_SIZE_RANGE = 0x846D;
+ int GL_ALPHA = 0x1906;
+ int GL_ALPHA_BITS = 0x0D55;
+ int GL_ALPHA_TEST = 0x0BC0;
+ int GL_ALWAYS = 0x0207;
+ int GL_AMBIENT = 0x1200;
+ int GL_AMBIENT_AND_DIFFUSE = 0x1602;
+ int GL_AND = 0x1501;
+ int GL_AND_INVERTED = 0x1504;
+ int GL_AND_REVERSE = 0x1502;
+ int GL_BACK = 0x0405;
+ int GL_BLEND = 0x0BE2;
+ int GL_BLUE_BITS = 0x0D54;
+ int GL_BYTE = 0x1400;
+ int GL_CCW = 0x0901;
+ int GL_CLAMP_TO_EDGE = 0x812F;
+ int GL_CLEAR = 0x1500;
+ int GL_COLOR_ARRAY = 0x8076;
+ int GL_COLOR_BUFFER_BIT = 0x4000;
+ int GL_COLOR_LOGIC_OP = 0x0BF2;
+ int GL_COLOR_MATERIAL = 0x0B57;
+ int GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;
+ int GL_CONSTANT_ATTENUATION = 0x1207;
+ int GL_COPY = 0x1503;
+ int GL_COPY_INVERTED = 0x150C;
+ int GL_CULL_FACE = 0x0B44;
+ int GL_CW = 0x0900;
+ int GL_DECAL = 0x2101;
+ int GL_DECR = 0x1E03;
+ int GL_DEPTH_BITS = 0x0D56;
+ int GL_DEPTH_BUFFER_BIT = 0x0100;
+ int GL_DEPTH_TEST = 0x0B71;
+ int GL_DIFFUSE = 0x1201;
+ int GL_DITHER = 0x0BD0;
+ int GL_DONT_CARE = 0x1100;
+ int GL_DST_ALPHA = 0x0304;
+ int GL_DST_COLOR = 0x0306;
+ int GL_EMISSION = 0x1600;
+ int GL_EQUAL = 0x0202;
+ int GL_EQUIV = 0x1509;
+ int GL_EXP = 0x0800;
+ int GL_EXP2 = 0x0801;
+ int GL_EXTENSIONS = 0x1F03;
+ int GL_FALSE = 0;
+ int GL_FASTEST = 0x1101;
+ int GL_FIXED = 0x140C;
+ int GL_FLAT = 0x1D00;
+ int GL_FLOAT = 0x1406;
+ int GL_FOG = 0x0B60;
+ int GL_FOG_COLOR = 0x0B66;
+ int GL_FOG_DENSITY = 0x0B62;
+ int GL_FOG_END = 0x0B64;
+ int GL_FOG_HINT = 0x0C54;
+ int GL_FOG_MODE = 0x0B65;
+ int GL_FOG_START = 0x0B63;
+ int GL_FRONT = 0x0404;
+ int GL_FRONT_AND_BACK = 0x0408;
+ int GL_GEQUAL = 0x0206;
+ int GL_GREATER = 0x0204;
+ int GL_GREEN_BITS = 0x0D53;
+ int GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES = 0x8B9B;
+ int GL_IMPLEMENTATION_COLOR_READ_TYPE_OES = 0x8B9A;
+ int GL_INCR = 0x1E02;
+ int GL_INVALID_ENUM = 0x0500;
+ int GL_INVALID_OPERATION = 0x0502;
+ int GL_INVALID_VALUE = 0x0501;
+ int GL_INVERT = 0x150A;
+ int GL_KEEP = 0x1E00;
+ int GL_LEQUAL = 0x0203;
+ int GL_LESS = 0x0201;
+ int GL_LIGHT_MODEL_AMBIENT = 0x0B53;
+ int GL_LIGHT_MODEL_TWO_SIDE = 0x0B52;
+ int GL_LIGHT0 = 0x4000;
+ int GL_LIGHT1 = 0x4001;
+ int GL_LIGHT2 = 0x4002;
+ int GL_LIGHT3 = 0x4003;
+ int GL_LIGHT4 = 0x4004;
+ int GL_LIGHT5 = 0x4005;
+ int GL_LIGHT6 = 0x4006;
+ int GL_LIGHT7 = 0x4007;
+ int GL_LIGHTING = 0x0B50;
+ int GL_LINE_LOOP = 0x0002;
+ int GL_LINE_SMOOTH = 0x0B20;
+ int GL_LINE_SMOOTH_HINT = 0x0C52;
+ int GL_LINE_STRIP = 0x0003;
+ int GL_LINEAR = 0x2601;
+ int GL_LINEAR_ATTENUATION = 0x1208;
+ int GL_LINEAR_MIPMAP_LINEAR = 0x2703;
+ int GL_LINEAR_MIPMAP_NEAREST = 0x2701;
+ int GL_LINES = 0x0001;
+ int GL_LUMINANCE = 0x1909;
+ int GL_LUMINANCE_ALPHA = 0x190A;
+ int GL_MAX_ELEMENTS_INDICES = 0x80E9;
+ int GL_MAX_ELEMENTS_VERTICES = 0x80E8;
+ int GL_MAX_LIGHTS = 0x0D31;
+ int GL_MAX_MODELVIEW_STACK_DEPTH = 0x0D36;
+ int GL_MAX_PROJECTION_STACK_DEPTH = 0x0D38;
+ int GL_MAX_TEXTURE_SIZE = 0x0D33;
+ int GL_MAX_TEXTURE_STACK_DEPTH = 0x0D39;
+ int GL_MAX_TEXTURE_UNITS = 0x84E2;
+ int GL_MAX_VIEWPORT_DIMS = 0x0D3A;
+ int GL_MODELVIEW = 0x1700;
+ int GL_MODULATE = 0x2100;
+ int GL_MULTISAMPLE = 0x809D;
+ int GL_NAND = 0x150E;
+ int GL_NEAREST = 0x2600;
+ int GL_NEAREST_MIPMAP_LINEAR = 0x2702;
+ int GL_NEAREST_MIPMAP_NEAREST = 0x2700;
+ int GL_NEVER = 0x0200;
+ int GL_NICEST = 0x1102;
+ int GL_NO_ERROR = 0;
+ int GL_NOOP = 0x1505;
+ int GL_NOR = 0x1508;
+ int GL_NORMAL_ARRAY = 0x8075;
+ int GL_NORMALIZE = 0x0BA1;
+ int GL_NOTEQUAL = 0x0205;
+ int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
+ int GL_ONE = 1;
+ int GL_ONE_MINUS_DST_ALPHA = 0x0305;
+ int GL_ONE_MINUS_DST_COLOR = 0x0307;
+ int GL_ONE_MINUS_SRC_ALPHA = 0x0303;
+ int GL_ONE_MINUS_SRC_COLOR = 0x0301;
+ int GL_OR = 0x1507;
+ int GL_OR_INVERTED = 0x150D;
+ int GL_OR_REVERSE = 0x150B;
+ int GL_OUT_OF_MEMORY = 0x0505;
+ int GL_PACK_ALIGNMENT = 0x0D05;
+ int GL_PALETTE4_R5_G6_B5_OES = 0x8B92;
+ int GL_PALETTE4_RGB5_A1_OES = 0x8B94;
+ int GL_PALETTE4_RGB8_OES = 0x8B90;
+ int GL_PALETTE4_RGBA4_OES = 0x8B93;
+ int GL_PALETTE4_RGBA8_OES = 0x8B91;
+ int GL_PALETTE8_R5_G6_B5_OES = 0x8B97;
+ int GL_PALETTE8_RGB5_A1_OES = 0x8B99;
+ int GL_PALETTE8_RGB8_OES = 0x8B95;
+ int GL_PALETTE8_RGBA4_OES = 0x8B98;
+ int GL_PALETTE8_RGBA8_OES = 0x8B96;
+ int GL_PERSPECTIVE_CORRECTION_HINT = 0x0C50;
+ int GL_POINT_SMOOTH = 0x0B10;
+ int GL_POINT_SMOOTH_HINT = 0x0C51;
+ int GL_POINTS = 0x0000;
+ int GL_POINT_FADE_THRESHOLD_SIZE = 0x8128;
+ int GL_POINT_SIZE = 0x0B11;
+ int GL_POLYGON_OFFSET_FILL = 0x8037;
+ int GL_POLYGON_SMOOTH_HINT = 0x0C53;
+ int GL_POSITION = 0x1203;
+ int GL_PROJECTION = 0x1701;
+ int GL_QUADRATIC_ATTENUATION = 0x1209;
+ int GL_RED_BITS = 0x0D52;
+ int GL_RENDERER = 0x1F01;
+ int GL_REPEAT = 0x2901;
+ int GL_REPLACE = 0x1E01;
+ int GL_RESCALE_NORMAL = 0x803A;
+ int GL_RGB = 0x1907;
+ int GL_RGBA = 0x1908;
+ int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
+ int GL_SAMPLE_ALPHA_TO_ONE = 0x809F;
+ int GL_SAMPLE_COVERAGE = 0x80A0;
+ int GL_SCISSOR_TEST = 0x0C11;
+ int GL_SET = 0x150F;
+ int GL_SHININESS = 0x1601;
+ int GL_SHORT = 0x1402;
+ int GL_SMOOTH = 0x1D01;
+ int GL_SMOOTH_LINE_WIDTH_RANGE = 0x0B22;
+ int GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12;
+ int GL_SPECULAR = 0x1202;
+ int GL_SPOT_CUTOFF = 0x1206;
+ int GL_SPOT_DIRECTION = 0x1204;
+ int GL_SPOT_EXPONENT = 0x1205;
+ int GL_SRC_ALPHA = 0x0302;
+ int GL_SRC_ALPHA_SATURATE = 0x0308;
+ int GL_SRC_COLOR = 0x0300;
+ int GL_STACK_OVERFLOW = 0x0503;
+ int GL_STACK_UNDERFLOW = 0x0504;
+ int GL_STENCIL_BITS = 0x0D57;
+ int GL_STENCIL_BUFFER_BIT = 0x0400;
+ int GL_STENCIL_TEST = 0x0B90;
+ int GL_SUBPIXEL_BITS = 0x0D50;
+ int GL_TEXTURE = 0x1702;
+ int GL_TEXTURE_2D = 0x0DE1;
+ int GL_TEXTURE_COORD_ARRAY = 0x8078;
+ int GL_TEXTURE_ENV = 0x2300;
+ int GL_TEXTURE_ENV_COLOR = 0x2201;
+ int GL_TEXTURE_ENV_MODE = 0x2200;
+ int GL_TEXTURE_MAG_FILTER = 0x2800;
+ int GL_TEXTURE_MIN_FILTER = 0x2801;
+ int GL_TEXTURE_WRAP_S = 0x2802;
+ int GL_TEXTURE_WRAP_T = 0x2803;
+ int GL_TEXTURE0 = 0x84C0;
+ int GL_TEXTURE1 = 0x84C1;
+ int GL_TEXTURE2 = 0x84C2;
+ int GL_TEXTURE3 = 0x84C3;
+ int GL_TEXTURE4 = 0x84C4;
+ int GL_TEXTURE5 = 0x84C5;
+ int GL_TEXTURE6 = 0x84C6;
+ int GL_TEXTURE7 = 0x84C7;
+ int GL_TEXTURE8 = 0x84C8;
+ int GL_TEXTURE9 = 0x84C9;
+ int GL_TEXTURE10 = 0x84CA;
+ int GL_TEXTURE11 = 0x84CB;
+ int GL_TEXTURE12 = 0x84CC;
+ int GL_TEXTURE13 = 0x84CD;
+ int GL_TEXTURE14 = 0x84CE;
+ int GL_TEXTURE15 = 0x84CF;
+ int GL_TEXTURE16 = 0x84D0;
+ int GL_TEXTURE17 = 0x84D1;
+ int GL_TEXTURE18 = 0x84D2;
+ int GL_TEXTURE19 = 0x84D3;
+ int GL_TEXTURE20 = 0x84D4;
+ int GL_TEXTURE21 = 0x84D5;
+ int GL_TEXTURE22 = 0x84D6;
+ int GL_TEXTURE23 = 0x84D7;
+ int GL_TEXTURE24 = 0x84D8;
+ int GL_TEXTURE25 = 0x84D9;
+ int GL_TEXTURE26 = 0x84DA;
+ int GL_TEXTURE27 = 0x84DB;
+ int GL_TEXTURE28 = 0x84DC;
+ int GL_TEXTURE29 = 0x84DD;
+ int GL_TEXTURE30 = 0x84DE;
+ int GL_TEXTURE31 = 0x84DF;
+ int GL_TRIANGLE_FAN = 0x0006;
+ int GL_TRIANGLE_STRIP = 0x0005;
+ int GL_TRIANGLES = 0x0004;
+ int GL_TRUE = 1;
+ int GL_UNPACK_ALIGNMENT = 0x0CF5;
+ int GL_UNSIGNED_BYTE = 0x1401;
+ int GL_UNSIGNED_SHORT = 0x1403;
+ int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
+ int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
+ int GL_UNSIGNED_SHORT_5_6_5 = 0x8363;
+ int GL_VENDOR = 0x1F00;
+ int GL_VERSION = 0x1F02;
+ int GL_VERTEX_ARRAY = 0x8074;
+ int GL_XOR = 0x1506;
+ int GL_ZERO = 0;
+
diff --git a/opengl/tools/glgen/stubs/GL11ExtHeader.java-if b/opengl/tools/glgen/stubs/GL11ExtHeader.java-if
new file mode 100644
index 0000000..7be2164
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GL11ExtHeader.java-if
@@ -0,0 +1,40 @@
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+// This source file is automatically generated
+
+package javax.microedition.khronos.opengles;
+
+public interface GL11Ext extends GL {
+ int GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES = 0x8B9E;
+ int GL_MATRIX_INDEX_ARRAY_OES = 0x8844;
+ int GL_MATRIX_INDEX_ARRAY_POINTER_OES = 0x8849;
+ int GL_MATRIX_INDEX_ARRAY_SIZE_OES = 0x8846;
+ int GL_MATRIX_INDEX_ARRAY_STRIDE_OES = 0x8848;
+ int GL_MATRIX_INDEX_ARRAY_TYPE_OES = 0x8847;
+ int GL_MATRIX_PALETTE_OES = 0x8840;
+ int GL_MAX_PALETTE_MATRICES_OES = 0x8842;
+ int GL_MAX_VERTEX_UNITS_OES = 0x86A4;
+ int GL_TEXTURE_CROP_RECT_OES = 0x8B9D;
+ int GL_WEIGHT_ARRAY_BUFFER_BINDING_OES = 0x889E;
+ int GL_WEIGHT_ARRAY_OES = 0x86AD;
+ int GL_WEIGHT_ARRAY_POINTER_OES = 0x86AC;
+ int GL_WEIGHT_ARRAY_SIZE_OES = 0x86AB;
+ int GL_WEIGHT_ARRAY_STRIDE_OES = 0x86AA;
+ int GL_WEIGHT_ARRAY_TYPE_OES = 0x86A9;
+
+ void glTexParameterfv(int target, int pname, float[] param, int offset);
+
diff --git a/opengl/tools/glgen/stubs/GL11ExtensionPackHeader.java-if b/opengl/tools/glgen/stubs/GL11ExtensionPackHeader.java-if
new file mode 100644
index 0000000..a800191
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GL11ExtensionPackHeader.java-if
@@ -0,0 +1,108 @@
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+// This source file is automatically generated
+
+package javax.microedition.khronos.opengles;
+
+public interface GL11ExtensionPack extends GL {
+ int GL_BLEND_DST_ALPHA = 0x80CA;
+ int GL_BLEND_DST_RGB = 0x80C8;
+ int GL_BLEND_EQUATION = 0x8009;
+ int GL_BLEND_EQUATION_ALPHA = 0x883D;
+ int GL_BLEND_EQUATION_RGB = 0x8009;
+ int GL_BLEND_SRC_ALPHA = 0x80CB;
+ int GL_BLEND_SRC_RGB = 0x80C9;
+ int GL_COLOR_ATTACHMENT0_OES = 0x8CE0;
+ int GL_COLOR_ATTACHMENT1_OES = 0x8CE1;
+ int GL_COLOR_ATTACHMENT2_OES = 0x8CE2;
+ int GL_COLOR_ATTACHMENT3_OES = 0x8CE3;
+ int GL_COLOR_ATTACHMENT4_OES = 0x8CE4;
+ int GL_COLOR_ATTACHMENT5_OES = 0x8CE5;
+ int GL_COLOR_ATTACHMENT6_OES = 0x8CE6;
+ int GL_COLOR_ATTACHMENT7_OES = 0x8CE7;
+ int GL_COLOR_ATTACHMENT8_OES = 0x8CE8;
+ int GL_COLOR_ATTACHMENT9_OES = 0x8CE9;
+ int GL_COLOR_ATTACHMENT10_OES = 0x8CEA;
+ int GL_COLOR_ATTACHMENT11_OES = 0x8CEB;
+ int GL_COLOR_ATTACHMENT12_OES = 0x8CEC;
+ int GL_COLOR_ATTACHMENT13_OES = 0x8CED;
+ int GL_COLOR_ATTACHMENT14_OES = 0x8CEE;
+ int GL_COLOR_ATTACHMENT15_OES = 0x8CEF;
+ int GL_DECR_WRAP = 0x8508;
+ int GL_DEPTH_ATTACHMENT_OES = 0x8D00;
+ int GL_DEPTH_COMPONENT = 0x1902;
+ int GL_DEPTH_COMPONENT16 = 0x81A5;
+ int GL_DEPTH_COMPONENT24 = 0x81A6;
+ int GL_DEPTH_COMPONENT32 = 0x81A7;
+ int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES = 0x8CD1;
+ int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES = 0x8CD0;
+ int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES = 0x8CD3;
+ int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES = 0x8CD2;
+ int GL_FRAMEBUFFER_BINDING_OES = 0x8CA6;
+ int GL_FRAMEBUFFER_COMPLETE_OES = 0x8CD5;
+ int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES = 0x8CD6;
+ int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES = 0x8CD9;
+ int GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_OES = 0x8CDB;
+ int GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES = 0x8CDA;
+ int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES = 0x8CD7;
+ int GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_OES = 0x8CDC;
+ int GL_FRAMEBUFFER_OES = 0x8D40;
+ int GL_FRAMEBUFFER_UNSUPPORTED_OES = 0x8CDD;
+ int GL_FUNC_ADD = 0x8006;
+ int GL_FUNC_REVERSE_SUBTRACT = 0x800B;
+ int GL_FUNC_SUBTRACT = 0x800A;
+ int GL_INCR_WRAP = 0x8507;
+ int GL_INVALID_FRAMEBUFFER_OPERATION_OES = 0x0506;
+ int GL_MAX_COLOR_ATTACHMENTS_OES = 0x8CDF;
+ int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
+ int GL_MAX_RENDERBUFFER_SIZE_OES = 0x84E8;
+ int GL_MIRRORED_REPEAT = 0x8370;
+ int GL_NORMAL_MAP = 0x8511;
+ int GL_REFLECTION_MAP = 0x8512;
+ int GL_RENDERBUFFER_ALPHA_SIZE_OES = 0x8D53;
+ int GL_RENDERBUFFER_BINDING_OES = 0x8CA7;
+ int GL_RENDERBUFFER_BLUE_SIZE_OES = 0x8D52;
+ int GL_RENDERBUFFER_DEPTH_SIZE_OES = 0x8D54;
+ int GL_RENDERBUFFER_GREEN_SIZE_OES = 0x8D51;
+ int GL_RENDERBUFFER_HEIGHT_OES = 0x8D43;
+ int GL_RENDERBUFFER_INTERNAL_FORMAT_OES = 0x8D44;
+ int GL_RENDERBUFFER_OES = 0x8D41;
+ int GL_RENDERBUFFER_RED_SIZE_OES = 0x8D50;
+ int GL_RENDERBUFFER_STENCIL_SIZE_OES = 0x8D55;
+ int GL_RENDERBUFFER_WIDTH_OES = 0x8D42;
+ int GL_RGB5_A1 = 0x8057;
+ int GL_RGB565_OES = 0x8D62;
+ int GL_RGB8 = 0x8051;
+ int GL_RGBA4 = 0x8056;
+ int GL_RGBA8 = 0x8058;
+ int GL_STENCIL_ATTACHMENT_OES = 0x8D20;
+ int GL_STENCIL_INDEX = 0x1901;
+ int GL_STENCIL_INDEX1_OES = 0x8D46;
+ int GL_STENCIL_INDEX4_OES = 0x8D47;
+ int GL_STENCIL_INDEX8_OES = 0x8D48;
+ int GL_STR = -1;
+ int GL_TEXTURE_BINDING_CUBE_MAP = 0x8514;
+ int GL_TEXTURE_CUBE_MAP = 0x8513;
+ int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
+ int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
+ int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
+ int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
+ int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
+ int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
+ int GL_TEXTURE_GEN_MODE = 0x2500;
+ int GL_TEXTURE_GEN_STR = 0x8D60;
+
diff --git a/opengl/tools/glgen/stubs/GL11Header.java-if b/opengl/tools/glgen/stubs/GL11Header.java-if
new file mode 100644
index 0000000..b0e5a6b
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GL11Header.java-if
@@ -0,0 +1,145 @@
+**
+** Copyright 2006, 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.
+*/
+
+// This source file is automatically generated
+
+package javax.microedition.khronos.opengles;
+
+public interface GL11 extends GL10 {
+ int GL_ACTIVE_TEXTURE = 0x84E0;
+ int GL_ADD_SIGNED = 0x8574;
+ int GL_ALPHA_SCALE = 0x0D1C;
+ int GL_ALPHA_TEST_FUNC = 0x0BC1;
+ int GL_ALPHA_TEST_REF = 0x0BC2;
+ int GL_ARRAY_BUFFER = 0x8892;
+ int GL_ARRAY_BUFFER_BINDING = 0x8894;
+ int GL_BLEND_DST = 0x0BE0;
+ int GL_BLEND_SRC = 0x0BE1;
+ int GL_BUFFER_ACCESS = 0x88BB;
+ int GL_BUFFER_SIZE = 0x8764;
+ int GL_BUFFER_USAGE = 0x8765;
+ int GL_CLIENT_ACTIVE_TEXTURE = 0x84E1;
+ int GL_CLIP_PLANE0 = 0x3000;
+ int GL_CLIP_PLANE1 = 0x3001;
+ int GL_CLIP_PLANE2 = 0x3002;
+ int GL_CLIP_PLANE3 = 0x3003;
+ int GL_CLIP_PLANE4 = 0x3004;
+ int GL_CLIP_PLANE5 = 0x3005;
+ int GL_COLOR_ARRAY_BUFFER_BINDING = 0x8898;
+ int GL_COLOR_ARRAY_POINTER = 0x8090;
+ int GL_COLOR_ARRAY_SIZE = 0x8081;
+ int GL_COLOR_ARRAY_STRIDE = 0x8083;
+ int GL_COLOR_ARRAY_TYPE = 0x8082;
+ int GL_COLOR_CLEAR_VALUE = 0x0C22;
+ int GL_COLOR_WRITEMASK = 0x0C23;
+ int GL_COMBINE = 0x8570;
+ int GL_COMBINE_ALPHA = 0x8572;
+ int GL_COMBINE_RGB = 0x8571;
+ int GL_CONSTANT = 0x8576;
+ int GL_COORD_REPLACE_OES = 0x8862;
+ int GL_CULL_FACE_MODE = 0x0B45;
+ int GL_CURRENT_COLOR = 0x0B00;
+ int GL_CURRENT_NORMAL = 0x0B02;
+ int GL_CURRENT_TEXTURE_COORDS = 0x0B03;
+ int GL_DEPTH_CLEAR_VALUE = 0x0B73;
+ int GL_DEPTH_FUNC = 0x0B74;
+ int GL_DEPTH_RANGE = 0x0B70;
+ int GL_DEPTH_WRITEMASK = 0x0B72;
+ int GL_DOT3_RGB = 0x86AE;
+ int GL_DOT3_RGBA = 0x86AF;
+ int GL_DYNAMIC_DRAW = 0x88E8;
+ int GL_ELEMENT_ARRAY_BUFFER = 0x8893;
+ int GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
+ int GL_FRONT_FACE = 0x0B46;
+ int GL_GENERATE_MIPMAP = 0x8191;
+ int GL_GENERATE_MIPMAP_HINT = 0x8192;
+ int GL_INTERPOLATE = 0x8575;
+ int GL_LINE_WIDTH = 0x0B21;
+ int GL_LOGIC_OP_MODE = 0x0BF0;
+ int GL_MATRIX_MODE = 0x0BA0;
+ int GL_MAX_CLIP_PLANES = 0x0D32;
+ int GL_MODELVIEW_MATRIX = 0x0BA6;
+ int GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES = 0x898D;
+ int GL_MODELVIEW_STACK_DEPTH = 0x0BA3;
+ int GL_NORMAL_ARRAY_BUFFER_BINDING = 0x8897;
+ int GL_NORMAL_ARRAY_POINTER = 0x808F;
+ int GL_NORMAL_ARRAY_STRIDE = 0x807F;
+ int GL_NORMAL_ARRAY_TYPE = 0x807E;
+ int GL_OPERAND0_ALPHA = 0x8598;
+ int GL_OPERAND0_RGB = 0x8590;
+ int GL_OPERAND1_ALPHA = 0x8599;
+ int GL_OPERAND1_RGB = 0x8591;
+ int GL_OPERAND2_ALPHA = 0x859A;
+ int GL_OPERAND2_RGB = 0x8592;
+ int GL_POINT_DISTANCE_ATTENUATION = 0x8129;
+ int GL_POINT_FADE_THRESHOLD_SIZE = 0x8128;
+ int GL_POINT_SIZE = 0x0B11;
+ int GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES = 0x8B9F;
+ int GL_POINT_SIZE_ARRAY_OES = 0x8B9C;
+ int GL_POINT_SIZE_ARRAY_POINTER_OES = 0x898C;
+ int GL_POINT_SIZE_ARRAY_STRIDE_OES = 0x898B;
+ int GL_POINT_SIZE_ARRAY_TYPE_OES = 0x898A;
+ int GL_POINT_SIZE_MAX = 0x8127;
+ int GL_POINT_SIZE_MIN = 0x8126;
+ int GL_POINT_SPRITE_OES = 0x8861;
+ int GL_POLYGON_OFFSET_FACTOR = 0x8038;
+ int GL_POLYGON_OFFSET_UNITS = 0x2A00;
+ int GL_PREVIOUS = 0x8578;
+ int GL_PRIMARY_COLOR = 0x8577;
+ int GL_PROJECTION_MATRIX = 0x0BA7;
+ int GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES = 0x898E;
+ int GL_PROJECTION_STACK_DEPTH = 0x0BA4;
+ int GL_RGB_SCALE = 0x8573;
+ int GL_SAMPLE_BUFFERS = 0x80A8;
+ int GL_SAMPLE_COVERAGE_INVERT = 0x80AB;
+ int GL_SAMPLE_COVERAGE_VALUE = 0x80AA;
+ int GL_SAMPLES = 0x80A9;
+ int GL_SCISSOR_BOX = 0x0C10;
+ int GL_SHADE_MODEL = 0x0B54;
+ int GL_SRC0_ALPHA = 0x8588;
+ int GL_SRC0_RGB = 0x8580;
+ int GL_SRC1_ALPHA = 0x8589;
+ int GL_SRC1_RGB = 0x8581;
+ int GL_SRC2_ALPHA = 0x858A;
+ int GL_SRC2_RGB = 0x8582;
+ int GL_STATIC_DRAW = 0x88E4;
+ int GL_STENCIL_CLEAR_VALUE = 0x0B91;
+ int GL_STENCIL_FAIL = 0x0B94;
+ int GL_STENCIL_FUNC = 0x0B92;
+ int GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95;
+ int GL_STENCIL_PASS_DEPTH_PASS = 0x0B96;
+ int GL_STENCIL_REF = 0x0B97;
+ int GL_STENCIL_VALUE_MASK = 0x0B93;
+ int GL_STENCIL_WRITEMASK = 0x0B98;
+ int GL_SUBTRACT = 0x84E7;
+ int GL_TEXTURE_BINDING_2D = 0x8069;
+ int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 0x889A;
+ int GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092;
+ int GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088;
+ int GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808A;
+ int GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089;
+ int GL_TEXTURE_MATRIX = 0x0BA8;
+ int GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES = 0x898F;
+ int GL_TEXTURE_STACK_DEPTH = 0x0BA5;
+ int GL_VERTEX_ARRAY_BUFFER_BINDING = 0x8896;
+ int GL_VERTEX_ARRAY_POINTER = 0x808E;
+ int GL_VERTEX_ARRAY_SIZE = 0x807A;
+ int GL_VERTEX_ARRAY_STRIDE = 0x807C;
+ int GL_VERTEX_ARRAY_TYPE = 0x807B;
+ int GL_VIEWPORT = 0x0BA2;
+ int GL_WRITE_ONLY = 0x88B9;
+
+ void glGetPointerv(int pname, java.nio.Buffer[] params);
diff --git a/opengl/tools/glgen/stubs/GL11ImplHeader.java-impl b/opengl/tools/glgen/stubs/GL11ImplHeader.java-impl
new file mode 100644
index 0000000..501be65
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GL11ImplHeader.java-impl
@@ -0,0 +1,30 @@
+// Copyright 2006 The Android Open Source Project
+
+// All Rights Reserved.
+
+// This source file is automatically generated
+
+package com.google.android.gles_jni;
+
+import java.nio.Buffer;
+import javax.microedition.khronos.opengles.GL11;
+import android.graphics.Canvas;
+
+public class GL11Impl implements GL11 {
+
+ // Private accessors for native code
+
+ native private static void _nativeClassInit();
+ static {
+ _nativeClassInit();
+ }
+
+ Buffer _colorPointer = null;
+ Buffer _normalPointer = null;
+ Buffer _texCoordPointer = null;
+ Buffer _vertexPointer = null;
+
+ public GL11Impl() {
+ }
+
+
diff --git a/opengl/tools/glgen/stubs/GLCHeader.cpp b/opengl/tools/glgen/stubs/GLCHeader.cpp
new file mode 100644
index 0000000..6495686
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GLCHeader.cpp
@@ -0,0 +1,129 @@
+**
+** Copyright 2006, 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.
+*/
+
+// This source file is automatically generated
+
+#include <android_runtime/AndroidRuntime.h>
+#include <utils/misc.h>
+
+#include <assert.h>
+#include <GLES/gl.h>
+
+#include <private/opengles/gl_context.h>
+
+#define _NUM_COMPRESSED_TEXTURE_FORMATS \
+ (::android::OGLES_NUM_COMPRESSED_TEXTURE_FORMATS)
+
+static int initialized = 0;
+
+static jclass nioAccessClass;
+static jclass bufferClass;
+static jclass OOMEClass;
+static jclass UOEClass;
+static jclass IAEClass;
+static jclass AIOOBEClass;
+static jmethodID getBasePointerID;
+static jmethodID getBaseArrayID;
+static jmethodID getBaseArrayOffsetID;
+static jfieldID positionID;
+static jfieldID limitID;
+static jfieldID elementSizeShiftID;
+
+/* Cache method IDs each time the class is loaded. */
+
+void
+nativeClassInitBuffer(JNIEnv *_env)
+{
+ jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
+ nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
+
+ jclass bufferClassLocal = _env->FindClass("java/nio/Buffer");
+ bufferClass = (jclass) _env->NewGlobalRef(bufferClassLocal);
+
+ getBasePointerID = _env->GetStaticMethodID(nioAccessClass,
+ "getBasePointer", "(Ljava/nio/Buffer;)J");
+ getBaseArrayID = _env->GetStaticMethodID(nioAccessClass,
+ "getBaseArray", "(Ljava/nio/Buffer;)Ljava/lang/Object;");
+ getBaseArrayOffsetID = _env->GetStaticMethodID(nioAccessClass,
+ "getBaseArrayOffset", "(Ljava/nio/Buffer;)I");
+
+ positionID = _env->GetFieldID(bufferClass, "position", "I");
+ limitID = _env->GetFieldID(bufferClass, "limit", "I");
+ elementSizeShiftID =
+ _env->GetFieldID(bufferClass, "_elementSizeShift", "I");
+}
+
+
+static void
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
+{
+ nativeClassInitBuffer(_env);
+
+ jclass IAEClassLocal =
+ _env->FindClass("java/lang/IllegalArgumentException");
+ jclass OOMEClassLocal =
+ _env->FindClass("java/lang/OutOfMemoryError");
+ jclass UOEClassLocal =
+ _env->FindClass("java/lang/UnsupportedOperationException");
+ jclass AIOOBEClassLocal =
+ _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");
+
+ IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
+ OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
+ UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
+ AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
+}
+
+static void *
+getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
+{
+ jint position;
+ jint limit;
+ jint elementSizeShift;
+ jlong pointer;
+ jint offset;
+ void *data;
+
+ position = _env->GetIntField(buffer, positionID);
+ limit = _env->GetIntField(buffer, limitID);
+ elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
+ *remaining = (limit - position) << elementSizeShift;
+ pointer = _env->CallStaticLongMethod(nioAccessClass,
+ getBasePointerID, buffer);
+ if (pointer != 0L) {
+ *array = NULL;
+ return (void *) (jint) pointer;
+ }
+
+ *array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
+ getBaseArrayID, buffer);
+ offset = _env->CallStaticIntMethod(nioAccessClass,
+ getBaseArrayOffsetID, buffer);
+ data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
+
+ return (void *) ((char *) data + offset);
+}
+
+
+static void
+releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
+{
+ _env->ReleasePrimitiveArrayCritical(array, data,
+ commit ? 0 : JNI_ABORT);
+}
+
+// --------------------------------------------------------------------------
+
diff --git a/opengl/tools/glgen/stubs/GLHeader.java-if b/opengl/tools/glgen/stubs/GLHeader.java-if
new file mode 100644
index 0000000..3b78f3d
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GLHeader.java-if
@@ -0,0 +1,22 @@
+/* //device/java/android/javax/microedition/khronos/opengles/GL.java
+**
+** Copyright 2006, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package javax.microedition.khronos.opengles;
+
+public interface GL {
+}
+
diff --git a/opengl/tools/glgen/stubs/GLImplHeader.java-impl b/opengl/tools/glgen/stubs/GLImplHeader.java-impl
new file mode 100644
index 0000000..db3a41c
--- /dev/null
+++ b/opengl/tools/glgen/stubs/GLImplHeader.java-impl
@@ -0,0 +1,48 @@
+**
+** Copyright 2006, 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.
+*/
+
+// This source file is automatically generated
+
+package com.google.android.gles_jni;
+
+import java.nio.Buffer;
+import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL10Ext;
+import javax.microedition.khronos.opengles.GL11;
+import javax.microedition.khronos.opengles.GL11Ext;
+import javax.microedition.khronos.opengles.GL11ExtensionPack;
+
+public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack {
+
+ // Private accessors for native code
+
+ native private static void _nativeClassInit();
+ static {
+ _nativeClassInit();
+ }
+
+ Buffer _colorPointer = null;
+ Buffer _normalPointer = null;
+ Buffer _texCoordPointer = null;
+ Buffer _vertexPointer = null;
+
+ public GLImpl() {
+ }
+
+ public void glGetPointerv(int pname, java.nio.Buffer[] params) {
+ throw new UnsupportedOperationException("glGetPointerv");
+ }
+
diff --git a/opengl/tools/glgen/stubs/glGetString.cpp b/opengl/tools/glgen/stubs/glGetString.cpp
new file mode 100644
index 0000000..22e1297
--- /dev/null
+++ b/opengl/tools/glgen/stubs/glGetString.cpp
@@ -0,0 +1,10 @@
+#include <string.h>
+
+/* const GLubyte * glGetString ( GLenum name ) */
+jstring
+android_glGetString
+ (JNIEnv *_env, jobject _this, jint name) {
+ const char * chars = (const char *)glGetString((GLenum)name);
+ jstring output = _env->NewStringUTF(chars);
+ return output;
+}
diff --git a/opengl/tools/glgen/stubs/glGetString.java-10-if b/opengl/tools/glgen/stubs/glGetString.java-10-if
new file mode 100644
index 0000000..898fabc
--- /dev/null
+++ b/opengl/tools/glgen/stubs/glGetString.java-10-if
@@ -0,0 +1,4 @@
+ public String glGetString(
+ int name
+ );
+
diff --git a/opengl/tools/glgen/stubs/glGetString.java-if b/opengl/tools/glgen/stubs/glGetString.java-if
new file mode 100644
index 0000000..898fabc
--- /dev/null
+++ b/opengl/tools/glgen/stubs/glGetString.java-if
@@ -0,0 +1,4 @@
+ public String glGetString(
+ int name
+ );
+
diff --git a/opengl/tools/glgen/stubs/glGetString.java-impl b/opengl/tools/glgen/stubs/glGetString.java-impl
new file mode 100644
index 0000000..8c7881c
--- /dev/null
+++ b/opengl/tools/glgen/stubs/glGetString.java-impl
@@ -0,0 +1,16 @@
+ // C function const GLubyte * glGetString ( GLenum name )
+
+ public native String _glGetString(
+ int name
+ );
+
+ public String glGetString(
+ int name
+ ) {
+ String returnValue;
+ returnValue = _glGetString(
+ name
+ );
+ return returnValue;
+ }
+
diff --git a/opengl/tools/glgen/stubs/glGetString.nativeReg b/opengl/tools/glgen/stubs/glGetString.nativeReg
new file mode 100644
index 0000000..e64187c
--- /dev/null
+++ b/opengl/tools/glgen/stubs/glGetString.nativeReg
@@ -0,0 +1 @@
+{"_glGetString", "(I)Ljava/lang/String;", (void *) android_glGetString },