| 1 |
/* San Angeles Observation OpenGL ES version example |
| 2 |
* Copyright 2004-2005 Jetro Lauha |
| 3 |
* All rights reserved. |
| 4 |
* Web: http://iki.fi/jetro/ |
| 5 |
* |
| 6 |
* This source is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of EITHER: |
| 8 |
* (1) The GNU Lesser General Public License as published by the Free |
| 9 |
* Software Foundation; either version 2.1 of the License, or (at |
| 10 |
* your option) any later version. The text of the GNU Lesser |
| 11 |
* General Public License is included with this source in the |
| 12 |
* file LICENSE-LGPL.txt. |
| 13 |
* (2) The BSD-style license that is included with this source in |
| 14 |
* the file LICENSE-BSD.txt. |
| 15 |
* |
| 16 |
* This source is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files |
| 19 |
* LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. |
| 20 |
* |
| 21 |
* $Id: importgl.h,v 1.4 2005/02/24 20:29:33 tonic Exp $ |
| 22 |
* $Revision: 1.4 $ |
| 23 |
*/ |
| 24 |
|
| 25 |
#ifndef IMPORTGL_H_INCLUDED |
| 26 |
#define IMPORTGL_H_INCLUDED |
| 27 |
|
| 28 |
|
| 29 |
#ifdef __cplusplus |
| 30 |
extern "C" { |
| 31 |
#endif |
| 32 |
|
| 33 |
|
| 34 |
#include <GLES/gl.h> |
| 35 |
#ifndef ANDROID_NDK |
| 36 |
#include <GLES/egl.h> |
| 37 |
#endif /* !ANDROID_NDK */ |
| 38 |
|
| 39 |
/* Dynamically fetches pointers to the egl & gl functions. |
| 40 |
* Should be called once on application initialization. |
| 41 |
* Returns non-zero on success and 0 on failure. |
| 42 |
*/ |
| 43 |
extern int importGLInit(); |
| 44 |
|
| 45 |
/* Frees the handle to egl & gl functions library. |
| 46 |
*/ |
| 47 |
extern void importGLDeinit(); |
| 48 |
|
| 49 |
/* Use DISABLE_IMPORTGL if you want to link the OpenGL ES at |
| 50 |
* compile/link time and not import it dynamically runtime. |
| 51 |
*/ |
| 52 |
#ifndef DISABLE_IMPORTGL |
| 53 |
|
| 54 |
|
| 55 |
#ifndef IMPORTGL_API |
| 56 |
#define IMPORTGL_API extern |
| 57 |
#endif |
| 58 |
#ifndef IMPORTGL_FNPTRINIT |
| 59 |
#define IMPORTGL_FNPTRINIT |
| 60 |
#endif |
| 61 |
|
| 62 |
#define FNDEF(retType, funcName, args) IMPORTGL_API retType (*funcPtr_##funcName) args IMPORTGL_FNPTRINIT |
| 63 |
|
| 64 |
#ifndef ANDROID_NDK |
| 65 |
FNDEF(EGLBoolean, eglChooseConfig, (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config)); |
| 66 |
FNDEF(EGLContext, eglCreateContext, (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list)); |
| 67 |
FNDEF(EGLSurface, eglCreateWindowSurface, (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list)); |
| 68 |
FNDEF(EGLBoolean, eglDestroyContext, (EGLDisplay dpy, EGLContext ctx)); |
| 69 |
FNDEF(EGLBoolean, eglDestroySurface, (EGLDisplay dpy, EGLSurface surface)); |
| 70 |
FNDEF(EGLBoolean, eglGetConfigAttrib, (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value)); |
| 71 |
FNDEF(EGLBoolean, eglGetConfigs, (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)); |
| 72 |
FNDEF(EGLDisplay, eglGetDisplay, (NativeDisplayType display)); |
| 73 |
FNDEF(EGLint, eglGetError, (void)); |
| 74 |
FNDEF(EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint *major, EGLint *minor)); |
| 75 |
FNDEF(EGLBoolean, eglMakeCurrent, (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)); |
| 76 |
FNDEF(EGLBoolean, eglSwapBuffers, (EGLDisplay dpy, EGLSurface draw)); |
| 77 |
FNDEF(EGLBoolean, eglTerminate, (EGLDisplay dpy)); |
| 78 |
#endif /* !ANDROID_NDK */ |
| 79 |
|
| 80 |
FNDEF(void, glBlendFunc, (GLenum sfactor, GLenum dfactor)); |
| 81 |
FNDEF(void, glClear, (GLbitfield mask)); |
| 82 |
FNDEF(void, glClearColorx, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)); |
| 83 |
FNDEF(void, glColor4x, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)); |
| 84 |
FNDEF(void, glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)); |
| 85 |
FNDEF(void, glDisable, (GLenum cap)); |
| 86 |
FNDEF(void, glDisableClientState, (GLenum array)); |
| 87 |
FNDEF(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)); |
| 88 |
FNDEF(void, glEnable, (GLenum cap)); |
| 89 |
FNDEF(void, glEnableClientState, (GLenum array)); |
| 90 |
FNDEF(void, glFrustumx, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)); |
| 91 |
FNDEF(GLenum, glGetError, (void)); |
| 92 |
FNDEF(void, glLightxv, (GLenum light, GLenum pname, const GLfixed *params)); |
| 93 |
FNDEF(void, glLoadIdentity, (void)); |
| 94 |
FNDEF(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param)); |
| 95 |
FNDEF(void, glMaterialxv, (GLenum face, GLenum pname, const GLfixed *params)); |
| 96 |
FNDEF(void, glMatrixMode, (GLenum mode)); |
| 97 |
FNDEF(void, glMultMatrixx, (const GLfixed *m)); |
| 98 |
FNDEF(void, glNormalPointer, (GLenum type, GLsizei stride, const GLvoid *pointer)); |
| 99 |
FNDEF(void, glPopMatrix, (void)); |
| 100 |
FNDEF(void, glPushMatrix, (void)); |
| 101 |
FNDEF(void, glRotatex, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z)); |
| 102 |
FNDEF(void, glScalex, (GLfixed x, GLfixed y, GLfixed z)); |
| 103 |
FNDEF(void, glShadeModel, (GLenum mode)); |
| 104 |
FNDEF(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z)); |
| 105 |
FNDEF(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)); |
| 106 |
FNDEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)); |
| 107 |
|
| 108 |
|
| 109 |
#undef FN |
| 110 |
#define FNPTR(name) funcPtr_##name |
| 111 |
|
| 112 |
#ifndef IMPORTGL_NO_FNPTR_DEFS |
| 113 |
|
| 114 |
// Redirect egl* and gl* function calls to funcPtr_egl* and funcPtr_gl*. |
| 115 |
|
| 116 |
#ifndef ANDROID_NDK |
| 117 |
#define eglChooseConfig FNPTR(eglChooseConfig) |
| 118 |
#define eglCreateContext FNPTR(eglCreateContext) |
| 119 |
#define eglCreateWindowSurface FNPTR(eglCreateWindowSurface) |
| 120 |
#define eglDestroyContext FNPTR(eglDestroyContext) |
| 121 |
#define eglDestroySurface FNPTR(eglDestroySurface) |
| 122 |
#define eglGetConfigAttrib FNPTR(eglGetConfigAttrib) |
| 123 |
#define eglGetConfigs FNPTR(eglGetConfigs) |
| 124 |
#define eglGetDisplay FNPTR(eglGetDisplay) |
| 125 |
#define eglGetError FNPTR(eglGetError) |
| 126 |
#define eglInitialize FNPTR(eglInitialize) |
| 127 |
#define eglMakeCurrent FNPTR(eglMakeCurrent) |
| 128 |
#define eglSwapBuffers FNPTR(eglSwapBuffers) |
| 129 |
#define eglTerminate FNPTR(eglTerminate) |
| 130 |
#endif /* !ANDROID_NDK */ |
| 131 |
|
| 132 |
#define glBlendFunc FNPTR(glBlendFunc) |
| 133 |
#define glClear FNPTR(glClear) |
| 134 |
#define glClearColorx FNPTR(glClearColorx) |
| 135 |
#define glColor4x FNPTR(glColor4x) |
| 136 |
#define glColorPointer FNPTR(glColorPointer) |
| 137 |
#define glDisable FNPTR(glDisable) |
| 138 |
#define glDisableClientState FNPTR(glDisableClientState) |
| 139 |
#define glDrawArrays FNPTR(glDrawArrays) |
| 140 |
#define glEnable FNPTR(glEnable) |
| 141 |
#define glEnableClientState FNPTR(glEnableClientState) |
| 142 |
#define glFrustumx FNPTR(glFrustumx) |
| 143 |
#define glGetError FNPTR(glGetError) |
| 144 |
#define glLightxv FNPTR(glLightxv) |
| 145 |
#define glLoadIdentity FNPTR(glLoadIdentity) |
| 146 |
#define glMaterialx FNPTR(glMaterialx) |
| 147 |
#define glMaterialxv FNPTR(glMaterialxv) |
| 148 |
#define glMatrixMode FNPTR(glMatrixMode) |
| 149 |
#define glMultMatrixx FNPTR(glMultMatrixx) |
| 150 |
#define glNormalPointer FNPTR(glNormalPointer) |
| 151 |
#define glPopMatrix FNPTR(glPopMatrix) |
| 152 |
#define glPushMatrix FNPTR(glPushMatrix) |
| 153 |
#define glRotatex FNPTR(glRotatex) |
| 154 |
#define glScalex FNPTR(glScalex) |
| 155 |
#define glShadeModel FNPTR(glShadeModel) |
| 156 |
#define glTranslatex FNPTR(glTranslatex) |
| 157 |
#define glVertexPointer FNPTR(glVertexPointer) |
| 158 |
#define glViewport FNPTR(glViewport) |
| 159 |
|
| 160 |
#endif // !IMPORTGL_NO_FNPTR_DEFS |
| 161 |
|
| 162 |
|
| 163 |
#endif // !DISABLE_IMPORTGL |
| 164 |
|
| 165 |
|
| 166 |
#ifdef __cplusplus |
| 167 |
} |
| 168 |
#endif |
| 169 |
|
| 170 |
|
| 171 |
#endif // !IMPORTGL_H_INCLUDED |