comparison android/testproject/jni/importgl.h @ 4704:611d39792201

Added minimal test project
author Paul Hunkin <paul@bieh.net>
date Thu, 17 Jun 2010 22:19:27 +1200
parents
children
comparison
equal deleted inserted replaced
4703:c93b44ddc63e 4704:611d39792201
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 /* Use DISABLE_IMPORTGL if you want to link the OpenGL ES at
40 * compile/link time and not import it dynamically runtime.
41 */
42 #ifndef DISABLE_IMPORTGL
43
44
45 /* Dynamically fetches pointers to the egl & gl functions.
46 * Should be called once on application initialization.
47 * Returns non-zero on success and 0 on failure.
48 */
49 extern int importGLInit();
50
51 /* Frees the handle to egl & gl functions library.
52 */
53 extern void importGLDeinit();
54
55
56 #ifndef IMPORTGL_API
57 #define IMPORTGL_API extern
58 #endif
59 #ifndef IMPORTGL_FNPTRINIT
60 #define IMPORTGL_FNPTRINIT
61 #endif
62
63 #define FNDEF(retType, funcName, args) IMPORTGL_API retType (*funcPtr_##funcName) args IMPORTGL_FNPTRINIT
64
65 #ifndef ANDROID_NDK
66 FNDEF(EGLBoolean, eglChooseConfig, (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config));
67 FNDEF(EGLContext, eglCreateContext, (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list));
68 FNDEF(EGLSurface, eglCreateWindowSurface, (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list));
69 FNDEF(EGLBoolean, eglDestroyContext, (EGLDisplay dpy, EGLContext ctx));
70 FNDEF(EGLBoolean, eglDestroySurface, (EGLDisplay dpy, EGLSurface surface));
71 FNDEF(EGLBoolean, eglGetConfigAttrib, (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value));
72 FNDEF(EGLBoolean, eglGetConfigs, (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config));
73 FNDEF(EGLDisplay, eglGetDisplay, (NativeDisplayType display));
74 FNDEF(EGLint, eglGetError, (void));
75 FNDEF(EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint *major, EGLint *minor));
76 FNDEF(EGLBoolean, eglMakeCurrent, (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx));
77 FNDEF(EGLBoolean, eglSwapBuffers, (EGLDisplay dpy, EGLSurface draw));
78 FNDEF(EGLBoolean, eglTerminate, (EGLDisplay dpy));
79 #endif /* !ANDROID_NDK */
80
81 FNDEF(void, glBlendFunc, (GLenum sfactor, GLenum dfactor));
82 FNDEF(void, glClear, (GLbitfield mask));
83 FNDEF(void, glClearColorx, (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha));
84 FNDEF(void, glColor4x, (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha));
85 FNDEF(void, glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
86 FNDEF(void, glDisable, (GLenum cap));
87 FNDEF(void, glDisableClientState, (GLenum array));
88 FNDEF(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count));
89 FNDEF(void, glEnable, (GLenum cap));
90 FNDEF(void, glEnableClientState, (GLenum array));
91 FNDEF(void, glFrustumx, (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar));
92 FNDEF(GLenum, glGetError, (void));
93 FNDEF(void, glLightxv, (GLenum light, GLenum pname, const GLfixed *params));
94 FNDEF(void, glLoadIdentity, (void));
95 FNDEF(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param));
96 FNDEF(void, glMaterialxv, (GLenum face, GLenum pname, const GLfixed *params));
97 FNDEF(void, glMatrixMode, (GLenum mode));
98 FNDEF(void, glMultMatrixx, (const GLfixed *m));
99 FNDEF(void, glNormalPointer, (GLenum type, GLsizei stride, const GLvoid *pointer));
100 FNDEF(void, glPopMatrix, (void));
101 FNDEF(void, glPushMatrix, (void));
102 FNDEF(void, glRotatex, (GLfixed angle, GLfixed x, GLfixed y, GLfixed z));
103 FNDEF(void, glScalex, (GLfixed x, GLfixed y, GLfixed z));
104 FNDEF(void, glShadeModel, (GLenum mode));
105 FNDEF(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z));
106 FNDEF(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer));
107 FNDEF(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height));
108
109
110 #undef FN
111 #define FNPTR(name) funcPtr_##name
112
113 #ifndef IMPORTGL_NO_FNPTR_DEFS
114
115 // Redirect egl* and gl* function calls to funcPtr_egl* and funcPtr_gl*.
116
117 #ifndef ANDROID_NDK
118 #define eglChooseConfig FNPTR(eglChooseConfig)
119 #define eglCreateContext FNPTR(eglCreateContext)
120 #define eglCreateWindowSurface FNPTR(eglCreateWindowSurface)
121 #define eglDestroyContext FNPTR(eglDestroyContext)
122 #define eglDestroySurface FNPTR(eglDestroySurface)
123 #define eglGetConfigAttrib FNPTR(eglGetConfigAttrib)
124 #define eglGetConfigs FNPTR(eglGetConfigs)
125 #define eglGetDisplay FNPTR(eglGetDisplay)
126 #define eglGetError FNPTR(eglGetError)
127 #define eglInitialize FNPTR(eglInitialize)
128 #define eglMakeCurrent FNPTR(eglMakeCurrent)
129 #define eglSwapBuffers FNPTR(eglSwapBuffers)
130 #define eglTerminate FNPTR(eglTerminate)
131 #endif /* !ANDROID_NDK */
132
133 #define glBlendFunc FNPTR(glBlendFunc)
134 #define glClear FNPTR(glClear)
135 #define glClearColorx FNPTR(glClearColorx)
136 #define glColor4x FNPTR(glColor4x)
137 #define glColorPointer FNPTR(glColorPointer)
138 #define glDisable FNPTR(glDisable)
139 #define glDisableClientState FNPTR(glDisableClientState)
140 #define glDrawArrays FNPTR(glDrawArrays)
141 #define glEnable FNPTR(glEnable)
142 #define glEnableClientState FNPTR(glEnableClientState)
143 #define glFrustumx FNPTR(glFrustumx)
144 #define glGetError FNPTR(glGetError)
145 #define glLightxv FNPTR(glLightxv)
146 #define glLoadIdentity FNPTR(glLoadIdentity)
147 #define glMaterialx FNPTR(glMaterialx)
148 #define glMaterialxv FNPTR(glMaterialxv)
149 #define glMatrixMode FNPTR(glMatrixMode)
150 #define glMultMatrixx FNPTR(glMultMatrixx)
151 #define glNormalPointer FNPTR(glNormalPointer)
152 #define glPopMatrix FNPTR(glPopMatrix)
153 #define glPushMatrix FNPTR(glPushMatrix)
154 #define glRotatex FNPTR(glRotatex)
155 #define glScalex FNPTR(glScalex)
156 #define glShadeModel FNPTR(glShadeModel)
157 #define glTranslatex FNPTR(glTranslatex)
158 #define glVertexPointer FNPTR(glVertexPointer)
159 #define glViewport FNPTR(glViewport)
160
161 #endif // !IMPORTGL_NO_FNPTR_DEFS
162
163
164 #endif // !DISABLE_IMPORTGL
165
166
167 #ifdef __cplusplus
168 }
169 #endif
170
171
172 #endif // !IMPORTGL_H_INCLUDED