Build in Maemo/scratchbox
[neverball] / share / glext.h
1 /*
2  * Copyright (C) 2003-2011 Neverball authors
3  *
4  * NEVERBALL is  free software; you can redistribute  it and/or modify
5  * it under the  terms of the GNU General  Public License as published
6  * by the Free  Software Foundation; either version 2  of the License,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
11  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
12  * General Public License for more details.
13  */
14
15 #ifndef GLEXT_H
16 #define GLEXT_H
17
18 /*---------------------------------------------------------------------------*/
19 /* Include the system OpenGL headers.                                        */
20
21 #ifdef _WIN32
22 #define WIN32_LEAN_AND_MEAN
23 #include <windows.h>
24 #endif
25
26 #ifdef __APPLE__
27 #include <OpenGL/gl.h>
28 #elif defined(__MAEMO__)
29 #include <GLES/gl.h>
30 #else
31 #include <GL/gl.h>
32 #endif
33
34 #ifdef _WIN32
35 #include <GL/glext.h>
36 #endif
37
38 /*---------------------------------------------------------------------------*/
39
40 #ifndef GL_MULTISAMPLE
41 #define GL_MULTISAMPLE                0x809D
42 #endif
43
44 #ifndef GL_TEXTURE0
45 #define GL_TEXTURE0                   0x84C0
46 #endif
47
48 #ifndef GL_TEXTURE1
49 #define GL_TEXTURE1                   0x84C1
50 #endif
51
52 #ifndef GL_TEXTURE2
53 #define GL_TEXTURE2                   0x84C2
54 #endif
55
56 #ifndef GL_ARRAY_BUFFER
57 #define GL_ARRAY_BUFFER               0x8892
58 #endif
59
60 #ifndef GL_ELEMENT_ARRAY_BUFFER
61 #define GL_ELEMENT_ARRAY_BUFFER       0x8893
62 #endif
63
64 #ifndef GL_STATC_DRAW
65 #define GL_STATIC_DRAW                0x88E4
66 #endif
67
68 #ifndef GL_DYNAMIC_DRAW
69 #define GL_DYNAMIC_DRAW               0x88E8
70 #endif
71
72 #ifndef GL_POINT_SPRITE
73 #define GL_POINT_SPRITE               0x8861
74 #endif
75
76 #ifndef GL_COORD_REPLACE
77 #define GL_COORD_REPLACE              0x8862
78 #endif
79
80 #ifndef GL_POINT_DISTANCE_ATTENUATIAN
81 #define GL_POINT_DISTANCE_ATTENUATION 0x8129
82 #endif
83
84 /*---------------------------------------------------------------------------*/
85
86 int glext_check(const char *);
87 int glext_init(void);
88
89 /*---------------------------------------------------------------------------*/
90
91 /* Exercise extreme paranoia in defining a cross-platform OpenGL interface.  */
92 /* If we're compiling against OpenGL ES then we must assume native linkage   */
93 /* of the extensions we use. Otherwise, GetProc them regardless of whether   */
94 /* they need it or not.                                                      */
95
96 #if defined(GL_VERSION_ES_CM_1_0) || \
97     defined(GL_VERSION_ES_CM_1_1) || \
98     defined(GL_OES_VERSION_1_0)
99
100 #define ENABLE_OPENGLES 1
101
102 #define glClientActiveTexture_ glClientActiveTexture
103 #define glActiveTexture_       glActiveTexture
104 #define glGenBuffers_          glGenBuffers
105 #define glBindBuffer_          glBindBuffer
106 #define glBufferData_          glBufferData
107 #define glBufferSubData_       glBufferSubData
108 #define glDeleteBuffers_       glDeleteBuffers
109 #define glIsBuffer_            glIsBuffer
110 #define glPointParameterfv_    glPointParameterfv
111
112 #define glOrtho_               glOrthof
113
114 #else /* No native linkage?  Define the extension API. */
115
116 #define glOrtho_               glOrtho
117
118 /*---------------------------------------------------------------------------*/
119 /* ARB_multitexture                                                          */
120
121 typedef void (*PFNGLACTIVETEXTURE_PROC)(GLenum);
122 typedef void (*PFNGLCLIENTACTIVETEXTURE_PROC)(GLenum);
123
124 extern PFNGLCLIENTACTIVETEXTURE_PROC glClientActiveTexture_;
125 extern PFNGLACTIVETEXTURE_PROC       glActiveTexture_;
126
127 /*---------------------------------------------------------------------------*/
128 /* ARB_vertex_buffer_object                                                  */
129
130 typedef void      (*PFNGLGENBUFFERS_PROC)(GLsizei, GLuint *);
131 typedef void      (*PFNGLBINDBUFFER_PROC)(GLenum, GLuint);
132 typedef void      (*PFNGLBUFFERDATA_PROC)(GLenum, GLsizeiptr, const GLvoid *, GLenum);
133 typedef void      (*PFNGLBUFFERSUBDATA_PROC)(GLenum, GLintptr, GLsizeiptr, const GLvoid *);
134 typedef void      (*PFNGLDELETEBUFFERS_PROC)(GLsizei, const GLuint *);
135 typedef GLboolean (*PFNGLISBUFFER_PROC)(GLuint);
136
137 extern PFNGLGENBUFFERS_PROC    glGenBuffers_;
138 extern PFNGLBINDBUFFER_PROC    glBindBuffer_;
139 extern PFNGLBUFFERDATA_PROC    glBufferData_;
140 extern PFNGLBUFFERSUBDATA_PROC glBufferSubData_;
141 extern PFNGLDELETEBUFFERS_PROC glDeleteBuffers_;
142 extern PFNGLISBUFFER_PROC      glIsBuffer_;
143
144 /*---------------------------------------------------------------------------*/
145 /* ARB_point_parameters                                                      */
146
147 typedef void (*PFNGLPOINTPARAMETERFV_PROC)(GLenum, const GLfloat *);
148
149 extern PFNGLPOINTPARAMETERFV_PROC glPointParameterfv_;
150
151 /*---------------------------------------------------------------------------*/
152 #endif /* !ENABLE_OPENGLES */
153
154 void glClipPlane4f_(GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
155
156 /*---------------------------------------------------------------------------*/
157
158 struct gl_info
159 {
160     GLint max_texture_units;
161     GLint max_texture_size;
162
163     unsigned int multitexture:1;
164     unsigned int vertex_buffer_object:1;
165     unsigned int point_parameters:1;
166 };
167
168 extern struct gl_info gli;
169
170 /*---------------------------------------------------------------------------*/
171 #endif