Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gfxlib.h
Go to the documentation of this file.
1 /*
2  * Vega Strike
3  * Copyright (C) 2001-2002 Daniel Horn
4  *
5  * http://vegastrike.sourceforge.net/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program 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 this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef _GFXLIB_H
23 #define _GFXLIB_H
24 #if defined (_WIN32) && !defined (__CYGWIN__)
25 #ifdef GLDRV_EXPORTS
26 #define GFXDRVAPI __declspec( dllexport )
27 #else
28 #define GFXDRVAPI __declspec( dllimport )
29 #endif
30 #else
31 #define GFXDRVAPI
32 #endif
33 /*#if 0
34  * #if defined(__APPLE__) || defined(MACOSX)
35  * #include <GLUT/glut.h>
36  * #else
37  * #include <GL/glut.h>
38  * #endif
39  #endif*/
40 #include <cstddef>
41 #include <vector>
42 class Matrix;
43 
44 using std::vector;
45 
46 #include "gfx/vec.h"
47 #include "gfxlib_struct.h"
48 
49 //Init functions
50 
52 void /*GFXDRVAPI*/ GFXInit( int, char** );
53 
55 void /*GFXDRVAPI*/ GFXLoop( void main_loop() );
56 
58 void /*GFXDRVAPI*/ GFXShutdown();
59 
60 //Misc functions
61 
63 void /*GFXDRVAPI*/ GFXBeginScene();
65 void /*GFXDRVAPI*/ GFXEndScene();
67 void /*GFXDRVAPI*/ GFXClear( const GFXBOOL colorbuffer,
68  const GFXBOOL depthbuffer = GFXTRUE,
69  const GFXBOOL stencilbuffer = GFXTRUE );
70 
72 void /*GFXDRVAPI*/ GFXCreateLightContext( int &con_number );
74 void /*GFXDRVAPI*/ GFXDeleteLightContext( const int con_number );
76 void /*GFXDRVAPI*/ GFXSetLightContext( const int con_number );
78 GFXBOOL /*GFXDRVAPI*/ GFXLightContextAmbient( const GFXColor &amb );
80 GFXBOOL /*GFXDRVAPI*/ GFXGetLightContextAmbient( GFXColor &amb );
82 void /*GFXDRVAPI*/ GFXPickLights( const Vector &center, const float radius );
84 void /*GFXDRVAPI*/ GFXPickLights( const Vector &center, const float radius, vector< int > &lights, const int maxlights, const bool pickglobals );
86 void /*GFXDRVAPI*/ GFXPickLights( vector< int >::const_iterator begin, vector< int >::const_iterator end );
88 GFXBOOL /*GFXDRVAPI*/ GFXSetSeparateSpecularColor( const GFXBOOL spec );
90 GFXBOOL /*GFXDRVAPI*/ GFXSetCutoff( const float cutoff );
92 void /*GFXDRVAPI*/ GFXSetOptimalIntensity( const float newint, const float saturatevalue );
94 GFXBOOL /*GFXDRVAPI*/ GFXSetOptimalNumLights( const int numlights );
95 
103 GFXBOOL /*GFXDRVAPI*/ GFXCreateLight( int &light, const GFXLight&, const bool global );
104 
106 void /*GFXDRVAPI*/ GFXDeleteLight( const int light );
107 
109 GFXBOOL /*GFXDRVAPI*/ GFXEnableLight( const int light );
110 
112 GFXBOOL /*GFXDRVAPI*/ GFXDisableLight( const int light );
113 
115 GFXBOOL /*GFXDRVAPI*/ GFXSetLight( const int light, const enum LIGHT_TARGET, const GFXColor &color );
116 
122 void /*GFXDRVAPI*/ GFXPushGlobalEffects();
123 
125 GFXBOOL /*GFXDRVAPI*/ GFXPopGlobalEffects();
126 
128 void /*GFXDRVAPI*/ GFXSetMaterial( unsigned int &number, const GFXMaterial &material );
130 void /*GFXDRVAPI*/ GFXModifyMaterial( const unsigned int number, const GFXMaterial &material );
132 GFXBOOL /*GFXDRVAPI*/ GFXGetMaterial( const unsigned int number, GFXMaterial &material );
133 const GFXMaterial& GFXGetMaterial( const unsigned int number );
135 void /*GFXDRVAPI*/ GFXSelectMaterialHighlights( const unsigned int number,
136  const GFXColor &ambient,
137  const GFXColor &diffuse,
138  const GFXColor &specular,
139  const GFXColor &emmissive );
140 void /*GFXDRVAPI*/ GFXSelectMaterial( const unsigned int number );
141 
142 //Matrix
147 void /*GFXDRVAPI*/ GFXHudMode( const bool Enter );
148 //this resets the matrices to what they were when we entered it, without chanigng pushed orpoped matrices
149 void /*GFXDRVAPI*/ GFXRestoreHudMode();
150 void /*GFXDRVAPI*/ GFXCenterCamera( const bool Enter );
151 void /*GFXDRVAPI*/ GFXTranslateView( const QVector &r );
152 void /*GFXDRVAPI*/ GFXLoadMatrixView( const Matrix &matrix );
153 void /*GFXDRVAPI*/ GFXGetMatrixView( Matrix &m );
155 
156 void /*GFXDRVAPI*/ GFXTranslateProjection( const Vector &r );
157 void /*GFXDRVAPI*/ GFXTranslateModel( const QVector &r );
159 void /*GFXDRVAPI*/ GFXMultMatrixModel( const Matrix &matrix );
160 
162 void /*GFXDRVAPI*/ GFXLoadMatrixModel( const Matrix &matrix );
163 void /*GFXDRVAPI*/ GFXLoadMatrixProjection( const float matrix[16] );
164 
165 void /*GFXDRVAPI*/ GFXLoadMatrixView( const Matrix &matrix );
166 
168 void /*GFXDRVAPI*/ GFXLoadIdentity( const MATRIXMODE mode );
169 
171 void /*GFXDRVAPI*/ GFXGetMatrixModel( Matrix &matrix );
172 
174 float /*GFXDRVAPI*/ GFXGetZPerspective( const float z );
176 float /*GFXDRVAPI*/ GFXGetXInvPerspective();
177 float /*GFXDRVAPI*/ GFXGetYInvPerspective();
178 
180 void /*GFXDRVAPI*/ GFXPerspective( float fov, float aspect, float znear, float zfar, float cockpit_offset );
181 
183 void /*GFXDRVAPI*/ GFXParallel( float left, float right, float bottom, float top, float znear, float zfar );
184 
186 void /*GFXDRVAPI*/ GFXViewPort( int minx, int miny, int maxx, int maxy );
187 
189 void /*GFXDRVAPI*/ GFXLookAt( Vector eye, QVector center, Vector up );
190 
192 void /*GFXDRVAPI*/ GFXGetFrustum( double f[6][4] );
193 
195 void /*GFXDRVAPI*/ GFXCalculateFrustum();
196 
198 void /*GFXDRVAPI*/ GFXCalculateFrustum( double frustum[6][4], const Matrix &modlmatrix, const float *projection );
199 
201 void /*GFXDRVAPI*/ GFXGetFrustumVars( bool, float *l, float *r, float *b, float *t, float *n, float *f );
202 
204 float /*GFXDRVAPI*/ GFXSphereInFrustum( const QVector &Center, float Radius );
205 
207 float /*GFXDRVAPI*/ GFXSphereInFrustum( double f[6][4], const QVector &Center, float Radius );
208 
209 void /*GFXDRVAPI*/ GFXBoxInFrustumModel( const Matrix &model );
210 
211 CLIPSTATE /*GFXDRVAPI*/ GFXBoxInFrustum( const Vector &min, const Vector &max );
212 
213 CLIPSTATE /*GFXDRVAPI*/ GFXBoxInFrustum( double f[6][4], const Vector &min, const Vector &max );
214 CLIPSTATE /*GFXDRVAPI*/ GFXTransformedBoxInFrustum( const Vector &min, const Vector &max );
215 CLIPSTATE /*GFXDRVAPI*/ GFXSpherePartiallyInFrustum( const Vector &cent, const float r );
216 CLIPSTATE /*GFXDRVAPI*/ GFXTransformedSpherePartiallyInFrustum( const Vector &cent, const float r );
217 CLIPSTATE /*GFXDRVAPI*/ GFXSpherePartiallyInFrustum( double f[6][4], const Vector &cent, const float r );
218 
220 void /*GFXDRVAPI*/ GFXFrustum( float *mat,
221  float *inv,
222  float left,
223  float right,
224  float bottom,
225  float top,
226  float nearval,
227  float farval );
228 
229 //Textures
239 GFXBOOL /*GFXDRVAPI*/ GFXCreateTexture( int width,
240  int height,
241  TEXTUREFORMAT externaltextureformat,
242  int *handle,
243  char *palette = 0,
244  int texturestage = 0,
245  enum FILTER mipmap = MIPMAP,
246  enum TEXTURE_TARGET texture_target = TEXTURE2D,
247  enum ADDRESSMODE address_mode = DEFAULT_ADDRESS_MODE );
248 
250 void /*GFXDRVAPI*/ GFXPrioritizeTexture( unsigned int handle, float priority );
251 
253 void /*GFXDRVAPI*/ GFXAttachPalette( unsigned char *palette, int handle );
254 
260 GFXBOOL /*GFXDRVAPI*/ GFXTransferTexture( unsigned char *buffer,
261  int handle,
262  int inWidth,
263  int inHeight,
264  enum TEXTUREFORMAT internalformat,
265  enum TEXTURE_IMAGE_TARGET image2D = TEXTURE_2D,
266  int max_texture_dimension = 65536 /*make sure it's not bigger than this--usually maybe 65536*/,
267  GFXBOOL detailtexture = GFXFALSE,
268  unsigned int pageIndex = 0 );
269 
270 GFXBOOL /*GFXDRVAPI*/ GFXTransferSubTexture( unsigned char *buffer,
271  int handle,
272  int x,
273  int y,
274  unsigned int width,
275  unsigned int height,
276  enum TEXTURE_IMAGE_TARGET image2D = TEXTURE_2D );
277 
279 void /*GFXDRVAPI*/ GFXDeleteTexture( int handle );
280 
282 void /*GFXDRVAPI*/ GFXDestroyAllTextures();
283 
285 void /*GFXDRVAPI*/ GFXSelectTexture( int handle, int stage = 0 );
286 
288 GFXBOOL /*GFXDRVAPI*/ GFXCapture( char *filename );
289 
290 //State
292 void /*GFXDRVAPI*/ GFXEnable( const enum STATE );
293 void /*GFXDRVAPI*/ GFXDisable( const enum STATE );
294 void /*GFXDRVAPI*/ GFXToggleTexture( bool enable, int whichstage, enum TEXTURE_TARGET target = TEXTURE2D );
296 void /*GFXDRVAPI*/ GFXTextureAddressMode( const ADDRESSMODE mode, enum TEXTURE_TARGET target = TEXTURE2D );
297 
299 void /*GFXDRVAPI*/ GFXBlendMode( const enum BLENDFUNC src, const enum BLENDFUNC dst );
300 
302 void /*GFXDRVAPI*/ GFXGetBlendMode( enum BLENDFUNC &src, enum BLENDFUNC &dst );
303 
304 void /*GFXDRVAPI*/ GFXColorMaterial( int LIGHTTARG );
305 
307 void /*GFXDRVAPI*/ GFXPointSize( const float size );
308 
310 void /*GFXDRVAPI*/ GFXLineWidth( const float size );
311 
313 void /*GFXDRVAPI*/ GFXPushBlendMode();
314 
316 void /*GFXDRVAPI*/ GFXPopBlendMode();
317 
319 void /*GFXDRVAPI*/ GFXActiveTexture( const int stage );
320 
322 enum DEPTHFUNC /*GFXDRVAPI*/ GFXDepthFunc();
323 
325 void /*GFXDRVAPI*/ GFXDepthFunc( const enum DEPTHFUNC );
326 
328 enum DEPTHFUNC /*GFXDRVAPI*/ GFXStencilFunc();
329 
331 void /*GFXDRVAPI*/ GFXStencilFunc( enum DEPTHFUNC *pFunc, int *pRef, int *pMask );
332 
334 void /*GFXDRVAPI*/ GFXStencilFunc( enum DEPTHFUNC sfunc, int ref, unsigned int mask );
335 
337 void /*GFXDRVAPI*/ GFXStencilOp( enum STENCILOP *pFail, enum STENCILOP *pZfail, enum STENCILOP *pZpass );
338 
340 void /*GFXDRVAPI*/ GFXStencilOp( enum STENCILOP fail, enum STENCILOP zfail, enum STENCILOP zpass );
341 
343 unsigned int /*GFXDRVAPI*/ GFXStencilMask();
344 
346 void /*GFXDRVAPI*/ GFXStencilMask( unsigned int mask );
347 
349 void /*GFXDRVALP*/ GFXAlphaTest( const enum DEPTHFUNC, const float ref );
351 {
353  GFXCLAMPTEXTURE, //clamp to edge, not to border
354  GFXBORDERTEXTURE //clamp to border, not to edge
355 };
357 {
365 };
366 void GFXTextureWrap( int stage, GFXTEXTUREWRAPMODES mode, enum TEXTURE_TARGET target = TEXTURE2D );
367 void GFXTextureEnv( int stage, GFXTEXTUREENVMODES mode, float arg2 = 0 );
368 bool GFXMultiTexAvailable();
370 void /*GFXDRVAPI*/ GFXPolygonOffset( float factor, float units );
371 void GFXGetPolygonOffset( float *factor, float *units );
373 void /*GFXDRVAPI*/ GFXPolygonMode( const enum POLYMODE );
375 void /*GFXDRVAPI*/ GFXCullFace( const enum POLYFACE );
377 void /*GFXDRVAPI*/ GFXBegin( const enum POLYTYPE );
378 
380 void /*GFXDRVAPI*/ GFXColorf( const GFXColor &col );
382 void /*GFXDRVAPI*/ GFXBlendColor( const GFXColor &col );
384 void /*GFXDRVAPI*/ GFXColor4f( const float r, const float g, const float b, const float a = 1.0 );
386 GFXColor /*GFXDRVAPI*/ GFXColorf();
387 
389 void /*GFXDRVAPI*/ GFXTexCoord2f( const float s, const float t );
390 
392 void /*GFXDRVAPI*/ GFXTexCoord4f( const float s, const float t, const float u, const float v );
394 void /*GFXDRVAPI*/ GFXTexCoord224f( const float s,
395  const float t,
396  const float s2,
397  const float t2,
398  const float s3,
399  const float t3,
400  const float u3,
401  const float v3 );
403 void /*GFXDRVAPI*/ GFXNormal3f( const float i, const float j, const float k );
405 void /*GFXDRVAPI*/ GFXNormal( const Vector &n );
406 
408 void /*GFXDRVAPI*/ GFXVertex3f( const float x, const float y, const float z = 1.0 );
409 void /*GFXDRVAPI*/ GFXVertex3f( const double x, const double y, const double z = 1.0 );
410 void /*GFXDRVAPI*/ GFXVertex3d( const double x, const double y, const double z = 1.0 );
411 
413 void /*GFXDRVAPI*/ GFXVertexf( const Vector &v );
414 void /*GFXDRVAPI*/ GFXVertexf( const QVector &v );
416 void /*GFXDRVAPI*/ GFXEnd();
417 void /*GFXDRVAPI*/ GFXCircle( float x, float y, float r1, float r2 );
419 void GFXOptimizeList( GFXVertex *old, int numV, GFXVertex **newlist, int *numnewVertices, unsigned int **indices );
420 
421 void GFXFogMode( const FOGMODE fog );
422 void GFXFogDensity( const float fogdensity );
423 void GFXFogLimits( const float fognear, const float fogfar );
424 void GFXFogColor( GFXColor c );
425 void GFXFogIndex( const int index );
426 //display list
428 void /*GFXDRVAPI*/ GFXCallList( int list );
429 
430 //pick mode
431 void /*GFXDRVAPI*/ GFXBeginPick( int x, int y, int xsize, int ysize );
432 void /*GFXDRVAPI*/ GFXSetPickName( int name );
433 //bool GFXCheckPicked();
434 vector< PickData >* /*GFXDRVAPI*/ GFXEndPick();
435 
436 //Subwindow management
438 void /*GFXDRVAPI*/ GFXSubwindow( int x, int y, int xsize, int ysize );
439 void /*GFXDRVAPI*/ GFXSubwindow( float x, float y, float xsize, float ysize );
440 
441 //Coordinate system conversion
443 Vector /*GFXDRVAPI*/ GFXDeviceToEye( int x, int y );
445 {
451 };
452 void GFXTextureCoordGenMode( int stage, GFXTEXTURECOORDMODE tex, const float params[4], const float paramt[4] );
453 
454 int GFXCreateProgram( const char *vertex, const char *fragment, const char *extra_defines );
455 void GFXDestroyProgram( int program );
456 //program created if necessary and active
457 int GFXActivateShader( const char *program = NULL /*null for default prog*/ );
458 int GFXActivateShader( int program );
459 void GFXDeactivateShader();
460 //return location of named value
461 int GFXNamedShaderConstant( char *progID, const char *name );
462 int GFXNamedShaderConstant( int progID, const char *name );
463 int GFXShaderConstant( int name, Vector value );
464 int GFXShaderConstant( int name, GFXColor value );
465 int GFXShaderConstant( int name, const float *value );
466 int GFXShaderConstanti( int name, int value );
467 int GFXShaderConstant( int name, float v1, float v2, float v3, float v4 );
468 int GFXShaderConstant( int name, float v1 );
469 int GFXShaderConstant4v( int name, unsigned int numvals, const float *value );
470 int GFXShaderConstantv( int name, unsigned int numvals, const float *value );
471 int GFXShaderConstantv( int name, unsigned int numvals, const int *value );
474 void GFXUploadLightState( int max_light_location, int active_light_array, int apparent_light_size_array, bool shader, vector<int>::const_iterator begin, vector<int>::const_iterator end );
475 bool GFXShaderReloaded();
477 #endif
478