Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

igl.h (10546B)


      1 /*
      2 ===========================================================================
      3 Copyright (C) 1999-2005 Id Software, Inc.
      4 
      5 This file is part of Quake III Arena source code.
      6 
      7 Quake III Arena source code is free software; you can redistribute it
      8 and/or modify it under the terms of the GNU General Public License as
      9 published by the Free Software Foundation; either version 2 of the License,
     10 or (at your option) any later version.
     11 
     12 Quake III Arena source code is distributed in the hope that it will be
     13 useful, 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 Foobar; 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 // $LogFile$
     25 // $Revision: 1.7.2.3 $
     26 // $Author: ttimo $
     27 // $Date: 2000/02/16 15:43:14 $
     28 // $Log: igl.h,v $
     29 // Revision 1.7.2.3  2000/02/16 15:43:14  ttimo
     30 // Curry bug #101996: added glTexParameterf and glNormal3f
     31 //
     32 // Revision 1.7.2.2  2000/02/13 17:48:07  ttimo
     33 // Curry bug #101874 - added glTexGenf to GL interface
     34 //
     35 // Revision 1.7.2.1  2000/02/04 22:59:34  ttimo
     36 // messaging API preview
     37 //
     38 // Revision 1.7  2000/01/18 00:43:59  ttimo
     39 // RC
     40 //
     41 // Revision 1.6  2000/01/13 00:46:41  ttimo
     42 // Merged in patches in / out
     43 // Revision 1.1.1.4  2000/01/18 00:17:12  ttimo
     44 // merging in for RC
     45 //
     46 // Revision 1.5  2000/01/11 22:14:48  ttimo
     47 // cleaning up after merging and thinks badly fucked up
     48 //
     49 // Revision 1.2  2000/01/09 04:39:14  ttimo
     50 // added some bindings to the GL table
     51 //
     52 // Revision 1.1.1.3  2000/01/11 16:43:15  ttimo
     53 // merged version from old reposit and Robert update
     54 //
     55 // Revision 1.1.1.1  2000/01/07 17:17:30  ttimo
     56 // initial import of Q3Radiant module
     57 //
     58 // Revision 1.1.1.1  2000/01/07 17:17:30  ttimo
     59 // initial import of Q3Radiant module
     60 //
     61 // Revision 1.3  2000/01/17 23:53:44  TBesset
     62 // ready for merge in sourceforge (RC candidate)
     63 //
     64 // Revision 1.2  2000/01/07 16:40:13  TBesset
     65 // merged from BSP frontend
     66 //
     67 // Revision 1.1.1.3  1999/12/29 18:31:27  TBesset
     68 // Q3Radiant public version
     69 //
     70 // Revision 1.1.1.1.2.1  1999/12/29 21:39:45  TBesset
     71 // updated to update3 from Robert
     72 //
     73 // Revision 1.1.1.3  1999/12/29 18:31:27  TBesset
     74 // Q3Radiant public version
     75 // Revision 1.1.1.3  1999/12/29 18:31:27  TBesset
     76 // Q3Radiant public version
     77 //
     78 // Revision 1.2  1999/11/22 17:46:48  Timo & Christine
     79 // merged EARadiant into the main tree
     80 // bug fixes for Q3Plugin / EAPlugin
     81 // export for Robert
     82 //
     83 // Revision 1.1.2.2  1999/11/03 20:38:04  Timo & Christine
     84 // MEAN plugin for Q3Radiant, alpha version
     85 //
     86 // Revision 1.1.2.1.2.1  1999/10/27 08:34:29  Timo & Christine
     87 // preview version of the texture tools plugin is ready
     88 // ( TexTool.dll plugin is in Q3Plugin module )
     89 // plugins can draw in their own window using Radiant's qgl bindings
     90 //
     91 // Revision 1.1.2.1  1999/10/08 16:28:14  Timo & Christine
     92 // started plugin extensions for EA features support in Q3Radiant
     93 // MEAN files plugin, and Surface Properties plugin
     94 //
     95 //
     96 // DESCRIPTION:
     97 // all purpose OpenGL interface for Q3Radiant plugins
     98 //
     99 
    100 #ifndef __IGL_H__
    101 #define __IGL_H__
    102 
    103 // we use this class to let plugins draw inside the Radiant windows
    104 class IGLWindow
    105 {
    106 public:
    107 	// Increment the number of references to this object
    108 	virtual void IncRef () = 0;
    109 	// Decrement the reference count
    110 	virtual void DecRef () = 0;
    111 	virtual void Draw( VIEWTYPE vt ) = 0;
    112 };
    113 
    114 // define a GUID for this interface so plugins can access and reference it
    115 // {0F237620-854B-11d3-8EF3-A2DFBD53251B}
    116 static const GUID QERQglTable_GUID = 
    117 { 0xf237620, 0x854b, 0x11d3, { 0x8e, 0xf3, 0xa2, 0xdf, 0xbd, 0x53, 0x25, 0x1b } };
    118 
    119 #include <gl/gl.h>
    120 #include <gl/glu.h>
    121 
    122 typedef void (APIENTRY* PFN_QGLALPHAFUNC)		(GLenum func, GLclampf ref);
    123 typedef void (APIENTRY* PFN_QGLBEGIN)			(GLenum);
    124 typedef void (APIENTRY* PFN_QGLBINDTEXTURE)		(GLenum target, GLuint texture);
    125 typedef void (APIENTRY* PFN_QGLBLENDFUNC)       (GLenum sfactor, GLenum dfactor);
    126 typedef void (APIENTRY* PFN_QGLCALLLIST)        (GLuint list);
    127 typedef void (APIENTRY* PFN_QGLCALLLISTS)       (GLsizei n, GLenum type, const GLvoid *lists);
    128 typedef void (APIENTRY* PFN_QGLCLEAR)			(GLbitfield mask);
    129 typedef void (APIENTRY* PFN_QGLCLEARCOLOR)		(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
    130 typedef void (APIENTRY* PFN_QGLCLEARDEPTH)      (GLclampd depth);
    131 typedef void (APIENTRY* PFN_QGLCOLOR3F)			(GLfloat red, GLfloat green, GLfloat blue);
    132 typedef void (APIENTRY* PFN_QGLCOLOR4F)			(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
    133 typedef void (APIENTRY* PFN_QGLCULLFACE)        (GLenum mode);
    134 typedef void (APIENTRY* PFN_QGLDELETELISTS)     (GLuint list, GLsizei range);
    135 typedef void (APIENTRY* PFN_QGLDISABLE)			(GLenum cap);
    136 typedef void (APIENTRY* PFN_QGLENABLE)			(GLenum cap);
    137 typedef void (APIENTRY* PFN_QGLEND)				();
    138 typedef void (APIENTRY* PFN_QGLENDLIST)         (void);
    139 typedef GLuint (APIENTRY* PFN_QGLGENLISTS)      (GLsizei range);
    140 typedef void (APIENTRY* PFN_QGLLISTBASE)        (GLuint base);
    141 typedef void (APIENTRY* PFN_QGLLOADIDENTITY)	();
    142 typedef void (APIENTRY* PFN_QGLMATRIXMODE)		(GLenum mode);
    143 typedef void (APIENTRY* PFN_QGLNEWLIST)         (GLuint list, GLenum mode);
    144 typedef void (APIENTRY* PFN_QGLNORMAL3F)		(GLfloat nx, GLfloat ny, GLfloat nz);
    145 typedef void (APIENTRY* PFN_QGLORTHO)			(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
    146 typedef void (APIENTRY*	PFN_QGLPOINTSIZE)		(GLfloat size);
    147 typedef void (APIENTRY* PFN_QGLPOLYGONMODE)		(GLenum face, GLenum mode);
    148 typedef void (APIENTRY* PFN_QGLPOPMATRIX)		();
    149 typedef void (APIENTRY* PFN_QGLPUSHMATRIX)		();
    150 typedef void (APIENTRY* PFN_QGLROTATED)         (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
    151 typedef void (APIENTRY* PFN_QGLROTATEF)			(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
    152 typedef void (APIENTRY* PFN_QGLSCALEF)			(GLfloat x, GLfloat y, GLfloat z);
    153 typedef void (APIENTRY* PFN_QGLTEXCOORD2F)		(GLfloat s, GLfloat t);
    154 typedef void (APIENTRY* PFN_QGLTEXENVF)			(GLenum target, GLenum pname, GLfloat param);
    155 typedef void (APIENTRY* PFN_QGLTEXGENF)			(GLenum coord, GLenum pname, GLfloat param);
    156 typedef void (APIENTRY* PFN_QGLTEXPARAMETERF)	(GLenum target, GLenum pname, GLfloat param);
    157 typedef void (APIENTRY* PFN_QGLTRANSLATED)      (GLdouble x, GLdouble y, GLdouble z);
    158 typedef void (APIENTRY* PFN_QGLTRANSLATEF)		(GLfloat x, GLfloat y, GLfloat z);
    159 typedef void (APIENTRY* PFN_QGLVERTEX2F)		(GLfloat x, GLfloat y);
    160 typedef void (APIENTRY* PFN_QGLVERTEX3F)		(GLfloat x, GLfloat y, GLfloat z);
    161 typedef void (APIENTRY* PFN_QGLVIEWPORT)		(GLint x, GLint y, GLsizei width, GLsizei height);
    162 
    163 typedef void	(WINAPI* PFN_QE_CHECKOPENGLFORERRORS)	();
    164 typedef int		(WINAPI* PFN_QEW_SETUPPIXELFORMAT)		(HDC hDC, qboolean zbuffer );
    165 typedef HGLRC	(WINAPI* PFN_QWGL_CREATECONTEXT)		(HDC);
    166 typedef BOOL	(WINAPI* PFN_QWGL_DELETECONTEXT)        (HGLRC);
    167 typedef BOOL	(WINAPI* PFN_QWGL_MAKECURRENT)			(HDC, HGLRC);
    168 typedef BOOL	(WINAPI* PFN_QWGL_SHARELISTS)			(HGLRC, HGLRC);
    169 typedef BOOL	(WINAPI* PFN_QWGL_SWAPBUFFERS)			(HDC);
    170 typedef BOOL    (WINAPI* PFN_QWGL_USEFONTBITMAPS)       (HDC, DWORD, DWORD, DWORD);
    171 
    172 // glu stuff
    173 typedef void (APIENTRY * PFN_QGLUPERSPECTIVE) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
    174 typedef void (APIENTRY * PFN_QGLULOOKAT)(
    175   GLdouble eyex,
    176   GLdouble eyey,
    177   GLdouble eyez,
    178   GLdouble centerx,
    179   GLdouble centery,
    180   GLdouble centerz,
    181   GLdouble upx,
    182   GLdouble upy,
    183   GLdouble upz);
    184 
    185 
    186 // specially provided by the editor for plugins
    187 typedef HGLRC	(WINAPI* PFN_QERAPP_GETQEGLOBALSHGLRC)	();
    188 
    189 // plugins drawing inside the GL windows
    190 //++timo TODO: add hooking into other windows
    191 //+timo NOTE: this could be moved to the messaging system instead of having a dedicated interface
    192 typedef void (WINAPI* PFN_QERAPP_HOOKXYGLWINDOW) (IGLWindow *);
    193 typedef void (WINAPI* PFN_QERAPP_UNHOOKGLWINDOW) (IGLWindow *);
    194 
    195 struct _QERQglTable
    196 {
    197 	//++timo do we really wanna play with versions ?
    198 //	float m_fVersion;
    199 	int m_nSize;
    200 	PFN_QGLALPHAFUNC		m_pfn_qglAlphaFunc;
    201 	PFN_QGLBEGIN			m_pfn_qglBegin;
    202 	PFN_QGLBINDTEXTURE		m_pfn_qglBindTexture;
    203 	PFN_QGLBLENDFUNC		m_pfn_qglBlendFunc;
    204 	PFN_QGLCALLLIST			m_pfn_qglCallList;
    205 	PFN_QGLCLEAR			m_pfn_qglClear;
    206 	PFN_QGLCLEARCOLOR		m_pfn_qglClearColor;
    207 	PFN_QGLCALLLISTS		m_pfn_qglCallLists;
    208 	PFN_QGLCLEARDEPTH		m_pfn_qglClearDepth;
    209 	PFN_QGLCOLOR3F			m_pfn_qglColor3f;
    210 	PFN_QGLCOLOR4F			m_pfn_qglColor4f;
    211 	PFN_QGLCULLFACE			m_pfn_qglCullFace;
    212 	PFN_QGLDELETELISTS		m_pfn_qglDeleteLists;
    213 	PFN_QGLDISABLE			m_pfn_qglDisable;
    214 	PFN_QGLENABLE			m_pfn_qglEnable;
    215 	PFN_QGLEND				m_pfn_qglEnd;
    216 	PFN_QGLENDLIST			m_pfn_qglEndList;
    217 	PFN_QGLGENLISTS			m_pfn_qglGenLists;
    218 	PFN_QGLLISTBASE			m_pfn_qglListBase;
    219 	PFN_QGLLOADIDENTITY		m_pfn_qglLoadIdentity;
    220 	PFN_QGLMATRIXMODE		m_pfn_qglMatrixMode;
    221 	PFN_QGLNEWLIST			m_pfn_qglNewList;
    222 	PFN_QGLNORMAL3F			m_pfn_qglNormal3f;
    223 	PFN_QGLORTHO			m_pfn_qglOrtho;
    224 	PFN_QGLPOINTSIZE		m_pfn_qglPointSize;
    225 	PFN_QGLPOLYGONMODE		m_pfn_qglPolygonMode;
    226 	PFN_QGLPOPMATRIX		m_pfn_qglPopMatrix;
    227 	PFN_QGLPUSHMATRIX		m_pfn_qglPushMatrix;
    228 	PFN_QGLROTATED			m_pfn_qglRotated;
    229 	PFN_QGLROTATEF			m_pfn_qglRotatef;
    230 	PFN_QGLSCALEF			m_pfn_qglScalef;
    231 	PFN_QGLTEXCOORD2F		m_pfn_qglTexCoord2f;
    232 	PFN_QGLTEXENVF			m_pfn_qglTexEnvf;
    233 	PFN_QGLTEXGENF			m_pfn_qglTexGenf;
    234 	PFN_QGLTEXPARAMETERF	m_pfn_qglTexParameterf;
    235 	PFN_QGLTRANSLATED		m_pfn_qglTranslated;
    236 	PFN_QGLTRANSLATEF		m_pfn_qglTranslatef;
    237 	PFN_QGLVERTEX2F			m_pfn_qglVertex2f;
    238 	PFN_QGLVERTEX3F			m_pfn_qglVertex3f;
    239 	PFN_QGLVIEWPORT			m_pfn_qglViewport;
    240 
    241 	PFN_QE_CHECKOPENGLFORERRORS	m_pfn_QE_CheckOpenGLForErrors;
    242 	PFN_QEW_SETUPPIXELFORMAT	m_pfn_QEW_SetupPixelFormat;
    243 	PFN_QWGL_CREATECONTEXT		m_pfn_qwglCreateContext;
    244 	PFN_QWGL_DELETECONTEXT      m_pfn_qwglDeleteContext;
    245 	PFN_QWGL_MAKECURRENT		m_pfn_qwglMakeCurrent;
    246 	PFN_QWGL_SHARELISTS			m_pfn_qwglShareLists;
    247 	PFN_QWGL_SWAPBUFFERS		m_pfn_qwglSwapBuffers;
    248 	PFN_QWGL_USEFONTBITMAPS		m_pfn_qwglUseFontBitmaps;
    249 
    250 	PFN_QERAPP_GETQEGLOBALSHGLRC	m_pfnGetQeglobalsHGLRC;
    251 
    252 	// glu stuff
    253 	PFN_QGLUPERSPECTIVE			m_pfn_qgluPerspective;
    254 	PFN_QGLULOOKAT				m_pfn_qgluLookAt;
    255 
    256 	// plugin entities drawing inside Radiant windows
    257 	PFN_QERAPP_HOOKXYGLWINDOW	m_pfnHookXYGLWindow;
    258 	PFN_QERAPP_UNHOOKGLWINDOW	m_pfnUnHookGLWindow;
    259 };
    260 
    261 #endif