added glshim library

This commit is contained in:
lubomyr
2015-02-09 20:25:03 +00:00
parent e5e9109652
commit 967c18296e
143 changed files with 231962 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
LOCAL_PATH := $(call my-dir)
###########################
#
# GL static library
#
###########################
include $(CLEAR_VARS)
LOCAL_MODULE := glshim
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \
$(LOCAL_PATH)/src/util \
$(LOCAL_PATH)/src/util/vectorial
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES) -DBCMHOST
LOCAL_SRC_FILES := \
src/gl/array.c \
src/gl/buffers.c \
src/gl/decompress.c \
src/gl/eval.c \
src/gl/framebuffers.c \
src/gl/gl.c \
src/gl/light.c \
src/gl/line.c \
src/gl/list.c \
src/gl/pixel.c \
src/gl/raster.c \
src/gl/render.c \
src/gl/stack.c \
src/gl/texgen.c \
src/gl/texture.c \
src/gl/wrap/gl.c \
src/gl/wrap/gles.c \
src/gl/wrap/gles2.c \
src/gl/wrap/glesext.c \
src/gl/wrap/glstub.c \
src/gl/math/eval.c \
src/glx/streaming.c
LOCAL_CFLAGS += -g -std=c99 -funwind-tables -O3 -DGL_EXPORTS -D_THREAD_SAFE=1 -DBCMHOST
LOCAL_LDLIBS := -ldl -llog -lEGL
include $(BUILD_SHARED_LIBRARY)

View File

@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 2.6)
project(glshim)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
# Raspberry PI
if(BCMHOST)
include_directories(/opt/vc/include /opt/vc/include/interface/vcos/pthreads /opt/vc/include/interface/vmcs_host/linux)
link_directories(/opt/vc/lib)
add_definitions(-DBCMHOST -D_GNU_SOURCE)
endif()
link_directories(${CMAKE_BINARY_DIR}/lib)
add_definitions(-O2)
include(flags.cmake)
include_directories(include)
add_subdirectory(src)

View File

@@ -0,0 +1,19 @@
Copyright (c) 2013 Ryan Hileman
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 THE
AUTHORS OR COPYRIGHT HOLDERS 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.

View File

@@ -0,0 +1,31 @@
glshim
====
This is a shim providing OpenGL 1.x functionality to OpenGL ES accelerated cards.
----
Compiling
----
cmake .; make GL
*or for the Raspberry Pi*
cmake . -DBCMHOST=1; make GL
----
GLU
----
You probably want the glu branch from https://github.com/lunixbochs/glues
git clone git@github.com:lunixbochs/glues.git; git checkout glu; cmake .; make
----
Installation
----
Put lib/libGL.so.1 in your `LD_LIBRARY_PATH`. If you need GLU, build libGLU.so.1 from the glues repo and do likewise.

View File

@@ -0,0 +1,84 @@
/**********************************************************************
*
* Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
* Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful but, except
* as otherwise stated in writing, without any warranty; without even the
* implied warranty of merchantability or fitness for a particular purpose.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
* Contact Information:
* Imagination Technologies Ltd. <gpl-support@imgtec.com>
* Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
*
******************************************************************************/
#ifndef __BC_CAT_H__
#define __BC_CAT_H__
#include <linux/ioctl.h>
#define BC_FOURCC(a,b,c,d) \
((unsigned long) ((a) | (b)<<8 | (c)<<16 | (d)<<24))
#define BC_PIX_FMT_NV12 BC_FOURCC('N', 'V', '1', '2') /*YUV 4:2:0*/
#define BC_PIX_FMT_UYVY BC_FOURCC('U', 'Y', 'V', 'Y') /*YUV 4:2:2*/
#define BC_PIX_FMT_YUYV BC_FOURCC('Y', 'U', 'Y', 'V') /*YUV 4:2:2*/
#define BC_PIX_FMT_RGB565 BC_FOURCC('R', 'G', 'B', 'P') /*RGB 5:6:5*/
enum BC_memory {
BC_MEMORY_MMAP = 1,
BC_MEMORY_USERPTR = 2,
};
typedef struct BCIO_package_TAG {
int input;
int output;
}BCIO_package;
/*
* the following types are tested for fourcc in struct bc_buf_params_t
* NV12
* UYVY
* RGB565 - not tested yet
* YUYV
*/
typedef struct bc_buf_params {
int count; /*number of buffers, [in/out]*/
int width; /*buffer width in pixel, multiple of 8 or 32*/
int height; /*buffer height in pixel*/
unsigned int fourcc; /*buffer pixel format*/
enum BC_memory type;
} bc_buf_params_t;
typedef struct bc_buf_ptr {
unsigned int index;
int size;
unsigned long pa;
} bc_buf_ptr_t;
#define BCIO_GID 'g'
#define BC_IOWR(INDEX) _IOWR(BCIO_GID, INDEX, BCIO_package)
#define BCIOGET_BUFFERCOUNT BC_IOWR(0) /*obsolete, since BCIOREQ_BUFFERS
return the number of buffers*/
#define BCIOGET_BUFFERPHYADDR BC_IOWR(1) /*get physical address by index*/
#define BCIOGET_BUFFERIDX BC_IOWR(2) /*get index by physical address*/
#define BCIOREQ_BUFFERS BC_IOWR(3)
#define BCIOSET_BUFFERPHYADDR BC_IOWR(4)
#endif

View File

@@ -0,0 +1,6 @@
add_definitions(-g -funwind-tables -ffast-math)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
add_definitions(-fsingle-precision-constant -mfpu=neon -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8)
endif()

View File

@@ -0,0 +1,329 @@
/* -*- mode: c; tab-width: 8; -*- */
/* vi: set sw=4 ts=8: */
/* Reference version of egl.h for EGL 1.4.
* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
*/
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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 THE AUTHORS OR COPYRIGHT HOLDERS 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#ifndef __egl_h_
#define __egl_h_
/* All platform-dependent types and macro boilerplate (such as EGLAPI
* and EGLAPIENTRY) should go in eglplatform.h.
*/
#include <EGL/eglplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/* EGL Types */
/* EGLint is defined in eglplatform.h */
typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum;
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLSurface;
typedef void *EGLClientBuffer;
/* EGL Versioning */
#define EGL_VERSION_1_0 1
#define EGL_VERSION_1_1 1
#define EGL_VERSION_1_2 1
#define EGL_VERSION_1_3 1
#define EGL_VERSION_1_4 1
/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
* enums are assigned unique values starting at 0x3000.
*/
/* EGL aliases */
#define EGL_FALSE 0
#define EGL_TRUE 1
/* Out-of-band handle values */
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
#define EGL_NO_CONTEXT ((EGLContext)0)
#define EGL_NO_DISPLAY ((EGLDisplay)0)
#define EGL_NO_SURFACE ((EGLSurface)0)
/* Out-of-band attribute value */
#define EGL_DONT_CARE ((EGLint)-1)
/* Errors / GetError return values */
#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
#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */
/* Reserved 0x300F-0x301F 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_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
#define EGL_NONE 0x3038 /* Attrib list terminator */
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
#define EGL_MIN_SWAP_INTERVAL 0x303B
#define EGL_MAX_SWAP_INTERVAL 0x303C
#define EGL_LUMINANCE_SIZE 0x303D
#define EGL_ALPHA_MASK_SIZE 0x303E
#define EGL_COLOR_BUFFER_TYPE 0x303F
#define EGL_RENDERABLE_TYPE 0x3040
#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */
#define EGL_CONFORMANT 0x3042
/* Reserved 0x3041-0x304F for additional config attributes */
/* Config attribute values */
#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */
#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */
#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */
/* More config attribute values, for EGL_TEXTURE_FORMAT */
#define EGL_NO_TEXTURE 0x305C
#define EGL_TEXTURE_RGB 0x305D
#define EGL_TEXTURE_RGBA 0x305E
#define EGL_TEXTURE_2D 0x305F
/* Config attribute mask bits */
#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */
#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */
#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */
#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */
#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */
/* QueryString targets */
#define EGL_VENDOR 0x3053
#define EGL_VERSION 0x3054
#define EGL_EXTENSIONS 0x3055
#define EGL_CLIENT_APIS 0x308D
/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
#define EGL_HEIGHT 0x3056
#define EGL_WIDTH 0x3057
#define EGL_LARGEST_PBUFFER 0x3058
#define EGL_TEXTURE_FORMAT 0x3080
#define EGL_TEXTURE_TARGET 0x3081
#define EGL_MIPMAP_TEXTURE 0x3082
#define EGL_MIPMAP_LEVEL 0x3083
#define EGL_RENDER_BUFFER 0x3086
#define EGL_VG_COLORSPACE 0x3087
#define EGL_VG_ALPHA_FORMAT 0x3088
#define EGL_HORIZONTAL_RESOLUTION 0x3090
#define EGL_VERTICAL_RESOLUTION 0x3091
#define EGL_PIXEL_ASPECT_RATIO 0x3092
#define EGL_SWAP_BEHAVIOR 0x3093
#define EGL_MULTISAMPLE_RESOLVE 0x3099
/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
#define EGL_BACK_BUFFER 0x3084
#define EGL_SINGLE_BUFFER 0x3085
/* OpenVG color spaces */
#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */
#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */
/* OpenVG alpha formats */
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */
/* Constant scale factor by which fractional display resolutions &
* aspect ratio are scaled when queried as integer values.
*/
#define EGL_DISPLAY_SCALING 10000
/* Unknown display resolution/aspect ratio */
#define EGL_UNKNOWN ((EGLint)-1)
/* Back buffer swap behaviors */
#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */
#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */
/* CreatePbufferFromClientBuffer buffer types */
#define EGL_OPENVG_IMAGE 0x3096
/* QueryContext targets */
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
/* CreateContext attributes */
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
/* Multisample resolution behaviors */
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */
/* BindAPI/QueryAPI targets */
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENGL_API 0x30A2
/* GetCurrentSurface targets */
#define EGL_DRAW 0x3059
#define EGL_READ 0x305A
/* WaitNative engines */
#define EGL_CORE_NATIVE_ENGINE 0x305B
/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
#define EGL_COLORSPACE EGL_VG_COLORSPACE
#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT
#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB
#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR
#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE
#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE
/* EGL extensions must request enum blocks from the Khronos
* API Registrar, who maintains the enumerant registry. Submit
* a bug in Khronos Bugzilla against task "Registry".
*/
/* EGL Functions */
EGLAPI EGLint EGLAPIENTRY eglGetError(void);
EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
EGLint config_size, EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
EGLConfig *configs, EGLint config_size,
EGLint *num_config);
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint *value);
EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
EGLNativeWindowType win,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
const EGLint *attrib_list);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
EGLNativePixmapType pixmap,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
EGLConfig config, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
EGLint attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx);
EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
EGLint attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
EGLNativePixmapType target);
/* This is a generic function pointer type, whose name indicates it must
* be cast to the proper type *and calling convention* before use.
*/
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
/* Now, define eglGetProcAddress using the generic function ptr. type */
EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
eglGetProcAddress(const char *procname);
#ifdef __cplusplus
}
#endif
#endif /* __egl_h_ */

View File

@@ -0,0 +1,477 @@
#ifndef __eglext_h_
#define __eglext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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 THE AUTHORS OR COPYRIGHT HOLDERS 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#include <EGL/eglplatform.h>
/*************************************************************/
/* Header file version number */
/* Current version at http://www.khronos.org/registry/egl/ */
/* $Revision: 19571 $ on $Date: 2012-10-31 10:10:33 -0700 (Wed, 31 Oct 2012) $ */
#define EGL_EGLEXT_VERSION 14
#ifndef EGL_KHR_config_attribs
#define EGL_KHR_config_attribs 1
#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */
#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */
#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */
#endif
#ifndef EGL_KHR_lock_surface
#define EGL_KHR_lock_surface 1
#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */
#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */
#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */
#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */
#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */
#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */
#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */
#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */
#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */
#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */
#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */
#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */
#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
#endif
#ifndef EGL_KHR_image
#define EGL_KHR_image 1
#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */
typedef void *EGLImageKHR;
#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
#endif
#ifndef EGL_KHR_vg_parent_image
#define EGL_KHR_vg_parent_image 1
#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */
#endif
#ifndef EGL_KHR_gl_texture_2D_image
#define EGL_KHR_gl_texture_2D_image 1
#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_gl_texture_cubemap_image
#define EGL_KHR_gl_texture_cubemap_image 1
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */
#endif
#ifndef EGL_KHR_gl_texture_3D_image
#define EGL_KHR_gl_texture_3D_image 1
#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */
#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_gl_renderbuffer_image
#define EGL_KHR_gl_renderbuffer_image 1
#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */
#ifndef EGL_KHR_reusable_sync
#define EGL_KHR_reusable_sync 1
typedef void* EGLSyncKHR;
typedef khronos_utime_nanoseconds_t EGLTimeKHR;
#define EGL_SYNC_STATUS_KHR 0x30F1
#define EGL_SIGNALED_KHR 0x30F2
#define EGL_UNSIGNALED_KHR 0x30F3
#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5
#define EGL_CONDITION_SATISFIED_KHR 0x30F6
#define EGL_SYNC_TYPE_KHR 0x30F7
#define EGL_SYNC_REUSABLE_KHR 0x30FA
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR <flags> bitfield */
#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
#endif
#endif
#ifndef EGL_KHR_image_base
#define EGL_KHR_image_base 1
/* Most interfaces defined by EGL_KHR_image_pixmap above */
#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */
#endif
#ifndef EGL_KHR_image_pixmap
#define EGL_KHR_image_pixmap 1
/* Interfaces defined by EGL_KHR_image above */
#endif
#ifndef EGL_IMG_context_priority
#define EGL_IMG_context_priority 1
#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100
#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
#endif
#ifndef EGL_KHR_lock_surface2
#define EGL_KHR_lock_surface2 1
#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110
#endif
#ifndef EGL_NV_coverage_sample
#define EGL_NV_coverage_sample 1
#define EGL_COVERAGE_BUFFERS_NV 0x30E0
#define EGL_COVERAGE_SAMPLES_NV 0x30E1
#endif
#ifndef EGL_NV_depth_nonlinear
#define EGL_NV_depth_nonlinear 1
#define EGL_DEPTH_ENCODING_NV 0x30E2
#define EGL_DEPTH_ENCODING_NONE_NV 0
#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */
#ifndef EGL_NV_sync
#define EGL_NV_sync 1
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6
#define EGL_SYNC_STATUS_NV 0x30E7
#define EGL_SIGNALED_NV 0x30E8
#define EGL_UNSIGNALED_NV 0x30E9
#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001
#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull
#define EGL_ALREADY_SIGNALED_NV 0x30EA
#define EGL_TIMEOUT_EXPIRED_NV 0x30EB
#define EGL_CONDITION_SATISFIED_NV 0x30EC
#define EGL_SYNC_TYPE_NV 0x30ED
#define EGL_SYNC_CONDITION_NV 0x30EE
#define EGL_SYNC_FENCE_NV 0x30EF
#define EGL_NO_SYNC_NV ((EGLSyncNV)0)
typedef void* EGLSyncNV;
typedef khronos_utime_nanoseconds_t EGLTimeNV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);
EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);
EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);
EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);
typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);
#endif
#endif
#if KHRONOS_SUPPORT_INT64 /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */
#ifndef EGL_KHR_fence_sync
#define EGL_KHR_fence_sync 1
/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
#define EGL_SYNC_CONDITION_KHR 0x30F8
#define EGL_SYNC_FENCE_KHR 0x30F9
#endif
#endif
#ifndef EGL_HI_clientpixmap
#define EGL_HI_clientpixmap 1
/* Surface Attribute */
#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74
/*
* Structure representing a client pixmap
* (pixmap's data is in client-space memory).
*/
struct EGLClientPixmapHI
{
void* pData;
EGLint iWidth;
EGLint iHeight;
EGLint iStride;
};
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);
#endif /* EGL_HI_clientpixmap */
#ifndef EGL_HI_colorformats
#define EGL_HI_colorformats 1
/* Config Attribute */
#define EGL_COLOR_FORMAT_HI 0x8F70
/* Color Formats */
#define EGL_COLOR_RGB_HI 0x8F71
#define EGL_COLOR_RGBA_HI 0x8F72
#define EGL_COLOR_ARGB_HI 0x8F73
#endif /* EGL_HI_colorformats */
#ifndef EGL_MESA_drm_image
#define EGL_MESA_drm_image 1
#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 /* CreateDRMImageMESA attribute */
#define EGL_DRM_BUFFER_USE_MESA 0x31D1 /* CreateDRMImageMESA attribute */
#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 /* EGL_IMAGE_FORMAT_MESA attribute value */
#define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */
#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4
#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 /* EGL_DRM_BUFFER_USE_MESA bits */
#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 /* EGL_DRM_BUFFER_USE_MESA bits */
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);
#endif
#ifndef EGL_NV_post_sub_buffer
#define EGL_NV_post_sub_buffer 1
#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);
#endif
#ifndef EGL_ANGLE_query_surface_pointer
#define EGL_ANGLE_query_surface_pointer 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
#endif
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
#endif
#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle
#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1
#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200
#endif
#ifndef EGL_NV_coverage_sample_resolve
#define EGL_NV_coverage_sample_resolve 1
#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131
#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132
#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLuint64NV requires 64-bit uint support */
#ifndef EGL_NV_system_time
#define EGL_NV_system_time 1
typedef khronos_utime_nanoseconds_t EGLuint64NV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);
#endif
#endif
#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */
#ifndef EGL_KHR_stream
#define EGL_KHR_stream 1
typedef void* EGLStreamKHR;
typedef khronos_uint64_t EGLuint64KHR;
#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0)
#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210
#define EGL_PRODUCER_FRAME_KHR 0x3212
#define EGL_CONSUMER_FRAME_KHR 0x3213
#define EGL_STREAM_STATE_KHR 0x3214
#define EGL_STREAM_STATE_CREATED_KHR 0x3215
#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216
#define EGL_STREAM_STATE_EMPTY_KHR 0x3217
#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218
#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219
#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A
#define EGL_BAD_STREAM_KHR 0x321B
#define EGL_BAD_STATE_KHR 0x321C
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_consumer_gltexture
#define EGL_KHR_stream_consumer_gltexture 1
#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_producer_eglsurface
#define EGL_KHR_stream_producer_eglsurface 1
#define EGL_STREAM_BIT_KHR 0x0800
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_producer_aldatalocator
#define EGL_KHR_stream_producer_aldatalocator 1
#endif
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_fifo
#define EGL_KHR_stream_fifo 1
/* reuse EGLTimeKHR */
#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC
#define EGL_STREAM_TIME_NOW_KHR 0x31FD
#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE
#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);
#endif
#endif
#ifndef EGL_EXT_create_context_robustness
#define EGL_EXT_create_context_robustness 1
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138
#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF
#endif
#ifndef EGL_ANGLE_d3d_share_handle_client_buffer
#define EGL_ANGLE_d3d_share_handle_client_buffer 1
/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */
#endif
#ifndef EGL_KHR_create_context
#define EGL_KHR_create_context 1
#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
#define EGL_CONTEXT_FLAGS_KHR 0x30FC
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
#define EGL_OPENGL_ES3_BIT_KHR 0x00000040
#endif
#ifndef EGL_KHR_surfaceless_context
#define EGL_KHR_surfaceless_context 1
/* No tokens/entry points, just relaxes an error condition */
#endif
#ifdef EGL_KHR_stream /* Requires KHR_stream extension */
#ifndef EGL_KHR_stream_cross_process_fd
#define EGL_KHR_stream_cross_process_fd 1
typedef int EGLNativeFileDescriptorKHR;
#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
#endif
#endif
#ifndef EGL_EXT_multiview_window
#define EGL_EXT_multiview_window 1
#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134
#endif
#ifndef EGL_KHR_wait_sync
#define EGL_KHR_wait_sync 1
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
#endif /* EGL_EGLEXT_PROTOTYPES */
typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,121 @@
#ifndef __eglplatform_h_
#define __eglplatform_h_
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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 THE AUTHORS OR COPYRIGHT HOLDERS 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Platform-specific types and definitions for egl.h
* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "EGL" component "Registry".
*/
#include <KHR/khrplatform.h>
/* Macros used in EGL function prototype declarations.
*
* EGL functions should be prototyped as:
*
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
*
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
*/
#ifndef EGLAPI
#define EGLAPI KHRONOS_APICALL
#endif
#ifndef EGLAPIENTRY
#define EGLAPIENTRY KHRONOS_APIENTRY
#endif
#define EGLAPIENTRYP EGLAPIENTRY*
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
* are aliases of window-system-dependent types, such as X Display * or
* Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
*
* Khronos STRONGLY RECOMMENDS that you use the default definitions
* provided below, since these changes affect both binary and source
* portability of applications using EGL running on different EGL
* implementations.
*/
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#elif defined(__unix__) && !defined(ANDROID)
/* X11 (tentative) */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#elif defined(ANDROID)
typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#else
#error "Platform not recognized"
#endif
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
typedef EGLNativeDisplayType NativeDisplayType;
typedef EGLNativePixmapType NativePixmapType;
typedef EGLNativeWindowType NativeWindowType;
/* Define EGLint. This must be a signed integral type large enough to contain
* all legal attribute names and values passed into and out of EGL, whether
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
* handle, or other. While in general a 32-bit integer will suffice, if
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
* integer type.
*/
typedef khronos_int32_t EGLint;
#endif /* __eglplatform_h */

View File

@@ -0,0 +1,115 @@
#ifndef __eglplatform_h_
#define __eglplatform_h_
/*
** Copyright (c) 2007-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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 THE AUTHORS OR COPYRIGHT HOLDERS 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Platform-specific types and definitions for egl.h
* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "EGL" component "Registry".
*/
#include <KHR/khrplatform.h>
/* Macros used in EGL function prototype declarations.
*
* EGL functions should be prototyped as:
*
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
*
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
*/
#ifndef EGLAPI
#define EGLAPI KHRONOS_APICALL
#endif
#ifndef EGLAPIENTRY
#define EGLAPIENTRY KHRONOS_APIENTRY
#endif
#define EGLAPIENTRYP EGLAPIENTRY*
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
* are aliases of window-system-dependent types, such as X Display * or
* Windows Device Context. They must be defined in platform-specific
* code below. The EGL-prefixed versions of Native*Type are the same
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
*
* Khronos STRONGLY RECOMMENDS that you use the default definitions
* provided below, since these changes affect both binary and source
* portability of applications using EGL running on different EGL
* implementations.
*/
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
typedef int EGLNativeDisplayType;
typedef void *EGLNativeWindowType;
typedef void *EGLNativePixmapType;
#elif defined(__unix__)
/* X11 (tentative) */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;
#else
#error "Platform not recognized"
#endif
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
typedef EGLNativeDisplayType NativeDisplayType;
typedef EGLNativePixmapType NativePixmapType;
typedef EGLNativeWindowType NativeWindowType;
/* Define EGLint. This must be a signed integral type large enough to contain
* all legal attribute names and values passed into and out of EGL, whether
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
* handle, or other. While in general a 32-bit integer will suffice, if
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
* integer type.
*/
typedef khronos_int32_t EGLint;
#endif /* __eglplatform_h */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,353 @@
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. 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 including the dates of first publication and
* either this permission notice or a reference to
* http://oss.sgi.com/projects/FreeB/
* 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
* SILICON GRAPHICS, INC. 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.
*
* Except as contained in this notice, the name of Silicon Graphics, Inc.
* shall not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization from
* Silicon Graphics, Inc.
*/
#ifndef __glu_h__
#define __glu_h__
#if defined(USE_MGL_NAMESPACE)
#include "glu_mangle.h"
#endif
#include <GL/gl.h>
#ifndef GLAPIENTRY
#if defined(_MSC_VER) || defined(__MINGW32__)
#define GLAPIENTRY __stdcall
#else
#define GLAPIENTRY
#endif
#endif
#ifndef GLAPIENTRYP
#define GLAPIENTRYP GLAPIENTRY *
#endif
#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
# undef GLAPI
# define GLAPI __declspec(dllexport)
#elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL)
/* tag specifying we're building for DLL runtime support */
# undef GLAPI
# define GLAPI __declspec(dllimport)
#elif !defined(GLAPI)
/* for use with static link lib build of Win32 edition only */
# define GLAPI extern
#endif /* _STATIC_MESA support */
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************/
/* Extensions */
#define GLU_EXT_object_space_tess 1
#define GLU_EXT_nurbs_tessellator 1
/* Boolean */
#define GLU_FALSE 0
#define GLU_TRUE 1
/* Version */
#define GLU_VERSION_1_1 1
#define GLU_VERSION_1_2 1
#define GLU_VERSION_1_3 1
/* StringName */
#define GLU_VERSION 100800
#define GLU_EXTENSIONS 100801
/* ErrorCode */
#define GLU_INVALID_ENUM 100900
#define GLU_INVALID_VALUE 100901
#define GLU_OUT_OF_MEMORY 100902
#define GLU_INCOMPATIBLE_GL_VERSION 100903
#define GLU_INVALID_OPERATION 100904
/* NurbsDisplay */
/* GLU_FILL */
#define GLU_OUTLINE_POLYGON 100240
#define GLU_OUTLINE_PATCH 100241
/* NurbsCallback */
#define GLU_NURBS_ERROR 100103
#define GLU_ERROR 100103
#define GLU_NURBS_BEGIN 100164
#define GLU_NURBS_BEGIN_EXT 100164
#define GLU_NURBS_VERTEX 100165
#define GLU_NURBS_VERTEX_EXT 100165
#define GLU_NURBS_NORMAL 100166
#define GLU_NURBS_NORMAL_EXT 100166
#define GLU_NURBS_COLOR 100167
#define GLU_NURBS_COLOR_EXT 100167
#define GLU_NURBS_TEXTURE_COORD 100168
#define GLU_NURBS_TEX_COORD_EXT 100168
#define GLU_NURBS_END 100169
#define GLU_NURBS_END_EXT 100169
#define GLU_NURBS_BEGIN_DATA 100170
#define GLU_NURBS_BEGIN_DATA_EXT 100170
#define GLU_NURBS_VERTEX_DATA 100171
#define GLU_NURBS_VERTEX_DATA_EXT 100171
#define GLU_NURBS_NORMAL_DATA 100172
#define GLU_NURBS_NORMAL_DATA_EXT 100172
#define GLU_NURBS_COLOR_DATA 100173
#define GLU_NURBS_COLOR_DATA_EXT 100173
#define GLU_NURBS_TEXTURE_COORD_DATA 100174
#define GLU_NURBS_TEX_COORD_DATA_EXT 100174
#define GLU_NURBS_END_DATA 100175
#define GLU_NURBS_END_DATA_EXT 100175
/* NurbsError */
#define GLU_NURBS_ERROR1 100251
#define GLU_NURBS_ERROR2 100252
#define GLU_NURBS_ERROR3 100253
#define GLU_NURBS_ERROR4 100254
#define GLU_NURBS_ERROR5 100255
#define GLU_NURBS_ERROR6 100256
#define GLU_NURBS_ERROR7 100257
#define GLU_NURBS_ERROR8 100258
#define GLU_NURBS_ERROR9 100259
#define GLU_NURBS_ERROR10 100260
#define GLU_NURBS_ERROR11 100261
#define GLU_NURBS_ERROR12 100262
#define GLU_NURBS_ERROR13 100263
#define GLU_NURBS_ERROR14 100264
#define GLU_NURBS_ERROR15 100265
#define GLU_NURBS_ERROR16 100266
#define GLU_NURBS_ERROR17 100267
#define GLU_NURBS_ERROR18 100268
#define GLU_NURBS_ERROR19 100269
#define GLU_NURBS_ERROR20 100270
#define GLU_NURBS_ERROR21 100271
#define GLU_NURBS_ERROR22 100272
#define GLU_NURBS_ERROR23 100273
#define GLU_NURBS_ERROR24 100274
#define GLU_NURBS_ERROR25 100275
#define GLU_NURBS_ERROR26 100276
#define GLU_NURBS_ERROR27 100277
#define GLU_NURBS_ERROR28 100278
#define GLU_NURBS_ERROR29 100279
#define GLU_NURBS_ERROR30 100280
#define GLU_NURBS_ERROR31 100281
#define GLU_NURBS_ERROR32 100282
#define GLU_NURBS_ERROR33 100283
#define GLU_NURBS_ERROR34 100284
#define GLU_NURBS_ERROR35 100285
#define GLU_NURBS_ERROR36 100286
#define GLU_NURBS_ERROR37 100287
/* NurbsProperty */
#define GLU_AUTO_LOAD_MATRIX 100200
#define GLU_CULLING 100201
#define GLU_SAMPLING_TOLERANCE 100203
#define GLU_DISPLAY_MODE 100204
#define GLU_PARAMETRIC_TOLERANCE 100202
#define GLU_SAMPLING_METHOD 100205
#define GLU_U_STEP 100206
#define GLU_V_STEP 100207
#define GLU_NURBS_MODE 100160
#define GLU_NURBS_MODE_EXT 100160
#define GLU_NURBS_TESSELLATOR 100161
#define GLU_NURBS_TESSELLATOR_EXT 100161
#define GLU_NURBS_RENDERER 100162
#define GLU_NURBS_RENDERER_EXT 100162
/* NurbsSampling */
#define GLU_OBJECT_PARAMETRIC_ERROR 100208
#define GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208
#define GLU_OBJECT_PATH_LENGTH 100209
#define GLU_OBJECT_PATH_LENGTH_EXT 100209
#define GLU_PATH_LENGTH 100215
#define GLU_PARAMETRIC_ERROR 100216
#define GLU_DOMAIN_DISTANCE 100217
/* NurbsTrim */
#define GLU_MAP1_TRIM_2 100210
#define GLU_MAP1_TRIM_3 100211
/* QuadricDrawStyle */
#define GLU_POINT 100010
#define GLU_LINE 100011
#define GLU_FILL 100012
#define GLU_SILHOUETTE 100013
/* QuadricCallback */
/* GLU_ERROR */
/* QuadricNormal */
#define GLU_SMOOTH 100000
#define GLU_FLAT 100001
#define GLU_NONE 100002
/* QuadricOrientation */
#define GLU_OUTSIDE 100020
#define GLU_INSIDE 100021
/* TessCallback */
#define GLU_TESS_BEGIN 100100
#define GLU_BEGIN 100100
#define GLU_TESS_VERTEX 100101
#define GLU_VERTEX 100101
#define GLU_TESS_END 100102
#define GLU_END 100102
#define GLU_TESS_ERROR 100103
#define GLU_TESS_EDGE_FLAG 100104
#define GLU_EDGE_FLAG 100104
#define GLU_TESS_COMBINE 100105
#define GLU_TESS_BEGIN_DATA 100106
#define GLU_TESS_VERTEX_DATA 100107
#define GLU_TESS_END_DATA 100108
#define GLU_TESS_ERROR_DATA 100109
#define GLU_TESS_EDGE_FLAG_DATA 100110
#define GLU_TESS_COMBINE_DATA 100111
/* TessContour */
#define GLU_CW 100120
#define GLU_CCW 100121
#define GLU_INTERIOR 100122
#define GLU_EXTERIOR 100123
#define GLU_UNKNOWN 100124
/* TessProperty */
#define GLU_TESS_WINDING_RULE 100140
#define GLU_TESS_BOUNDARY_ONLY 100141
#define GLU_TESS_TOLERANCE 100142
/* TessError */
#define GLU_TESS_ERROR1 100151
#define GLU_TESS_ERROR2 100152
#define GLU_TESS_ERROR3 100153
#define GLU_TESS_ERROR4 100154
#define GLU_TESS_ERROR5 100155
#define GLU_TESS_ERROR6 100156
#define GLU_TESS_ERROR7 100157
#define GLU_TESS_ERROR8 100158
#define GLU_TESS_MISSING_BEGIN_POLYGON 100151
#define GLU_TESS_MISSING_BEGIN_CONTOUR 100152
#define GLU_TESS_MISSING_END_POLYGON 100153
#define GLU_TESS_MISSING_END_CONTOUR 100154
#define GLU_TESS_COORD_TOO_LARGE 100155
#define GLU_TESS_NEED_COMBINE_CALLBACK 100156
/* TessWinding */
#define GLU_TESS_WINDING_ODD 100130
#define GLU_TESS_WINDING_NONZERO 100131
#define GLU_TESS_WINDING_POSITIVE 100132
#define GLU_TESS_WINDING_NEGATIVE 100133
#define GLU_TESS_WINDING_ABS_GEQ_TWO 100134
/*************************************************************/
#ifdef __cplusplus
class GLUnurbs;
class GLUquadric;
class GLUtesselator;
#else
typedef struct GLUnurbs GLUnurbs;
typedef struct GLUquadric GLUquadric;
typedef struct GLUtesselator GLUtesselator;
#endif
typedef GLUnurbs GLUnurbsObj;
typedef GLUquadric GLUquadricObj;
typedef GLUtesselator GLUtesselatorObj;
typedef GLUtesselator GLUtriangulatorObj;
#define GLU_TESS_MAX_COORD 1.0e150
/* Internal convenience typedefs */
typedef void (GLAPIENTRYP _GLUfuncptr)(void);
GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb);
GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess);
GLAPI void GLAPIENTRY gluBeginSurface (GLUnurbs* nurb);
GLAPI void GLAPIENTRY gluBeginTrim (GLUnurbs* nurb);
GLAPI GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
GLAPI GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data);
GLAPI GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
GLAPI GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
GLAPI GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
GLAPI GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
GLAPI GLboolean GLAPIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString);
GLAPI void GLAPIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks);
GLAPI void GLAPIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb);
GLAPI void GLAPIENTRY gluDeleteQuadric (GLUquadric* quad);
GLAPI void GLAPIENTRY gluDeleteTess (GLUtesselator* tess);
GLAPI void GLAPIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops);
GLAPI void GLAPIENTRY gluEndCurve (GLUnurbs* nurb);
GLAPI void GLAPIENTRY gluEndPolygon (GLUtesselator* tess);
GLAPI void GLAPIENTRY gluEndSurface (GLUnurbs* nurb);
GLAPI void GLAPIENTRY gluEndTrim (GLUnurbs* nurb);
GLAPI const GLubyte * GLAPIENTRY gluErrorString (GLenum error);
GLAPI void GLAPIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data);
GLAPI const GLubyte * GLAPIENTRY gluGetString (GLenum name);
GLAPI void GLAPIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data);
GLAPI void GLAPIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view);
GLAPI void GLAPIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ);
GLAPI GLUnurbs* GLAPIENTRY gluNewNurbsRenderer (void);
GLAPI GLUquadric* GLAPIENTRY gluNewQuadric (void);
GLAPI GLUtesselator* GLAPIENTRY gluNewTess (void);
GLAPI void GLAPIENTRY gluNextContour (GLUtesselator* tess, GLenum type);
GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
GLAPI void GLAPIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData);
GLAPI void GLAPIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData);
GLAPI void GLAPIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type);
GLAPI void GLAPIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value);
GLAPI void GLAPIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type);
GLAPI void GLAPIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
GLAPI void GLAPIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep);
GLAPI void GLAPIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
GLAPI void GLAPIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport);
GLAPI GLint GLAPIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ);
GLAPI void GLAPIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type);
GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
GLAPI void GLAPIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw);
GLAPI void GLAPIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal);
GLAPI void GLAPIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation);
GLAPI void GLAPIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture);
GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut);
GLAPI void GLAPIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks);
GLAPI void GLAPIENTRY gluTessBeginContour (GLUtesselator* tess);
GLAPI void GLAPIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data);
GLAPI void GLAPIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
GLAPI void GLAPIENTRY gluTessEndContour (GLUtesselator* tess);
GLAPI void GLAPIENTRY gluTessEndPolygon (GLUtesselator* tess);
GLAPI void GLAPIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
GLAPI void GLAPIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data);
GLAPI void GLAPIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data);
GLAPI GLint GLAPIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ);
GLAPI GLint GLAPIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW);
#ifdef __cplusplus
}
#endif
#endif /* __glu_h__ */

View File

@@ -0,0 +1,86 @@
/*
* Mesa 3-D graphics library
* Version: 3.0
* Copyright (C) 1995-1998 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef GLU_MANGLE_H
#define GLU_MANGLE_H
#define gluLookAt mgluLookAt
#define gluOrtho2D mgluOrtho2D
#define gluPerspective mgluPerspective
#define gluPickMatrix mgluPickMatrix
#define gluProject mgluProject
#define gluUnProject mgluUnProject
#define gluErrorString mgluErrorString
#define gluScaleImage mgluScaleImage
#define gluBuild1DMipmaps mgluBuild1DMipmaps
#define gluBuild2DMipmaps mgluBuild2DMipmaps
#define gluNewQuadric mgluNewQuadric
#define gluDeleteQuadric mgluDeleteQuadric
#define gluQuadricDrawStyle mgluQuadricDrawStyle
#define gluQuadricOrientation mgluQuadricOrientation
#define gluQuadricNormals mgluQuadricNormals
#define gluQuadricTexture mgluQuadricTexture
#define gluQuadricCallback mgluQuadricCallback
#define gluCylinder mgluCylinder
#define gluSphere mgluSphere
#define gluDisk mgluDisk
#define gluPartialDisk mgluPartialDisk
#define gluNewNurbsRenderer mgluNewNurbsRenderer
#define gluDeleteNurbsRenderer mgluDeleteNurbsRenderer
#define gluLoadSamplingMatrices mgluLoadSamplingMatrices
#define gluNurbsProperty mgluNurbsProperty
#define gluGetNurbsProperty mgluGetNurbsProperty
#define gluBeginCurve mgluBeginCurve
#define gluEndCurve mgluEndCurve
#define gluNurbsCurve mgluNurbsCurve
#define gluBeginSurface mgluBeginSurface
#define gluEndSurface mgluEndSurface
#define gluNurbsSurface mgluNurbsSurface
#define gluBeginTrim mgluBeginTrim
#define gluEndTrim mgluEndTrim
#define gluPwlCurve mgluPwlCurve
#define gluNurbsCallback mgluNurbsCallback
#define gluNewTess mgluNewTess
#define gluDeleteTess mgluDeleteTess
#define gluTessBeginPolygon mgluTessBeginPolygon
#define gluTessBeginContour mgluTessBeginContour
#define gluTessVertex mgluTessVertex
#define gluTessEndPolygon mgluTessEndPolygon
#define gluTessEndContour mgluTessEndContour
#define gluTessProperty mgluTessProperty
#define gluTessNormal mgluTessNormal
#define gluTessCallback mgluTessCallback
#define gluGetTessProperty mgluGetTessProperty
#define gluBeginPolygon mgluBeginPolygon
#define gluNextContour mgluNextContour
#define gluEndPolygon mgluEndPolygon
#define gluGetString mgluGetString
#define gluBuild1DMipmapLevels mgluBuild1DMipmapLevels
#define gluBuild2DMipmapLevels mgluBuild2DMipmapLevels
#define gluBuild3DMipmapLevels mgluBuild3DMipmapLevels
#define gluBuild3DMipmaps mgluBuild3DMipmaps
#define gluCheckExtension mgluCheckExtension
#define gluUnProject4 mgluUnProject4
#define gluNurbsCallbackData mgluNurbsCallbackData
#define gluNurbsCallbackDataEXT mgluNurbsCallbackDataEXT
#endif

View File

@@ -0,0 +1,526 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 1999-2006 Brian Paul 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
* BRIAN PAUL 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.
*/
#ifndef GLX_H
#define GLX_H
#ifdef __VMS
#include <GL/vms_x_fix.h>
# ifdef __cplusplus
/* VMS Xlib.h gives problems with C++.
* this avoids a bunch of trivial warnings */
#pragma message disable nosimpint
#endif
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef __VMS
# ifdef __cplusplus
#pragma message enable nosimpint
#endif
#endif
#include <GL/gl.h>
#if defined(USE_MGL_NAMESPACE)
#include "glx_mangle.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define GLX_VERSION_1_1 1
#define GLX_VERSION_1_2 1
#define GLX_VERSION_1_3 1
#define GLX_VERSION_1_4 1
#define GLX_EXTENSION_NAME "GLX"
/*
* Tokens for glXChooseVisual and glXGetConfig:
*/
#define GLX_USE_GL 1
#define GLX_BUFFER_SIZE 2
#define GLX_LEVEL 3
#define GLX_RGBA 4
#define GLX_DOUBLEBUFFER 5
#define GLX_STEREO 6
#define GLX_AUX_BUFFERS 7
#define GLX_RED_SIZE 8
#define GLX_GREEN_SIZE 9
#define GLX_BLUE_SIZE 10
#define GLX_ALPHA_SIZE 11
#define GLX_DEPTH_SIZE 12
#define GLX_STENCIL_SIZE 13
#define GLX_ACCUM_RED_SIZE 14
#define GLX_ACCUM_GREEN_SIZE 15
#define GLX_ACCUM_BLUE_SIZE 16
#define GLX_ACCUM_ALPHA_SIZE 17
/*
* Error codes returned by glXGetConfig:
*/
#define GLX_BAD_SCREEN 1
#define GLX_BAD_ATTRIBUTE 2
#define GLX_NO_EXTENSION 3
#define GLX_BAD_VISUAL 4
#define GLX_BAD_CONTEXT 5
#define GLX_BAD_VALUE 6
#define GLX_BAD_ENUM 7
/*
* GLX 1.1 and later:
*/
#define GLX_VENDOR 1
#define GLX_VERSION 2
#define GLX_EXTENSIONS 3
/*
* GLX 1.3 and later:
*/
#define GLX_CONFIG_CAVEAT 0x20
#define GLX_DONT_CARE 0xFFFFFFFF
#define GLX_X_VISUAL_TYPE 0x22
#define GLX_TRANSPARENT_TYPE 0x23
#define GLX_TRANSPARENT_INDEX_VALUE 0x24
#define GLX_TRANSPARENT_RED_VALUE 0x25
#define GLX_TRANSPARENT_GREEN_VALUE 0x26
#define GLX_TRANSPARENT_BLUE_VALUE 0x27
#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
#define GLX_WINDOW_BIT 0x00000001
#define GLX_PIXMAP_BIT 0x00000002
#define GLX_PBUFFER_BIT 0x00000004
#define GLX_AUX_BUFFERS_BIT 0x00000010
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
#define GLX_DEPTH_BUFFER_BIT 0x00000020
#define GLX_STENCIL_BUFFER_BIT 0x00000040
#define GLX_ACCUM_BUFFER_BIT 0x00000080
#define GLX_NONE 0x8000
#define GLX_SLOW_CONFIG 0x8001
#define GLX_TRUE_COLOR 0x8002
#define GLX_DIRECT_COLOR 0x8003
#define GLX_PSEUDO_COLOR 0x8004
#define GLX_STATIC_COLOR 0x8005
#define GLX_GRAY_SCALE 0x8006
#define GLX_STATIC_GRAY 0x8007
#define GLX_TRANSPARENT_RGB 0x8008
#define GLX_TRANSPARENT_INDEX 0x8009
#define GLX_VISUAL_ID 0x800B
#define GLX_SCREEN 0x800C
#define GLX_NON_CONFORMANT_CONFIG 0x800D
#define GLX_DRAWABLE_TYPE 0x8010
#define GLX_RENDER_TYPE 0x8011
#define GLX_X_RENDERABLE 0x8012
#define GLX_FBCONFIG_ID 0x8013
#define GLX_RGBA_TYPE 0x8014
#define GLX_COLOR_INDEX_TYPE 0x8015
#define GLX_MAX_PBUFFER_WIDTH 0x8016
#define GLX_MAX_PBUFFER_HEIGHT 0x8017
#define GLX_MAX_PBUFFER_PIXELS 0x8018
#define GLX_PRESERVED_CONTENTS 0x801B
#define GLX_LARGEST_PBUFFER 0x801C
#define GLX_WIDTH 0x801D
#define GLX_HEIGHT 0x801E
#define GLX_EVENT_MASK 0x801F
#define GLX_DAMAGED 0x8020
#define GLX_SAVED 0x8021
#define GLX_WINDOW 0x8022
#define GLX_PBUFFER 0x8023
#define GLX_PBUFFER_HEIGHT 0x8040
#define GLX_PBUFFER_WIDTH 0x8041
#define GLX_RGBA_BIT 0x00000001
#define GLX_COLOR_INDEX_BIT 0x00000002
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
/*
* GLX 1.4 and later:
*/
#define GLX_SAMPLE_BUFFERS 0x186a0 /*100000*/
#define GLX_SAMPLES 0x186a1 /*100001*/
typedef struct __GLXcontextRec *GLXContext;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
/* GLX 1.3 and later */
typedef struct __GLXFBConfigRec *GLXFBConfig;
typedef XID GLXFBConfigID;
typedef XID GLXContextID;
typedef XID GLXWindow;
typedef XID GLXPbuffer;
/*
** Events.
** __GLX_NUMBER_EVENTS is set to 17 to account for the BufferClobberSGIX
** event - this helps initialization if the server supports the pbuffer
** extension and the client doesn't.
*/
#define GLX_PbufferClobber 0
#define GLX_BufferSwapComplete 1
#define __GLX_NUMBER_EVENTS 17
extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
int *attribList );
extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
GLXContext shareList, Bool direct );
extern void glXDestroyContext( Display *dpy, GLXContext ctx );
extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
GLXContext ctx);
extern void glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
unsigned long mask );
extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
extern GLXPixmap glXCreateGLXPixmap( Display *dpy, XVisualInfo *visual,
Pixmap pixmap );
extern void glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
extern Bool glXQueryExtension( Display *dpy, int *errorb, int *event );
extern Bool glXQueryVersion( Display *dpy, int *maj, int *min );
extern Bool glXIsDirect( Display *dpy, GLXContext ctx );
extern int glXGetConfig( Display *dpy, XVisualInfo *visual,
int attrib, int *value );
extern GLXContext glXGetCurrentContext( void );
extern GLXDrawable glXGetCurrentDrawable( void );
extern void glXWaitGL( void );
extern void glXWaitX( void );
extern void glXUseXFont( Font font, int first, int count, int list );
/* GLX 1.1 and later */
extern const char *glXQueryExtensionsString( Display *dpy, int screen );
extern const char *glXQueryServerString( Display *dpy, int screen, int name );
extern const char *glXGetClientString( Display *dpy, int name );
/* GLX 1.2 and later */
extern Display *glXGetCurrentDisplay( void );
/* GLX 1.3 and later */
extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
const int *attribList, int *nitems );
extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
int attribute, int *value );
extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
int *nelements );
extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
GLXFBConfig config );
extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config,
Window win, const int *attribList );
extern void glXDestroyWindow( Display *dpy, GLXWindow window );
extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config,
Pixmap pixmap, const int *attribList );
extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
const int *attribList );
extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
unsigned int *value );
extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config,
int renderType, GLXContext shareList,
Bool direct );
extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
GLXDrawable read, GLXContext ctx );
extern GLXDrawable glXGetCurrentReadDrawable( void );
extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute,
int *value );
extern void glXSelectEvent( Display *dpy, GLXDrawable drawable,
unsigned long mask );
extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
unsigned long *mask );
/* GLX 1.3 function pointer typedefs */
typedef GLXFBConfig * (* PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
typedef GLXFBConfig * (* PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
typedef int (* PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
typedef XVisualInfo * (* PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
typedef GLXWindow (* PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
typedef void (* PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
typedef GLXPixmap (* PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
typedef void (* PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
typedef GLXPbuffer (* PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
typedef void (* PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
typedef void (* PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
typedef GLXContext (* PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
typedef Bool (* PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
typedef GLXDrawable (* PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
typedef Display * (* PFNGLXGETCURRENTDISPLAYPROC) (void);
typedef int (* PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
typedef void (* PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
typedef void (* PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
/*
* ARB 2. GLX_ARB_get_proc_address
*/
#ifndef GLX_ARB_get_proc_address
#define GLX_ARB_get_proc_address 1
typedef void (*__GLXextFuncPtr)(void);
extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
#endif /* GLX_ARB_get_proc_address */
/* GLX 1.4 and later */
extern void (*glXGetProcAddress(const GLubyte *procname))( void );
/* GLX 1.4 function pointer typedefs */
typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
#ifndef GLX_GLXEXT_LEGACY
#include <GL/glxext.h>
#endif /* GLX_GLXEXT_LEGACY */
/**
** The following aren't in glxext.h yet.
**/
/*
* ???. GLX_NV_vertex_array_range
*/
#ifndef GLX_NV_vertex_array_range
#define GLX_NV_vertex_array_range
extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
extern void glXFreeMemoryNV(GLvoid *pointer);
typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer);
#endif /* GLX_NV_vertex_array_range */
/*
* ARB ?. GLX_ARB_render_texture
* XXX This was never finalized!
*/
#ifndef GLX_ARB_render_texture
#define GLX_ARB_render_texture 1
extern Bool glXBindTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
extern Bool glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attribList);
#endif /* GLX_ARB_render_texture */
/*
* Remove this when glxext.h is updated.
*/
#ifndef GLX_NV_float_buffer
#define GLX_NV_float_buffer 1
#define GLX_FLOAT_COMPONENTS_NV 0x20B0
#endif /* GLX_NV_float_buffer */
/*
* #?. GLX_MESA_swap_frame_usage
*/
#ifndef GLX_MESA_swap_frame_usage
#define GLX_MESA_swap_frame_usage 1
extern int glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, float *usage);
extern int glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
extern int glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable);
extern int glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
typedef int (*PFNGLXGETFRAMEUSAGEMESAPROC) (Display *dpy, GLXDrawable drawable, float *usage);
typedef int (*PFNGLXBEGINFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
typedef int (*PFNGLXENDFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable);
typedef int (*PFNGLXQUERYFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage);
#endif /* GLX_MESA_swap_frame_usage */
/*
* #?. GLX_MESA_swap_control
*/
#ifndef GLX_MESA_swap_control
#define GLX_MESA_swap_control 1
extern int glXSwapIntervalMESA(unsigned int interval);
extern int glXGetSwapIntervalMESA(void);
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval);
typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
#endif /* GLX_MESA_swap_control */
/*
* #?. GLX_EXT_texture_from_pixmap
* XXX not finished?
*/
#ifndef GLX_EXT_texture_from_pixmap
#define GLX_EXT_texture_from_pixmap 1
#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
#define GLX_Y_INVERTED_EXT 0x20D4
#define GLX_TEXTURE_FORMAT_EXT 0x20D5
#define GLX_TEXTURE_TARGET_EXT 0x20D6
#define GLX_MIPMAP_TEXTURE_EXT 0x20D7
#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
#define GLX_TEXTURE_1D_BIT_EXT 0x00000001
#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
#define GLX_TEXTURE_1D_EXT 0x20DB
#define GLX_TEXTURE_2D_EXT 0x20DC
#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
#define GLX_FRONT_LEFT_EXT 0x20DE
#define GLX_FRONT_RIGHT_EXT 0x20DF
#define GLX_BACK_LEFT_EXT 0x20E0
#define GLX_BACK_RIGHT_EXT 0x20E1
#define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT
#define GLX_BACK_EXT GLX_BACK_LEFT_EXT
#define GLX_AUX0_EXT 0x20E2
#define GLX_AUX1_EXT 0x20E3
#define GLX_AUX2_EXT 0x20E4
#define GLX_AUX3_EXT 0x20E5
#define GLX_AUX4_EXT 0x20E6
#define GLX_AUX5_EXT 0x20E7
#define GLX_AUX6_EXT 0x20E8
#define GLX_AUX7_EXT 0x20E9
#define GLX_AUX8_EXT 0x20EA
#define GLX_AUX9_EXT 0x20EB
extern void glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
extern void glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer);
#endif /* GLX_EXT_texture_from_pixmap */
/*** Should these go here, or in another header? */
/*
** GLX Events
*/
typedef struct {
int event_type; /* GLX_DAMAGED or GLX_SAVED */
int draw_type; /* GLX_WINDOW or GLX_PBUFFER */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came for SendEvent request */
Display *display; /* display the event was read from */
GLXDrawable drawable; /* XID of Drawable */
unsigned int buffer_mask; /* mask indicating which buffers are affected */
unsigned int aux_buffer; /* which aux buffer was affected */
int x, y;
int width, height;
int count; /* if nonzero, at least this many more */
} GLXPbufferClobberEvent;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
GLXDrawable drawable; /* drawable on which event was requested in event mask */
int event_type;
int64_t ust;
int64_t msc;
int64_t sbc;
} GLXBufferSwapComplete;
typedef union __GLXEvent {
GLXPbufferClobberEvent glxpbufferclobber;
GLXBufferSwapComplete glxbufferswapcomplete;
long pad[24];
} GLXEvent;
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,82 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 1999-2006 Brian Paul 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
* BRIAN PAUL 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.
*/
#ifndef GLX_MANGLE_H
#define GLX_MANGLE_H
#define glXChooseVisual mglXChooseVisual
#define glXCreateContext mglXCreateContext
#define glXDestroyContext mglXDestroyContext
#define glXMakeCurrent mglXMakeCurrent
#define glXCopyContext mglXCopyContext
#define glXSwapBuffers mglXSwapBuffers
#define glXCreateGLXPixmap mglXCreateGLXPixmap
#define glXDestroyGLXPixmap mglXDestroyGLXPixmap
#define glXQueryExtension mglXQueryExtension
#define glXQueryVersion mglXQueryVersion
#define glXIsDirect mglXIsDirect
#define glXGetConfig mglXGetConfig
#define glXGetCurrentContext mglXGetCurrentContext
#define glXGetCurrentDrawable mglXGetCurrentDrawable
#define glXWaitGL mglXWaitGL
#define glXWaitX mglXWaitX
#define glXUseXFont mglXUseXFont
#define glXQueryExtensionsString mglXQueryExtensionsString
#define glXQueryServerString mglXQueryServerString
#define glXGetClientString mglXGetClientString
#define glXCreateGLXPixmapMESA mglXCreateGLXPixmapMESA
#define glXReleaseBuffersMESA mglXReleaseBuffersMESA
#define glXCopySubBufferMESA mglXCopySubBufferMESA
#define glXGetVideoSyncSGI mglXGetVideoSyncSGI
#define glXWaitVideoSyncSGI mglXWaitVideoSyncSGI
/* GLX 1.2 */
#define glXGetCurrentDisplay mglXGetCurrentDisplay
/* GLX 1.3 */
#define glXChooseFBConfig mglXChooseFBConfig
#define glXGetFBConfigAttrib mglXGetFBConfigAttrib
#define glXGetFBConfigs mglXGetFBConfigs
#define glXGetVisualFromFBConfig mglXGetVisualFromFBConfig
#define glXCreateWindow mglXCreateWindow
#define glXDestroyWindow mglXDestroyWindow
#define glXCreatePixmap mglXCreatePixmap
#define glXDestroyPixmap mglXDestroyPixmap
#define glXCreatePbuffer mglXCreatePbuffer
#define glXDestroyPbuffer mglXDestroyPbuffer
#define glXQueryDrawable mglXQueryDrawable
#define glXCreateNewContext mglXCreateNewContext
#define glXMakeContextCurrent mglXMakeContextCurrent
#define glXGetCurrentReadDrawable mglXGetCurrentReadDrawable
#define glXQueryContext mglXQueryContext
#define glXSelectEvent mglXSelectEvent
#define glXGetSelectedEvent mglXGetSelectedEvent
/* GLX 1.4 */
#define glXGetProcAddress mglXGetProcAddress
#define glXGetProcAddressARB mglXGetProcAddressARB
#endif

View File

@@ -0,0 +1,993 @@
#ifndef __glxext_h_
#define __glxext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007-2010 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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 THE AUTHORS OR COPYRIGHT HOLDERS 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Function declaration macros - to move into glplatform.h */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
/*************************************************************/
/* Header file version number, required by OpenGL ABI for Linux */
/* glxext.h last updated 2010/08/06 */
/* Current version at http://www.opengl.org/registry/ */
#define GLX_GLXEXT_VERSION 32
#ifndef GLX_VERSION_1_3
#define GLX_WINDOW_BIT 0x00000001
#define GLX_PIXMAP_BIT 0x00000002
#define GLX_PBUFFER_BIT 0x00000004
#define GLX_RGBA_BIT 0x00000001
#define GLX_COLOR_INDEX_BIT 0x00000002
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
#define GLX_AUX_BUFFERS_BIT 0x00000010
#define GLX_DEPTH_BUFFER_BIT 0x00000020
#define GLX_STENCIL_BUFFER_BIT 0x00000040
#define GLX_ACCUM_BUFFER_BIT 0x00000080
#define GLX_CONFIG_CAVEAT 0x20
#define GLX_X_VISUAL_TYPE 0x22
#define GLX_TRANSPARENT_TYPE 0x23
#define GLX_TRANSPARENT_INDEX_VALUE 0x24
#define GLX_TRANSPARENT_RED_VALUE 0x25
#define GLX_TRANSPARENT_GREEN_VALUE 0x26
#define GLX_TRANSPARENT_BLUE_VALUE 0x27
#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
#define GLX_DONT_CARE 0xFFFFFFFF
#define GLX_NONE 0x8000
#define GLX_SLOW_CONFIG 0x8001
#define GLX_TRUE_COLOR 0x8002
#define GLX_DIRECT_COLOR 0x8003
#define GLX_PSEUDO_COLOR 0x8004
#define GLX_STATIC_COLOR 0x8005
#define GLX_GRAY_SCALE 0x8006
#define GLX_STATIC_GRAY 0x8007
#define GLX_TRANSPARENT_RGB 0x8008
#define GLX_TRANSPARENT_INDEX 0x8009
#define GLX_VISUAL_ID 0x800B
#define GLX_SCREEN 0x800C
#define GLX_NON_CONFORMANT_CONFIG 0x800D
#define GLX_DRAWABLE_TYPE 0x8010
#define GLX_RENDER_TYPE 0x8011
#define GLX_X_RENDERABLE 0x8012
#define GLX_FBCONFIG_ID 0x8013
#define GLX_RGBA_TYPE 0x8014
#define GLX_COLOR_INDEX_TYPE 0x8015
#define GLX_MAX_PBUFFER_WIDTH 0x8016
#define GLX_MAX_PBUFFER_HEIGHT 0x8017
#define GLX_MAX_PBUFFER_PIXELS 0x8018
#define GLX_PRESERVED_CONTENTS 0x801B
#define GLX_LARGEST_PBUFFER 0x801C
#define GLX_WIDTH 0x801D
#define GLX_HEIGHT 0x801E
#define GLX_EVENT_MASK 0x801F
#define GLX_DAMAGED 0x8020
#define GLX_SAVED 0x8021
#define GLX_WINDOW 0x8022
#define GLX_PBUFFER 0x8023
#define GLX_PBUFFER_HEIGHT 0x8040
#define GLX_PBUFFER_WIDTH 0x8041
#endif
#ifndef GLX_VERSION_1_4
#define GLX_SAMPLE_BUFFERS 100000
#define GLX_SAMPLES 100001
#endif
#ifndef GLX_ARB_get_proc_address
#endif
#ifndef GLX_ARB_multisample
#define GLX_SAMPLE_BUFFERS_ARB 100000
#define GLX_SAMPLES_ARB 100001
#endif
#ifndef GLX_ARB_vertex_buffer_object
#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095
#endif
#ifndef GLX_ARB_fbconfig_float
#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9
#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004
#endif
#ifndef GLX_ARB_framebuffer_sRGB
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2
#endif
#ifndef GLX_ARB_create_context
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
#define GLX_CONTEXT_FLAGS_ARB 0x2094
#endif
#ifndef GLX_ARB_create_context_profile
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
#endif
#ifndef GLX_ARB_create_context_robustness
#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
#endif
#ifndef GLX_SGIS_multisample
#define GLX_SAMPLE_BUFFERS_SGIS 100000
#define GLX_SAMPLES_SGIS 100001
#endif
#ifndef GLX_EXT_visual_info
#define GLX_X_VISUAL_TYPE_EXT 0x22
#define GLX_TRANSPARENT_TYPE_EXT 0x23
#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24
#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25
#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26
#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27
#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28
#define GLX_NONE_EXT 0x8000
#define GLX_TRUE_COLOR_EXT 0x8002
#define GLX_DIRECT_COLOR_EXT 0x8003
#define GLX_PSEUDO_COLOR_EXT 0x8004
#define GLX_STATIC_COLOR_EXT 0x8005
#define GLX_GRAY_SCALE_EXT 0x8006
#define GLX_STATIC_GRAY_EXT 0x8007
#define GLX_TRANSPARENT_RGB_EXT 0x8008
#define GLX_TRANSPARENT_INDEX_EXT 0x8009
#endif
#ifndef GLX_SGI_swap_control
#endif
#ifndef GLX_SGI_video_sync
#endif
#ifndef GLX_SGI_make_current_read
#endif
#ifndef GLX_SGIX_video_source
#endif
#ifndef GLX_EXT_visual_rating
#define GLX_VISUAL_CAVEAT_EXT 0x20
#define GLX_SLOW_VISUAL_EXT 0x8001
#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
/* reuse GLX_NONE_EXT */
#endif
#ifndef GLX_EXT_import_context
#define GLX_SHARE_CONTEXT_EXT 0x800A
#define GLX_VISUAL_ID_EXT 0x800B
#define GLX_SCREEN_EXT 0x800C
#endif
#ifndef GLX_SGIX_fbconfig
#define GLX_WINDOW_BIT_SGIX 0x00000001
#define GLX_PIXMAP_BIT_SGIX 0x00000002
#define GLX_RGBA_BIT_SGIX 0x00000001
#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002
#define GLX_DRAWABLE_TYPE_SGIX 0x8010
#define GLX_RENDER_TYPE_SGIX 0x8011
#define GLX_X_RENDERABLE_SGIX 0x8012
#define GLX_FBCONFIG_ID_SGIX 0x8013
#define GLX_RGBA_TYPE_SGIX 0x8014
#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015
/* reuse GLX_SCREEN_EXT */
#endif
#ifndef GLX_SGIX_pbuffer
#define GLX_PBUFFER_BIT_SGIX 0x00000004
#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000
#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008
#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010
#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020
#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040
#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080
#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100
#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016
#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017
#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018
#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019
#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A
#define GLX_PRESERVED_CONTENTS_SGIX 0x801B
#define GLX_LARGEST_PBUFFER_SGIX 0x801C
#define GLX_WIDTH_SGIX 0x801D
#define GLX_HEIGHT_SGIX 0x801E
#define GLX_EVENT_MASK_SGIX 0x801F
#define GLX_DAMAGED_SGIX 0x8020
#define GLX_SAVED_SGIX 0x8021
#define GLX_WINDOW_SGIX 0x8022
#define GLX_PBUFFER_SGIX 0x8023
#endif
#ifndef GLX_SGI_cushion
#endif
#ifndef GLX_SGIX_video_resize
#define GLX_SYNC_FRAME_SGIX 0x00000000
#define GLX_SYNC_SWAP_SGIX 0x00000001
#endif
#ifndef GLX_SGIX_dmbuffer
#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024
#endif
#ifndef GLX_SGIX_swap_group
#endif
#ifndef GLX_SGIX_swap_barrier
#endif
#ifndef GLX_SGIS_blended_overlay
#define GLX_BLENDED_RGBA_SGIS 0x8025
#endif
#ifndef GLX_SGIS_shared_multisample
#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026
#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027
#endif
#ifndef GLX_SUN_get_transparent_index
#endif
#ifndef GLX_3DFX_multisample
#define GLX_SAMPLE_BUFFERS_3DFX 0x8050
#define GLX_SAMPLES_3DFX 0x8051
#endif
#ifndef GLX_MESA_copy_sub_buffer
#endif
#ifndef GLX_MESA_pixmap_colormap
#endif
#ifndef GLX_MESA_release_buffers
#endif
#ifndef GLX_MESA_set_3dfx_mode
#define GLX_3DFX_WINDOW_MODE_MESA 0x1
#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
#endif
#ifndef GLX_SGIX_visual_select_group
#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028
#endif
#ifndef GLX_OML_swap_method
#define GLX_SWAP_METHOD_OML 0x8060
#define GLX_SWAP_EXCHANGE_OML 0x8061
#define GLX_SWAP_COPY_OML 0x8062
#define GLX_SWAP_UNDEFINED_OML 0x8063
#endif
#ifndef GLX_OML_sync_control
#endif
#ifndef GLX_NV_float_buffer
#define GLX_FLOAT_COMPONENTS_NV 0x20B0
#endif
#ifndef GLX_SGIX_hyperpipe
#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80
#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91
#define GLX_BAD_HYPERPIPE_SGIX 92
#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001
#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002
#define GLX_PIPE_RECT_SGIX 0x00000001
#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002
#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003
#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004
#define GLX_HYPERPIPE_ID_SGIX 0x8030
#endif
#ifndef GLX_MESA_agp_offset
#endif
#ifndef GLX_EXT_fbconfig_packed_float
#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1
#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008
#endif
#ifndef GLX_EXT_framebuffer_sRGB
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2
#endif
#ifndef GLX_EXT_texture_from_pixmap
#define GLX_TEXTURE_1D_BIT_EXT 0x00000001
#define GLX_TEXTURE_2D_BIT_EXT 0x00000002
#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004
#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0
#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1
#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2
#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3
#define GLX_Y_INVERTED_EXT 0x20D4
#define GLX_TEXTURE_FORMAT_EXT 0x20D5
#define GLX_TEXTURE_TARGET_EXT 0x20D6
#define GLX_MIPMAP_TEXTURE_EXT 0x20D7
#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8
#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9
#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA
#define GLX_TEXTURE_1D_EXT 0x20DB
#define GLX_TEXTURE_2D_EXT 0x20DC
#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD
#define GLX_FRONT_LEFT_EXT 0x20DE
#define GLX_FRONT_RIGHT_EXT 0x20DF
#define GLX_BACK_LEFT_EXT 0x20E0
#define GLX_BACK_RIGHT_EXT 0x20E1
#define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT
#define GLX_BACK_EXT GLX_BACK_LEFT_EXT
#define GLX_AUX0_EXT 0x20E2
#define GLX_AUX1_EXT 0x20E3
#define GLX_AUX2_EXT 0x20E4
#define GLX_AUX3_EXT 0x20E5
#define GLX_AUX4_EXT 0x20E6
#define GLX_AUX5_EXT 0x20E7
#define GLX_AUX6_EXT 0x20E8
#define GLX_AUX7_EXT 0x20E9
#define GLX_AUX8_EXT 0x20EA
#define GLX_AUX9_EXT 0x20EB
#endif
#ifndef GLX_NV_present_video
#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0
#endif
#ifndef GLX_NV_video_out
#define GLX_VIDEO_OUT_COLOR_NV 0x20C3
#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4
#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5
#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
#define GLX_VIDEO_OUT_FRAME_NV 0x20C8
#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9
#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA
#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB
#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC
#endif
#ifndef GLX_NV_swap_group
#endif
#ifndef GLX_NV_video_capture
#define GLX_DEVICE_ID_NV 0x20CD
#define GLX_UNIQUE_ID_NV 0x20CE
#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
#endif
#ifndef GLX_EXT_swap_control
#define GLX_SWAP_INTERVAL_EXT 0x20F1
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
#endif
#ifndef GLX_NV_copy_image
#endif
#ifndef GLX_INTEL_swap_event
#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000
#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180
#define GLX_COPY_COMPLETE_INTEL 0x8181
#define GLX_FLIP_COMPLETE_INTEL 0x8182
#endif
#ifndef GLX_NV_multisample_coverage
#define GLX_COVERAGE_SAMPLES_NV 100001
#define GLX_COLOR_SAMPLES_NV 0x20B3
#endif
#ifndef GLX_AMD_gpu_association
#define GLX_GPU_VENDOR_AMD 0x1F00
#define GLX_GPU_RENDERER_STRING_AMD 0x1F01
#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
#define GLX_GPU_RAM_AMD 0x21A3
#define GLX_GPU_CLOCK_AMD 0x21A4
#define GLX_GPU_NUM_PIPES_AMD 0x21A5
#define GLX_GPU_NUM_SIMD_AMD 0x21A6
#define GLX_GPU_NUM_RB_AMD 0x21A7
#define GLX_GPU_NUM_SPI_AMD 0x21A8
#endif
#ifndef GLX_EXT_create_context_es2_profile
#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
#endif
/*************************************************************/
#ifndef GLX_ARB_get_proc_address
typedef void (*__GLXextFuncPtr)(void);
#endif
#ifndef GLX_SGIX_video_source
typedef XID GLXVideoSourceSGIX;
#endif
#ifndef GLX_SGIX_fbconfig
typedef XID GLXFBConfigIDSGIX;
typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
#endif
#ifndef GLX_SGIX_pbuffer
typedef XID GLXPbufferSGIX;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came for SendEvent request */
Display *display; /* display the event was read from */
GLXDrawable drawable; /* i.d. of Drawable */
int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */
int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */
unsigned int mask; /* mask indicating which buffers are affected*/
int x, y;
int width, height;
int count; /* if nonzero, at least this many more */
} GLXBufferClobberEventSGIX;
#endif
#ifndef GLX_NV_video_output
typedef unsigned int GLXVideoDeviceNV;
#endif
#ifndef GLX_NV_video_capture
typedef XID GLXVideoCaptureDeviceNV;
#endif
#ifndef GLEXT_64_TYPES_DEFINED
/* This code block is duplicated in glext.h, so must be protected */
#define GLEXT_64_TYPES_DEFINED
/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
/* (as used in the GLX_OML_sync_control extension). */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <inttypes.h>
#elif defined(__sun__) || defined(__digital__)
#include <inttypes.h>
#if defined(__STDC__)
#if defined(__arch64__) || defined(_LP64)
typedef long int int64_t;
typedef unsigned long int uint64_t;
#else
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
#endif /* __arch64__ */
#endif /* __STDC__ */
#elif defined( __VMS ) || defined(__sgi)
#include <inttypes.h>
#elif defined(__SCO__) || defined(__USLC__)
#include <stdint.h>
#elif defined(__UNIXOS2__) || defined(__SOL64__)
typedef long int int32_t;
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
#elif defined(_WIN32) && defined(__GNUC__)
#include <stdint.h>
#elif defined(_WIN32)
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <inttypes.h> /* Fallback option */
#endif
#endif
#ifndef GLX_VERSION_1_3
#define GLX_VERSION_1_3 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern GLXFBConfig * glXGetFBConfigs (Display *dpy, int screen, int *nelements);
extern GLXFBConfig * glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements);
extern int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value);
extern XVisualInfo * glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config);
extern GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
extern void glXDestroyWindow (Display *dpy, GLXWindow win);
extern GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
extern void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap);
extern GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list);
extern void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf);
extern void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
extern GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
extern Bool glXMakeContextCurrent (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
extern GLXDrawable glXGetCurrentReadDrawable (void);
extern Display * glXGetCurrentDisplay (void);
extern int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value);
extern void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask);
extern void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void);
typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
#endif
#ifndef GLX_VERSION_1_4
#define GLX_VERSION_1_4 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *procName);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
#endif
#ifndef GLX_ARB_get_proc_address
#define GLX_ARB_get_proc_address 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);
#endif
#ifndef GLX_ARB_multisample
#define GLX_ARB_multisample 1
#endif
#ifndef GLX_ARB_fbconfig_float
#define GLX_ARB_fbconfig_float 1
#endif
#ifndef GLX_ARB_framebuffer_sRGB
#define GLX_ARB_framebuffer_sRGB 1
#endif
#ifndef GLX_ARB_create_context
#define GLX_ARB_create_context 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern GLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
#endif
#ifndef GLX_ARB_create_context_profile
#define GLX_ARB_create_context_profile 1
#endif
#ifndef GLX_ARB_create_context_robustness
#define GLX_ARB_create_context_robustness 1
#endif
#ifndef GLX_SGIS_multisample
#define GLX_SGIS_multisample 1
#endif
#ifndef GLX_EXT_visual_info
#define GLX_EXT_visual_info 1
#endif
#ifndef GLX_SGI_swap_control
#define GLX_SGI_swap_control 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXSwapIntervalSGI (int interval);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
#endif
#ifndef GLX_SGI_video_sync
#define GLX_SGI_video_sync 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXGetVideoSyncSGI (unsigned int *count);
extern int glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count);
typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count);
#endif
#ifndef GLX_SGI_make_current_read
#define GLX_SGI_make_current_read 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXMakeCurrentReadSGI (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
extern GLXDrawable glXGetCurrentReadDrawableSGI (void);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);
#endif
#ifndef GLX_SGIX_video_source
#define GLX_SGIX_video_source 1
#ifdef _VL_H
#ifdef GLX_GLXEXT_PROTOTYPES
extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
extern void glXDestroyGLXVideoSourceSGIX (Display *dpy, GLXVideoSourceSGIX glxvideosource);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource);
#endif /* _VL_H */
#endif
#ifndef GLX_EXT_visual_rating
#define GLX_EXT_visual_rating 1
#endif
#ifndef GLX_EXT_import_context
#define GLX_EXT_import_context 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Display * glXGetCurrentDisplayEXT (void);
extern int glXQueryContextInfoEXT (Display *dpy, GLXContext context, int attribute, int *value);
extern GLXContextID glXGetContextIDEXT (const GLXContext context);
extern GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID);
extern void glXFreeContextEXT (Display *dpy, GLXContext context);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void);
typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value);
typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);
typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID);
typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context);
#endif
#ifndef GLX_SGIX_fbconfig
#define GLX_SGIX_fbconfig 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXGetFBConfigAttribSGIX (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *dpy, int screen, int *attrib_list, int *nelements);
extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
extern GLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config);
extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements);
typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config);
typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis);
#endif
#ifndef GLX_SGIX_pbuffer
#define GLX_SGIX_pbuffer 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
extern void glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf);
extern int glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
extern void glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask);
extern void glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf);
typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask);
typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask);
#endif
#ifndef GLX_SGI_cushion
#define GLX_SGI_cushion 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern void glXCushionSGI (Display *dpy, Window window, float cushion);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion);
#endif
#ifndef GLX_SGIX_video_resize
#define GLX_SGIX_video_resize 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXBindChannelToWindowSGIX (Display *display, int screen, int channel, Window window);
extern int glXChannelRectSGIX (Display *display, int screen, int channel, int x, int y, int w, int h);
extern int glXQueryChannelRectSGIX (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
extern int glXQueryChannelDeltasSGIX (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
extern int glXChannelRectSyncSGIX (Display *display, int screen, int channel, GLenum synctype);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window);
typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h);
typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype);
#endif
#ifndef GLX_SGIX_dmbuffer
#define GLX_SGIX_dmbuffer 1
#ifdef _DM_BUFFER_H_
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXAssociateDMPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
#endif /* _DM_BUFFER_H_ */
#endif
#ifndef GLX_SGIX_swap_group
#define GLX_SGIX_swap_group 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern void glXJoinSwapGroupSGIX (Display *dpy, GLXDrawable drawable, GLXDrawable member);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);
#endif
#ifndef GLX_SGIX_swap_barrier
#define GLX_SGIX_swap_barrier 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern void glXBindSwapBarrierSGIX (Display *dpy, GLXDrawable drawable, int barrier);
extern Bool glXQueryMaxSwapBarriersSGIX (Display *dpy, int screen, int *max);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);
typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);
#endif
#ifndef GLX_SUN_get_transparent_index
#define GLX_SUN_get_transparent_index 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
#endif
#ifndef GLX_MESA_copy_sub_buffer
#define GLX_MESA_copy_sub_buffer 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern void glXCopySubBufferMESA (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
#endif
#ifndef GLX_MESA_pixmap_colormap
#define GLX_MESA_pixmap_colormap 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
#endif
#ifndef GLX_MESA_release_buffers
#define GLX_MESA_release_buffers 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable);
#endif
#ifndef GLX_MESA_set_3dfx_mode
#define GLX_MESA_set_3dfx_mode 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXSet3DfxModeMESA (int mode);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode);
#endif
#ifndef GLX_SGIX_visual_select_group
#define GLX_SGIX_visual_select_group 1
#endif
#ifndef GLX_OML_swap_method
#define GLX_OML_swap_method 1
#endif
#ifndef GLX_OML_sync_control
#define GLX_OML_sync_control 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXGetSyncValuesOML (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
extern Bool glXGetMscRateOML (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
extern int64_t glXSwapBuffersMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
extern Bool glXWaitForMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
extern Bool glXWaitForSbcOML (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
#endif
#ifndef GLX_NV_float_buffer
#define GLX_NV_float_buffer 1
#endif
#ifndef GLX_SGIX_hyperpipe
#define GLX_SGIX_hyperpipe 1
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int networkId;
} GLXHyperpipeNetworkSGIX;
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int channel;
unsigned int
participationType;
int timeSlice;
} GLXHyperpipeConfigSGIX;
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
int destXOrigin, destYOrigin, destWidth, destHeight;
} GLXPipeRect;
typedef struct {
char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
int XOrigin, YOrigin, maxHeight, maxWidth;
} GLXPipeRectLimits;
#ifdef GLX_GLXEXT_PROTOTYPES
extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *dpy, int *npipes);
extern int glXHyperpipeConfigSGIX (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *dpy, int hpId, int *npipes);
extern int glXDestroyHyperpipeConfigSGIX (Display *dpy, int hpId);
extern int glXBindHyperpipeSGIX (Display *dpy, int hpId);
extern int glXQueryHyperpipeBestAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
extern int glXHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
extern int glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);
typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);
typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);
typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);
typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
#endif
#ifndef GLX_MESA_agp_offset
#define GLX_MESA_agp_offset 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern unsigned int glXGetAGPOffsetMESA (const void *pointer);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer);
#endif
#ifndef GLX_EXT_fbconfig_packed_float
#define GLX_EXT_fbconfig_packed_float 1
#endif
#ifndef GLX_EXT_framebuffer_sRGB
#define GLX_EXT_framebuffer_sRGB 1
#endif
#ifndef GLX_EXT_texture_from_pixmap
#define GLX_EXT_texture_from_pixmap 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern void glXBindTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
extern void glXReleaseTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);
typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer);
#endif
#ifndef GLX_NV_present_video
#define GLX_NV_present_video 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern unsigned int * glXEnumerateVideoDevicesNV (Display *dpy, int screen, int *nelements);
extern int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef unsigned int * ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);
typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
#endif
#ifndef GLX_NV_video_output
#define GLX_NV_video_output 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXGetVideoDeviceNV (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
extern int glXReleaseVideoDeviceNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
extern int glXBindVideoImageNV (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
extern int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf);
extern int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
extern int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf);
typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
#endif
#ifndef GLX_NV_swap_group
#define GLX_NV_swap_group 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern Bool glXJoinSwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint group);
extern Bool glXBindSwapBarrierNV (Display *dpy, GLuint group, GLuint barrier);
extern Bool glXQuerySwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
extern Bool glXQueryMaxSwapGroupsNV (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
extern Bool glXQueryFrameCountNV (Display *dpy, int screen, GLuint *count);
extern Bool glXResetFrameCountNV (Display *dpy, int screen);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group);
typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier);
typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count);
typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen);
#endif
#ifndef GLX_NV_video_capture
#define GLX_NV_video_capture 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXBindVideoCaptureDeviceNV (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
extern GLXVideoCaptureDeviceNV * glXEnumerateVideoCaptureDevicesNV (Display *dpy, int screen, int *nelements);
extern void glXLockVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);
extern int glXQueryVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
extern void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements);
typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
#endif
#ifndef GLX_EXT_swap_control
#define GLX_EXT_swap_control 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern int glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef int ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
#endif
#ifndef GLX_NV_copy_image
#define GLX_NV_copy_image 1
#ifdef GLX_GLXEXT_PROTOTYPES
extern void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif /* GLX_GLXEXT_PROTOTYPES */
typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifndef GLX_INTEL_swap_event
#define GLX_INTEL_swap_event 1
#endif
#ifndef GLX_NV_multisample_coverage
#define GLX_NV_multisample_coverage 1
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,862 @@
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2007-2008 Red Hat, Inc.
* (C) Copyright IBM Corporation 2004
* 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
* on the rights to use, copy, modify, merge, publish, distribute, sub
* license, 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 (including the next
* paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS 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.
*/
/**
* \file dri_interface.h
*
* This file contains all the types and functions that define the interface
* between a DRI driver and driver loader. Currently, the most common driver
* loader is the XFree86 libGL.so. However, other loaders do exist, and in
* the future the server-side libglx.a will also be a loader.
*
* \author Kevin E. Martin <kevin@precisioninsight.com>
* \author Ian Romanick <idr@us.ibm.com>
* \author Kristian Høgsberg <krh@redhat.com>
*/
#ifndef DRI_INTERFACE_H
#define DRI_INTERFACE_H
/* For archs with no drm.h */
#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
#ifndef __NOT_HAVE_DRM_H
#define __NOT_HAVE_DRM_H
#endif
#endif
#ifndef __NOT_HAVE_DRM_H
#include <drm.h>
#else
typedef unsigned int drm_context_t;
typedef unsigned int drm_drawable_t;
typedef struct drm_clip_rect drm_clip_rect_t;
#endif
/**
* \name DRI interface structures
*
* The following structures define the interface between the GLX client
* side library and the DRI (direct rendering infrastructure).
*/
/*@{*/
typedef struct __DRIdisplayRec __DRIdisplay;
typedef struct __DRIscreenRec __DRIscreen;
typedef struct __DRIcontextRec __DRIcontext;
typedef struct __DRIdrawableRec __DRIdrawable;
typedef struct __DRIconfigRec __DRIconfig;
typedef struct __DRIframebufferRec __DRIframebuffer;
typedef struct __DRIversionRec __DRIversion;
typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
typedef struct __DRIextensionRec __DRIextension;
typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
typedef struct __DRIbufferRec __DRIbuffer;
typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
/*@}*/
/**
* Extension struct. Drivers 'inherit' from this struct by embedding
* it as the first element in the extension struct.
*
* We never break API in for a DRI extension. If we need to change
* the way things work in a non-backwards compatible manner, we
* introduce a new extension. During a transition period, we can
* leave both the old and the new extension in the driver, which
* allows us to move to the new interface without having to update the
* loader(s) in lock step.
*
* However, we can add entry points to an extension over time as long
* as we don't break the old ones. As we add entry points to an
* extension, we increase the version number. The corresponding
* #define can be used to guard code that accesses the new entry
* points at compile time and the version field in the extension
* struct can be used at run-time to determine how to use the
* extension.
*/
struct __DRIextensionRec {
const char *name;
int version;
};
/**
* The first set of extension are the screen extensions, returned by
* __DRIcore::getExtensions(). This entry point will return a list of
* extensions and the loader can use the ones it knows about by
* casting them to more specific extensions and advertising any GLX
* extensions the DRI extensions enables.
*/
/**
* Used by drivers to indicate support for setting the read drawable.
*/
#define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
#define __DRI_READ_DRAWABLE_VERSION 1
/**
* Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
*/
#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
#define __DRI_COPY_SUB_BUFFER_VERSION 1
struct __DRIcopySubBufferExtensionRec {
__DRIextension base;
void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
};
/**
* Used by drivers that implement the GLX_SGI_swap_control or
* GLX_MESA_swap_control extension.
*/
#define __DRI_SWAP_CONTROL "DRI_SwapControl"
#define __DRI_SWAP_CONTROL_VERSION 1
struct __DRIswapControlExtensionRec {
__DRIextension base;
void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
};
/**
* Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
*/
#define __DRI_FRAME_TRACKING "DRI_FrameTracking"
#define __DRI_FRAME_TRACKING_VERSION 1
struct __DRIframeTrackingExtensionRec {
__DRIextension base;
/**
* Enable or disable frame usage tracking.
*
* \since Internal API version 20030317.
*/
int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
/**
* Retrieve frame usage information.
*
* \since Internal API version 20030317.
*/
int (*queryFrameTracking)(__DRIdrawable *drawable,
int64_t * sbc, int64_t * missedFrames,
float * lastMissedUsage, float * usage);
};
/**
* Used by drivers that implement the GLX_SGI_video_sync extension.
*/
#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
struct __DRImediaStreamCounterExtensionRec {
__DRIextension base;
/**
* Wait for the MSC to equal target_msc, or, if that has already passed,
* the next time (MSC % divisor) is equal to remainder. If divisor is
* zero, the function will return as soon as MSC is greater than or equal
* to target_msc.
*/
int (*waitForMSC)(__DRIdrawable *drawable,
int64_t target_msc, int64_t divisor, int64_t remainder,
int64_t * msc, int64_t * sbc);
/**
* Get the number of vertical refreshes since some point in time before
* this function was first called (i.e., system start up).
*/
int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
int64_t *msc);
};
#define __DRI_TEX_OFFSET "DRI_TexOffset"
#define __DRI_TEX_OFFSET_VERSION 1
struct __DRItexOffsetExtensionRec {
__DRIextension base;
/**
* Method to override base texture image with a driver specific 'offset'.
* The depth passed in allows e.g. to ignore the alpha channel of texture
* images where the non-alpha components don't occupy a whole texel.
*
* For GLX_EXT_texture_from_pixmap with AIGLX.
*/
void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch);
};
/* Valid values for format in the setTexBuffer2 function below. These
* values match the GLX tokens for compatibility reasons, but we
* define them here since the DRI interface can't depend on GLX. */
#define __DRI_TEXTURE_FORMAT_NONE 0x20D8
#define __DRI_TEXTURE_FORMAT_RGB 0x20D9
#define __DRI_TEXTURE_FORMAT_RGBA 0x20DA
#define __DRI_TEX_BUFFER "DRI_TexBuffer"
#define __DRI_TEX_BUFFER_VERSION 2
struct __DRItexBufferExtensionRec {
__DRIextension base;
/**
* Method to override base texture image with the contents of a
* __DRIdrawable.
*
* For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of
* setTexBuffer2 in version 2 of this interface
*/
void (*setTexBuffer)(__DRIcontext *pDRICtx,
GLint target,
__DRIdrawable *pDraw);
/**
* Method to override base texture image with the contents of a
* __DRIdrawable, including the required texture format attribute.
*
* For GLX_EXT_texture_from_pixmap with AIGLX.
*/
void (*setTexBuffer2)(__DRIcontext *pDRICtx,
GLint target,
GLint format,
__DRIdrawable *pDraw);
};
/**
* Used by drivers that implement DRI2
*/
#define __DRI2_FLUSH "DRI2_Flush"
#define __DRI2_FLUSH_VERSION 3
struct __DRI2flushExtensionRec {
__DRIextension base;
void (*flush)(__DRIdrawable *drawable);
/**
* Ask the driver to call getBuffers/getBuffersWithFormat before
* it starts rendering again.
*
* \param drawable the drawable to invalidate
*
* \since 3
*/
void (*invalidate)(__DRIdrawable *drawable);
};
/**
* XML document describing the configuration options supported by the
* driver.
*/
extern const char __driConfigOptions[];
/*@}*/
/**
* The following extensions describe loader features that the DRI
* driver can make use of. Some of these are mandatory, such as the
* getDrawableInfo extension for DRI and the DRI Loader extensions for
* DRI2, while others are optional, and if present allow the driver to
* expose certain features. The loader pass in a NULL terminated
* array of these extensions to the driver in the createNewScreen
* constructor.
*/
typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
/**
* Callback to getDrawableInfo protocol
*/
#define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
#define __DRI_GET_DRAWABLE_INFO_VERSION 1
struct __DRIgetDrawableInfoExtensionRec {
__DRIextension base;
/**
* This function is used to get information about the position, size, and
* clip rects of a drawable.
*/
GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
unsigned int * index, unsigned int * stamp,
int * x, int * y, int * width, int * height,
int * numClipRects, drm_clip_rect_t ** pClipRects,
int * backX, int * backY,
int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
void *loaderPrivate);
};
/**
* Callback to get system time for media stream counter extensions.
*/
#define __DRI_SYSTEM_TIME "DRI_SystemTime"
#define __DRI_SYSTEM_TIME_VERSION 1
struct __DRIsystemTimeExtensionRec {
__DRIextension base;
/**
* Get the 64-bit unadjusted system time (UST).
*/
int (*getUST)(int64_t * ust);
/**
* Get the media stream counter (MSC) rate.
*
* Matching the definition in GLX_OML_sync_control, this function returns
* the rate of the "media stream counter". In practical terms, this is
* the frame refresh rate of the display.
*/
GLboolean (*getMSCRate)(__DRIdrawable *draw,
int32_t * numerator, int32_t * denominator,
void *loaderPrivate);
};
/**
* Damage reporting
*/
#define __DRI_DAMAGE "DRI_Damage"
#define __DRI_DAMAGE_VERSION 1
struct __DRIdamageExtensionRec {
__DRIextension base;
/**
* Reports areas of the given drawable which have been modified by the
* driver.
*
* \param drawable which the drawing was done to.
* \param rects rectangles affected, with the drawable origin as the
* origin.
* \param x X offset of the drawable within the screen (used in the
* front_buffer case)
* \param y Y offset of the drawable within the screen.
* \param front_buffer boolean flag for whether the drawing to the
* drawable was actually done directly to the front buffer (instead
* of backing storage, for example)
* \param loaderPrivate the data passed in at createNewDrawable time
*/
void (*reportDamage)(__DRIdrawable *draw,
int x, int y,
drm_clip_rect_t *rects, int num_rects,
GLboolean front_buffer,
void *loaderPrivate);
};
#define __DRI_SWRAST_IMAGE_OP_DRAW 1
#define __DRI_SWRAST_IMAGE_OP_CLEAR 2
#define __DRI_SWRAST_IMAGE_OP_SWAP 3
/**
* SWRast Loader extension.
*/
#define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
#define __DRI_SWRAST_LOADER_VERSION 1
struct __DRIswrastLoaderExtensionRec {
__DRIextension base;
/*
* Drawable position and size
*/
void (*getDrawableInfo)(__DRIdrawable *drawable,
int *x, int *y, int *width, int *height,
void *loaderPrivate);
/**
* Put image to drawable
*/
void (*putImage)(__DRIdrawable *drawable, int op,
int x, int y, int width, int height,
char *data, void *loaderPrivate);
/**
* Get image from readable
*/
void (*getImage)(__DRIdrawable *readable,
int x, int y, int width, int height,
char *data, void *loaderPrivate);
};
/**
* Invalidate loader extension. The presence of this extension
* indicates to the DRI driver that the loader will call invalidate in
* the __DRI2_FLUSH extension, whenever the needs to query for new
* buffers. This means that the DRI driver can drop the polling in
* glViewport().
*
* The extension doesn't provide any functionality, it's only use to
* indicate to the driver that it can use the new semantics. A DRI
* driver can use this to switch between the different semantics or
* just refuse to initialize if this extension isn't present.
*/
#define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
#define __DRI_USE_INVALIDATE_VERSION 1
typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
struct __DRIuseInvalidateExtensionRec {
__DRIextension base;
};
/**
* The remaining extensions describe driver extensions, immediately
* available interfaces provided by the driver. To start using the
* driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
* the extension you need in the array.
*/
#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
/**
* Tokens for __DRIconfig attribs. A number of attributes defined by
* GLX or EGL standards are not in the table, as they must be provided
* by the loader. For example, FBConfig ID or visual ID, drawable type.
*/
#define __DRI_ATTRIB_BUFFER_SIZE 1
#define __DRI_ATTRIB_LEVEL 2
#define __DRI_ATTRIB_RED_SIZE 3
#define __DRI_ATTRIB_GREEN_SIZE 4
#define __DRI_ATTRIB_BLUE_SIZE 5
#define __DRI_ATTRIB_LUMINANCE_SIZE 6
#define __DRI_ATTRIB_ALPHA_SIZE 7
#define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
#define __DRI_ATTRIB_DEPTH_SIZE 9
#define __DRI_ATTRIB_STENCIL_SIZE 10
#define __DRI_ATTRIB_ACCUM_RED_SIZE 11
#define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
#define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
#define __DRI_ATTRIB_SAMPLE_BUFFERS 15
#define __DRI_ATTRIB_SAMPLES 16
#define __DRI_ATTRIB_RENDER_TYPE 17
#define __DRI_ATTRIB_CONFIG_CAVEAT 18
#define __DRI_ATTRIB_CONFORMANT 19
#define __DRI_ATTRIB_DOUBLE_BUFFER 20
#define __DRI_ATTRIB_STEREO 21
#define __DRI_ATTRIB_AUX_BUFFERS 22
#define __DRI_ATTRIB_TRANSPARENT_TYPE 23
#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
#define __DRI_ATTRIB_FLOAT_MODE 29
#define __DRI_ATTRIB_RED_MASK 30
#define __DRI_ATTRIB_GREEN_MASK 31
#define __DRI_ATTRIB_BLUE_MASK 32
#define __DRI_ATTRIB_ALPHA_MASK 33
#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
#define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
#define __DRI_ATTRIB_SWAP_METHOD 40
#define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
#define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
#define __DRI_ATTRIB_YINVERTED 47
/* __DRI_ATTRIB_RENDER_TYPE */
#define __DRI_ATTRIB_RGBA_BIT 0x01
#define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
#define __DRI_ATTRIB_LUMINANCE_BIT 0x04
/* __DRI_ATTRIB_CONFIG_CAVEAT */
#define __DRI_ATTRIB_SLOW_BIT 0x01
#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
/* __DRI_ATTRIB_TRANSPARENT_TYPE */
#define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
#define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
#define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
#define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
/**
* This extension defines the core DRI functionality.
*/
#define __DRI_CORE "DRI_Core"
#define __DRI_CORE_VERSION 1
struct __DRIcoreExtensionRec {
__DRIextension base;
__DRIscreen *(*createNewScreen)(int screen, int fd,
unsigned int sarea_handle,
const __DRIextension **extensions,
const __DRIconfig ***driverConfigs,
void *loaderPrivate);
void (*destroyScreen)(__DRIscreen *screen);
const __DRIextension **(*getExtensions)(__DRIscreen *screen);
int (*getConfigAttrib)(const __DRIconfig *config,
unsigned int attrib,
unsigned int *value);
int (*indexConfigAttrib)(const __DRIconfig *config, int index,
unsigned int *attrib, unsigned int *value);
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
const __DRIconfig *config,
unsigned int drawable_id,
unsigned int head,
void *loaderPrivate);
void (*destroyDrawable)(__DRIdrawable *drawable);
void (*swapBuffers)(__DRIdrawable *drawable);
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
const __DRIconfig *config,
__DRIcontext *shared,
void *loaderPrivate);
int (*copyContext)(__DRIcontext *dest,
__DRIcontext *src,
unsigned long mask);
void (*destroyContext)(__DRIcontext *context);
int (*bindContext)(__DRIcontext *ctx,
__DRIdrawable *pdraw,
__DRIdrawable *pread);
int (*unbindContext)(__DRIcontext *ctx);
};
/**
* Stored version of some component (i.e., server-side DRI module, kernel-side
* DRM, etc.).
*
* \todo
* There are several data structures that explicitly store a major version,
* minor version, and patch level. These structures should be modified to
* have a \c __DRIversionRec instead.
*/
struct __DRIversionRec {
int major; /**< Major version number. */
int minor; /**< Minor version number. */
int patch; /**< Patch-level. */
};
/**
* Framebuffer information record. Used by libGL to communicate information
* about the framebuffer to the driver's \c __driCreateNewScreen function.
*
* In XFree86, most of this information is derrived from data returned by
* calling \c XF86DRIGetDeviceInfo.
*
* \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
* __driUtilCreateNewScreen CallCreateNewScreen
*
* \bug This structure could be better named.
*/
struct __DRIframebufferRec {
unsigned char *base; /**< Framebuffer base address in the CPU's
* address space. This value is calculated by
* calling \c drmMap on the framebuffer handle
* returned by \c XF86DRIGetDeviceInfo (or a
* similar function).
*/
int size; /**< Framebuffer size, in bytes. */
int stride; /**< Number of bytes from one line to the next. */
int width; /**< Pixel width of the framebuffer. */
int height; /**< Pixel height of the framebuffer. */
int dev_priv_size; /**< Size of the driver's dev-priv structure. */
void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
};
/**
* This extension provides alternative screen, drawable and context
* constructors for legacy DRI functionality. This is used in
* conjunction with the core extension.
*/
#define __DRI_LEGACY "DRI_Legacy"
#define __DRI_LEGACY_VERSION 1
struct __DRIlegacyExtensionRec {
__DRIextension base;
__DRIscreen *(*createNewScreen)(int screen,
const __DRIversion *ddx_version,
const __DRIversion *dri_version,
const __DRIversion *drm_version,
const __DRIframebuffer *frame_buffer,
void *pSAREA, int fd,
const __DRIextension **extensions,
const __DRIconfig ***driver_configs,
void *loaderPrivate);
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
const __DRIconfig *config,
drm_drawable_t hwDrawable,
int renderType, const int *attrs,
void *loaderPrivate);
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
const __DRIconfig *config,
int render_type,
__DRIcontext *shared,
drm_context_t hwContext,
void *loaderPrivate);
};
/**
* This extension provides alternative screen, drawable and context
* constructors for swrast DRI functionality. This is used in
* conjunction with the core extension.
*/
#define __DRI_SWRAST "DRI_SWRast"
#define __DRI_SWRAST_VERSION 1
struct __DRIswrastExtensionRec {
__DRIextension base;
__DRIscreen *(*createNewScreen)(int screen,
const __DRIextension **extensions,
const __DRIconfig ***driver_configs,
void *loaderPrivate);
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
const __DRIconfig *config,
void *loaderPrivate);
};
/**
* DRI2 Loader extension.
*/
#define __DRI_BUFFER_FRONT_LEFT 0
#define __DRI_BUFFER_BACK_LEFT 1
#define __DRI_BUFFER_FRONT_RIGHT 2
#define __DRI_BUFFER_BACK_RIGHT 3
#define __DRI_BUFFER_DEPTH 4
#define __DRI_BUFFER_STENCIL 5
#define __DRI_BUFFER_ACCUM 6
#define __DRI_BUFFER_FAKE_FRONT_LEFT 7
#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
#define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
struct __DRIbufferRec {
unsigned int attachment;
unsigned int name;
unsigned int pitch;
unsigned int cpp;
unsigned int flags;
};
#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
#define __DRI_DRI2_LOADER_VERSION 3
struct __DRIdri2LoaderExtensionRec {
__DRIextension base;
__DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate);
/**
* Flush pending front-buffer rendering
*
* Any rendering that has been performed to the
* \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
* \c __DRI_BUFFER_FRONT_LEFT.
*
* \param driDrawable Drawable whose front-buffer is to be flushed
* \param loaderPrivate Loader's private data that was previously passed
* into __DRIdri2ExtensionRec::createNewDrawable
*/
void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
/**
* Get list of buffers from the server
*
* Gets a list of buffer for the specified set of attachments. Unlike
* \c ::getBuffers, this function takes a list of attachments paired with
* opaque \c unsigned \c int value describing the format of the buffer.
* It is the responsibility of the caller to know what the service that
* allocates the buffers will expect to receive for the format.
*
* \param driDrawable Drawable whose buffers are being queried.
* \param width Output where the width of the buffers is stored.
* \param height Output where the height of the buffers is stored.
* \param attachments List of pairs of attachment ID and opaque format
* requested for the drawable.
* \param count Number of attachment / format pairs stored in
* \c attachments.
* \param loaderPrivate Loader's private data that was previously passed
* into __DRIdri2ExtensionRec::createNewDrawable.
*/
__DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate);
};
/**
* This extension provides alternative screen, drawable and context
* constructors for DRI2.
*/
#define __DRI_DRI2 "DRI_DRI2"
#define __DRI_DRI2_VERSION 2
#define __DRI_API_OPENGL 0
#define __DRI_API_GLES 1
#define __DRI_API_GLES2 2
struct __DRIdri2ExtensionRec {
__DRIextension base;
__DRIscreen *(*createNewScreen)(int screen, int fd,
const __DRIextension **extensions,
const __DRIconfig ***driver_configs,
void *loaderPrivate);
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
const __DRIconfig *config,
void *loaderPrivate);
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
const __DRIconfig *config,
__DRIcontext *shared,
void *loaderPrivate);
/* Since version 2 */
unsigned int (*getAPIMask)(__DRIscreen *screen);
__DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
int api,
const __DRIconfig *config,
__DRIcontext *shared,
void *data);
};
/**
* This extension provides functionality to enable various EGLImage
* extensions.
*/
#define __DRI_IMAGE "DRI_IMAGE"
#define __DRI_IMAGE_VERSION 1
/**
* These formats correspond to the similarly named MESA_FORMAT_*
* tokens, except in the native endian of the CPU. For example, on
* little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
* MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
*/
#define __DRI_IMAGE_FORMAT_RGB565 0x1001
#define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
#define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
#define __DRI_IMAGE_USE_SHARE 0x0001
#define __DRI_IMAGE_USE_SCANOUT 0x0002
/**
* queryImage attributes
*/
#define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
#define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
#define __DRI_IMAGE_ATTRIB_NAME 0x2002
typedef struct __DRIimageRec __DRIimage;
typedef struct __DRIimageExtensionRec __DRIimageExtension;
struct __DRIimageExtensionRec {
__DRIextension base;
__DRIimage *(*createImageFromName)(__DRIscreen *screen,
int width, int height, int format,
int name, int pitch,
void *loaderPrivate);
__DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
int renderbuffer,
void *loaderPrivate);
void (*destroyImage)(__DRIimage *image);
__DRIimage *(*createImage)(__DRIscreen *screen,
int width, int height, int format,
unsigned int use,
void *loaderPrivate);
GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
};
/**
* This extension must be implemented by the loader and passed to the
* driver at screen creation time. The EGLImage entry points in the
* various client APIs take opaque EGLImage handles and use this
* extension to map them to a __DRIimage. At version 1, this
* extensions allows mapping EGLImage pointers to __DRIimage pointers,
* but future versions could support other EGLImage-like, opaque types
* with new lookup functions.
*/
#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
#define __DRI_IMAGE_LOOKUP_VERSION 1
typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
struct __DRIimageLookupExtensionRec {
__DRIextension base;
__DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
void *loaderPrivate);
};
/**
* This extension allows for common DRI2 options
*/
#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
#define __DRI2_CONFIG_QUERY_VERSION 1
typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
struct __DRI2configQueryExtensionRec {
__DRIextension base;
int (*configQueryb)(__DRIscreen *screen, const char *var, GLboolean *val);
int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val);
int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val);
};
#endif

View File

@@ -0,0 +1,15 @@
/*
* Skeleton egl.h to provide compatibility for early GLES 1.0
* applications. Several early implementations included gl.h
* in egl.h leading applications to include only egl.h
*
* $Revision: 6252 $ on $Date:: 2008-08-06 16:35:08 -0700 #$
*/
#ifndef __legacy_egl_h_
#define __legacy_egl_h_
#include <EGL/egl.h>
#include <GLES/gl.h>
#endif /* __legacy_egl_h_ */

View File

@@ -0,0 +1,770 @@
#ifndef __gl_h_
#define __gl_h_
/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
#include <GLES/glplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
typedef void GLvoid;
typedef char GLchar;
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef khronos_int8_t GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef khronos_float_t GLfloat;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
typedef khronos_int32_t GLclampx;
typedef khronos_intptr_t GLintptr;
typedef khronos_ssize_t GLsizeiptr;
/*************************************************************/
/* OpenGL ES core versions */
#define GL_VERSION_ES_CM_1_0 1
#define GL_VERSION_ES_CL_1_0 1
#define GL_VERSION_ES_CM_1_1 1
#define GL_VERSION_ES_CL_1_1 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 */
/* ClipPlaneName */
#define GL_CLIP_PLANE0 0x3000
#define GL_CLIP_PLANE1 0x3001
#define GL_CLIP_PLANE2 0x3002
#define GL_CLIP_PLANE3 0x3003
#define GL_CLIP_PLANE4 0x3004
#define GL_CLIP_PLANE5 0x3005
/* 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_CURRENT_COLOR 0x0B00
#define GL_CURRENT_NORMAL 0x0B02
#define GL_CURRENT_TEXTURE_COORDS 0x0B03
#define GL_POINT_SIZE 0x0B11
#define GL_POINT_SIZE_MIN 0x8126
#define GL_POINT_SIZE_MAX 0x8127
#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
#define GL_POINT_DISTANCE_ATTENUATION 0x8129
#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
#define GL_LINE_WIDTH 0x0B21
#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_SHADE_MODEL 0x0B54
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_MATRIX_MODE 0x0BA0
#define GL_VIEWPORT 0x0BA2
#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
#define GL_PROJECTION_STACK_DEPTH 0x0BA4
#define GL_TEXTURE_STACK_DEPTH 0x0BA5
#define GL_MODELVIEW_MATRIX 0x0BA6
#define GL_PROJECTION_MATRIX 0x0BA7
#define GL_TEXTURE_MATRIX 0x0BA8
#define GL_ALPHA_TEST_FUNC 0x0BC1
#define GL_ALPHA_TEST_REF 0x0BC2
#define GL_BLEND_DST 0x0BE0
#define GL_BLEND_SRC 0x0BE1
#define GL_LOGIC_OP_MODE 0x0BF0
#define GL_SCISSOR_BOX 0x0C10
#define GL_SCISSOR_TEST 0x0C11
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_LIGHTS 0x0D31
#define GL_MAX_CLIP_PLANES 0x0D32
#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_TEXTURE_UNITS 0x84E2
#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
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_VERTEX_ARRAY_SIZE 0x807A
#define GL_VERTEX_ARRAY_TYPE 0x807B
#define GL_VERTEX_ARRAY_STRIDE 0x807C
#define GL_NORMAL_ARRAY_TYPE 0x807E
#define GL_NORMAL_ARRAY_STRIDE 0x807F
#define GL_COLOR_ARRAY_SIZE 0x8081
#define GL_COLOR_ARRAY_TYPE 0x8082
#define GL_COLOR_ARRAY_STRIDE 0x8083
#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
#define GL_VERTEX_ARRAY_POINTER 0x808E
#define GL_NORMAL_ARRAY_POINTER 0x808F
#define GL_COLOR_ARRAY_POINTER 0x8090
#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* 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_FOG_HINT 0x0C54
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* 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
#define GL_GENERATE_MIPMAP 0x8191
/* 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
#define GL_ACTIVE_TEXTURE 0x84E0
#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
/* 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
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
/* Texture combine + dot3 */
#define GL_SUBTRACT 0x84E7
#define GL_COMBINE 0x8570
#define GL_COMBINE_RGB 0x8571
#define GL_COMBINE_ALPHA 0x8572
#define GL_RGB_SCALE 0x8573
#define GL_ADD_SIGNED 0x8574
#define GL_INTERPOLATE 0x8575
#define GL_CONSTANT 0x8576
#define GL_PRIMARY_COLOR 0x8577
#define GL_PREVIOUS 0x8578
#define GL_OPERAND0_RGB 0x8590
#define GL_OPERAND1_RGB 0x8591
#define GL_OPERAND2_RGB 0x8592
#define GL_OPERAND0_ALPHA 0x8598
#define GL_OPERAND1_ALPHA 0x8599
#define GL_OPERAND2_ALPHA 0x859A
#define GL_ALPHA_SCALE 0x0D1C
#define GL_SRC0_RGB 0x8580
#define GL_SRC1_RGB 0x8581
#define GL_SRC2_RGB 0x8582
#define GL_SRC0_ALPHA 0x8588
#define GL_SRC1_ALPHA 0x8589
#define GL_SRC2_ALPHA 0x858A
#define GL_DOT3_RGB 0x86AE
#define GL_DOT3_RGBA 0x86AF
/*------------------------------------------------------------------------*
* required OES extension tokens
*------------------------------------------------------------------------*/
/* OES_read_format */
#ifndef GL_OES_read_format
#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
#endif
/* GL_OES_compressed_paletted_texture */
#ifndef GL_OES_compressed_paletted_texture
#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
#endif
/* OES_point_size_array */
#ifndef GL_OES_point_size_array
#define GL_POINT_SIZE_ARRAY_OES 0x8B9C
#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A
#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B
#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C
#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F
#endif
/* GL_OES_point_sprite */
#ifndef GL_OES_point_sprite
#define GL_POINT_SPRITE_OES 0x8861
#define GL_COORD_REPLACE_OES 0x8862
#endif
/*************************************************************/
/* Available only in Common profile */
GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref);
GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
GL_API void GL_APIENTRY glFogf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]);
GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glLightModelf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glLightModelfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glLineWidth (GLfloat width);
GL_API void GL_APIENTRY glLoadMatrixf (const GLfloat *m);
GL_API void GL_APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glMultMatrixf (const GLfloat *m);
GL_API void GL_APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
GL_API void GL_APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);
GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glPointParameterf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glPointSize (GLfloat size);
GL_API void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_API void GL_APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
GL_API void GL_APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);
GL_API void GL_APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);
/* Available in both Common and Common-Lite profiles */
GL_API void GL_APIENTRY glActiveTexture (GLenum texture);
GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
GL_API void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_API void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_API void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
GL_API void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
GL_API void GL_APIENTRY glClear (GLbitfield mask);
GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
GL_API void GL_APIENTRY glClearDepthx (GLclampx depth);
GL_API void GL_APIENTRY glClearStencil (GLint s);
GL_API void GL_APIENTRY glClientActiveTexture (GLenum texture);
GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation);
GL_API void GL_APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_API void GL_APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
GL_API void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
GL_API void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_API void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_API void GL_APIENTRY glCullFace (GLenum mode);
GL_API void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
GL_API void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
GL_API void GL_APIENTRY glDepthFunc (GLenum func);
GL_API void GL_APIENTRY glDepthMask (GLboolean flag);
GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
GL_API void GL_APIENTRY glDisable (GLenum cap);
GL_API void GL_APIENTRY glDisableClientState (GLenum array);
GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
GL_API void GL_APIENTRY glEnable (GLenum cap);
GL_API void GL_APIENTRY glEnableClientState (GLenum array);
GL_API void GL_APIENTRY glFinish (void);
GL_API void GL_APIENTRY glFlush (void);
GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glFrontFace (GLenum mode);
GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params);
GL_API void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed eqn[4]);
GL_API void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
GL_API void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
GL_API GLenum GL_APIENTRY glGetError (void);
GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetPointerv (GLenum pname, GLvoid **params);
GL_API const GLubyte * GL_APIENTRY glGetString (GLenum name);
GL_API void GL_APIENTRY glGetTexEnviv (GLenum env, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_API GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_API GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_API GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLineWidthx (GLfixed width);
GL_API void GL_APIENTRY glLoadIdentity (void);
GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m);
GL_API void GL_APIENTRY glLogicOp (GLenum opcode);
GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glMatrixMode (GLenum mode);
GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m);
GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
GL_API void GL_APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glPointSizex (GLfixed size);
GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
GL_API void GL_APIENTRY glPopMatrix (void);
GL_API void GL_APIENTRY glPushMatrix (void);
GL_API void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_API void GL_APIENTRY glShadeModel (GLenum mode);
GL_API void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_API void GL_APIENTRY glStencilMask (GLuint mask);
GL_API void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_API void GL_APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);
GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);
GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
GL_API void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
/*------------------------------------------------------------------------*
* Required OES extension functions
*------------------------------------------------------------------------*/
/* GL_OES_read_format */
#ifndef GL_OES_read_format
#define GL_OES_read_format 1
#endif
/* GL_OES_compressed_paletted_texture */
#ifndef GL_OES_compressed_paletted_texture
#define GL_OES_compressed_paletted_texture 1
#endif
/* GL_OES_point_size_array */
#ifndef GL_OES_point_size_array
#define GL_OES_point_size_array 1
GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer);
#endif
/* GL_OES_point_sprite */
#ifndef GL_OES_point_sprite
#define GL_OES_point_sprite 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* __gl_h_ */

View File

@@ -0,0 +1,620 @@
#ifndef __gl2_h_
#define __gl2_h_
/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -0800 #$ */
#include <GLES2/gl2platform.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/*-------------------------------------------------------------------------
* Data type definitions
*-----------------------------------------------------------------------*/
typedef void GLvoid;
typedef char GLchar;
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef khronos_int8_t GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef khronos_float_t GLfloat;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
/* GL types for handling large vertex buffer objects */
typedef khronos_intptr_t GLintptr;
typedef khronos_ssize_t GLsizeiptr;
/* OpenGL ES core versions */
#define GL_ES_VERSION_2_0 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 (not supported in ES20) */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* 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 */
/* BlendEquationSeparate */
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
#define GL_BLEND_EQUATION_ALPHA 0x883D
/* BlendSubtract */
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
/* Separate Blend Functions */
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
#define GL_BLEND_SRC_ALPHA 0x80CB
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
/* 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_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
#define GL_SCISSOR_TEST 0x0C11
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#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_OUT_OF_MEMORY 0x0505
/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
/* GetPName */
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_STENCIL_BACK_FUNC 0x8800
#define GL_STENCIL_BACK_FAIL 0x8801
#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
#define GL_STENCIL_BACK_REF 0x8CA3
#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
/* GL_SCISSOR_TEST */
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#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
#define GL_POLYGON_OFFSET_UNITS 0x2A00
/* GL_POLYGON_OFFSET_FILL */
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* HintTarget */
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* DataType */
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
/* PixelFormat */
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
/* 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
/* Shaders */
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_SHADER_TYPE 0x8B4F
#define GL_DELETE_STATUS 0x8B80
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_ATTACHED_SHADERS 0x8B85
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GL_ACTIVE_ATTRIBUTES 0x8B89
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
/* StencilFunction */
#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
/* StencilOp */
/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* 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 */
#define GL_TEXTURE 0x1702
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
/* 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
#define GL_ACTIVE_TEXTURE 0x84E0
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
/* Uniform Types */
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
#define GL_INT_VEC2 0x8B53
#define GL_INT_VEC3 0x8B54
#define GL_INT_VEC4 0x8B55
#define GL_BOOL 0x8B56
#define GL_BOOL_VEC2 0x8B57
#define GL_BOOL_VEC3 0x8B58
#define GL_BOOL_VEC4 0x8B59
#define GL_FLOAT_MAT2 0x8B5A
#define GL_FLOAT_MAT3 0x8B5B
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
/* Vertex Arrays */
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
/* Read Format */
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
/* Shader Source */
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
/* Shader Binary */
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
/* Shader Precision-Specified Types */
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
/* Framebuffer Object. */
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGB565 0x8D62
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_STENCIL_INDEX8 0x8D48
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
#define GL_NONE 0
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
/*-------------------------------------------------------------------------
* GL core functions.
*-----------------------------------------------------------------------*/
GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode );
GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth);
GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glFinish (void);
GL_APICALL void GL_APIENTRY glFlush (void);
GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL GLenum GL_APIENTRY glGetError (void);
GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
#ifdef __cplusplus
}
#endif
#endif /* __gl2_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
#ifndef __gl2platform_h_
#define __gl2platform_h_
/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "OpenGL-ES" component "Registry".
*/
#include <KHR/khrplatform.h>
#ifndef GL_APICALL
#define GL_APICALL KHRONOS_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY KHRONOS_APIENTRY
#endif
#endif /* __gl2platform_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
#ifndef __gl3ext_h_
#define __gl3ext_h_
/* $Revision: 17809 $ on $Date:: 2012-05-14 08:03:36 -0700 #$ */
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* OpenGL ES 3 Extensions
*
* After an OES extension's interactions with OpenGl ES 3.0 have been documented,
* its tokens and function definitions should be added to this file in a manner
* that does not conflict with gl2ext.h or gl3.h.
*
* Tokens and function definitions for extensions that have become standard
* features in OpenGL ES 3.0 will not be added to this file.
*
* Applications using OpenGL-ES-2-only extensions should include gl2ext.h
*/
#endif /* __gl3ext_h_ */

View File

@@ -0,0 +1,30 @@
#ifndef __gl3platform_h_
#define __gl3platform_h_
/* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* Platform-specific types and definitions for OpenGL ES 3.X gl3.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "OpenGL-ES" component "Registry".
*/
#include <KHR/khrplatform.h>
#ifndef GL_APICALL
#define GL_APICALL KHRONOS_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY KHRONOS_APIENTRY
#endif
#endif /* __gl3platform_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
#ifndef __glplatform_h_
#define __glplatform_h_
/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* Platform-specific types and definitions for OpenGL ES 1.X gl.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "OpenGL-ES" component "Registry".
*/
#include <KHR/khrplatform.h>
#ifndef GL_API
#define GL_API KHRONOS_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY KHRONOS_APIENTRY
#endif
#endif /* __glplatform_h_ */

View File

@@ -0,0 +1,269 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2009 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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 THE AUTHORS OR COPYRIGHT HOLDERS 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by sending them to the public Khronos Bugzilla
* (http://khronos.org/bugzilla) by filing a bug against product
* "Khronos (general)" component "Registry".
*
* A predefined template which fills in some of the bug fields can be
* reached using http://tinyurl.com/khrplatform-h-bugreport, but you
* must create a Bugzilla login first.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

19
project/jni/glshim/spec/build Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash -ux
cd "$(dirname "$0")"
base=../src/
gles="yml/gles-1.1.yml,yml/oes.yml"
gles2="yml/gles-2.0.yml"
opengl="yml/opengl.yml"
cats="VERSION_1_0,VERSION_1_1,VERSION_1_2,VERSION_1_3,VERSION_1_4,VERSION_1_5,EXT_swap_control"
./gen.py "$gles" mock.c.j2 mock.c mock.h > "$base/../test/util/mock.c" &
./gen.py "$gles" --ifndef USE_ES2 mock.h.j2 mock.h "gl_str.h" "wrap/gles.h" > "$base/../test/util/mock.h"
./gen.py "$gles" --ifndef USE_ES2 gleswrap.c.j2 gleswrap.c gles.h ../loader.h ../skip.h > "$base/gl/wrap/gles.c" &
./gen.py --deep "$opengl,$gles" --ifndef USE_ES2 glwrap.h.j2 gleswrap.h ../types.h > "$base/gl/wrap/gles.h"
./gen.py "$gles2" --ifdef USE_ES2 gleswrap.c.j2 gles2wrap.c gles2.h ../loader.h > "$base/gl/wrap/gles2.c"
./gen.py "$gles2" --ifdef USE_ES2 glwrap.h.j2 gles2wrap.h > "$base/gl/wrap/gles2.h"
rm -rf "$base/../test/build"

163
project/jni/glshim/spec/gen.py Executable file
View File

@@ -0,0 +1,163 @@
#!/usr/bin/env python
import argparse
import jinja2
import re
from yaml import load
split_re = re.compile(r'^(?P<type>.*?)\s*(?P<name>\w+)$')
env = jinja2.Environment(
trim_blocks=True,
loader=jinja2.FileSystemLoader('template'),
)
def args(args, add_type=True):
return ', '.join(
'{} {}'.format(arg['type'], arg['name']) if add_type else arg['name']
for arg in args
)
f = '0.2f'
printf_lookup = {
'GLbitfield': 'd',
'GLboolean': 'd',
'GLbyte': 'c',
'GLubyte': 'c',
'GLchar': 'c',
'GLdouble': '0.2f',
'GLenum': '0x%04X',
'GLfloat': '0.2f',
'GLint': 'd',
'GLintptr': 'd',
'GLintptrARB': 'd',
'GLshort': 'd',
'GLsizei': 'd',
'GLsizeiptr': 'd',
'GLsizeiptrARB': 'd',
'GLuint': 'u',
'GLushort': 'u',
'GLvoid': 'p',
}
def printf(args):
if isinstance(args, dict):
args = (args,)
types = []
for arg in args:
typ = arg['type']
if '*' in typ:
t = 'p'
else:
t = printf_lookup.get(typ, 'p')
if not '%' in t:
t = '%' + t
types.append(t)
return ', '.join(types)
def unconst(s):
split = s.split(' ')
while 'const' in split:
split.remove('const')
return ' '.join(split)
env.filters['args'] = args
env.filters['printf'] = printf
env.filters['unconst'] = unconst
def split_arg(arg):
match = split_re.match(arg)
if match:
return match.groupdict()
else:
return {'type': 'unknown', 'name': arg}
def gen(files, template, guard_name, headers,
deep=False, cats=(), ifdef=None, ifndef=None):
funcs = {}
formats = []
unique_formats = set()
for data in files:
if deep and not isinstance(data.values()[0], list):
functions = []
for cat, f in data.items():
if not cats or cat in cats:
functions.extend(f.items())
else:
functions = data.items()
for name, args in sorted(functions):
props = {}
if args:
ret = args.pop(0)
else:
ret = 'void'
args = [split_arg(arg) for arg in args if not arg == 'void']
if any(arg.get('type') == 'unknown' for arg in args):
continue
if args:
args[0]['first'] = True
args[-1]['last'] = True
for i, arg in enumerate(args):
arg['index'] = i
types = '_'.join(
arg['type'].replace(' ', '_').replace('*', '__GENPT__')
for arg in [{'type': ret}] + args)
props.update({
'return': ret,
'name': name,
'args': args,
'types': types,
'void': ret == 'void',
})
if not types in unique_formats:
unique_formats.add(types)
formats.append(props)
funcs[name] = props
context = {
'functions': [i[1] for i in sorted(funcs.items())],
'formats': formats,
'headers': headers,
'name': guard_name,
'ifdef': ifdef,
'ifndef': ifndef,
}
t = env.get_template(template)
return t.render(**context).rstrip('\n')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate code with yml/jinja.')
parser.add_argument('yaml', help='spec files')
parser.add_argument('template', help='jinja template to load')
parser.add_argument('name', help='header guard name')
parser.add_argument('headers', nargs='*', help='headers to include')
parser.add_argument('--deep', help='nested definitions', action='store_true')
parser.add_argument('--cats', help='deep category filter')
parser.add_argument('--ifdef', help='wrap with ifdef')
parser.add_argument('--ifndef', help='wrap with ifndef')
args = parser.parse_args()
files = []
for name in args.yaml.split(','):
with open(name) as f:
data = load(f)
if data:
files.append(data)
if args.cats:
cats = args.cats.split(',')
else:
cats = None
print gen(files, args.template, args.name,
args.headers, args.deep, cats,
args.ifdef, args.ifndef)

View File

@@ -0,0 +1,2 @@
jinja2
pyyaml

View File

@@ -0,0 +1,7 @@
{% if ifdef %}#ifdef {{ ifdef }}
{% endif %}
{% if ifndef %}#ifndef {{ ifndef }}
{% endif %}
{% block main %}{% endblock %}
{% if ifdef %}#endif{% endif %}
{% if ifndef %}#endif{% endif %}

View File

@@ -0,0 +1,5 @@
{% if func.args %}
printf("{{ func.name }}({{ func.args|printf }});\n", {{ func.args|args(0) }});
{% else %}
printf("{{ func.name }}();\n");
{% endif %}

View File

@@ -0,0 +1,10 @@
{% extends "base/base.j2" %}
{% block main %}
{% include "base/headers.j2" %}
{% set guard = name.upper().replace('.', '_') -%}
#ifndef {{ guard }}
#define {{ guard }}
{% block content %}{% endblock %}
#endif
{% endblock %}

View File

@@ -0,0 +1,7 @@
{% for header in headers %}
{% if "<" in header %}
#include {{ header }}
{% else %}
#include "{{ header }}"
{% endif %}
{% endfor %}

View File

@@ -0,0 +1,22 @@
void glIndexedCall(const indexed_call_t *packed, void *ret_v) {
switch (packed->func) {
{% for f in functions %}
#ifndef skip_index_{{ f.name }}
case {{ f.name }}_INDEX: {
INDEXED_{{ f.types }} *unpacked = (INDEXED_{{ f.types }} *)packed;
{% if f.args %}
ARGS_{{ f.types }} args = unpacked->args;
{% endif %}
{% if not f.void %}
{{ f.return }} *ret = ({{ f.return }} *)ret_v;
*ret =
{% endif %}
{{ f.name }}({% for arg in f.args -%}
args.a{{ loop.index }}{% if not arg.last %}, {% endif %}
{% endfor %});
break;
}
#endif
{% endfor %}
}
}

View File

@@ -0,0 +1,16 @@
void glPackedCall(const packed_call_t *packed) {
switch (packed->format) {
{% for f in formats %}
case FORMAT_{{ f.types }}: {
PACKED_{{ f.types }} *unpacked = (PACKED_{{ f.types }} *)packed;
{% if f.args %}
ARGS_{{ f.types }} args = unpacked->args;
{% endif %}
unpacked->func({% for arg in f.args -%}
args.a{{ loop.index }}{% if not arg.last %}, {% endif %}
{% endfor %});
break;
}
{% endfor %}
}
}

View File

@@ -0,0 +1,16 @@
{% extends "base/base.j2" %}
{% block main %}
{% block headers %}
{% include "base/headers.j2" %}
{% endblock %}
{% for func in functions %}
{% block definition scoped %}
{{ func.return }} {% block func_prefix %}{% endblock %}{{ func.name }}({{ func.args|args }}) {
{% block load scoped %}{% endblock %}
{% block call scoped %}
{% if not func.void %}return {% endif %}{% block prefix %}wrap{% endblock %}_{{ func.name }}({{ func.args|args(0) }});
{%- endblock %}
}
{% endblock %}
{% endfor %}
{% endblock %}

View File

@@ -0,0 +1,54 @@
{% extends "base/header.j2" %}
{% block content %}
enum FORMAT {
{% for f in formats %}
FORMAT_{{ f.types }},
{% endfor %}
};
{% for f in formats %}
typedef {{ f.return }} (*FUNC_{{ f.types }})({{ f.args|args }});
{% if f.args %}
typedef struct {
{% for arg in f.args %}
{{ arg.type|unconst }} a{{ loop.index }}{% if arg.type == 'GLdouble' %} __attribute__ ((aligned(8))){% endif %};
{% endfor %}
} ARGS_{{ f.types }};
{% endif %}
typedef struct {
int format;
FUNC_{{ f.types }} func;
int refs;
{% if f.args %}
ARGS_{{ f.types }} args;
{% endif %}
} PACKED_{{ f.types }};
typedef struct {
int func;
{% if f.args %}
ARGS_{{ f.types }} args;
{% endif %}
} INDEXED_{{ f.types }};
{% endfor %}
extern void glPushCall(void *data);
void glPackedCall(const packed_call_t *packed);
void glIndexedCall(const indexed_call_t *packed, void *ret_v);
{% for func in functions %}
#define {{ func.name }}_INDEX {{ loop.index }}
#define {{ func.name }}_RETURN {{ func.return }}
#define {{ func.name }}_ARG_NAMES {{ func.args|args(0) }}
#define {{ func.name }}_ARG_EXPAND {{ func.args|args }}
#define {{ func.name }}_PACKED PACKED_{{ func.types }}
#define {{ func.name }}_INDEXED INDEXED_{{ func.types }}
#define {{ func.name }}_FORMAT FORMAT_{{ func.types }}
{% endfor %}
{% for func in functions %}
{{ func.return }} {{ func.name }}({{ func.name }}_ARG_EXPAND);
typedef {{ func.return }} (*{{ func.name }}_PTR)({{ func.name }}_ARG_EXPAND);
{% endfor %}
{% endblock %}

View File

@@ -0,0 +1,21 @@
{% extends "base/wrap.c.j2" %}
{% block headers %}
{{ super() }}
{% include "base/packed_call.j2" %}
{% endblock %}
{% block definition %}
#ifndef skip_{{ func.name }}
{{ super() -}}
#endif
{% endblock %}
{% block load %}
LOAD_GLES({{ func.name }});
{% endblock %}
{% block call %}
#ifndef direct_{{ func.name }}
PUSH_IF_COMPILING({{ func.name }});
#endif
{{ super() }}
{% endblock %}
{% block prefix %}gles{% endblock %}

View File

@@ -0,0 +1,21 @@
{% extends "base/wrap.h.j2" %}
{% block content %}
{{ super() }}
{% for func in functions %}
#ifndef direct_{{ func.name }}
#define push_{{ func.name }}({{ func.args|args(0) }}) { \
{{ func.name }}_PACKED *packed_data = malloc(sizeof({{ func.name }}_PACKED)); \
packed_data->format = {{ func.name }}_FORMAT; \
packed_data->func = {{ func.name }}; \
packed_data->refs = 0; \
{% if func.args %}
{% for arg in func.args %}
packed_data->args.a{{ loop.index }} = ({{ arg.type|unconst }}){{ arg.name }}; \
{% endfor %}
{% endif %}
glPushCall((void *)packed_data); \
}
#endif
{% endfor %}
{% endblock %}

View File

@@ -0,0 +1,83 @@
{% extends "base/wrap.c.j2" %}
{% block headers %}
{{ super() }}
#include <stdio.h>
#include "tack.h"
static tack_t mock = {0};
const char *mock_name(int func) {
switch (func) {
{% for f in functions %}
case {{ f.name }}_INDEX: return "{{ f.name }}";
{% endfor %}
}
}
void mock_print(const indexed_call_t *packed) {
if (packed == NULL) {
printf("NULL()\n");
return;
}
switch (packed->func) {
{% for f in functions %}
case {{ f.name }}_INDEX: {
INDEXED_{{ f.types }} *unpacked = (INDEXED_{{ f.types }} *)packed;
{% if f.args %}
ARGS_{{ f.types }} args = unpacked->args;
{% endif %}
printf("{{ f.name }}({{ f.args|printf }});\n"
{%- for arg in f.args %}, args.a{{ loop.index }}{% endfor -%});
break;
}
{% endfor %}
}
}
void *mock_get(int idx) {
return tack_get(&mock, idx);
}
void *mock_peek() {
return tack_peek(&mock);
}
void *mock_cur() {
return tack_cur(&mock);
}
void *mock_shift() {
return tack_shift(&mock);
}
void *mock_slide(int func) {
if (mock.pos >= mock.len) {
return NULL;
}
indexed_call_t **stack = (indexed_call_t **)mock.data;
for (int i = mock.pos; i < mock.len; i++) {
if (stack[i]->func == func) {
mock.pos = i + 1;
return stack[i];
}
}
return NULL;
}
void mock_push(void *call) {
tack_push(&mock, call);
}
void *mock_pop() {
return tack_pop(&mock);
}
{% endblock %}
{% block func_prefix %}gles_{% endblock %}
{% block call %}
emit_{{ func.name }}({{ func.args|args(0) }});
{% if not func.void %}
return ({{ func.return }})0;
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,132 @@
{% extends "base/header.j2" %}
{% block main %}
#ifdef __cplusplus
extern "C" {
#endif
{{ super() }}
#ifdef __cplusplus
} // extern "C"
#endif
{% endblock %}
{% block content %}
{{ super() }}
const char *mock_name(int func);
void *mock_cur();
void *mock_get(int idx);
void *mock_peek();
void *mock_shift();
void *mock_slide(int func);
void mock_print(const indexed_call_t *packed);
void mock_push(void *call);
static int verbose_test = 0;
static int failed_test = 0;
#define verbose { verbose_test = 1; }
#define mock_warningf(...) { printf("WARNING: "), printf(__VA_ARGS__); }
#define mock_errorf(...) { printf("ERROR: "); printf(__VA_ARGS__); failed_test = 1; }
#define mock_assert(cond, ...) { if (!(cond)) { mock_errorf(__VA_ARGS__); }}
#define assert(cond) mock_assert(cond, "%s\n", #cond)
#define mock_print_ptr(prefix, ptr, size) \
printf("%s ", prefix); \
if (ptr == NULL) { \
printf("NULL"); \
} else { \
for (size_t i = 0; i < size; i++) { \
if (i > 0 && i % 4 == 0) printf(" "); \
printf("%02X", *(uint8_t *)(ptr+i)); \
} \
} \
printf("\n");
#define mock_return { \
indexed_call_t *call = NULL; \
while ((call = mock_shift()) != NULL) { \
mock_warningf("extra "); \
mock_print(call); \
} \
if (state.error) { \
mock_warningf("Ended with GL error flag: %s\n", gl_str(state.error)); \
} \
return failed_test; \
}
{% for func in functions %}
#define pack_{{ func.name }}({{ func.args|args(0) }}) ({ \
{{ func.name }}_INDEXED *packed_data = malloc(sizeof({{ func.name }}_INDEXED)); \
packed_data->func = {{ func.name }}_INDEX; \
{% if func.args %}
{% for arg in func.args %}
packed_data->args.a{{ loop.index }} = ({{ arg.type|unconst }}){{ arg.name }}; \
{% endfor %}
{% endif %}
packed_data; \
})
#define emit_{{ func.name }}({{ func.args|args(0) }}) { \
mock_push(pack_{{ func.name }}({{ func.args|args(0) }})); \
}
#define test_{{ func.name }}({{ func.args|args(0) }}) { \
{{ func.name }}_INDEXED *packed = mock_cur(); \
if (packed == NULL) { \
mock_errorf("{{ func.name }} missing (no calls left)\n"); \
} else if (packed->func != {{ func.name }}_INDEX) { \
if (verbose_test) { \
mock_print(mock_cur()); \
} \
indexed_call_t *tmp = (indexed_call_t *)packed; \
packed = mock_slide({{ func.name }}_INDEX); \
if (! packed) { \
mock_errorf("{{ func.name }} missing\n"); \
} else { \
mock_warningf("unexpected call while looking for {{ func.name }}:\n "); \
mock_print(tmp); \
}\
} else { \
if (verbose_test) { \
mock_print(mock_cur()); \
} \
mock_shift(); \
} \
if (packed) { \
int match = 1; \
void *a, *b; \
{% for arg in func.args %}
{% if '*' in arg.type %}
a = packed->args.a{{ loop.index }}, b = {{ arg.name }}; \
if (b == NULL && a != NULL || (a != NULL && b != NULL && (memcmp(a, b, sizeof({{ arg.name }})) != 0))) { \
printf(" ERROR: arg mismatch: {{ arg.name }}\n"); \
mock_print_ptr(" expected:", b, sizeof({{ arg.name }})); \
mock_print_ptr(" found:", a, sizeof({{ arg.name }})); \
{% elif 'float' in arg.type or 'double' in arg.type %}
if (packed->args.a{{ loop.index }} - {{ arg.name }} >= 0.01) { \
{% else %}
if (packed->args.a{{ loop.index }} != {{ arg.name }}) { \
{% endif %}
match = 0; \
} \
{% endfor %}
if (! match) { \
mock_errorf("calls do not match:\n"); \
printf(" have: "); mock_print((const indexed_call_t *)packed); \
printf(" want: {{ func.name }}({{ func.args|printf }});\n", {{ func.args|args(0) }}); \
} \
} \
}
{% endfor %}
{% for func in functions %}
#define gles_{{ func.name }}_INDEX {{ loop.index }}
#define gles_{{ func.name }}_RETURN {{ func.return }}
#define gles_{{ func.name }}_ARG_NAMES {{ func.args|args(0) }}
#define gles_{{ func.name }}_ARG_EXPAND {{ func.args|args }}
#define gles_{{ func.name }}_PACKED PACKED_{{ func.types }}
#define gles_{{ func.name }}_INDEXED INDEXED_{{ func.types }}
#define gles_{{ func.name }}_FORMAT FORMAT_{{ func.types }}
{% endfor %}
{% for func in functions %}
{{ func.return }} gles_{{ func.name }}({{ func.name }}_ARG_EXPAND);
{% endfor %}
{% endblock %}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,112 @@
#!/usr/bin/env python
from collections import defaultdict
import re
import xml.etree.ElementTree as ET
import yaml
def etna_to_yml(xml):
defs = xml.find('functions')
functions = defaultdict(dict)
for f in defs.findall('function'):
name = f.get('name')
ret = f.find('return')
if ret is not None:
ret = ret.get('type')
if ret is None:
ret = 'void'
params = []
for p in f.findall('param'):
params.append('{} {}'.format(p.get('type'), p.get('name')))
functions[name] = [ret] + params
return functions
def lua_to_yml(xml):
typemap = xml.find('typemap')
types = {}
for t in typemap:
name = t.get('typename')
types[name] = t.get('C-lang', name)
defs = xml.find('functions').find('function-defs')
functions = defaultdict(dict)
for f in defs.findall('function'):
cat = f.get('category')
ret = f.get('return')
ret = types.get(ret, ret)
func = f.get('name')
params = []
for param in f.findall('param'):
typ = param.get('type')
typ = types.get(typ, typ)
name = param.get('name')
kind = param.get('kind')
if kind in ('array', 'reference', 'array[size]'):
typ = typ.rstrip()
if not typ.endswith('*') or kind == 'reference':
typ += ' *'
if not 'const' in typ and param.get('input', 'false') == 'true':
typ = 'const ' + typ
p = '{} {}'.format(typ, name)
p = p.replace('* ', '*')
params.append(p)
args = [ret]
args.extend(params)
functions[cat][func] = args
return functions
def khronos_to_yml(xml):
def extract(node):
return node.findtext('ptype') or node.text, node.findtext('name')
def clean(s):
return re.sub('\s+', ' ', s).strip()
defs = xml.find('commands')
functions = defaultdict(dict)
for f in defs.findall('command'):
proto = f.find('proto')
ret, name = extract(proto)
params = []
for param in f.findall('param'):
params.append(clean(' '.join((param.itertext()))))
functions[name] = [ret] + params
return functions
def to_yml(filename):
with open(filename, 'r') as f:
data = f.read()
data = re.sub(' xmlns="[^"]+"', '', data, count=1)
xml = ET.fromstring(data)
if xml.tag == 'root':
functions = etna_to_yml(xml)
elif xml.tag == 'specification':
functions = lua_to_yml(xml)
elif xml.tag == 'registry':
functions = khronos_to_yml(xml)
else:
print 'unrecognized root tag:', xml.tag
yml = yaml.dump(dict(functions))
with open(filename.replace('xml', 'yml'), 'w') as o:
o.write(yml)
if __name__ == '__main__':
import sys
if len(sys.argv) < 2:
print 'Usage: {} <file.xml> [file.xml...]'.format(sys.argv[0])
sys.exit(1)
for name in sys.argv[1:]:
to_yml(name)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,147 @@
glActiveTexture: [void, GLenum texture]
glAlphaFunc: [void, GLenum func, GLclampf ref]
glAlphaFuncx: [void, GLenum func, GLclampx ref]
glBindBuffer: [void, GLenum target, GLuint buffer]
glBindTexture: [void, GLenum target, GLuint texture]
glBlendFunc: [void, GLenum sfactor, GLenum dfactor]
glBufferData: [void, GLenum target, GLsizeiptr size, "const GLvoid *data", GLenum usage]
glBufferSubData: [void, GLenum target, GLintptr offset, GLsizeiptr size, "const GLvoid *data"]
glClear: [void, GLbitfield mask]
glClearColor: [void, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha]
glClearColorx: [void, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha]
glClearDepthf: [void, GLclampf depth]
glClearDepthx: [void, GLclampx depth]
glClearStencil: [void, GLint s]
glClientActiveTexture: [void, GLenum texture]
glClipPlanef: [void, GLenum plane, "const GLfloat *equation"]
glClipPlanex: [void, GLenum plane, "const GLfixed *equation"]
glColor4f: [void, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha]
glColor4ub: [void, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha]
glColor4x: [void, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha]
glColorMask: [void, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha]
glColorPointer: [void, GLint size, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glCompressedTexImage2D: [void, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, "const GLvoid *data"]
glCompressedTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, "const GLvoid *data"]
glCopyTexImage2D: [void, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border]
glCopyTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height]
glCullFace: [void, GLenum mode]
glDeleteBuffers: [void, GLsizei n, "const GLuint *buffers"]
glDeleteTextures: [void, GLsizei n, "const GLuint *textures"]
glDepthFunc: [void, GLenum func]
glDepthMask: [void, GLboolean flag]
glDepthRangef: [void, GLclampf near, GLclampf far]
glDepthRangex: [void, GLclampx near, GLclampx far]
glDisable: [void, GLenum cap]
glDisableClientState: [void, GLenum array]
glDisableClientState: [void, GLenum array]
glDrawArrays: [void, GLenum mode, GLint first, GLsizei count]
glDrawElements: [void, GLenum mode, GLsizei count, GLenum type, "const GLvoid *indices"]
glEnable: [void, GLenum cap]
glEnableClientState: [void, GLenum array]
glEnableClientState: [void, GLenum array]
glFinish: [void, void]
glFlush: [void, void]
glFogf: [void, GLenum pname, GLfloat param]
glFogfv: [void, GLenum pname, "const GLfloat *params"]
glFogx: [void, GLenum pname, GLfixed param]
glFogxv: [void, GLenum pname, "const GLfixed *params"]
glFrontFace: [void, GLenum mode]
glFrustumf: [void, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far]
glFrustumx: [void, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed near, GLfixed far]
glGenBuffers: [void, GLsizei n, "GLuint *buffers"]
glGenTextures: [void, GLsizei n, "GLuint *textures"]
glGetBooleanv: [void, GLenum pname, "GLboolean *params"]
glGetBufferParameteriv: [void, GLenum target, GLenum pname, "GLint *params"]
glGetClipPlanef: [void, GLenum plane, "GLfloat *equation"]
glGetClipPlanex: [void, GLenum plane, "GLfixed *equation"]
glGetError: [GLenum, void]
glGetFixedv: [void, GLenum pname, "GLfixed *params"]
glGetFloatv: [void, GLenum pname, "GLfloat *params"]
glGetIntegerv: [void, GLenum pname, "GLint *params"]
glGetLightfv: [void, GLenum light, GLenum pname, "GLfloat *params"]
glGetLightxv: [void, GLenum light, GLenum pname, "GLfixed *params"]
glGetMaterialfv: [void, GLenum face, GLenum pname, "GLfloat *params"]
glGetMaterialxv: [void, GLenum face, GLenum pname, "GLfixed *params"]
glGetPointerv: [void, GLenum pname, "GLvoid **params"]
glGetString: [const GLubyte *, GLenum name]
glGetTexEnvfv: [void, GLenum target, GLenum pname, "GLfloat *params"]
glGetTexEnviv: [void, GLenum target, GLenum pname, "GLint *params"]
glGetTexEnvxv: [void, GLenum target, GLenum pname, "GLfixed *params"]
glGetTexParameterfv: [void, GLenum target, GLenum pname, "GLfloat *params"]
glGetTexParameteriv: [void, GLenum target, GLenum pname, "GLint *params"]
glGetTexParameterxv: [void, GLenum target, GLenum pname, "GLfixed *params"]
glHint: [void, GLenum target, GLenum mode]
glIsBuffer: [GLboolean, GLuint buffer]
glIsEnabled: [GLboolean, GLenum cap]
glIsTexture: [GLboolean, GLuint texture]
glLightf: [void, GLenum light, GLenum pname, GLfloat param]
glLightfv: [void, GLenum light, GLenum pname, "const GLfloat *params"]
glLightModelf: [void, GLenum pname, GLfloat param]
glLightModelfv: [void, GLenum pname, "const GLfloat *params"]
glLightModelx: [void, GLenum pname, GLfixed param]
glLightModelxv: [void, GLenum pname, "const GLfixed *params"]
glLightx: [void, GLenum light, GLenum pname, GLfixed param]
glLightxv: [void, GLenum light, GLenum pname, "const GLfixed *params"]
glLineWidth: [void, GLfloat width]
glLineWidthx: [void, GLfixed width]
glLoadIdentity: [void, void]
glLoadMatrixf: [void, "const GLfloat *m"]
glLoadMatrixx: [void, "const GLfixed *m"]
glLogicOp: [void, GLenum opcode]
glMaterialf: [void, GLenum face, GLenum pname, GLfloat param]
glMaterialfv: [void, GLenum face, GLenum pname, "const GLfloat *params"]
glMaterialx: [void, GLenum face, GLenum pname, GLfixed param]
glMaterialxv: [void, GLenum face, GLenum pname, "const GLfixed *params"]
glMatrixMode: [void, GLenum mode]
glMultiTexCoord4f: [void, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q]
glMultiTexCoord4x: [void, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q]
glMultMatrixf: [void, "const GLfloat *m"]
glMultMatrixx: [void, "const GLfixed *m"]
glNormal3f: [void, GLfloat nx, GLfloat ny, GLfloat nz]
glNormal3x: [void, GLfixed nx, GLfixed ny, GLfixed nz]
glNormalPointer: [void, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glOrthof: [void, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far]
glOrthox: [void, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed near, GLfixed far]
glPixelStorei: [void, GLenum pname, GLint param]
glPointParameterf: [void, GLenum pname, GLfloat param]
glPointParameterfv: [void, GLenum pname, "const GLfloat *params"]
glPointParameterx: [void, GLenum pname, GLfixed param]
glPointParameterxv: [void, GLenum pname, "const GLfixed *params"]
glPointSize: [void, GLfloat size]
glPointSizePointerOES: [void, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glPointSizex: [void, GLfixed size]
glPolygonOffset: [void, GLfloat factor, GLfloat units]
glPolygonOffsetx: [void, GLfixed factor, GLfixed units]
glPopMatrix: [void, void]
glPushMatrix: [void, void]
glReadPixels: [void, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, "GLvoid *pixels"]
glRotatef: [void, GLfloat angle, GLfloat x, GLfloat y, GLfloat z]
glRotatex: [void, GLfixed angle, GLfixed x, GLfixed y, GLfixed z]
glSampleCoverage: [void, GLclampf value, GLboolean invert]
glSampleCoveragex: [void, GLclampx value, GLboolean invert]
glScalef: [void, GLfloat x, GLfloat y, GLfloat z]
glScalex: [void, GLfixed x, GLfixed y, GLfixed z]
glScissor: [void, GLint x, GLint y, GLsizei width, GLsizei height]
glShadeModel: [void, GLenum mode]
glStencilFunc: [void, GLenum func, GLint ref, GLuint mask]
glStencilMask: [void, GLuint mask]
glStencilOp: [void, GLenum fail, GLenum zfail, GLenum zpass]
glTexCoordPointer: [void, GLint size, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glTexEnvf: [void, GLenum target, GLenum pname, GLfloat param]
glTexEnvfv: [void, GLenum target, GLenum pname, "const GLfloat *params"]
glTexEnvi: [void, GLenum target, GLenum pname, GLint param]
glTexEnviv: [void, GLenum target, GLenum pname, "const GLint *params"]
glTexEnvx: [void, GLenum target, GLenum pname, GLfixed param]
glTexEnvxv: [void, GLenum target, GLenum pname, "const GLfixed *params"]
glTexImage2D: [void, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, "const GLvoid *pixels"]
glTexParameterf: [void, GLenum target, GLenum pname, GLfloat param]
glTexParameterfv: [void, GLenum target, GLenum pname, "const GLfloat *params"]
glTexParameteri: [void, GLenum target, GLenum pname, GLint param]
glTexParameteriv: [void, GLenum target, GLenum pname, "const GLint *params"]
glTexParameterx: [void, GLenum target, GLenum pname, GLfixed param]
glTexParameterxv: [void, GLenum target, GLenum pname, "const GLfixed *params"]
glTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, "const GLvoid *pixels"]
glTranslatef: [void, GLfloat x, GLfloat y, GLfloat z]
glTranslatex: [void, GLfixed x, GLfixed y, GLfixed z]
glVertexPointer: [void, GLint size, GLenum type, GLsizei stride, "const GLvoid *pointer"]
glViewport: [void, GLint x, GLint y, GLsizei width, GLsizei height]

View File

@@ -0,0 +1,169 @@
glActiveTexture: [void, GLenum texture]
glAttachShader: [void, GLuint program, GLuint shader]
glBindAttribLocation: [void, GLuint program, GLuint index, const GLchar * name]
glBindBuffer: [void, GLenum target, GLuint buffer]
glBindFramebuffer: [void, GLenum target, GLuint framebuffer]
glBindRenderbuffer: [void, GLenum target, GLuint renderbuffer]
glBindTexture: [void, GLenum target, GLuint texture]
glBlendColor: [void, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha]
glBlendEquation: [void, GLenum mode]
glBlendEquationSeparate: [void, GLenum modeRGB, GLenum modeA]
glBlendFunc: [void, GLenum sfactor, GLenum dfactor]
glBlendFuncSeparate: [void, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha,
GLenum dfactorAlpha]
glBufferData: [void, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage]
glBufferSubData: [void, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid
* data]
glCheckFramebufferStatus: [GLenum, GLenum target]
glClear: [void, GLbitfield mask]
glClearColor: [void, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha]
glClearDepthf: [void, GLclampf depth]
glClearStencil: [void, GLint s]
glColorMask: [void, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha]
glCompileShader: [void, GLuint shader]
glCompressedTexImage2D: [void, GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data]
glCompressedTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint
yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const
GLvoid * data]
glCopyTexImage2D: [void, GLenum target, GLint level, GLenum internalformat, GLint
x, GLint y, GLsizei width, GLsizei height, GLint border]
glCopyTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height]
glCreateProgram: [GLuint]
glCreateShader: [GLuint, GLenum type]
glCullFace: [void, GLenum mode]
glDeleteBuffers: [void, GLsizei n, const GLuint * buffer]
glDeleteFramebuffers: [void, GLsizei n, const GLuint * framebuffers]
glDeleteProgram: [void, GLuint program]
glDeleteRenderbuffers: [void, GLsizei n, const GLuint * renderbuffers]
glDeleteShader: [void, GLuint program]
glDeleteTextures: [void, GLsizei n, const GLuint * textures]
glDepthFunc: [void, GLenum func]
glDepthMask: [void, GLboolean flag]
glDepthRangef: [void, GLclampf zNear, GLclampf zFar]
glDetachShader: [void, GLuint program, GLuint shader]
glDisable: [void, GLenum cap]
glDisableVertexAttribArray: [void, GLuint index]
glDrawArrays: [void, GLenum mode, GLint first, GLsizei count]
glDrawElements: [void, GLenum mode, GLsizei count, GLenum type, const GLvoid * indices]
glEnable: [void, GLenum cap]
glEnableVertexAttribArray: [void, GLuint index]
glFinish: [void]
glFlush: [void]
glFramebufferRenderbuffer: [void, GLenum target, GLenum attachment, GLenum renderbuffertarget,
GLuint renderbuffer]
glFramebufferTexture2D: [void, GLenum target, GLenum attachment, GLenum textarget,
GLuint texture, GLint level]
glFrontFace: [void, GLenum mode]
glGenBuffers: [void, GLsizei n, GLuint * buffer]
glGenFramebuffers: [void, GLsizei n, GLuint * framebuffers]
glGenRenderbuffers: [void, GLsizei n, GLuint * renderbuffers]
glGenTextures: [void, GLsizei n, GLuint * textures]
glGenerateMipmap: [void, GLenum target]
glGetActiveAttrib: [void, GLuint program, GLuint index, GLsizei bufSize, GLsizei *
length, GLint * size, GLenum * type, GLchar * name]
glGetActiveUniform: [void, GLuint program, GLuint index, GLsizei bufSize, GLsizei
* length, GLint * size, GLenum * type, GLchar * name]
glGetAttachedShaders: [void, GLuint program, GLsizei maxCount, GLsizei * count, GLuint
* obj]
glGetAttribLocation: [GLint, GLuint program, const GLchar * name]
glGetBooleanv: [void, GLenum pname, GLboolean * params]
glGetBufferParameteriv: [void, GLenum target, GLenum pname, GLint * params]
glGetError: [GLenum]
glGetFloatv: [void, GLenum pname, GLfloat * params]
glGetFramebufferAttachmentParameteriv: [void, GLenum target, GLenum attachment, GLenum
pname, GLint * params]
glGetIntegerv: [void, GLenum pname, GLint * params]
glGetProgramInfoLog: [void, GLuint program, GLsizei bufSize, GLsizei * length, GLchar
* infoLog]
glGetProgramiv: [void, GLuint program, GLenum pname, GLint * params]
glGetRenderbufferParameteriv: [void, GLenum target, GLenum pname, GLint * params]
glGetShaderInfoLog: [void, GLuint shader, GLsizei bufSize, GLsizei * length, GLchar
* infoLog]
glGetShaderPrecisionFormat: [void, GLenum shadertype, GLenum precisiontype, GLint
* range, GLint * precision]
glGetShaderSource: [void, GLuint shader, GLsizei bufSize, GLsizei * length, GLchar
* source]
glGetShaderiv: [void, GLuint shader, GLenum pname, GLint * params]
glGetString: [const GLubyte *, GLenum name]
glGetTexParameterfv: [void, GLenum target, GLenum pname, GLfloat * params]
glGetTexParameteriv: [void, GLenum target, GLenum pname, GLint * params]
glGetUniformLocation: [GLint, GLuint program, const GLchar * name]
glGetUniformfv: [void, GLuint program, GLint location, GLfloat * params]
glGetUniformiv: [void, GLuint program, GLint location, GLint * params]
glGetVertexAttribPointerv: [void, GLuint index, GLenum pname, GLvoid ** pointer]
glGetVertexAttribfv: [void, GLuint index, GLenum pname, GLfloat * params]
glGetVertexAttribiv: [void, GLuint index, GLenum pname, GLint * params]
glHint: [void, GLenum target, GLenum mode]
glIsBuffer: [GLboolean, GLuint buffer]
glIsEnabled: [GLboolean, GLenum cap]
glIsFramebuffer: [GLboolean, GLuint framebuffer]
glIsProgram: [GLboolean, GLuint program]
glIsRenderbuffer: [GLboolean, GLuint renderbuffer]
glIsShader: [GLboolean, GLuint shader]
glIsTexture: [GLboolean, GLuint texture]
glLineWidth: [void, GLfloat width]
glLinkProgram: [void, GLuint program]
glPixelStorei: [void, GLenum pname, GLint param]
glPolygonOffset: [void, GLfloat factor, GLfloat units]
glReadPixels: [void, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLvoid * pixels]
glReleaseShaderCompiler: [void]
glRenderbufferStorage: [void, GLenum target, GLenum internalformat, GLsizei width,
GLsizei height]
glSampleCoverage: [void, GLclampf value, GLboolean invert]
glScissor: [void, GLint x, GLint y, GLsizei width, GLsizei height]
glShaderBinary: [void, GLsizei n, const GLuint * shaders, GLenum binaryformat, const
GLvoid * binary, GLsizei length]
glShaderSource: [void, GLuint shader, GLsizei count, const GLchar * const * string,
const GLint * length]
glStencilFunc: [void, GLenum func, GLint ref, GLuint mask]
glStencilFuncSeparate: [void, GLenum face, GLenum func, GLint ref, GLuint mask]
glStencilMask: [void, GLuint mask]
glStencilMaskSeparate: [void, GLenum face, GLuint mask]
glStencilOp: [void, GLenum fail, GLenum zfail, GLenum zpass]
glStencilOpSeparate: [void, GLenum face, GLenum sfail, GLenum zfail, GLenum zpass]
glTexImage2D: [void, GLenum target, GLint level, GLint internalformat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels]
glTexParameterf: [void, GLenum target, GLenum pname, GLfloat param]
glTexParameterfv: [void, GLenum target, GLenum pname, const GLfloat * params]
glTexParameteri: [void, GLenum target, GLenum pname, GLint param]
glTexParameteriv: [void, GLenum target, GLenum pname, const GLint * params]
glTexSubImage2D: [void, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels]
glUniform1f: [void, GLint location, GLfloat v0]
glUniform1fv: [void, GLint location, GLsizei count, const GLfloat * value]
glUniform1i: [void, GLint location, GLint v0]
glUniform1iv: [void, GLint location, GLsizei count, const GLint * value]
glUniform2f: [void, GLint location, GLfloat v0, GLfloat v1]
glUniform2fv: [void, GLint location, GLsizei count, const GLfloat * value]
glUniform2i: [void, GLint location, GLint v0, GLint v1]
glUniform2iv: [void, GLint location, GLsizei count, const GLint * value]
glUniform3f: [void, GLint location, GLfloat v0, GLfloat v1, GLfloat v2]
glUniform3fv: [void, GLint location, GLsizei count, const GLfloat * value]
glUniform3i: [void, GLint location, GLint v0, GLint v1, GLint v2]
glUniform3iv: [void, GLint location, GLsizei count, const GLint * value]
glUniform4f: [void, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3]
glUniform4fv: [void, GLint location, GLsizei count, const GLfloat * value]
glUniform4i: [void, GLint location, GLint v0, GLint v1, GLint v2, GLint v3]
glUniform4iv: [void, GLint location, GLsizei count, const GLint * value]
glUniformMatrix2fv: [void, GLint location, GLsizei count, GLboolean transpose, const
GLfloat * value]
glUniformMatrix3fv: [void, GLint location, GLsizei count, GLboolean transpose, const
GLfloat * value]
glUniformMatrix4fv: [void, GLint location, GLsizei count, GLboolean transpose, const
GLfloat * value]
glUseProgram: [void, GLuint program]
glValidateProgram: [void, GLuint program]
glVertexAttrib1f: [void, GLuint index, GLfloat x]
glVertexAttrib1fv: [void, GLuint index, const GLfloat * v]
glVertexAttrib2f: [void, GLuint index, GLfloat x, GLfloat y]
glVertexAttrib2fv: [void, GLuint index, const GLfloat * v]
glVertexAttrib3f: [void, GLuint index, GLfloat x, GLfloat y, GLfloat z]
glVertexAttrib3fv: [void, GLuint index, const GLfloat * v]
glVertexAttrib4f: [void, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w]
glVertexAttrib4fv: [void, GLuint index, const GLfloat * v]
glVertexAttribPointer: [void, GLuint index, GLint size, GLenum type, GLboolean normalized,
GLsizei stride, const GLvoid * pointer]
glViewport: [void, GLint x, GLint y, GLsizei width, GLsizei height]

View File

@@ -0,0 +1,4 @@
# glTexGenfOES: [void, GLenum coord, GLenum pname, GLfloat param]
# glTexGenfvOES: [void, GLenum coord, GLenum pname, "const GLfloat *params"]
# glTexGeniOES: [void, GLenum coord, GLenum pname, GLint param]
# glTexGenivOES: [void, GLenum coord, GLenum pname, "const GLint *params"]

View File

@@ -0,0 +1,4 @@
glBlendColorOES: [void, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha]
glBlendEquationOES: [void, GLenum mode]
glBlendEquationSeparateOES: [void, GLenum modeRGB, GLenum modeAlpha]
glBlendFuncSeparateOES: [void, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
include_directories(util)
file(GLOB_RECURSE GL_SOURCES gl/*.c)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
include_directories(glx)
aux_source_directory(glx GLX_SOURCES)
list(APPEND GL_SOURCES ${GLX_SOURCES})
else()
message(STATUS "Not on Linux: building without GLX support.")
endif()
add_library(GL SHARED ${GL_SOURCES})
if(BCMHOST)
set(PI_LIBS bcm_host vcos pthread)
target_link_libraries(GL ${PI_LIBS} GLESv1_CM)
target_link_libraries(GL2 ${PI_LIBS} GLESv2)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(GL X11 dl)
endif()
if(CMAKE_SHARED_LIBRARY_SUFFIX MATCHES ".so")
set_target_properties(GL PROPERTIES SUFFIX ".so.1")
endif()
aux_source_directory(preload PRELOAD_SOURCES)
add_library(preload SHARED ${PRELOAD_SOURCES})
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(preload X11)
endif()
add_subdirectory(proxy)

132
project/jni/glshim/src/config.h Executable file
View File

@@ -0,0 +1,132 @@
#define SYS_proxy 9999
#define MAX_EVAL_ORDER 30
#define MAX_TEX 8
#define MAX_STACK_PROJECTION 16
#define MAX_STACK_TEXTURE 16
#define MAX_STACK_MODELVIEW 64
#define MAX_STACK_COLOR 16
// don't auto-wrap these functions
#define skip_glColor4ub
// gl.c
#define skip_glColor4f
#define skip_glDisable
#define skip_glEnable
#define skip_glGetIntegerv
#define skip_glGetString
#define skip_glIsEnabled
#define skip_glMaterialfv
#define skip_glMaterialf
#define skip_glNormal3f
#define skip_glGetFloatv
#define skip_glPushMatrix
#define skip_glPopMatrix
#define skip_glBindBuffer
#define skip_glBufferData
#define skip_glBufferSubData
#define skip_glDeleteBuffers
#define skip_glGenBuffers
#define skip_glIsBuffer
#define skip_glGetBufferPointerv
#define skip_glMapBuffer
#define skip_glUnmapBuffer
#define skip_glGetBufferParameteriv
#define skip_glGetBufferSubData
#define skip_glBlendColor
/*
#define skip_glBlendEquation
#define skip_glBlendEquationSeparate
#define skip_glBlendEquationSeparatei
#define skip_glBlendFuncSeparate
#define skip_glBlendFuncSeparatei
*/
#define skip_glGetError
// light.c
#define skip_glLightModelf
#define skip_glLightModelfv
#define skip_glLightfv
#define skip_glLightf
// raster.c
#define skip_glViewport
// texture.c
#define skip_glIsTexture
#define skip_glBindTexture
#define skip_glCopyTexImage2D
#define skip_glCopyTexSubImage2D
#define skip_glGenTextures
#define skip_glDeleteTextures
#define skip_glPixelStorei
#define skip_glTexImage2D
#define skip_glTexParameteri
#define skip_glTexParameterf
#define skip_glTexSubImage2D
#define skip_glActiveTexture
#define skip_glClientActiveTexture
#define skip_glMultiTexCoord4f
#define skip_glTexGeni
#define skip_glTexGenfv
#define skip_glReadPixels
#define skip_glCompressedTexImage2D
#define skip_glCompressedTexSubImage2D
// glDrawArrays
#define skip_glDrawArrays
#define skip_glDrawElements
#define skip_glVertexPointer
#define skip_glColorPointer
#define skip_glNormalPointer
#define skip_glTexCoordPointer
#define skip_glDisableClientState
#define skip_glEnableClientState
// Framebuffers
#define skip_glGenFramebuffers
#define skip_glDeleteFramebuffers
#define skip_glIsFramebuffer
#define skip_glCheckFramebufferStatus
#define skip_glBindFramebuffer
#define skip_glFramebufferTexture2D
#define skip_glGenRenderbuffers
#define skip_glFramebufferRenderbuffer
#define skip_glDeleteRenderbuffers
#define skip_glRenderbufferStorage
#define skip_glRenderbufferStorageMultisample
#define skip_glBindRenderbuffer
#define skip_glIsRenderbuffer
#define skip_glGenerateMipmap
#define skip_glGetFramebufferAttachmentParameteriv
#define skip_glGetRenderbufferParameteriv
// don't compile these into display lists
#define direct_glColorPointer
#define direct_glDeleteLists
#define direct_glDisableClientState
#define direct_glEdgeFlagPointer
#define direct_glEnableClientState
#define direct_glClientActiveTexture
#define direct_glFeedbackBuffer
#define direct_glFinish
#define direct_glFlush
#define direct_glGenLists
#define direct_glIndexPointer
#define direct_glInterleavedArrays
#define direct_glIsEnabled
#define direct_glIsList
#define direct_glNormalPointer
#define direct_glPopClientAttrib
#define direct_glPixelStore
#define direct_glPushClientAttrib
#define direct_glRenderMode
#define direct_glSelectBuffer
#define direct_glTexCoordPointer
#define direct_glVertexPointer
#define direct_glGenTextures
#define direct_glGetError

211
project/jni/glshim/src/gl/array.c Executable file
View File

@@ -0,0 +1,211 @@
#include "array.h"
GLvoid *copy_gl_array(const GLvoid *src,
GLenum from, GLsizei width, GLsizei stride,
GLenum to, GLsizei to_width, GLsizei skip, GLsizei count) {
if (! src || !count)
return NULL;
if (! stride)
stride = width * gl_sizeof(from);
const char *unknown_str = "libGL: copy_gl_array -> unknown type: %x\n";
GLvoid *dst = malloc((count-skip) * to_width * gl_sizeof(to));
GLsizei from_size = gl_sizeof(from) * width;
GLsizei to_size = gl_sizeof(to) * to_width;
if (to_width < width) {
printf("Warning: copy_gl_array: %i < %i\n", to_width, width);
return NULL;
}
// if stride is weird, we need to be able to arbitrarily shift src
// so we leave it in a uintptr_t and cast after incrementing
uintptr_t in = (uintptr_t)src;
in += stride*skip;
if (from == to && to_width >= width) {
GL_TYPE_SWITCH(out, dst, to,
for (int i = skip; i < count; i++) {
memcpy(out, (GLvoid *)in, from_size);
for (int j = width; j < to_width; j++) {
out[j] = 0;
}
out += to_width;
in += stride;
},
default:
printf(unknown_str, from);
return NULL;
)
} else {
GL_TYPE_SWITCH(out, dst, to,
for (int i = skip; i < count; i++) {
GL_TYPE_SWITCH(input, in, from,
for (int j = 0; j < width; j++) {
out[j] = input[j];
}
for (int j = width; j < to_width; j++) {
out[j] = 0;
}
out += to_width;
in += stride;
,
default:
printf(unknown_str, from);
return NULL;
)
},
default:
printf(unknown_str, to);
return NULL;
)
}
return dst;
}
GLvoid *copy_gl_array_convert(const GLvoid *src,
GLenum from, GLsizei width, GLsizei stride,
GLenum to, GLsizei to_width, GLsizei skip, GLsizei count, GLvoid* filler) {
if (! src || !count)
return NULL;
if (! stride)
stride = width * gl_sizeof(from);
const char *unknown_str = "libGL: copy_gl_array -> unknown type: %x\n";
GLvoid *dst = malloc((count-skip) * to_width * gl_sizeof(to));
GLsizei from_size = gl_sizeof(from) * width;
GLsizei to_size = gl_sizeof(to) * to_width;
if (to_width < width) {
/*printf("Warning: copy_gl_array: %i < %i\n", to_width, width);
return NULL;*/
width = to_width;
}
// if stride is weird, we need to be able to arbitrarily shift src
// so we leave it in a uintptr_t and cast after incrementing
uintptr_t in = (uintptr_t)src;
in += stride*skip;
if (from == to && to_width >= width) {
GL_TYPE_SWITCH(out, dst, to,
for (int i = skip; i < count; i++) {
memcpy(out, (GLvoid *)in, from_size);
for (int j = width; j < to_width; j++) {
memcpy(&out[j], filler, gl_sizeof(to));
}
out += to_width;
in += stride;
},
default:
printf(unknown_str, from);
return NULL;
)
} else {
GL_TYPE_SWITCH_MAX(out, dst, to,
for (int i = skip; i < count; i++) {
GL_TYPE_SWITCH(input, in, from,
for (int j = 0; j < width; j++) {
out[j] = input[j]*maxv/gl_max_value(from);
}
for (int j = width; j < to_width; j++) {
memcpy(&out[j], filler, gl_sizeof(to));
}
out += to_width;
in += stride;
,
default:
printf(unknown_str, from);
return NULL;
)
},
default:
printf(unknown_str, to);
return NULL;
)
}
return dst;
}
GLvoid *copy_gl_pointer(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
float filler = 0.0f;
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array_convert(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
GL_FLOAT, width, skip, count, &filler);
}
GLvoid *copy_gl_pointer_color(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
float filler = 1.0f;
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array_convert(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
GL_FLOAT, width, skip, count, &filler);
}
GLvoid *copy_gl_pointer_raw(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff) {
uintptr_t buffer = (buff)?(uintptr_t)buff->data:0;
return copy_gl_array(ptr->pointer+buffer, ptr->type, ptr->size, ptr->stride,
GL_FLOAT, width, skip, count);
}
GLfloat *gl_pointer_index(pointer_state_t *p, GLint index) {
static GLfloat buf[4];
GLsizei size = gl_sizeof(p->type);
GLsizei stride = p->stride ? p->stride : size * p->size;
uintptr_t ptr = (uintptr_t)(p->pointer) + (stride * index)
+ (uintptr_t)((state.buffers.vertex)?state.buffers.vertex->data:0);
GL_TYPE_SWITCH(src, ptr, p->type,
for (int i = 0; i < p->size; i++) {
buf[i] = src[i];
}
// zero anything not set by the pointer
for (int i = p->size; i < 4; i++) {
buf[i] = 0;
},
default:
printf("libGL: unknown pointer type: 0x%x\n", p->type);
)
return buf;
}
GLfloat *copy_eval_double(GLenum target, GLint ustride, GLint uorder,
GLint vstride, GLint vorder,
const GLdouble *src) {
GLsizei width = get_map_width(target);
GLsizei dwidth = (uorder == 2 && vorder == 2) ? 0 : uorder * vorder;
GLsizei hwidth = (uorder > vorder ? uorder : vorder) * width;
GLsizei elements;
GLsizei uinc = ustride - vorder * vstride;
if (hwidth > dwidth) {
elements = (uorder * vorder * width + hwidth);
} else {
elements = (uorder * vorder * width + dwidth);
}
GLfloat *points = malloc(elements * sizeof(GLfloat));
GLfloat *dst = points;
for (int i = 0; i < uorder; i++, src += uinc) {
for (int j = 0; j < vorder; j++, src += vstride) {
for (int k = 0; k < width; k++) {
*dst++ = src[k];
}
}
}
return points;
}
void normalize_indices(GLushort *indices, GLsizei *max, GLsizei *min, GLsizei count) {
*max = 0;
*min = -1;
for (int i = 0; i < count; i++) {
GLsizei n = indices[i];
if (*min == -1)
*min = n;
*min = (n < *min) ? n : *min;
*max = (n > *max) ? n : *max;
}
for (int i = 0; i < count; i++) {
indices[i] -= *min;
}
}

View File

@@ -0,0 +1,22 @@
#include "gl.h"
#ifndef GL_ARRAY_H
#define GL_ARRAY_H
#include "state.h"
GLvoid *copy_gl_array(const GLvoid *src,
GLenum from, GLsizei width, GLsizei stride,
GLenum to, GLsizei to_width, GLsizei skip, GLsizei count);
GLvoid *copy_gl_array_convert(const GLvoid *src,
GLenum from, GLsizei width, GLsizei stride,
GLenum to, GLsizei to_width, GLsizei skip, GLsizei count, GLvoid* filler);
GLvoid *copy_gl_pointer(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLvoid *copy_gl_pointer_color(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLvoid *copy_gl_pointer_raw(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count, glbuffer_t *buff);
GLfloat *gl_pointer_index(pointer_state_t *ptr, GLint index);
GLfloat *copy_eval_double(GLenum target, GLint ustride, GLint uorder, GLint vstride, GLint vorder, const GLdouble *points);
void normalize_indices(GLushort *indices, GLsizei *max, GLsizei *min, GLsizei count);
#endif

View File

@@ -0,0 +1,333 @@
#include "buffers.h"
static GLuint lastbuffer = 1;
// Utility function to bond / unbind a particular buffer
glbuffer_t** BUFF(GLenum target) {
switch(target) {
case GL_ARRAY_BUFFER:
return &state.buffers.vertex;
break;
case GL_ELEMENT_ARRAY_BUFFER:
return &state.buffers.elements;
break;
case GL_PIXEL_PACK_BUFFER:
return &state.buffers.pack;
break;
case GL_PIXEL_UNPACK_BUFFER:
return &state.buffers.unpack;
break;
default:
printf("LIBGL: Warning, unknown buffer target 0x%04X\n", target);
}
return (glbuffer_t**)NULL;
}
void unbind_buffer(GLenum target) {
glbuffer_t **t = BUFF(target);
if (t)
*t=(glbuffer_t*)NULL;
}
void bind_buffer(GLenum target, glbuffer_t* buff) {
glbuffer_t ** t = BUFF(target);
if (t)
*t = buff;
}
glbuffer_t* getbuffer_buffer(GLenum target) {
glbuffer_t ** t = BUFF(target);
if (t)
return *t;
return NULL;
}
int buffer_target(GLenum target) {
if (target==GL_ARRAY_BUFFER)
return 1;
if (target==GL_ELEMENT_ARRAY_BUFFER)
return 1;
if (target==GL_PIXEL_PACK_BUFFER)
return 1;
if (target==GL_PIXEL_UNPACK_BUFFER)
return 1;
return 0;
}
void glGenBuffers(GLsizei n, GLuint * buffers) {
//printf("glGenBuffers(%i, %p)\n", n, buffers);
noerrorShim();
if (n<1) {
errorShim(GL_INVALID_VALUE);
return;
}
for (int i=0; i<n; i++) {
buffers[i] = lastbuffer++;
}
}
void glBindBuffer(GLenum target, GLuint buffer) {
//printf("glBindBuffer(0x%04X, %u)\n", target, buffer);
khint_t k;
int ret;
khash_t(buff) *list = state.buffers.list;
if (! list) {
list = state.buffers.list = kh_init(buff);
// segfaults if we don't do a single put
kh_put(buff, list, 1, &ret);
kh_del(buff, list, 1);
}
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return;
}
// if buffer = 0 => unbind buffer!
if (buffer == 0) {
// unbind buffer
unbind_buffer(target);
} else {
// search for an existing buffer
k = kh_get(buff, list, buffer);
glbuffer_t *buff = NULL;
if (k == kh_end(list)){
k = kh_put(buff, list, buffer, &ret);
buff = kh_value(list, k) = malloc(sizeof(glbuffer_t));
buff->buffer = buffer;
buff->type = target;
buff->data = NULL;
buff->usage = GL_STATIC_DRAW;
buff->size = 0;
buff->access = GL_READ_WRITE;
buff->mapped = 0;
} else {
buff = kh_value(list, k);
}
bind_buffer(target, buff);
}
noerrorShim();
}
void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) {
//printf("glBufferData(0x%04X, %i, %p, 0x%04X)\n", target, size, data, usage);
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return;
}
glbuffer_t *buff = getbuffer_buffer(target);
if (buff==NULL) {
errorShim(GL_INVALID_OPERATION);
printf("LIBGL: Warning, null buffer for target=0x%04X for glBufferData\n", target);
return;
}
if (buff->data) {
free(buff->data);
}
buff->size = size;
buff->usage = usage;
buff->data = malloc(size);
buff->access = GL_READ_WRITE;
if (data)
memcpy(buff->data, data, size);
noerrorShim();
}
void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) {
//printf("glBufferSubData(0x%04X, %p, %i, %p)\n", target, offset, size, data);
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return;
}
glbuffer_t *buff = getbuffer_buffer(target);
if (buff==NULL) {
errorShim(GL_INVALID_OPERATION);
// printf("LIBGL: Warning, null buffer for target=0x%04X for glBufferSubData\n", target);
return;
}
memcpy(buff->data + offset, data, size); //TODO, some check maybe?
noerrorShim();
}
void glDeleteBuffers(GLsizei n, const GLuint * buffers) {
//printf("glDeleteBuffers(%i, %p)\n", n, buffers);
khash_t(buff) *list = state.buffers.list;
if (list) {
khint_t k;
glbuffer_t *buff;
for (int i = 0; i < n; i++) {
GLuint t = buffers[i];
k = kh_get(buff, list, t);
if (k != kh_end(list)) {
buff = kh_value(list, k);
if (state.buffers.vertex == buff)
state.buffers.vertex = NULL;
if (state.buffers.elements == buff)
state.buffers.elements = NULL;
if (state.buffers.pack == buff)
state.buffers.pack = NULL;
if (state.buffers.unpack == buff)
state.buffers.unpack = NULL;
if (buff->data) free(buff->data);
kh_del(buff, list, k);
free(buff);
}
}
}
noerrorShim();
}
GLboolean glIsBuffer(GLuint buffer) {
//printf("glIsBuffer(%u)\n", buffer);
khash_t(buff) *list = state.buffers.list;
khint_t k;
noerrorShim();
if (list) {
k = kh_get(buff, list, buffer);
if (k != kh_end(list)) {
return GL_TRUE;
}
}
return GL_FALSE;
}
void glGetBufferParameteriv(GLenum target, GLenum value, GLint * data) {
//printf("glGetBufferParameteriv(0x%04X, 0x%04X, %p)\n", target, value, data);
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return;
}
glbuffer_t* buff = getbuffer_buffer(target);
if (buff==NULL) {
errorShim(GL_INVALID_OPERATION);
return; // Should generate an error!
}
noerrorShim();
switch (value) {
case GL_BUFFER_ACCESS:
data[0] = buff->access;
break;
case GL_BUFFER_ACCESS_FLAGS:
data[0] = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
break;
case GL_BUFFER_MAPPED:
data[0]=(buff->mapped)?GL_TRUE:GL_FALSE;
break;
case GL_BUFFER_MAP_LENGTH:
data[0]=(buff->mapped)?buff->size:0;
break;
case GL_BUFFER_MAP_OFFSET:
data[0]=0;
break;
case GL_BUFFER_SIZE:
data[0] = buff->size;
break;
case GL_BUFFER_USAGE:
data[0] = buff->usage;
break;
default:
errorShim(GL_INVALID_ENUM);
/* TODO Error if something else */
}
}
void *glMapBuffer(GLenum target, GLenum access) {
//printf("glMapBuffer(0x%04X, 0x%04X)\n", target, access);
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return (void*)NULL;
}
glbuffer_t *buff = getbuffer_buffer(target);
if (buff==NULL)
return (void*)NULL; // Should generate an error!
buff->access = access; // not used
buff->mapped = 1;
noerrorShim();
return buff->data; // Not nice, should do some copy or something probably
}
GLboolean glUnmapBuffer(GLenum target) {
//printf("glUnmapBuffer(0x%04X)\n", target);
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return GL_FALSE;
}
glbuffer_t *buff = getbuffer_buffer(target);
if (buff==NULL)
return GL_FALSE; // Should generate an error!
noerrorShim();
if (buff->mapped) {
buff->mapped = 0;
return GL_TRUE;
}
return GL_FALSE;
}
void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid * data) {
//printf("glGetBufferSubData(0x%04X, %p, %i, %p)\n", target, offset, size, data);
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return;
}
glbuffer_t *buff = getbuffer_buffer(target);
if (buff==NULL)
return; // Should generate an error!
// TODO, check parameter consistancie
memcpy(data, buff->data+offset, size);
noerrorShim();
}
void glGetBufferPointerv(GLenum target, GLenum pname, GLvoid ** params) {
//printf("glGetBufferPointerv(0x%04X, 0x%04X, %p)\n", target, pname, params);
if (!buffer_target(target)) {
errorShim(GL_INVALID_ENUM);
return;
}
glbuffer_t *buff = getbuffer_buffer(target);
if (buff==NULL)
return; // Should generate an error!
if (pname != GL_BUFFER_MAP_POINTER) {
errorShim(GL_INVALID_ENUM);
return;
}
if (!buff->mapped) {
params[0] = NULL;
} else {
params[0] = buff->data;
}
}
void glGenBuffersARB(GLsizei n, GLuint * buffers) {
glGenBuffers(n, buffers);
}
void glBindBufferARB(GLenum target, GLuint buffer) {
glBindBuffer(target, buffer);
}
void glBufferDataARB(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) {
glBufferData(target, size, data, usage);
}
void glBufferSubDataARB(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) {
glBufferSubData(target, offset, size, data);
}
void glDeleteBuffersARB(GLsizei n, const GLuint * buffers) {
glDeleteBuffers(n, buffers);
}
GLboolean glIsBufferARB(GLuint buffer) {
return glIsBuffer(buffer);
}
void glGetBufferParameterivARB(GLenum target, GLenum value, GLint * data) {
glGetBufferParameteriv(target, value, data);
}
void *glMapBufferARB(GLenum target, GLenum access) {
glMapBuffer(target, access);
}
GLboolean glUnmapBufferARB(GLenum target) {
return glUnmapBuffer(target);
}
void glGetBufferSubDataARB(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid * data) {
glGetBufferSubData(target, offset, size, data);
}
void glGetBufferPointervARB(GLenum target, GLenum pname, GLvoid ** params) {
glGetBufferPointerv(target, pname, params);
}

View File

@@ -0,0 +1,44 @@
#include "gl.h"
#ifndef GL_BUFFERS_H
#define GL_BUFFERS_H
typedef struct {
GLuint buffer;
GLenum type;
GLsizeiptr size;
GLenum usage;
GLint access;
int mapped;
GLvoid *data;
} glbuffer_t;
KHASH_MAP_INIT_INT(buff, glbuffer_t *)
/*
extern void glGenBuffers(GLsizei n, GLuint * buffers);
extern void glBindBuffer(GLenum target, GLuint buffer);
extern void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
extern void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
extern void glDeleteBuffers(GLsizei n, const GLuint * buffers);
extern GLboolean glIsBuffer(GLuint buffer);
extern void glGetBufferParameteriv(GLenum target, GLenum value, GLint * data);
*/
void *glMapBuffer(GLenum target, GLenum access);
GLboolean glUnmapBuffer(GLenum target);
void glGetBufferPointerv(GLenum target, GLenum pname, GLvoid ** params);
extern void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid * data);
void glGenBuffersARB(GLsizei n, GLuint * buffers);
void glBindBufferARB(GLenum target, GLuint buffer);
void glBufferDataARB(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
void glBufferSubDataARB(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
void glDeleteBuffersARB(GLsizei n, const GLuint * buffers);
GLboolean glIsBufferARB(GLuint buffer);
void glGetBufferParameterivARB(GLenum target, GLenum value, GLint * data);
void *glMapBufferARB(GLenum target, GLenum access);
GLboolean glUnmapBufferARB(GLenum target);
void glGetBufferSubDataARB(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid * data);
void glGetBufferPointervARB(GLenum target, GLenum pname, GLvoid ** params);
#endif

527
project/jni/glshim/src/gl/const.h Executable file
View File

@@ -0,0 +1,527 @@
#define GL_QUADS 7
#define GL_QUAD_STRIP 8
#define GL_POLYGON 9
/* texture mapping */
#define GL_TEXTURE_ENV 0x2300
#define GL_TEXTURE_ENV_MODE 0x2200
#define GL_TEXTURE_1D 0x0DE0
#define GL_TEXTURE_2D 0x0DE1
#define GL_TEXTURE_3D 0x806F
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_ENV_COLOR 0x2201
#define GL_TEXTURE_GEN_S 0x0C60
#define GL_TEXTURE_GEN_T 0x0C61
#define GL_TEXTURE_GEN_MODE 0x2500
#define GL_TEXTURE_BORDER_COLOR 0x1004
#define GL_TEXTURE_WIDTH 0x1000
#define GL_TEXTURE_HEIGHT 0x1001
#define GL_TEXTURE_BORDER 0x1005
#define GL_TEXTURE_COMPONENTS 0x1003
#define GL_TEXTURE_RED_SIZE 0x805C
#define GL_TEXTURE_GREEN_SIZE 0x805D
#define GL_TEXTURE_BLUE_SIZE 0x805E
#define GL_TEXTURE_ALPHA_SIZE 0x805F
#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
#define GL_TEXTURE_INTENSITY_SIZE 0x8061
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
#define GL_OBJECT_LINEAR 0x2401
#define GL_OBJECT_PLANE 0x2501
#define GL_EYE_LINEAR 0x2400
#define GL_EYE_PLANE 0x2502
#define GL_SPHERE_MAP 0x2402
#define GL_NORMAL_MAP 0x8511
#define GL_REFLECTION_MAP 0x8512
#define GL_DECAL 0x2101
#define GL_MODULATE 0x2100
#define GL_NEAREST 0x2600
#define GL_REPEAT 0x2901
#define GL_CLAMP 0x2900
#define GL_S 0x2000
#define GL_T 0x2001
#define GL_R 0x2002
#define GL_Q 0x2003
#define GL_TEXTURE_GEN_R 0x0C62
#define GL_TEXTURE_GEN_Q 0x0C63
#define GL_PROXY_TEXTURE_1D 0x8063
#define GL_PROXY_TEXTURE_2D 0x8064
#define GL_PROXY_TEXTURE_3D 0x8070
#define GL_TEXTURE_MIN_LOD 0x813A
#define GL_TEXTURE_MAX_LOD 0x813B
#define GL_TEXTURE_LOD_BIAS 0x8501
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_GEN_STR 0x8D60
// GL_ARB_texture_rectangle
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7
#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
#define GL_LINE_SMOOTH 0x0B20
#define GL_LINE_STIPPLE 0x0B24
#define GL_LINE_STIPPLE_PATTERN 0x0B25
#define GL_LINE_STIPPLE_REPEAT 0x0B26
#define GL_LINE_WIDTH 0x0B21
#define GL_LINE_WIDTH_GRANULARITY 0x0B23
#define GL_LINE_WIDTH_RANGE 0x0B22
#define GL_OBJECT_LINEAR 0x2401
#define GL_OBJECT_PLANE 0x2501
#define GL_EYE_LINEAR 0x2400
#define GL_EYE_PLANE 0x2502
#define GL_SPHERE_MAP 0x2402
#define GL_CURRENT_BIT 0x00001
#define GL_POINT_BIT 0x00002
#define GL_LINE_BIT 0x00004
#define GL_POLYGON_BIT 0x00008
#define GL_POLYGON_STIPPLE_BIT 0x00010
#define GL_PIXEL_MODE_BIT 0x00020
#define GL_LIGHTING_BIT 0x00040
#define GL_FOG_BIT 0x00080
// some of these are already defined in GLES
// #define GL_DEPTH_BUFFER_BIT 0x00100
#define GL_ACCUM_BUFFER_BIT 0x00200
// #define GL_STENCIL_BUFFER_BIT 0x00400
#define GL_VIEWPORT_BIT 0x00800
#define GL_TRANSFORM_BIT 0x01000
#define GL_ENABLE_BIT 0x02000
// #define GL_COLOR_BUFFER_BIT 0x04000
#define GL_HINT_BIT 0x08000
#define GL_EVAL_BIT 0x10000
#define GL_LIST_BIT 0x20000
#define GL_TEXTURE_BIT 0x40000
#define GL_SCISSOR_BIT 0x80000
#define GL_ALL_ATTRIB_BITS 0xFFFFF
#define GL_MULTISAMPLE_BIT 0x20000000
#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF
#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
// secondary color
#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
#define GL_SECONDARY_COLOR_ARRAY 0x845E
#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
#define GL_COLOR_SUM 0x8458
// pixel formats
#define GL_RED 0x1903
#define GL_RG 0x8227
#define GL_BGR 0x80E0
#define GL_BGRA 0x80E1
#define GL_UNSIGNED_BYTE_3_3_2 0x8032
#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
#define GL_UNSIGNED_INT_8_8_8_8 0x8035
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
#define GL_UNSIGNED_INT_10_10_10_2 0x8036
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
#define GL_RGB8 0x8051
#define GL_RGB5 0x8050
// types
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_2_BYTES 0x1407
#define GL_3_BYTES 0x1408
#define GL_4_BYTES 0x1409
#define GL_DOUBLE 0x140A
#define GL_COMPILE 0x1300
#define GL_COMPILE_AND_EXECUTE 0x1301
// fog
#define GL_FOG 0x0B60
#define GL_FOG_MODE 0x0B65
#define GL_FOG_DENSITY 0x0B62
#define GL_FOG_COLOR 0x0B66
#define GL_FOG_INDEX 0x0B61
#define GL_FOG_START 0x0B63
#define GL_FOG_END 0x0B64
#define GL_LINEAR 0x2601
#define GL_EXP 0x0800
#define GL_EXP2 0x0801
// lighting
#define GL_LIGHTING 0x0B50
#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
#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
#define GL_AMBIENT 0x1200
#define GL_DIFFUSE 0x1201
#define GL_SPECULAR 0x1202
#define GL_SHININESS 0x1601
#define GL_EMISSION 0x1600
#define GL_POSITION 0x1203
#define GL_SPOT_DIRECTION 0x1204
#define GL_AMBIENT_AND_DIFFUSE 0x1602
#define GL_COLOR_INDEXES 0x1603
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
#define GL_FRONT_AND_BACK 0x0408
#define GL_SHADE_MODEL 0x0B54
#define GL_FLAT 0x1D00
#define GL_SMOOTH 0x1D01
#define GL_COLOR_MATERIAL 0x0B57
#define GL_COLOR_MATERIAL_FACE 0x0B55
#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
#define GL_NORMALIZE 0x0BA1
// pixel transfer
#define GL_MAP_COLOR 0x0D10
#define GL_MAP_STENCIL 0x0D11
#define GL_INDEX_SHIFT 0x0D12
#define GL_INDEX_OFFSET 0x0D13
#define GL_RED_SCALE 0x0D14
#define GL_RED_BIAS 0x0D15
#define GL_GREEN_SCALE 0x0D18
#define GL_GREEN_BIAS 0x0D19
#define GL_BLUE_SCALE 0x0D1A
#define GL_BLUE_BIAS 0x0D1B
#define GL_ALPHA_SCALE 0x0D1C
#define GL_ALPHA_BIAS 0x0D1D
#define GL_DEPTH_SCALE 0x0D1E
#define GL_DEPTH_BIAS 0x0D1F
#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
#define GL_PIXEL_MAP_S_TO_S 0x0C71
#define GL_PIXEL_MAP_I_TO_I 0x0C70
#define GL_PIXEL_MAP_I_TO_R 0x0C72
#define GL_PIXEL_MAP_I_TO_G 0x0C73
#define GL_PIXEL_MAP_I_TO_B 0x0C74
#define GL_PIXEL_MAP_I_TO_A 0x0C75
#define GL_PIXEL_MAP_R_TO_R 0x0C76
#define GL_PIXEL_MAP_G_TO_G 0x0C77
#define GL_PIXEL_MAP_B_TO_B 0x0C78
#define GL_PIXEL_MAP_A_TO_A 0x0C79
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_PACK_LSB_FIRST 0x0D01
#define GL_PACK_ROW_LENGTH 0x0D02
#define GL_PACK_SKIP_PIXELS 0x0D04
#define GL_PACK_SKIP_ROWS 0x0D03
#define GL_PACK_SWAP_BYTES 0x0D00
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_UNPACK_LSB_FIRST 0x0CF1
#define GL_UNPACK_ROW_LENGTH 0x0CF2
#define GL_UNPACK_SKIP_PIXELS 0x0CF4
#define GL_UNPACK_SKIP_ROWS 0x0CF3
#define GL_UNPACK_SWAP_BYTES 0x0CF0
#define GL_ZOOM_X 0x0D16
#define GL_ZOOM_Y 0x0D17
// blending
#define GL_BLEND 0x0BE2
#define GL_BLEND_SRC 0x0BE1
#define GL_BLEND_DST 0x0BE0
#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
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
// glGet
#define GL_AUX_BUFFERS 0x0C00
#define GL_MAX_ELEMENTS_VERTICES 0x80E8
#define GL_MAX_ELEMENTS_INDICES 0x80E9
#define GL_POINT_SIZE_RANGE 0x0B12
#define GL_RENDER_MODE 0x0C40
#define GL_NAME_STACK_DEPTH 0x0D70
#define GL_MAX_NAME_STACK_DEPTH 0x0D37
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
// evaluators
#define GL_AUTO_NORMAL 0x0D80
#define GL_MAP1_COLOR_4 0x0D90
#define GL_MAP1_INDEX 0x0D91
#define GL_MAP1_NORMAL 0x0D92
#define GL_MAP1_TEXTURE_COORD_1 0x0D93
#define GL_MAP1_TEXTURE_COORD_2 0x0D94
#define GL_MAP1_TEXTURE_COORD_3 0x0D95
#define GL_MAP1_TEXTURE_COORD_4 0x0D96
#define GL_MAP1_VERTEX_3 0x0D97
#define GL_MAP1_VERTEX_4 0x0D98
#define GL_MAP2_COLOR_4 0x0DB0
#define GL_MAP2_INDEX 0x0DB1
#define GL_MAP2_NORMAL 0x0DB2
#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
#define GL_MAP2_VERTEX_3 0x0DB7
#define GL_MAP2_VERTEX_4 0x0DB8
#define GL_MAP1_GRID_DOMAIN 0x0DD0
#define GL_MAP1_GRID_SEGMENTS 0x0DD1
#define GL_MAP2_GRID_DOMAIN 0x0DD2
#define GL_MAP2_GRID_SEGMENTS 0x0DD3
#define GL_COEFF 0x0A00
#define GL_ORDER 0x0A01
#define GL_DOMAIN 0x0A02
#define GL_MAX_LIST_NESTING 0x0B31
/* polygons */
#define GL_POINT 0x1B00
#define GL_LINE 0x1B01
#define GL_FILL 0x1B02
#define GL_CW 0x0900
#define GL_CCW 0x0901
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_POLYGON_MODE 0x0B40
#define GL_POLYGON_SMOOTH 0x0B41
#define GL_POLYGON_STIPPLE 0x0B42
#define GL_EDGE_FLAG 0x0B43
#define GL_CULL_FACE 0x0B44
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_POINT 0x2A01
#define GL_POLYGON_OFFSET_LINE 0x2A02
/* Shader Source */
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
/* Shader Binary */
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
/* Shader Precision-Specified Types */
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
/* Texture Parameters */
#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
#define GL_TEXTURE_RED_SIZE 0x805C
#define GL_TEXTURE_GREEN_SIZE 0x805D
#define GL_TEXTURE_BLUE_SIZE 0x805E
#define GL_TEXTURE_ALPHA_SIZE 0x805F
#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
#define GL_TEXTURE_INTENSITY_SIZE 0x8061
#define GL_TEXTURE_RED_TYPE 0x8C10
#define GL_TEXTURE_GREEN_TYPE 0x8C11
#define GL_TEXTURE_BLUE_TYPE 0x8C12
#define GL_TEXTURE_ALPHA_TYPE 0x8C13
#define GL_TEXTURE_DEPTH_TYPE 0x8C16
#define GL_TEXTURE_DEPTH 0x8071
#define GL_TEXTURE_DEPTH_SIZE 0x884A
#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
#define GL_TEXTURE_COMPRESSED 0x86A1
#define GL_TEXTURE_MAX_LEVEL 0x813D
/* Compressed Textures */
#define COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
#define COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
#define COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
#define COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
/* Render Mode */
#define GL_SELECT 0x1c02
#define GL_RENDER 0x1C00
/* Interleaved Array */
#define GL_V2F 0x2A20
#define GL_V3F 0x2A21
#define GL_C4UB_V2F 0x2A22
#define GL_C4UB_V3F 0x2A23
#define GL_C3F_V3F 0x2A24
#define GL_N3F_V3F 0x2A25
#define GL_C4F_N3F_V3F 0x2A26
#define GL_T2F_V3F 0x2A27
#define GL_T4F_V4F 0x2A28
#define GL_T2F_C4UB_V3F 0x2A29
#define GL_T2F_C3F_V3F 0x2A2A
#define GL_T2F_N3F_V3F 0x2A2B
#define GL_T2F_C4F_N3F_V3F 0x2A2C
#define GL_T4F_C4F_N3F_V4F 0x2A2D
/* Buffers Array */
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_QUERY_COUNTER_BITS 0x8864
#define GL_CURRENT_QUERY 0x8865
#define GL_QUERY_RESULT 0x8866
#define GL_QUERY_RESULT_AVAILABLE 0x8867
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
#define GL_READ_ONLY 0x88B8
#define GL_WRITE_ONLY 0x88B9
#define GL_READ_WRITE 0x88BA
#define GL_BUFFER_ACCESS 0x88BB
#define GL_BUFFER_MAPPED 0x88BC
#define GL_BUFFER_MAP_POINTER 0x88BD
#define GL_STREAM_DRAW 0x88E0
#define GL_STREAM_READ 0x88E1
#define GL_STREAM_COPY 0x88E2
#define GL_STATIC_DRAW 0x88E4
#define GL_STATIC_READ 0x88E5
#define GL_STATIC_COPY 0x88E6
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_DYNAMIC_READ 0x88E9
#define GL_DYNAMIC_COPY 0x88EA
#define GL_SAMPLES_PASSED 0x8914
#define GL_SRC1_ALPHA 0x8589
#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
#define GL_MAP_READ_BIT 0x0001
#define GL_MAP_WRITE_BIT 0x0002
#define GL_BUFFER_ACCESS_FLAGS 0x911F
#define GL_BUFFER_MAP_LENGTH 0x9120
#define GL_BUFFER_MAP_OFFSET 0x9121
#define GL_READ_ONLY 0x88B8
#define GL_WRITE_ONLY 0x88B9
#define GL_READ_WRITE 0x88BA
#define GL_PIXEL_PACK_BUFFER 0x88EB
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
/* Framebuffers */
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
#define GL_FRAMEBUFFER_DEFAULT 0x8218
#define GL_FRAMEBUFFER_UNDEFINED 0x8219
#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
#define GL_DEPTH_STENCIL 0x84F9
#define GL_UNSIGNED_INT_24_8 0x84FA
#define GL_DEPTH24_STENCIL8 0x88F0
#define GL_TEXTURE_STENCIL_SIZE 0x88F1
#define GL_TEXTURE_RED_TYPE 0x8C10
#define GL_TEXTURE_GREEN_TYPE 0x8C11
#define GL_TEXTURE_BLUE_TYPE 0x8C12
#define GL_TEXTURE_ALPHA_TYPE 0x8C13
#define GL_TEXTURE_DEPTH_TYPE 0x8C16
#define GL_UNSIGNED_NORMALIZED 0x8C17
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_READ_FRAMEBUFFER 0x8CA8
#define GL_DRAW_FRAMEBUFFER 0x8CA9
#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
#define GL_RENDERBUFFER_SAMPLES 0x8CAB
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_COLOR_ATTACHMENT1 0x8CE1
#define GL_COLOR_ATTACHMENT2 0x8CE2
#define GL_COLOR_ATTACHMENT3 0x8CE3
#define GL_COLOR_ATTACHMENT4 0x8CE4
#define GL_COLOR_ATTACHMENT5 0x8CE5
#define GL_COLOR_ATTACHMENT6 0x8CE6
#define GL_COLOR_ATTACHMENT7 0x8CE7
#define GL_COLOR_ATTACHMENT8 0x8CE8
#define GL_COLOR_ATTACHMENT9 0x8CE9
#define GL_COLOR_ATTACHMENT10 0x8CEA
#define GL_COLOR_ATTACHMENT11 0x8CEB
#define GL_COLOR_ATTACHMENT12 0x8CEC
#define GL_COLOR_ATTACHMENT13 0x8CED
#define GL_COLOR_ATTACHMENT14 0x8CEE
#define GL_COLOR_ATTACHMENT15 0x8CEF
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
#define GL_STENCIL_INDEX1 0x8D46
#define GL_STENCIL_INDEX4 0x8D47
#define GL_STENCIL_INDEX8 0x8D48
#define GL_STENCIL_INDEX16 0x8D49
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
#define GL_MAX_SAMPLES 0x8D57
#define GL_INDEX 0x8222
#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14
#define GL_TEXTURE_INTENSITY_TYPE 0x8C15
#define GL_DEPTH_COMPONENT24 0x81A6
#define GL_DEPTH_COMPONENT16 0x81A5

View File

@@ -0,0 +1,316 @@
#include <stdint.h>
#include <stddef.h>
/*
DXT1/DXT3/DXT5 texture decompression
The original code is from Benjamin Dobell, see below for details. Compared to
the original this one adds DXT3 decompression, is valid C89, and is x64
compatible as it uses fixed size integers everywhere. It also uses a different
PackRGBA order.
---
Copyright (c) 2012, Matthäus G. "Anteru" Chajdas (http://anteru.net)
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 THE
AUTHORS OR COPYRIGHT HOLDERS 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.
---
Copyright (C) 2009 Benjamin Dobell, Glass Echidna
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 THE
AUTHORS OR COPYRIGHT HOLDERS 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.
---
*/
static uint32_t PackRGBA (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{
return r | (g << 8) | (b << 16) | (a << 24);
}
static void DecompressBlockDXT1Internal (const uint8_t* block,
uint32_t* output,
uint32_t outputStride,
const uint8_t* alphaValues)
{
uint32_t temp, code;
uint16_t color0, color1;
uint8_t r0, g0, b0, r1, g1, b1;
int i, j;
color0 = *(const uint16_t*)(block);
color1 = *(const uint16_t*)(block + 2);
temp = (color0 >> 11) * 255 + 16;
r0 = (uint8_t)((temp/32 + temp)/32);
temp = ((color0 & 0x07E0) >> 5) * 255 + 32;
g0 = (uint8_t)((temp/64 + temp)/64);
temp = (color0 & 0x001F) * 255 + 16;
b0 = (uint8_t)((temp/32 + temp)/32);
temp = (color1 >> 11) * 255 + 16;
r1 = (uint8_t)((temp/32 + temp)/32);
temp = ((color1 & 0x07E0) >> 5) * 255 + 32;
g1 = (uint8_t)((temp/64 + temp)/64);
temp = (color1 & 0x001F) * 255 + 16;
b1 = (uint8_t)((temp/32 + temp)/32);
code = *(const uint32_t*)(block + 4);
if (color0 > color1) {
for (j = 0; j < 4; ++j) {
for (i = 0; i < 4; ++i) {
uint32_t finalColor, positionCode;
uint8_t alpha;
alpha = alphaValues [j*4+i];
finalColor = 0;
positionCode = (code >> 2*(4*j+i)) & 0x03;
switch (positionCode) {
case 0:
finalColor = PackRGBA(r0, g0, b0, alpha);
break;
case 1:
finalColor = PackRGBA(r1, g1, b1, alpha);
break;
case 2:
finalColor = PackRGBA((2*r0+r1)/3, (2*g0+g1)/3, (2*b0+b1)/3, alpha);
break;
case 3:
finalColor = PackRGBA((r0+2*r1)/3, (g0+2*g1)/3, (b0+2*b1)/3, alpha);
break;
}
output [j*outputStride + i] = finalColor;
}
}
} else {
for (j = 0; j < 4; ++j) {
for (i = 0; i < 4; ++i) {
uint32_t finalColor, positionCode;
uint8_t alpha;
alpha = alphaValues [j*4+i];
finalColor = 0;
positionCode = (code >> 2*(4*j+i)) & 0x03;
switch (positionCode) {
case 0:
finalColor = PackRGBA(r0, g0, b0, alpha);
break;
case 1:
finalColor = PackRGBA(r1, g1, b1, alpha);
break;
case 2:
finalColor = PackRGBA((r0+r1)/2, (g0+g1)/2, (b0+b1)/2, alpha);
break;
case 3:
finalColor = PackRGBA(0, 0, 0, alpha);
break;
}
output [j*outputStride + i] = finalColor;
}
}
}
}
/*
void DecompressBlockDXT1(): Decompresses one block of a DXT1 texture and stores the resulting pixels at the appropriate offset in 'image'.
uint32_t x: x-coordinate of the first pixel in the block.
uint32_t y: y-coordinate of the first pixel in the block.
uint32_t width: width of the texture being decompressed.
const uint8_t *blockStorage: pointer to the block to decompress.
uint32_t *image: pointer to image where the decompressed pixel data should be stored.
*/
void DecompressBlockDXT1(uint32_t x, uint32_t y, uint32_t width,
const uint8_t* blockStorage,
uint32_t* image)
{
static const uint8_t const_alpha [] = {
255, 255, 255, 255,
255, 255, 255, 255,
255, 255, 255, 255,
255, 255, 255, 255
};
DecompressBlockDXT1Internal (blockStorage,
image + x + (y * width), width, const_alpha);
}
/*
void DecompressBlockDXT5(): Decompresses one block of a DXT5 texture and stores the resulting pixels at the appropriate offset in 'image'.
uint32_t x: x-coordinate of the first pixel in the block.
uint32_t y: y-coordinate of the first pixel in the block.
uint32_t width: width of the texture being decompressed.
const uint8_t *blockStorage: pointer to the block to decompress.
uint32_t *image: pointer to image where the decompressed pixel data should be stored.
*/
void DecompressBlockDXT5(uint32_t x, uint32_t y, uint32_t width,
const uint8_t* blockStorage, uint32_t* image)
{
uint8_t alpha0, alpha1;
const uint8_t* bits;
uint32_t alphaCode1;
uint16_t alphaCode2;
uint16_t color0, color1;
uint8_t r0, g0, b0, r1, g1, b1;
int i, j;
uint32_t temp, code;
alpha0 = *(blockStorage);
alpha1 = *(blockStorage + 1);
bits = blockStorage + 2;
alphaCode1 = bits[2] | (bits[3] << 8) | (bits[4] << 16) | (bits[5] << 24);
alphaCode2 = bits[0] | (bits[1] << 8);
color0 = *(const uint16_t*)(blockStorage + 8);
color1 = *(const uint16_t*)(blockStorage + 10);
temp = (color0 >> 11) * 255 + 16;
r0 = (uint8_t)((temp/32 + temp)/32);
temp = ((color0 & 0x07E0) >> 5) * 255 + 32;
g0 = (uint8_t)((temp/64 + temp)/64);
temp = (color0 & 0x001F) * 255 + 16;
b0 = (uint8_t)((temp/32 + temp)/32);
temp = (color1 >> 11) * 255 + 16;
r1 = (uint8_t)((temp/32 + temp)/32);
temp = ((color1 & 0x07E0) >> 5) * 255 + 32;
g1 = (uint8_t)((temp/64 + temp)/64);
temp = (color1 & 0x001F) * 255 + 16;
b1 = (uint8_t)((temp/32 + temp)/32);
code = *(const uint32_t*)(blockStorage + 12);
for (j = 0; j < 4; j++) {
for (i = 0; i < 4; i++) {
uint8_t finalAlpha;
int alphaCode, alphaCodeIndex;
uint8_t colorCode;
uint32_t finalColor;
alphaCodeIndex = 3*(4*j+i);
if (alphaCodeIndex <= 12) {
alphaCode = (alphaCode2 >> alphaCodeIndex) & 0x07;
} else if (alphaCodeIndex == 15) {
alphaCode = (alphaCode2 >> 15) | ((alphaCode1 << 1) & 0x06);
} else /* alphaCodeIndex >= 18 && alphaCodeIndex <= 45 */ {
alphaCode = (alphaCode1 >> (alphaCodeIndex - 16)) & 0x07;
}
if (alphaCode == 0) {
finalAlpha = alpha0;
} else if (alphaCode == 1) {
finalAlpha = alpha1;
} else {
if (alpha0 > alpha1) {
finalAlpha = (uint8_t)(((8-alphaCode)*alpha0 + (alphaCode-1)*alpha1)/7);
} else {
if (alphaCode == 6) {
finalAlpha = 0;
} else if (alphaCode == 7) {
finalAlpha = 255;
} else {
finalAlpha = (uint8_t)(((6-alphaCode)*alpha0 + (alphaCode-1)*alpha1)/5);
}
}
}
colorCode = (code >> 2*(4*j+i)) & 0x03;
finalColor = 0;
switch (colorCode) {
case 0:
finalColor = PackRGBA(r0, g0, b0, finalAlpha);
break;
case 1:
finalColor = PackRGBA(r1, g1, b1, finalAlpha);
break;
case 2:
finalColor = PackRGBA((2*r0+r1)/3, (2*g0+g1)/3, (2*b0+b1)/3, finalAlpha);
break;
case 3:
finalColor = PackRGBA((r0+2*r1)/3, (g0+2*g1)/3, (b0+2*b1)/3, finalAlpha);
break;
}
image [i + x + (width* (y+j))] = finalColor;
}
}
}
/*
void DecompressBlockDXT3(): Decompresses one block of a DXT3 texture and stores the resulting pixels at the appropriate offset in 'image'.
uint32_t x: x-coordinate of the first pixel in the block.
uint32_t y: y-coordinate of the first pixel in the block.
uint32_t height: height of the texture being decompressed.
const uint8_t *blockStorage: pointer to the block to decompress.
uint32_t *image: pointer to image where the decompressed pixel data should be stored.
*/
void DecompressBlockDXT3(uint32_t x, uint32_t y, uint32_t width,
const uint8_t* blockStorage,
uint32_t* image)
{
int i;
uint8_t alphaValues [16] = { 0 };
for (i = 0; i < 4; ++i) {
const uint16_t* alphaData = (const uint16_t*) (blockStorage);
alphaValues [i*4 + 0] = (((*alphaData) >> 0) & 0xF ) * 17;
alphaValues [i*4 + 1] = (((*alphaData) >> 4) & 0xF ) * 17;
alphaValues [i*4 + 2] = (((*alphaData) >> 8) & 0xF ) * 17;
alphaValues [i*4 + 3] = (((*alphaData) >> 12) & 0xF) * 17;
blockStorage += 2;
}
DecompressBlockDXT1Internal (blockStorage,
image + x + (y * width), width, alphaValues);
}

View File

@@ -0,0 +1,19 @@
#ifndef _DECOMPRESS_H_
#define _DECOMPRESS_H_
#include "gl.h"
void DecompressBlockDXT1(uint32_t x, uint32_t y, uint32_t width,
const uint8_t* blockStorage,
uint32_t* image);
void DecompressBlockDXT3(uint32_t x, uint32_t y, uint32_t width,
const uint8_t* blockStorage,
uint32_t* image);
void DecompressBlockDXT5(uint32_t x, uint32_t y, uint32_t width,
const uint8_t* blockStorage, uint32_t* image);
#endif

View File

@@ -0,0 +1,34 @@
#include <GL/gl.h>
// newly-defined GL functions
GLboolean glIsList(GLuint list);
GLuint glGenLists(GLsizei range);
void glActiveTextureARB(GLenum texture);
void glArrayElement(GLint i);
void glBegin(GLenum mode);
void glCallList(GLuint list);
void glCallLists(GLsizei n, GLenum type, const GLvoid *lists);
void glClearDepth(GLdouble depth);
void glDeleteList(GLuint list);
void glDeleteLists(GLuint list, GLsizei range);
void glDrawArrays(GLenum mode, GLint first, GLsizei count);
void glEnd();
void glEndList();
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void glGetDoublev(GLenum pname, GLdouble *params);
void glIndexf(GLfloat i);
void glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
void glListBase(GLuint base);
void glLockArraysEXT(GLint first, GLsizei count);
void glNewList(GLuint list, GLenum mode);
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void glSecondaryColor3f(GLfloat r, GLfloat g, GLfloat b);
void glTexCoord2f(GLfloat s, GLfloat t);
void glUnlockArraysEXT();
void glVertex2f(GLfloat x, GLfloat y);
void glVertex2i(GLint x, GLint y);
void glVertex3f(GLfloat x, GLfloat y, GLfloat z);
GLenum glGetError();
// custom functions
void glPushCall(void *call);

317
project/jni/glshim/src/gl/eval.c Executable file
View File

@@ -0,0 +1,317 @@
// TODO: glIsEnabled(), glGetMap()
// TODO: GL_AUTO_NORMAL
#include "eval.h"
#include "math/eval.h"
static inline map_state_t **get_map_pointer(GLenum target) {
switch (target) {
case GL_MAP1_COLOR_4: return &state.map1.color4;
case GL_MAP1_INDEX: return &state.map1.index;
case GL_MAP1_TEXTURE_COORD_1: return &state.map1.texture1;
case GL_MAP1_TEXTURE_COORD_2: return &state.map1.texture2;
case GL_MAP1_TEXTURE_COORD_3: return &state.map1.texture3;
case GL_MAP1_TEXTURE_COORD_4: return &state.map1.texture4;
case GL_MAP1_VERTEX_3: return &state.map1.vertex3;
case GL_MAP1_VERTEX_4: return &state.map1.vertex4;
case GL_MAP2_COLOR_4: return &state.map2.color4;
case GL_MAP2_INDEX: return &state.map2.index;
case GL_MAP2_TEXTURE_COORD_1: return &state.map2.texture1;
case GL_MAP2_TEXTURE_COORD_2: return &state.map2.texture2;
case GL_MAP2_TEXTURE_COORD_3: return &state.map2.texture3;
case GL_MAP2_TEXTURE_COORD_4: return &state.map2.texture4;
case GL_MAP2_VERTEX_3: return &state.map2.vertex3;
case GL_MAP2_VERTEX_4: return &state.map2.vertex4;
default:
printf("libGL: unknown glMap target 0x%x\n", target);
}
return NULL;
}
#define set_map_coords(n) \
map->n._1 = n##1; \
map->n._2 = n##2; \
map->n.d = 1.0/(n##2 - n##1); \
map->n.stride = n##stride; \
map->n.order = n##order;
#define case_state(dims, magic, name) \
case magic: { \
map->width = get_map_width(magic); \
map_statef_t *m = (map_statef_t *)state.map##dims.name; \
if (m) { \
if (m->free) \
free((void *)m->points); \
free(m); \
} \
state.map##dims.name = (map_state_t *)map; \
break; \
}
#define map_switch(dims) \
switch (target) { \
case_state(dims, GL_MAP##dims##_COLOR_4, color4); \
case_state(dims, GL_MAP##dims##_INDEX, index); \
case_state(dims, GL_MAP##dims##_NORMAL, normal); \
case_state(dims, GL_MAP##dims##_TEXTURE_COORD_1, texture1); \
case_state(dims, GL_MAP##dims##_TEXTURE_COORD_2, texture2); \
case_state(dims, GL_MAP##dims##_TEXTURE_COORD_3, texture3); \
case_state(dims, GL_MAP##dims##_TEXTURE_COORD_4, texture4); \
case_state(dims, GL_MAP##dims##_VERTEX_3, vertex3); \
case_state(dims, GL_MAP##dims##_VERTEX_4, vertex4); \
}
void glMap1d(GLenum target, GLdouble u1, GLdouble u2,
GLint ustride, GLint uorder, const GLdouble *points) {
noerrorShim();
map_statef_t *map = malloc(sizeof(map_statef_t));
map->type = GL_FLOAT; map->dims = 1; map->free = true;
set_map_coords(u);
map_switch(1);
map->points = copy_eval_double(target, ustride, uorder, 0, 1, points);
}
void glMap1f(GLenum target, GLfloat u1, GLfloat u2,
GLint ustride, GLint uorder, const GLfloat *points) {
noerrorShim();
map_statef_t *map = malloc(sizeof(map_statef_t));
map->type = GL_FLOAT; map->dims = 1; map->free = false;
set_map_coords(u);
map_switch(1);
map->points = points;
}
void glMap2d(GLenum target, GLdouble u1, GLdouble u2,
GLint ustride, GLint uorder, GLdouble v1, GLdouble v2,
GLint vstride, GLint vorder, const GLdouble *points) {
noerrorShim();
map_statef_t *map = malloc(sizeof(map_statef_t));
map->type = GL_FLOAT; map->dims = 2; map->free = true;
set_map_coords(u);
set_map_coords(v);
map_switch(2);
map->points = copy_eval_double(target, ustride, uorder, vstride, vorder, points);
}
void glMap2f(GLenum target, GLfloat u1, GLfloat u2,
GLint ustride, GLint uorder, GLfloat v1, GLfloat v2,
GLint vstride, GLint vorder, const GLfloat *points) {
noerrorShim();
map_statef_t *map = malloc(sizeof(map_statef_t));
map->type = GL_FLOAT; map->dims = 2; map->free = false;
set_map_coords(u);
set_map_coords(v);
map_switch(2);
map->points = points;
}
#undef set_map_coords
#undef case_state
#undef map_switch
#define p_map(d, name, func, code) { \
map_state_t *_map = state.map##d.name; \
if (_map) { \
if (_map->type == GL_DOUBLE) { \
map_stated_t *map = (map_stated_t *)_map; \
printf("double: not implemented\n"); \
} else if (_map->type == GL_FLOAT) { \
map_statef_t *map = (map_statef_t *)_map; \
GLfloat out[4]; \
code \
func##v(out); \
} \
}}
#define iter_maps(d, code) \
p_map(d, color4, glColor4f, code); \
p_map(d, index, glIndexf, code); \
p_map(d, normal, glNormal3f, code); \
p_map(d, texture1, glTexCoord1f, code); \
p_map(d, texture2, glTexCoord2f, code); \
p_map(d, texture3, glTexCoord3f, code); \
p_map(d, texture4, glTexCoord4f, code); \
p_map(d, vertex3, glVertex3f, code); \
p_map(d, vertex4, glVertex4f, code);
void glEvalCoord1f(GLfloat u) {
noerrorShim();
iter_maps(1,
GLfloat uu = (u - map->u._1) * map->u.d;
_math_horner_bezier_curve(map->points, out, uu, map->width, map->u.order);
)
}
void glEvalCoord2f(GLfloat u, GLfloat v) {
noerrorShim();
iter_maps(2,
GLfloat uu = (u - map->u._1) * map->u.d;
GLfloat vv = (v - map->v._1) * map->v.d;
// TODO: GL_AUTONORMAL
_math_horner_bezier_surf((GLfloat *)map->points, out, uu, vv,
map->width, map->u.order, map->v.order);
)
}
#undef p_map
#undef iter_maps
void glMapGrid1f(GLint un, GLfloat u1, GLfloat u2) {
noerrorShim();
// TODO: double support?
map_statef_t *map;
if (! state.map_grid)
state.map_grid = malloc(sizeof(map_statef_t));
map = (map_statef_t *)state.map_grid;
map->dims = 1;
map->u.n = un;
map->u._1 = u1;
map->u._2 = u2;
}
void glMapGrid2f(GLint un, GLfloat u1, GLfloat u2,
GLint vn, GLfloat v1, GLfloat v2) {
noerrorShim();
// TODO: double support?
map_statef_t *map;
if (! state.map_grid)
state.map_grid = malloc(sizeof(map_statef_t));
map = (map_statef_t *)state.map_grid;
map->dims = 2;
map->u.n = un;
map->u._1 = u1;
map->u._2 = u2;
map->v.n = vn;
map->v._1 = v1;
map->v._2 = v2;
}
static inline GLenum eval_mesh_prep(map_statef_t **map, GLenum mode) {
if (state.map2.vertex4) {
*map = (map_statef_t *)state.map2.vertex4;
} else if (state.map2.vertex3) {
*map = (map_statef_t *)state.map2.vertex3;
} else {
return 0;
}
if ((*map)->type == GL_DOUBLE) {
printf("libGL: GL_DOUBLE map not implemented\n");
return 0;
}
switch (mode) {
case GL_POINT: return GL_POINTS;
case GL_LINE: return GL_LINE_STRIP;
case GL_FILL: return GL_TRIANGLE_STRIP;
case 0: return 1;
default:
printf("unknown glEvalMesh mode: %x\n", mode);
return 0;
}
}
void glEvalMesh1(GLenum mode, GLint i1, GLint i2) {
noerrorShim();
map_statef_t *map;
GLenum renderMode = eval_mesh_prep(&map, mode);
if (! renderMode)
return;
GLfloat u, du, u1;
du = map->u.d;
GLint i;
glBegin(renderMode);
for (u = u1, i = i1; i <= i2; i++, u += du) {
glEvalCoord1f(u);
}
glEnd();
}
void glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) {
noerrorShim();
map_statef_t *map;
GLenum renderMode = eval_mesh_prep(&map, mode);
if (! renderMode)
return;
GLfloat u, du, u1, v, dv, v1;
du = map->u.d;
dv = map->v.d;
GLint i, j;
glBegin(renderMode);
for (v = v1, j = j1; j <= j2; j++, v += dv) {
for (u = u1, i = i1; i <= i2; i++, u += du) {
glEvalCoord2f(u, v);
if (mode == GL_FILL)
glEvalCoord2f(u, v + dv);
}
}
glEnd();
if (mode == GL_LINE) {
glBegin(renderMode);
for (u = u1, i = i1; i <= i2; i++, u += du) {
for (v = v1, j = j1; j <= j2; j++, v += dv) {
glEvalCoord2f(u, v);
}
}
glEnd();
}
}
void glEvalPoint1(GLint i) {
map_statef_t *map;
if (eval_mesh_prep(&map, 0))
glEvalCoord1f(i + map->u.d);
}
void glEvalPoint2(GLint i, GLint j) {
map_statef_t *map;
if (eval_mesh_prep(&map, 0))
glEvalCoord2f(i + map->u.d, j + map->v.d);
}
#define GL_GET_MAP(t, type) \
void glGetMap##t##v(GLenum target, GLenum query, type *v) { \
noerrorShim(); \
map_statef_t *map = *(map_statef_t **)get_map_pointer(target); \
if (map) { \
switch (query) { \
case GL_COEFF: { \
const GLfloat *points = map->points; \
for (int i = 0; i < map->u.order; i++) { \
if (map->dims == 2) { \
for (int j = 0; j < map->v.order; j++) { \
*v++ = *points++; \
} \
} else { \
*v++ = *points++; \
} \
} \
return; \
} \
case GL_ORDER: \
*v++ = map->u.order; \
if (map->dims == 2) \
*v++ = map->v.order; \
return; \
case GL_DOMAIN: \
*v++ = map->u._1; \
*v++ = map->u._2; \
if (map->dims == 2) { \
*v++ = map->u._1; \
*v++ = map->u._2; \
} \
return; \
} \
} \
}
GL_GET_MAP(i, GLint)
GL_GET_MAP(f, GLfloat)
GL_GET_MAP(d, GLdouble)
#undef GL_GET_MAP

View File

@@ -0,0 +1,82 @@
#include "gl.h"
#ifndef GL_MAP_H
#define GL_MAP_H
void glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
void glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
void glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
void glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
void glEvalCoord1d(GLdouble u);
void glEvalCoord1f(GLfloat u);
void glEvalCoord2d(GLdouble u, GLdouble v);
void glEvalCoord2f(GLfloat u, GLfloat v);
void glEvalMesh1(GLenum mode, GLint i1, GLint i2);
void glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
void glEvalPoint1(GLint i);
void glEvalPoint2(GLint i, GLint j);
void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2);
void glMapGrid1f(GLint un, GLfloat u1, GLfloat u2);
void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
void glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
void glGetMapdv(GLenum target, GLenum query, GLdouble *v);
void glGetMapfv(GLenum target, GLenum query, GLfloat *v);
void glGetMapiv(GLenum target, GLenum query, GLint *v);
typedef struct {
GLenum type;
} map_state_t;
typedef struct {
GLdouble _1, _2, n, d;
GLint stride, order;
} mapcoordd_t;
typedef struct {
GLdouble _1, _2, n, d;
GLint stride, order;
} mapcoordf_t;
typedef struct {
GLenum type;
GLint dims, width;
mapcoordd_t u, v;
GLboolean free;
const GLdouble *points;
} map_stated_t;
typedef struct {
GLenum type;
GLint dims, width;
mapcoordf_t u, v;
GLboolean free;
const GLfloat *points;
} map_statef_t;
static const GLsizei get_map_width(GLenum target) {
switch (target) {
case GL_MAP1_COLOR_4: return 4;
case GL_MAP1_INDEX: return 3;
case GL_MAP1_NORMAL: return 3;
case GL_MAP1_TEXTURE_COORD_1: return 1;
case GL_MAP1_TEXTURE_COORD_2: return 2;
case GL_MAP1_TEXTURE_COORD_3: return 3;
case GL_MAP1_TEXTURE_COORD_4: return 4;
case GL_MAP1_VERTEX_3: return 3;
case GL_MAP1_VERTEX_4: return 4;
case GL_MAP2_COLOR_4: return 4;
case GL_MAP2_INDEX: return 3;
case GL_MAP2_NORMAL: return 3;
case GL_MAP2_TEXTURE_COORD_1: return 1;
case GL_MAP2_TEXTURE_COORD_2: return 2;
case GL_MAP2_TEXTURE_COORD_3: return 3;
case GL_MAP2_TEXTURE_COORD_4: return 4;
case GL_MAP2_VERTEX_3: return 3;
case GL_MAP2_VERTEX_4: return 4;
}
return 0;
}
#endif

View File

@@ -0,0 +1,618 @@
#include "framebuffers.h"
#ifndef ANDROID
#include <execinfo.h>
#endif
//extern void* eglGetProcAddress(const char* name);
khash_t(dsr) *depthstencil = NULL;
GLuint current_rb = 0;
GLuint current_fb = 0;
GLuint mainfbo_fbo = 0; // The MainFBO
GLuint mainfbo_tex = 0; // Texture Attachment
GLuint mainfbo_dep = 0; // Depth attachment
GLuint mainfbo_ste = 0; // Stencil attachement
int mainfbo_width = 800;
int mainfbo_height = 480;
int mainfbo_nwidth = 1024;
int mainfbo_nheight = 512;
GLuint fbo_read = 0; // if not 0, that's the READ only Framebuffer attached
GLuint fbo_draw = 0; // if not 0, that's the DRAW only Framebuffer attached
int npot(int n);
void readfboBegin() {
//printf("readfboBegin, fbo status read=%u, draw=%u, main=%u, current=%u\n", fbo_read, fbo_draw, mainfbo_fbo, current_fb);
LOAD_GLES_OES(glBindFramebuffer);
if (!(fbo_read || fbo_draw))
return;
GLuint fbo = fbo_read;
if (!fbo && mainfbo_fbo)
fbo = mainfbo_fbo;
gles_glBindFramebuffer(GL_FRAMEBUFFER, fbo);
}
void readfboEnd() {
//printf("readfboEnd, fbo status read=%u, draw=%u, main=%u, current=%u\n", fbo_read, fbo_draw, mainfbo_fbo, current_fb);
LOAD_GLES_OES(glBindFramebuffer);
if (!(fbo_read || fbo_draw))
return;
GLuint fbo = current_fb;
if (!fbo && mainfbo_fbo)
fbo = mainfbo_fbo;
gles_glBindFramebuffer(GL_FRAMEBUFFER, fbo);
}
void glGenFramebuffers(GLsizei n, GLuint *ids) {
LOAD_GLES_OES(glGenFramebuffers);
//printf("glGenFramebuffers(%i, %p)\n", n, ids);
errorGL();
gles_glGenFramebuffers(n, ids);
}
void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) {
//printf("glDeleteFramebuffers(%i, %p), framebuffers[0]=%u\n", n, framebuffers, framebuffers[0]);
LOAD_GLES_OES(glDeleteFramebuffers);
errorGL();
gles_glDeleteFramebuffers(n, framebuffers);
}
GLboolean glIsFramebuffer(GLuint framebuffer) {
//printf("glIsFramebuffer(%u)\n", framebuffer);
LOAD_GLES_OES(glIsFramebuffer);
errorGL();
return gles_glIsFramebuffer(framebuffer);
}
GLenum fb_status;
GLenum glCheckFramebufferStatus(GLenum target) {
//LOAD_GLES_OES(glCheckFramebufferStatus);
//errorGL();
//GLenum result = gles_glCheckFramebufferStatus(target);
GLenum result = fb_status;
noerrorShim();
//printf("glCheckFramebufferStatus(0x%04X)=0x%04X\n", target, result);
return result;
}
void glBindFramebuffer(GLenum target, GLuint framebuffer) {
//printf("glBindFramebuffer(0x%04X, %u), list=%s\n", target, framebuffer, state.list.active?"active":"none");
PUSH_IF_COMPILING(glBindFramebuffer);
LOAD_GLES_OES(glBindFramebuffer);
LOAD_GLES_OES(glCheckFramebufferStatus);
// fixme lubomyr
LOAD_GLES(glGetError);
if (target == GL_FRAMEBUFFER) {
if (fbo_read)
fbo_read = 0;
if (fbo_draw)
fbo_draw = 0;
}
if (target == GL_READ_FRAMEBUFFER) {
fbo_read = framebuffer;
noerrorShim();
fb_status = GL_FRAMEBUFFER_COMPLETE;
return; //don't bind for now
}
if (target == GL_DRAW_FRAMEBUFFER) {
target = GL_FRAMEBUFFER;
fbo_draw = framebuffer;
}
current_fb = framebuffer;
if (mainfbo_fbo && (framebuffer==0))
framebuffer = mainfbo_fbo;
//errorGL();
//noerrorShim();
gles_glBindFramebuffer(target, framebuffer);
GLenum err=gles_glGetError();
errorShim(err);
fb_status = gles_glCheckFramebufferStatus(target);
}
void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
LOAD_GLES_OES(glFramebufferTexture2D);
LOAD_GLES(glTexImage2D);
LOAD_GLES(glBindTexture);
//printf("glFramebufferTexture2D(0x%04X, 0x%04X, 0x%04X, %u, %i)\n", target, attachment, textarget, texture, level);
// find texture and get it's real name
if (texture) {
gltexture_t *tex = NULL;
int ret;
khint_t k;
khash_t(tex) *list = state.texture.list;
if (! list) {
list = state.texture.list = kh_init(tex);
// segfaults if we don't do a single put
kh_put(tex, list, 1, &ret);
kh_del(tex, list, 1);
}
k = kh_get(tex, list, texture);
if (k == kh_end(list)){
} else {
tex = kh_value(list, k);
texture = tex->glname;
// check if texture is shrinked...
if (tex->shrink) {
printf("LIBGL: unshrinking shrinked texture for FBO\n");
tex->width *= 2*tex->shrink;
tex->height *= 2*tex->shrink;
tex->nwidth = npot(tex->width);
tex->nheight = npot(tex->height);
tex->shrink = 0;
gltexture_t *bound = state.texture.bound[state.texture.active];
GLuint oldtex = (bound)?bound->glname:0;
if (oldtex!=tex->glname) gles_glBindTexture(GL_TEXTURE_2D, tex->glname);
gles_glTexImage2D(GL_TEXTURE_2D, 0, tex->format, tex->width, tex->height, 0, tex->format, tex->type, NULL);
if (oldtex!=tex->glname) gles_glBindTexture(GL_TEXTURE_2D, oldtex);
}
//printf("found texture, glname=%u, size=%ix%i(%ix%i), format/type=0x%04X/0x%04X\n", texture, tex->width, tex->height, tex->nwidth, tex->nheight, tex->format, tex->type);
}
}
errorGL();
gles_glFramebufferTexture2D(target, attachment, textarget, texture, level);
}
void glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
glFramebufferTexture2D(target, attachment, GL_TEXTURE_2D, texture, level);
}
void glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer) {
(void)layer;
glFramebufferTexture2D(target, attachment, GL_TEXTURE_2D, texture, level);
}
void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers) {
LOAD_GLES_OES(glGenRenderbuffers);
//printf("glGenRenderbuffers(%i, %p)\n", n, renderbuffers);
errorGL();
gles_glGenRenderbuffers(n, renderbuffers);
}
void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) {
LOAD_GLES_OES(glFramebufferRenderbuffer);
//printf("glFramebufferRenderbuffer(0x%04X, 0x%04X, 0x%04X, %u)\n", target, attachment, renderbuffertarget, renderbuffer);
if (depthstencil && (attachment==GL_STENCIL_ATTACHMENT)) {
khint_t k = kh_get(dsr, depthstencil, renderbuffer);
if (k != kh_end(depthstencil)) {
gldepthstencil_t *dsr = kh_value(depthstencil, k);
renderbuffer = dsr->stencil;
}
}
errorGL();
gles_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
}
void glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers) {
LOAD_GLES_OES(glDeleteRenderbuffers);
// check if we delete a depthstencil
khint_t k;
if (depthstencil)
for (int i=0; i<n; i++) {
khint_t k;
gldepthstencil_t *dsr;
for (int i = 0; i < n; i++) {
GLuint t = renderbuffers[i];
k = kh_get(dsr, depthstencil, t);
if (k != kh_end(depthstencil)) {
dsr = kh_value(depthstencil, k);
gles_glDeleteRenderbuffers(1, &dsr->stencil);
kh_del(dsr, depthstencil, k);
free(dsr);
}
}
}
errorGL();
gles_glDeleteRenderbuffers(n, renderbuffers);
}
void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
LOAD_GLES_OES(glRenderbufferStorage);
LOAD_GLES_OES(glGenRenderbuffers);
LOAD_GLES_OES(glBindRenderbuffer);
//printf("glRenderbufferStorage(0x%04X, 0x%04X, %i, %i)\n", target, internalformat, width, height);
errorGL();
width = npot(width);
height = npot(height);
// check if internal format is GL_DEPTH_STENCIL_EXT
// in that case, create first a STENCIL one then a DEPTH one....
if ((internalformat == GL_DEPTH_STENCIL) || (internalformat == GL_DEPTH24_STENCIL8)) {
khint_t k;
int ret;
internalformat = GL_DEPTH_COMPONENT24;
GLuint old_rb = current_rb;
GLuint stencil;
if (!depthstencil) {
depthstencil = kh_init(dsr);
// segfaults if we don't do a single put
kh_put(dsr, depthstencil, 1, &ret);
kh_del(dsr, depthstencil, 1);
}
// search for an existing buffer (should not exist!)
k = kh_get(dsr, depthstencil, current_rb);
gldepthstencil_t *dsr = NULL;
if (k == kh_end(depthstencil)){
k = kh_put(dsr, depthstencil, current_rb, &ret);
dsr = kh_value(depthstencil, k) = malloc(sizeof(gldepthstencil_t));
dsr->renderbuffer = current_rb;
} else {
dsr = kh_value(depthstencil, k);
}
// create a stencil buffer
gles_glGenRenderbuffers(1, &stencil);
dsr->stencil = stencil;
gles_glBindRenderbuffer(GL_RENDERBUFFER, stencil);
gles_glRenderbufferStorage(target, GL_STENCIL_INDEX8, width, height);
gles_glBindRenderbuffer(GL_RENDERBUFFER, current_rb);
}
gles_glRenderbufferStorage(target, internalformat, width, height);
}
void glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) { //STUB
glRenderbufferStorage(target, internalformat, width, height);
}
void glBindRenderbuffer(GLenum target, GLuint renderbuffer) {
PUSH_IF_COMPILING(glBindRenderbuffer);
LOAD_GLES_OES(glBindRenderbuffer);
//printf("glBindRenderbuffer(0x%04X, %u)\n", target, renderbuffer);
current_rb = renderbuffer;
errorGL();
gles_glBindRenderbuffer(target, renderbuffer);
}
GLboolean glIsRenderbuffer(GLuint renderbuffer) {
//printf("glIsRenderbuffer(%u)\n", renderbuffer);
LOAD_GLES_OES(glIsRenderbuffer);
errorGL();
return gles_glIsRenderbuffer(renderbuffer);
}
void glGenerateMipmap(GLenum target) {
//printf("glGenerateMipmap(0x%04X)\n", target);
LOAD_GLES_OES(glGenerateMipmap);
errorGL();
return gles_glGenerateMipmap(target);
}
void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params) {
LOAD_GLES_OES(glGetFramebufferAttachmentParameteriv);
errorGL();
return gles_glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
}
void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint * params) {
LOAD_GLES_OES(glGetRenderbufferParameteriv);
errorGL();
return gles_glGetRenderbufferParameteriv(target, pname, params);
}
void createMainFBO(int width, int height) {
LOAD_GLES_OES(glGenFramebuffers);
LOAD_GLES_OES(glBindFramebuffer);
LOAD_GLES_OES(glFramebufferTexture2D);
LOAD_GLES_OES(glCheckFramebufferStatus);
LOAD_GLES_OES(glFramebufferRenderbuffer);
LOAD_GLES_OES(glRenderbufferStorage);
LOAD_GLES_OES(glGenRenderbuffers);
LOAD_GLES_OES(glBindRenderbuffer);
LOAD_GLES(glTexImage2D);
LOAD_GLES(glGenTextures);
LOAD_GLES(glBindTexture);
LOAD_GLES(glActiveTexture);
LOAD_GLES(glTexParameteri);
LOAD_GLES(glClientActiveTexture);
LOAD_GLES(glClear);
// If there is already a Framebuffer created, let's delete it....
if (mainfbo_fbo)
deleteMainFBO();
// switch to texture unit 0 if needed
if (state.texture.active != 0)
gles_glActiveTexture(GL_TEXTURE0);
if (state.texture.client != 0)
gles_glClientActiveTexture(GL_TEXTURE0);
mainfbo_width = width;
mainfbo_height = height;
mainfbo_nwidth = width = npot(width);
mainfbo_nheight = height = npot(height);
// create the texture
gles_glGenTextures(1, &mainfbo_tex);
gles_glBindTexture(GL_TEXTURE_2D, mainfbo_tex);
gles_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gles_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gles_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gles_glBindTexture(GL_TEXTURE_2D, 0);
// create the render buffers
gles_glGenRenderbuffers(1, &mainfbo_dep);
gles_glGenRenderbuffers(1, &mainfbo_ste);
gles_glBindRenderbuffer(GL_RENDERBUFFER, mainfbo_ste);
gles_glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
gles_glBindRenderbuffer(GL_RENDERBUFFER, mainfbo_dep);
gles_glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
gles_glBindRenderbuffer(GL_RENDERBUFFER, 0);
// create a fbo
gles_glGenFramebuffers(1, &mainfbo_fbo);
gles_glBindFramebuffer(GL_FRAMEBUFFER, mainfbo_fbo);
gles_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mainfbo_ste);
gles_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mainfbo_dep);
gles_glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mainfbo_tex, 0);
GLenum status = gles_glCheckFramebufferStatus(GL_FRAMEBUFFER);
gles_glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Final check, and bind the fbo for future use
if (status != GL_FRAMEBUFFER_COMPLETE) {
printf("LIBGL: Error while creating main fbo (0x%04X)\n", status);
deleteMainFBO();
gles_glBindFramebuffer(GL_FRAMEBUFFER, current_fb);
gles_glBindFramebuffer(GL_RENDERBUFFER, current_rb);
} else {
gles_glBindFramebuffer(GL_FRAMEBUFFER, (current_fb)?current_fb:mainfbo_fbo);
if (current_rb)
gles_glBindRenderbuffer(GL_RENDERBUFFER, current_rb);
// clear color, depth and stencil...
if (current_fb==0)
gles_glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
// Put everything back, and active the MainFBO
if (state.texture.bound[0])
gles_glBindTexture(GL_TEXTURE_2D, state.texture.bound[0]->glname);
if (state.texture.active != 0)
gles_glActiveTexture(GL_TEXTURE0 + state.texture.active);
if (state.texture.client != 0)
gles_glClientActiveTexture(GL_TEXTURE0 + state.texture.client);
}
void blitMainFBO() {
LOAD_GLES_OES(glDrawTexi);
LOAD_GLES(glBindTexture);
LOAD_GLES(glActiveTexture);
LOAD_GLES(glClientActiveTexture);
LOAD_GLES(glViewport);
LOAD_GLES(glEnable);
LOAD_GLES(glDisable);
LOAD_GLES(glGetIntegerv);
if (mainfbo_fbo==0)
return;
// switch to texture unit 0 if needed
if (state.texture.active != 0)
gles_glActiveTexture(GL_TEXTURE0);
if (state.texture.client != 0)
gles_glClientActiveTexture(GL_TEXTURE0);
// bind the FBO texture
gles_glEnable(GL_TEXTURE_2D);
gles_glBindTexture(GL_TEXTURE_2D, mainfbo_tex);
// blit
GLuint old_vp[4];
gles_glGetIntegerv(GL_VIEWPORT, old_vp);
gles_glViewport(0, 0, mainfbo_width, mainfbo_height);
// Draw the texture
#if 1
gles_glDrawTexi(0, 0, 0, mainfbo_width, mainfbo_height);
#else
{
LOAD_GLES(glEnableClientState);
LOAD_GLES(glDisableClientState);
LOAD_GLES(glBindTexture);
LOAD_GLES(glVertexPointer);
LOAD_GLES(glTexCoordPointer);
LOAD_GLES(glDrawArrays);
glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT);
GLfloat old_projection[16], old_modelview[16], old_texture[16];
glMatrixMode(GL_TEXTURE);
glGetFloatv(GL_TEXTURE_MATRIX, old_texture);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glGetFloatv(GL_PROJECTION_MATRIX, old_projection);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glGetFloatv(GL_MODELVIEW_MATRIX, old_modelview);
glLoadIdentity();
float w2 = 800 / 2.0f;
float h2 = 480 / 2.0f;
float x1=0;
float x2=mainfbo_width;
float y1=0;
float y2=mainfbo_height;
GLfloat vert[] = {
(x1-w2)/w2, (y1-h2)/h2, 0,
(x2-w2)/w2, (y1-h2)/h2, 0,
(x2-w2)/w2, (y2-h2)/h2, 0,
(x1-w2)/w2, (y2-h2)/h2, 0,
};
float sw = mainfbo_width / mainfbo_nwidth;
float sh = mainfbo_height / mainfbo_nheight;
GLfloat tex[] = {
0, 0,
sw, 0,
sw, sh,
0, sh
};
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT | GL_CLIENT_PIXEL_STORE_BIT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.0f);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
gles_glEnableClientState(GL_VERTEX_ARRAY);
gles_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
gles_glDisableClientState(GL_COLOR_ARRAY);
gles_glDisableClientState(GL_NORMAL_ARRAY);
gles_glVertexPointer(3, GL_FLOAT, 0, vert);
gles_glTexCoordPointer(2, GL_FLOAT, 0, tex);
//glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
gles_glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// All the previous states are Pushed / Poped anyway...
glPopClientAttrib();
glMatrixMode(GL_TEXTURE);
glLoadMatrixf(old_texture);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(old_modelview);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(old_projection);
glPopAttrib();
}
#endif
// put back viewport
gles_glViewport(old_vp[0], old_vp[1], old_vp[2], old_vp[3]);
// Put everything back
if (state.texture.bound[0])
gles_glBindTexture(GL_TEXTURE_2D, state.texture.bound[0]->glname);
else
gles_glBindTexture(GL_TEXTURE_2D, 0);
if (!state.enable.texture_2d[0])
gles_glDisable(GL_TEXTURE_2D);
if (state.texture.active != 0)
gles_glActiveTexture(GL_TEXTURE0 + state.texture.active);
if (state.texture.client != 0)
gles_glClientActiveTexture(GL_TEXTURE0 + state.texture.client);
}
void bindMainFBO() {
LOAD_GLES_OES(glBindFramebuffer);
LOAD_GLES_OES(glCheckFramebufferStatus);
if (!mainfbo_fbo)
return;
if (current_fb==0) {
gles_glBindFramebuffer(GL_FRAMEBUFFER, mainfbo_fbo);
gles_glCheckFramebufferStatus(GL_FRAMEBUFFER);
}
}
void unbindMainFBO() {
LOAD_GLES_OES(glBindFramebuffer);
if (!mainfbo_fbo)
return;
if (current_fb==0) {
GLuint pixel;
gles_glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
void deleteMainFBO() {
LOAD_GLES_OES(glDeleteFramebuffers);
LOAD_GLES_OES(glDeleteRenderbuffers);
LOAD_GLES(glDeleteTextures);
if (mainfbo_dep) {
gles_glDeleteRenderbuffers(1, &mainfbo_dep);
mainfbo_dep = 0;
}
if (mainfbo_ste) {
gles_glDeleteRenderbuffers(1, &mainfbo_ste);
mainfbo_ste = 0;
}
if (mainfbo_tex) {
gles_glDeleteTextures(1, &mainfbo_tex);
mainfbo_tex = 0;
}
if (mainfbo_fbo) {
gles_glDeleteFramebuffers(1, &mainfbo_fbo);
mainfbo_fbo = 0;
}
// all done...
}
// EXT direct wrapper
void glGenFramebuffersEXT(GLsizei n, GLuint *ids) {
glGenFramebuffers(n, ids);
}
void glDeleteFramebuffersEXT(GLsizei n, GLuint *framebuffers) {
glDeleteFramebuffers(n, framebuffers);
}
GLboolean glIsFramebufferEXT(GLuint framebuffer) {
return glIsFramebuffer(framebuffer);
}
GLenum glCheckFramebufferStatusEXT(GLenum target) {
return glCheckFramebufferStatus(target);
}
void glBindFramebufferEXT(GLenum target, GLuint framebuffer) {
glBindFramebuffer(target, framebuffer);
}
void glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
glFramebufferTexture1D(target, attachment, textarget, texture, level);
}
void glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
glFramebufferTexture2D(target, attachment, textarget, texture, level);
}
void glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer) {
glFramebufferTexture3D(target, attachment, textarget, texture, level, layer);
}
void glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) {
glGenRenderbuffers(n, renderbuffers);
}
void glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) {
glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
}
void glDeleteRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) {
glDeleteRenderbuffers(n, renderbuffers);
}
void glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
glRenderbufferStorage(target, internalformat, width, height);
}
void glBindRenderbufferEXT(GLenum target, GLuint renderbuffer) {
glBindRenderbuffer(target, renderbuffer);
}
GLboolean glIsRenderbufferEXT(GLuint renderbuffer) {
return glIsRenderbuffer(renderbuffer);
}
void glGenerateMipmapEXT(GLenum target) {
glGenerateMipmap(target);
}
void glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params) {
glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
}
void glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params) {
glGetRenderbufferParameteriv(target, pname, params);
}

View File

@@ -0,0 +1,64 @@
#include "gl.h"
#ifndef GL_FRAMEBUFFERS_H
#define GL_FRAMEBUFFERS_H
/*
void glGenFramebuffers(GLsizei n, GLuint *ids);
void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers);
GLboolean glIsFramebuffer(GLuint framebuffer);
GLenum glCheckFramebufferStatus(GLenum target);
void glBindFramebuffer(GLenum target, GLuint framebuffer);
void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers);
void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers);
void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void glBindRenderbuffer(GLenum target, GLuint renderbuffer);
GLboolean glIsRenderbuffer(GLuint renderbuffer);
void glGenerateMipmap(GLenum target);
void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params);
void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint * params);
*/
void glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); // naive Wrap
void glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); // naive Wrap
void glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); //STUB
// Direct creation of EXT versions...
void glGenFramebuffersEXT(GLsizei n, GLuint *ids);
void glDeleteFramebuffersEXT(GLsizei n, GLuint *framebuffers);
GLboolean glIsFramebufferEXT(GLuint framebuffer);
GLenum glCheckFramebufferStatusEXT(GLenum target);
void glBindFramebufferEXT(GLenum target, GLuint framebuffer);
void glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); // naive Wrap
void glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
void glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); // naive Wrap
void glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers);
void glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void glDeleteRenderbuffersEXT(GLsizei n, GLuint *renderbuffers);
void glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void glBindRenderbufferEXT(GLenum target, GLuint renderbuffer);
GLboolean glIsRenderbufferEXT(GLuint renderbuffer);
void glGenerateMipmapEXT(GLenum target);
void glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params);
void glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params);
// Need to keep track of Renderbuffer that are created as DEPTH_STENCIL, to create 2 seperate buffers...
typedef struct {
GLuint renderbuffer; // This is the Depth buffer...
GLuint stencil; // this will be the secondary Stencil buffer
} gldepthstencil_t;
KHASH_MAP_INIT_INT(dsr, gldepthstencil_t *)
// In case of LIBGL_FB=2, let's create an FBO for everything, that is than blitted just before the SwapBuffer
void createMainFBO(int width, int height);
void blitMainFBO();
void deleteMainFBO();
void bindMainFBO();
void unbindMainFBO();
void readfboBegin();
void readfboEnd();
#endif

1442
project/jni/glshim/src/gl/gl.c Executable file

File diff suppressed because it is too large Load Diff

415
project/jni/glshim/src/gl/gl.h Executable file
View File

@@ -0,0 +1,415 @@
#include <dlfcn.h>
#include <GLES/gl.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "khash.h"
#ifdef __ARM_NEON__
#include <arm_neon.h>
#endif
#ifndef GL_H
#define GL_H
#include "../config.h"
#include "wrap/es.h"
#include "const.h"
//Typedef for egl to be abble to call LOAD_EGL...
typedef EGLBoolean (*eglBindAPI_PTR)(EGLenum api);
typedef EGLBoolean (*eglBindTexImage_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
typedef EGLBoolean (*eglChooseConfig_PTR)(EGLDisplay dpy, const EGLint * attrib_list, EGLConfig * configs, EGLint config_size, EGLint * num_config);
typedef EGLBoolean (*eglCopyBuffers_PTR)(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
typedef EGLContext (*eglCreateContext_PTR)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint * attrib_list);
typedef EGLImageKHR (*eglCreateImageKHR_PTR)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint * attrib_list);
typedef EGLSurface (*eglCreatePbufferFromClientBuffer_PTR)(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint * attrib_list);
typedef EGLSurface (*eglCreatePbufferSurface_PTR)(EGLDisplay dpy, EGLConfig config, const EGLint * attrib_list);
typedef EGLSurface (*eglCreatePixmapSurface_PTR)(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint * attrib_list);
typedef EGLSurface (*eglCreatePixmapSurfaceHI_PTR)(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI * pixmap);
typedef EGLStreamKHR (*eglCreateStreamFromFileDescriptorKHR_PTR)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
typedef EGLStreamKHR (*eglCreateStreamKHR_PTR)(EGLDisplay dpy, const EGLint * attrib_list);
typedef EGLSurface (*eglCreateStreamProducerSurfaceKHR_PTR)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint * attrib_list);
typedef EGLSyncKHR (*eglCreateSyncKHR_PTR)(EGLDisplay dpy, EGLenum type, const EGLint * attrib_list);
typedef EGLSurface (*eglCreateWindowSurface_PTR)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint * attrib_list);
typedef EGLBoolean (*eglDestroyContext_PTR)(EGLDisplay dpy, EGLContext ctx);
typedef EGLBoolean (*eglDestroyImageKHR_PTR)(EGLDisplay dpy, EGLImageKHR image);
typedef EGLBoolean (*eglDestroyStreamKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (*eglDestroySurface_PTR)(EGLDisplay dpy, EGLSurface surface);
typedef EGLBoolean (*eglDestroySyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync);
typedef EGLBoolean (*eglGetConfigAttrib_PTR)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value);
typedef EGLBoolean (*eglGetConfigs_PTR)(EGLDisplay dpy, EGLConfig * configs, EGLint config_size, EGLint * num_config);
typedef EGLContext (*eglGetCurrentContext_PTR)();
typedef EGLDisplay (*eglGetCurrentDisplay_PTR)();
typedef EGLSurface (*eglGetCurrentSurface_PTR)(EGLint readdraw);
typedef EGLDisplay (*eglGetDisplay_PTR)(EGLNativeDisplayType display_id);
typedef EGLint (*eglGetError_PTR)();
typedef __eglMustCastToProperFunctionPointerType (*eglGetProcAddress_PTR)(const char * procname);
typedef EGLNativeFileDescriptorKHR (*eglGetStreamFileDescriptorKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (*eglGetSyncAttribKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint * value);
typedef EGLBoolean (*eglInitialize_PTR)(EGLDisplay dpy, EGLint * major, EGLint * minor);
typedef EGLBoolean (*eglLockSurfaceKHR_PTR)(EGLDisplay display, EGLSurface surface, const EGLint * attrib_list);
typedef EGLBoolean (*eglMakeCurrent_PTR)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
typedef EGLenum (*eglQueryAPI_PTR)();
typedef EGLBoolean (*eglQueryContext_PTR)(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint * value);
typedef EGLBoolean (*eglQueryStreamKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint * value);
typedef EGLBoolean (*eglQueryStreamTimeKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR * value);
typedef const char * (*eglQueryString_PTR)(EGLDisplay dpy, EGLint name);
typedef EGLBoolean (*eglQuerySurface_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint * value);
typedef EGLBoolean (*eglReleaseTexImage_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
typedef EGLBoolean (*eglReleaseThread_PTR)();
typedef EGLBoolean (*eglSignalSyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
typedef EGLBoolean (*eglStreamAttribKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);
typedef EGLBoolean (*eglStreamConsumerAcquireKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (*eglStreamConsumerGLTextureExternalKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (*eglStreamConsumerReleaseKHR_PTR)(EGLDisplay dpy, EGLStreamKHR stream);
typedef EGLBoolean (*eglSurfaceAttrib_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
typedef EGLBoolean (*eglSwapBuffers_PTR)(EGLDisplay dpy, EGLSurface surface);
typedef EGLBoolean (*eglSwapBuffersWithDamageEXT_PTR)(EGLDisplay dpy, EGLSurface surface, EGLint * rects, EGLint n_rects);
typedef EGLBoolean (*eglSwapInterval_PTR)(EGLDisplay dpy, EGLint interval);
typedef EGLBoolean (*eglTerminate_PTR)(EGLDisplay dpy);
typedef EGLBoolean (*eglUnlockSurfaceKHR_PTR)(EGLDisplay display, EGLSurface surface);
typedef EGLBoolean (*eglWaitClient_PTR)();
typedef EGLBoolean (*eglWaitGL_PTR)();
typedef EGLBoolean (*eglWaitNative_PTR)(EGLint engine);
typedef EGLint (*eglWaitSyncKHR_PTR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
// end of defintions
#define checkError(code) \
{int error; while ((error = glGetError())) {} \
code \
if ((error = glGetError())) \
printf(#code " -> %i\n", error);}
#define printError(file, line) \
{int error; if ((error = glGetError())) \
printf(file ":%i -> %i\n", line, error);}
#define GLdouble double
// will become a reference to dlopen'd gles
extern void *gles;
void *egl;
#ifndef EGL_LIB
#define EGL_LIB "libEGL.so"
#endif
#ifndef GLES_LIB
#ifdef USE_ES2
#define GLES_LIB "libGLESv2.so"
#else
#if defined(BCMHOST)
#define GLES_LIB "libGLESv1_CM.so"
#else
#define GLES_LIB "libGLES_CM.so"
//#define GLES_LIB "/media/SEBEXT/sources/PVRTrace/libGLES1.so"
#endif // BCMHOST
#endif // USE_ES2
#endif // GLES_LIB
static void load_gles_lib() {
if (gles) {
return;
}
char *override = getenv("LIBGL_GLES");
int flags = RTLD_LOCAL | RTLD_LAZY;
if (override) {
if ((gles = dlopen(override, flags))) {
printf("libGL backend: %s\n", override);
return;
}
}
gles = dlopen(GLES_LIB, RTLD_LOCAL | RTLD_LAZY);
// fixme lubomyr
printf("libGL backend: %s\n", GLES_LIB);
}
static void load_egl_lib() {
if (egl) {
return;
}
char *override = getenv("LIBGL_EGL");
int flags = RTLD_LOCAL | RTLD_LAZY;
if (override) {
if ((egl = dlopen(override, flags))) {
printf("libGL egl backend: %s\n", override);
return;
}
}
egl = dlopen(EGL_LIB, RTLD_LOCAL | RTLD_LAZY);
// fixme lubomyr
printf("libGL egl backend: %s\n", EGL_LIB);
}
#define WARN_NULL(name) if (name == NULL) printf("libGL: warning, " #name " is NULL\n");
#define LOAD_GLES(name) \
static name##_PTR gles_##name; \
if (gles_##name == NULL) { \
if (gles == NULL) { \
load_gles_lib(); \
WARN_NULL(gles); \
} \
gles_##name = (name##_PTR)dlsym(gles, #name); \
WARN_NULL(gles_##name); \
}
#define LOAD_GLES_OES(name) \
static name##_PTR gles_##name; \
if (gles_##name == NULL) { \
if (gles == NULL) { \
load_gles_lib(); \
WARN_NULL(gles); \
} \
LOAD_EGL(eglGetProcAddress) \
gles_##name = (name##_PTR)egl_eglGetProcAddress(#name"OES"); \
WARN_NULL(gles_##name); \
}
#define LOAD_EGL(name) \
static name##_PTR egl_##name; \
if (egl_##name == NULL) { \
if (egl == NULL) { \
load_egl_lib(); \
WARN_NULL(egl); \
} \
egl_##name = (name##_PTR)dlsym(egl, #name); \
WARN_NULL(egl_##name); \
}
#define GL_TYPE_CASE(name, var, magic, type, code) \
case magic: { \
type *name = (type *)var; \
code \
break; \
}
#define GL_TYPE_CASE_MAX(name, var, magic, type, code, max) \
case magic: { \
type *name = (type *)var; \
type maxv = max; \
code \
break; \
}
#define GL_TYPE_SWITCH(name, var, type, code, extra) \
switch (type) { \
GL_TYPE_CASE(name, var, GL_DOUBLE, GLdouble, code) \
GL_TYPE_CASE(name, var, GL_FLOAT, GLfloat, code) \
GL_TYPE_CASE(name, var, GL_INT, GLint, code) \
GL_TYPE_CASE(name, var, GL_SHORT, GLshort, code) \
GL_TYPE_CASE(name, var, GL_BYTE, GLbyte, code) \
GL_TYPE_CASE(name, var, GL_UNSIGNED_BYTE, GLubyte, code) \
GL_TYPE_CASE(name, var, GL_UNSIGNED_INT, GLuint, code) \
GL_TYPE_CASE(name, var, GL_UNSIGNED_SHORT, GLushort, code) \
extra \
}
#define GL_TYPE_SWITCH_MAX(name, var, type, code, extra) \
switch (type) { \
GL_TYPE_CASE_MAX(name, var, GL_DOUBLE, GLdouble, code, 1.0d) \
GL_TYPE_CASE_MAX(name, var, GL_FLOAT, GLfloat, code, 1.0f) \
GL_TYPE_CASE_MAX(name, var, GL_INT, GLint, code, 2147483647l) \
GL_TYPE_CASE_MAX(name, var, GL_SHORT, GLshort, code, 32767) \
GL_TYPE_CASE_MAX(name, var, GL_BYTE, GLbyte, code, 255) \
GL_TYPE_CASE_MAX(name, var, GL_UNSIGNED_BYTE, GLubyte, code, 127) \
GL_TYPE_CASE_MAX(name, var, GL_UNSIGNED_INT, GLuint, code, 4294967295l) \
GL_TYPE_CASE_MAX(name, var, GL_UNSIGNED_SHORT, GLushort, code, 65535) \
extra \
}
#define PUSH_IF_COMPILING_EXT(nam, ...) \
if (state.list.compiling && state.list.active) { \
NewStage(state.list.active, STAGE_GLCALL); \
push_##nam(__VA_ARGS__); \
noerrorShim(); \
return (nam##_RETURN)0; \
}
//printf("list:%i, " #nam "\n", state.list.name); \
#define PUSH_IF_COMPILING(name) PUSH_IF_COMPILING_EXT(name, name##_ARG_NAMES)
static const GLsizei gl_sizeof(GLenum type) {
// types
switch (type) {
case GL_DOUBLE:
return 8;
case GL_FLOAT:
case GL_INT:
case GL_UNSIGNED_INT:
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT_8_8_8_8:
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_4_BYTES:
return 4;
case GL_3_BYTES:
return 3;
case GL_LUMINANCE_ALPHA:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
case GL_2_BYTES:
return 2;
case GL_ALPHA:
case GL_LUMINANCE:
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_BYTE_3_3_2:
return 1;
}
// formats
printf("libGL: Unsupported pixel data type: 0x%x\n", type);
return 0;
}
static const GLuint gl_max_value(GLenum type) {
switch (type) {
// float/double only make sense on tex/color
// be careful about using this
case GL_DOUBLE:
case GL_FLOAT:
return 1;
case GL_BYTE: return 127;
case GL_UNSIGNED_BYTE: return 255;
case GL_SHORT: return 32767;
case GL_UNSIGNED_SHORT: return 65535;
case GL_INT: return 2147483647;
case GL_UNSIGNED_INT: return 4294967295;
}
printf("libGL: unknown gl max value type: 0x%x\n", type);
return 0;
}
static const GLboolean is_type_packed(GLenum type) {
switch (type) {
case GL_4_BYTES:
case GL_3_BYTES:
case GL_2_BYTES:
case GL_UNSIGNED_BYTE_2_3_3_REV:
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_INT_10_10_10_2:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT_8_8_8_8:
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_UNSIGNED_SHORT_1_5_5_5_REV:
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_4_4_4_4_REV:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_UNSIGNED_SHORT_5_6_5_REV:
return true;
}
return false;
}
static const GLsizei pixel_sizeof(GLenum format, GLenum type) {
GLsizei width = 0;
switch (format) {
case GL_RED:
case GL_ALPHA:
case GL_LUMINANCE:
width = 1;
break;
case GL_RG:
case GL_LUMINANCE_ALPHA:
width = 2;
break;
case GL_RGB:
case GL_BGR:
width = 3;
break;
case GL_RGBA:
case GL_BGRA:
width = 4;
break;
default:
printf("libGL: unsupported pixel format %x\n", format);
return 0;
}
if (is_type_packed(type))
width = 1;
return width * gl_sizeof(type);
}
static const GLboolean pixel_hasalpha(GLenum format) {
switch (format) {
case GL_ALPHA:
case GL_RGBA:
case GL_BGRA:
return true;
case GL_RED:
case GL_LUMINANCE:
case GL_RG:
case GL_RGB:
case GL_BGR:
return false;
default:
return true;
}
}
static inline const GLboolean valid_vertex_type(GLenum type) {
switch (type) {
case GL_BYTE:
case GL_FIXED:
case GL_FLOAT:
case GL_SHORT:
return true;
default:
return false;
}
}
#include "wrap/stub.h"
#include "wrap/gl.h"
#include "eval.h"
#include "light.h"
#include "line.h"
#include "list.h"
#include "pixel.h"
#include "raster.h"
#include "stack.h"
#include "texgen.h"
#include "texture.h"
#include "array.h"
#include "framebuffers.h"
extern void glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
#include "state.h"
extern glstate_t state;
static inline void errorGL() { // next glGetError will be from GL
state.shim_error = 0;
}
static inline void errorShim(GLenum error) { // next glGetError will be "error" from glShim
state.shim_error = 1;
state.last_error = error;
}
static inline void noerrorShim() {
errorShim(GL_NO_ERROR);
}
#include "defines.h"
#include "render.h"
#endif

View File

@@ -0,0 +1,71 @@
#include "light.h"
#ifndef USE_ES2
void glLightModelf(GLenum pname, GLfloat param) {
//printf("%sglLightModelf(%04X, %.2f)\n", (state.list.compiling)?"list":"", pname, param);
if (state.list.compiling && state.list.active) {
GLfloat dummy[4];
dummy[0]=param;
glLightModelfv(pname, dummy);
return;
}
LOAD_GLES(glLightModelf);
switch (pname) {
case GL_LIGHT_MODEL_AMBIENT:
case GL_LIGHT_MODEL_TWO_SIDE:
errorGL();
gles_glLightModelf(pname, param);
break;
default:
errorShim(GL_INVALID_ENUM);
//printf("stubbed glLightModelf(%i, %.2f)\n", pname, param);
break;
}
}
void glLightModelfv(GLenum pname, const GLfloat* params) {
//printf("%sglLightModelfv(%04X, [%.2f, %.2f, %.2f, %.2f])\n", (state.list.compiling)?"list":"", pname, params[0], params[1], params[2], params[3]);
if (state.list.compiling && state.list.active) {
NewStage(state.list.active, STAGE_LIGHTMODEL);
/* if (state.list.active->lightmodel)
state.list.active = extend_renderlist(state.list.active);*/
state.list.active->lightmodelparam = pname;
state.list.active->lightmodel = (GLfloat*)malloc(4*sizeof(GLfloat));
memcpy(state.list.active->lightmodel, params, 4*sizeof(GLfloat));
noerrorShim();
return;
}
LOAD_GLES(glLightModelfv);
switch (pname) {
case GL_LIGHT_MODEL_AMBIENT:
case GL_LIGHT_MODEL_TWO_SIDE:
errorGL();
gles_glLightModelfv(pname, params);
break;
default:
errorShim(GL_INVALID_ENUM);
//printf("stubbed glLightModelfv(%i, %p [%.2f])\n", pname, params, params[0]);
break;
}
}
void glLightfv(GLenum light, GLenum pname, const GLfloat* params) {
//printf("%sglLightfv(%04X, %04X, [%.2f, %.2f, %.2f, %.2f])\n", (state.list.compiling)?"list":"", light, pname, params[0], params[1], params[2], params[3]);
if (state.list.compiling && state.list.active) {
NewStage(state.list.active, STAGE_LIGHT);
rlLightfv(state.list.active, light, pname, params);
noerrorShim();
return;
}
LOAD_GLES(glLightfv);
gles_glLightfv(light, pname, params);
errorGL();
}
void glLightf(GLenum light, GLenum pname, const GLfloat params) {
GLfloat dummy[4];
dummy[0]=params;
glLightfv(light, pname, dummy);
errorGL();
}
#endif

View File

@@ -0,0 +1,6 @@
#include "gl.h"
void glLightModelf(GLenum pname, GLfloat param);
void glLightModelfv(GLenum pname, const GLfloat* params);
void glLightfv(GLenum light, GLenum pname, const GLfloat* params);
void glLightf(GLenum light, GLenum pname, const GLfloat params);

View File

@@ -0,0 +1,62 @@
#include "line.h"
GLint stippleFactor = 1;
GLushort stipplePattern = 0xFFFF;
GLubyte *stippleData = NULL;
GLuint stippleTexture = 0;
void glLineStipple(GLuint factor, GLushort pattern) {
stippleFactor = factor;
stipplePattern = pattern;
if (stippleData != NULL) {
free(stippleData);
}
stippleData = (GLubyte *)malloc(sizeof(GLubyte) * 16);
for (int i = 0; i < 16; i++) {
stippleData[i] = (stipplePattern >> i) & 1 ? 255 : 0;
}
glPushAttrib(GL_TEXTURE_BIT);
if (! stippleTexture)
glGenTextures(1, &stippleTexture);
glBindTexture(GL_TEXTURE_2D, stippleTexture);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
16, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, stippleData);
glPopAttrib();
noerrorShim();
}
void bind_stipple_tex() {
glBindTexture(GL_TEXTURE_2D, stippleTexture);
}
GLfloat *gen_stipple_tex_coords(GLfloat *vert, int length) {
// generate our texture coords
GLfloat *tex = (GLfloat *)malloc(length * 2 * sizeof(GLfloat));
GLfloat *texPos = tex;
GLfloat *vertPos = vert;
GLfloat x1, x2, y1, y2;
GLfloat len;
for (int i = 0; i < length / 2; i++) {
x1 = *vertPos++;
y1 = *vertPos++;
vertPos++; // z
x2 = *vertPos++;
y2 = *vertPos++;
vertPos++;
len = sqrt(pow(x2-x1, 2) + pow(y2-y1, 2)) / stippleFactor * 16;
*texPos++ = 0;
*texPos++ = 0;
*texPos++ = len;
*texPos++ = 0;
}
return tex;
}

View File

@@ -0,0 +1,5 @@
#include "gl.h"
extern void glLineStipple(GLuint factor, GLushort pattern);
extern GLfloat *gen_stipple_tex_coords(GLfloat *vert, int length);
extern void bind_stipple_tex();

754
project/jni/glshim/src/gl/list.c Executable file
View File

@@ -0,0 +1,754 @@
#include "gl.h"
#include "list.h"
#define alloc_sublist(n, cap) \
(GLfloat *)malloc(n * sizeof(GLfloat) * cap)
#define realloc_sublist(ref, n, cap) \
if (ref) \
ref = (GLfloat *)realloc(ref, n * sizeof(GLfloat) * cap)
static GLushort *cached_q2t = NULL;
static unsigned long cached_q2t_len = 0;
renderlist_t *alloc_renderlist() {
renderlist_t *list = (renderlist_t *)malloc(sizeof(renderlist_t));
list->len = 0;
list->ilen = 0;
list->cap = DEFAULT_RENDER_LIST_CAPACITY;
list->calls.len = 0;
list->calls.cap = 0;
list->calls.calls = NULL;
list->mode = 0;
list->mode_init = 0;
list->vert = NULL;
list->normal = NULL;
list->color = NULL;
list->secondary = NULL;
list->glcall_list = 0;
list->raster = NULL;
list->stage = STAGE_NONE;
list->pushattribute = 0;
list->popattribute = false;
int a;
for (a=0; a<MAX_TEX; a++)
list->tex[a] = NULL;
list->material = NULL;
list->light = NULL;
list->texgen = NULL;
list->lightmodel = NULL;
list->lightmodelparam = GL_LIGHT_MODEL_AMBIENT;
list->indices = NULL;
list->q2t = false;
list->set_texture = false;
list->texture = 0;
list->polygon_mode = 0;
list->prev = NULL;
list->next = NULL;
list->open = true;
return list;
}
renderlist_t *extend_renderlist(renderlist_t *list) {
renderlist_t *new = alloc_renderlist();
list->next = new;
new->prev = list;
if (list->open)
end_renderlist(list);
return new;
}
void free_renderlist(renderlist_t *list) {
// test if list is NULL
if (list == NULL)
return;
// we want the first list in the chain
while (list->prev)
list = list->prev;
renderlist_t *next;
do {
if (list->calls.len > 0) {
for (int i = 0; i < list->calls.len; i++) {
free(list->calls.calls[i]);
}
free(list->calls.calls);
}
if (list->vert) free(list->vert);
if (list->normal) free(list->normal);
if (list->color) free(list->color);
if (list->secondary) free(list->secondary);
int a;
for (a=0; a<MAX_TEX; a++)
if (list->tex[a]) free(list->tex[a]);
if (list->material) {
rendermaterial_t *m;
kh_foreach_value(list->material, m,
free(m);
)
kh_destroy(material, list->material);
}
if (list->light) {
renderlight_t *m;
kh_foreach_value(list->light, m,
free(m);
)
kh_destroy(light, list->light);
}
if (list->texgen) {
rendertexgen_t *m;
kh_foreach_value(list->texgen, m,
free(m);
)
kh_destroy(texgen, list->texgen);
}
if (list->lightmodel)
free(list->lightmodel);
if ((list->indices) && (!list->q2t))
free(list->indices);
if (list->raster) {
if (list->raster->texture)
glDeleteTextures(1, &list->raster->texture);
free(list->raster);
}
next = list->next;
free(list);
} while ((list = next));
}
static inline
void resize_renderlist(renderlist_t *list) {
if (list->len >= list->cap) {
list->cap += DEFAULT_RENDER_LIST_CAPACITY;
realloc_sublist(list->vert, 3, list->cap);
realloc_sublist(list->normal, 3, list->cap);
realloc_sublist(list->color, 4, list->cap);
realloc_sublist(list->secondary, 4, list->cap);
for (int a=0; a<MAX_TEX; a++)
realloc_sublist(list->tex[a], 2, list->cap);
}
}
void q2t_renderlist(renderlist_t *list) {
if (!list->len || !list->vert || list->q2t) return;
// TODO: split to multiple lists if list->len > 65535
int a = 0, b = 1, c = 2, d = 3;
int winding[6] = {
a, b, d,
b, c, d,
};
unsigned long len = list->len * 6 / 4;
// q2t on glDrawElements?
GLushort *old_indices = NULL;
GLushort *indices;
if (list->indices)
old_indices = list->indices;
// free(list->indices);
if ((len > cached_q2t_len) || (old_indices)) {
if (old_indices) {
indices = malloc(len * sizeof(GLushort));
} else {
if (cached_q2t)
free(cached_q2t);
cached_q2t = malloc(len * sizeof(GLushort));
cached_q2t_len = len;
}
int k = 0;
for (int i = 0; i < list->len; i += 4) {
for (int j = 0; j < 6; j++) {
if (old_indices)
indices[k+j] = old_indices[i + winding[j]];
else
cached_q2t[k+j] = i + winding[j];
}
k += 6;
}
}
if (!old_indices) {
// list->indices = cached_q2t;
list->q2t = true;
} else {
free(old_indices);
list->indices = indices;
}
list->ilen = len;
return;
}
void end_renderlist(renderlist_t *list) {
if (! list->open)
return;
list->stage = STAGE_LAST;
list->open = false;
for (int a=0; a<MAX_TEX; a++) {
gltexture_t *bound = state.texture.bound[a];
if ((list->tex[a]) && (bound) && ((bound->width != bound->nwidth) || (bound->height != bound->nheight))) {
tex_coord_npot(list->tex[a], list->len, bound->width, bound->height, bound->nwidth, bound->nheight);
}
// GL_ARB_texture_rectangle
if ((list->tex[a]) && state.texture.rect_arb[a] && (bound)) {
tex_coord_rect_arb(list->tex[a], list->len, bound->width, bound->height);
}
}
switch (list->mode) {
case GL_QUADS:
if (list->len==4) {
list->mode = GL_TRIANGLE_FAN;
} else {
list->mode = GL_TRIANGLES;
q2t_renderlist(list);
}
break;
case GL_POLYGON:
list->mode = GL_TRIANGLE_FAN;
break;
case GL_QUAD_STRIP:
list->mode = GL_TRIANGLE_STRIP;
break;
}
}
void draw_renderlist(renderlist_t *list) {
if (!list) return;
LOAD_GLES(glDrawArrays);
LOAD_GLES(glDrawElements);
#ifdef USE_ES2
LOAD_GLES(glVertexAttribPointer);
#else
LOAD_GLES(glVertexPointer);
LOAD_GLES(glNormalPointer);
LOAD_GLES(glColorPointer);
LOAD_GLES(glTexCoordPointer);
#endif
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
GLfloat *final_colors;
int old_tex;
GLushort *indices;
do {
// push/pop attributes
if (list->pushattribute)
glPushAttrib(list->pushattribute);
if (list->popattribute)
glPopAttrib();
// do call_list
if (list->glcall_list)
glCallList(list->glcall_list);
// optimize zero-length segments out earlier?
call_list_t *cl = &list->calls;
if (cl->len > 0) {
for (int i = 0; i < cl->len; i++) {
glPackedCall(cl->calls[i]);
}
}
old_tex = state.texture.active;
if (list->set_texture) {
glBindTexture(list->target_texture, list->texture);
}
// raster
if (list->raster) {
rasterlist_t * r = list->raster;
//glBitmap(r->width, r->height, r->xorig, r->yorig, r->xmove, r->ymove, r->raster);
render_raster_list(list->raster);
}
if (list->material) {
khash_t(material) *map = list->material;
rendermaterial_t *m;
kh_foreach_value(map, m,
switch (m->pname) {
case GL_SHININESS:
glMaterialf(GL_FRONT_AND_BACK, m->pname, m->color[0]);
break;
default:
glMaterialfv(GL_FRONT_AND_BACK, m->pname, m->color);
}
)
}
if (list->light) {
khash_t(light) *lig = list->light;
renderlight_t *m;
kh_foreach_value(lig, m,
switch (m->pname) {
default:
glLightfv(m->which, m->pname, m->color);
}
)
}
if (list->lightmodel) {
glLightModelfv(list->lightmodelparam, list->lightmodel);
}
if (list->texgen) {
khash_t(texgen) *tgn = list->texgen;
rendertexgen_t *m;
kh_foreach_value(tgn, m,
switch (m->pname) {
case GL_TEXTURE_GEN_MODE:
glTexGeni(m->coord, m->pname, m->color[0]);
break;
default:
glTexGenfv(m->coord, m->pname, m->color);
}
)
}
if (list->polygon_mode)
glPolygonMode(GL_FRONT_AND_BACK, list->polygon_mode);
if (! list->len)
continue;
#ifdef USE_ES2
if (list->vert) {
glEnableVertexAttribArray(0);
gles_glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, list->vert);
}
gles_glDrawArrays(list->mode, 0, list->len);
#else
if (list->vert) {
glEnableClientState(GL_VERTEX_ARRAY);
gles_glVertexPointer(3, GL_FLOAT, 0, list->vert);
} else {
glDisableClientState(GL_VERTEX_ARRAY);
}
if (list->normal) {
glEnableClientState(GL_NORMAL_ARRAY);
gles_glNormalPointer(GL_FLOAT, 0, list->normal);
} else {
glDisableClientState(GL_NORMAL_ARRAY);
}
indices = list->indices;
if (list->q2t && !(state.polygon_mode == GL_LINE))
indices = cached_q2t;
final_colors = NULL;
if (list->color) {
glEnableClientState(GL_COLOR_ARRAY);
if (state.enable.color_sum && (list->secondary)) {
final_colors=(GLfloat*)malloc(list->len * 4 * sizeof(GLfloat));
if (indices) {
for (int i=0; i<list->ilen; i++)
for (int j=0; j<4; j++) {
const int k=indices[i]*4+j;
final_colors[k]=list->color[k] + list->secondary[k];
}
} else {
for (int i=0; i<list->len*4; i++)
final_colors[i]=list->color[i] + list->secondary[i];
}
gles_glColorPointer(4, GL_FLOAT, 0, final_colors);
} else
gles_glColorPointer(4, GL_FLOAT, 0, list->color);
} else {
glDisableClientState(GL_COLOR_ARRAY);
}
GLuint texture;
bool stipple;
stipple = false;
if (! list->tex[0]) {
// TODO: do we need to support GL_LINE_STRIP?
if (list->mode == GL_LINES && state.enable.line_stipple) {
stipple = true;
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
list->tex[0] = gen_stipple_tex_coords(list->vert, list->len);
}
}
GLfloat *texgened[MAX_TEX];
GLint needclean[MAX_TEX];
for (int a=0; a<MAX_TEX; a++) {
texgened[a]=NULL;
needclean[a]=0;
if ((state.enable.texgen_s[a] || state.enable.texgen_t[a] || state.enable.texgen_r[a])) {
gen_tex_coords(list->vert, list->normal, &texgened[a], list->len, &needclean[a], a, (list->ilen<list->len)?indices:NULL, (list->ilen<list->len)?list->ilen:0);
} else if (state.enable.texture_2d[a] && (list->tex[a]==NULL)) {
gen_tex_coords(list->vert, list->normal, &texgened[a], list->len, &needclean[a], a, (list->ilen<list->len)?indices:NULL, (list->ilen<list->len)?list->ilen:0);
}
}
old_tex = state.texture.client;
for (int a=0; a<MAX_TEX; a++) {
if ((list->tex[a] || texgened[a])/* && state.enable.texture_2d[a]*/) {
glClientActiveTexture(GL_TEXTURE0+a);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
gles_glTexCoordPointer(2, GL_FLOAT, 0, (texgened[a])?texgened[a]:list->tex[a]);
} else {
if (state.enable.tex_coord_array[a]) {
glClientActiveTexture(GL_TEXTURE0+a);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
//else if (!state.enable.texgen_s[a] && state.enable.texture_2d[a]) printf("LIBGL: texture_2d[%i] without TexCoord, mode=0x%04X (init=0x%04X), listlen=%i\n", a, list->mode, list->mode_init, list->len);
}
}
if (state.texture.client != old_tex) glClientActiveTexture(GL_TEXTURE0+old_tex);
GLenum mode;
mode = list->mode;
if ((state.polygon_mode == GL_LINE) && (mode>=GL_TRIANGLES))
mode = GL_LINE_LOOP;
if ((state.polygon_mode == GL_POINT) && (mode>=GL_TRIANGLES))
mode = GL_POINTS;
if (indices) {
if (state.render_mode == GL_SELECT) {
select_glDrawElements(list->mode, list->len, GL_UNSIGNED_SHORT, indices);
} else {
if (state.polygon_mode == GL_LINE && list->mode_init>=GL_TRIANGLES) {
int n, s;
GLushort ind_line[list->ilen*3+1];
switch (list->mode_init) {
case GL_TRIANGLES:
n = 3;
s = 3;
break;
case GL_TRIANGLE_STRIP:
n = 3;
s = 1;
break;
case GL_TRIANGLE_FAN: // wrong here...
n = list->ilen;
s = list->ilen;
break;
case GL_QUADS:
n = 4;
s = 4;
break;
case GL_QUAD_STRIP:
n = 4;
s = 1;
break;
default: // Polygon and other?
n = list->ilen;
s = list->ilen;
break;
}
int k = 0;
for (int i=n; i<=list->ilen; i+=s) {
memcpy(ind_line+k, indices+i-n, sizeof(GLushort)*n);
k+=n;
}
//gles_glDrawElements(mode, n, GL_UNSIGNED_SHORT, indices+i-n);
gles_glDrawElements(mode, k, GL_UNSIGNED_SHORT, ind_line);
} else {
gles_glDrawElements(mode, list->ilen, GL_UNSIGNED_SHORT, indices);
}
}
} else {
if (state.render_mode == GL_SELECT) {
select_glDrawArrays(list->mode, 0, list->len);
} else {
int len = list->len;
if ((state.polygon_mode == GL_LINE) && (list->mode_init>=GL_TRIANGLES)) {
int n, s;
if (list->q2t)
len = len*4/6;
GLushort ind_line[len*3+1];
switch (list->mode_init) {
case GL_TRIANGLES:
n = 3;
s = 3;
break;
case GL_TRIANGLE_STRIP:
n = 3;
s = 1;
break;
case GL_TRIANGLE_FAN: // wrong here...
n = len;
s = len;
break;
case GL_QUADS:
n = 4;
s = 4;
break;
case GL_QUAD_STRIP:
n = 4;
s = 1;
break;
default: // Polygon and other?
n = len;
s = len;
break;
}
int k=0;
for (int i=n; i<=len; i+=s)
for (int j=0; j<n; j++)
ind_line[k++]=i-n+j;
//gles_glDrawArrays(mode, i-n, n);
gles_glDrawElements(mode, k, GL_UNSIGNED_SHORT, ind_line);
} else {
gles_glDrawArrays(mode, 0, len);
}
}
}
for (int a=0; a<MAX_TEX; a++) {
if (needclean[a])
gen_tex_clean(needclean[a], a);
if (texgened[a]) {
free(texgened[a]);
texgened[a] = NULL;
}
}
if (final_colors)
free(final_colors);
if (stipple) {
glPopAttrib();
}
#endif
} while ((list = list->next));
glPopClientAttrib();
}
// gl function wrappers
void rlVertex3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z) {
if (list->vert == NULL) {
list->vert = alloc_sublist(3, list->cap);
} else {
resize_renderlist(list);
}
if (list->normal) {
GLfloat *normal = list->normal + (list->len * 3);
memcpy(normal, list->lastNormal, sizeof(GLfloat) * 3);
}
if (list->color) {
GLfloat *color = list->color + (list->len * 4);
memcpy(color, state.color, sizeof(GLfloat) * 4);
}
if (list->secondary) {
GLfloat *secondary = list->secondary + (list->len * 4);
memcpy(secondary, state.secondary, sizeof(GLfloat) * 4);
}
for (int a=0; a<MAX_TEX; a++) {
if (list->tex[a]) {
GLfloat *tex = list->tex[a] + (list->len * 2);
memcpy(tex, state.texcoord[a], sizeof(GLfloat) * 2);
}
}
GLfloat *vert = list->vert + (list->len++ * 3);
vert[0] = x; vert[1] = y; vert[2] = z;
}
void rlNormal3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z) {
if (list->normal == NULL) {
list->normal = alloc_sublist(3, list->cap);
// catch up
int i;
if (list->len) for (i = 0; i < list->len-1; i++) {
GLfloat *normal = (list->normal + (i * 3));
memcpy(normal, list->lastNormal, sizeof(GLfloat) * 3);
}
} else {
resize_renderlist(list);
}
GLfloat *normal = list->lastNormal;
normal[0] = x; normal[1] = y; normal[2] = z;
}
void rlColor4f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
if (list->color == NULL) {
list->color = alloc_sublist(4, list->cap);
// catch up
int i;
if (list->len) for (i = 0; i < list->len-1; i++) {
GLfloat *color = (list->color + (i * 4));
memcpy(color, state.color, sizeof(GLfloat) * 4);
} else {
GLfloat *color = list->color;
color[0] = r; color[1] = g; color[2] = b; color[3] = a;
}
} else {
resize_renderlist(list);
}
GLfloat *color = state.color;
color[0] = r; color[1] = g; color[2] = b; color[3] = a;
}
void rlSecondary3f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b) {
if (list->secondary == NULL) {
list->secondary = alloc_sublist(4, list->cap);
// catch up
int i;
if (list->len) for (i = 0; i < list->len-1; i++) {
GLfloat *secondary = (list->secondary + (i * 4));
memcpy(secondary, state.secondary, sizeof(GLfloat) * 4);
}
} else {
resize_renderlist(list);
}
GLfloat *color = state.secondary;
color[0] = r; color[1] = g; color[2] = b; color[3] = 0.0f;
}
void rlMaterialfv(renderlist_t *list, GLenum face, GLenum pname, const GLfloat * params) {
rendermaterial_t *m;
khash_t(material) *map;
khint_t k;
int ret;
if (! list->material) {
list->material = map = kh_init(material);
// segfaults if we don't do a single put
kh_put(material, map, 1, &ret);
kh_del(material, map, 1);
} else {
map = list->material;
}
// TODO: currently puts all faces in the same map
k = kh_get(material, map, pname);
if (k == kh_end(map)) {
k = kh_put(material, map, pname, &ret);
m = kh_value(map, k) = malloc(sizeof(rendermaterial_t));
} else {
m = kh_value(map, k);
}
m->face = face;
m->pname = pname;
m->color[0] = params[0];
m->color[1] = params[1];
m->color[2] = params[2];
m->color[3] = params[3];
}
void rlLightfv(renderlist_t *list, GLenum which, GLenum pname, const GLfloat * params) {
renderlight_t *m;
khash_t(light) *map;
khint_t k;
int ret;
if (! list->light) {
list->light = map = kh_init(light);
// segfaults if we don't do a single put
kh_put(light, map, 1, &ret);
kh_del(light, map, 1);
} else {
map = list->light;
}
int key = pname | ((which-GL_LIGHT0)<<16);
k = kh_get(light, map, key);
if (k == kh_end(map)) {
k = kh_put(light, map, key, &ret);
m = kh_value(map, k) = malloc(sizeof(renderlight_t));
} else {
m = kh_value(map, k);
}
m->which = which;
m->pname = pname;
m->color[0] = params[0];
m->color[1] = params[1];
m->color[2] = params[2];
m->color[3] = params[3];
}
void rlTexGenfv(renderlist_t *list, GLenum coord, GLenum pname, const GLfloat * params) {
rendertexgen_t *m;
khash_t(texgen) *map;
khint_t k;
int ret;
if (! list->texgen) {
list->texgen = map = kh_init(texgen);
// segfaults if we don't do a single put
kh_put(texgen, map, 1, &ret);
kh_del(texgen, map, 1);
} else {
map = list->texgen;
}
int key = pname | ((coord-GL_S)<<16);
k = kh_get(texgen, map, key);
if (k == kh_end(map)) {
k = kh_put(texgen, map, key, &ret);
m = kh_value(map, k) = malloc(sizeof(rendertexgen_t));
} else {
m = kh_value(map, k);
}
m->coord = coord;
m->pname = pname;
m->color[0] = params[0];
m->color[1] = params[1];
m->color[2] = params[2];
m->color[3] = params[3];
}
void rlTexCoord2f(renderlist_t *list, GLfloat s, GLfloat t) {
if (list->tex[0] == NULL) {
list->tex[0] = alloc_sublist(2, list->cap);
// catch up
GLfloat *tex = list->tex[0];
if (list->len) for (int i = 0; i < list->len-1; i++) {
memcpy(tex, state.texcoord[0], sizeof(GLfloat) * 2);
tex += 2;
}
} else {
resize_renderlist(list);
}
GLfloat *tex = state.texcoord[0];
tex[0] = s; tex[1] = t;
}
void rlMultiTexCoord2f(renderlist_t *list, GLenum target, GLfloat s, GLfloat t) {
if (list->tex[target-GL_TEXTURE0] == NULL) {
list->tex[target-GL_TEXTURE0] = alloc_sublist(2, list->cap);
// catch up
GLfloat *tex = list->tex[target-GL_TEXTURE0];
if (list->len) for (int i = 0; i < list->len-1; i++) {
memcpy(tex, state.texcoord[target-GL_TEXTURE0], sizeof(GLfloat) * 2);
tex += 2;
}
} else {
resize_renderlist(list);
}
GLfloat *tex = state.texcoord[target-GL_TEXTURE0];
tex[0] = s; tex[1] = t;
}
void rlBindTexture(renderlist_t *list, GLenum target, GLuint texture) {
list->texture = texture;
list->target_texture = target;
list->set_texture = true;
}
void rlPushCall(renderlist_t *list, packed_call_t *data) {
call_list_t *cl = &list->calls;
if (!cl->calls) {
cl->cap = DEFAULT_CALL_LIST_CAPACITY;
cl->calls = malloc(DEFAULT_CALL_LIST_CAPACITY * sizeof(uintptr_t));
} else if (list->calls.len == list->calls.cap) {
cl->cap += DEFAULT_CALL_LIST_CAPACITY;
cl->calls = realloc(cl->calls, cl->cap * sizeof(uintptr_t));
}
cl->calls[cl->len++] = data;
}
#undef alloc_sublist
#undef realloc_sublist

145
project/jni/glshim/src/gl/list.h Executable file
View File

@@ -0,0 +1,145 @@
#include "gl.h"
#ifndef DISPLAY_LIST_H
#define DISPLAY_LIST_H
typedef enum {
STAGE_NONE = 0,
STAGE_PUSH,
STAGE_POP,
STAGE_CALLLIST,
STAGE_GLCALL,
STAGE_BINDTEX,
STAGE_RASTER,
STAGE_MATERIAL,
STAGE_LIGHT,
STAGE_LIGHTMODEL,
STAGE_TEXGEN,
STAGE_POLYGON,
STAGE_DRAW,
STAGE_LAST
} liststage_t;
static int StageExclusive[STAGE_LAST] = {
0, // STAGE_NONE
1, // STAGE_PUSH
1, // STAGE_POP
1, // STAGE_CALLLIST
0, // STAGE_GLCALL
1, // STAGE_BINDTEX
1, // STAGE_RASTER
0, // STAGE_MATERIAL
0, // STAGE_LIGHT
1, // STAGE_LIGTMODEL
0, // STAGE_TEXGEN
1, // STAGE_POLYGON
1 // STAGE_DRAW
};
typedef struct {
int face;
int pname;
GLfloat color[4];
int count;
} rendermaterial_t;
typedef struct {
int which;
int pname;
GLfloat color[4];
int count;
} renderlight_t;
typedef struct {
int coord;
int pname;
GLfloat color[4];
int count;
} rendertexgen_t;
typedef struct {
GLfloat xmove;
GLfloat ymove;
GLsizei width;
GLsizei height;
GLfloat xorig;
GLfloat yorig;
GLfloat zoomx;
GLfloat zoomy;
GLboolean bitmap;
GLuint texture;
} rasterlist_t;
KHASH_MAP_INIT_INT(material, rendermaterial_t *)
KHASH_MAP_INIT_INT(light, renderlight_t *)
KHASH_MAP_INIT_INT(texgen, rendertexgen_t *)
typedef struct _call_list_t {
unsigned long len;
unsigned long cap;
packed_call_t **calls;
} call_list_t;
typedef struct _renderlist_t {
unsigned long len;
unsigned long ilen;
unsigned long cap;
GLenum mode;
GLenum mode_init; // initial requested mode
GLfloat lastNormal[3];
call_list_t calls;
GLfloat *vert;
GLfloat *normal;
GLfloat *color;
GLfloat *secondary;
GLfloat *tex[MAX_TEX];
GLushort *indices;
GLboolean q2t;
GLuint glcall_list;
rasterlist_t *raster;
liststage_t stage;
GLbitfield pushattribute;
GLboolean popattribute;
khash_t(material) *material;
khash_t(light) *light;
khash_t(texgen) *texgen;
GLfloat *lightmodel;
GLenum lightmodelparam;
GLenum polygon_mode;
GLuint texture; // I cannot know the active texture inside a list (for now => TODO?)
GLenum target_texture; // to support cube maps...
GLboolean set_texture;
struct _renderlist_t *prev;
struct _renderlist_t *next;
GLboolean open;
} renderlist_t;
#define DEFAULT_CALL_LIST_CAPACITY 20
#define DEFAULT_RENDER_LIST_CAPACITY 20
#define NewStage(l, s) if (l->stage+StageExclusive[s] > s) {l = extend_renderlist(l);} l->stage = s
extern renderlist_t *alloc_renderlist();
extern renderlist_t *extend_renderlist(renderlist_t *list);
extern void free_renderlist(renderlist_t *list);
extern void draw_renderlist(renderlist_t *list);
extern void q2t_renderlist(renderlist_t *list);
extern void end_renderlist(renderlist_t *list);
extern void rlBindTexture(renderlist_t *list, GLenum target, GLuint texture);
extern void rlColor4f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b, GLfloat a);
extern void rlMaterialfv(renderlist_t *list, GLenum face, GLenum pname, const GLfloat * params);
extern void rlLightfv(renderlist_t *list, GLenum which, GLenum pname, const GLfloat * params);
extern void rlTexGenfv(renderlist_t *list, GLenum coord, GLenum pname, const GLfloat * params);
extern void rlNormal3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z);
extern void rlPushCall(renderlist_t *list, packed_call_t *data);
extern void rlTexCoord2f(renderlist_t *list, GLfloat s, GLfloat t);
extern void rlMultiTexCoord2f(renderlist_t *list, GLenum texture, GLfloat s, GLfloat t);
extern void rlVertex3f(renderlist_t *list, GLfloat x, GLfloat y, GLfloat z);
extern void rlSecondary3f(renderlist_t *list, GLfloat r, GLfloat g, GLfloat b);
#endif

View File

@@ -0,0 +1,453 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 Brian Paul 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
* BRIAN PAUL 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.
*/
/*
* eval.c was written by
* Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and
* Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de).
*
* My original implementation of evaluators was simplistic and didn't
* compute surface normal vectors properly. Bernd and Volker applied
* used more sophisticated methods to get better results.
*
* Thanks guys!
*/
#include "eval.h"
static GLboolean init_done = false;
static GLfloat inv_tab[MAX_EVAL_ORDER];
/*
* Horner scheme for Bezier curves
*
* Bezier curves can be computed via a Horner scheme.
* Horner is numerically less stable than the de Casteljau
* algorithm, but it is faster. For curves of degree n
* the complexity of Horner is O(n) and de Casteljau is O(n^2).
* Since stability is not important for displaying curve
* points I decided to use the Horner scheme.
*
* A cubic Bezier curve with control points b0, b1, b2, b3 can be
* written as
*
* (([3] [3] ) [3] ) [3]
* c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
*
* [n]
* where s=1-t and the binomial coefficients [i]. These can
* be computed iteratively using the identity:
*
* [n] [n ] [n]
* [i] = (n-i+1)/i * [i-1] and [0] = 1
*/
void
_math_horner_bezier_curve(const GLfloat * cp, GLfloat * out, GLfloat t,
GLuint dim, GLuint order) {
if (! init_done)
_math_init_eval();
GLfloat s, powert, bincoeff;
GLuint i, k;
if (order >= 2) {
bincoeff = (GLfloat) (order - 1);
s = 1.0F - t;
for (k = 0; k < dim; k++)
out[k] = s * cp[k] + bincoeff * t * cp[dim + k];
for (i = 2, cp += 2 * dim, powert = t * t; i < order;
i++, powert *= t, cp += dim) {
bincoeff *= (GLfloat) (order - i);
bincoeff *= inv_tab[i];
for (k = 0; k < dim; k++)
out[k] = s * out[k] + bincoeff * powert * cp[k];
}
} else { /* order=1 -> constant curve */
for (k = 0; k < dim; k++)
out[k] = cp[k];
}
}
/*
* Tensor product Bezier surfaces
*
* Again the Horner scheme is used to compute a point on a
* TP Bezier surface. First a control polygon for a curve
* on the surface in one parameter direction is computed,
* then the point on the curve for the other parameter
* direction is evaluated.
*
* To store the curve control polygon additional storage
* for max(uorder,vorder) points is needed in the
* control net cn.
*/
void
_math_horner_bezier_surf(GLfloat * cn, GLfloat * out, GLfloat u, GLfloat v,
GLuint dim, GLuint uorder, GLuint vorder) {
if (! init_done)
_math_init_eval();
GLfloat *cp = cn + uorder * vorder * dim;
GLuint i, uinc = vorder * dim;
if (vorder > uorder) {
if (uorder >= 2) {
GLfloat s, poweru, bincoeff;
GLuint j, k;
/* Compute the control polygon for the surface-curve in u-direction */
for (j = 0; j < vorder; j++) {
GLfloat *ucp = &cn[j * dim];
/* Each control point is the point for parameter u on a */
/* curve defined by the control polygons in u-direction */
bincoeff = (GLfloat) (uorder - 1);
s = 1.0F - u;
for (k = 0; k < dim; k++)
cp[j * dim + k] = s * ucp[k] + bincoeff * u * ucp[uinc + k];
for (i = 2, ucp += 2 * uinc, poweru = u * u; i < uorder;
i++, poweru *= u, ucp += uinc) {
bincoeff *= (GLfloat) (uorder - i);
bincoeff *= inv_tab[i];
for (k = 0; k < dim; k++)
cp[j * dim + k] =
s * cp[j * dim + k] + bincoeff * poweru * ucp[k];
}
}
/* Evaluate curve point in v */
_math_horner_bezier_curve(cp, out, v, dim, vorder);
} else /* uorder=1 -> cn defines a curve in v */
_math_horner_bezier_curve(cn, out, v, dim, vorder);
} else { /* vorder <= uorder */
if (vorder > 1) {
GLuint i;
/* Compute the control polygon for the surface-curve in u-direction */
for (i = 0; i < uorder; i++, cn += uinc) {
/* For constant i all cn[i][j] (j=0..vorder) are located */
/* on consecutive memory locations, so we can use */
/* horner_bezier_curve to compute the control points */
_math_horner_bezier_curve(cn, &cp[i * dim], v, dim, vorder);
}
/* Evaluate curve point in u */
_math_horner_bezier_curve(cp, out, u, dim, uorder);
} else /* vorder=1 -> cn defines a curve in u */
_math_horner_bezier_curve(cn, out, u, dim, uorder);
}
}
/*
* The direct de Casteljau algorithm is used when a point on the
* surface and the tangent directions spanning the tangent plane
* should be computed (this is needed to compute normals to the
* surface). In this case the de Casteljau algorithm approach is
* nicer because a point and the partial derivatives can be computed
* at the same time. To get the correct tangent length du and dv
* must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
* Since only the directions are needed, this scaling step is omitted.
*
* De Casteljau needs additional storage for uorder*vorder
* values in the control net cn.
*/
void
_math_de_casteljau_surf(GLfloat * cn, GLfloat * out, GLfloat * du,
GLfloat * dv, GLfloat u, GLfloat v, GLuint dim,
GLuint uorder, GLuint vorder) {
GLfloat *dcn = cn + uorder * vorder * dim;
GLfloat us = 1.0F - u, vs = 1.0F - v;
GLuint h, i, j, k;
GLuint minorder = uorder < vorder ? uorder : vorder;
GLuint uinc = vorder * dim;
GLuint dcuinc = vorder;
/* Each component is evaluated separately to save buffer space */
/* This does not drasticaly decrease the performance of the */
/* algorithm. If additional storage for (uorder-1)*(vorder-1) */
/* points would be available, the components could be accessed */
/* in the innermost loop which could lead to less cache misses. */
#define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)]
#define DCN(I, J) dcn[(I)*dcuinc+(J)]
if (minorder < 3) {
if (uorder == vorder) {
for (k = 0; k < dim; k++) {
/* Derivative direction in u */
du[k] = vs * (CN(1, 0, k) - CN(0, 0, k)) +
v * (CN(1, 1, k) - CN(0, 1, k));
/* Derivative direction in v */
dv[k] = us * (CN(0, 1, k) - CN(0, 0, k)) +
u * (CN(1, 1, k) - CN(1, 0, k));
/* bilinear de Casteljau step */
out[k] = us * (vs * CN(0, 0, k) + v * CN(0, 1, k)) +
u * (vs * CN(1, 0, k) + v * CN(1, 1, k));
}
} else if (minorder == uorder) {
for (k = 0; k < dim; k++) {
/* bilinear de Casteljau step */
DCN(1, 0) = CN(1, 0, k) - CN(0, 0, k);
DCN(0, 0) = us * CN(0, 0, k) + u * CN(1, 0, k);
for (j = 0; j < vorder - 1; j++) {
/* for the derivative in u */
DCN(1, j + 1) = CN(1, j + 1, k) - CN(0, j + 1, k);
DCN(1, j) = vs * DCN(1, j) + v * DCN(1, j + 1);
/* for the `point' */
DCN(0, j + 1) = us * CN(0, j + 1, k) + u * CN(1, j + 1, k);
DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
}
/* remaining linear de Casteljau steps until the second last step */
for (h = minorder; h < vorder - 1; h++)
for (j = 0; j < vorder - h; j++) {
/* for the derivative in u */
DCN(1, j) = vs * DCN(1, j) + v * DCN(1, j + 1);
/* for the `point' */
DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
}
/* derivative direction in v */
dv[k] = DCN(0, 1) - DCN(0, 0);
/* derivative direction in u */
du[k] = vs * DCN(1, 0) + v * DCN(1, 1);
/* last linear de Casteljau step */
out[k] = vs * DCN(0, 0) + v * DCN(0, 1);
}
} else { /* minorder == vorder */
for (k = 0; k < dim; k++) {
/* bilinear de Casteljau step */
DCN(0, 1) = CN(0, 1, k) - CN(0, 0, k);
DCN(0, 0) = vs * CN(0, 0, k) + v * CN(0, 1, k);
for (i = 0; i < uorder - 1; i++) {
/* for the derivative in v */
DCN(i + 1, 1) = CN(i + 1, 1, k) - CN(i + 1, 0, k);
DCN(i, 1) = us * DCN(i, 1) + u * DCN(i + 1, 1);
/* for the `point' */
DCN(i + 1, 0) = vs * CN(i + 1, 0, k) + v * CN(i + 1, 1, k);
DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
}
/* remaining linear de Casteljau steps until the second last step */
for (h = minorder; h < uorder - 1; h++)
for (i = 0; i < uorder - h; i++) {
/* for the derivative in v */
DCN(i, 1) = us * DCN(i, 1) + u * DCN(i + 1, 1);
/* for the `point' */
DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
}
/* derivative direction in u */
du[k] = DCN(1, 0) - DCN(0, 0);
/* derivative direction in v */
dv[k] = us * DCN(0, 1) + u * DCN(1, 1);
/* last linear de Casteljau step */
out[k] = us * DCN(0, 0) + u * DCN(1, 0);
}
}
} else if (uorder == vorder) {
for (k = 0; k < dim; k++) {
/* first bilinear de Casteljau step */
for (i = 0; i < uorder - 1; i++) {
DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k);
for (j = 0; j < vorder - 1; j++) {
DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k);
DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
}
}
/* remaining bilinear de Casteljau steps until the second last step */
for (h = 2; h < minorder - 1; h++) {
for (i = 0; i < uorder - h; i++) {
DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
for (j = 0; j < vorder - h; j++) {
DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1);
DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
}
}
}
/* derivative direction in u */
du[k] = vs * (DCN(1, 0) - DCN(0, 0)) + v * (DCN(1, 1) - DCN(0, 1));
/* derivative direction in v */
dv[k] = us * (DCN(0, 1) - DCN(0, 0)) + u * (DCN(1, 1) - DCN(1, 0));
/* last bilinear de Casteljau step */
out[k] = us * (vs * DCN(0, 0) + v * DCN(0, 1)) +
u * (vs * DCN(1, 0) + v * DCN(1, 1));
}
} else if (minorder == uorder) {
for (k = 0; k < dim; k++) {
/* first bilinear de Casteljau step */
for (i = 0; i < uorder - 1; i++) {
DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k);
for (j = 0; j < vorder - 1; j++) {
DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k);
DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
}
}
/* remaining bilinear de Casteljau steps until the second last step */
for (h = 2; h < minorder - 1; h++) {
for (i = 0; i < uorder - h; i++) {
DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
for (j = 0; j < vorder - h; j++) {
DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1);
DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
}
}
}
/* last bilinear de Casteljau step */
DCN(2, 0) = DCN(1, 0) - DCN(0, 0);
DCN(0, 0) = us * DCN(0, 0) + u * DCN(1, 0);
for (j = 0; j < vorder - 1; j++) {
/* for the derivative in u */
DCN(2, j + 1) = DCN(1, j + 1) - DCN(0, j + 1);
DCN(2, j) = vs * DCN(2, j) + v * DCN(2, j + 1);
/* for the `point' */
DCN(0, j + 1) = us * DCN(0, j + 1) + u * DCN(1, j + 1);
DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
}
/* remaining linear de Casteljau steps until the second last step */
for (h = minorder; h < vorder - 1; h++) {
for (j = 0; j < vorder - h; j++) {
/* for the derivative in u */
DCN(2, j) = vs * DCN(2, j) + v * DCN(2, j + 1);
/* for the `point' */
DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
}
}
/* derivative direction in v */
dv[k] = DCN(0, 1) - DCN(0, 0);
/* derivative direction in u */
du[k] = vs * DCN(2, 0) + v * DCN(2, 1);
/* last linear de Casteljau step */
out[k] = vs * DCN(0, 0) + v * DCN(0, 1);
}
} else { /* minorder == vorder */
for (k = 0; k < dim; k++) {
/* first bilinear de Casteljau step */
for (i = 0; i < uorder - 1; i++) {
DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k);
for (j = 0; j < vorder - 1; j++) {
DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k);
DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
}
}
/* remaining bilinear de Casteljau steps until the second last step */
for (h = 2; h < minorder - 1; h++) {
for (i = 0; i < uorder - h; i++) {
DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
for (j = 0; j < vorder - h; j++) {
DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1);
DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
}
}
}
/* last bilinear de Casteljau step */
DCN(0, 2) = DCN(0, 1) - DCN(0, 0);
DCN(0, 0) = vs * DCN(0, 0) + v * DCN(0, 1);
for (i = 0; i < uorder - 1; i++) {
/* for the derivative in v */
DCN(i + 1, 2) = DCN(i + 1, 1) - DCN(i + 1, 0);
DCN(i, 2) = us * DCN(i, 2) + u * DCN(i + 1, 2);
/* for the `point' */
DCN(i + 1, 0) = vs * DCN(i + 1, 0) + v * DCN(i + 1, 1);
DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
}
/* remaining linear de Casteljau steps until the second last step */
for (h = minorder; h < uorder - 1; h++) {
for (i = 0; i < uorder - h; i++) {
/* for the derivative in v */
DCN(i, 2) = us * DCN(i, 2) + u * DCN(i + 1, 2);
/* for the `point' */
DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
}
}
/* derivative direction in u */
du[k] = DCN(1, 0) - DCN(0, 0);
/* derivative direction in v */
dv[k] = us * DCN(0, 2) + u * DCN(1, 2);
/* last linear de Casteljau step */
out[k] = us * DCN(0, 0) + u * DCN(1, 0);
}
}
#undef DCN
#undef CN
}
/*
* Do one-time initialization for evaluators.
*/
void _math_init_eval() {
GLuint i;
/* KW: precompute 1/x for useful x.
*/
for (i = 1; i < MAX_EVAL_ORDER; i++)
inv_tab[i] = 1.0F / i;
init_done = true;
}

View File

@@ -0,0 +1,103 @@
/*
* Mesa 3-D graphics library
* Version: 3.5
*
* Copyright (C) 1999-2001 Brian Paul 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
* BRIAN PAUL 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.
*/
#ifndef _M_EVAL_H
#define _M_EVAL_H
#include "../gl.h"
void _math_init_eval( void );
/*
* Horner scheme for Bezier curves
*
* Bezier curves can be computed via a Horner scheme.
* Horner is numerically less stable than the de Casteljau
* algorithm, but it is faster. For curves of degree n
* the complexity of Horner is O(n) and de Casteljau is O(n^2).
* Since stability is not important for displaying curve
* points I decided to use the Horner scheme.
*
* A cubic Bezier curve with control points b0, b1, b2, b3 can be
* written as
*
* (([3] [3] ) [3] ) [3]
* c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
*
* [n]
* where s=1-t and the binomial coefficients [i]. These can
* be computed iteratively using the identity:
*
* [n] [n ] [n]
* [i] = (n-i+1)/i * [i-1] and [0] = 1
*/
void
_math_horner_bezier_curve(const GLfloat *cp, GLfloat *out, GLfloat t,
GLuint dim, GLuint order);
/*
* Tensor product Bezier surfaces
*
* Again the Horner scheme is used to compute a point on a
* TP Bezier surface. First a control polygon for a curve
* on the surface in one parameter direction is computed,
* then the point on the curve for the other parameter
* direction is evaluated.
*
* To store the curve control polygon additional storage
* for max(uorder,vorder) points is needed in the
* control net cn.
*/
void
_math_horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v,
GLuint dim, GLuint uorder, GLuint vorder);
/*
* The direct de Casteljau algorithm is used when a point on the
* surface and the tangent directions spanning the tangent plane
* should be computed (this is needed to compute normals to the
* surface). In this case the de Casteljau algorithm approach is
* nicer because a point and the partial derivatives can be computed
* at the same time. To get the correct tangent length du and dv
* must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
* Since only the directions are needed, this scaling step is omitted.
*
* De Casteljau needs additional storage for uorder*vorder
* values in the control net cn.
*/
void
_math_de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv,
GLfloat u, GLfloat v, GLuint dim,
GLuint uorder, GLuint vorder);
#endif

862
project/jni/glshim/src/gl/pixel.c Executable file
View File

@@ -0,0 +1,862 @@
#include "pixel.h"
static const colorlayout_t *get_color_map(GLenum format) {
#define map(fmt, ...) \
case fmt: { \
static colorlayout_t layout = {fmt, __VA_ARGS__}; \
return &layout; }
switch (format) {
map(GL_RED, 0, -1, -1, -1);
map(GL_RG, 0, 1, -1, -1);
map(GL_RGBA, 0, 1, 2, 3);
map(GL_RGB, 0, 1, 2, -1);
map(GL_BGRA, 2, 1, 0, 3);
map(GL_BGR, 2, 1, 0, -1);
map(GL_LUMINANCE_ALPHA, 0, 0, 0, 1);
map(GL_LUMINANCE, 0, 0, 0, -1);
map(GL_ALPHA, -1, -1, -1, 0);
default:
printf("libGL: unknown pixel format %i\n", format);
break;
}
static colorlayout_t null = {0};
return &null;
#undef map
}
static inline
bool remap_pixel(const GLvoid *src, GLvoid *dst,
const colorlayout_t *src_color, GLenum src_type,
const colorlayout_t *dst_color, GLenum dst_type) {
#define type_case(constant, type, ...) \
case constant: { \
const type *s = (const type *)src; \
type *d = (type *)dst; \
type v = *s; \
__VA_ARGS__ \
break; \
}
#define default(arr, amod, vmod, key, def) \
(key >= 0)? arr[amod key] vmod : def
#define carefully(arr, amod, key, value) \
if (key >= 0) d[amod key] = value;
#define read_each(amod, vmod) \
pixel.r = default(s, amod, vmod, src_color->red, 0.0f); \
pixel.g = default(s, amod, vmod, src_color->green, 0.0f); \
pixel.b = default(s, amod, vmod, src_color->blue, 0.0f); \
pixel.a = default(s, amod, vmod, src_color->alpha, 1.0f);
#define write_each(amod, vmod) \
carefully(d, amod, dst_color->red, pixel.r vmod) \
carefully(d, amod, dst_color->green, pixel.g vmod) \
carefully(d, amod, dst_color->blue, pixel.b vmod) \
carefully(d, amod, dst_color->alpha, pixel.a vmod)
// this pixel stores our intermediate color
// it will be RGBA and normalized to between (0.0 - 1.0f)
pixel_t pixel;
int max_a = src_color->red;
if (src_color->green>max_a) max_a=src_color->green;
if (src_color->blue>max_a) max_a=src_color->blue;
if (src_color->alpha>max_a) max_a=src_color->alpha;
switch (src_type) {
type_case(GL_DOUBLE, GLdouble, read_each(,))
type_case(GL_FLOAT, GLfloat, read_each(,))
type_case(GL_BYTE, GLbyte, read_each(, / 128.0f))
case GL_UNSIGNED_INT_8_8_8_8_REV:
type_case(GL_UNSIGNED_BYTE, GLubyte, read_each(, / 255.0f))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, read_each(max_a - , / 255.0f))
type_case(GL_UNSIGNED_SHORT_1_5_5_5_REV, GLushort,
s = (GLushort[]){
(v & 31),
((v & 0x03e0) >> 5),
((v & 0x7c00) >> 10),
((v & 0x8000) >> 15)*31,
};
read_each(, / 31.0f);
)
type_case(GL_UNSIGNED_SHORT_5_6_5, GLushort,
s = (GLushort[]){
(v & 31)*2,
((v & 0x07e0) >> 5),
((v & 0xF800) >> 11)*2,
};
read_each(, / 63.0f);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
s = (GLushort[]){
(v & 0x000f),
((v & 0x00f0) >> 4),
((v & 0x0f00) >> 8),
((v & 0xf000) >> 12)
};
read_each(, / 15.0f);
)
default:
// TODO: add glSetError?
printf("libGL: Unsupported source data type: %04X\n", src_type);
return false;
break;
}
max_a = dst_color->red;
if (dst_color->green>max_a) max_a=dst_color->green;
if (dst_color->blue>max_a) max_a=dst_color->blue;
if (dst_color->alpha>max_a) max_a=dst_color->alpha;
if ((dst_color->red==dst_color->green) && (dst_color->red==dst_color->blue)) {
// special case
GLfloat aa = (pixel.r + pixel.g + pixel.b)/3.0f; //*TODO* find a better formula. real luminance is not just the mean value.
pixel.r = pixel.b = pixel.b = aa;
}
switch (dst_type) {
type_case(GL_FLOAT, GLfloat, write_each(,))
type_case(GL_BYTE, GLbyte, write_each(, * 127.0f))
type_case(GL_UNSIGNED_BYTE, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8_REV, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, write_each(max_a - , * 255.0))
// TODO: force 565 to RGB? then we can change [4] -> 3
type_case(GL_UNSIGNED_SHORT_5_6_5, GLushort,
GLfloat color[4];
color[dst_color->red] = pixel.r;
color[dst_color->green] = pixel.g;
color[dst_color->blue] = pixel.b;
*d = ((GLushort)(color[0] * 31.0) & 0x1f << 11) |
((GLushort)(color[1] * 63.0) & 0x3f << 5) |
((GLushort)(color[2] * 31.0) & 0x1f);
)
type_case(GL_UNSIGNED_SHORT_5_5_5_1, GLushort,
GLfloat color[4];
color[dst_color->red] = pixel.r;
color[dst_color->green] = pixel.g;
color[dst_color->blue] = pixel.b;
color[dst_color->alpha] = pixel.a;
// TODO: can I macro this or something? it follows a pretty strict form.
*d = ((GLuint)(color[0] * 31) & 0x1f << 0) |
((GLuint)(color[1] * 31) & 0x1f << 5) |
((GLuint)(color[2] * 31) & 0x1f << 10) |
((GLuint)(color[3] * 1) & 0x01 << 15);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
GLfloat color[4];
color[dst_color->red] = pixel.r;
color[dst_color->green] = pixel.g;
color[dst_color->blue] = pixel.b;
color[dst_color->alpha] = pixel.a;
*d = ((GLushort)(color[0] * 15.0) & 0x0f << 12) |
((GLushort)(color[1] * 15.0) & 0x0f << 8) |
((GLushort)(color[2] * 15.0) & 0x0f << 4) |
((GLushort)(color[3] * 15.0) & 0x0f);
)
default:
printf("libGL: Unsupported target data type: %04X\n", dst_type);
return false;
break;
}
return true;
#undef type_case
#undef default
#undef carefully
#undef read_each
#undef write_each
}
static inline
bool transform_pixel(const GLvoid *src, GLvoid *dst,
const colorlayout_t *src_color, GLenum src_type,
const GLfloat *scale, const GLfloat *bias) {
#define type_case(constant, type, ...) \
case constant: { \
const type *s = (const type *)src; \
type *d = (type *)dst; \
type v = *s; \
__VA_ARGS__ \
break; \
}
#define default(arr, amod, vmod, key, def) \
(amod key) >= 0 ? arr[amod key] vmod : def
#define carefully(arr, amod, key, value) \
if ((amod key) >= 0) d[amod key] = value;
#define read_each(amod, vmod) \
pixel.r = default(s, amod, vmod, src_color->red, 0.0f); \
pixel.g = default(s, amod, vmod, src_color->green, 0.0f); \
pixel.b = default(s, amod, vmod, src_color->blue, 0.0f); \
pixel.a = default(s, amod, vmod, src_color->alpha, 1.0f);
#define write_each(amod, vmod) \
carefully(d, amod, src_color->red, pixel.r vmod) \
carefully(d, amod, src_color->green, pixel.g vmod) \
carefully(d, amod, src_color->blue, pixel.b vmod) \
carefully(d, amod, src_color->alpha, pixel.a vmod)
#define transformf(pix, number) \
pix=pix*scale[number]+bias[number]; \
if (pix<0.0) pix=0.0; \
if (pix>1.0) pix=1.0;
// this pixel stores our intermediate color
// it will be RGBA and normalized to between (0.0 - 1.0f)
pixel_t pixel;
int max_a = src_color->red;
if (src_color->green>max_a) max_a=src_color->green;
if (src_color->blue>max_a) max_a=src_color->blue;
if (src_color->alpha>max_a) max_a=src_color->alpha;
switch (src_type) {
type_case(GL_DOUBLE, GLdouble, read_each(,))
type_case(GL_FLOAT, GLfloat, read_each(,))
case GL_UNSIGNED_INT_8_8_8_8_REV:
type_case(GL_UNSIGNED_BYTE, GLubyte, read_each(, / 255.0f))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, read_each(max_a - , / 255.0f))
type_case(GL_UNSIGNED_SHORT_1_5_5_5_REV, GLushort,
s = (GLushort[]){
(v & 31),
((v & 0x03e0) >> 5),
((v & 0x7c00) >> 10),
((v & 0x8000) >> 15)*31,
};
read_each(, / 31.0f);
)
type_case(GL_UNSIGNED_SHORT_5_6_5, GLushort,
s = (GLushort[]){
(v & 31)*2,
((v & 0x07e0) >> 5),
((v & 0xF800) >> 11)*2,
};
read_each(, / 63.0f);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
s = (GLushort[]){
(v & 0x000f),
((v & 0x00f0) >> 4),
((v & 0x0f00) >> 8),
((v & 0xf000) >> 12)
};
read_each(, / 15.0f);
)
default:
// TODO: add glSetError?
printf("libGL: transform_pixel: Unsupported source data type: %04X\n", src_type);
return false;
break;
}
transformf(pixel.r, 0);
transformf(pixel.g, 1);
transformf(pixel.b, 2);
transformf(pixel.a, 3);
switch (src_type) {
type_case(GL_FLOAT, GLfloat, write_each(,))
type_case(GL_UNSIGNED_BYTE, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8_REV, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, write_each(max_a - , * 255.0))
// TODO: force 565 to RGB? then we can change [4] -> 3
type_case(GL_UNSIGNED_SHORT_5_6_5, GLushort,
GLfloat color[4];
color[src_color->red] = pixel.r;
color[src_color->green] = pixel.g;
color[src_color->blue] = pixel.b;
*d = ((GLuint)(color[2] * 31) & 0x1f << 11) |
((GLuint)(color[1] * 63) & 0x3f << 5) |
((GLuint)(color[0] * 31) & 0x1f);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
GLfloat color[4];
color[src_color->red] = pixel.r;
color[src_color->green] = pixel.g;
color[src_color->blue] = pixel.b;
color[src_color->alpha] = pixel.a;
*d = ((GLushort)(color[3] * 15.0) & 0x0f << 12) |
((GLushort)(color[2] * 15.0) & 0x0f << 8) |
((GLushort)(color[1] * 15.0) & 0x0f << 4) |
((GLushort)(color[0] * 15.0) & 0x0f);
)
default:
printf("libGL: Unsupported target data type: %04X\n", src_type);
return false;
break;
}
return true;
#undef transformf
#undef type_case
#undef default
#undef carefully
#undef read_each
#undef write_each
}
static inline
bool half_pixel(const GLvoid *src0, const GLvoid *src1,
const GLvoid *src2, const GLvoid *src3,
GLvoid *dst,
const colorlayout_t *src_color, GLenum src_type) {
#define type_case(constant, type, ...) \
case constant: { \
const type *s[4]; \
s[0] = (const type *)src0; \
s[1] = (const type *)src1; \
s[2] = (const type *)src2; \
s[3] = (const type *)src3; \
type *d = (type *)dst; \
type v[4]; \
v[0] = *s[0]; \
v[1] = *s[1]; \
v[2] = *s[2]; \
v[3] = *s[3]; \
__VA_ARGS__ \
break; \
}
#define default(arr, amod, vmod, key, def) \
(amod key) >= 0 ? arr[amod key] vmod : def
#define carefully(arr, amod, key, value) \
if ((amod key) >= 0) d[amod key] = value;
#define read_i_each(amod, vmod, i) \
pix[i].r = default(s[i], amod, vmod, src_color->red, 0.0f); \
pix[i].g = default(s[i], amod, vmod, src_color->green, 0.0f); \
pix[i].b = default(s[i], amod, vmod, src_color->blue, 0.0f); \
pix[i].a = default(s[i], amod, vmod, src_color->alpha, 1.0f);
#define read_each(amod, vmod) \
read_i_each(amod, vmod, 0); \
read_i_each(amod, vmod, 1); \
read_i_each(amod, vmod, 2); \
read_i_each(amod, vmod, 3);
#define write_each(amod, vmod) \
carefully(d, amod, src_color->red, pixel.r vmod) \
carefully(d, amod, src_color->green, pixel.g vmod) \
carefully(d, amod, src_color->blue, pixel.b vmod) \
carefully(d, amod, src_color->alpha, pixel.a vmod)
// this pixel stores our intermediate color
// it will be RGBA and normalized to between (0.0 - 1.0f)
pixel_t pix[4], pixel;
int max_a = src_color->red;
if (src_color->green>max_a) max_a=src_color->green;
if (src_color->blue>max_a) max_a=src_color->blue;
if (src_color->alpha>max_a) max_a=src_color->alpha;
switch (src_type) {
type_case(GL_DOUBLE, GLdouble, read_each(,))
type_case(GL_FLOAT, GLfloat, read_each(,))
case GL_UNSIGNED_INT_8_8_8_8_REV:
type_case(GL_UNSIGNED_BYTE, GLubyte, read_each(, / 255.0f))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, read_each(max_a - , / 255.0f))
type_case(GL_UNSIGNED_SHORT_1_5_5_5_REV, GLushort,
for (int ii=0; ii<4; ii++) {
s[ii] = (GLushort[]) {
(v[ii] & 31),
((v[ii] & 0x03e0) >> 5),
((v[ii] & 0x7c00) >> 10),
((v[ii] & 0x8000) >> 15)*31,
};
};
read_each(, / 31.0f);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
for (int ii=0; ii<4; ii++) {
s[ii] = (GLushort[]) {
(v[ii] & 0x000f),
((v[ii] & 0x00f0) >> 4),
((v[ii] & 0x0f00) >> 8),
((v[ii] & 0xf000) >> 12)
};
};
read_each(, / 15.0f);
)
default:
// TODO: add glSetError?
printf("libGL: half_pixel: Unsupported source data type: %04X\n", src_type);
return false;
break;
}
pixel.r = (pix[0].r + pix[1].r + pix[2].r + pix[3].r) * 0.25f;
pixel.g = (pix[0].g + pix[1].g + pix[2].g + pix[3].g) * 0.25f;
pixel.b = (pix[0].b + pix[1].b + pix[2].b + pix[3].b) * 0.25f;
pixel.a = (pix[0].a + pix[1].a + pix[2].a + pix[3].a) * 0.25f;
switch (src_type) {
type_case(GL_FLOAT, GLfloat, write_each(,))
type_case(GL_UNSIGNED_BYTE, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8_REV, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, write_each(max_a - , * 255.0))
// TODO: force 565 to RGB? then we can change [4] -> 3
type_case(GL_UNSIGNED_SHORT_5_6_5, GLushort,
GLfloat color[4];
color[src_color->red] = pixel.r;
color[src_color->green] = pixel.g;
color[src_color->blue] = pixel.b;
*d = ((GLuint)(color[0] * 31) & 0x1f << 11) |
((GLuint)(color[1] * 63) & 0x3f << 5) |
((GLuint)(color[2] * 31) & 0x1f);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
GLfloat color[4];
color[src_color->red] = pixel.r;
color[src_color->green] = pixel.g;
color[src_color->blue] = pixel.b;
color[src_color->alpha] = pixel.a;
*d = ((GLushort)(color[0] * 15.0) & 0x0f << 12) |
((GLushort)(color[1] * 15.0) & 0x0f << 8) |
((GLushort)(color[2] * 15.0) & 0x0f << 4) |
((GLushort)(color[3] * 15.0) & 0x0f);
)
default:
printf("libGL: half_pixel: Unsupported target data type: %04X\n", src_type);
return false;
break;
}
return true;
#undef type_case
#undef default
#undef carefully
#undef read_each
#undef read_each_i
#undef write_each
}
static inline
bool quarter_pixel(const GLvoid *src[16],
GLvoid *dst,
const colorlayout_t *src_color, GLenum src_type) {
#define type_case(constant, type, ...) \
case constant: { \
const type *s[16]; \
for (int aa=0; aa<16; aa++) \
s[aa] = (const type *)src[aa]; \
type *d = (type *)dst; \
type v[16]; \
for (int aa=0; aa<16; aa++) \
v[aa] = *s[aa]; \
__VA_ARGS__ \
break; \
}
#define default(arr, amod, vmod, key, def) \
(amod key) >= 0 ? arr[amod key] vmod : def
#define carefully(arr, amod, key, value) \
if ((amod key) >= 0) d[amod key] = value;
#define read_i_each(amod, vmod, i) \
pix[i].r = default(s[i], amod, vmod, src_color->red, 0.0f); \
pix[i].g = default(s[i], amod, vmod, src_color->green, 0.0f); \
pix[i].b = default(s[i], amod, vmod, src_color->blue, 0.0f); \
pix[i].a = default(s[i], amod, vmod, src_color->alpha, 1.0f);
#define read_each(amod, vmod) \
read_i_each(amod, vmod, 0); \
read_i_each(amod, vmod, 1); \
read_i_each(amod, vmod, 2); \
read_i_each(amod, vmod, 3); \
read_i_each(amod, vmod, 4); \
read_i_each(amod, vmod, 5); \
read_i_each(amod, vmod, 6); \
read_i_each(amod, vmod, 7); \
read_i_each(amod, vmod, 8); \
read_i_each(amod, vmod, 9); \
read_i_each(amod, vmod,10); \
read_i_each(amod, vmod,11); \
read_i_each(amod, vmod,12); \
read_i_each(amod, vmod,13); \
read_i_each(amod, vmod,14); \
read_i_each(amod, vmod,15); \
#define write_each(amod, vmod) \
carefully(d, amod, src_color->red, pixel.r vmod) \
carefully(d, amod, src_color->green, pixel.g vmod) \
carefully(d, amod, src_color->blue, pixel.b vmod) \
carefully(d, amod, src_color->alpha, pixel.a vmod)
// this pixel stores our intermediate color
// it will be RGBA and normalized to between (0.0 - 1.0f)
pixel_t pix[16], pixel;
int max_a = src_color->red;
if (src_color->green>max_a) max_a=src_color->green;
if (src_color->blue>max_a) max_a=src_color->blue;
if (src_color->alpha>max_a) max_a=src_color->alpha;
switch (src_type) {
type_case(GL_DOUBLE, GLdouble, read_each(,))
type_case(GL_FLOAT, GLfloat, read_each(,))
case GL_UNSIGNED_INT_8_8_8_8_REV:
type_case(GL_UNSIGNED_BYTE, GLubyte, read_each(, / 255.0f))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, read_each(max_a - , / 255.0f))
type_case(GL_UNSIGNED_SHORT_1_5_5_5_REV, GLushort,
for (int ii=0; ii<16; ii++) {
s[ii] = (GLushort[]) {
(v[ii] & 31),
((v[ii] & 0x03e0) >> 5),
((v[ii] & 0x7c00) >> 10),
((v[ii] & 0x8000) >> 15)*31,
};
};
read_each(, / 31.0f);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
for (int ii=0; ii<16; ii++) {
s[ii] = (GLushort[]) {
(v[ii] & 0x000f),
((v[ii] & 0x00f0) >> 4),
((v[ii] & 0x0f00) >> 8),
((v[ii] & 0xf000) >> 12)
};
};
read_each(, / 15.0f);
)
default:
// TODO: add glSetError?
printf("libGL: quarter_pixel: Unsupported source data type: %04X\n", src_type);
return false;
break;
}
pixel.r = (pix[0].r + pix[1].r + pix[2].r + pix[3].r + pix[4].r + pix[5].r + pix[6].r + pix[7].r + pix[8].r + pix[9].r + pix[10].r + pix[11].r + pix[12].r + pix[13].r + pix[14].r + pix[15].r) * 0.0625f;
pixel.g = (pix[0].g + pix[1].g + pix[2].g + pix[3].g + pix[4].g + pix[5].g + pix[6].g + pix[7].g + pix[8].g + pix[9].g + pix[10].g + pix[11].g + pix[12].g + pix[13].g + pix[14].g + pix[15].g) * 0.0625f;
pixel.b = (pix[0].b + pix[1].b + pix[2].b + pix[3].b + pix[4].b + pix[5].b + pix[6].b + pix[7].b + pix[8].b + pix[9].b + pix[10].b + pix[11].b + pix[12].b + pix[13].b + pix[14].b + pix[15].b) * 0.0625f;
pixel.a = (pix[0].a + pix[1].a + pix[2].a + pix[3].a + pix[4].a + pix[5].a + pix[6].a + pix[7].a + pix[8].a + pix[9].a + pix[10].a + pix[11].a + pix[12].a + pix[13].a + pix[14].a + pix[15].a) * 0.0625f;
switch (src_type) {
type_case(GL_FLOAT, GLfloat, write_each(,))
type_case(GL_UNSIGNED_BYTE, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8_REV, GLubyte, write_each(, * 255.0))
type_case(GL_UNSIGNED_INT_8_8_8_8, GLubyte, write_each(max_a - , * 255.0))
// TODO: force 565 to RGB? then we can change [4] -> 3
type_case(GL_UNSIGNED_SHORT_5_6_5, GLushort,
GLfloat color[4];
color[src_color->red] = pixel.r;
color[src_color->green] = pixel.g;
color[src_color->blue] = pixel.b;
*d = ((GLuint)(color[0] * 31) & 0x1f << 11) |
((GLuint)(color[1] * 63) & 0x3f << 5) |
((GLuint)(color[2] * 31) & 0x1f);
)
type_case(GL_UNSIGNED_SHORT_4_4_4_4, GLushort,
GLfloat color[4];
color[src_color->red] = pixel.r;
color[src_color->green] = pixel.g;
color[src_color->blue] = pixel.b;
color[src_color->alpha] = pixel.a;
*d = ((GLushort)(color[0] * 15.0) & 0x0f << 12) |
((GLushort)(color[1] * 15.0) & 0x0f << 8) |
((GLushort)(color[2] * 15.0) & 0x0f << 4) |
((GLushort)(color[3] * 15.0) & 0x0f);
)
default:
printf("libGL: quarter_pixel Unsupported target data type: %04X\n", src_type);
return false;
break;
}
return true;
#undef type_case
#undef default
#undef carefully
#undef read_each
#undef read_each_i
#undef write_each
}
bool pixel_convert(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum src_format, GLenum src_type,
GLenum dst_format, GLenum dst_type, GLuint stride) {
const colorlayout_t *src_color, *dst_color;
GLuint pixels = width * height;
GLuint dst_size = pixels * pixel_sizeof(dst_format, dst_type);
GLuint dst_width = stride * pixel_sizeof(dst_format, dst_type);
GLuint src_width = width * pixel_sizeof(dst_format, dst_type);
//printf("pixel conversion: %ix%i - %04x, %04x -> %04x, %04x, transform=%i\n", width, height, src_format, src_type, dst_format, dst_type, raster_need_transform());
src_color = get_color_map(src_format);
dst_color = get_color_map(dst_format);
if (!dst_size || !pixel_sizeof(src_format, src_type)
|| !src_color->type || !dst_color->type)
return false;
if (src_type == dst_type && src_color->type == dst_color->type) {
if (*dst == src)
return true;
if (*dst == NULL) // alloc dst only if dst==NULL
*dst = malloc(dst_size);
if (stride) // for in-place conversion
for (int yy=0; yy<height; yy++)
memcpy((*dst)+yy*dst_width, src+yy*src_width, src_width);
else
memcpy(*dst, src, dst_size);
return true;
}
GLsizei src_stride = pixel_sizeof(src_format, src_type);
GLsizei dst_stride = pixel_sizeof(dst_format, dst_type);
if (*dst == src || *dst == NULL)
*dst = malloc(dst_size);
uintptr_t src_pos = (uintptr_t)src;
uintptr_t dst_pos = (uintptr_t)*dst;
// fast optimized loop for common conversion cases first...
if ((src_format == GL_BGRA) && (dst_format == GL_RGBA) && (dst_type == GL_UNSIGNED_BYTE) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
tmp = *(const GLuint*)src_pos;
*(GLuint*)dst_pos = (tmp&0xff00ff00) | ((tmp&0x00ff0000)>>16) | ((tmp&0x000000ff)<<16);
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width - src_width;
}
return true;
}
if ((src_format == GL_RGB) && (dst_format == GL_RGB) && (dst_type = GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
tmp = *(const GLuint*)src_pos;
*(GLushort*)dst_pos = ((tmp&0x00f80000)>>(16+3)) | ((tmp&0x0000fc00)>>(8+2-5)) | ((tmp&0x000000f8)<<(11-3));
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width - src_width;
}
return true;
}
if ((src_format == GL_BGR) && (dst_format == GL_RGB) && (dst_type = GL_UNSIGNED_SHORT_5_6_5) && ((src_type == GL_UNSIGNED_BYTE)||(src_type == GL_UNSIGNED_INT_8_8_8_8_REV))) {
GLuint tmp;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
tmp = *(const GLuint*)src_pos;
*(GLushort*)dst_pos = ((tmp&0x00f80000)>>(16+3-11)) | ((tmp&0x0000fc00)>>(8+2-5)) | ((tmp&0x000000f8)>>(3));
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width - src_width;
}
return true;
}
if (! remap_pixel((const GLvoid *)src_pos, (GLvoid *)dst_pos,
src_color, src_type, dst_color, dst_type)) {
// fake convert, to get if it's ok or not
return false;
}
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
remap_pixel((const GLvoid *)src_pos, (GLvoid *)dst_pos,
src_color, src_type, dst_color, dst_type);
src_pos += src_stride;
dst_pos += dst_stride;
}
if (stride)
dst_pos += dst_width - src_width;
}
return true;
}
bool pixel_transform(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum src_format, GLenum src_type,
const GLfloat *scales, const GLfloat *bias)
{
const colorlayout_t *src_color;
GLuint pixels = width * height;
GLuint dst_size = pixels * pixel_sizeof(src_format, src_type);
src_color = get_color_map(src_format);
GLsizei src_stride = pixel_sizeof(src_format, src_type);
if (*dst == src || *dst == NULL)
*dst = malloc(dst_size);
uintptr_t src_pos = (uintptr_t)src;
uintptr_t dst_pos = (uintptr_t)*dst;
if (! transform_pixel((const GLvoid *)src_pos, (GLvoid *)dst_pos,
src_color, src_type, scales, bias)) {
// fake convert, to get if it's ok or not
return false;
}
for (int aa=0; aa<dst_size; aa++) {
for (int i = 0; i < pixels; i++) {
transform_pixel((const GLvoid *)src_pos, (GLvoid *)dst_pos,
src_color, src_type, scales, bias);
src_pos += src_stride;
dst_pos += src_stride;
}
return true;
}
return false;
}
bool pixel_scale(const GLvoid *old, GLvoid **new,
GLuint width, GLuint height,
GLfloat ratio,
GLenum format, GLenum type) {
GLuint pixel_size, new_width, new_height;
new_width = width * ratio;
new_height = height * ratio;
printf("scaling %ux%u -> %ux%u\n", width, height, new_width, new_height);
GLvoid *dst;
uintptr_t src, pos, pixel;
pixel_size = pixel_sizeof(format, type);
dst = malloc(pixel_size * new_width * new_height);
src = (uintptr_t)old;
pos = (uintptr_t)dst;
for (int y = 0; y < new_height; y++) {
for (int x = 0; x < new_width; x++) {
pixel = src + ((x / ratio) +
(y / ratio) * width) * pixel_size;
memcpy((GLvoid *)pos, (GLvoid *)pixel, pixel_size);
pos += pixel_size;
}
}
*new = dst;
return true;
}
bool pixel_halfscale(const GLvoid *old, GLvoid **new,
GLuint width, GLuint height,
GLenum format, GLenum type) {
GLuint pixel_size, new_width, new_height;
new_width = width / 2;
new_height = height / 2;
/* if (new_width*2!=width || new_height*2!=height) {
printf("LIBGL: halfscaling %ux%u failed\n", width, height);
return false;
}*/
// printf("LIBGL: halfscaling %ux%u -> %ux%u\n", width, height, new_width, new_height);
const colorlayout_t *src_color;
src_color = get_color_map(format);
GLvoid *dst;
uintptr_t src, pos, pix0, pix1, pix2, pix3;
pixel_size = pixel_sizeof(format, type);
dst = malloc(pixel_size * new_width * new_height);
src = (uintptr_t)old;
pos = (uintptr_t)dst;
for (int y = 0; y < new_height; y++) {
for (int x = 0; x < new_width; x++) {
pix0 = src + ((x * 2) +
(y * 2) * width) * pixel_size;
pix1 = src + ((x * 2 + 1) +
(y * 2) * width) * pixel_size;
pix2 = src + ((x * 2) +
(y * 2 + 1) * width) * pixel_size;
pix3 = src + ((x * 2 + 1) +
(y * 2 + 1) * width) * pixel_size;
half_pixel((GLvoid *)pix0, (GLvoid *)pix1, (GLvoid *)pix2, (GLvoid *)pix3, (GLvoid *)pos, src_color, type);
pos += pixel_size;
}
}
*new = dst;
return true;
}
bool pixel_thirdscale(const GLvoid *old, GLvoid **new,
GLuint width, GLuint height,
GLenum format, GLenum type) {
GLuint pixel_size, new_width, new_height, dest_size;
new_width = width / 2;
new_height = height / 2;
if (new_width*2!=width || new_height*2!=height || format!=GL_RGBA || type!=GL_UNSIGNED_BYTE) {
//printf("LIBGL: thirdscaling %ux%u failed\n", width, height);
return false;
}
// printf("LIBGL: halfscaling %ux%u -> %ux%u\n", width, height, new_width, new_height);
const colorlayout_t *src_color;
src_color = get_color_map(format);
GLvoid *dst;
uintptr_t src, pos, pix0, pix1, pix2, pix3;
pixel_size = pixel_sizeof(format, type);
dest_size = pixel_sizeof(format, GL_UNSIGNED_SHORT_4_4_4_4);
dst = malloc(dest_size * new_width * new_height);
src = (uintptr_t)old;
pos = (uintptr_t)dst;
GLubyte tmp[4];
for (int y = 0; y < new_height; y++) {
for (int x = 0; x < new_width; x++) {
pix0 = src + ((x * 2) +
(y * 2) * width) * pixel_size;
pix1 = src + ((x * 2 + 1) +
(y * 2) * width) * pixel_size;
pix2 = src + ((x * 2) +
(y * 2 + 1) * width) * pixel_size;
pix3 = src + ((x * 2 + 1) +
(y * 2 + 1) * width) * pixel_size;
half_pixel((GLvoid *)pix0, (GLvoid *)pix1, (GLvoid *)pix2, (GLvoid *)pix3, (GLvoid *)tmp, src_color, type);
*((GLushort*)pos) = (((GLushort)tmp[0])&0xf0)<<8 | (((GLushort)tmp[1])&0xf0)<<4 | (((GLushort)tmp[2])&0xf0) | (((GLushort)tmp[3])>>4);
pos += dest_size;
}
}
*new = dst;
return true;
}
bool pixel_quarterscale(const GLvoid *old, GLvoid **new,
GLuint width, GLuint height,
GLenum format, GLenum type) {
GLuint pixel_size, new_width, new_height;
new_width = width / 4;
new_height = height / 4;
if (new_width*4!=width || new_height*4!=height) {
printf("LIBGL: quarterscaling %ux%u failed", width, height);
return false;
}
// printf("LIBGL: quarterscaling %ux%u -> %ux%u\n", width, height, new_width, new_height);
const colorlayout_t *src_color;
src_color = get_color_map(format);
GLvoid *dst;
uintptr_t src, pos, pix[16];
pixel_size = pixel_sizeof(format, type);
dst = malloc(pixel_size * new_width * new_height);
src = (uintptr_t)old;
pos = (uintptr_t)dst;
for (int y = 0; y < new_height; y++) {
for (int x = 0; x < new_width; x++) {
for (int dx=0; dx<4; dx++) {
for (int dy=0; dy<4; dy++) {
pix[dx+dy*4] = src + ((x * 4 + dx) +
(y * 4 + dy) * width) * pixel_size;
}
}
quarter_pixel((const GLvoid **)pix, (GLvoid *)pos, src_color, type);
pos += pixel_size;
}
}
*new = dst;
return true;
}
bool pixel_to_ppm(const GLvoid *pixels, GLuint width, GLuint height,
GLenum format, GLenum type, GLuint name) {
if (! pixels)
return false;
GLvoid *src=0;
char filename[64];
int size = /*4 * */3 * width * height;
if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
src = (GLvoid*)pixels;
} else {
if (! pixel_convert(pixels, (GLvoid **)&src, width, height, format, type, GL_RGB, GL_UNSIGNED_BYTE, 0)) {
return false;
}
}
snprintf(filename, 64, "/tmp/tex.%d.ppm", name);
FILE *fd = fopen(filename, "w");
fprintf(fd, "P6 %d %d %d\n", width, height, 255);
fwrite(src, 1, size, fd);
fclose(fd);
return true;
}

View File

@@ -0,0 +1,46 @@
#include "gl.h"
#ifndef PIXEL_H
#define PIXEL_H
typedef struct {
GLenum type;
GLint red, green, blue, alpha;
} colorlayout_t;
typedef struct {
GLfloat r, g, b, a;
} pixel_t;
bool pixel_convert(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum src_format, GLenum src_type,
GLenum dst_format, GLenum dst_type, GLuint stride);
bool pixel_transform(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum src_format, GLenum src_type,
const GLfloat *scale, const GLfloat *bias);
bool pixel_scale(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLfloat ratio,
GLenum format, GLenum type);
bool pixel_halfscale(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum format, GLenum type);
bool pixel_thirdscale(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum format, GLenum type);
bool pixel_quarterscale(const GLvoid *src, GLvoid **dst,
GLuint width, GLuint height,
GLenum format, GLenum type);
bool pixel_to_ppm(const GLvoid *pixels,
GLuint width, GLuint height,
GLenum format, GLenum type, GLuint name);
#endif

View File

@@ -0,0 +1,426 @@
#include "raster.h"
rasterpos_t rPos = {0, 0, 0};
viewport_t viewport = {0, 0, 0, 0};
GLubyte *raster = NULL;
GLfloat zoomx=1.0f;
GLfloat zoomy=1.0f;
GLuint raster_texture=0;
GLsizei raster_width=0;
GLsizei raster_height=0;
GLint raster_x1, raster_x2, raster_y1, raster_y2;
#define min(a, b) ((a)<b)?(a):(b)
#define max(a, b) ((a)>(b))?(a):(b)
GLfloat raster_scale[4] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat raster_bias[4] = {0.0f, 0.0f, 0.0f, 0.0f};
extern void matrix_column_row(const GLfloat *a, GLfloat *b);
extern void matrix_vector(const GLfloat *a, const GLfloat *b, GLfloat *c);
void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z) {
#if 1
// Transform xyz coordinates with currzent modelview and projection matrix...
GLfloat glmatrix[16], projection[16], modelview[16];
GLfloat t[3], transl[3] = {x, y, z};
glGetFloatv(GL_PROJECTION_MATRIX, glmatrix);
matrix_column_row(glmatrix, projection);
glGetFloatv(GL_MODELVIEW_MATRIX, glmatrix);
matrix_column_row(glmatrix, modelview);
matrix_vector(modelview, transl, t);
matrix_vector(projection, t, transl);
GLfloat w2, h2;
w2=viewport.width/2.0f;
h2=viewport.height/2.0f;
rPos.x = transl[0]*w2+w2;
rPos.y = transl[1]*h2+h2;
rPos.z = transl[2];
#else
rPos.x = x;
rPos.y = y;
rPos.z = z;
#endif
}
void glWindowPos3f(GLfloat x, GLfloat y, GLfloat z) {
rPos.x = x;
rPos.y = y;
rPos.z = z;
}
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
PUSH_IF_COMPILING(glViewport);
LOAD_GLES(glViewport);
gles_glViewport(x, y, width, height);
viewport.x = x;
viewport.y = y;
viewport.width = width;
viewport.height = height;
}
void glPixelZoom(GLfloat xfactor, GLfloat yfactor) {
zoomx = xfactor;
zoomy = yfactor;
//printf("LIBGL: glPixelZoom(%f, %f)\n", xfactor, yfactor);
}
void glPixelTransferf(GLenum pname, GLfloat param) {
//printf("LIBGL: glPixelTransferf(%04x, %f)\n", pname, param);
switch(pname) {
case GL_RED_SCALE:
raster_scale[0]=param;
break;
case GL_RED_BIAS:
raster_bias[0]=param;
break;
case GL_GREEN_SCALE:
case GL_BLUE_SCALE:
case GL_ALPHA_SCALE:
raster_scale[(pname-GL_GREEN_SCALE)/2+1]=param;
break;
case GL_GREEN_BIAS:
case GL_BLUE_BIAS:
case GL_ALPHA_BIAS:
raster_bias[(pname-GL_GREEN_BIAS)/2+1]=param;
break;
/*default:
printf("LIBGL: stubbed glPixelTransferf(%04x, %f)\n", pname, param);*/
// the other...
}
}
void init_raster(int width, int height) {
int w, h;
w=npot(width);
h=npot(height);
if (raster) {
if ((raster_width!=w) || (raster_height!=h)) {
free(raster);
raster = NULL;
} else
memset(raster, 0, 4 * raster_width * raster_height * sizeof(GLubyte));
}
if (!raster) {
raster = (GLubyte *)malloc(4 * w * h * sizeof(GLubyte));
memset(raster, 0, 4 * w * h * sizeof(GLubyte));
raster_x1 = 0; raster_y1 = 0; raster_x2 = width; raster_y2 = height;
raster_width = w; raster_height = h;
}
}
GLubyte raster_transform(GLubyte pix, GLubyte number) {
GLfloat a = (GLfloat)pix*(1.0f/255.0f);
a=a*raster_scale[number]+raster_bias[number];
if (a<0.0) a=0.0;
if (a>1.0) a=1.0;
return (GLubyte)(a*255.0f);
}
GLfloat raster_transformf(GLfloat pix, GLubyte number) {
pix=pix*raster_scale[number]+raster_bias[number];
if (pix<0.0) pix=0.0;
if (pix>1.0) pix=1.0;
return pix;
}
int raster_need_transform() {
for (int i=0; i<4; i++) if (raster_scale[i]!=1.0f) return 1;
for (int i=0; i<4; i++) if (raster_bias[i]!=0.0f) return 1;
return 0;
}
GLuint raster_to_texture()
{
LOAD_GLES(glGenTextures);
LOAD_GLES(glBindTexture);
LOAD_GLES(glTexEnvf);
LOAD_GLES(glTexImage2D);
LOAD_GLES(glActiveTexture);
renderlist_t *old_list = state.list.active;
if (old_list) state.list.active = NULL; // deactivate list...
GLboolean compiling = state.list.compiling;
state.list.compiling = false;
glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT );
GLuint old_tex_unit, old_tex;
glGetIntegerv(GL_ACTIVE_TEXTURE, &old_tex_unit);
if (old_tex_unit!=GL_TEXTURE0) glActiveTexture(GL_TEXTURE0);
old_tex = 0;
if (state.texture.bound[0])
old_tex = state.texture.bound[0]->texture;
GLuint raster_texture;
glEnable(GL_TEXTURE_2D);
gles_glGenTextures(1, &raster_texture);
gles_glBindTexture(GL_TEXTURE_2D, raster_texture);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gles_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, raster_width, raster_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, raster);
gles_glBindTexture(GL_TEXTURE_2D, old_tex);
if (old_tex_unit!=GL_TEXTURE0)
glActiveTexture(old_tex_unit);
glPopAttrib();
if (old_list) state.list.active = old_list;
state.list.compiling = compiling;
return raster_texture;
}
void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove, const GLubyte *bitmap) {
/*printf("glBitmap, xy={%f, %f}, xyorig={%f, %f}, size={%u, %u}, zoom={%f, %f}, viewport={%i, %i, %i, %i}\n",
rPos.x, rPos.y, xorig, yorig, width, height, zoomx, zoomy, viewport.x, viewport.y, viewport.width, viewport.height);*/
// TODO: shouldn't be drawn if the raster pos is outside the viewport?
// TODO: negative width/height mirrors bitmap?
noerrorShim();
if ((!width && !height) || (bitmap==0)) {
if (state.list.compiling) {
if (state.list.active->raster)
state.list.active = extend_renderlist(state.list.active); // already a raster in the list, create a new one
rasterlist_t *r = state.list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
r->texture = 0;
r->xorig = 0;
r->yorig = 0;
r->zoomx = 1.0f;
r->zoomy = 1.0f;
r->xmove = xmove;
r->ymove = ymove;
} else {
rPos.x += xmove;
rPos.y += ymove;
}
return;
}
init_raster(width, height);
const GLubyte *from;
GLubyte *to;
int x, y;
int pixtrans=raster_need_transform();
// copy to pixel data
for (y = 0; y < height; y++) {
to = raster + 4 * (GLint)(y * raster_width);
from = bitmap + (y * ((width+7)/8));
for (x = 0; x < width; x++) {
// TODO: wasteful, unroll this?
GLubyte b = from[(x / 8)];
int p = (b & (1 << (7 - (x % 8)))) ? 255 : 0;
// r, g, b, a
//p = (p ? 255 : 0);
if (pixtrans) {
*to++ = raster_transform(p, 0);
*to++ = raster_transform(p, 1);
*to++ = raster_transform(p, 2);
*to++ = raster_transform(p, 3);
} else {
*to++ = p;
*to++ = p;
*to++ = p;
*to++ = p;
}
}
}
rasterlist_t rast;
rasterlist_t *r;
if (state.list.compiling) {
NewStage(state.list.active, STAGE_RASTER);
/* if (state.list.active->raster)
state.list.active = extend_renderlist(state.list.active);*/ // already a raster in the list, create a new one
r = state.list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
} else {
r = &rast;
}
r->texture = raster_to_texture();
r->xmove = xmove;
r->ymove = ymove;
r->xorig = xorig;
r->yorig = yorig;
r->width = width;
r->height = height;
r->bitmap = true;
r->zoomx = zoomx;
r->zoomy = zoomy;
LOAD_GLES(glDeleteTextures);
if (!state.list.compiling) {
render_raster_list(r);
gles_glDeleteTextures(1, &r->texture);
r->texture = 0;
}
}
void glDrawPixels(GLsizei width, GLsizei height, GLenum format,
GLenum type, const GLvoid *data) {
GLubyte *pixels, *from, *to;
GLvoid *dst = NULL;
noerrorShim();
/*printf("glDrawPixels, xy={%f, %f}, size={%i, %i}, format=%04x, type=%04x, zoom={%f, %f}, viewport={%i, %i, %i, %i}\n",
rPos.x, rPos.y, width, height, format, type, zoomx, (zoominversey)?-zoomy:zoomy, viewport.x, viewport.y, viewport.width, viewport.height);*/
// check of unsuported format...
if ((format == GL_STENCIL_INDEX) || (format == GL_DEPTH_COMPONENT)) {
errorShim(GL_INVALID_ENUM);
return;
}
init_raster(width, height);
GLsizei bmp_width = (state.texture.unpack_row_length)?state.texture.unpack_row_length:width;
if (! pixel_convert(data, &dst, bmp_width, height,
format, type, GL_RGBA, GL_UNSIGNED_BYTE, 0)) {
return;
}
pixels = (GLubyte *)dst;
GLint vx, vy;
int pixtrans=raster_need_transform();
for (int y = 0; y < height; y++) {
to = raster + 4 * (GLint)(y * raster_width);
from = pixels + 4 * (state.texture.unpack_skip_pixels + (y + state.texture.unpack_skip_rows) * bmp_width);
for (int x = 0; x < width; x++) {
if (pixtrans) {
*to++ = raster_transform(*from++, 0);
*to++ = raster_transform(*from++, 1);
*to++ = raster_transform(*from++, 2);
*to++ = raster_transform(*from++, 3);
} else {
*to++ = *from++;
*to++ = *from++;
*to++ = *from++;
*to++ = *from++;
}
}
}
if (pixels != data)
free(pixels);
rasterlist_t rast;
rasterlist_t *r;
if (state.list.compiling) {
NewStage(state.list.active, STAGE_RASTER);
/* if (state.list.active->raster)
state.list.active = extend_renderlist(state.list.active);*/ // already a raster in the list, create a new one
rasterlist_t *r = state.list.active->raster = (rasterlist_t*)malloc(sizeof(rasterlist_t));
} else {
r = &rast;
}
r->texture = raster_to_texture(width, height);
r->xmove = 0;
r->ymove = 0;
r->xorig = 0;
r->yorig = 0;
r->width = width;
r->height = height;
r->bitmap = false;
r->zoomx = zoomx;
r->zoomy = zoomy;
LOAD_GLES(glDeleteTextures);
if (!state.list.compiling) {
render_raster_list(r);
gles_glDeleteTextures(1, &r->texture);
r->texture = 0;
}
}
void render_raster_list(rasterlist_t* rast) {
//printf("render_raster_list, rast->width=%i, rast->height=%i, rPos.x=%f, rPos.y=%f, raster->texture=%u\n", rast->width, rast->height, rPos.x, rPos.y, rast->texture);
LOAD_GLES(glEnableClientState);
LOAD_GLES(glDisableClientState);
LOAD_GLES(glBindTexture);
LOAD_GLES(glVertexPointer);
LOAD_GLES(glTexCoordPointer);
LOAD_GLES(glDrawArrays);
if (rast->texture) {
glPushAttrib(GL_TEXTURE_BIT | GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT);
GLfloat old_projection[16], old_modelview[16], old_texture[16];
GLuint old_tex = state.texture.active;
if (old_tex!=0) glActiveTexture(GL_TEXTURE0);
GLuint old_cli = state.texture.client;
if (old_cli!=0) glClientActiveTexture(GL_TEXTURE0);
glMatrixMode(GL_TEXTURE);
glGetFloatv(GL_TEXTURE_MATRIX, old_texture);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glGetFloatv(GL_PROJECTION_MATRIX, old_projection);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glGetFloatv(GL_MODELVIEW_MATRIX, old_modelview);
glLoadIdentity();
float w2 = viewport.width / 2.0f;
float h2 = viewport.height / 2.0f;
float raster_x1=rPos.x-rast->xorig;
float raster_x2=rPos.x-rast->xorig + rast->width * rast->zoomx ;
float raster_y1=rPos.y-rast->yorig;
float raster_y2=rPos.y-rast->yorig + rast->height * rast->zoomy ;
GLfloat vert[] = {
(raster_x1-w2)/w2, (raster_y1-h2)/h2, 0,
(raster_x2-w2)/w2, (raster_y1-h2)/h2, 0,
(raster_x2-w2)/w2, (raster_y2-h2)/h2, 0,
(raster_x1-w2)/w2, (raster_y2-h2)/h2, 0,
};
float sw = rast->width / (GLfloat)npot(rast->width);
float sh = rast->height / (GLfloat)npot(rast->height);
GLfloat tex[] = {
0, 0,
sw, 0,
sw, sh,
0, sh
};
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT | GL_CLIENT_PIXEL_STORE_BIT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
if (rast->bitmap) {
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.0f);
} else {
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
glEnable(GL_TEXTURE_2D);
gles_glBindTexture(GL_TEXTURE_2D, rast->texture);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
gles_glEnableClientState(GL_VERTEX_ARRAY);
gles_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
gles_glDisableClientState(GL_COLOR_ARRAY);
gles_glDisableClientState(GL_NORMAL_ARRAY);
gles_glVertexPointer(3, GL_FLOAT, 0, vert);
gles_glTexCoordPointer(2, GL_FLOAT, 0, tex);
//glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
gles_glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
// All the previous states are Pushed / Poped anyway...
if (old_tex!=0) glActiveTexture(GL_TEXTURE0+old_tex);
if (old_cli!=0) glClientActiveTexture(GL_TEXTURE0+old_cli);
glPopClientAttrib();
glMatrixMode(GL_TEXTURE);
glLoadMatrixf(old_texture);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(old_modelview);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(old_projection);
glPopAttrib();
}
rPos.x += rast->xmove;
rPos.y += rast->ymove;
}

View File

@@ -0,0 +1,45 @@
#include "gl.h"
#ifndef GL_STENCIL_INDEX
#define GL_STENCIL_INDEX 0x1901
#endif
#ifndef GL_DEPTH_COMPONENT
#define GL_DEPTH_COMPONENT 0x1902
#endif
#ifndef RASTER_H
#define RASTER_H
typedef struct {
GLfloat x;
GLfloat y;
GLfloat z;
} rasterpos_t;
typedef struct {
GLint x;
GLint y;
GLsizei width;
GLsizei height;
} viewport_t;
extern GLfloat raster_scale[4];
extern GLfloat raster_bias[4];
int raster_need_transform();
extern void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
extern void glDrawPixels(GLsizei width, GLsizei height, GLenum format,
GLenum type, const GLvoid *data);
extern void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z);
extern void glWindowPos3f(GLfloat x, GLfloat y, GLfloat z);
extern void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
extern void render_raster();
extern void glPixelZoom(GLfloat xfactor, GLfloat yfactor);
extern void glPixelTransferf(GLenum pname, GLfloat param);
void render_raster_list(rasterlist_t* raster);
#endif

View File

@@ -0,0 +1,323 @@
#include "raster.h"
GLint glRenderMode(GLenum mode) {
int ret = 0;
if ((mode==GL_SELECT) || (mode==GL_RENDER)) { // missing GL_FEEDBACK
noerrorShim();
} else {
errorShim(GL_INVALID_ENUM);
return 0;
}
if (state.render_mode == GL_SELECT)
ret = state.selectbuf.count/4;
if (mode == GL_SELECT) {
if (state.selectbuf.buffer == NULL) // error, cannot use Select Mode without select buffer
errorShim(GL_INVALID_OPERATION);
return 0;
state.selectbuf.count = 0;
}
state.render_mode = mode;
return ret;
}
void glInitNames() {
if (state.namestack.names == 0) {
state.namestack.names = (GLuint*)malloc(1024*sizeof(GLuint));
}
state.namestack.top = 0;
noerrorShim();
}
void glPopName() {
noerrorShim();
if (state.render_mode != GL_SELECT)
return;
if (state.namestack.top>0)
state.namestack.top--;
else
errorShim(GL_STACK_UNDERFLOW);
}
void glPushName(GLuint name) {
noerrorShim();
if (state.render_mode != GL_SELECT)
return;
if (state.namestack.names==0)
return;
if (state.namestack.top < 1024) {
state.namestack.names[state.namestack.top++] = name;
}
}
void glLoadName(GLuint name) {
noerrorShim();
if (state.render_mode != GL_SELECT)
return;
if (state.namestack.names == 0)
return;
state.namestack.names[state.namestack.top] = name;
}
void glSelectBuffer(GLsizei size, GLuint *buffer) {
noerrorShim();
state.selectbuf.buffer = buffer;
state.selectbuf.size = size;
}
GLfloat projection[16], modelview[16];
void init_select() {
/*
Initialize matrix and array vector for a select_Draw*
*/
GLfloat tmp[16];
glGetFloatv(GL_PROJECTION_MATRIX, tmp);
matrix_column_row(tmp, projection);
glGetFloatv(GL_MODELVIEW_MATRIX, tmp);
matrix_column_row(tmp, modelview);
}
void select_transform(GLfloat *a) {
/*
Transfor a[3] using projection and modelview matrix (init with init_select)
*/
GLfloat tmp[3];
matrix_vector(modelview, a, tmp);
matrix_vector(projection, tmp, a);
}
GLboolean select_point_in_viewscreen(const GLfloat *a) {
/*
Return True is point is inside the Viewport
*/
if (a[0]<-1.0f) return false;
if (a[1]<-1.0f) return false;
if (a[0]>+1.0f) return false;
if (a[1]>+1.0f) return false;
return true;
}
GLboolean select_segment_in_viewscreen(const GLfloat *a, const GLfloat *b) {
/*
Return True is the segment is fully inside viewscreen
or cross the viewscreen
Viewscreen is (-1,-1)(+1,+1)
False if completly outside
*/
// Fast either point inside viewport
if (select_point_in_viewscreen(a)) return true;
if (select_point_in_viewscreen(b)) return true;
// Using Liang-Barsky algorithm
GLfloat vx, vy;
vx=b[0]-a[0];
vy=b[1]-a[1];
GLfloat p[4] = {-vx, vx, -vy, vy};
GLfloat q[4] = {a[0] + 1.0f, -1.0f - a[0], a[1] + 1.0f, -1.0f - a[1]};
GLfloat u1 = -1e10;
GLfloat u2 = +1e10;
for (int i=0; i<4; i++) {
if (p[i] == 0.0f) {
if (q[i]<0)
return false;
} else {
GLfloat t =q[i] / p[i];
if ((p[i]<0.0f) && (u1<t))
u1 = t;
else if ((p[i]>0.0f) && (u2>t))
u2 = t;
}
}
if ((u1 > u2) || (u1>1) || (u1<0))
return false;
return true;
}
GLboolean select_triangle_in_viewscreen(const GLfloat *a, const GLfloat *b, const GLfloat *c) {
/*
Return True is the triangle is in the viewscreen, or completly include, or include the viewscreen
*/
// fast, check either point inside the viewscreen
if (select_point_in_viewscreen(a)) return true;
if (select_point_in_viewscreen(b)) return true;
if (select_point_in_viewscreen(c)) return true;
// Now check if the viewscreen is completly inside the triangle
#define sign(p1, p2, p3) (p1[0]-p3[0])*(p2[1]-p3[1])-(p2[0]-p3[0])*(p1[1]-p3[1])
for (int i=0; i<4; i++) {
GLboolean b1,b2,b3;
GLfloat pt[2];
pt[0] = (i%2)?-1.0f:+1.0f;
pt[1] = (i>2)?-1.0f:+1.0f;
b1 = (sign(pt, a, b))<0.0f;
b2 = (sign(pt, b, c))<0.0f;
b3 = (sign(pt, c, a))<0.0f;
if ((b1==b2) && (b2==b3)) {
return true;
}
}
#undef sign
// Check if any segment intersect the viewscreen
if (select_segment_in_viewscreen(a, b)) return true;
if (select_segment_in_viewscreen(b, c)) return true;
if (select_segment_in_viewscreen(c, a)) return true;
return false;
}
void select_glDrawArrays(GLenum mode, GLuint first, GLuint count) {
if (count == 0) return;
if (state.pointers.vertex.pointer == NULL) return;
if (state.selectbuf.buffer == NULL) return;
GLfloat *vert = copy_gl_array(state.pointers.vertex.pointer, state.pointers.vertex.type,
state.pointers.vertex.size, state.pointers.vertex.stride,
GL_FLOAT, 3, 0, count);
GLfloat tmp[3];
GLfloat zmin=1.0f, zmax=0.0f;
init_select();
#define FOUND() { \
free(vert); \
for (int j=i+1; j<count; j++) { \
select_transform(vert+j*3); \
if (vert[j*3+2]<zmin) zmin=vert[j*3+2]; \
if (vert[j*3+2]>zmax) zmax=vert[j*3+2]; \
} \
if (zmin<0.0f) zmin = 0.0f; \
if (zmax>1.0f) zmax = 1.0f; \
if (state.selectbuf.count+4<state.selectbuf.size) { \
state.selectbuf.buffer[state.selectbuf.count++] = state.selectbuf.count/4; \
state.selectbuf.buffer[state.selectbuf.count++] = zmin*(1<<31); \
state.selectbuf.buffer[state.selectbuf.count++] = zmax*(1<<31); \
state.selectbuf.buffer[state.selectbuf.count++] = state.namestack.names[state.namestack.top];\
} \
return; }
for (int i=first; i<count; i++) {
select_transform(vert+i*3);
if (vert[i*3+2]<zmin) zmin=vert[i*3+2];
if (vert[i*3+2]>zmax) zmax=vert[i*3+2];
//matrix_vector(projection, vert+i*3, tmp);
//matrix_vector(modelview, tmp, vert+i*3);
switch (mode) {
case GL_POINTS:
if (select_point_in_viewscreen(vert+i*3))
FOUND();
break;
case GL_LINES:
if (i%2==1) {
if (select_segment_in_viewscreen(vert+(i-1)*3, vert+i*3))
FOUND();
}
break;
case GL_LINE_STRIP:
case GL_LINE_LOOP: //FIXME: the last "loop" segment is missing here
if (i>0) {
if (select_segment_in_viewscreen(vert+(i-1)*3, vert+i*3))
FOUND();
}
break;
case GL_TRIANGLES:
if (i%3==2) {
if (select_triangle_in_viewscreen(vert+(i-2)*3, vert+(i-1)*3, vert+i*3))
FOUND();
}
break;
case GL_TRIANGLE_STRIP:
if (i>1) {
if (select_triangle_in_viewscreen(vert+(i-2)*3, vert+(i-1)*3, vert+i*3))
FOUND();
}
break;
case GL_TRIANGLE_FAN:
if (i>1) {
if (select_triangle_in_viewscreen(vert, vert+(i-1)*3, vert+i*3))
FOUND();
}
break;
default:
return; // Should never go there!
}
}
free(vert);
#undef FOUND
}
void select_glDrawElements(GLenum mode, GLuint count, GLenum type, GLvoid * indices) {
if (count == 0) return;
if (state.pointers.vertex.pointer == NULL) return;
GLushort *ind = (GLushort*)indices;
GLsizei min, max;
normalize_indices(indices, &max, &min, count);
GLfloat *vert = copy_gl_array(state.pointers.vertex.pointer, state.pointers.vertex.type,
state.pointers.vertex.size, state.pointers.vertex.stride,
GL_FLOAT, 3, 0, max);
GLfloat tmp[3];
init_select();
GLfloat zmin=1.0f, zmax=0.0f;
for (int i=min; i<max; i++) {
select_transform(vert+i*3);
if (vert[i*3+2]<zmin) zmin=vert[i*3+2];
if (vert[i*3+2]>zmax) zmax=vert[i*3+2];
}
#define FOUND() { \
free(vert); \
if (zmin<0.0f) zmin = 0.0f; \
if (zmax>1.0f) zmax = 1.0f; \
if (state.selectbuf.count+4<state.selectbuf.size) { \
state.selectbuf.buffer[state.selectbuf.count++] = state.selectbuf.count/4; \
state.selectbuf.buffer[state.selectbuf.count++] = zmin*(1<<31); \
state.selectbuf.buffer[state.selectbuf.count++] = zmax*(1<<31); \
state.selectbuf.buffer[state.selectbuf.count++] = state.namestack.names[state.namestack.top];\
} \
return; }
for (int i=0; i<count; i++) {
switch (mode) {
case GL_POINTS:
if (select_point_in_viewscreen(vert+ind[i]*3))
FOUND();
break;
case GL_LINES:
if (i%2==1) {
if (select_segment_in_viewscreen(vert+ind[(i-1)]*3, vert+ind[i]*3))
FOUND();
}
break;
case GL_LINE_STRIP:
case GL_LINE_LOOP: //FIXME: the last "loop" segment is missing here
if (i>0) {
if (select_segment_in_viewscreen(vert+ind[(i-1)]*3, vert+ind[i]*3))
FOUND();
}
break;
case GL_TRIANGLES:
if (i%3==2) {
if (select_triangle_in_viewscreen(vert+ind[(i-2)]*3, vert+ind[(i-1)]*3, vert+ind[i]*3))
FOUND();
}
break;
case GL_TRIANGLE_STRIP:
if (i>1) {
if (select_triangle_in_viewscreen(vert+ind[(i-2)]*3, vert+ind[(i-1)]*3, vert+ind[i]*3))
FOUND();
}
break;
case GL_TRIANGLE_FAN:
if (i>1) {
if (select_triangle_in_viewscreen(vert+ind[0]*3, vert+ind[(i-1)]*3, vert+ind[i]*3))
FOUND();
}
break;
default:
return; // Should never go there!
}
}
free(vert);
#undef FOUND
}

View File

@@ -0,0 +1,14 @@
#ifndef RENDER_H
#define RENDER_H
#include "gl.h"
GLint glRenderMode(GLenum mode);
void glInitNames();
void glPopName();
void glPushName(GLuint name);
void glLoadName(GLuint name);
void glSelectBuffer(GLsizei size, GLuint *buffer);
void select_glDrawElements(GLenum mode, GLuint count, GLenum type, GLvoid * indices);
void select_glDrawArrays(GLenum mode, GLuint first, GLuint count);
#endif

555
project/jni/glshim/src/gl/stack.c Executable file
View File

@@ -0,0 +1,555 @@
#include "stack.h"
glstack_t *stack = NULL;
glclientstack_t *clientStack = NULL;
void glPushAttrib(GLbitfield mask) {
//printf("glPushAttrib(0x%04X)\n", mask);
noerrorShim();
if (state.list.compiling && state.list.active) {
NewStage(state.list.active, STAGE_PUSH);
state.list.active->pushattribute = mask;
return;
}
if (stack == NULL) {
stack = (glstack_t *)malloc(STACK_SIZE * sizeof(glstack_t));
stack->len = 0;
stack->cap = STACK_SIZE;
} else if (stack->len == stack->cap) {
stack->cap += STACK_SIZE;
stack = (glstack_t *)realloc(stack, stack->cap * sizeof(glstack_t));
}
glstack_t *cur = stack + stack->len;
cur->mask = mask;
cur->clip_planes_enabled = NULL;
cur->clip_planes = NULL;
cur->lights_enabled = NULL;
cur->lights = NULL;
// TODO: GL_ACCUM_BUFFER_BIT
// TODO: will tracking these myself be much faster than glGet?
if (mask & GL_COLOR_BUFFER_BIT) {
cur->alpha_test = glIsEnabled(GL_ALPHA_TEST);
glGetIntegerv(GL_ALPHA_TEST_FUNC, &cur->alpha_test_func);
glGetFloatv(GL_ALPHA_TEST_REF, &cur->alpha_test_ref);
cur->blend = glIsEnabled(GL_BLEND);
glGetIntegerv(GL_BLEND_SRC, &cur->blend_src_func);
glGetIntegerv(GL_BLEND_DST, &cur->blend_dst_func);
cur->dither = glIsEnabled(GL_DITHER);
cur->color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
glGetIntegerv(GL_LOGIC_OP_MODE, &cur->logic_op);
glGetFloatv(GL_COLOR_CLEAR_VALUE, cur->clear_color);
glGetFloatv(GL_COLOR_WRITEMASK, cur->color_mask);
}
if (mask & GL_CURRENT_BIT) {
glGetFloatv(GL_CURRENT_COLOR, cur->color);
glGetFloatv(GL_CURRENT_NORMAL, cur->normal);
glGetFloatv(GL_CURRENT_TEXTURE_COORDS, cur->tex);
}
if (mask & GL_DEPTH_BUFFER_BIT) {
cur->depth_test = glIsEnabled(GL_DEPTH_TEST);
glGetIntegerv(GL_DEPTH_FUNC, &cur->depth_func);
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &cur->clear_depth);
glGetIntegerv(GL_DEPTH_WRITEMASK, &cur->depth_mask);
}
if (mask & GL_ENABLE_BIT) {
int i;
GLint max_clip_planes;
glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
cur->clip_planes_enabled = (GLboolean *)malloc(max_clip_planes * sizeof(GLboolean));
for (i = 0; i < max_clip_planes; i++) {
*(cur->clip_planes_enabled + i) = glIsEnabled(GL_CLIP_PLANE0 + i);
}
GLint max_lights;
glGetIntegerv(GL_MAX_LIGHTS, &max_lights);
cur->lights_enabled = (GLboolean *)malloc(max_lights * sizeof(GLboolean));
for (i = 0; i < max_lights; i++) {
*(cur->lights_enabled + i) = glIsEnabled(GL_LIGHT0 + i);
}
cur->alpha_test = glIsEnabled(GL_ALPHA_TEST);
cur->blend = glIsEnabled(GL_BLEND);
cur->cull_face = glIsEnabled(GL_CULL_FACE);
cur->depth_test = glIsEnabled(GL_DEPTH_TEST);
cur->dither = glIsEnabled(GL_DITHER);
cur->fog = glIsEnabled(GL_FOG);
cur->lighting = glIsEnabled(GL_LIGHTING);
cur->line_smooth = glIsEnabled(GL_LINE_SMOOTH);
cur->line_stipple = glIsEnabled(GL_LINE_STIPPLE);
cur->color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP);
cur->multisample = glIsEnabled(GL_MULTISAMPLE);
cur->normalize = glIsEnabled(GL_NORMALIZE);
cur->point_smooth = glIsEnabled(GL_POINT_SMOOTH);
cur->polygon_offset_fill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
cur->sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE);
cur->sample_alpha_to_one = glIsEnabled(GL_SAMPLE_ALPHA_TO_ONE);
cur->sample_coverage = glIsEnabled(GL_SAMPLE_COVERAGE);
cur->scissor_test = glIsEnabled(GL_SCISSOR_TEST);
cur->stencil_test = glIsEnabled(GL_STENCIL_TEST);
cur->colormaterial = glIsEnabled(GL_COLOR_MATERIAL);
int a;
int old_tex=state.texture.active;
for (a=0; a<MAX_TEX; a++) {
/*glActiveTexture(GL_TEXTURE0+a);*/
cur->texture_2d[a] = state.enable.texture_2d[a];/*glIsEnabled(GL_TEXTURE_2D);*/
}
/*glActiveTexture(GL_TEXTURE0+old_tex);*/
}
// TODO: GL_EVAL_BIT
if (mask & GL_FOG_BIT) {
cur->fog = glIsEnabled(GL_FOG);
glGetFloatv(GL_FOG_COLOR, cur->fog_color);
glGetFloatv(GL_FOG_DENSITY, &cur->fog_density);
glGetFloatv(GL_FOG_START, &cur->fog_start);
glGetFloatv(GL_FOG_END, &cur->fog_end);
glGetIntegerv(GL_FOG_MODE, &cur->fog_mode);
}
if (mask & GL_HINT_BIT) {
glGetIntegerv(GL_PERSPECTIVE_CORRECTION_HINT, &cur->perspective_hint);
glGetIntegerv(GL_POINT_SMOOTH_HINT, &cur->point_smooth_hint);
glGetIntegerv(GL_LINE_SMOOTH_HINT, &cur->line_smooth_hint);
glGetIntegerv(GL_FOG_HINT, &cur->fog_hint);
glGetIntegerv(GL_GENERATE_MIPMAP_HINT, &cur->mipmap_hint);
}
if (mask & GL_LIGHTING_BIT) {
cur->lighting = glIsEnabled(GL_LIGHTING);
glGetIntegerv(GL_LIGHT_MODEL_AMBIENT, cur->light_model_ambient);
glGetIntegerv(GL_LIGHT_MODEL_TWO_SIDE, &cur->light_model_two_side);
int i;
GLint max_lights;
glGetIntegerv(GL_MAX_LIGHTS, &max_lights);
cur->lights_enabled = (GLboolean *)malloc(max_lights * sizeof(GLboolean));
cur->lights = (GLfloat *)malloc(max_lights * sizeof(GLfloat));
for (i = 0; i < max_lights; i++) {
*(cur->lights_enabled + i) = glIsEnabled(GL_LIGHT0 + i);
/* TODO: record all data about the lights
glGetFloatv(GL_LIGHT0 + i, cur->lights + i);
*/
}
glGetIntegerv(GL_SHADE_MODEL, &cur->shade_model);
}
if (mask & GL_LINE_BIT) {
cur->line_smooth = glIsEnabled(GL_LINE_SMOOTH);
// TODO: stipple stuff here
glGetFloatv(GL_LINE_WIDTH, &cur->line_width);
}
// GL_LIST_BIT
if (mask & GL_LIST_BIT) {
cur->list_base = state.list.base;
}
if (mask & GL_MULTISAMPLE_BIT) {
cur->multisample = glIsEnabled(GL_MULTISAMPLE);
cur->sample_alpha_to_coverage = glIsEnabled(GL_SAMPLE_ALPHA_TO_COVERAGE);
cur->sample_alpha_to_one = glIsEnabled(GL_SAMPLE_ALPHA_TO_ONE);
cur->sample_coverage = glIsEnabled(GL_SAMPLE_COVERAGE);
}
// GL_PIXEL_MODE_BIT
if (mask & GL_PIXEL_MODE_BIT) {
GLenum pixel_name[] = {GL_RED_BIAS, GL_RED_SCALE, GL_GREEN_BIAS, GL_GREEN_SCALE, GL_BLUE_BIAS, GL_BLUE_SCALE, GL_ALPHA_BIAS, GL_ALPHA_SCALE};
int i;
for (i=0; i<8; i++)
glGetFloatv(pixel_name[i], &cur->pixel_scale_bias[i]);
glGetFloatv(GL_ZOOM_X, &cur->pixel_zoomx);
glGetFloatv(GL_ZOOM_Y, &cur->pixel_zoomy);
}
if (mask & GL_POINT_BIT) {
cur->point_smooth = glIsEnabled(GL_POINT_SMOOTH);
glGetFloatv(GL_POINT_SIZE, &cur->point_size);
}
// TODO: GL_POLYGON_BIT
// TODO: GL_POLYGON_STIPPLE_BIT
if (mask & GL_SCISSOR_BIT) {
cur->scissor_test = glIsEnabled(GL_SCISSOR_TEST);
glGetFloatv(GL_SCISSOR_BOX, cur->scissor_box);
}
// TODO: GL_STENCIL_BUFFER_BIT
// GL_TEXTURE_BIT - TODO: incomplete
if (mask & GL_TEXTURE_BIT) {
cur->active=state.texture.active;
int a;
for (a=0; a<MAX_TEX; a++) {
//glActiveTexture(GL_TEXTURE0+a);
//glGetIntegerv(GL_TEXTURE_BINDING_2D, &cur->texture[a]);
cur->texture[a] = (state.texture.bound[a])?state.texture.bound[a]->texture:0;
}
//glActiveTexture(GL_TEXTURE0+cur->active);
}
// GL_TRANSFORM_BIT
if (mask & GL_TRANSFORM_BIT) {
if (!(mask & GL_ENABLE_BIT)) {
int i;
GLint max_clip_planes;
glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
cur->clip_planes_enabled = (GLboolean *)malloc(max_clip_planes * sizeof(GLboolean));
for (i = 0; i < max_clip_planes; i++) {
*(cur->clip_planes_enabled + i) = glIsEnabled(GL_CLIP_PLANE0 + i);
}
}
glGetIntegerv(GL_MATRIX_MODE, &cur->matrix_mode);
cur->rescale_normal_flag = glIsEnabled(GL_RESCALE_NORMAL);
cur->normalize_flag = glIsEnabled(GL_NORMALIZE);
}
// GL_VIEWPORT_BIT
if (mask & GL_VIEWPORT_BIT) {
glGetIntegerv(GL_VIEWPORT, cur->viewport_size);
glGetFloatv(GL_DEPTH_RANGE, cur->depth_range);
}
stack->len++;
}
void glPushClientAttrib(GLbitfield mask) {
noerrorShim();
if (clientStack == NULL) {
clientStack = (glclientstack_t *)malloc(STACK_SIZE * sizeof(glclientstack_t));
clientStack->len = 0;
clientStack->cap = STACK_SIZE;
} else if (clientStack->len == clientStack->cap) {
clientStack->cap += STACK_SIZE;
clientStack = (glclientstack_t *)realloc(clientStack, clientStack->cap * sizeof(glclientstack_t));
}
glclientstack_t *cur = clientStack + clientStack->len;
cur->mask = mask;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
glGetIntegerv(GL_PACK_ALIGNMENT, &cur->pack_align);
glGetIntegerv(GL_UNPACK_ALIGNMENT, &cur->unpack_align);
cur->unpack_row_length = state.texture.unpack_row_length;
cur->unpack_skip_pixels = state.texture.unpack_skip_pixels;
cur->unpack_skip_rows = state.texture.unpack_skip_rows;
cur->pack_row_length = state.texture.pack_row_length;
cur->pack_skip_pixels = state.texture.pack_skip_pixels;
cur->pack_skip_rows = state.texture.pack_skip_rows;
}
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
cur->vert_enable = state.enable.vertex_array;
cur->color_enable = state.enable.color_array;
cur->secondary_enable = state.enable.secondary_array;
cur->normal_enable = state.enable.normal_array;
int a;
for (a=0; a<MAX_TEX; a++) {
cur->tex_enable[a] = state.enable.tex_coord_array[a];
}
memcpy(&cur->verts, &state.pointers.vertex, sizeof(pointer_state_t));
cur->ref_verts = (void*)state.pointers.vertex.pointer;
memcpy(&cur->color, &state.pointers.color, sizeof(pointer_state_t));
cur->ref_colors = (void*)state.pointers.color.pointer;
memcpy(&cur->secondary, &state.pointers.secondary, sizeof(pointer_state_t));
cur->ref_secondary = (void*)state.pointers.secondary.pointer;
memcpy(&cur->normal, &state.pointers.normal, sizeof(pointer_state_t));
cur->ref_normal = (void*)state.pointers.normal.pointer;
for (a=0; a<MAX_TEX; a++) {
memcpy(&cur->tex[a], &state.pointers.tex_coord[a], sizeof(pointer_state_t));
cur->ref_tex[a] = (void*)state.pointers.tex_coord[a].pointer;
}
cur->client = state.texture.client;
}
clientStack->len++;
}
#define maybe_free(x) \
if (x) free(x)
#define enable_disable(pname, enabled) \
if (enabled) glEnable(pname); \
else glDisable(pname)
#define v2(c) c[0], c[1]
#define v3(c) v2(c), c[2]
#define v4(c) v3(c), c[3]
void glPopAttrib() {
//printf("glPopAttrib()\n");
noerrorShim();
if (state.list.compiling && state.list.active) {
NewStage(state.list.active, STAGE_POP);
state.list.active->popattribute = true;
return;
}
if (stack == NULL || stack->len == 0) {
errorShim(GL_STACK_UNDERFLOW);
return;
}
glstack_t *cur = stack + stack->len-1;
if (cur->mask & GL_COLOR_BUFFER_BIT) {
#ifndef USE_ES2
enable_disable(GL_ALPHA_TEST, cur->alpha_test);
glAlphaFunc(cur->alpha_test_func, cur->alpha_test_ref);
#endif
enable_disable(GL_BLEND, cur->blend);
glBlendFunc(cur->blend_src_func, cur->blend_dst_func);
enable_disable(GL_DITHER, cur->dither);
#ifndef USE_ES2
enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op);
glLogicOp(cur->logic_op);
#endif
GLfloat *c;
glClearColor(v4(cur->clear_color));
glColorMask(v4(cur->color_mask));
}
if (cur->mask & GL_CURRENT_BIT) {
glColor4f(v4(cur->color));
#ifndef USE_ES2
glNormal3f(v3(cur->normal));
#endif
glTexCoord2f(v2(cur->tex));
}
if (cur->mask & GL_DEPTH_BUFFER_BIT) {
enable_disable(GL_DEPTH_TEST, cur->depth_test);
glDepthFunc(cur->depth_func);
glClearDepth(cur->clear_depth);
glDepthMask(cur->depth_mask);
}
if (cur->mask & GL_ENABLE_BIT) {
int i;
GLint max_clip_planes;
glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
for (i = 0; i < max_clip_planes; i++) {
enable_disable(GL_CLIP_PLANE0 + i, *(cur->clip_planes_enabled + i));
}
GLint max_lights;
glGetIntegerv(GL_MAX_LIGHTS, &max_lights);
for (i = 0; i < max_lights; i++) {
enable_disable(GL_LIGHT0 + i, *(cur->lights_enabled + i));
}
enable_disable(GL_ALPHA_TEST, cur->alpha_test);
enable_disable(GL_BLEND, cur->blend);
enable_disable(GL_CULL_FACE, cur->cull_face);
enable_disable(GL_DEPTH_TEST, cur->depth_test);
enable_disable(GL_DITHER, cur->dither);
enable_disable(GL_FOG, cur->fog);
enable_disable(GL_LIGHTING, cur->lighting);
enable_disable(GL_LINE_SMOOTH, cur->line_smooth);
enable_disable(GL_LINE_STIPPLE, cur->line_stipple);
enable_disable(GL_COLOR_LOGIC_OP, cur->color_logic_op);
enable_disable(GL_MULTISAMPLE, cur->multisample);
enable_disable(GL_NORMALIZE, cur->normalize);
enable_disable(GL_POINT_SMOOTH, cur->point_smooth);
enable_disable(GL_POLYGON_OFFSET_FILL, cur->polygon_offset_fill);
enable_disable(GL_SAMPLE_ALPHA_TO_COVERAGE, cur->sample_alpha_to_coverage);
enable_disable(GL_SAMPLE_ALPHA_TO_ONE, cur->sample_alpha_to_one);
enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage);
enable_disable(GL_SCISSOR_TEST, cur->scissor_test);
enable_disable(GL_STENCIL_TEST, cur->stencil_test);
enable_disable(GL_COLOR_MATERIAL, cur->colormaterial);
int a;
int old_tex = state.texture.active;
for (a=0; a<MAX_TEX; a++) {
if (state.enable.texture_2d[a] != cur->texture_2d[a]) {
glActiveTexture(GL_TEXTURE0+a);
enable_disable(GL_TEXTURE_2D, cur->texture_2d[a]);
}
}
if (state.texture.active != old_tex) glActiveTexture(GL_TEXTURE0+old_tex);
}
#ifndef USE_ES2
if (cur->mask & GL_FOG_BIT) {
enable_disable(GL_FOG, cur->fog);
glFogfv(GL_FOG_COLOR, cur->fog_color);
glFogf(GL_FOG_DENSITY, cur->fog_density);
glFogf(GL_FOG_START, cur->fog_start);
glFogf(GL_FOG_END, cur->fog_end);
glFogf(GL_FOG_MODE, cur->fog_mode);
}
#endif
if (cur->mask & GL_HINT_BIT) {
enable_disable(GL_PERSPECTIVE_CORRECTION_HINT, cur->perspective_hint);
enable_disable(GL_POINT_SMOOTH_HINT, cur->point_smooth_hint);
enable_disable(GL_LINE_SMOOTH_HINT, cur->line_smooth_hint);
enable_disable(GL_FOG_HINT, cur->fog_hint);
enable_disable(GL_GENERATE_MIPMAP_HINT, cur->mipmap_hint);
}
// GL_LIST_BIT
if (cur->mask & GL_LIST_BIT) {
glListBase(cur->list_base);
}
if (cur->mask & GL_LINE_BIT) {
enable_disable(GL_LINE_SMOOTH, cur->line_smooth);
// TODO: stipple stuff here
glLineWidth(cur->line_width);
}
if (cur->mask & GL_MULTISAMPLE_BIT) {
enable_disable(GL_MULTISAMPLE, cur->multisample);
enable_disable(GL_SAMPLE_ALPHA_TO_COVERAGE, cur->sample_alpha_to_coverage);
enable_disable(GL_SAMPLE_ALPHA_TO_ONE, cur->sample_alpha_to_one);
enable_disable(GL_SAMPLE_COVERAGE, cur->sample_coverage);
}
#ifndef USE_ES2
if (cur->mask & GL_POINT_BIT) {
enable_disable(GL_POINT_SMOOTH, cur->point_smooth);
glPointSize(cur->point_size);
}
#endif
if (cur->mask & GL_SCISSOR_BIT) {
enable_disable(GL_SCISSOR_TEST, cur->scissor_test);
glScissor(v4(cur->scissor_box));
}
if (cur->mask & GL_TEXTURE_BIT) {
int a;
for (a=0; a<MAX_TEX; a++) {
if ((cur->texture[a]==0 && state.texture.bound[a] != 0) || (cur->texture[a]!=0 && state.texture.bound[a]==0)) {
glActiveTexture(GL_TEXTURE0+a);
glBindTexture(GL_TEXTURE_2D, cur->texture[a]);
}
}
if (state.texture.active!= cur->active) glActiveTexture(GL_TEXTURE0+cur->active);
}
if (cur->mask & GL_PIXEL_MODE_BIT) {
GLenum pixel_name[] = {GL_RED_BIAS, GL_RED_SCALE, GL_GREEN_BIAS, GL_GREEN_SCALE, GL_BLUE_BIAS, GL_BLUE_SCALE, GL_ALPHA_BIAS, GL_ALPHA_SCALE};
int i;
for (i=0; i<8; i++)
glPixelTransferf(pixel_name[i], cur->pixel_scale_bias[i]);
glPixelZoom(cur->pixel_zoomx, cur->pixel_zoomy);
}
if (cur->mask & GL_TRANSFORM_BIT) {
if (!(cur->mask & GL_ENABLE_BIT)) {
int i;
GLint max_clip_planes;
glGetIntegerv(GL_MAX_CLIP_PLANES, &max_clip_planes);
for (i = 0; i < max_clip_planes; i++) {
enable_disable(GL_CLIP_PLANE0 + i, *(cur->clip_planes_enabled + i));
}
}
glMatrixMode(cur->matrix_mode);
enable_disable(GL_NORMALIZE, cur->normalize_flag);
enable_disable(GL_RESCALE_NORMAL, cur->rescale_normal_flag);
}
if (cur->mask & GL_VIEWPORT_BIT) {
glViewport(cur->viewport_size[0], cur->viewport_size[1], cur->viewport_size[2], cur->viewport_size[3]);
glDepthRangef(cur->depth_range[0], cur->depth_range[1]);
}
maybe_free(cur->clip_planes_enabled);
maybe_free(cur->clip_planes);
maybe_free(cur->lights_enabled);
maybe_free(cur->lights);
stack->len--;
}
#undef enable_disable
#define enable_disable(pname, enabled) \
if (enabled) glEnableClientState(pname); \
else glDisableClientState(pname)
void glPopClientAttrib() {
noerrorShim();
//LOAD_GLES(glVertexPointer);
//LOAD_GLES(glColorPointer);
//LOAD_GLES(glNormalPointer);
//LOAD_GLES(glTexCoordPointer);
if (clientStack == NULL || clientStack->len == 0) {
errorShim(GL_STACK_UNDERFLOW);
return;
}
glclientstack_t *cur = clientStack + clientStack->len-1;
if (cur->mask & GL_CLIENT_PIXEL_STORE_BIT) {
glPixelStorei(GL_PACK_ALIGNMENT, cur->pack_align);
glPixelStorei(GL_UNPACK_ALIGNMENT, cur->unpack_align);
glPixelStorei(GL_UNPACK_ROW_LENGTH, cur->unpack_row_length);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, cur->unpack_skip_pixels);
glPixelStorei(GL_UNPACK_SKIP_ROWS, cur->unpack_skip_rows);
glPixelStorei(GL_PACK_ROW_LENGTH, cur->pack_row_length);
glPixelStorei(GL_PACK_SKIP_PIXELS, cur->pack_skip_pixels);
glPixelStorei(GL_PACK_SKIP_ROWS, cur->pack_skip_rows);
}
if (cur->mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
if (state.enable.vertex_array != cur->vert_enable)
enable_disable(GL_VERTEX_ARRAY, cur->vert_enable);
if (state.enable.normal_array != cur->normal_enable)
enable_disable(GL_NORMAL_ARRAY, cur->normal_enable);
if (state.enable.color_array != cur->color_enable)
enable_disable(GL_COLOR_ARRAY, cur->color_enable);
if (state.enable.secondary_array != cur->secondary_enable)
enable_disable(GL_SECONDARY_COLOR_ARRAY, cur->secondary_enable);
for (int a=0; a<MAX_TEX; a++) {
if (state.enable.tex_coord_array[a] != cur->tex_enable[a]) {
glClientActiveTexture(GL_TEXTURE0+a);
enable_disable(GL_TEXTURE_COORD_ARRAY, cur->tex_enable[a]);
}
}
if (state.pointers.vertex.pointer != cur->ref_verts) {
memcpy(&state.pointers.vertex, &cur->verts, sizeof(pointer_state_t));
//if (state.pointers.vertex.pointer) gles_glVertexPointer(state.pointers.vertex.size, state.pointers.vertex.type, state.pointers.vertex.stride, state.pointers.vertex.pointer);
}
if (state.pointers.color.pointer != cur->ref_colors) {
memcpy(&state.pointers.color, &cur->color, sizeof(pointer_state_t));
//if (state.pointers.color.pointer) gles_glColorPointer(state.pointers.color.size, state.pointers.color.type, state.pointers.color.stride, state.pointers.color.pointer);
}
if (state.pointers.secondary.pointer != cur->ref_secondary) {
memcpy(&state.pointers.secondary, &cur->secondary, sizeof(pointer_state_t));
}
if (state.pointers.normal.pointer != cur->ref_normal) {
memcpy(&state.pointers.normal, &cur->normal, sizeof(pointer_state_t));
//if (state.pointers.normal.pointer) gles_glNormalPointer(state.pointers.normal.type, state.pointers.normal.stride, state.pointers.normal.pointer);
}
for (int a=0; a<MAX_TEX; a++) {
if (state.pointers.tex_coord[a].pointer != cur->ref_tex[a]) {
memcpy(&state.pointers.tex_coord[a], &cur->tex[a], sizeof(pointer_state_t));
//if (state.pointers.tex_coord[a].pointer) {
// glClientActiveTexture(GL_TEXTURE0+a);
// gles_glTexCoordPointer(state.pointers.tex_coord[a].size, state.pointers.tex_coord[a].type, state.pointers.tex_coord[a].stride, state.pointers.tex_coord[a].pointer);
//}
}
}
if (state.texture.client != cur->client) glClientActiveTexture(GL_TEXTURE0+cur->client);
}
clientStack->len--;
}
#undef maybe_free
#undef enable_disable
#undef v2
#undef v3
#undef v4

169
project/jni/glshim/src/gl/stack.h Executable file
View File

@@ -0,0 +1,169 @@
#include "gl.h"
#include "state.h"
#ifndef GL_STACK_H
#define GL_STACK_H
#define STACK_SIZE 16
typedef struct {
GLbitfield mask;
// GL_COLOR_BUFFER_BIT
GLboolean alpha_test;
GLint alpha_test_func;
GLclampf alpha_test_ref;
GLboolean blend;
GLint blend_src_func;
GLint blend_dst_func;
GLboolean dither;
GLboolean color_logic_op;
GLint logic_op;
GLfloat clear_color[4];
GLfloat color_mask[4];
// GL_CURRENT_BIT
GLfloat color[4];
GLfloat normal[4];
GLfloat tex[4];
GLfloat secondary[4];
// TODO: can only fill this via raster.c
GLfloat raster_pos[3];
GLboolean raster_valid;
GLfloat pixel_scale_bias[4+4];
GLfloat pixel_zoomx;
GLfloat pixel_zoomy;
// GL_DEPTH_BUFFER_BIT
GLboolean depth_test;
GLint depth_func;
GLfloat clear_depth;
GLint depth_mask;
// GL_ENABLE_BIT
GLboolean cull_face;
GLboolean normalize;
GLboolean polygon_offset_fill;
GLboolean stencil_test;
GLboolean texture_2d[MAX_TEX];
GLboolean colormaterial;
// GL_FOG_BIT
GLboolean fog;
GLfloat fog_color[4];
GLfloat fog_density;
GLfloat fog_start;
GLfloat fog_end;
GLint fog_mode;
// GL_HINT_BIT
GLint perspective_hint;
GLint point_smooth_hint;
GLint line_smooth_hint;
GLint fog_hint;
GLint mipmap_hint;
// GL_LIGHTING_BIT
GLboolean lighting;
GLboolean *lights_enabled;
GLfloat *lights;
GLint light_model_ambient[4];
GLint light_model_two_side;
GLint shade_model;
// GL_LINE_BIT
GLboolean line_smooth;
GLboolean line_stipple; // TODO: needs to be hooked locally?
GLfloat line_width;
// GL_LIST_BIT
GLint list_base;
// GL_MULTISAMPLE_BIT
GLboolean multisample;
GLboolean sample_alpha_to_coverage;
GLboolean sample_alpha_to_one;
GLboolean sample_coverage;
// GL_POINT_BIT
GLboolean point_smooth;
GLfloat point_size;
// TODO: GL_POLYGON_BIT
// TODO: GL_POLYGON_STIPPLE_BIT
// GL_SCISSOR_BIT
GLboolean scissor_test;
GLfloat scissor_box[4];
// TODO: GL_STENCIL_BUFFER_BIT
// GL_TEXTURE_BIT
GLint texture[MAX_TEX];
GLint active;
// GL_TRANSFORM_BIT
// with Clip Planes...
GLenum matrix_mode;
GLboolean normalize_flag;
GLboolean rescale_normal_flag;
// GL_VIEWPORT_BIT
GLint viewport_size[4];
GLfloat depth_range[2];
// dynamically-sized shenanigans
GLboolean *clip_planes_enabled;
GLfloat *clip_planes;
// misc
unsigned int len;
unsigned int cap;
} glstack_t;
typedef struct {
GLbitfield mask;
// GL_CLIENT_PIXEL_STORE_BIT
GLint pack_align;
GLint unpack_align;
GLuint unpack_row_length;
GLuint unpack_skip_pixels;
GLuint unpack_skip_rows;
GLuint pack_row_length;
GLuint pack_skip_pixels;
GLuint pack_skip_rows;
// GL_CLIENT_VERTEX_ARRAY_BIT
GLuint client;
GLboolean vert_enable;
GLboolean color_enable;
GLboolean tex_enable[MAX_TEX];
GLboolean normal_enable;
GLboolean secondary_enable;
pointer_state_t verts;
pointer_state_t color;
pointer_state_t normal;
pointer_state_t tex[MAX_TEX];
pointer_state_t secondary;
// lets track old pointer address to avoid useless copy back
GLvoid *ref_verts,
*ref_colors,
*ref_secondary,
*ref_normal,
*ref_tex[MAX_TEX];
unsigned int len;
unsigned int cap;
} glclientstack_t;
void glPushClientAttrib(GLbitfield mask);
void glPopClientAttrib();
void glPushAttrib(GLbitfield mask);
void glPopAttrib();
#endif

142
project/jni/glshim/src/gl/state.h Executable file
View File

@@ -0,0 +1,142 @@
#include "gl.h"
#ifndef GL_STATE_H
#define GL_STATE_H
#include "eval.h"
#include "texture.h"
#include "buffers.h"
typedef struct {
GLboolean line_stipple,
blend,
color_sum,
secondary_array,
color_array,
normal_array,
vertex_array,
tex_coord_array[MAX_TEX],
texgen_s[MAX_TEX],
texgen_t[MAX_TEX],
texgen_r[MAX_TEX],
texture_2d[MAX_TEX];
} enable_state_t;
typedef struct {
GLenum S;
GLenum T;
GLenum R;
GLfloat Sv[4];
GLfloat Tv[4];
GLfloat Rv[4];
} texgen_state_t;
typedef struct {
GLuint unpack_row_length,
unpack_skip_pixels,
unpack_skip_rows;
GLboolean unpack_lsb_first;
// TODO: use those values
GLuint pack_row_length,
pack_skip_pixels,
pack_skip_rows;
GLboolean pack_lsb_first;
// TODO: do we only need to worry about GL_TEXTURE_2D?
GLboolean rect_arb[MAX_TEX];
gltexture_t *bound[MAX_TEX];
khash_t(tex) *list;
GLuint active; // active texture
GLuint client; // client active texture
} texture_state_t;
typedef struct {
GLint size;
GLenum type;
GLsizei stride;
glbuffer_t *buffer;
const GLvoid *pointer;
} pointer_state_t;
typedef struct {
pointer_state_t vertex, color, normal, tex_coord[MAX_TEX], secondary;
} pointer_states_t;
typedef struct {
renderlist_t *active;
renderlist_t *first;
GLboolean compiling;
GLboolean locked;
GLuint base;
GLuint name;
GLenum mode;
GLuint count;
GLuint cap;
} displaylist_state_t;
typedef struct {
map_state_t *vertex3,
*vertex4,
*index,
*color4,
*normal,
*texture1,
*texture2,
*texture3,
*texture4;
} map_states_t;
typedef struct {
int top;
GLuint *names;
} namestack_t;
typedef struct {
int count;
GLuint *buffer;
GLuint size;
} selectbuf_t;
typedef struct {
int top;
GLfloat *stack;
} matrixstack_t;
typedef struct {
glbuffer_t *vertex;
glbuffer_t *elements;
glbuffer_t *pack;
glbuffer_t *unpack;
khash_t(buff) *list;
} buffers_t;
typedef struct {
displaylist_state_t list;
enable_state_t enable;
map_state_t *map_grid;
map_states_t map1, map2;
pointer_states_t pointers;
renderlist_t **lists;
texgen_state_t texgen[MAX_TEX];
texture_state_t texture;
GLfloat color[4];
GLfloat secondary[4];
GLfloat texcoord[MAX_TEX][2];
int render_mode;
int polygon_mode;
namestack_t namestack;
matrixstack_t *modelview_matrix;
matrixstack_t *projection_matrix;
matrixstack_t **texture_matrix;
selectbuf_t selectbuf;
buffers_t buffers;
int shim_error;
GLenum last_error;
} glstate_t;
#endif

View File

@@ -0,0 +1,397 @@
#include "texgen.h"
//extern void* eglGetProcAddress(const char*);
void glTexGeni(GLenum coord, GLenum pname, GLint param) {
// coord is in: GL_S, GL_T, GL_R, GL_Q
// pname == GL_TEXTURE_GEN_MODE
/* param is in:
GL_OBJECT_LINEAR, GL_EYE_LINEAR,
GL_SPHERE_MAP, GL_NORMAL_MAP, or GL_REFLECTION_MAP
*/
/*
switch (coord) {
case GL_S: state.texgen[state.texture.active].S = param; break;
case GL_T: state.texgen[state.texture.active].T = param; break;
}
*/
GLfloat params[4] = {0,0,0,0};
params[0]=param;
glTexGenfv(coord, pname, params);
}
void glTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) {
//printf("glTexGenfv(0x%04X, 0x%04X, [%.02f, ...]), texture=%i\n", coord, pname, param[0], state.texture.active);
if (state.list.compiling && state.list.active) {
NewStage(state.list.active, STAGE_TEXGEN);
rlTexGenfv(state.list.active, coord, pname, param);
noerrorShim();
return;
}
// pname is in: GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, GL_EYE_PLANE
noerrorShim();
if (pname == GL_TEXTURE_GEN_MODE) {
switch (coord) {
case GL_S: state.texgen[state.texture.active].S = param[0]; break;
case GL_T: state.texgen[state.texture.active].T = param[0]; break;
case GL_R: state.texgen[state.texture.active].R = param[0]; break;
default:
errorShim(GL_INVALID_ENUM);
}
} else {
switch (coord) {
case GL_S:
memcpy(state.texgen[state.texture.active].Sv, param, 4 * sizeof(GLfloat));
break;
case GL_T:
memcpy(state.texgen[state.texture.active].Tv, param, 4 * sizeof(GLfloat));
break;
case GL_R:
memcpy(state.texgen[state.texture.active].Rv, param, 4 * sizeof(GLfloat));
break;
default:
errorShim(GL_INVALID_ENUM);
}
}
/*
If pname is GL_TEXTURE_GEN_MODE, then the array must contain
a single symbolic constant, one of
GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_MAP, GL_NORMAL_MAP,
or GL_REFLECTION_MAP.
Otherwise, params holds the coefficients for the texture-coordinate
generation function specified by pname.
*/
}
void glGetTexGenfv(GLenum coord,GLenum pname,GLfloat *params) {
noerrorShim();
switch(pname) {
case GL_TEXTURE_GEN_MODE:
switch (coord) {
case GL_S: *params = state.texgen[state.texture.active].S; break;
case GL_T: *params = state.texgen[state.texture.active].T; break;
case GL_R: *params = state.texgen[state.texture.active].R; break;
default: *params = GL_EYE_LINEAR;
}
break;
case GL_OBJECT_PLANE:
case GL_EYE_PLANE: // probably wrong...
switch (coord) {
case GL_S:
memcpy(params, state.texgen[state.texture.active].Sv, 4 * sizeof(GLfloat));
break;
case GL_T:
memcpy(params, state.texgen[state.texture.active].Tv, 4 * sizeof(GLfloat));
break;
case GL_R:
memcpy(params, state.texgen[state.texture.active].Rv, 4 * sizeof(GLfloat));
break;
default:
errorShim(GL_INVALID_ENUM);
}
break;
default:
errorShim(GL_INVALID_ENUM);
}
}
GLfloat dot(const GLfloat *a, const GLfloat *b) {
return a[0]*b[0] + a[1]*b[1] + a[2]*b[2];
}
//TODO: NEONize all thoses functions, maybe also making the vector an array of 4 float can help.
void matrix_vector(const GLfloat *a, const GLfloat *b, GLfloat *c) {
c[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3];
c[1] = a[4] * b[0] + a[5] * b[1] + a[6] * b[2] + a[7];
c[2] = a[8] * b[0] + a[9] * b[1] + a[10] * b[2] + a[11];
}
void vector_matrix(const GLfloat *a, const GLfloat *b, GLfloat *c) {
c[0] = a[0] * b[0] + a[1] * b[4] + a[2] * b[8] + b[12];
c[1] = a[0] * b[1] + a[1] * b[5] + a[2] * b[9] + b[13];
c[2] = a[0] * b[2] + a[1] * b[6] + a[2] * b[10] + b[14];
}
void vector_normalize(GLfloat *a) {
float det=1.0f/sqrtf(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);
a[0]*=det;
a[1]*=det;
a[2]*=det;
}
void matrix_column_row(const GLfloat *a, GLfloat *b) {
// column major -> row major
for (int i=0; i<4; i++)
for (int j=0; j<4; j++)
b[i*4+j]=a[i+j*4];
}
void matrix_row_column(const GLfloat *a, GLfloat *b) {
// row major -> column major
for (int i=0; i<4; i++)
for (int j=0; j<4; j++)
b[i+j*4]=a[i*4+j];
}
void matrix_inverse(const GLfloat *m, GLfloat *r) {
r[0] = m[5]*m[10]*m[15] - m[5]*m[14]*m[11] - m[6]*m[9]*m[15] + m[6]*m[13]*m[11] + m[7]*m[9]*m[14] - m[7]*m[13]*m[10];
r[1] = -m[1]*m[10]*m[15] + m[1]*m[14]*m[11] + m[2]*m[9]*m[15] - m[2]*m[13]*m[11] - m[3]*m[9]*m[14] + m[3]*m[13]*m[10];
r[2] = m[1]*m[6]*m[15] - m[1]*m[14]*m[7] - m[2]*m[5]*m[15] + m[2]*m[13]*m[7] + m[3]*m[5]*m[14] - m[3]*m[13]*m[6];
r[3] = -m[1]*m[6]*m[11] + m[1]*m[10]*m[7] + m[2]*m[5]*m[11] - m[2]*m[9]*m[7] - m[3]*m[5]*m[10] + m[3]*m[9]*m[6];
r[4] = -m[4]*m[10]*m[15] + m[4]*m[14]*m[11] + m[6]*m[8]*m[15] - m[6]*m[12]*m[11] - m[7]*m[8]*m[14] + m[7]*m[12]*m[10];
r[5] = m[0]*m[10]*m[15] - m[0]*m[14]*m[11] - m[2]*m[8]*m[15] + m[2]*m[12]*m[11] + m[3]*m[8]*m[14] - m[3]*m[12]*m[10];
r[6] = -m[0]*m[6]*m[15] + m[0]*m[14]*m[7] + m[2]*m[4]*m[15] - m[2]*m[12]*m[7] - m[3]*m[4]*m[14] + m[3]*m[12]*m[6];
r[7] = m[0]*m[6]*m[11] - m[0]*m[10]*m[7] - m[2]*m[4]*m[11] + m[2]*m[8]*m[7] + m[3]*m[4]*m[10] - m[3]*m[8]*m[6];
r[8] = m[4]*m[9]*m[15] - m[4]*m[13]*m[11] - m[5]*m[8]*m[15] + m[5]*m[12]*m[11] + m[7]*m[8]*m[13] - m[7]*m[12]*m[9];
r[9] = -m[0]*m[9]*m[15] + m[0]*m[13]*m[11] + m[1]*m[8]*m[15] - m[1]*m[12]*m[11] - m[3]*m[8]*m[13] + m[3]*m[12]*m[9];
r[10] = m[0]*m[5]*m[15] - m[0]*m[13]*m[7] - m[1]*m[4]*m[15] + m[1]*m[12]*m[7] + m[3]*m[4]*m[13] - m[3]*m[12]*m[5];
r[11] = -m[0]*m[5]*m[11] + m[0]*m[9]*m[7] + m[1]*m[4]*m[11] - m[1]*m[8]*m[7] - m[3]*m[4]*m[9] + m[3]*m[8]*m[5];
r[12] = -m[4]*m[9]*m[14] + m[4]*m[13]*m[10] + m[5]*m[8]*m[14] - m[5]*m[12]*m[10] - m[6]*m[8]*m[13] + m[6]*m[12]*m[9];
r[13] = m[0]*m[9]*m[14] - m[0]*m[13]*m[10] - m[1]*m[8]*m[14] + m[1]*m[12]*m[10] + m[2]*m[8]*m[13] - m[2]*m[12]*m[9];
r[14] = -m[0]*m[5]*m[14] + m[0]*m[13]*m[6] + m[1]*m[4]*m[14] - m[1]*m[12]*m[6] - m[2]*m[4]*m[13] + m[2]*m[12]*m[5];
r[15] = m[0]*m[5]*m[10] - m[0]*m[9]*m[6] - m[1]*m[4]*m[10] + m[1]*m[8]*m[6] + m[2]*m[4]*m[9] - m[2]*m[8]*m[5];
GLfloat det = 1/(m[0]*r[0] + m[1]*r[4] + m[2]*r[8] + m[3]*r[12]);
for (int i = 0; i < 16; i++) r[i] *= det;
}
void dot_loop(const GLfloat *verts, const GLfloat *params, GLfloat *out, GLint count, GLushort *indices) {
for (int i = 0; i < count; i++) {
GLushort k = indices?indices[i]:i;
out[k*2] = dot(verts+k*3, params) + params[3];
}
}
void sphere_loop(const GLfloat *verts, const GLfloat *norm, GLfloat *out, GLint count, GLushort *indices) {
// based on https://www.opengl.org/wiki/Mathematics_of_glTexGen
if (!norm) {
printf("LIBGL: GL_SPHERE_MAP without Normals\n");
return;
}
// First get the ModelviewMatrix
GLfloat ModelviewMatrix[16], InvModelview[16];
glGetFloatv(GL_MODELVIEW_MATRIX, InvModelview);
// column major -> row major
for (int i=0; i<4; i++)
for (int j=0; j<4; j++)
ModelviewMatrix[i*4+j]=InvModelview[i+j*4];
// And get the inverse
matrix_inverse(ModelviewMatrix, InvModelview);
GLfloat eye[3], eye_norm[3], reflect[3];
GLfloat a;
for (int i=0; i<count; i++) {
GLushort k = indices?indices[i]:i;
matrix_vector(ModelviewMatrix, verts+k*3, eye);
vector_normalize(eye);
vector_matrix(norm+k*3, InvModelview, eye_norm);
vector_normalize(eye_norm);
a=dot(eye, eye_norm)*2.0f;
for (int j=0; j<3; j++)
reflect[j]=eye[j]-eye_norm[j]*a;
reflect[2]+=1.0f;
a = 1.0f / (2.0f*sqrtf(dot(reflect, reflect)));
out[k*2+0] = reflect[0]*a + 0.5f;
out[k*2+1] = reflect[1]*a + 0.5f;
}
}
void eye_loop(const GLfloat *verts, const GLfloat *param, GLfloat *out, GLint count, GLushort *indices) {
// based on https://www.opengl.org/wiki/Mathematics_of_glTexGen
// First get the ModelviewMatrix
GLfloat ModelviewMatrix[16], InvModelview[16];
glGetFloatv(GL_MODELVIEW_MATRIX, InvModelview);
// column major -> row major
matrix_column_row(InvModelview, ModelviewMatrix);
// And get the inverse
matrix_inverse(ModelviewMatrix, InvModelview);
GLfloat plane[3], tmp[3];
vector_matrix(param, InvModelview, plane);
for (int i=0; i<count; i++) {
GLushort k = indices?indices[i]:i;
matrix_vector(ModelviewMatrix, verts+k*3, tmp);
out[k*2]=dot(plane, tmp);
}
}
static inline void tex_coord_loop(GLfloat *verts, GLfloat *norm, GLfloat *out, GLint count, GLenum type, GLfloat *params, GLushort *indices) {
switch (type) {
case GL_OBJECT_LINEAR:
dot_loop(verts, params, out, count, indices);
break;
case GL_EYE_LINEAR:
eye_loop(verts, params, out, count, indices);
break;
case GL_SPHERE_MAP:
//printf("LIBGL: GL_SPHERE_MAP with only 1 TexGen available"); //Broken here
break;
}
}
void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count, GLint *needclean, int texture, GLushort *indices, GLuint ilen) {
// TODO: do less work when called from glDrawElements?
(*needclean) = 0;
// special case : no texgen but texture activated, create a simple 1 repeated element
if (!state.enable.texgen_s[texture] && !state.enable.texgen_t[texture] && !state.enable.texgen_r[texture]) {
if ((*coords)==NULL)
*coords = (GLfloat *)malloc(count * 2 * sizeof(GLfloat));
if (indices)
for (int i=0; i<ilen; i++) {
memcpy((*coords)+indices[i]*2, state.texcoord[texture], sizeof(GLfloat)*2);
}
else
for (int i=0; i<count*2; i+=2) {
memcpy((*coords)+i, state.texcoord[texture], sizeof(GLfloat)*2);
}
return;
}
// special case: SPHERE_MAP needs both texgen to make sense
if ((state.enable.texgen_s[texture] && (state.texgen[texture].S==GL_SPHERE_MAP)) && (state.enable.texgen_t[texture] && (state.texgen[texture].T==GL_SPHERE_MAP)))
{
if (!state.enable.texture_2d[texture])
return;
if ((*coords)==NULL)
*coords = (GLfloat *)malloc(count * 2 * sizeof(GLfloat));
sphere_loop(verts, norm, *coords, (indices)?ilen:count, indices);
return;
}
// special case: REFLECTION_MAP needs the 3 texgen to make sense
if ((state.enable.texgen_s[texture] && (state.texgen[texture].S==GL_REFLECTION_MAP))
&& (state.enable.texgen_t[texture] && (state.texgen[texture].T==GL_REFLECTION_MAP))
&& (state.enable.texgen_r[texture] && (state.texgen[texture].R==GL_REFLECTION_MAP)))
{
*needclean=1;
// setup reflection map!
GLuint old_tex=state.texture.active;
if (old_tex!=texture) glActiveTexture(GL_TEXTURE0 + texture);
LOAD_GLES_OES(glTexGeni);
LOAD_GLES_OES(glTexGenfv);
LOAD_GLES(glEnable);
// setup cube map mode
gles_glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
gles_glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
gles_glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
// enable texgen
gles_glEnable(GL_TEXTURE_GEN_STR); //GLES only support the 3 gen at the same time!
if (old_tex!=texture) glActiveTexture(GL_TEXTURE0 + old_tex);
return;
}
// special case: NORMAL_MAP needs the 3 texgen to make sense
if ((state.enable.texgen_s[texture] && (state.texgen[texture].S==GL_NORMAL_MAP))
&& (state.enable.texgen_t[texture] && (state.texgen[texture].T==GL_NORMAL_MAP))
&& (state.enable.texgen_r[texture] && (state.texgen[texture].R==GL_NORMAL_MAP)))
{
*needclean=1;
// setup reflection map!
GLuint old_tex=state.texture.active;
if (old_tex!=texture) glActiveTexture(GL_TEXTURE0 + texture);
LOAD_GLES_OES(glTexGeni);
LOAD_GLES_OES(glTexGenfv);
LOAD_GLES(glEnable);
// setup cube map mode
gles_glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
gles_glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
gles_glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
// enable texgen
gles_glEnable(GL_TEXTURE_GEN_STR);
if (old_tex!=texture) glActiveTexture(GL_TEXTURE0 + old_tex);
return;
}
if (!state.enable.texture_2d[texture])
return;
if ((*coords)==NULL)
*coords = (GLfloat *)malloc(count * 2 * sizeof(GLfloat));
/* LOAD_GLES(glPushMatrix);
LOAD_GLES(glGetIntegerv);
LOAD_GLES(glMatrixMode);
LOAD_GLES(glLoadIdentity);
LOAD_GLES(glActiveTexture);
GLuint old=state.texture.active;
GLuint matmode;
gles_glGetIntegerv(GL_MATRIX_MODE, &matmode);
if (matmode!=GL_TEXTURE)
gles_glMatrixMode(GL_TEXTURE);
if (old!=texture)
gles_glActiveTexture(GL_TEXTURE0+texture);
gles_glPushMatrix();
gles_glLoadIdentity();
if (matmode!=GL_TEXTURE)
gles_glMatrixMode(matmode);
if (old!=texture)
gles_glActiveTexture(GL_TEXTURE0+old);
*needclean=2;
*/
if (state.enable.texgen_s[texture])
tex_coord_loop(verts, norm, *coords, (indices)?ilen:count, state.texgen[texture].S, state.texgen[texture].Sv, indices);
if (state.enable.texgen_t[texture])
tex_coord_loop(verts, norm, *coords+1, (indices)?ilen:count, state.texgen[texture].T, state.texgen[texture].Tv, indices);
}
void gen_tex_clean(GLint cleancode, int texture) {
if (cleancode == 0)
return;
if (cleancode == 1) {
GLuint old_tex=state.texture.active;
if (old_tex!=texture) glActiveTexture(GL_TEXTURE0 + texture);
LOAD_GLES(glDisable);
gles_glDisable(GL_TEXTURE_GEN_STR);
if (old_tex!=texture) glActiveTexture(GL_TEXTURE0 + old_tex);
return;
}
/* if (cleancode == 2) {
LOAD_GLES(glPopMatrix);
LOAD_GLES(glGetIntegerv);
LOAD_GLES(glMatrixMode);
LOAD_GLES(glActiveTexture);
GLuint old=state.texture.active;
GLuint matmode;
gles_glGetIntegerv(GL_MATRIX_MODE, &matmode);
if (matmode!=GL_TEXTURE)
gles_glMatrixMode(GL_TEXTURE);
if (old!=texture)
gles_glActiveTexture(GL_TEXTURE0+texture);
gles_glPopMatrix();
if (matmode!=GL_TEXTURE)
gles_glMatrixMode(matmode);
if (old!=texture)
gles_glActiveTexture(GL_TEXTURE0+old);
}*/
}
void glLoadTransposeMatrixf(const GLfloat *m) {
GLfloat mf[16];
matrix_row_column(m, mf);
glLoadMatrixf(mf);
errorGL();
}
void glLoadTransposeMatrixd(const GLdouble *m) {
GLfloat mf[16];
for (int i=0; i<16; i++)
mf[i] = m[i];
glLoadTransposeMatrixf(mf);
}
void glMultTransposeMatrixd(const GLdouble *m) {
GLfloat mf[16];
for (int i=0; i<16; i++)
mf[i] = m[i];
glMultTransposeMatrixf(mf);
}
void glMultTransposeMatrixf(const GLfloat *m) {
GLfloat mf[16];
matrix_row_column(m, mf);
glMultMatrixf(mf);
errorGL();
}

View File

@@ -0,0 +1,21 @@
#include "gl.h"
#include <math.h>
extern void glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params);
extern void glTexGeni(GLenum coord, GLenum pname, GLint param);
extern void gen_tex_coords(GLfloat *verts, GLfloat *norm, GLfloat **coords, GLint count, GLint *needclean, int texture, GLushort* indices, GLuint ilen);
extern void gen_tex_clean(GLint cleancode, int texture);
extern void glGetTexGenfv(GLenum coord,GLenum pname,GLfloat *params);
extern GLfloat dot(const GLfloat *a, const GLfloat *b);
extern void matrix_vector(const GLfloat *a, const GLfloat *b, GLfloat *c);
extern void vector_matrix(const GLfloat *a, const GLfloat *b, GLfloat *c);
extern void vector_normalize(GLfloat *a);
extern void matrix_column_row(const GLfloat *a, GLfloat *b);
extern void matrix_row_column(const GLfloat *a, GLfloat *b);
extern void matrix_inverse(const GLfloat *m, GLfloat *r);
extern void glLoadTransposeMatrixf(const GLfloat *m);
extern void glLoadTransposeMatrixd(const GLdouble *m);
extern void glMultTransposeMatrixd(const GLdouble *m);
extern void glMultTransposeMatrixf(const GLfloat *m);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,128 @@
#include "gl.h"
#ifndef GL_TEXTURE_H
#define GL_TEXTURE_H
void glTexImage2D(GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type, const GLvoid *data);
void glTexImage1D(GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLint border,
GLenum format, GLenum type, const GLvoid *data);
void glTexImage3D(GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type, const GLvoid *data);
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format, GLenum type,
const GLvoid *data);
void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLenum format, GLenum type,
const GLvoid *data);
void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format,
GLenum type, const GLvoid *data);
void glBindTexture(GLenum target, GLuint texture);
void glGenTextures(GLsizei n, GLuint * textures);
void glDeleteTextures(GLsizei n, const GLuint * textures);
void glTexParameteri(GLenum target, GLenum pname, GLint param);
void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
GLboolean glAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences);
void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params);
void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * img);
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * data);
void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border,
GLsizei imageSize, const GLvoid *data);
void glCompressedTexImage1D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLint border,
GLsizei imageSize, const GLvoid *data);
void glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLsizei depth, 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 glCompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLenum format,
GLsizei imageSize, const GLvoid *data);
void glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format,
GLsizei imageSize, const GLvoid *data);
void glGetCompressedTexImage(GLenum target, GLint lod, GLvoid *img);
void glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
GLsizei width, GLint border);
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 glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y,
GLsizei width);
void tex_coord_rect_arb(GLfloat *tex, GLsizei len,
GLsizei width, GLsizei height);
void tex_coord_npot(GLfloat *tex, GLsizei len,
GLsizei width, GLsizei height,
GLsizei nwidth, GLsizei nheight);
int npot(int n);
typedef struct {
GLuint texture;
GLuint glname;
GLenum target;
GLsizei width;
GLsizei height;
GLsizei nwidth;
GLsizei nheight;
GLenum format;
GLenum type;
int shrink;
GLboolean mipmap_auto;
GLboolean mipmap_need;
GLenum min_filter;
GLenum mag_filter;
GLboolean uploaded;
GLboolean alpha;
GLboolean streamed;
int streamingID;
GLvoid *data; // in case we want to keep a copy of it (it that case, always RGBA/GL_UNSIGNED_BYTE
} gltexture_t;
KHASH_MAP_INIT_INT(tex, gltexture_t *)
static inline GLenum map_tex_target(GLenum target) {
switch (target) {
case GL_TEXTURE_1D:
case GL_TEXTURE_3D:
case GL_TEXTURE_RECTANGLE_ARB:
target = GL_TEXTURE_2D;
break;
case GL_PROXY_TEXTURE_1D:
case GL_PROXY_TEXTURE_3D:
target = GL_PROXY_TEXTURE_2D;
break;
}
return target;
}
void glActiveTexture( GLenum texture );
void glClientActiveTexture( GLenum texture );
void glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t );
GLboolean glIsTexture( GLuint texture );
void tex_setup_texcoord(GLuint texunit, GLuint len);
#endif

View File

@@ -0,0 +1,5 @@
#ifdef USE_ES2
#include "gles2.h"
#else
#include "gles.h"
#endif

View File

@@ -0,0 +1,766 @@
#include "gl.h"
#include <limits.h>
#define constDoubleToFloat(a, size) \
GLfloat s[size]; \
int i; \
for (i = 0; i < size; i++) { \
s[i] = a[i]; \
}
// naive wrappers
#ifdef USE_ES2
void glCompileShaderARB(GLuint shader) {
glCompileShader(shader);
GLint status;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE) {
GLint log_length;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
GLchar *log = malloc(sizeof(GLchar) * log_length);
glGetShaderInfoLog(shader, log_length, NULL, log);
printf("Shader compile failed: %s\n", log);
free(log);
}
}
GLuint glCreateShaderObjectARB(GLenum shaderType) {
return glCreateShader(shaderType);
}
void glShaderSourceARB(GLuint shader, GLsizei count, const GLchar **string, const GLint *length) {
glShaderSource(shader, count, string, length);
}
void glGetObjectParameterivARB(GLuint shader, GLenum pname, GLint *params) {
glGetShaderiv(shader, pname, params);
}
#endif
void glActiveTextureARB(GLenum texture) {
glActiveTexture(texture);
}
void glClearDepth(GLdouble depth) {
glClearDepthf(depth);
}
void glClientActiveTextureARB(GLenum texture) {
#ifndef USE_ES2
glClientActiveTexture(texture);
#endif
}
void glClipPlane(GLenum plane, const GLdouble *equation) {
constDoubleToFloat(equation, 4);
glClipPlanef(plane, s);
}
void glDepthRange(GLdouble nearVal, GLdouble farVal) {
glDepthRangef(nearVal, farVal);
}
void glFogi(GLenum pname, GLint param) {
glFogf(pname, param);
}
void glFogiv(GLenum pname, GLint *iparams) {
switch (pname) {
case GL_FOG_DENSITY:
case GL_FOG_START:
case GL_FOG_END:
case GL_FOG_INDEX: {
glFogf(pname, *iparams);
break;
}
case GL_FOG_MODE:
case GL_FOG_COLOR: {
GLfloat params[4];
for (int i = 0; i < 4; i++) {
params[i] = iparams[i];
}
glFogfv(pname, params);
break;
}
}
}
void glGetTexGendv(GLenum coord,GLenum pname,GLdouble *params) {
GLfloat fparams[4];
glGetTexGenfv(coord, pname, fparams);
if (pname==GL_TEXTURE_GEN_MODE) *params=fparams[0];
else for (int i=0; i<4; i++) params[i]=fparams[i];
}
void glGetTexGeniv(GLenum coord,GLenum pname,GLint *params) {
GLfloat fparams[4];
glGetTexGenfv(coord, pname, fparams);
if (pname==GL_TEXTURE_GEN_MODE) *params=fparams[0];
else for (int i=0; i<4; i++) params[i]=fparams[i];
}
void glGetMaterialiv(GLenum face, GLenum pname, GLint * params) {
GLfloat fparams[4];
glGetMaterialfv(face, pname, fparams);
if (pname==GL_SHININESS) *params=fparams[0];
else for (int i=0; i<4; i++) params[i]=fparams[i];
}
void glGetLightiv(GLenum light, GLenum pname, GLint * params) {
GLfloat fparams[4];
glGetLightfv(light, pname, fparams);
int n=4;
if (pname==GL_SPOT_EXPONENT) n=1;
if (pname==GL_SPOT_CUTOFF) n=1;
if (pname==GL_SPOT_EXPONENT) n=1;
if (pname==GL_SPOT_DIRECTION) n=3;
else for (int i=0; i<n; i++) params[i]=fparams[i];
}
void glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params) {
GLint iparams;
glGetTexLevelParameteriv(target, level, pname, &iparams);
(*params)=iparams;
return;
}
void glGetClipPlane(GLenum plane, GLdouble *equation) {
GLfloat fparams[4];
glGetClipPlanef(plane, fparams);
for (int i=0; i<4; i++) equation[i]=fparams[i];
}
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom,
GLdouble top, GLdouble near, GLdouble far) {
glFrustumf(left, right, bottom, top, near, far);
}
void glPixelStoref(GLenum pname, GLfloat param) {
glPixelStorei(pname, param);
}
void glLighti(GLenum light, GLenum pname, GLint param) {
glLightf(light, pname, param);
}
void glPixelTransferi(GLenum pname, GLint param) {
glPixelTransferf(pname, param);
}
void glLightiv(GLenum light, GLenum pname, GLint *iparams) {
switch (pname) {
case GL_AMBIENT:
case GL_DIFFUSE:
case GL_SPECULAR:
case GL_POSITION: {
GLfloat params[4];
for (int i = 0; i < 4; i++) {
params[i] = iparams[i];
}
glLightfv(light, pname, params);
break;
}
case GL_SPOT_DIRECTION: {
GLfloat params[4];
for (int i = 0; i < 4; i++) {
params[i] = iparams[i];
}
glLightfv(light, pname, params);
break;
}
case GL_SPOT_EXPONENT:
case GL_SPOT_CUTOFF:
case GL_CONSTANT_ATTENUATION:
case GL_LINEAR_ATTENUATION:
case GL_QUADRATIC_ATTENUATION: {
glLightf(light, pname, *iparams);
break;
}
}
}
#ifndef USE_ES2
void glLightModeli(GLenum pname, GLint param) {
glLightModelf(pname, param);
}
void glLightModeliv(GLenum pname, GLint *iparams) {
switch (pname) {
case GL_LIGHT_MODEL_AMBIENT: {
GLfloat params[4];
for (int i = 0; i < 4; i++) {
params[i] = iparams[i];
}
glLightModelfv(pname, params);
break;
}
case GL_LIGHT_MODEL_LOCAL_VIEWER:
case GL_LIGHT_MODEL_TWO_SIDE: {
glLightModelf(pname, *iparams);
break;
}
}
}
#endif
void glMateriali(GLenum face, GLenum pname, GLint param) {
glMaterialf(face, pname, param);
}
void glMaterialiv(GLenum face, GLenum pname, GLint *iparams) {
printf("glMaterialiv(%04X, %04X, [%i,...]\n", face, pname, iparams[0]);
switch (pname) {
case GL_AMBIENT:
case GL_DIFFUSE:
case GL_SPECULAR:
case GL_EMISSION:
{
GLfloat params[4];
for (int i = 0; i < 4; i++) {
params[i] = iparams[i]; // should divide by MAX_INT
}
glMaterialfv(face, pname, params);
break;
}
case GL_SHININESS:
{
GLfloat params[2];
for (int i = 0; i < 2; i++) {
params[i] = iparams[i];
}
glMaterialfv(face, pname, params);
break;
}
case GL_AMBIENT_AND_DIFFUSE: {
glMaterialf(face, pname, *iparams);
break;
}
case GL_COLOR_INDEXES:
{
GLfloat params[3];
for (int i = 0; i < 3; i++) {
params[i] = iparams[i];
}
glMaterialfv(face, pname, params);
break;
}
}
}
/*
void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t) {
glMultiTexCoord4f(target, s, t, 0.0f, 1.0f);
}
* */
void glMultiTexCoord1f(GLenum target, GLfloat s) {
glMultiTexCoord2f(target, s, 0);
}
void glMultiTexCoord1fv(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], 0);
}
void glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r) {
glMultiTexCoord2f(target, s, t);
}
void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
glMultiTexCoord2f(target, s, t);
}
void glMultiTexCoord2fv(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], t[1]);
}
void glMultiTexCoord3fv(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], t[1]);
}
void glMultiTexCoord4fv(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], t[1]);
}
void glMultiTexCoord1fARB(GLenum target, GLfloat s) {
glMultiTexCoord2f(target, s, 0);
}
void glMultiTexCoord1fvARB(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], 0);
}
void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) {
glMultiTexCoord2f(target, s, t);
}
void glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r) {
glMultiTexCoord2f(target, s, t);
}
void glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
glMultiTexCoord2f(target, s, t);
}
void glMultiTexCoord2fvARB(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], t[1]);
}
void glMultiTexCoord3fvARB(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], t[1]);
}
void glMultiTexCoord4fvARB(GLenum target, GLfloat *t) {
glMultiTexCoord2f(target, t[0], t[1]);
}
/*
void glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) {
glBlendFuncSeparate (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
}
*/
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom,
GLdouble top, GLdouble near, GLdouble far) {
glOrthof(left, right, bottom, top, near, far);
}
// OES wrappers
void glClearDepthfOES(GLfloat depth) {
glClearDepthf(depth);
}
void glClipPlanefOES(GLenum plane, const GLfloat *equation) {
glClipPlanef(plane, equation);
}
void glDepthRangefOES(GLclampf near, GLclampf far) {
glDepthRangef(near, far);
}
void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom,
GLfloat top, GLfloat near, GLfloat far) {
glFrustumf(left, right, bottom, top, near, far);
}
void glGetClipPlanefOES(GLenum pname, GLfloat equation[4]) {
glGetClipPlanef(pname, equation);
}
void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom,
GLfloat top, GLfloat near, GLfloat far) {
glOrthof(left, right, bottom, top, near, far);
}
// glRect
#define GL_RECT(suffix, type) \
void glRect##suffix(type x1, type y1, type x2, type y2) { \
glBegin(GL_POLYGON); \
glVertex2##suffix(x1, y1); \
glVertex2##suffix(x2, y1); \
glVertex2##suffix(x2, y2); \
glVertex2##suffix(x1, y2); \
glEnd(); \
} \
void glRect##suffix##v(const type *v) { \
glRect##suffix(v[0], v[1], v[2], v[3]); \
}
GL_RECT(d, GLdouble)
GL_RECT(f, GLfloat)
GL_RECT(i, GLint)
GL_RECT(s, GLshort)
#undef GL_RECT
// basic thunking
#define THUNK(suffix, type, max) \
/* colors */ \
void glColor3##suffix(type r, type g, type b) { \
glColor4f(r/max, g/max, b/max, 1.0f); \
} \
void glColor4##suffix(type r, type g, type b, type a) { \
glColor4f(r/max, g/max, b/max, a/max); \
} \
void glColor3##suffix##v(const type *v) { \
glColor4f(v[0]/max, v[1]/max, v[2]/max, 1.0f); \
} \
void glColor4##suffix##v(const type *v) { \
glColor4f(v[0]/max, v[1]/max, v[2]/max, v[3]/max); \
} \
void glSecondaryColor3##suffix(type r, type g, type b) { \
glSecondaryColor3f(r/max, g/max, b/max); \
} \
void glSecondaryColor3##suffix##v(const type *v) { \
glSecondaryColor3f(v[0]/max, v[1]/max, v[2]/max); \
} \
/* index */ \
void glIndex##suffix(type c) { \
glIndexf(c); \
} \
void glIndex##suffix##v(const type *c) { \
glIndexf(c[0]); \
} \
/* normal */ \
void glNormal3##suffix(type x, type y, type z) { \
glNormal3f(x, y, z); \
} \
void glNormal3##suffix##v(const type *v) { \
glNormal3f(v[0], v[1], v[2]); \
} \
/* raster */ \
void glRasterPos2##suffix(type x, type y) { \
glRasterPos3f(x, y, 0); \
} \
void glRasterPos2##suffix##v(type *v) { \
glRasterPos3f(v[0], v[1], 0); \
} \
void glRasterPos3##suffix(type x, type y, type z) { \
glRasterPos3f(x, y, z); \
} \
void glRasterPos3##suffix##v(type *v) { \
glRasterPos3f(v[0], v[1], v[2]); \
} \
void glRasterPos4##suffix(type x, type y, type z, type w) { \
glRasterPos4f(x, y, z, w); \
} \
void glRasterPos4##suffix##v(type *v) { \
glRasterPos4f(v[0], v[1], v[2], v[3]); \
} \
void glWindowPos2##suffix(type x, type y) { \
glWindowPos3f(x, y, 0); \
} \
void glWindowPos2##suffix##v(type *v) { \
glWindowPos3f(v[0], v[1], 0); \
} \
void glWindowPos3##suffix(type x, type y, type z) { \
glWindowPos3f(x, y, z); \
} \
void glWindowPos3##suffix##v(type *v) { \
glWindowPos3f(v[0], v[1], v[2]); \
} \
/* vertex */ \
void glVertex2##suffix(type x, type y) { \
glVertex2f(x, y); \
} \
void glVertex2##suffix##v(type *v) { \
glVertex2f(v[0], v[1]); \
} \
void glVertex3##suffix(type x, type y, type z) { \
glVertex3f(x, y, z); \
} \
void glVertex3##suffix##v(type *v) { \
glVertex3f(v[0], v[1], v[2]); \
} \
void glVertex4##suffix(type r, type g, type b, type w) { \
glVertex4f(r, g, b, w); \
} \
void glVertex4##suffix##v(type *v) { \
glVertex4f(v[0], v[1], v[2], v[3]); \
} \
/* texture */ \
void glTexCoord1##suffix(type s) { \
glTexCoord2f(s, 0); \
} \
void glTexCoord1##suffix##v(type *t) { \
glTexCoord2f(t[0], 0); \
} \
void glTexCoord2##suffix(type s, type t) { \
glTexCoord2f(s, t); \
} \
void glTexCoord2##suffix##v(type *t) { \
glTexCoord2f(t[0], t[1]); \
} \
void glTexCoord3##suffix(type s, type t, type r) { \
glTexCoord2f(s, t); \
} \
void glTexCoord3##suffix##v(type *t) { \
glTexCoord2f(t[0], t[1]); \
} \
void glTexCoord4##suffix(type s, type t, type r, type q) { \
glTexCoord2f(s, t); \
} \
void glTexCoord4##suffix##v(type *t) { \
glTexCoord2f(t[0], t[1]); \
} \
/* multi-texture */ \
void glMultiTexCoord1##suffix(GLenum target, type s) { \
glMultiTexCoord2f(target, s, 0); \
} \
void glMultiTexCoord1##suffix##v(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], 0); \
} \
void glMultiTexCoord2##suffix(GLenum target, type s, type t) { \
glMultiTexCoord2f(target, s, t); \
} \
void glMultiTexCoord2##suffix##v(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], t[1]); \
} \
void glMultiTexCoord3##suffix(GLenum target, type s, type t, type r) { \
glMultiTexCoord2f(target, s, t); \
} \
void glMultiTexCoord3##suffix##v(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], t[1]); \
} \
void glMultiTexCoord4##suffix(GLenum target, type s, type t, type r, type q) { \
glMultiTexCoord2f(target, s, t); \
} \
void glMultiTexCoord4##suffix##v(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], t[1]); \
} \
/* multi-texture ARB */ \
void glMultiTexCoord1##suffix##ARB(GLenum target, type s) { \
glMultiTexCoord2f(target, s, 0); \
} \
void glMultiTexCoord1##suffix##vARB(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], 0); \
} \
void glMultiTexCoord2##suffix##ARB(GLenum target, type s, type t) { \
glMultiTexCoord2f(target, s, t); \
} \
void glMultiTexCoord2##suffix##vARB(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], t[1]); \
} \
void glMultiTexCoord3##suffix##ARB(GLenum target, type s, type t, type r) { \
glMultiTexCoord2f(target, s, t); \
} \
void glMultiTexCoord3##suffix##vARB(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], t[1]); \
} \
void glMultiTexCoord4##suffix##ARB(GLenum target, type s, type t, type r, type q) { \
glMultiTexCoord2f(target, s, t); \
} \
void glMultiTexCoord4##suffix##vARB(GLenum target, type *t) { \
glMultiTexCoord2f(target, t[0], t[1]); \
}
THUNK(b, GLbyte, (float)CHAR_MAX)
THUNK(d, GLdouble, 1.0f)
THUNK(i, GLint, (float)INT_MAX)
THUNK(s, GLshort, (float)SHRT_MAX)
THUNK(ub, GLubyte, (float)UCHAR_MAX)
THUNK(ui, GLuint, (float)UINT_MAX)
THUNK(us, GLushort, (float)USHRT_MAX)
#undef THUNK
// glGet
#define THUNK(suffix, type) \
void glGet##suffix##v(GLenum pname, type *params) { \
int i, n = 1; \
switch (pname) { \
/* two values */ \
case GL_ALIASED_POINT_SIZE_RANGE: \
case GL_ALIASED_LINE_WIDTH_RANGE: \
case GL_MAX_VIEWPORT_DIMS: \
n = 2; \
break; \
/* three values */ \
case GL_CURRENT_NORMAL: \
case GL_POINT_DISTANCE_ATTENUATION: \
n = 3; \
break; \
/* four values */ \
case GL_COLOR_CLEAR_VALUE: \
case GL_COLOR_WRITEMASK: \
case GL_CURRENT_COLOR: \
case GL_CURRENT_TEXTURE_COORDS: \
case GL_DEPTH_RANGE: \
case GL_FOG_COLOR: \
case GL_LIGHT_MODEL_AMBIENT: \
case GL_SCISSOR_BOX: \
case GL_SMOOTH_LINE_WIDTH_RANGE: \
case GL_SMOOTH_POINT_SIZE_RANGE: \
case GL_VIEWPORT: \
n = 4; \
break; \
/* GL_NUM_COMPRESSED_TEXTURE_FORMATS values */ \
case GL_COMPRESSED_TEXTURE_FORMATS: \
n = GL_NUM_COMPRESSED_TEXTURE_FORMATS; \
break; \
/* sixteen values */ \
case GL_MODELVIEW_MATRIX: \
case GL_PROJECTION_MATRIX: \
case GL_TEXTURE_MATRIX: \
n = 16; \
break; \
} \
GLfloat *p = (GLfloat *)malloc(sizeof(GLfloat) * n); \
glGetFloatv(pname, p); \
for (i = 0; i < n; i++) { \
params[i] = (type)p[i]; \
} \
free(p); \
}
THUNK(Double, GLdouble)
//THUNK(Integer, GLint)
//THUNK(Float, GLfloat)
#undef THUNK
// manually defined float wrappers, because we don't autowrap float functions
// color
void glColor3f(GLfloat r, GLfloat g, GLfloat b) {
glColor4f(r, g, b, 1.0f);
}
void glColor3fv(GLfloat *c) {
glColor4f(c[0], c[1], c[2], 1.0f);
}
void glColor4fv(GLfloat *c) {
glColor4f(c[0], c[1], c[2], c[3]);
}
void glIndexfv(const GLfloat *c) {
glIndexf(*c);
}
void glSecondaryColor3fv(const GLfloat *v) {
glSecondaryColor3f(v[0], v[1], v[2]);
}
// raster
void glRasterPos2f(GLfloat x, GLfloat y) {
glRasterPos3f(x, y, 0.0f);
}
void glRasterPos2fv(const GLfloat *v) {
glRasterPos3f(v[0], v[1], 0.0f);
}
void glRasterPos3fv(const GLfloat *v) {
glRasterPos3f(v[0], v[1], v[2]);
}
void glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
glRasterPos3f(x/w, y/w, z/w);
}
void glRasterPos4fv(const GLfloat *v) {
glRasterPos4f(v[0], v[1], v[2], v[3]);
}
void glWindowPos2f(GLfloat x, GLfloat y) {
glWindowPos3f(x, y, 0.0f);
}
void glWindowPos2fv(const GLfloat *v) {
glWindowPos3f(v[0], v[1], 0.0f);
}
void glWindowPos3fv(const GLfloat *v) {
glWindowPos3f(v[0], v[1], v[2]);
}
// eval
void glEvalCoord1d(GLdouble u) {
glEvalCoord1f(u);
}
void glEvalCoord2d(GLdouble u, GLdouble v) {
glEvalCoord2f(u, v);
}
void glEvalCoord1fv(GLfloat *v) {
glEvalCoord1f(v[0]);
}
void glEvalCoord1dv(GLdouble *v) {
glEvalCoord1d(v[0]);
}
void glEvalCoord2fv(GLfloat *v) {
glEvalCoord2f(v[0], v[1]);
}
void glEvalCoord2dv(GLdouble *v) {
glEvalCoord2d(v[0], v[1]);
}
void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2) {
glMapGrid1f(un, u1, u2);
}
void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2,
GLint vn, GLdouble v1, GLdouble v2) {
glMapGrid2f(un, u1, u2, vn, v1, v2);
}
// matrix
void glLoadMatrixd(const GLdouble *m) {
constDoubleToFloat(m, 16);
glLoadMatrixf(s);
}
void glMultMatrixd(const GLdouble *m) {
constDoubleToFloat(m, 16);
glMultMatrixf(s);
}
// normal
void glNormal3fv(GLfloat *v) {
glNormal3f(v[0], v[1], v[2]);
}
// textures
void glTexCoord1f(GLfloat s) {
glTexCoord2f(s, 0);
}
void glTexCoord1fv(GLfloat *t) {
glTexCoord2f(t[0], 0);
}
void glTexCoord2fv(GLfloat *t) {
glTexCoord2f(t[0], t[1]);
}
void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r) {
glTexCoord2f(s, t);
}
void glTexCoord3fv(GLfloat *t) {
glTexCoord2f(t[0], t[1]);
}
void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
glTexCoord2f(s, t);
}
void glTexCoord4fv(GLfloat *t) {
glTexCoord2f(t[0], t[1]);
}
// texgen
void glTexGend(GLenum coord, GLenum pname, GLdouble param) {
glTexGeni(coord, pname, param);
}
void glTexGenf(GLenum coord, GLenum pname, GLfloat param) {
// TODO: this is gross/lossy.
glTexGeni(coord, pname, param);
}
void glTexGendv(GLenum coord, GLenum pname, const GLdouble *params) {
GLfloat tmp[4];
tmp[0]=params[0];
if ((pname==GL_OBJECT_PLANE) || (pname==GL_EYE_PLANE))
for (int i=1; i<4; i++)
tmp[i]=params[i];
glTexGenfv(coord, pname, tmp);
}
void glTexGeniv(GLenum coord, GLenum pname, const GLint *params) {
GLfloat tmp[4];
tmp[0]=params[0];
if ((pname==GL_OBJECT_PLANE) || (pname==GL_EYE_PLANE))
for (int i=1; i<4; i++)
tmp[i]=params[i];
glTexGenfv(coord, pname, tmp);
}
// transforms
void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) {
glRotatef(angle, x, y, z);
}
void glScaled(GLdouble x, GLdouble y, GLdouble z) {
glScalef(x, y, z);
}
void glTranslated(GLdouble x, GLdouble y, GLdouble z) {
glTranslatef(x, y, z);
}
// vertex
void glVertex2f(GLfloat x, GLfloat y) {
glVertex3f(x, y, 0);
}
void glVertex2fv(GLfloat *v) {
glVertex3f(v[0], v[1], 0);
}
void glVertex3fv(GLfloat *v) {
glVertex3f(v[0], v[1], v[2]);
}
void glVertex4f(GLfloat r, GLfloat g, GLfloat b, GLfloat w) {
glVertex3f(r/w, g/w, b/w);
}
void glVertex4fv(GLfloat *v) {
glVertex3f(v[0]/v[3], v[1]/v[3], v[2]/v[3]);
}
void glDrawRangeElements(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenum type,const void *indices) {
//printf("glDrawRangeElements(0x%04X, %i, %i, %i, 0x%04X, @%p), inlist=%i\n", mode, start, end, count, type, indices, (state.list.active)?1:0);
GLushort *newinds = (GLushort*)malloc(sizeof(GLushort)*count);
int newcount=0;
glbuffer_t *elements = state.buffers.elements;
state.buffers.elements = NULL;
uintptr_t ptr = (uintptr_t)indices;
if (elements)
ptr+=(uintptr_t)elements->data;
for (int i=0; i<count; i++) {
GL_TYPE_SWITCH(indice, ptr, type,
if ((indice[i]>=start) && (indice[i]<=end))
newinds[newcount++]=indice[i];
, );
}
glDrawElements(mode, newcount, GL_UNSIGNED_SHORT, newinds);
free(newinds);
state.buffers.elements = elements;
}
void glBlendEquationSeparatei(GLuint buf, GLenum modeRGB, GLenum modeAlpha) {
// ignore buf is better than nothing...
// TODO: handle buf
glBlendEquationSeparate(modeRGB, modeAlpha);
}
void glBlendFuncSeparatei(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
// ignore buf is better than nothing..
// TODO: handle buf
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
#undef constDoubleToFloat

View File

@@ -0,0 +1,221 @@
#include "../gl.h"
#include <GLES/glext.h>
#ifndef GL_WRAP_H
#define GL_WRAP_H
// misc naive wrappers
#ifdef USE_ES2
void glCompileShaderARB(GLuint shader);
GLuint glCreateShaderObjectARB(GLenum shaderType);
void glGetObjectParameterivARB(GLuint shader, GLenum pname, GLint *params);
void glShaderSourceARB(GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
#endif
void glActiveTextureARB(GLenum texture);
void glClearDepth(GLdouble depth);
void glClientActiveTextureARB(GLenum texture);
void glClipPlane(GLenum plane, const GLdouble *equation);
void glDepthRange(GLdouble nearVal, GLdouble farVal);
void glFogi(GLenum pname, GLint param);
void glFogiv(GLenum pname, GLint *params);
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void glGetDoublev(GLenum pname, GLdouble *params);
void glLighti(GLenum light, GLenum pname, GLint param);
void glLightiv(GLenum light, GLenum pname, GLint *iparams);
void glLightModeli(GLenum pname, GLint param);
void glLightModeliv(GLenum pname, GLint *iparams);
void glMateriali(GLenum face, GLenum pname, GLint param);
void glMaterialiv(GLenum face, GLenum pname, GLint *param);
void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t);
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void glGetMaterialiv(GLenum face, GLenum pname, GLint * params);
void glGetLightiv(GLenum light, GLenum pname, GLint * params);
void glGetClipPlane(GLenum plane, GLdouble *equation);
void glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
void glDrawRangeElementsEXT(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenum type,const void *indices);
void glDrawRangeElements(GLenum mode,GLuint start,GLuint end,GLsizei count,GLenum type,const void *indices);
// color
void glColor3f(GLfloat r, GLfloat g, GLfloat b);
void glColor3fv(GLfloat *c);
void glColor4fv(GLfloat *c);
void glIndexfv(const GLfloat *c);
void glSecondaryColor3fv(const GLfloat *v);
// raster
void glRasterPos2f(GLfloat x, GLfloat y);
void glRasterPos2fv(const GLfloat *v);
void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z);
void glRasterPos3fv(const GLfloat *v);
void glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void glRasterPos4fv(const GLfloat *v);
void glWindowPos2f(GLfloat x, GLfloat y);
void glWindowPos2fv(const GLfloat *v);
void glWindowPos3f(GLfloat x, GLfloat y, GLfloat z);
void glWindowPos3fv(const GLfloat *v);
void glPixelStoref(GLenum pname, GLfloat param);
void glGetTexGendv(GLenum coord,GLenum pname,GLdouble *params);
void glGetTexGeniv(GLenum coord,GLenum pname,GLint *params);
void glPixelTransferi(GLenum pname, GLint param);
void glPixelTransferf(GLenum pname, GLfloat param);
// eval
void glEvalCoord1d(GLdouble u);
void glEvalCoord1dv(GLdouble *v);
void glEvalCoord1fv(GLfloat *v);
void glEvalCoord2d(GLdouble u, GLdouble v);
void glEvalCoord2dv(GLdouble *v);
void glEvalCoord2fv(GLfloat *v);
void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2);
void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
// matrix
void glLoadMatrixd(const GLdouble *m);
void glMultMatrixd(const GLdouble *m);
// normal
void glNormal3fv(GLfloat *v);
// rect
#define GL_RECT(suffix, type) \
void glRect##suffix(type x1, type y1, type x2, type y2); \
void glRect##suffix##v(const type *v);
GL_RECT(d, GLdouble)
GL_RECT(f, GLfloat)
GL_RECT(i, GLint)
GL_RECT(s, GLshort)
#undef GL_RECT
// textures
void glTexCoord1f(GLfloat s);
void glTexCoord1fv(GLfloat *t);
void glTexCoord2fv(GLfloat *t);
void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r);
void glTexCoord3fv(GLfloat *t);
void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
void glTexCoord4fv(GLfloat *t);
void glMultiTexCoord1f(GLenum target, GLfloat s);
void glMultiTexCoord1fv(GLenum target, GLfloat *t);
void glMultiTexCoord2fv(GLenum target, GLfloat *t);
void glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r);
void glMultiTexCoord3fv(GLenum target, GLfloat *t);
void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
void glMultiTexCoord4fv(GLenum target, GLfloat *t);
void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
void glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r);
void glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
void glMultiTexCoord2fvARB(GLenum target, GLfloat *t);
void glMultiTexCoord3fvARB(GLenum target, GLfloat *t);
void glMultiTexCoord4fvARB(GLenum target, GLfloat *t);
void glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params);
void glPolygonMode(GLenum face, GLenum mode);
// texgen
void glTexGend(GLenum coord, GLenum pname, GLdouble param);
void glTexGeni(GLenum coord, GLenum pname, GLint param);
void glTexGenf(GLenum coord, GLenum pname, GLfloat param);
void glTexGendv(GLenum coord, GLenum pname, const GLdouble *params);
void glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params);
void glTexGeniv(GLenum coord, GLenum pname, const GLint *params);
// transforms
void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
void glScaled(GLdouble x, GLdouble y, GLdouble z);
void glTranslated(GLdouble x, GLdouble y, GLdouble z);
// vertex
void glVertex2f(GLfloat x, GLfloat y);
void glVertex2fv(GLfloat *v);
void glVertex3fv(GLfloat *v);
void glVertex4f(GLfloat r, GLfloat g, GLfloat b, GLfloat w);
void glVertex4fv(GLfloat *v);
// OES wrappers
void glClearDepthfOES(GLfloat depth);
void glClipPlanefOES(GLenum plane, const GLfloat *equation);
void glDepthRangefOES(GLclampf near, GLclampf far);
void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far);
void glGetClipPlanefOES(GLenum plane, GLfloat equation[4]);
void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far);
// basic thunking
#define THUNK(suffix, type) \
void glColor3##suffix##v(const type *v); \
void glColor3##suffix(type r, type g, type b); \
void glColor4##suffix##v(const type *v); \
void glColor4##suffix(type r, type g, type b, type a); \
void glSecondaryColor3##suffix##v(const type *v); \
void glSecondaryColor3##suffix(type r, type g, type b); \
void glIndex##suffix##v(const type *c); \
void glIndex##suffix(type c); \
void glNormal3##suffix##v(const type *v); \
void glNormal3##suffix(type x, type y, type z); \
void glRasterPos2##suffix##v(type *v); \
void glRasterPos2##suffix(type x, type y); \
void glRasterPos3##suffix##v(type *v); \
void glRasterPos3##suffix(type x, type y, type z); \
void glRasterPos4##suffix##v(type *v); \
void glRasterPos4##suffix(type x, type y, type z, type w); \
void glWindowPos2##suffix##v(type *v); \
void glWindowPos2##suffix(type x, type y); \
void glWindowPos3##suffix##v(type *v); \
void glWindowPos3##suffix(type x, type y, type z); \
void glVertex2##suffix##v(type *v); \
void glVertex2##suffix(type x, type y); \
void glVertex3##suffix##v(type *v); \
void glVertex3##suffix(type x, type y, type z); \
void glVertex4##suffix(type x, type y, type z, type w); \
void glVertex4##suffix##v(type *v); \
void glTexCoord1##suffix(type s); \
void glTexCoord1##suffix##v(type *t); \
void glTexCoord2##suffix(type s, type t); \
void glTexCoord2##suffix##v(type *t); \
void glTexCoord3##suffix(type s, type t, type r); \
void glTexCoord3##suffix##v(type *t); \
void glTexCoord4##suffix(type s, type t, type r, type q); \
void glTexCoord4##suffix##v(type *t); \
void glMultiTexCoord1##suffix(GLenum target, type s); \
void glMultiTexCoord1##suffix##v(GLenum target, type *t); \
void glMultiTexCoord2##suffix(GLenum target, type s, type t); \
void glMultiTexCoord2##suffix##v(GLenum target, type *t); \
void glMultiTexCoord3##suffix(GLenum target, type s, type t, type r); \
void glMultiTexCoord3##suffix##v(GLenum target, type *t); \
void glMultiTexCoord4##suffix(GLenum target, type s, type t, type r, type q); \
void glMultiTexCoord4##suffix##v(GLenum target, type *t); \
void glMultiTexCoord1##suffix##ARB(GLenum target, type s); \
void glMultiTexCoord1##suffix##vARB(GLenum target, type *t); \
void glMultiTexCoord2##suffix##ARB(GLenum target, type s, type t); \
void glMultiTexCoord2##suffix##vARB(GLenum target, type *t); \
void glMultiTexCoord3##suffix##ARB(GLenum target, type s, type t, type r); \
void glMultiTexCoord3##suffix##vARB(GLenum target, type *t); \
void glMultiTexCoord4##suffix##ARB(GLenum target, type s, type t, type r, type q); \
void glMultiTexCoord4##suffix##vARB(GLenum target, type *t);
THUNK(b, GLbyte)
THUNK(d, GLdouble)
THUNK(i, GLint)
THUNK(s, GLshort)
THUNK(ub, GLubyte)
THUNK(ui, GLuint)
THUNK(us, GLushort)
#undef THUNK
#define THUNK(suffix, type) \
extern void glGet##suffix##v(GLenum pname, type *params);
THUNK(Double, GLdouble)
THUNK(Integer, GLint)
THUNK(Float, GLfloat)
#undef THUNK
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More