]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/igl.h
apply patch from Martin Gerhardy - more quake2 related modules compiled and misc...
[xonotic/netradiant.git] / include / igl.h
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 //-----------------------------------------------------------------------------
23 //
24 //
25 // DESCRIPTION:
26 // all purpose OpenGL interface for Q3Radiant plugins
27 //
28
29 #ifndef __IGL_H__
30 #define __IGL_H__
31
32 #if defined (__linux__) || defined (__APPLE__)
33 #include <GL/glx.h>
34 #endif
35
36 // we use these classes to let plugins draw inside the Radiant windows
37 // 2D window like YZ XZ XY
38 class IGL2DWindow
39 {
40 public:
41         virtual ~IGL2DWindow() { }
42         // Increment the number of references to this object
43         virtual void IncRef () = 0;
44         // Decrement the reference count
45         virtual void DecRef () = 0;
46         virtual void Draw2D( VIEWTYPE vt ) = 0;
47 };
48
49 // 3D window
50 class IGL3DWindow
51 {
52 public:
53         virtual ~IGL3DWindow() { }
54   // Increment the number of references to this object
55   virtual void IncRef () = 0;
56   // Decrement the reference count
57   virtual void DecRef () = 0;
58   virtual void Draw3D() = 0;
59 };
60
61 #define QGL_MAJOR "qgl"
62
63 #include <GL/gl.h>
64
65 typedef void (APIENTRY* PFN_QGLALPHAFUNC) (GLenum func, GLclampf ref);
66 typedef void (APIENTRY* PFN_QGLBEGIN) (GLenum);
67 typedef void (APIENTRY* PFN_QGLBINDTEXTURE) (GLenum target, GLuint texture);
68 typedef void (APIENTRY* PFN_QGLBLENDFUNC) (GLenum sfactor, GLenum dfactor);
69 typedef void (APIENTRY* PFN_QGLCALLLIST) (GLuint list);
70 typedef void (APIENTRY* PFN_QGLCALLLISTS) (GLsizei n, GLenum type, const GLvoid *lists);
71 typedef void (APIENTRY* PFN_QGLCLEAR) (GLbitfield mask);
72 typedef void (APIENTRY* PFN_QGLCLEARCOLOR) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
73 typedef void (APIENTRY* PFN_QGLCLEARDEPTH) (GLclampd depth);
74 typedef void (APIENTRY* PFN_QGLCOLOR3F) (GLfloat red, GLfloat green, GLfloat blue);
75 typedef void (APIENTRY* PFN_QGLCOLOR3FV) (const GLfloat *v);
76 typedef void (APIENTRY* PFN_QGLCOLOR4F) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
77 typedef void (APIENTRY* PFN_QGLCOLOR4FV) (const GLfloat *v);
78 typedef void (APIENTRY* PFN_QGLCOLOR4UBV) (const GLubyte *v);
79 typedef void (APIENTRY* PFN_QGLCOLORPOINTER) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
80 typedef void (APIENTRY* PFN_QGLCULLFACE) (GLenum mode);
81 typedef void (APIENTRY* PFN_QGLDELETELISTS) (GLuint list, GLsizei range);
82 typedef void (APIENTRY* PFN_QGLDELETETEXTURES)  (GLsizei n, const GLuint *textures);
83 typedef void (APIENTRY* PFN_QGLDEPTHFUNC) (GLenum func);
84 typedef void (APIENTRY* PFN_QGLDEPTHMASK) (GLboolean flag);
85 typedef void (APIENTRY* PFN_QGLDISABLE) (GLenum cap);
86 typedef void (APIENTRY* PFN_QGLDISABLECLIENTSTATE) (GLenum array);
87 typedef void (APIENTRY* PFN_QGLDRAWELEMENTS) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
88 typedef void (APIENTRY* PFN_QGLENABLE) (GLenum cap);
89 typedef void (APIENTRY* PFN_QGLENABLECLIENTSTATE) (GLenum array);
90 typedef void (APIENTRY* PFN_QGLEND) ();
91 typedef void (APIENTRY* PFN_QGLENDLIST) ();
92 typedef void (APIENTRY* PFN_QGLFOGF) (GLenum pname, GLfloat param);
93 typedef void (APIENTRY* PFN_QGLFOGFV) (GLenum pname, const GLfloat *params);
94 typedef void (APIENTRY* PFN_QGLFOGFI) (GLenum pname, GLint param);
95 typedef GLuint (APIENTRY* PFN_QGLGENLISTS) (GLsizei range);
96 typedef void (APIENTRY *PFN_QGLGENTEXTURES) (GLsizei n, GLuint *textures);
97 typedef void (APIENTRY* PFN_QGLGETDOUBLEV) (GLenum pname, GLdouble *params);
98 typedef void (APIENTRY* PFN_QGLHINT) (GLenum target, GLenum mode);
99 typedef void (APIENTRY* PFN_QGLGETINTEGERV) (GLenum pname, GLint *params);
100 typedef void (APIENTRY* PFN_QGLLIGHTFV) (GLenum light, GLenum pname, const GLfloat *params);
101 typedef void (APIENTRY* PFN_QGLLINEWIDTH) (GLfloat size);
102 typedef void (APIENTRY* PFN_QGLLINESTIPPLE) (GLint factor, GLushort pattern);
103 typedef void (APIENTRY* PFN_QGLLINEWIDTH)       (GLfloat size);
104 typedef void (APIENTRY* PFN_QGLLISTBASE) (GLuint base);
105 typedef void (APIENTRY* PFN_QGLLOADIDENTITY) ();
106 typedef void (APIENTRY* PFN_QGLMATERIALF) (GLenum face, GLenum pname, GLfloat param);
107 typedef void (APIENTRY* PFN_QGLMATERIALFV) (GLenum face, GLenum pname, const GLfloat *params);
108 typedef void (APIENTRY* PFN_QGLMATRIXMODE) (GLenum mode);
109 typedef void (APIENTRY* PFN_QGLMULTMATRIXF)    (const GLfloat *m);
110 typedef void (APIENTRY* PFN_QGLNEWLIST) (GLuint list, GLenum mode);
111 typedef void (APIENTRY* PFN_QGLNORMAL3F) (GLfloat nx, GLfloat ny, GLfloat nz);
112 typedef void (APIENTRY* PFN_QGLNORMAL3FV) (const GLfloat *n);
113 typedef void (APIENTRY* PFN_QGLNORMALPOINTER) (GLenum type, GLsizei stride, const GLvoid *pointer);
114 typedef void (APIENTRY* PFN_QGLORTHO) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
115 typedef void (APIENTRY* PFN_QGLPOINTSIZE) (GLfloat size);
116 typedef void (APIENTRY* PFN_QGLPOLYGONMODE) (GLenum face, GLenum mode);
117 typedef void (APIENTRY* PFN_QGLPOPATTRIB) ();
118 typedef void (APIENTRY* PFN_QGLPOPMATRIX) ();
119 typedef void (APIENTRY* PFN_QGLPUSHATTRIB) (GLbitfield mask);
120 typedef void (APIENTRY* PFN_QGLPUSHMATRIX) ();
121 typedef void (APIENTRY* PFN_QGLRASTERPOS3FV) (const GLfloat *v);
122 typedef void (APIENTRY* PFN_QGLROTATED) (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
123 typedef void (APIENTRY* PFN_QGLROTATEF) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
124 typedef void (APIENTRY* PFN_QGLSCALEF)                  (GLfloat x, GLfloat y, GLfloat z);
125 typedef void (APIENTRY* PFN_QGLSCISSOR) (GLint x, GLint y, GLsizei width, GLsizei height);
126 typedef void (APIENTRY* PFN_QGLSCALEF) (GLfloat x, GLfloat y, GLfloat z);
127 typedef void (APIENTRY* PFN_QGLSHADEMODEL) (GLenum mode);
128 typedef void (APIENTRY* PFN_QGLTEXCOORD2F) (GLfloat s, GLfloat t);
129 typedef void (APIENTRY* PFN_QGLTEXCOORD2FV) (const GLfloat *v);
130 typedef void (APIENTRY* PFN_QGLTEXCOORDPOINTER) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
131 typedef void (APIENTRY* PFN_QGLTEXENVF) (GLenum target, GLenum pname, GLfloat param);
132 typedef void (APIENTRY* PFN_QGLTEXGENF) (GLenum coord, GLenum pname, GLfloat param);
133 typedef void (APIENTRY* PFN_QGLTEXIMAGE1D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
134 typedef void (APIENTRY* PFN_QGLTEXIMAGE2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
135 typedef void (APIENTRY* PFN_QGLTEXPARAMETERF) (GLenum target, GLenum pname, GLfloat param);
136 typedef void (APIENTRY* PFN_QGLTEXPARAMETERFV) (GLenum target, GLenum pname, const GLfloat *params);
137 typedef void (APIENTRY* PFN_QGLTEXPARAMETERI) (GLenum target, GLenum pname, GLint param);
138 typedef void (APIENTRY* PFN_QGLTEXPARAMETERIV) (GLenum target, GLenum pname, const GLint *params);
139 typedef void (APIENTRY* PFN_QGLTEXSUBIMAGE1D) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
140 typedef void (APIENTRY* PFN_QGLTEXSUBIMAGE2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
141 typedef void (APIENTRY* PFN_QGLTRANSLATED) (GLdouble x, GLdouble y, GLdouble z);
142 typedef void (APIENTRY* PFN_QGLTRANSLATEF) (GLfloat x, GLfloat y, GLfloat z);
143 typedef void (APIENTRY* PFN_QGLVERTEX2F) (GLfloat x, GLfloat y);
144 typedef void (APIENTRY* PFN_QGLVERTEX3F) (GLfloat x, GLfloat y, GLfloat z);
145 typedef void (APIENTRY* PFN_QGLVERTEX3FV) (const GLfloat *v);
146 typedef void (APIENTRY* PFN_QGLVERTEXPOINTER) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
147 typedef void (APIENTRY* PFN_QGLVIEWPORT) (GLint x, GLint y, GLsizei width, GLsizei height);
148
149 typedef void (WINAPI* PFN_QE_CHECKOPENGLFORERRORS)      ();
150
151 // glu stuff
152 // TTimo: NOTE: relying on glu might not be such a good idea. On many systems, the GLU lib is outdated, misversioned etc.
153 typedef void (APIENTRY * PFN_QGLUPERSPECTIVE) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
154 typedef void (APIENTRY * PFN_QGLULOOKAT) (GLdouble eyex, GLdouble eyey, GLdouble eyez,
155                                           GLdouble centerx, GLdouble centery, GLdouble centerz,
156                                           GLdouble upx, GLdouble upy, GLdouble upz);
157 //++timo gluErrorString is defined but not exposed in the IGL interface
158
159
160 // plugins drawing inside the GL windows
161 //++timo TODO: add hooking into other windows (Z and .. texture??)
162 //+timo NOTE: this could be moved to the messaging system instead of having a dedicated interface <- yet I don't know how
163 typedef void (WINAPI* PFN_QERAPP_HOOKGL2DWINDOW) (IGL2DWindow *);
164 typedef void (WINAPI* PFN_QERAPP_UNHOOKGL2DWINDOW) (IGL2DWindow *);
165 typedef void (WINAPI* PFN_QERAPP_HOOKGL3DWINDOW) (IGL3DWindow *);
166 typedef void (WINAPI* PFN_QERAPP_UNHOOKGL3DWINDOW) (IGL3DWindow *);
167
168 struct _QERQglTable
169 {
170   //++timo do we really wanna play with versions ?
171   //    float m_fVersion;
172   int m_nSize;
173   PFN_QGLALPHAFUNC              m_pfn_qglAlphaFunc;
174   PFN_QGLBEGIN                  m_pfn_qglBegin;
175   PFN_QGLBINDTEXTURE            m_pfn_qglBindTexture;
176   PFN_QGLBLENDFUNC              m_pfn_qglBlendFunc;
177   PFN_QGLCALLLIST                       m_pfn_qglCallList;
178   PFN_QGLCLEAR                  m_pfn_qglClear;
179   PFN_QGLCLEARCOLOR             m_pfn_qglClearColor;
180   PFN_QGLCALLLISTS              m_pfn_qglCallLists;
181   PFN_QGLCLEARDEPTH             m_pfn_qglClearDepth;
182   PFN_QGLCOLOR3F                        m_pfn_qglColor3f;
183   PFN_QGLCOLOR3FV         m_pfn_qglColor3fv;
184   PFN_QGLCOLOR4F                        m_pfn_qglColor4f;
185   PFN_QGLCOLOR4FV         m_pfn_qglColor4fv;
186   PFN_QGLCOLOR4UBV        m_pfn_qglColor4ubv;   // ydnar
187   PFN_QGLCOLORPOINTER     m_pfn_qglColorPointer;
188   PFN_QGLCULLFACE                       m_pfn_qglCullFace;
189   PFN_QGLDELETELISTS            m_pfn_qglDeleteLists;
190   PFN_QGLDELETETEXTURES  m_pfn_qglDeleteTextures;
191   PFN_QGLDEPTHFUNC        m_pfn_qglDepthFunc;
192   PFN_QGLDEPTHMASK        m_pfn_qglDepthMask;
193   PFN_QGLDISABLE                        m_pfn_qglDisable;
194   PFN_QGLDISABLECLIENTSTATE m_pfn_qglDisableClientState;
195   PFN_QGLDRAWELEMENTS                   m_pfn_qglDrawElements;
196   PFN_QGLENABLE                 m_pfn_qglEnable;
197   PFN_QGLENABLECLIENTSTATE  m_pfn_qglEnableClientState;
198   PFN_QGLEND                            m_pfn_qglEnd;
199   PFN_QGLENDLIST                        m_pfn_qglEndList;
200   PFN_QGLFOGF              m_pfn_qglFogf;
201   PFN_QGLFOGFV             m_pfn_qglFogfv;
202   PFN_QGLFOGFI             m_pfn_qglFogi;
203   PFN_QGLGENLISTS                       m_pfn_qglGenLists;
204   PFN_QGLGENTEXTURES  m_pfn_qglGenTextures;
205   PFN_QGLGETDOUBLEV                     m_pfn_qglGetDoublev;
206   PFN_QGLGETINTEGERV      m_pfn_qglGetIntegerv;
207   PFN_QGLHINT             m_pfn_qglHint;
208   PFN_QGLLIGHTFV          m_pfn_qglLightfv;
209   PFN_QGLLINESTIPPLE      m_pfn_qglLineStipple;
210   PFN_QGLLINEWIDTH        m_pfn_qglLineWidth;
211   PFN_QGLLISTBASE                       m_pfn_qglListBase;
212   PFN_QGLLOADIDENTITY           m_pfn_qglLoadIdentity;
213   PFN_QGLMATERIALF              m_pfn_qglMaterialf;
214   PFN_QGLMATERIALFV       m_pfn_qglMaterialfv;
215   PFN_QGLMATRIXMODE             m_pfn_qglMatrixMode;
216   PFN_QGLMULTMATRIXF  m_pfn_qglMultMatrixf;
217   PFN_QGLNEWLIST                        m_pfn_qglNewList;
218   PFN_QGLNORMAL3F                       m_pfn_qglNormal3f;
219   PFN_QGLNORMAL3FV                      m_pfn_qglNormal3fv;
220         PFN_QGLNORMALPOINTER            m_pfn_qglNormalPointer;
221   PFN_QGLORTHO                  m_pfn_qglOrtho;
222   PFN_QGLPOINTSIZE              m_pfn_qglPointSize;
223   PFN_QGLPOLYGONMODE            m_pfn_qglPolygonMode;
224   PFN_QGLPOPATTRIB              m_pfn_qglPopAttrib;
225   PFN_QGLPOPMATRIX              m_pfn_qglPopMatrix;
226   PFN_QGLPUSHATTRIB             m_pfn_qglPushAttrib;
227   PFN_QGLPUSHMATRIX             m_pfn_qglPushMatrix;
228         PFN_QGLRASTERPOS3FV     m_pfn_qglRasterPos3fv;
229   PFN_QGLROTATED                        m_pfn_qglRotated;
230   PFN_QGLROTATEF                        m_pfn_qglRotatef;
231   PFN_QGLSCALEF                 m_pfn_qglScalef;
232   PFN_QGLSCISSOR        m_pfn_qglScissor;
233   PFN_QGLSHADEMODEL             m_pfn_qglShadeModel;
234   PFN_QGLTEXCOORD2F             m_pfn_qglTexCoord2f;
235   PFN_QGLTEXCOORD2FV      m_pfn_qglTexCoord2fv;
236         PFN_QGLTEXCOORDPOINTER          m_pfn_qglTexCoordPointer;
237   PFN_QGLTEXENVF                        m_pfn_qglTexEnvf;
238   PFN_QGLTEXGENF                        m_pfn_qglTexGenf;
239   PFN_QGLTEXIMAGE1D     m_pfn_qglTexImage1D;
240   PFN_QGLTEXIMAGE2D     m_pfn_qglTexImage2D;
241   PFN_QGLTEXPARAMETERF  m_pfn_qglTexParameterf;
242   PFN_QGLTEXPARAMETERFV m_pfn_qglTexParameterfv;
243   PFN_QGLTEXPARAMETERI  m_pfn_qglTexParameteri;
244   PFN_QGLTEXPARAMETERIV m_pfn_qglTexParameteriv;
245   PFN_QGLTEXSUBIMAGE1D  m_pfn_qglTexSubImage1D;
246   PFN_QGLTEXSUBIMAGE2D  m_pfn_qglTexSubImage2D;
247   PFN_QGLTRANSLATED             m_pfn_qglTranslated;
248   PFN_QGLTRANSLATEF             m_pfn_qglTranslatef;
249   PFN_QGLVERTEX2F                       m_pfn_qglVertex2f;
250   PFN_QGLVERTEX3F                       m_pfn_qglVertex3f;
251   PFN_QGLVERTEX3FV        m_pfn_qglVertex3fv;
252         PFN_QGLVERTEXPOINTER            m_pfn_qglVertexPointer;
253   PFN_QGLVIEWPORT                       m_pfn_qglViewport;
254
255   PFN_QE_CHECKOPENGLFORERRORS   m_pfn_QE_CheckOpenGLForErrors;
256
257   // glu stuff
258   PFN_QGLUPERSPECTIVE                   m_pfn_qgluPerspective;
259   PFN_QGLULOOKAT                                m_pfn_qgluLookAt;
260
261   // plugin entities drawing inside Radiant windows
262   PFN_QERAPP_HOOKGL2DWINDOW     m_pfnHookGL2DWindow;
263   PFN_QERAPP_UNHOOKGL2DWINDOW   m_pfnUnHookGL2DWindow;
264   PFN_QERAPP_HOOKGL3DWINDOW m_pfnHookGL3DWindow;
265   PFN_QERAPP_UNHOOKGL3DWINDOW m_pfnUnHookGL3DWindow;
266 };
267
268 #endif