From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / jwxyz / jwzglesI.h
1 /* xscreensaver, Copyright (c) 2012-2015 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  */
11
12 /* A compatibility shim to allow OpenGL 1.3 source code to work in an
13    OpenGLES environment, where almost every OpenGL 1.3 function has
14    been "deprecated".  See jwzgles.c for details.
15  */
16
17 #ifndef __JWZGLES_I_H__
18 #define __JWZGLES_I_H__
19
20 #ifdef GL_VERSION_ES_CM_1_0  /* compiling against OpenGLES 1.x */
21
22 /* These OpenGL 1.3 constants are not present in OpenGLES 1.
23    Fortunately, it looks like they didn't re-use any of the numbers,
24    so we can just keep using the OpenGL 1.3 values.  I'm actually
25    kind of shocked that the GLES folks passed up that opportunity
26    for further clusterfuckery.
27  */
28 # define GLdouble double
29
30 # define GL_ACCUM_BUFFER_BIT                    0x00000200
31 # define GL_ALL_ATTRIB_BITS                     0x000FFFFF
32 # define GL_AUTO_NORMAL                         0x0D80
33 # define GL_BLEND_SRC_ALPHA                     0x80CB
34 # define GL_C3F_V3F                             0x2A24
35 # define GL_C4F_N3F_V3F                         0x2A26
36 # define GL_C4UB_V2F                            0x2A22
37 # define GL_C4UB_V3F                            0x2A23
38 # define GL_CLAMP                               0x2900
39 # define GL_COLOR_BUFFER_BIT                    0x00004000
40 # define GL_COLOR_MATERIAL_FACE                 0x0B55
41 # define GL_COLOR_MATERIAL_PARAMETER            0x0B56
42 # define GL_COMPILE                             0x1300
43 # define GL_CURRENT_BIT                         0x00000001
44 # define GL_DEPTH_BUFFER_BIT                    0x00000100
45 # define GL_DOUBLEBUFFER                        0x0C32
46 # define GL_ENABLE_BIT                          0x00002000
47 # define GL_EVAL_BIT                            0x00010000
48 # define GL_EYE_LINEAR                          0x2400
49 # define GL_EYE_PLANE                           0x2502
50 # define GL_FEEDBACK                            0x1C01
51 # define GL_FILL                                0x1B02
52 # define GL_FOG_BIT                             0x00000080
53 # define GL_HINT_BIT                            0x00008000
54 # define GL_INTENSITY                           0x8049
55 # define GL_LIGHTING_BIT                        0x00000040
56 # define GL_LIGHT_MODEL_COLOR_CONTROL           0x81F8
57 # define GL_LIGHT_MODEL_LOCAL_VIEWER            0x0B51
58 # define GL_LINE                                0x1B01
59 # define GL_LINE_BIT                            0x00000004
60 # define GL_LIST_BIT                            0x00020000
61 # define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT      0x84FF
62 # define GL_N3F_V3F                             0x2A25
63 # define GL_OBJECT_LINEAR                       0x2401
64 # define GL_OBJECT_PLANE                        0x2501
65 # define GL_PIXEL_MODE_BIT                      0x00000020
66 # define GL_POINT_BIT                           0x00000002
67 # define GL_POLYGON                             0x0009
68 # define GL_POLYGON_BIT                         0x00000008
69 # define GL_POLYGON_MODE                        0x0B40
70 # define GL_POLYGON_SMOOTH                      0x0B41
71 # define GL_POLYGON_STIPPLE                     0x0B42
72 # define GL_POLYGON_STIPPLE_BIT                 0x00000010
73 # define GL_Q                                   0x2003
74 # define GL_QUADS                               0x0007
75 # define GL_QUAD_STRIP                          0x0008
76 # define GL_R                                   0x2002
77 # define GL_RENDER                              0x1C00
78 # define GL_RGBA_MODE                           0x0C31
79 # define GL_S                                   0x2000
80 # define GL_SCISSOR_BIT                         0x00080000
81 # define GL_SELECT                              0x1C02
82 # define GL_SEPARATE_SPECULAR_COLOR             0x81FA
83 # define GL_SINGLE_COLOR                        0x81F9
84 # define GL_SPHERE_MAP                          0x2402
85 # define GL_STENCIL_BUFFER_BIT                  0x00000400
86 # define GL_T                                   0x2001
87 # define GL_T2F_C3F_V3F                         0x2A2A
88 # define GL_T2F_C4F_N3F_V3F                     0x2A2C
89 # define GL_T2F_C4UB_V3F                        0x2A29
90 # define GL_T2F_N3F_V3F                         0x2A2B
91 # define GL_T2F_V3F                             0x2A27
92 # define GL_T4F_C4F_N3F_V4F                     0x2A2D
93 # define GL_T4F_V4F                             0x2A28
94 # define GL_TEXTURE_1D                          0x0DE0
95 # define GL_TEXTURE_ALPHA_SIZE                  0x805F
96 # define GL_TEXTURE_BIT                         0x00040000
97 # define GL_TEXTURE_BLUE_SIZE                   0x805E
98 # define GL_TEXTURE_BORDER                      0x1005
99 # define GL_TEXTURE_BORDER_COLOR                0x1004
100 # define GL_TEXTURE_COMPONENTS                  0x1003
101 # define GL_TEXTURE_GEN_MODE                    0x2500
102 # define GL_TEXTURE_GEN_Q                       0x0C63
103 # define GL_TEXTURE_GEN_R                       0x0C62
104 # define GL_TEXTURE_GEN_S                       0x0C60
105 # define GL_TEXTURE_GEN_T                       0x0C61
106 # define GL_TEXTURE_GREEN_SIZE                  0x805D
107 # define GL_TEXTURE_HEIGHT                      0x1001
108 # define GL_TEXTURE_INTENSITY_SIZE              0x8061
109 # define GL_TEXTURE_LUMINANCE_SIZE              0x8060
110 # define GL_TEXTURE_MAX_ANISOTROPY_EXT          0x84FE
111 # define GL_TEXTURE_RED_SIZE                    0x805C
112 # define GL_TEXTURE_WIDTH                       0x1000
113 # define GL_TRANSFORM_BIT                       0x00001000
114 # define GL_UNPACK_ROW_LENGTH                   0x0CF2
115 # define GL_UNSIGNED_INT_8_8_8_8_REV            0x8367
116 # define GL_V2F                                 0x2A20
117 # define GL_V3F                                 0x2A21
118 # define GL_VIEWPORT_BIT                        0x00000800
119 # define GL_INT                                 0x1404
120 # define GL_DOUBLE                              0x140A
121
122 #endif
123
124
125 typedef struct jwzgles_state jwzgles_state;
126
127 extern jwzgles_state *jwzgles_make_state (void);
128 extern void jwzgles_free_state (void);
129 extern void jwzgles_make_current (jwzgles_state *);
130
131
132 /* Prototypes for the things re-implemented in jwzgles.c 
133  */
134
135 extern int  jwzgles_glGenLists (int n);
136 extern void jwzgles_glNewList (int id, int mode);
137 extern void jwzgles_glEndList (void);
138 extern void jwzgles_glDeleteLists (int list, int range);
139 extern void jwzgles_glBegin (int mode);
140 extern void jwzgles_glNormal3fv (const GLfloat *);
141 extern void jwzgles_glNormal3f (GLfloat x, GLfloat y, GLfloat z);
142 extern void jwzgles_glTexCoord1f (GLfloat s);
143 extern void jwzgles_glTexCoord2fv (const GLfloat *);
144 extern void jwzgles_glTexCoord2f (GLfloat s, GLfloat t);
145 extern void jwzgles_glTexCoord3fv (const GLfloat *);
146 extern void jwzgles_glTexCoord3f (GLfloat s, GLfloat t, GLfloat r);
147 extern void jwzgles_glTexCoord4fv (const GLfloat *);
148 extern void jwzgles_glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q);
149 extern void jwzgles_glVertex2f (GLfloat x, GLfloat y);
150 extern void jwzgles_glVertex2dv (const GLdouble *);
151 extern void jwzgles_glVertex2fv (const GLfloat *);
152 extern void jwzgles_glVertex2i (GLint x, GLint y);
153 extern void jwzgles_glVertex3f (GLfloat x, GLfloat y, GLfloat z);
154 extern void jwzgles_glVertex3dv (const GLdouble *);
155 extern void jwzgles_glVertex3fv (const GLfloat *);
156 extern void jwzgles_glVertex3i (GLint x, GLint y, GLint z);
157 extern void jwzgles_glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
158 extern void jwzgles_glVertex4fv (const GLfloat *);
159 extern void jwzgles_glVertex4i (GLint x, GLint y, GLint z, GLint w);
160 extern void jwzgles_glEnd (void);
161 extern void jwzgles_glCallList (int id);
162 extern void jwzgles_glClearIndex(GLfloat c);
163 extern void jwzgles_glBitmap (GLsizei, GLsizei, GLfloat, GLfloat, GLfloat,
164                               GLfloat, const GLubyte *);
165 extern void jwzgles_glPushAttrib(int);
166 extern void jwzgles_glPopAttrib(void);
167
168
169 /* These functions are present in both OpenGL 1.3 and in OpenGLES 1,
170    but are allowed within glNewList/glEndList, so we must wrap them
171    to allow them to be recorded.
172  */
173 extern void jwzgles_glActiveTexture (GLuint);
174 extern void jwzgles_glBindTexture (GLuint, GLuint);
175 extern void jwzgles_glBlendFunc (GLuint, GLuint);
176 extern void jwzgles_glClear (GLuint);
177 extern void jwzgles_glClearColor (GLclampf, GLclampf, GLclampf, GLclampf);
178 extern void jwzgles_glClearStencil (GLuint);
179 extern void jwzgles_glColorMask (GLuint, GLuint, GLuint, GLuint);
180 extern void jwzgles_glCullFace (GLuint);
181 extern void jwzgles_glDepthFunc (GLuint);
182 extern void jwzgles_glDepthMask (GLuint);
183 extern void jwzgles_glDisable (GLuint);
184 extern void jwzgles_glDrawArrays (GLuint, GLuint, GLuint);
185 extern GLboolean jwzgles_glIsEnabled (GLuint);
186 extern void jwzgles_glEnable (GLuint);
187 extern void jwzgles_glFrontFace (GLuint);
188 extern void jwzgles_glHint (GLuint, GLuint);
189 extern void jwzgles_glLineWidth (GLfloat);
190 extern void jwzgles_glLoadIdentity (void);
191 extern void jwzgles_glLogicOp (GLuint);
192 extern void jwzgles_glMatrixMode (GLuint);
193 extern void jwzgles_glMultMatrixf (const GLfloat *);
194 extern void jwzgles_glPointSize (GLfloat);
195 extern void jwzgles_glPolygonOffset (GLfloat, GLfloat);
196 extern void jwzgles_glPopMatrix (void);
197 extern void jwzgles_glPushMatrix (void);
198 extern void jwzgles_glScissor (GLuint, GLuint, GLuint, GLuint);
199 extern void jwzgles_glShadeModel (GLuint);
200 extern void jwzgles_glStencilFunc (GLuint, GLuint, GLuint);
201 extern void jwzgles_glStencilMask (GLuint);
202 extern void jwzgles_glStencilOp (GLuint, GLuint, GLuint);
203 extern void jwzgles_glViewport (GLuint, GLuint, GLuint, GLuint);
204 extern void jwzgles_glTranslatef (GLfloat, GLfloat, GLfloat);
205 extern void jwzgles_glRotatef (GLfloat, GLfloat, GLfloat, GLfloat);
206 extern void jwzgles_glRotated (GLdouble, GLdouble x, GLdouble y, GLdouble z);
207 extern void jwzgles_glScalef (GLfloat, GLfloat, GLfloat);
208 extern void jwzgles_glColor3f (GLfloat, GLfloat, GLfloat);
209 extern void jwzgles_glColor4f (GLfloat, GLfloat, GLfloat, GLfloat);
210 extern void jwzgles_glColor3fv (const GLfloat *);
211 extern void jwzgles_glColor4fv (const GLfloat *);
212 extern void jwzgles_glColor3s (GLshort, GLshort, GLshort);
213 extern void jwzgles_glColor4s (GLshort, GLshort, GLshort, GLshort);
214 extern void jwzgles_glColor3sv (const GLshort *);
215 extern void jwzgles_glColor4sv (const GLshort *);
216 extern void jwzgles_glColor3us (GLushort, GLushort, GLushort);
217 extern void jwzgles_glColor4us (GLushort, GLushort, GLushort, GLushort);
218 extern void jwzgles_glColor3usv (const GLushort *);
219 extern void jwzgles_glColor4usv (const GLushort *);
220 extern void jwzgles_glColor3d (GLdouble, GLdouble, GLdouble);
221 extern void jwzgles_glColor4d (GLdouble, GLdouble, GLdouble, GLdouble);
222 extern void jwzgles_glColor3dv (const GLdouble *);
223 extern void jwzgles_glColor4dv (const GLdouble *);
224 extern void jwzgles_glColor4i (GLint, GLint, GLint, GLint);
225 extern void jwzgles_glColor3i (GLint, GLint, GLint);
226 extern void jwzgles_glColor3iv (const GLint *);
227 extern void jwzgles_glColor4iv (const GLint *);
228 extern void jwzgles_glColor4ui (GLuint, GLuint, GLuint, GLuint);
229 extern void jwzgles_glColor3ui (GLuint, GLuint, GLuint);
230 extern void jwzgles_glColor3uiv (const GLuint *);
231 extern void jwzgles_glColor4uiv (const GLuint *);
232 extern void jwzgles_glColor4b (GLbyte, GLbyte, GLbyte, GLbyte);
233 extern void jwzgles_glColor3b (GLbyte, GLbyte, GLbyte);
234 extern void jwzgles_glColor4bv (const GLbyte *);
235 extern void jwzgles_glColor3bv (const GLbyte *);
236 extern void jwzgles_glColor4ub (GLubyte, GLubyte, GLubyte, GLubyte);
237 extern void jwzgles_glColor3ub (GLubyte, GLubyte, GLubyte);
238 extern void jwzgles_glColor4ubv (const GLubyte *);
239 extern void jwzgles_glColor3ubv (const GLubyte *);
240 extern void jwzgles_glMaterialf (GLuint, GLuint, GLfloat);
241 extern void jwzgles_glMateriali (GLuint, GLuint, GLuint);
242 extern void jwzgles_glMaterialfv (GLuint, GLuint, const GLfloat *);
243 extern void jwzgles_glMaterialiv (GLuint, GLuint, const GLint *);
244 extern void jwzgles_glFinish (void);
245 extern void jwzgles_glFlush (void);
246 extern void jwzgles_glPixelStorei (GLuint, GLuint);
247 extern void jwzgles_glEnableClientState (GLuint);
248 extern void jwzgles_glDisableClientState (GLuint);
249
250 extern void jwzgles_glInitNames (void);
251 extern void jwzgles_glPushName (GLuint);
252 extern GLuint jwzgles_glPopName (void);
253 extern GLuint jwzgles_glRenderMode (GLuint);
254 extern void jwzgles_glSelectBuffer (GLsizei, GLuint *);
255 extern void jwzgles_glLightf (GLenum, GLenum, GLfloat);
256 extern void jwzgles_glLighti (GLenum, GLenum, GLint);
257 extern void jwzgles_glLightfv (GLenum, GLenum, const GLfloat *);
258 extern void jwzgles_glLightiv (GLenum, GLenum, const GLint *);
259 extern void jwzgles_glLightModelf (GLenum, GLfloat);
260 extern void jwzgles_glLightModeli (GLenum, GLint);
261 extern void jwzgles_glLightModelfv (GLenum, const GLfloat *);
262 extern void jwzgles_glLightModeliv (GLenum, const GLint *);
263 extern void jwzgles_glGenTextures (GLuint, GLuint *);
264 extern void jwzgles_glFrustum (GLfloat, GLfloat, GLfloat, GLfloat,
265                                GLfloat, GLfloat);
266 extern void jwzgles_glOrtho (GLfloat, GLfloat, GLfloat, GLfloat, 
267                              GLfloat, GLfloat);
268 extern void jwzgles_glTexImage1D (GLenum target, GLint level,
269                                   GLint internalFormat,
270                                   GLsizei width, GLint border,
271                                   GLenum format, GLenum type,
272                                   const GLvoid *pixels);
273 extern void jwzgles_glTexImage2D (GLenum target,
274                                   GLint         level,
275                                   GLint         internalFormat,
276                                   GLsizei       width,
277                                   GLsizei       height,
278                                   GLint         border,
279                                   GLenum        format,
280                                   GLenum        type,
281                                   const GLvoid *data);
282 extern void jwzgles_glTexSubImage2D (GLenum target, GLint level,
283                                      GLint xoffset, GLint yoffset,
284                                      GLsizei width, GLsizei height,
285                                      GLenum format, GLenum type,
286                                      const GLvoid *pixels);
287 extern void jwzgles_glCopyTexImage2D (GLenum target, GLint level, 
288                                       GLenum internalformat,
289                                       GLint x, GLint y, 
290                                       GLsizei width, GLsizei height, 
291                                       GLint border);
292 extern void jwzgles_glInterleavedArrays (GLenum, GLsizei, const GLvoid *);
293 extern void jwzgles_glTexEnvf (GLuint, GLuint, GLfloat);
294 extern void jwzgles_glTexEnvi (GLuint, GLuint, GLuint);
295 extern void jwzgles_glTexParameterf (GLuint, GLuint, GLfloat);
296 extern void jwzgles_glTexParameteri (GLuint, GLuint, GLuint);
297 extern void jwzgles_glTexGeni (GLenum, GLenum, GLint);
298 extern void jwzgles_glTexGenfv (GLenum, GLenum, const GLfloat *);
299 extern void jwzgles_glGetTexGenfv (GLenum, GLenum, GLfloat *);
300 extern void jwzgles_glRectf (GLfloat, GLfloat, GLfloat, GLfloat);
301 extern void jwzgles_glRecti (GLint, GLint, GLint, GLint);
302 extern void jwzgles_glLightModelfv (GLenum, const GLfloat *);
303 extern void jwzgles_glClearDepth (GLfloat);
304 extern GLboolean jwzgles_glIsList (GLuint);
305 extern void jwzgles_glColorMaterial (GLenum, GLenum);
306 extern void jwzgles_glPolygonMode (GLenum, GLenum);
307 extern void jwzgles_glFogf (GLenum, GLfloat);
308 extern void jwzgles_glFogi (GLenum, GLint);
309 extern void jwzgles_glFogfv (GLenum, const GLfloat *);
310 extern void jwzgles_glFogiv (GLenum, const GLint *);
311 extern void jwzgles_glAlphaFunc (GLenum, GLfloat);
312 extern void jwzgles_glClipPlane (GLenum, const GLdouble *);
313 extern void jwzgles_glDrawBuffer (GLenum);
314 extern void jwzgles_glDeleteTextures (GLuint, const GLuint *);
315
316 extern void jwzgles_gluPerspective (GLdouble fovy, GLdouble aspect, 
317                                     GLdouble near, GLdouble far);
318 extern void jwzgles_gluLookAt (GLfloat eyex, GLfloat eyey, GLfloat eyez,
319                                GLfloat centerx, GLfloat centery, 
320                                GLfloat centerz,
321                                GLfloat upx, GLfloat upy, GLfloat upz);
322 extern GLint jwzgles_gluProject (GLdouble objx, GLdouble objy, GLdouble objz, 
323                                  const GLdouble modelMatrix[16], 
324                                  const GLdouble projMatrix[16],
325                                  const GLint viewport[4],
326                                  GLdouble *winx, GLdouble *winy, 
327                                  GLdouble *winz);
328 extern int jwzgles_gluBuild2DMipmaps (GLenum target,
329                                       GLint internalFormat,
330                                       GLsizei width,
331                                       GLsizei height,
332                                       GLenum format,
333                                       GLenum type,
334                                       const GLvoid *data);
335 extern GLboolean jwzgles_gluCheckExtension (const GLubyte *ext_name,
336                                             const GLubyte *ext_string);
337 extern void jwzgles_glGetFloatv (GLenum pname, GLfloat *params);
338 extern void jwzgles_glGetPointerv (GLenum pname, GLvoid **params);
339 extern void jwzgles_glGetDoublev (GLenum pname, GLdouble *params);
340 extern void jwzgles_glGetIntegerv (GLenum pname, GLint *params);
341 extern void jwzgles_glGetBooleanv (GLenum pname, GLboolean *params);
342 extern void jwzgles_glVertexPointer (GLuint, GLuint, GLuint, const void *);
343 extern void jwzgles_glNormalPointer (GLenum, GLuint, const void *);
344 extern void jwzgles_glColorPointer (GLuint, GLuint, GLuint, const void *);
345 extern void jwzgles_glTexCoordPointer (GLuint, GLuint, GLuint, const void *);
346 extern void jwzgles_glBindBuffer (GLuint, GLuint);
347 extern void jwzgles_glBufferData (GLenum, GLsizeiptr, const void *, GLenum);
348 extern const char *jwzgles_gluErrorString (GLenum error);
349
350 #endif /* __JWZGLES_I_H__ */