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 File Reference
#include <cstddef>
#include <vector>
#include "gfx/vec.h"
#include "gfxlib_struct.h"

Go to the source code of this file.

Macros

#define GFXDRVAPI
 

Enumerations

enum  GFXTEXTUREWRAPMODES { GFXREPEATTEXTURE, GFXCLAMPTEXTURE, GFXBORDERTEXTURE }
 
enum  GFXTEXTUREENVMODES {
  GFXREPLACETEXTURE, GFXADDTEXTURE, GFXMODULATETEXTURE, GFXADDSIGNEDTEXTURE,
  GFXCOMPOSITETEXTURE, GFXINTERPOLATETEXTURE, GFXDETAILTEXTURE
}
 
enum  GFXTEXTURECOORDMODE {
  NO_GEN, EYE_LINEAR_GEN, OBJECT_LINEAR_GEN, SPHERE_MAP_GEN,
  CUBE_MAP_GEN
}
 

Functions

void GFXInit (int, char **)
 Loads Glut and graphics drivers. More...
 
void GFXLoop (void main_loop())
 loops on the function over and over More...
 
void GFXShutdown ()
 Shuts down the graphics subsystem. More...
 
void GFXBeginScene ()
 resets all local lights and sets identity matrix More...
 
void GFXEndScene ()
 Flushes and Swaps buffers. More...
 
void GFXClear (const GFXBOOL colorbuffer, const GFXBOOL depthbuffer=GFXTRUE, const GFXBOOL stencilbuffer=GFXTRUE)
 Clears the Z buffer. Also clears color buffer if GFXTRUE passed in. More...
 
void GFXCreateLightContext (int &con_number)
 creates a light context (relevant to a star system) to add lights to More...
 
void GFXDeleteLightContext (const int con_number)
 Deletes a light context (hence a star system) More...
 
void GFXSetLightContext (const int con_number)
 Sets active light context (restores all gllights in such context) More...
 
GFXBOOL GFXLightContextAmbient (const GFXColor &amb)
 Sets the ambient light value. More...
 
GFXBOOL GFXGetLightContextAmbient (GFXColor &amb)
 Gets the ambient light value. More...
 
void GFXPickLights (const Vector &center, const float radius)
 picks and activates local lights near to "center" More...
 
void GFXPickLights (const Vector &center, const float radius, vector< int > &lights, const int maxlights, const bool pickglobals)
 picks and does not activate local lights near to "center" More...
 
void GFXPickLights (vector< int >::const_iterator begin, vector< int >::const_iterator end)
 activates local lights picked by GFXPickLight More...
 
GFXBOOL GFXSetSeparateSpecularColor (const GFXBOOL spec)
 Sets the light model to have separate specular color (if available) More...
 
GFXBOOL GFXSetCutoff (const float cutoff)
 Sets the intensity cutoff before picked lights are ignored. More...
 
void GFXSetOptimalIntensity (const float newint, const float saturatevalue)
 Sets the optimal intensity given that Optimal number of lights is fulfilled. More...
 
GFXBOOL GFXSetOptimalNumLights (const int numlights)
 Sets number of lights graphics can handle optimally. More...
 
GFXBOOL GFXCreateLight (int &light, const GFXLight &, const bool global)
 
void GFXDeleteLight (const int light)
 Deletes a light, removing it from the light table if necessary. More...
 
GFXBOOL GFXEnableLight (const int light)
 activates a light if not already activated More...
 
GFXBOOL GFXDisableLight (const int light)
 Deactivates an active light. More...
 
GFXBOOL GFXSetLight (const int light, const enum LIGHT_TARGET, const GFXColor &color)
 Modifies the parameters of the given light. More...
 
void GFXPushGlobalEffects ()
 
GFXBOOL GFXPopGlobalEffects ()
 This function undoes the above function to restore the global lights after specialFX phase. More...
 
void GFXSetMaterial (unsigned int &number, const GFXMaterial &material)
 Creates a new material given a material struct. Will search through already made materials for matching materials to minimize switching. More...
 
void GFXModifyMaterial (const unsigned int number, const GFXMaterial &material)
 Modifies the given material to be like the passed in structure. More...
 
GFXBOOL GFXGetMaterial (const unsigned int number, GFXMaterial &material)
 Gets the statistics of the material stored in number. More...
 
const GFXMaterialGFXGetMaterial (const unsigned int number)
 
void GFXSelectMaterialHighlights (const unsigned int number, const GFXColor &ambient, const GFXColor &diffuse, const GFXColor &specular, const GFXColor &emmissive)
 Tells Graphics library which material to use on next polygon if lighting enabled. More...
 
void GFXSelectMaterial (const unsigned int number)
 
void GFXHudMode (const bool Enter)
 
void GFXRestoreHudMode ()
 
void GFXCenterCamera (const bool Enter)
 
void GFXTranslateView (const QVector &r)
 
void GFXLoadMatrixView (const Matrix &matrix)
 
void GFXGetMatrixView (Matrix &m)
 
void GFXTranslateProjection (const Vector &r)
 Translates the current "mode" matrix by a given vector. More...
 
void GFXTranslateModel (const QVector &r)
 
void GFXMultMatrixModel (const Matrix &matrix)
 Multipliex the current "mode" matrix by a given matrix. More...
 
void GFXLoadMatrixModel (const Matrix &matrix)
 loads a given matrix to the current "mode" More...
 
void GFXLoadMatrixProjection (const float matrix[16])
 
void GFXLoadIdentity (const MATRIXMODE mode)
 Loads the identity matrix for the given mode. More...
 
void GFXGetMatrixModel (Matrix &matrix)
 retrieves the matrix for a given mode. More...
 
float GFXGetZPerspective (const float z)
 Given the current projection matrix, how much will the model be divided by. More...
 
float GFXGetXInvPerspective ()
 Screen to eye. More...
 
float GFXGetYInvPerspective ()
 
void GFXPerspective (float fov, float aspect, float znear, float zfar, float cockpit_offset)
 Sets the Projection matrix to have fov and aspect as follows (fov is field of view in radians, aspect is width/height znear and zfar are clip planes. More...
 
void GFXParallel (float left, float right, float bottom, float top, float znear, float zfar)
 Sets the Projection matrix to a parallel view with given paramters. More...
 
void GFXViewPort (int minx, int miny, int maxx, int maxy)
 Sets the final translation to screen coordinates, Also adjusts range of clearing. More...
 
void GFXLookAt (Vector eye, QVector center, Vector up)
 Sets the VIEW matrix to look from center in direction of eye with up vector up. More...
 
void GFXGetFrustum (double f[6][4])
 Gets the 6 clip planes of the current Projection matrix. More...
 
void GFXCalculateFrustum ()
 Calculates frustum matrix (internal use) More...
 
void GFXCalculateFrustum (double frustum[6][4], const Matrix &modlmatrix, const float *projection)
 Calculates the planes for a given frustum in 3space given a matrix and a projection. More...
 
void GFXGetFrustumVars (bool, float *l, float *r, float *b, float *t, float *n, float *f)
 Saves and restores last used left,right,bot,top,near,far vals (internal use) More...
 
float GFXSphereInFrustum (const QVector &Center, float Radius)
 checks if a sphere is in the currently loaded Frustum given its center and radius More...
 
float GFXSphereInFrustum (double f[6][4], const QVector &Center, float Radius)
 Checks if a sphere is in the given frustum calculated by GFXCalculateFrustum. Used in Unit clipping. More...
 
void GFXBoxInFrustumModel (const Matrix &model)
 
CLIPSTATE GFXBoxInFrustum (const Vector &min, const Vector &max)
 
CLIPSTATE GFXBoxInFrustum (double f[6][4], const Vector &min, const Vector &max)
 
CLIPSTATE GFXTransformedBoxInFrustum (const Vector &min, const Vector &max)
 
CLIPSTATE GFXSpherePartiallyInFrustum (const Vector &cent, const float r)
 
CLIPSTATE GFXTransformedSpherePartiallyInFrustum (const Vector &cent, const float r)
 
CLIPSTATE GFXSpherePartiallyInFrustum (double f[6][4], const Vector &cent, const float r)
 
void GFXFrustum (float *mat, float *inv, float left, float right, float bottom, float top, float nearval, float farval)
 Given matrices, calculates the matrix and inverse matrix of a projection matrix to go from screen to 3-space coordinates. More...
 
GFXBOOL GFXCreateTexture (int width, int height, TEXTUREFORMAT externaltextureformat, int *handle, char *palette=0, int texturestage=0, enum FILTER mipmap=MIPMAP, enum TEXTURE_TARGET texture_target=TEXTURE2D, enum ADDRESSMODE address_mode=DEFAULT_ADDRESS_MODE)
 
void GFXPrioritizeTexture (unsigned int handle, float priority)
 Sets the priority of the texture for memory management. More...
 
void GFXAttachPalette (unsigned char *palette, int handle)
 Attaches a given palette to the current texture. More...
 
GFXBOOL GFXTransferTexture (unsigned char *buffer, int handle, int inWidth, int inHeight, enum TEXTUREFORMAT internalformat, enum TEXTURE_IMAGE_TARGET image2D=TEXTURE_2D, int max_texture_dimension=65536, GFXBOOL detailtexture=GFXFALSE, unsigned int pageIndex=0)
 
GFXBOOL GFXTransferSubTexture (unsigned char *buffer, int handle, int x, int y, unsigned int width, unsigned int height, enum TEXTURE_IMAGE_TARGET image2D=TEXTURE_2D)
 
void GFXDeleteTexture (int handle)
 Deletes the texture from the graphics card. More...
 
void GFXDestroyAllTextures ()
 Cleans up all textures. More...
 
void GFXSelectTexture (int handle, int stage=0)
 Selects the current texture as being "active" so further drawn objects will have it. More...
 
GFXBOOL GFXCapture (char *filename)
 Screen capture (FIXME) More...
 
void GFXEnable (const enum STATE)
 Enables and disables given state. More...
 
void GFXDisable (const enum STATE)
 
void GFXToggleTexture (bool enable, int whichstage, enum TEXTURE_TARGET target=TEXTURE2D)
 
void GFXTextureAddressMode (const ADDRESSMODE mode, enum TEXTURE_TARGET target=TEXTURE2D)
 Sets texture to clamp or wrap texture coordinates. More...
 
void GFXBlendMode (const enum BLENDFUNC src, const enum BLENDFUNC dst)
 Sets the current blend mode to src,dst. More...
 
void GFXGetBlendMode (enum BLENDFUNC &src, enum BLENDFUNC &dst)
 Gets the current blend mode to src,dst. More...
 
void GFXColorMaterial (int LIGHTTARG)
 
void GFXPointSize (const float size)
 Sets the size in pixels of a GFXPOINT. More...
 
void GFXLineWidth (const float size)
 Sets the line width in pixels of a GFXLINE. More...
 
void GFXPushBlendMode ()
 Pushes and saves current blend mode. More...
 
void GFXPopBlendMode ()
 Restores previous blend mode. More...
 
void GFXActiveTexture (const int stage)
 Sets the active texture stage in multitexture. More...
 
enum DEPTHFUNC GFXDepthFunc ()
 Returns the current depth function. More...
 
void GFXDepthFunc (const enum DEPTHFUNC)
 Sets up depth compare function. More...
 
enum DEPTHFUNC GFXStencilFunc ()
 Returns the current stencil test function. More...
 
void GFXStencilFunc (enum DEPTHFUNC *pFunc, int *pRef, int *pMask)
 Gets details about the current stancil compare function - Specify NULL for unwanted fields. More...
 
void GFXStencilFunc (enum DEPTHFUNC sfunc, int ref, unsigned int mask)
 Sets up a stencil compare function. More...
 
void GFXStencilOp (enum STENCILOP *pFail, enum STENCILOP *pZfail, enum STENCILOP *pZpass)
 Gets the current stencil write operations - Specify NULL for unwanted fields. More...
 
void GFXStencilOp (enum STENCILOP fail, enum STENCILOP zfail, enum STENCILOP zpass)
 Sets up the stencil write operations. More...
 
unsigned int GFXStencilMask ()
 Returns the current stencil write mask. More...
 
void GFXStencilMask (unsigned int mask)
 Sets the stencil write mask. More...
 
void GFXAlphaTest (const enum DEPTHFUNC, const float ref)
 Turns on alpha testing mode (or turns if off if DEPTHFUNC is set to ALWAYS. More...
 
void GFXTextureWrap (int stage, GFXTEXTUREWRAPMODES mode, enum TEXTURE_TARGET target=TEXTURE2D)
 
void GFXTextureEnv (int stage, GFXTEXTUREENVMODES mode, float arg2=0)
 
bool GFXMultiTexAvailable ()
 
void GFXPolygonOffset (float factor, float units)
 Sets Depth Offset for polgyons. More...
 
void GFXGetPolygonOffset (float *factor, float *units)
 
void GFXPolygonMode (const enum POLYMODE)
 Sets the polygon rasterization mode. More...
 
void GFXCullFace (const enum POLYFACE)
 Sets the facecull mode. More...
 
void GFXBegin (const enum POLYTYPE)
 Begins a polytype. More...
 
void GFXColorf (const GFXColor &col)
 Specifies a color for henceforth drawn vertices to share. More...
 
void GFXBlendColor (const GFXColor &col)
 specifies the current blend color More...
 
void GFXColor4f (const float r, const float g, const float b, const float a=1.0)
 Specifies a color for henceforth drawn vertices to share. More...
 
GFXColor GFXColorf ()
 Gets the current color. More...
 
void GFXTexCoord2f (const float s, const float t)
 Specifies a pair of texture coordinates for given vertex. More...
 
void GFXTexCoord4f (const float s, const float t, const float u, const float v)
 Specifies four texture coordinates for a given vertex (2 textures) More...
 
void GFXTexCoord224f (const float s, const float t, const float s2, const float t2, const float s3, const float t3, const float u3, const float v3)
 Specifies four texture coordinates for a given vertex (3 textures) More...
 
void GFXNormal3f (const float i, const float j, const float k)
 Specifies a normal with 3 floats. More...
 
void GFXNormal (const Vector &n)
 Specifies a notmal with 1 vector. More...
 
void GFXVertex3f (const float x, const float y, const float z=1.0)
 Specifies a vertex with 3 floats. More...
 
void GFXVertex3f (const double x, const double y, const double z=1.0)
 
void GFXVertex3d (const double x, const double y, const double z=1.0)
 
void GFXVertexf (const Vector &v)
 Specifies a vertex with a vector. More...
 
void GFXVertexf (const QVector &v)
 
void GFXEnd ()
 Ends the current set of polytypes. More...
 
void GFXCircle (float x, float y, float r1, float r2)
 
void GFXOptimizeList (GFXVertex *old, int numV, GFXVertex **newlist, int *numnewVertices, unsigned int **indices)
 Optimizes a list to reuse repeated vertices! More...
 
void GFXFogMode (const FOGMODE fog)
 
void GFXFogDensity (const float fogdensity)
 
void GFXFogLimits (const float fognear, const float fogfar)
 
void GFXFogColor (GFXColor c)
 
void GFXFogIndex (const int index)
 
void GFXCallList (int list)
 Draws a given display list. More...
 
void GFXBeginPick (int x, int y, int xsize, int ysize)
 
void GFXSetPickName (int name)
 
vector< PickData > * GFXEndPick ()
 
void GFXSubwindow (int x, int y, int xsize, int ysize)
 Creates a subwindow with the current parameters for center and size. More...
 
void GFXSubwindow (float x, float y, float xsize, float ysize)
 
Vector GFXDeviceToEye (int x, int y)
 convertes eyespace to 3space at the near plane More...
 
void GFXTextureCoordGenMode (int stage, GFXTEXTURECOORDMODE tex, const float params[4], const float paramt[4])
 
int GFXCreateProgram (const char *vertex, const char *fragment, const char *extra_defines)
 
void GFXDestroyProgram (int program)
 
int GFXActivateShader (const char *program=NULL)
 
int GFXActivateShader (int program)
 
void GFXDeactivateShader ()
 
int GFXNamedShaderConstant (char *progID, const char *name)
 
int GFXNamedShaderConstant (int progID, const char *name)
 
int GFXShaderConstant (int name, Vector value)
 
int GFXShaderConstant (int name, GFXColor value)
 
int GFXShaderConstant (int name, const float *value)
 
int GFXShaderConstanti (int name, int value)
 
int GFXShaderConstant (int name, float v1, float v2, float v3, float v4)
 
int GFXShaderConstant (int name, float v1)
 
int GFXShaderConstant4v (int name, unsigned int numvals, const float *value)
 
int GFXShaderConstantv (int name, unsigned int numvals, const float *value)
 
int GFXShaderConstantv (int name, unsigned int numvals, const int *value)
 
bool GFXDefaultShaderSupported ()
 
void GFXReloadDefaultShader ()
 
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)
 
bool GFXShaderReloaded ()
 
int GFXGetProgramVersion ()
 

Macro Definition Documentation

#define GFXDRVAPI

Definition at line 31 of file gfxlib.h.

Enumeration Type Documentation

Enumerator
NO_GEN 
EYE_LINEAR_GEN 
OBJECT_LINEAR_GEN 
SPHERE_MAP_GEN 
CUBE_MAP_GEN 

Definition at line 444 of file gfxlib.h.

445 {
446  NO_GEN,
451 };
Enumerator
GFXREPLACETEXTURE 
GFXADDTEXTURE 
GFXMODULATETEXTURE 
GFXADDSIGNEDTEXTURE 
GFXCOMPOSITETEXTURE 
GFXINTERPOLATETEXTURE 
GFXDETAILTEXTURE 

Definition at line 356 of file gfxlib.h.

Enumerator
GFXREPEATTEXTURE 
GFXCLAMPTEXTURE 
GFXBORDERTEXTURE 

Definition at line 350 of file gfxlib.h.

351 {
353  GFXCLAMPTEXTURE, //clamp to edge, not to border
354  GFXBORDERTEXTURE //clamp to border, not to edge
355 };

Function Documentation

int GFXActivateShader ( const char *  program = NULL)

Definition at line 519 of file gl_program.cpp.

References getDefaultProgram(), GFXActivateShader(), and GFXCreateProgram().

Referenced by GFXActivateShader(), GFXDeactivateShader(), and GFXShaderReloaded().

520 {
521  int defaultprogram = getDefaultProgram();
522  int curprogram = defaultprogram;
523  if (program)
524  curprogram = GFXCreateProgram( program, program, NULL );
525  return GFXActivateShader( curprogram );
526 }
int GFXActivateShader ( int  program)

Definition at line 504 of file gl_program.cpp.

References glUseProgram_p, and programChanged.

505 {
506  static int lastprogram = 0;
507  if (program != lastprogram)
508  programChanged = true;
509  if (program != lastprogram
510 #ifndef __APPLE__
511  && glUseProgram_p
512 #endif
513  ) {
514  glUseProgram_p( program );
515  lastprogram = program;
516  } else {return 0; } return program;
517 }
void GFXActiveTexture ( const int  stage)

Sets the active texture stage in multitexture.

Definition at line 594 of file gl_state.cpp.

References activeTextureStage, gl_options, glActiveTextureARB_p, and gl_options_t::Multitexture.

Referenced by GameStarSystem::activateLightMap(), Background::Draw(), GFXCreateTexture(), GFXDisable(), GFXEnable(), GFXInit(), GFXSelectTexture(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXTextureWrap(), GFXToggleTexture(), LookAtHelper(), Texture::MakeActive(), RestoreSpecMapState(), and SetupSpecMapSecondPass().

595 {
596 #if !defined (IRIX)
598  glActiveTextureARB_p( GL_TEXTURE0_ARB+stage );
599  activeTextureStage = stage;
600  } else {
601  activeTextureStage = stage; //This ensures consistent behavior - they shouldn't even call us
602  }
603 #endif
604 }
void GFXAlphaTest ( const enum  DEPTHFUNC,
const float  ref 
)

Turns on alpha testing mode (or turns if off if DEPTHFUNC is set to ALWAYS.

Definition at line 606 of file gl_state.cpp.

References ALWAYS, EQUAL, GEQUAL, GREATER, LEQUAL, LESS, NEQUAL, and NEVER.

Referenced by Bolt::Draw(), Stars::Draw(), GameCockpit::Draw(), BaseInterface::Room::BaseVSSprite::Draw(), DrawHUDSprite(), and setupGLState().

607 {
608  if (df == ALWAYS) {
609  glDisable( GL_ALPHA_TEST );
610  return;
611  } else {
612  glEnable( GL_ALPHA_TEST );
613  }
614  GLenum tmp;
615  switch (df)
616  {
617  case NEVER:
618  tmp = GL_NEVER;
619  break;
620  case LESS:
621  tmp = GL_LESS;
622  break;
623  case EQUAL:
624  tmp = GL_EQUAL;
625  break;
626  case LEQUAL:
627  tmp = GL_LEQUAL;
628  break;
629  case GREATER:
630  tmp = GL_GREATER;
631  break;
632  case NEQUAL:
633  tmp = GL_NOTEQUAL;
634  break;
635  case GEQUAL:
636  tmp = GL_GEQUAL;
637  break;
638  default:
639  case ALWAYS:
640  tmp = GL_ALWAYS;
641  break;
642  }
643  glAlphaFunc( tmp, ref );
644 }
void GFXAttachPalette ( unsigned char *  palette,
int  handle 
)

Attaches a given palette to the current texture.

Definition at line 410 of file gl_texture.cpp.

References ConvertPalette(), and textures.

411 {
412  ConvertPalette( textures[handle].palette, palette );
413  //memcpy (textures[handle].palette,palette,768);
414 }
void GFXBegin ( const enum  POLYTYPE)

Begins a polytype.

Definition at line 152 of file gl_misc.cpp.

References GFXLINE, GFXLINESTRIP, GFXPOINT, GFXPOLY, GFXQUAD, GFXQUADSTRIP, GFXTRI, GFXTRIFAN, and GFXTRISTRIP.

Referenced by AnimationDraw(), ParticlePoint::Draw(), GuiTexture::draw(), Background::Draw(), VSSprite::Draw(), BaseInterface::Room::BaseText::Draw(), BaseInterface::Room::Draw(), ParticleTrail::DrawAndUpdate(), Animation::DrawAsVSSprite(), Radar::SphereDisplay::DrawBackground(), Radar::BubbleDisplay::DrawBackground(), NavigationSystem::DrawButtonOutline(), NavigationSystem::DrawCircle(), DrawCrosshairs(), NavigationSystem::DrawCursor(), DrawDamageFlash(), DrawFrustum(), NavigationSystem::DrawGalaxy(), NavigationSystem::DrawGrid(), Radar::PlaneDisplay::DrawGround(), DrawGun(), NavigationSystem::DrawHalfCircleBottom(), NavigationSystem::DrawHalfCircleTop(), DrawHUDSprite(), DrawITTSLine(), DrawITTSMark(), NavigationSystem::DrawJump(), NavigationSystem::DrawMissile(), NavigationSystem::DrawNavCircle(), Animation::DrawNoTransform(), Animation::DrawNow(), DrawOneTargetBox(), NavigationSystem::DrawPlanet(), DrawShield(), DrawSquare(), NavigationSystem::DrawStation(), Radar::PlaneDisplay::DrawTarget(), NavigationSystem::DrawTargetCorners(), Radar::SphereDisplay::DrawTargetMarker(), Radar::BubbleDisplay::DrawTargetMarker(), Radar::PlaneDisplay::DrawTargetMarker(), Radar::SphereDisplay::DrawTrack(), Radar::BubbleDisplay::DrawTrack(), GFXCircle(), and Box::ProcessDrawQueue().

153 {
154  GLenum mode;
155  switch (ptype)
156  {
157  case GFXTRI:
158  mode = GL_TRIANGLES;
159  break;
160  case GFXLINE:
161  mode = GL_LINES;
162  break;
163  case GFXTRISTRIP:
164  mode = GL_TRIANGLE_STRIP;
165  break;
166  case GFXTRIFAN:
167  mode = GL_TRIANGLE_FAN;
168  break;
169  case GFXQUAD:
170  mode = GL_QUADS;
171  break;
172  case GFXQUADSTRIP:
173  mode = GL_QUAD_STRIP;
174  break;
175  case GFXLINESTRIP:
176  mode = GL_LINE_STRIP;
177  break;
178  case GFXPOLY:
179  mode = GL_POLYGON;
180  break;
181  case GFXPOINT:
182  mode = GL_POINTS;
183  break;
184  default:
185  mode = GL_POINTS;
186  assert( 0 ||! "Bad case in gl_misc.cpp." );
187  break;
188  }
189  glBegin( mode );
190 }
void GFXBeginPick ( int  x,
int  y,
int  xsize,
int  ysize 
)

Definition at line 18 of file gl_pick.cpp.

References GFXGetFrustumVars(), picked_objects, GFXMatrices::projection, selectbuf, and SELECTBUF_SIZE.

19 {
20  //save and change gl projection matrix
21  GLint viewport[4];
22 
23  float left, right, bottom, top, fnear, ffar;
24  GFXGetFrustumVars( true, &left, &right, &bottom, &top, &fnear, &ffar );
25 
26  glMatrixMode( GL_PROJECTION );
27  glPushMatrix();
28  glLoadIdentity();
29  glGetIntegerv( GL_VIEWPORT, viewport );
30  gluPickMatrix( x, viewport[3]-y, xsize, ysize, viewport );
31  glMultMatrixf( projection );
32 
33  glSelectBuffer( SELECTBUF_SIZE, selectbuf );
34  glRenderMode( GL_SELECT );
35  glGetError();
36 
37  delete picked_objects;
38  picked_objects = new vector< PickData > ();
39 }
void GFXBeginScene ( )

resets all local lights and sets identity matrix

Definition at line 54 of file gl_misc.cpp.

References GFXLoadIdentity(), light_rekey_frame(), and MODEL.

Referenced by base_main_loop(), bootstrap_draw(), gamemenu_draw(), nav_main_loop(), GameUniverse::StartDraw(), and GameUniverse::StartGFX().

55 {
56  GFXLoadIdentity( MODEL ); //bad this should instead load the cached view matrix
58 }
void GFXBlendColor ( const GFXColor col)

specifies the current blend color

void GFXBlendMode ( const enum BLENDFUNC  src,
const enum BLENDFUNC  dst 
)

Sets the current blend mode to src,dst.

Definition at line 342 of file gl_state.cpp.

References blendToGL(), currBlendMode, BlendMode::dfactor, and BlendMode::sfactor.

Referenced by bootstrap_draw(), CoordinateSelect::Draw(), Bolt::Draw(), Background::Draw(), VDU::Draw(), Stars::Draw(), WindowManager::draw(), GameCockpit::Draw(), BaseInterface::Room::BaseVSSprite::Draw(), BaseInterface::Room::Draw(), NavigationSystem::Draw(), GFXVertexList::Draw(), UnivMap::Draw(), ParticleTrail::DrawAndUpdate(), Animation::DrawAsVSSprite(), NavigationSystem::DrawButtonOutline(), NavigationSystem::DrawCircle(), DrawCrosshairs(), NavigationSystem::DrawCursor(), DrawDamageFlash(), DrawDockingBoxes(), DrawFrustum(), NavigationSystem::DrawGalaxy(), DrawGlutMouse(), NavigationSystem::DrawGrid(), NavigationSystem::DrawHalfCircleBottom(), NavigationSystem::DrawHalfCircleTop(), DrawHUDSprite(), DrawITTSLine(), DrawITTSMark(), NavigationSystem::DrawJump(), PaintText::drawLines(), NavigationSystem::DrawMissile(), NavigationSystem::DrawMission(), NavigationSystem::DrawNavCircle(), Animation::DrawNoTransform(), Mesh::DrawNow(), DrawOneTargetBox(), NavigationSystem::DrawPlanet(), NavigationSystem::DrawSectorList(), DrawShield(), NavigationSystem::DrawShip(), NavigationSystem::DrawStation(), NavigationSystem::DrawTargetCorners(), GFXInit(), GFXPopBlendMode(), Box::ProcessDrawQueue(), Halo::ProcessDrawQueue(), Logo::ProcessDrawQueue(), Animation::ProcessDrawQueue(), Beam::ProcessDrawQueue(), Animation::ProcessFarDrawQueue(), QuadTree::Render(), Briefing::Render(), SetupCloakState(), SetupDamageMapThirdPass(), SetupEnvmapPass(), SetupGlowMapFourthPass(), setupGLState(), SetupSpecMapFirstPass(), SetupSpecMapSecondPass(), StartGUIFrame(), TerrainMakeActive(), and TerrainMakeClearActive().

343 {
344  GLenum sfactor = blendToGL(src);
345  GLenum dfactor = blendToGL(dst);
346  glBlendFunc( sfactor, dfactor );
347  currBlendMode.sfactor = src;
348  currBlendMode.dfactor = dst;
349 }
CLIPSTATE GFXBoxInFrustum ( const Vector min,
const Vector max 
)

Definition at line 14 of file gl_clip.cpp.

References BoxFrust, and GFXBoxInFrustum().

Referenced by IdentityTransform::BoxInFrustum(), GFXBoxInFrustum(), and GFXTransformedBoxInFrustum().

15 {
16  return GFXBoxInFrustum( BoxFrust, min, max );
17 }
CLIPSTATE GFXBoxInFrustum ( double  f[6][4],
const Vector min,
const Vector max 
)

Definition at line 48 of file gl_clip.cpp.

References GFX_NOT_VISIBLE, GFX_PARTIALLY_VISIBLE, GFX_TOTALLY_VISIBLE, i, j, v, and Vector.

49 {
50  //Doesn't do a perfect test for NOT_VISIBLE. Just checks to
51  //see if all box vertices are outside at least one frustum
52  //plane. Some pathological boxes could return SOME_CLIP even
53  //though they're really fully outside the frustum. But that
54  //won't hurt us too much if it isn't a common case; the
55  //contents will just be culled/clipped at a later stage in the
56  //pipeline.
57 
58  //Check each vertex of the box against the view frustum, and compute
59  //bit codes for whether the point is outside each plane.
60  int OrCodes = 0, AndCodes = ~0;
61  for (int i = 0; i < 8; i++) {
62  Vector v( min.i, min.j, min.k );
63  if (i&1) v.i = (max.i);
64  if (i&2) v.j = (max.j);
65  if (i&4) v.k = (max.k);
66  //Now check against the frustum planes.
67  int Code = 0;
68  int Bit = 1;
69  for (int j = 0; j < 6; j++, Bit <<= 1)
70  if (v.i*f[j][0]+v.j*f[j][1]+v.k*f[j][2]+f[j][3] < 0)
71  //The point is outside this plane.
72  Code |= Bit;
73  OrCodes |= Code;
74  AndCodes &= Code;
75  }
76  //Based on bit-codes, return culling results.
77  if (OrCodes == 0)
78  //The box is completely within the frustum.
79  return GFX_TOTALLY_VISIBLE;
80  else if (AndCodes != 0)
81  //All the points are outside one of the frustum planes.
82  return GFX_NOT_VISIBLE;
83  else
84  return GFX_PARTIALLY_VISIBLE;
85 }
void GFXBoxInFrustumModel ( const Matrix model)

Definition at line 187 of file gl_clip.cpp.

References BoxFrust, GFXCalculateFrustum(), MultMatrix(), GFXMatrices::projection, and GFXMatrices::view.

Referenced by QuadTree::Render().

188 {
189  Matrix tmp;
190  MultMatrix( tmp, view, model );
192 }
void GFXCalculateFrustum ( )

Calculates frustum matrix (internal use)

Definition at line 193 of file gl_clip.cpp.

References frust, GFXCalculateFrustum(), GFXMatrices::projection, and GFXMatrices::view.

Referenced by GFXBoxInFrustumModel(), GFXCalculateFrustum(), ClickList::requestIterator(), and Camera::UpdateGFX().

194 {
196 }
void GFXCalculateFrustum ( double  frustum[6][4],
const Matrix modlmatrix,
const float projection 
)

Calculates the planes for a given frustum in 3space given a matrix and a projection.

Definition at line 223 of file gl_clip.cpp.

References UniverseUtil::sqrt(), and WackyMultFloatMatrix().

224 {
225  double clip[16];
226  WackyMultFloatMatrix( clip, proj, modl );
227  double t;
228  /* Extract the numbers for the RIGHT plane */
229  frustum[0][0] = clip[3]-clip[0];
230  frustum[0][1] = clip[7]-clip[4];
231  frustum[0][2] = clip[11]-clip[8];
232  frustum[0][3] = clip[15]-clip[12];
233 
234  /* Normalize the result */
235  t = sqrt( frustum[0][0]*frustum[0][0]+frustum[0][1]*frustum[0][1]+frustum[0][2]*frustum[0][2] );
236  frustum[0][0] /= t;
237  frustum[0][1] /= t;
238  frustum[0][2] /= t;
239  frustum[0][3] /= t;
240 
241  /* Extract the numbers for the LEFT plane */
242  frustum[1][0] = clip[3]+clip[0];
243  frustum[1][1] = clip[7]+clip[4];
244  frustum[1][2] = clip[11]+clip[8];
245  frustum[1][3] = clip[15]+clip[12];
246 
247  /* Normalize the result */
248  t = sqrt( frustum[1][0]*frustum[1][0]+frustum[1][1]*frustum[1][1]+frustum[1][2]*frustum[1][2] );
249  frustum[1][0] /= t;
250  frustum[1][1] /= t;
251  frustum[1][2] /= t;
252  frustum[1][3] /= t;
253 
254  /* Extract the BOTTOM plane */
255  frustum[2][0] = clip[3]+clip[1];
256  frustum[2][1] = clip[7]+clip[5];
257  frustum[2][2] = clip[11]+clip[9];
258  frustum[2][3] = clip[15]+clip[13];
259 
260  /* Normalize the result */
261  t = sqrt( frustum[2][0]*frustum[2][0]+frustum[2][1]*frustum[2][1]+frustum[2][2]*frustum[2][2] );
262  frustum[2][0] /= t;
263  frustum[2][1] /= t;
264  frustum[2][2] /= t;
265  frustum[2][3] /= t;
266 
267  /* Extract the TOP plane */
268  frustum[3][0] = clip[3]-clip[1];
269  frustum[3][1] = clip[7]-clip[5];
270  frustum[3][2] = clip[11]-clip[9];
271  frustum[3][3] = clip[15]-clip[13];
272 
273  /* Normalize the result */
274  t = sqrt( frustum[3][0]*frustum[3][0]+frustum[3][1]*frustum[3][1]+frustum[3][2]*frustum[3][2] );
275  frustum[3][0] /= t;
276  frustum[3][1] /= t;
277  frustum[3][2] /= t;
278  frustum[3][3] /= t;
279 
280  /* Extract the FAR plane */
281  frustum[5][0] = clip[3]-clip[2];
282  frustum[5][1] = clip[7]-clip[6];
283  frustum[5][2] = clip[11]-clip[10];
284  frustum[5][3] = clip[15]-clip[14];
285 
286  /* Normalize the result */
287  t = sqrt( frustum[5][0]*frustum[5][0]+frustum[5][1]*frustum[5][1]+frustum[5][2]*frustum[5][2] );
288  frustum[5][0] /= t;
289  frustum[5][1] /= t;
290  frustum[5][2] /= t;
291  frustum[5][3] /= t;
292 
293  /* Extract the NEAR plane */
294  frustum[4][0] = clip[3]+clip[2];
295  frustum[4][1] = clip[7]+clip[6];
296  frustum[4][2] = clip[11]+clip[10];
297  frustum[4][3] = clip[15]+clip[14];
298 
299  /* Normalize the result */
300  t = sqrt( frustum[4][0]*frustum[4][0]+frustum[4][1]*frustum[4][1]+frustum[4][2]*frustum[4][2] );
301  frustum[4][0] /= t;
302  frustum[4][1] /= t;
303  frustum[4][2] /= t;
304  frustum[4][3] /= t;
305 }
void GFXCallList ( int  list)

Draws a given display list.

Definition at line 312 of file gl_misc.cpp.

Referenced by GFXVertexList::Draw().

313 {
314 //VSFileSystem::Fprintf (stderr,"CallListStart");///causes crash with GF2 privaledge instruction on Win2k in certain instances
315 //fflush (stderr);
316  glCallList( list );
317 //VSFileSystem::Fprintf (stderr,"CallListEnd");
318 //fflush (stderr);
319 }
GFXBOOL GFXCapture ( char *  filename)

Screen capture (FIXME)

Definition at line 73 of file gl_misc.cpp.

References GFXFALSE.

74 {
75  return GFXFALSE;
76 }
void GFXCenterCamera ( const bool  Enter)

Definition at line 224 of file gl_matrix.cpp.

References GFXLoadIdentity(), MODEL, Matrix::p, QVector, and GFXMatrices::view.

Referenced by Background::Draw(), and Mesh::DrawNow().

225 {
226  static QVector tmp;
227  if (Enter) {
228  tmp = view.p;
229  view.p.Set( 0, 0, 0 );
230  glMatrixMode( GL_MODELVIEW );
231  glLoadIdentity();
232  } else {
233  view.p = tmp;
235  }
236 }
void GFXCircle ( float  x,
float  y,
float  r1,
float  r2 
)

Definition at line 37 of file gl_misc.cpp.

References UniverseUtil::cos(), f, g_game, VegaConfig::getVariable(), GFXBegin(), GFXEnd(), GFXLINESTRIP, GFXVertex3f(), i, int, M_PI, Magnitude(), XMLSupport::parse_float(), UniverseUtil::sin(), Vector, vs_config, game_data_t::x_resolution, and game_data_t::y_resolution.

Referenced by DrawCrosshairs().

38 {
39  static float aaccuracy = XMLSupport::parse_float( vs_config->getVariable( "graphics", "circle_accuracy", "0.1" ) );
40  float segmag =
41  ( Vector( wid*g_game.x_resolution, 0,
42  0 )
43  -Vector( wid*g_game.x_resolution*cos( 2.*M_PI/360.0 ), hei*g_game.y_resolution*sin( 2.*M_PI/360.0 ), 0 ) ).Magnitude();
44  int accuracy = (int) ( 360.0f*aaccuracy*(1.0f < segmag ? 1.0 : segmag) );
45  if (accuracy < 4) accuracy = 4;
46  //const int accuracy=((wid*g_game.x_resolution)+(hei*g_game.y_resolution))*M_PI;
48  float iaccuracy = 1.0f/accuracy;
49  for (int i = 0; i <= accuracy; i++)
50  GFXVertex3f( x+wid*cos( i*2.*M_PI*iaccuracy ), y+hei*sin( i*2.*M_PI*iaccuracy ), 0 );
51  GFXEnd();
52 }
void GFXClear ( const GFXBOOL  colorbuffer,
const GFXBOOL  depthbuffer = GFXTRUE,
const GFXBOOL  stencilbuffer = GFXTRUE 
)

Clears the Z buffer. Also clears color buffer if GFXTRUE passed in.

Definition at line 66 of file gl_misc.cpp.

Referenced by bootstrap_draw(), Background::Draw(), WindowManager::draw(), GameCockpit::Draw(), BaseInterface::Room::BaseShip::Draw(), Mesh::ProcessUndrawnMeshes(), Mesh::ProcessZFarMeshes(), Briefing::Render(), and StartGUIFrame().

67 {
68  glClear( (colorbuffer ? GL_COLOR_BUFFER_BIT : 0)
69  |(depthbuffer ? GL_DEPTH_BUFFER_BIT : 0)
70  |(stencilbuffer ? GL_STENCIL_BUFFER_BIT : 0) );
71 }
void GFXColor4f ( const float  r,
const float  g,
const float  b,
const float  a = 1.0 
)
GFXColor GFXColorf ( )

Gets the current color.

Definition at line 197 of file gl_misc.cpp.

198 {
199  float col[4];
200  glGetFloatv( GL_CURRENT_COLOR, col ); //It's best this way, we don't use it much, anyway.
201  return GFXColor( col[0], col[1], col[2], col[3] );
202 }
void GFXColorMaterial ( int  LIGHTTARG)

Definition at line 365 of file gl_state.cpp.

References AMBIENT, DIFFUSE, EMISSION, and SPECULAR.

Referenced by PointStarVlist::BeginDrawState(), SpriteStarVlist::BeginDrawState(), PointStarVlist::EndDrawState(), SpriteStarVlist::EndDrawState(), quadsquare::Render(), RestoreCloakState(), and SetupCloakState().

366 {
367  if (LIGHTTARG) {
368  glEnable( GL_COLOR_MATERIAL );
369  switch (LIGHTTARG)
370  {
371  case EMISSION:
372  glColorMaterial( GL_FRONT_AND_BACK, GL_EMISSION );
373  break;
374  case AMBIENT:
375  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT );
376  break;
377  case DIFFUSE:
378  glColorMaterial( GL_FRONT_AND_BACK, GL_DIFFUSE );
379  break;
380  case (AMBIENT|DIFFUSE):
381  glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
382  break;
383  case SPECULAR:
384  glColorMaterial( GL_FRONT_AND_BACK, GL_SPECULAR );
385  break;
386  }
387  } else {
388  glDisable( GL_COLOR_MATERIAL );
389  }
390 }
GFXBOOL GFXCreateLight ( int light,
const GFXLight ,
const bool  global 
)

GFXCreateLight gets a light as a parameter. It sets light to have the index of the created light for modification in the future. If the light is global, it will always affect objects in space. if the light is not global, it is local and goes into a 3d hashtable to be picked at a later point on a per object basis.

Definition at line 272 of file gl_light.cpp.

References _llights.

Referenced by Stars::Draw(), BaseInterface::Room::BaseShip::Draw(), Mesh::DrawNow(), SetupCloakState(), and Atmosphere::Update().

273 {
274  for (light = 0; light < static_cast<int>(_llights->size()); light++)
275  if ( (*_llights)[light].Target() == -2 )
276  break;
277  if ( light == static_cast<int>(_llights->size()) )
278  _llights->push_back( gfx_light() );
279  return (*_llights)[light].Create( templatecopy, global );
280 }
void GFXCreateLightContext ( int con_number)

creates a light context (relevant to a star system) to add lights to

Definition at line 317 of file gl_light.cpp.

References _ambient_light, _currentContext, _local_lights_dat, GFXBOOL, GFXFALSE, GFXSetLightContext(), GFXTRUE, and SetupGLLightGlobals().

Referenced by GameStarSystem::GameStarSystem(), GFXInit(), and GameUniverse::StartGFX().

318 {
319  static GFXBOOL LightInit = GFXFALSE;
320  if (!LightInit) {
321  LightInit = GFXTRUE;
323  }
324  con_number = _local_lights_dat.size();
325  _currentContext = con_number;
326  _ambient_light.push_back( GFXColor( 0, 0, 0, 1 ) );
327  _local_lights_dat.push_back( vector< gfx_light > () );
328  GFXSetLightContext( con_number );
329 }
int GFXCreateProgram ( const char *  vertex,
const char *  fragment,
const char *  extra_defines 
)

Definition at line 302 of file gl_program.cpp.

References cacheKey(), GFXCreateProgramNoCache(), programCache, and programICache.

Referenced by Technique::Pass::compile(), getDefaultProgram(), GFXActivateShader(), GFXCreateProgram(), and GFXReloadDefaultShader().

303 {
304  ProgramCache::key_type key = cacheKey( vprogram, fprogram, extra_defines );
305  ProgramCache::const_iterator it = programCache.find( key );
306  if ( it != programCache.end() )
307  return it->second;
308  int rv = programCache[key] = GFXCreateProgramNoCache( vprogram, fprogram, extra_defines );
309  programICache[rv] = key;
310  return rv;
311 }
GFXBOOL GFXCreateTexture ( int  width,
int  height,
TEXTUREFORMAT  externaltextureformat,
int handle,
char *  palette = 0,
int  texturestage = 0,
enum FILTER  mipmap = MIPMAP,
enum TEXTURE_TARGET  texture_target = TEXTURE2D,
enum ADDRESSMODE  address_mode = DEFAULT_ADDRESS_MODE 
)

Creates a texture with given w,h & tex format. Returns handle in handle var The palette may be specified but defaults to NULL. Texture Stage indicates Which texture unit the texture must reside on. The filter indicates If linear, bilinear, mipmapping or trilinear filterring should be used. Filtering is clamped to g_game.mipmap so hardware isn't abused (3dfx had trilinear troubles, and it might be a memory constraint) Texture target defines the type of texture it is for eventual cube mapping

Definition at line 312 of file gl_texture.cpp.

References activetexture, ConvertPalette(), CUBEMAP, GetUncompressedTextureFormat(), GFXActiveTexture(), GFXTextureAddressMode(), GFXTRUE, gl_options, GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_RECTANGLE_ARB, height, isPowerOfTwo(), gl_options_t::mipmap, MIPMAP, NEAREST, PALETTE8, TEXTURE1D, TEXTURE2D, TEXTURE3D, TEXTURERECT, textures, TRILINEAR, VSFileSystem::vs_dprintf(), and width.

Referenced by Texture::Bind(), PipelinedTexture::Clone(), PipelinedTexture::PipelinedTexture(), StreamTexture::StreamTexture(), and PipelinedTexture::Swap().

321 {
322  int dummy = 0;
323  if ( ( mipmap&(MIPMAP|TRILINEAR) ) && !isPowerOfTwo( width, dummy ) )
324  VSFileSystem::vs_dprintf( 1, "Width %d not a power of two", width );
325  if ( ( mipmap&(MIPMAP|TRILINEAR) ) && !isPowerOfTwo( height, dummy ) )
326  VSFileSystem::vs_dprintf( 1, "Height %d not a power of two", height );
327  GFXActiveTexture( texturestage );
328  *handle = 0;
329  while ( *handle < static_cast<int>(textures.size()) ) {
330  if (!textures[*handle].alive)
331  break;
332  else
333  (*handle)++;
334  }
335  if ( (*handle) == static_cast<int>(textures.size()) ) {
336  textures.push_back( GLTexture() );
337  textures.back().palette = NULL;
338  textures.back().alive = GFXTRUE;
339  textures.back().name = -1;
340  textures.back().width = textures.back().height = textures.back().iwidth = textures.back().iheight = 1;
341  }
342  switch (texture_target)
343  {
344  case TEXTURE1D:
345  textures[*handle].targets = GL_TEXTURE_1D;
346  break;
347  case TEXTURE2D:
348  textures[*handle].targets = GL_TEXTURE_2D;
349  break;
350 #ifdef GL_EXT_texture3D
351  case TEXTURE3D:
352  textures[*handle].targets = GL_TEXTURE_3D;
353  break;
354 #endif
355  case CUBEMAP:
356  textures[*handle].targets = GL_TEXTURE_CUBE_MAP_EXT;
357  break;
358  case TEXTURERECT:
359  textures[*handle].targets = GL_TEXTURE_RECTANGLE_ARB;
360  break;
361  }
362  //for those libs with stubbed out handle gen't
363  textures[*handle].name = *handle+1;
364  textures[*handle].alive = GFXTRUE;
365  textures[*handle].texturestage = texturestage;
366  textures[*handle].mipmapped = mipmap;
367  glGenTextures( 1, &textures[*handle].name );
368  glBindTexture( textures[*handle].targets, textures[*handle].name );
369  activetexture[texturestage] = *handle;
370  GFXTextureAddressMode( address_mode, texture_target );
371  if (textures[*handle].mipmapped&(TRILINEAR|MIPMAP) && gl_options.mipmap >= 2) {
372  glTexParameteri( textures[*handle].targets, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
373  if (textures[*handle].mipmapped&TRILINEAR && gl_options.mipmap >= 3)
374  glTexParameteri( textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
375  else
376  glTexParameteri( textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
377  } else {
378  if (textures[*handle].mipmapped == NEAREST || gl_options.mipmap == 0) {
379  glTexParameteri( textures[*handle].targets, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
380  glTexParameteri( textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
381  } else {
382  glTexParameteri( textures[*handle].targets, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
383  glTexParameteri( textures[*handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
384  }
385  }
386  glTexParameterf( textures[*handle].targets, GL_TEXTURE_PRIORITY, .5 );
387  textures[*handle].width = width;
388  textures[*handle].height = height;
389  textures[*handle].iwidth = width;
390  textures[*handle].iheight = height;
391  textures[*handle].palette = NULL;
392  if (palette && textureformat == PALETTE8) {
393  VSFileSystem::vs_dprintf( 3, " palette " );
394  textures[*handle].palette = (GLubyte*) malloc( sizeof (GLubyte)*1024 );
395  ConvertPalette( textures[*handle].palette, (unsigned char*) palette );
396  }
397  textures[*handle].textureformat = GetUncompressedTextureFormat( textureformat );
398  return GFXTRUE;
399 }
void GFXCullFace ( const enum  POLYFACE)

Sets the facecull mode.

Definition at line 123 of file gl_misc.cpp.

References GFXBACK, GFXFRONT, and GFXFRONTANDBACK.

Referenced by setupGLState().

124 {
125  GLenum face;
126  switch (polyface)
127  {
128  case GFXFRONT:
129  face = GL_FRONT;
130  break;
131  default:
132  case GFXBACK:
133  face = GL_BACK;
134  break;
135  case GFXFRONTANDBACK:
136  face = GL_FRONT_AND_BACK;
137  break;
138  }
139  glCullFace( face );
140 }
void GFXDeactivateShader ( )

Definition at line 528 of file gl_program.cpp.

References GFXActivateShader().

Referenced by Mesh::ProcessUndrawnMeshes(), and Mesh::ProcessZFarMeshes().

529 {
530  GFXActivateShader( (int) 0 );
531 }
bool GFXDefaultShaderSupported ( )

Definition at line 499 of file gl_program.cpp.

References getDefaultProgram().

Referenced by init_opengl_extensions().

500 {
501  return getDefaultProgram() != 0;
502 }
void GFXDeleteLight ( const int  light)

Deletes a light, removing it from the light table if necessary.

Definition at line 282 of file gl_light.cpp.

Referenced by Atmosphere::Draw(), Stars::Draw(), BaseInterface::Room::BaseShip::Draw(), Mesh::DrawNow(), and GamePlanet::Kill().

283 {
284  (*_llights)[light].Kill();
285 }
void GFXDeleteLightContext ( const int  con_number)

Deletes a light context (hence a star system)

Definition at line 331 of file gl_light.cpp.

References _local_lights_dat.

332 {
333  _local_lights_dat[con_number] = vector< gfx_light > ();
334 }
void GFXDeleteTexture ( int  handle)

Deletes the texture from the graphics card.

Definition at line 1039 of file gl_texture.cpp.

References activetexture, GFXFALSE, i, and textures.

Referenced by GFXDestroyAllTextures(), Texture::UnBind(), PipelinedTexture::~PipelinedTexture(), and StreamTexture::~StreamTexture().

1040 {
1041  if (textures[handle].alive) {
1042  glDeleteTextures( 1, &textures[handle].name );
1043  for (size_t i = 0; i < sizeof (activetexture)/sizeof (int); ++i)
1044  if (activetexture[i] == handle)
1045  activetexture[i] = -1;
1046  }
1047  if (textures[handle].palette) {
1048  free( textures[handle].palette );
1049  textures[handle].palette = 0;
1050  }
1051  textures[handle].alive = GFXFALSE;
1052 }
void GFXDepthFunc ( const enum  DEPTHFUNC)

Sets up depth compare function.

Definition at line 399 of file gl_state.cpp.

References ALWAYS, cur_depth_func, EQUAL, GEQUAL, GREATER, LEQUAL, LESS, NEQUAL, and NEVER.

400 {
401  GLenum func;
402  switch (dfunc)
403  {
404  case NEVER:
405  func = GL_NEVER;
406  break;
407  case LESS:
408  func = GL_LESS;
409  break;
410  case EQUAL:
411  func = GL_EQUAL;
412  break;
413  case LEQUAL:
414  func = GL_LEQUAL;
415  break;
416  case GREATER:
417  func = GL_GREATER;
418  break;
419  case NEQUAL:
420  func = GL_NOTEQUAL;
421  break;
422  case GEQUAL:
423  func = GL_GEQUAL;
424  break;
425  case ALWAYS:
426  func = GL_ALWAYS;
427  break;
428  default:
429  func = GL_NEVER;
430  break;
431  }
432  glDepthFunc( func );
433  cur_depth_func = dfunc;
434 }
void GFXDestroyAllTextures ( )

Cleans up all textures.

Definition at line 1069 of file gl_texture.cpp.

References GFXDeleteTexture(), and textures.

Referenced by GFXShutdown().

1070 {
1071  for (size_t handle = 0; handle < textures.size(); handle++)
1072  GFXDeleteTexture( handle );
1073 }
void GFXDestroyProgram ( int  program)

Definition at line 318 of file gl_program.cpp.

References programCache, and programICache.

Referenced by Technique::Pass::compile().

319 {
320  // Find program
321  ProgramICache::iterator it = programICache.find( program );
322  if (it != programICache.end()) {
323  /*
324  if (glDeleteProgram_p)
325  glDeleteProgram_p( program );
326  */
327  // FIXME: Real problem here with program leakage,
328  // but cannot destroy like this, brings all kind of issues
329  // since the caller may not hold the only reference.
330  programCache.erase(it->second);
331  programICache.erase(it);
332  }
333 }
Vector GFXDeviceToEye ( int  x,
int  y 
)

convertes eyespace to 3space at the near plane

Definition at line 343 of file gl_misc.cpp.

References b, f, g_game, GFXGetFrustumVars(), Vector, game_data_t::x_resolution, and game_data_t::y_resolution.

Referenced by MouseCoordinate().

344 {
345  float l, r, b, t, n, f;
346  GFXGetFrustumVars( true, &l, &r, &b, &t, &n, &f );
347  return Vector( (l+(r-l)*float(x)/g_game.x_resolution),
348  (t+(b-t)*float(y)/g_game.y_resolution),
349  n );
350 }
void GFXDisable ( const enum  STATE)

Referenced by AnimationDraw(), SpriteStarVlist::BeginDrawState(), bootstrap_draw(), Radar::SphereDisplay::Draw(), Radar::BubbleDisplay::Draw(), Radar::PlaneDisplay::Draw(), Bolt::Draw(), Background::Draw(), VSSprite::Draw(), Atmosphere::Draw(), GameStarSystem::Draw(), VDU::Draw(), Stars::Draw(), WindowManager::draw(), GameCockpit::Draw(), BaseInterface::Room::BaseShip::Draw(), BaseInterface::Room::Draw(), NavigationSystem::Draw(), GFXVertexList::Draw(), UnivMap::Draw(), ParticleTrail::DrawAndUpdate(), Animation::DrawAsVSSprite(), Radar::SphereDisplay::DrawBackground(), NavigationSystem::DrawButtonOutline(), NavigationSystem::DrawCircle(), DrawCrosshairs(), NavigationSystem::DrawCursor(), DrawDamageFlash(), DrawDockingBoxes(), DrawFrustum(), NavigationSystem::DrawGalaxy(), DrawGlutMouse(), NavigationSystem::DrawGrid(), NavigationSystem::DrawHalfCircleBottom(), NavigationSystem::DrawHalfCircleTop(), DrawHUDSprite(), DrawITTSLine(), DrawITTSMark(), NavigationSystem::DrawJump(), NavigationSystem::DrawMissile(), NavigationSystem::DrawMission(), NavigationSystem::DrawNavCircle(), Animation::DrawNoTransform(), Mesh::DrawNow(), DrawOneTargetBox(), NavigationSystem::DrawPlanet(), NavigationSystem::DrawSectorList(), DrawShield(), NavigationSystem::DrawShip(), NavigationSystem::DrawStation(), NavigationSystem::DrawTargetCorners(), Radar::SphereDisplay::DrawTargetMarker(), SpriteStarVlist::EndDrawState(), EndGUIFrame(), Box::ProcessDrawQueue(), Halo::ProcessDrawQueue(), Logo::ProcessDrawQueue(), Atmosphere::ProcessDrawQueue(), Animation::ProcessDrawQueue(), Beam::ProcessDrawQueue(), Animation::ProcessFarDrawQueue(), Mesh::ProcessUndrawnMeshes(), QuadTree::Render(), Briefing::Render(), Mesh::SelectCullFace(), SetupCloakState(), SetupDamageMapThirdPass(), SetupEnvmapPass(), SetupGlowMapFourthPass(), setupGLState(), SetupSpecMapFirstPass(), SetupSpecMapSecondPass(), StartGUIFrame(), and TerrainMakeActive().

GFXBOOL GFXDisableLight ( const int  light)

Deactivates an active light.

Definition at line 306 of file gl_light.cpp.

References _llights, GFXFALSE, and GFXTRUE.

Referenced by GamePlanet::DisableLights(), and Atmosphere::Draw().

307 {
308  assert( light >= 0 && light <= static_cast<int>(_llights->size()) );
309  if ( (*_llights)[light].Target() == -2 )
310  return GFXFALSE;
311  (*_llights)[light].Disable();
312  return GFXTRUE;
313 }
void GFXEnable ( const enum  STATE)

Enables and disables given state.

Referenced by AnimationDraw(), SpriteStarVlist::BeginDrawState(), bootstrap_draw(), createObjects(), Radar::SphereDisplay::Draw(), Radar::BubbleDisplay::Draw(), Radar::PlaneDisplay::Draw(), Bolt::Draw(), Background::Draw(), VSSprite::Draw(), GameStarSystem::Draw(), VDU::Draw(), Stars::Draw(), WindowManager::draw(), GameCockpit::Draw(), BaseInterface::Room::BaseShip::Draw(), BaseInterface::Room::BaseVSSprite::Draw(), BaseInterface::Room::Draw(), NavigationSystem::Draw(), GFXVertexList::Draw(), UnivMap::Draw(), ParticleTrail::DrawAndUpdate(), Animation::DrawAsVSSprite(), Radar::SphereDisplay::DrawBackground(), NavigationSystem::DrawButtonOutline(), NavigationSystem::DrawCircle(), DrawCrosshairs(), NavigationSystem::DrawCursor(), DrawDamageFlash(), DrawDockingBoxes(), DrawFrustum(), DrawGlutMouse(), NavigationSystem::DrawGrid(), NavigationSystem::DrawHalfCircleBottom(), NavigationSystem::DrawHalfCircleTop(), DrawHUDSprite(), DrawITTSLine(), DrawITTSMark(), NavigationSystem::DrawJump(), NavigationSystem::DrawMissile(), NavigationSystem::DrawMission(), NavigationSystem::DrawNavCircle(), Animation::DrawNoTransform(), Mesh::DrawNow(), DrawOneTargetBox(), NavigationSystem::DrawPlanet(), DrawShield(), NavigationSystem::DrawShip(), NavigationSystem::DrawStation(), NavigationSystem::DrawTargetCorners(), Radar::SphereDisplay::DrawTargetMarker(), SpriteStarVlist::EndDrawState(), EndGUIFrame(), Box::ProcessDrawQueue(), Halo::ProcessDrawQueue(), Logo::ProcessDrawQueue(), Atmosphere::ProcessDrawQueue(), Animation::ProcessDrawQueue(), Beam::ProcessDrawQueue(), Animation::ProcessFarDrawQueue(), Mesh::ProcessUndrawnMeshes(), QuadTree::Render(), Briefing::Render(), RestoreCloakState(), Mesh::RestoreCullFace(), RestoreEnvmapState(), RestoreGlowMapState(), RestoreSpecMapState(), SphereMesh::SelectCullFace(), Mesh::SelectCullFace(), SetupCloakState(), setupGLState(), SetupSpecMapSecondPass(), StartGUIFrame(), and TerrainMakeActive().

GFXBOOL GFXEnableLight ( const int  light)

activates a light if not already activated

Definition at line 296 of file gl_light.cpp.

References _llights, GFXFALSE, and GFXTRUE.

Referenced by GamePlanet::EnableLights(), and Atmosphere::Update().

297 {
298  assert( light >= 0 && light <= static_cast<int>(_llights->size()) );
299  //return FALSE;
300  if ( (*_llights)[light].Target() == -2 )
301  return GFXFALSE;
302  (*_llights)[light].Enable();
303  return GFXTRUE;
304 }
vector< PickData >* GFXEndPick ( )

Definition at line 89 of file gl_pick.cpp.

References a, picked_objects, and selectbuf.

90 {
91  int num_hits = glRenderMode( GL_RENDER );
92  assert( num_hits != -1 );
93  //num_hits could == -1, check for this case
94  unsigned *ptr = selectbuf;
95  for (int a = 0; a < num_hits; a++) {
96  picked_objects->push_back( PickData( ptr[3], ptr[1], ptr[2] ) );
97  ptr += ptr[0]+3;
98  }
99  //restore gl projection matrix
100  glMatrixMode( GL_PROJECTION );
101  glPopMatrix();
102  return picked_objects;
103 }
void GFXEndScene ( )

Flushes and Swaps buffers.

Definition at line 60 of file gl_misc.cpp.

References winsys_swap_buffers().

Referenced by base_main_loop(), bootstrap_draw(), gamemenu_draw(), nav_main_loop(), GameUniverse::StartDraw(), and GameUniverse::StartGFX().

61 {
62  glFlush();
63  winsys_swap_buffers(); //swap the buffers
64 }
void GFXFogColor ( GFXColor  c)

Definition at line 69 of file gl_fog.cpp.

References GFXColor::a, GFXColor::b, _GFXFogState::c, c, GFXColor::g, GFXFogState, and GFXColor::r.

Referenced by GameNebula::SetFogState().

70 {
71  if (c.r != GFXFogState.c.r || c.g != GFXFogState.c.g || c.b != GFXFogState.c.b || c.a != GFXFogState.c.a) {
72  glFogfv( GL_FOG_COLOR, &c.r );
73  GFXFogState.c = c;
74  }
75 }
void GFXFogDensity ( const float  fogdensity)

Definition at line 51 of file gl_fog.cpp.

References _GFXFogState::density, and GFXFogState.

Referenced by GameNebula::SetFogState().

52 {
53  if (fogdensity != GFXFogState.density) {
54  glFogf( GL_FOG_DENSITY, fogdensity );
55  GFXFogState.density = fogdensity;
56  }
57 }
void GFXFogIndex ( const int  index)

Definition at line 77 of file gl_fog.cpp.

References GFXFogState, _GFXFogState::index, and index.

Referenced by GameNebula::SetFogState().

78 {
79  if (GFXFogState.index != index) {
80  glFogi( GL_FOG_INDEX, index );
82  }
83 }
void GFXFogLimits ( const float  fognear,
const float  fogfar 
)

Definition at line 59 of file gl_fog.cpp.

References _GFXFogState::ffar, GFXFogState, and _GFXFogState::nnear.

Referenced by GameNebula::SetFogState().

60 {
61  if (GFXFogState.nnear != fognear || GFXFogState.ffar != fogfar) {
62  GFXFogState.nnear = fognear;
63  GFXFogState.ffar = fogfar;
64  glFogf( GL_FOG_START, fognear );
65  glFogf( GL_FOG_END, fogfar );
66  }
67 }
void GFXFogMode ( const FOGMODE  fog)

Definition at line 23 of file gl_fog.cpp.

References _GFXFogState::curmode, _GFXFogState::enabled, FOG_EXP, FOG_EXP2, FOG_LINEAR, FOG_OFF, and GFXFogState.

Referenced by GameStarSystem::Draw(), Mesh::DrawNow(), Animation::ProcessDrawQueue(), GameNebula::SetFogState(), and SetupFogState().

24 {
25  if (GFXFogState.curmode != fog || !GFXFogState.enabled) {
26  switch (fog)
27  {
28  case FOG_OFF:
29  if (!GFXFogState.enabled)
30  return;
31  glDisable( GL_FOG );
32  GFXFogState.enabled = false;
33  return;
34  case FOG_EXP:
35  glFogi( GL_FOG_MODE, GL_EXP );
36  break;
37  case FOG_EXP2:
38  glFogi( GL_FOG_MODE, GL_EXP2 );
39  break;
40  case FOG_LINEAR:
41  glFogi( GL_FOG_MODE, GL_LINEAR );
42  break;
43  }
44  }
45  if (!GFXFogState.enabled) glEnable( GL_FOG );
46  GFXFogState.curmode = fog;
47  GFXFogState.enabled = true;
48  //glHint (GL_FOG_HINT,GL_NICEST );
49 }
void GFXFrustum ( float mat,
float inv,
float  left,
float  right,
float  bottom,
float  top,
float  nearval,
float  farval 
)

Given matrices, calculates the matrix and inverse matrix of a projection matrix to go from screen to 3-space coordinates.

Definition at line 303 of file gl_matrix.cpp.

References a, b, c, d, float, M, x, and y.

Referenced by gl_Frustum(), and ClickList::requestIterator().

304 {
305  GLfloat x, y, a, b, c, d;
306  x = ( ( (float) 2.0 )*nearval )/(right-left);
307  y = ( ( (float) 2.0 )*nearval )/(top-bottom);
308  a = (right+left)/(right-left);
309  b = (top+bottom)/(top-bottom);
310  //If farval == 0, we'll build an infinite-farplane projection matrix.
311  if (farval == 0) {
312  c = -1.0;
313  d = -1.99*nearval; //-2*nearval, but using exactly -2 might create artifacts
314  } else {
315  c = -(farval+nearval)/(farval-nearval);
316  d = -( ( (float) 2.0 )*farval*nearval )/(farval-nearval);
317  }
318 #define M( row, col ) m[col*4+row]
319  M( 0, 0 ) = x;
320  M( 0, 1 ) = 0.0F;
321  M( 0, 2 ) = a;
322  M( 0, 3 ) = 0.0F;
323  M( 1, 0 ) = 0.0F;
324  M( 1, 1 ) = y;
325  M( 1, 2 ) = b;
326  M( 1, 3 ) = 0.0F;
327  M( 2, 0 ) = 0.0F;
328  M( 2, 1 ) = 0.0F;
329  M( 2, 2 ) = c;
330  M( 2, 3 ) = d;
331  M( 3, 0 ) = 0.0F;
332  M( 3, 1 ) = 0.0F;
333  M( 3, 2 ) = -1.0F;
334  M( 3, 3 ) = 0.0F;
335 #undef M
336 #define M( row, col ) i[col*4+row]
337  M( 0, 0 ) = 1./x;
338  M( 0, 1 ) = 0.0F;
339  M( 0, 2 ) = 0.0F;
340  M( 0, 3 ) = a/x;
341  M( 1, 0 ) = 0.0F;
342  M( 1, 1 ) = 1./y;
343  M( 1, 2 ) = 0.0F;
344  M( 1, 3 ) = b/y;
345  M( 2, 0 ) = 0.0F;
346  M( 2, 1 ) = 0.0F;
347  M( 2, 2 ) = 0.0F;
348  M( 2, 3 ) = -1.0F;
349  M( 3, 0 ) = 0.0F;
350  M( 3, 1 ) = 0.0F;
351  M( 3, 2 ) = 1.F/d;
352  M( 3, 3 ) = (float) c/d;
353 #undef M
354 }
void GFXGetBlendMode ( enum BLENDFUNC src,
enum BLENDFUNC dst 
)

Gets the current blend mode to src,dst.

Definition at line 311 of file gl_state.cpp.

References currBlendMode, BlendMode::dfactor, and BlendMode::sfactor.

Referenced by VSSprite::Draw(), GFXVertexList::Draw(), Animation::DrawAsVSSprite(), Animation::DrawNoTransform(), and Animation::DrawNow().

312 {
313  src = currBlendMode.sfactor;
314  dst = currBlendMode.dfactor;
315 }
void GFXGetFrustum ( double  f[6][4])

Gets the 6 clip planes of the current Projection matrix.

Definition at line 183 of file gl_clip.cpp.

References frust.

184 {
185  f = frust;
186 }
void GFXGetFrustumVars ( bool  ,
float l,
float r,
float b,
float t,
float n,
float f 
)

Saves and restores last used left,right,bot,top,near,far vals (internal use)

Definition at line 162 of file gl_clip.cpp.

References b.

Referenced by GFXBeginPick(), GFXDeviceToEye(), GFXGetZPerspective(), GFXParallel(), gl_Frustum(), ClickList::requestIterator(), and CoordinateSelect::UpdateMouse().

163 {
164  static float nnear, ffar, left, right, bot, top; //Visual C++ reserves near and far
165  if (!retr) {
166  nnear = *n;
167  ffar = *f;
168  left = *l;
169  right = *r;
170  bot = *b;
171  top = *t;
172  } else {
173  *l = left;
174  *r = right;
175  *b = bot;
176  *t = top;
177  *n = nnear;
178  *f = ffar;
179  }
180  //VSFileSystem::Fprintf (stderr,"<FUN%f,%f,%f,%f,%f,%f>>",near,far,left,right,bot,top);
181 }
GFXBOOL GFXGetLightContextAmbient ( GFXColor amb)

Gets the ambient light value.

Definition at line 264 of file gl_light.cpp.

References _ambient_light, _currentContext, GFXFALSE, and GFXTRUE.

Referenced by GameStarSystem::Draw(), SphereMesh::ProcessDrawQueue(), CityLights::ProcessDrawQueue(), Terrain::Render(), and Terrain::RenderAll().

265 {
266  if ( _currentContext >= static_cast<int>(_ambient_light.size()) )
267  return GFXFALSE;
269  return GFXTRUE;
270 }
GFXBOOL GFXGetMaterial ( const unsigned int  number,
GFXMaterial material 
)

Gets the statistics of the material stored in number.

Definition at line 67 of file gfxlib_struct_server.cpp.

References GFXFALSE, GFXTRUE, and materialinfo.

Referenced by Mission::call_unit_launch(), and Mesh::GetMaterial().

68 {
69  return GFXFALSE;
70 }
const GFXMaterial& GFXGetMaterial ( const unsigned int  number)

Definition at line 50 of file gl_material.cpp.

References materialinfo.

51 {
52  if ( number >= materialinfo.size() ) {
53  static GFXMaterial tmp;
54  return tmp;
55  }
56  return materialinfo[number];
57 }
void GFXGetMatrixModel ( Matrix matrix)

retrieves the matrix for a given mode.

Definition at line 292 of file gl_matrix.cpp.

References CopyMatrix(), and GFXMatrices::model.

Referenced by LocationSelect::Draw(), and GFXUploadLightState().

293 {
294  CopyMatrix( matrix, model );
295 }
void GFXGetMatrixView ( Matrix m)

Definition at line 288 of file gl_matrix.cpp.

References CopyMatrix(), and GFXMatrices::view.

Referenced by LocationSelect::Draw(), and Camera::GetView().

289 {
290  CopyMatrix( matrix, view );
291 }
void GFXGetPolygonOffset ( float factor,
float units 
)

Definition at line 81 of file gl_misc.cpp.

References last_factor, and last_units.

Referenced by SetupSpecMapFirstPass().

82 {
83  *factor = last_factor;
84  *units = last_units;
85 }
int GFXGetProgramVersion ( )

Definition at line 647 of file gl_program.cpp.

References programVersion.

Referenced by Technique::Pass::compile(), and Technique::compile().

648 {
649  return programVersion;
650 }
float GFXGetXInvPerspective ( )

Screen to eye.

Definition at line 51 of file gl_matrix.cpp.

References GFXMatrices::invprojection.

Referenced by LocationSelect::Draw().

52 {
53  return /*invprojection[11]* */ invprojection[0]; //invprojection[15];//should be?? c/d == invproj[15]
54 }
float GFXGetYInvPerspective ( )

Definition at line 56 of file gl_matrix.cpp.

References GFXMatrices::invprojection.

Referenced by LocationSelect::Draw().

57 {
58  return /*invprojection[11]* */ invprojection[5]; //invprojection[15];//should be?? c/d == invproj[15]
59 }
float GFXGetZPerspective ( const float  z)

Given the current projection matrix, how much will the model be divided by.

GFXGetZPerspective () returns the relative scale of an object placed at distance z from the camera with the current projection matrix.

GFXGetXPerspective () returns the number that x/z is multiplied by to land a pixel on the screen. | xs 0 a 0 |[x] [xs + az] [1/xs 0 0 a/xs][x] [x/xs+ aw/xs] | 0 ys b 0 |[y] = [ys + bz] ^-1 [ 0 1/ys 0 b/ys][y] = [y/ys+ bw/ys] | 0 0 c d |[z] [cz + dw] [ 0 0 0 -1 ][z] [0 ] | 0 0 -1 0 |[w] [-z ] [ 0 0 1/d c/d ][w] [z/d + cw/d ] therefore return 1/(xs *d) and 1/(ys * d) I'm not good with matrix math...tell me if I should ret 1/xs+c/d instead for test cases I can think of, it doesn't matter—

Definition at line 311 of file gl_clip.cpp.

References a, and GFXGetFrustumVars().

Referenced by perspectiveFactor().

312 {
313  /*
314  *
315  * | xs 0 a 0 |[x] [xs + az] [1/xs 0 0 a/xs][x] [x/xs+ aw/xs]
316  * | 0 ys b 0 |[y] = [ys + bz] ^-1 [ 0 1/ys 0 b/ys][y] = [y/ys+ bw/ys]
317  * | 0 0 c d |[z] [cz + dw] [ 0 0 0 -1 ][z] [0 ]
318  * | 0 0 -1 0 |[w] [-z ] [ 0 0 1/d c/d ][w] [z/d + cw/d ]
319  *
320  */
321 
322  float left, right, bottom, top, nearval, farval;
323  GFXGetFrustumVars( true, &left, &right, &bottom, &top, &nearval, &farval );
324 
325  float xs = 2*nearval/(right-left);
326  float a = (right+left)/(right-left);
327 
328  //Compute homogeneus x,w for (1,0,z,0)
329  float hx = xs+z*a;
330  float hw = -z;
331 
332  //Translate into euclidean coordinates and return euclidean x
333  return fabs( hx/hw );
334 }
void GFXHudMode ( const bool  Enter)

Hud Mode saves the current matrices and sets projection and view matrices to identity. Caution: use of other matrix functions in HudMode could alter state.

Definition at line 246 of file gl_matrix.cpp.

Referenced by bootstrap_draw(), WindowManager::draw(), GameCockpit::Draw(), BaseInterface::Room::BaseShip::Draw(), NavigationSystem::Draw(), EndGUIFrame(), and StartGUIFrame().

247 {
248  if (Enter) {
249  glMatrixMode( GL_MODELVIEW );
250  glPushMatrix();
251  glLoadIdentity();
252  glMatrixMode( GL_PROJECTION );
253  glPushMatrix();
254  glLoadIdentity();
255  } else {
256  glMatrixMode( GL_PROJECTION );
257  glPopMatrix();
258  glMatrixMode( GL_MODELVIEW );
259  glPopMatrix();
260  }
261 }
void GFXInit ( int  ,
char **   
)

Loads Glut and graphics drivers.

Definition at line 532 of file gl_init.cpp.

References gl_options_t::compression, CUBE_MAP_GEN, CUBEMAP, gl_options_t::display_lists, gl_options_t::ext_clamp_to_border, gl_options_t::ext_clamp_to_edge, g_game, VegaConfig::getColor(), VegaConfig::getVariable(), GFXActiveTexture(), GFXADDTEXTURE, GFXBlendMode(), GFXCreateLightContext(), GFXInitTextureManager(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXToggleTexture(), GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, gl_options, i, init_opengl_extensions(), initfov(), gl_options_t::max_movie_dimension, gl_options_t::max_rect_dimension, gl_options_t::max_texture_dimension, gl_options_t::mipmap, gl_options_t::Multitexture, ONE, gl_options_t::PaletteExt, XMLSupport::parse_bool(), XMLSupport::parse_int(), gl_options_t::pot_video_textures, gl_options_t::rect_textures, Reshape(), gl_options_t::s3tc, gl_options_t::smooth_lines, gl_options_t::smooth_points, gl_options_t::smooth_shade, SPHERE_MAP_GEN, TEXTURE2D, vs_config, VSFileSystem::vs_dprintf(), vsExtensionSupported(), vsVendorMatch(), winsys_enable_key_repeat(), winsys_init(), winsys_set_reshape_func(), winsys_show_cursor(), winsys_swap_buffers(), gl_options_t::wireframe, game_data_t::x_resolution, game_data_t::y_resolution, and ZERO.

Referenced by GameUniverse::Init().

533 {
534  char vsname[12] = "Vega Strike";
535  char vsicon[9] = "vega.ico";
536  winsys_init (&argc,argv,&vsname[0],&vsicon[0]);
537  /* Ingore key-repeat messages */
538  winsys_enable_key_repeat( false );
539 
540  glViewport( 0, 0, g_game.x_resolution, g_game.y_resolution );
541  float clearcol[4];
542  gl_options.wireframe = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "use_wireframe", "0" ) );
544  XMLSupport::parse_int( vs_config->getVariable( "graphics", "max_texture_dimension", "65536" ) );
546  XMLSupport::parse_int( vs_config->getVariable( "graphics", "max_movie_dimension", "65536" ) );
547 
549  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "rect_textures",
550  ( vsExtensionSupported( "GL_ARB_texture_non_power_of_two" )
551  || vsExtensionSupported( "GL_ARB_texture_rectangle" )
552  || vsExtensionSupported( "GL_NV_texture_rectangle" )
553  ) ? "true" : "false" ) );
554 
556  VSFileSystem::vs_dprintf(3, "RECT textures supported\n");
557 
558  // Fetch max rect textue dimension
559  GLint max_rect_dimension = 65535;
560  glGetIntegerv(
562  &max_rect_dimension);
563 
564  gl_options.max_rect_dimension = max_rect_dimension;
565  VSFileSystem::vs_dprintf(3, "RECT max texture dimension: %d\n", max_rect_dimension);
566  }
567 
569  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "pot_video_textures",
571  || ( vsExtensionSupported( "GL_ARB_texture_non_power_of_two" )
572  && vsVendorMatch("nvidia") )
573  ) ? "false" : "true" ) );
574 
576  // Enforce max rect texture for movies, which use them
579  }
580 
582  VSFileSystem::vs_dprintf(1, "Forcing POT video textures\n");
583  else
584  VSFileSystem::vs_dprintf(3, "Using NPOT video textures\n");
585 
586  gl_options.smooth_shade = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "SmoothShade", "true" ) );
587  gl_options.mipmap = XMLSupport::parse_int( vs_config->getVariable( "graphics", "mipmapdetail", "2" ) );
588  gl_options.compression = XMLSupport::parse_int( vs_config->getVariable( "graphics", "texture_compression", "0" ) );
589  gl_options.Multitexture = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "reflection", "true" ) );
590  gl_options.smooth_lines = XMLSupport::parse_bool( vs_config->getVariable( "graphics/mesh", "smooth_lines", "true" ) );
591  gl_options.smooth_points = XMLSupport::parse_bool( vs_config->getVariable( "graphics/mesh", "smooth_points", "true" ) );
592 
593  gl_options.display_lists = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "displaylists", "false" ) );
594  gl_options.s3tc = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "s3tc", "true" ) );
595  gl_options.ext_clamp_to_edge = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "ext_clamp_to_edge", "true" ) );
596  gl_options.ext_clamp_to_border = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "ext_clamp_to_border", "true" ) );
597 
598  vs_config->getColor( "space_background", clearcol );
599  glClearColor( clearcol[0], clearcol[1], clearcol[2], clearcol[3] );
601  initfov();
602  glShadeModel( GL_SMOOTH );
603  glEnable( GL_CULL_FACE );
604  glCullFace( GL_BACK );
605  glShadeModel( GL_SMOOTH );
606  glEnable( GL_DEPTH_TEST );
607  glDepthFunc( GL_LESS );
608  if (gl_options.wireframe)
609  glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
610  if (gl_options.smooth_shade == 0)
611  glShadeModel( GL_FLAT );
612  glEnable( GL_ALPHA_TEST );
613  glAlphaFunc( GL_GREATER, 0.0 );
614 
618  GFXActiveTexture( 0 );
619  glEnable( GL_TEXTURE_2D ); //use two-dimensional texturing
620  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
621  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
622 
623 #if defined (IRIX)
624  glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
625 #endif
626  if ( vsExtensionSupported( "GL_EXT_color_table" ) || vsExtensionSupported( "GL_EXT_shared_texture_palette" ) ) {
628  VSFileSystem::vs_dprintf(3, "OpenGL::EXTColorTable supported\n");
629  } else {
631  VSFileSystem::vs_dprintf( 2, "OpenGL::EXTColorTable unsupported\n" );
632  }
633  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
634  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
635  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
636  if (gl_options.Multitexture) {
637  for (int i = 1; i < 4; ++i) {
638  GFXActiveTexture( i );
639  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
640  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
641  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
642  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
644  glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
645  glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
646  glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
647  glPixelStorei( GL_UNPACK_SWAP_BYTES, 0 );
648  // Choose cubemap or spheremap coordinates.
649  if (i == 1) {
650 #ifdef NV_CUBE_MAP
651  GFXToggleTexture( true, 1, CUBEMAP );
652  GFXTextureCoordGenMode( 1, CUBE_MAP_GEN, NULL, NULL );
653 #else
654  const float tempo[4] = {1, 0, 0, 0};
655  GFXToggleTexture( true, 1, TEXTURE2D );
656  GFXTextureCoordGenMode( 1, SPHERE_MAP_GEN, tempo, tempo );
657 #endif
658  }
659  }
660  }
661  GFXActiveTexture( 0 );
662  glClearDepth( 1 );
663  glEnable( GL_BLEND );
664  glDisable( GL_ALPHA_TEST );
665  GFXBlendMode( ONE, ZERO );
666 
667  glColor3f( 0, 0, 0 );
668  glMatrixMode( GL_MODELVIEW );
669  glLoadIdentity();
670  glMatrixMode( GL_TEXTURE );
671  glLoadIdentity(); //set all matricies to identity
672  glMatrixMode( GL_PROJECTION );
673  glLoadIdentity();
674 
675  glEnable( GL_LIGHTING );
676 
677  glDisable( GL_NORMALIZE );
678 
679  glDisable( GL_LINE_SMOOTH );
680  glDisable( GL_POINT_SMOOTH );
681 
682  int con;
683  GFXCreateLightContext( con );
684  //glutSetCursor(GLUT_CURSOR_NONE);
685  /* Avoid scrambled screen on startup - Twice, for triple buffering */
686  if ( XMLSupport::parse_bool( vs_config->getVariable( "graphics", "ClearOnStartup", "true" ) ) ) {
687  glClear( GL_COLOR_BUFFER_BIT );
689  glClear( GL_COLOR_BUFFER_BIT );
691  }
692  winsys_show_cursor( false );
693 }
GFXBOOL GFXLightContextAmbient ( const GFXColor amb)

Sets the ambient light value.

Definition at line 251 of file gl_light.cpp.

References _ambient_light, _currentContext, GFXColor::a, GFXColor::b, GFXColor::g, GFXFALSE, GFXTRUE, and GFXColor::r.

Referenced by GameStarSystem::Draw(), GFXPopGlobalEffects(), GFXPushGlobalEffects(), SphereMesh::ProcessDrawQueue(), CityLights::ProcessDrawQueue(), Terrain::Render(), Terrain::RenderAll(), and GameUniverse::StartGFX().

252 {
253  if ( _currentContext >= static_cast<int>(_ambient_light.size()) )
254  return GFXFALSE;
256  //(_ambient_light[_currentContext])[1]=amb.g;
257  //(_ambient_light[_currentContext])[2]=amb.b;
258  //(_ambient_light[_currentContext])[3]=amb.a;
259  float tmp[4] = {amb.r, amb.g, amb.b, amb.a};
260  glLightModelfv( GL_LIGHT_MODEL_AMBIENT, tmp );
261  return GFXTRUE;
262 }
void GFXLoadIdentity ( const MATRIXMODE  mode)

Loads the identity matrix for the given mode.

Definition at line 263 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), GFX_SCALE, Identity(), IdentityFloat(), GFXMatrices::model, MODEL, Matrix::p, GFXMatrices::projection, PROJECTION, GFXMatrices::rotview, GFXMatrices::view, VIEW, and ViewToModel().

Referenced by bootstrap_draw(), CoordinateSelect::Draw(), LocationSelect::Draw(), GamePlanet::Draw(), Stars::Draw(), GameCockpit::Draw(), ParticleTrail::DrawAndUpdate(), Mesh::DrawNow(), GamePlanet::DrawTerrain(), GFXBeginScene(), GFXCenterCamera(), GFXUploadLightState(), Halo::ProcessDrawQueue(), Camera::UpdateGFX(), and Camera::UpdateGLCenter().

264 {
265  switch (mode)
266  {
267  case MODEL:
268  Identity( model );
269  glMatrixMode( GL_MODELVIEW );
270  //glLoadMatrixf(transview);
271  glLoadIdentity();
272  glTranslated( -view.p.i*GFX_SCALE, -view.p.j*GFX_SCALE, -view.p.k*GFX_SCALE );
273  glScalef( GFX_SCALE, GFX_SCALE, GFX_SCALE );
274  break;
275  case PROJECTION:
278  break;
279  case VIEW:
280  Identity( view );
281  ViewToModel();
282  glMatrixMode( GL_PROJECTION );
283  glLoadMatrixf( projection );
284  break;
285  }
286 }
void GFXLoadMatrixModel ( const Matrix matrix)
void GFXLoadMatrixProjection ( const float  matrix[16])

Definition at line 213 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), VsnetOSS::memcpy(), and GFXMatrices::projection.

Referenced by GFXParallel().

214 {
215  memcpy( projection, matrix, 16*sizeof (float) );
217 }
void GFXLoadMatrixView ( const Matrix matrix)

Definition at line 200 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), CopyMatrix(), GFXMatrices::view, and ViewToModel().

Referenced by GFXLookAt().

201 {
202  CopyMatrix( view, matrix );
203  ViewToModel();
205 }
void GFXLookAt ( Vector  eye,
QVector  center,
Vector  up 
)

Sets the VIEW matrix to look from center in direction of eye with up vector up.

Definition at line 495 of file gl_matrix.cpp.

References GFXLoadMatrixView(), LookAtHelper(), and GFXMatrices::view.

Referenced by Camera::UpdateGFX(), and Camera::UpdateGLCenter().

496 {
497  LookAtHelper( eye.i, eye.j, eye.k, center.i, center.j, center.k, up.i, up.j, up.k );
499 }
void GFXLoop ( void   main_loop())

loops on the function over and over

so we can call this function multiple times to change the display and idle functions

Definition at line 732 of file gl_init.cpp.

References main_loop(), winsys_process_events(), winsys_set_display_func(), and winsys_set_idle_func().

Referenced by BaseInterface::InitCallbacks(), GameUniverse::Loop(), GameMenu::processSinglePlayerButton(), restore_main_loop(), UniverseUtil::startMenuInterface(), and NavComputer::toggleVisibility().

733 {
736 
737  //glutDisplayFunc(main_loop);
738  //glutIdleFunc (main_loop);
739  static bool are_we_looping = false;
741  if (!are_we_looping) {
742  are_we_looping = true;
744  }
745 }
void GFXModifyMaterial ( const unsigned int  number,
const GFXMaterial material 
)

Modifies the given material to be like the passed in structure.

Definition at line 45 of file gl_material.cpp.

References materialinfo.

46 {
47  materialinfo[number] = material;
48 }
bool GFXMultiTexAvailable ( )

Definition at line 32 of file gl_misc.cpp.

References gl_options, and gl_options_t::Multitexture.

33 {
34  return gl_options.Multitexture != 0;
35 }
void GFXMultMatrixModel ( const Matrix matrix)

Multipliex the current "mode" matrix by a given matrix.

Definition at line 189 of file gl_matrix.cpp.

References CopyMatrix(), GFXMatrices::model, MultMatrix(), and ViewToModel().

Referenced by LocationSelect::Draw().

190 {
191  Matrix t;
192  MultMatrix( t, model, matrix );
193  CopyMatrix( model, t );
194  ViewToModel();
195 }
int GFXNamedShaderConstant ( char *  progID,
const char *  name 
)

Definition at line 639 of file gl_program.cpp.

References cacheKey(), defaultprog, GFXNamedShaderConstant(), and programCache.

Referenced by Technique::Pass::compile(), and GFXNamedShaderConstant().

640 {
641  int programname = defaultprog;
642  if (progID)
643  programname = programCache[cacheKey( progID, progID, NULL )];
644  return GFXNamedShaderConstant( programname, name );
645 }
int GFXNamedShaderConstant ( int  progID,
const char *  name 
)

Definition at line 626 of file gl_program.cpp.

References glGetUniformLocation_p.

627 {
628  if (1
629 #ifndef __APPLE__
631 #endif
632  ) {
633  int varloc = glGetUniformLocation_p( progID, name );
634  return varloc;
635  }
636  return -1; //varloc cound be 0
637 }
void GFXNormal ( const Vector n)

Specifies a notmal with 1 vector.

Definition at line 263 of file gl_misc.cpp.

264 {
265  glNormal3fv( &n.i );
266 }
void GFXNormal3f ( const float  i,
const float  j,
const float  k 
)

Specifies a normal with 3 floats.

Definition at line 258 of file gl_misc.cpp.

259 {
260  glNormal3f( i, j, k );
261 }
void GFXOptimizeList ( GFXVertex old,
int  numV,
GFXVertex **  newlist,
int numnewVertices,
unsigned int **  indices 
)

Optimizes a list to reuse repeated vertices!

Definition at line 68 of file gl_vertex_list.cpp.

References i, VsnetOSS::memcpy(), and VSFileSystem::vs_dprintf().

Referenced by Mesh::PostProcessLoading().

69 {
70  std::map< GFXVertex*, int, VertexCompare >vtxcache;
71 
72  *ind = (unsigned int*) malloc( sizeof (unsigned int)*numV );
73  *nw = (GFXVertex*) malloc( numV*sizeof (GFXVertex) );
74  int _nnewV = *nnewV = 0;
75  int i;
76  bool quickpath = true;
77  for (i = 0; i < numV; i++) {
78  std::map< GFXVertex*, int, VertexCompare >::const_iterator it = vtxcache.find( old+i );
79  if ( it != vtxcache.end() ) {
80  if (quickpath && i > 0) {
81  quickpath = false;
82  memcpy( *nw, old, sizeof(GFXVertex)*size_t(i) );
83  }
84  (*ind)[i] = it->second;
85  } else {
86  if (!quickpath)
87  memcpy( (*nw)+_nnewV, old+i, sizeof (GFXVertex) );
88  vtxcache[old+i] = ( (*ind)[i] ) = _nnewV;
89  ++_nnewV;
90  }
91  }
92  if (quickpath && i > 0)
93  memcpy( *nw, old, sizeof(GFXVertex)*size_t(i) );
94  *nnewV = _nnewV;
95 
96  VSFileSystem::vs_dprintf(3, "Optimized vertex list - vertices: %d -> %d\n", numV, *nnewV);
97 }
void GFXParallel ( float  left,
float  right,
float  bottom,
float  top,
float  znear,
float  zfar 
)

Sets the Projection matrix to a parallel view with given paramters.

Definition at line 376 of file gl_matrix.cpp.

References GFXGetFrustumVars(), GFXLoadMatrix(), GFXLoadMatrixProjection(), M, GFXMatrices::projection, PROJECTION, x, y, and z.

Referenced by Camera::UpdateGFX(), and Camera::UpdateGLCenter().

377 {
378  float *m = projection, x, y, z, tx, ty, tz;
379  x = 2.0/(right-left);
380  y = 2.0/(top-bottom);
381  z = -2.0/(farval-nearval);
382  tx = -(right+left)/(right-left);
383  ty = -(top+bottom)/(top-bottom);
384  tz = -(farval+nearval)/(farval-nearval);
385 
386 #define M( row, col ) m[col*4+row]
387  M( 0, 0 ) = x;
388  M( 0, 1 ) = 0.0F;
389  M( 0, 2 ) = 0.0F;
390  M( 0, 3 ) = tx;
391  M( 1, 0 ) = 0.0F;
392  M( 1, 1 ) = y;
393  M( 1, 2 ) = 0.0F;
394  M( 1, 3 ) = ty;
395  M( 2, 0 ) = 0.0F;
396  M( 2, 1 ) = 0.0F;
397  M( 2, 2 ) = z;
398  M( 2, 3 ) = tz;
399  M( 3, 0 ) = 0.0F;
400  M( 3, 1 ) = 0.0F;
401  M( 3, 2 ) = 0.0F;
402  M( 3, 3 ) = 1.0F;
403 #undef M
405  GFXGetFrustumVars( false, &left, &right, &bottom, &top, &nearval, &farval );
406 }
void GFXPerspective ( float  fov,
float  aspect,
float  znear,
float  zfar,
float  cockpit_offset 
)

Sets the Projection matrix to have fov and aspect as follows (fov is field of view in radians, aspect is width/height znear and zfar are clip planes.

Definition at line 356 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), GFX_SCALE, gl_Frustum(), M_PI, and GFXMatrices::projection.

Referenced by Camera::UpdateGFX(), and Camera::UpdateGLCenter().

357 {
358  znear *= GFX_SCALE;
359  zfar *= GFX_SCALE;
360  cockpit_offset *= GFX_SCALE;
361  //gluPerspective (fov,aspect,znear,zfar);
362 
363  float xmin, xmax, ymin, ymax;
364 
365  ymax = znear*tanf( fov*M_PI/( (float) 360.0 ) ); //78.0 --> 4.7046
366 
367  ymin = -ymax; //-4.7046
368 
369  xmin = (ymin-cockpit_offset/2)*aspect; //-6.2571
370  xmax = (ymax+cockpit_offset/2)*aspect; //6.2571
371  ymin -= cockpit_offset;
372  gl_Frustum( xmin, xmax, ymin, ymax, znear, zfar );
374 }
void GFXPickLights ( const Vector center,
const float  radius 
)

picks and activates local lights near to "center"

Definition at line 173 of file gl_light_pick.cpp.

References gfx_light::dopickenables(), GFXPickLights(), newpicked, and swappicked().

Referenced by Mesh::DrawNow(), and GFXPickLights().

174 {
175  swappicked();
176  GFXPickLights( center, radius, *newpicked, 8, false );
178 }
void GFXPickLights ( const Vector center,
const float  radius,
vector< int > &  lights,
const int  maxlights,
const bool  pickglobals 
)

picks and does not activate local lights near to "center"

Definition at line 139 of file gl_light_pick.cpp.

References _GLLightsEnabled, GFX_MAX_LIGHTS, OpenGLL::GL_ENABLED, OpenGLL::GLL_LOCAL, GLLights, i, index, j, lighttable, picklight(), and QVector.

140 {
141  QVector tmp;
142  //Beware if re-using rndvar !! Because rand returns an int and on 64 bits archs sizeof( void*) != sizeof( int) !!!
143  //void * rndvar = (void *)rand();
144  int lightsenabled = _GLLightsEnabled;
145  tmp = QVector( radius, radius, radius );
146 
147  if (lightsenabled && pickglobals) {
148  // Push global lights into the picked set
149  for (int i = 0; i < GFX_MAX_LIGHTS; ++i) {
151  // It's global and enabled
152  lights.push_back(GLLights[i].index);
153  }
154  }
155  }
156 
157  veclinecol *tmppickt[2];
158  lighttable.Get( center.Cast(), tmppickt );
159 
160  for (int j = 0; j < 2; j++) {
161  veclinecol::iterator i;
162 
163  for (i = tmppickt[j]->begin(); i != tmppickt[j]->end(); i++) {
164  if ( picklight( *i->lc, center, radius, lightsenabled, i->GetIndex() ) ) {
165  lights.push_back( i->GetIndex() );
166  lightsenabled++;
167  }
168  }
169  }
170  std::sort( lights.begin(), lights.end(), lightsort( center, radius ) );
171 }
void GFXPickLights ( vector< int >::const_iterator  begin,
vector< int >::const_iterator  end 
)

activates local lights picked by GFXPickLight

Definition at line 180 of file gl_light_pick.cpp.

References gfx_light::dopickenables(), newpicked, and swappicked().

181 {
182  swappicked();
183  newpicked->insert( newpicked->end(), begin, end );
185 }
void GFXPointSize ( const float  size)
void GFXPolygonMode ( const enum  POLYMODE)

Sets the polygon rasterization mode.

Definition at line 104 of file gl_misc.cpp.

References GFXFILLMODE, GFXLINEMODE, and GFXPOINTMODE.

Referenced by setupGLState().

105 {
106  GLenum mode;
107  switch (polymode)
108  {
109  default:
110  case GFXFILLMODE:
111  mode = GL_FILL;
112  break;
113  case GFXLINEMODE:
114  mode = GL_LINE;
115  break;
116  case GFXPOINTMODE:
117  mode = GL_POINT;
118  break;
119  }
120  glPolygonMode( GL_FRONT_AND_BACK, mode );
121 }
void GFXPolygonOffset ( float  factor,
float  units 
)

Sets Depth Offset for polgyons.

Definition at line 87 of file gl_misc.cpp.

References last_factor, and last_units.

Referenced by Logo::ProcessDrawQueue(), SphereMesh::ProcessDrawQueue(), CityLights::ProcessDrawQueue(), quadsquare::Render(), setupGLState(), and SetupSpecMapFirstPass().

88 {
89  last_factor = factor;
90  last_units = units;
91  if (!factor && !units) {
92  glDisable( GL_POLYGON_OFFSET_FILL );
93  glDisable( GL_POLYGON_OFFSET_POINT );
94  glDisable( GL_POLYGON_OFFSET_LINE );
95  glPolygonOffset( 0, 0 );
96  } else {
97  glPolygonOffset( factor, units );
98  glEnable( GL_POLYGON_OFFSET_FILL );
99  glEnable( GL_POLYGON_OFFSET_POINT );
100  glEnable( GL_POLYGON_OFFSET_LINE );
101  }
102 }
GFXBOOL GFXPopGlobalEffects ( )

This function undoes the above function to restore the global lights after specialFX phase.

Definition at line 67 of file gl_light.cpp.

References GFX_MAX_LIGHTS, GFXLightContextAmbient(), GlobalEffects, GlobalEffectsAmbient, GlobalEffectsFreelist, and i.

Referenced by GameStarSystem::Draw(), Stars::Draw(), and Mesh::ProcessUndrawnMeshes().

68 {
69  if ( GlobalEffects.empty() )
70  return false;
71  //VSFileSystem::Fprintf (stderr,"GES %d",GlobalEffects.size());
72  for (int i = 0; i < GFX_MAX_LIGHTS; i++)
73  if (GlobalEffects.top()[i])
74  glEnable( GL_LIGHT0+i );
75 
76  if (GlobalEffectsFreelist.size() >= 10)
77  delete[] GlobalEffects.top();
78  else
80  GlobalEffects.pop();
81 
84  return true;
85 }
void GFXPrioritizeTexture ( unsigned int  handle,
float  priority 
)

Sets the priority of the texture for memory management.

Definition at line 401 of file gl_texture.cpp.

Referenced by Texture::Prioritize().

402 {
403  glPrioritizeTextures( 1,
404 #if defined (__APPLE__)
405  (GLuint*)
406 #endif
407  &handle, &priority );
408 }
void GFXPushGlobalEffects ( )

In the case of shields and other T&L based effects, the global lights must be disabled yet saved for later use while the selected lights are used shortly then disabled. This saves values of global lights

Definition at line 45 of file gl_light.cpp.

References _ambient_light, _currentContext, GFX_MAX_LIGHTS, GFXLightContextAmbient(), OpenGLL::GL_ENABLED, GlobalEffects, GlobalEffectsAmbient, GlobalEffectsFreelist, i, OpenGLLights::options, and unpicklights().

Referenced by Stars::Draw(), and Mesh::ProcessUndrawnMeshes().

46 {
47  bool *tmp;
48  if (GlobalEffectsFreelist.empty()) {
49  tmp = new bool[GFX_MAX_LIGHTS];
50  } else {
51  tmp = GlobalEffectsFreelist.top();
53  }
54 
55  unpicklights(); //costly but necessary to get rid of pesky local enables that shoudln't be tagged to get reenabled
56  for (int i = 0; i < GFX_MAX_LIGHTS; i++) {
57  tmp[i] = ( 0 != (GLLights[i].options&OpenGLL::GL_ENABLED) );
58  if (GLLights[i].options&OpenGLL::GL_ENABLED)
59  glDisable( GL_LIGHT0+i );
60  }
61  //VSFileSystem::Fprintf (stderr,"PUSH %d",GlobalEffects.size());
62  GlobalEffects.push( tmp );
64  GFXLightContextAmbient( GFXColor( 0, 0, 0, 1 ) );
65 }
void GFXReloadDefaultShader ( )

Definition at line 373 of file gl_program.cpp.

References defaultprog, GFXCreateProgram(), glDeleteProgram_p, hifiprog, hifiProgramName, lowfiprog, lowfiProgramName, programChanged, programVersion, and VSFileSystem::vs_fprintf().

Referenced by doReloadShader().

374 {
375  VSFileSystem::vs_fprintf(stderr, "Reloading all shaders\n");
376 
377  // Increasing the timestamp makes all programs elsewhere recompile
378  ++programVersion;
379 
380  bool islow = (lowfiprog == defaultprog);
384  }
385  programChanged = true;
386  if (islow) {
387  hifiprog = GFXCreateProgram( hifiProgramName.c_str(), hifiProgramName.c_str(), NULL );
388  if (hifiprog == 0) hifiprog = GFXCreateProgram( lowfiProgramName.c_str(), lowfiProgramName.c_str(), NULL );
389  lowfiprog = GFXCreateProgram( lowfiProgramName.c_str(), lowfiProgramName.c_str(), NULL );
390  if (lowfiprog == 0) lowfiprog = GFXCreateProgram( hifiProgramName.c_str(), hifiProgramName.c_str(), NULL );
392  } else {
393  lowfiprog = GFXCreateProgram( lowfiProgramName.c_str(), lowfiProgramName.c_str(), NULL );
394  if (lowfiprog == 0) lowfiprog = GFXCreateProgram( hifiProgramName.c_str(), hifiProgramName.c_str(), NULL );
395  hifiprog = GFXCreateProgram( hifiProgramName.c_str(), hifiProgramName.c_str(), NULL );
396  if (hifiprog == 0) hifiprog = GFXCreateProgram( lowfiProgramName.c_str(), lowfiProgramName.c_str(), NULL );
398  }
399 }
void GFXRestoreHudMode ( )

Definition at line 238 of file gl_matrix.cpp.

239 {
240  glMatrixMode( GL_MODELVIEW );
241  glLoadIdentity();
242  glMatrixMode( GL_PROJECTION );
243  glLoadIdentity();
244 }
void GFXSelectMaterial ( const unsigned int  number)

Definition at line 131 of file gl_material.cpp.

References materialinfo, power, and selectedmaterial.

Referenced by Stars::Draw(), Mesh::DrawNow(), setupGLState(), GameUniverse::StartGFX(), and TerrainMakeActive().

132 {
133  if (1 || static_cast<int>(number) != selectedmaterial) { //FIXME Last time I checked true or anything was true
134  float matvect[4];
135  matvect[0] = materialinfo[number].ar;
136  matvect[1] = materialinfo[number].ag;
137  matvect[2] = materialinfo[number].ab;
138  matvect[3] = materialinfo[number].aa;
139  glMaterialfv( GL_FRONT, GL_AMBIENT, matvect );
140 
141  matvect[0] = materialinfo[number].dr;
142  matvect[1] = materialinfo[number].dg;
143  matvect[2] = materialinfo[number].db;
144  matvect[3] = materialinfo[number].da;
145  glMaterialfv( GL_FRONT, GL_DIFFUSE, matvect );
146 
147  matvect[0] = materialinfo[number].sr;
148  matvect[1] = materialinfo[number].sg;
149  matvect[2] = materialinfo[number].sb;
150  matvect[3] = materialinfo[number].sa;
151  glMaterialfv( GL_FRONT, GL_SPECULAR, matvect );
152 
153  matvect[0] = materialinfo[number].er;
154  matvect[1] = materialinfo[number].eg;
155  matvect[2] = materialinfo[number].eb;
156  matvect[3] = materialinfo[number].ea;
157  glMaterialfv( GL_FRONT, GL_EMISSION, matvect );
158 
159  glMaterialfv( GL_FRONT, GL_SHININESS, &materialinfo[number].power );
160  selectedmaterial = number;
161  }
162 }
void GFXSelectMaterialHighlights ( const unsigned int  number,
const GFXColor ambient,
const GFXColor diffuse,
const GFXColor specular,
const GFXColor emmissive 
)

Tells Graphics library which material to use on next polygon if lighting enabled.

Definition at line 96 of file gl_material.cpp.

References GFXColor::a, GFXColor::b, GFXColor::g, materialinfo, power, GFXColor::r, and selectedmaterial.

Referenced by SetupCloakState(), SetupEnvmapPass(), SetupGlowMapFourthPass(), SetupSpecMapFirstPass(), and SetupSpecMapSecondPass().

101 {
102  selectedmaterial = -1;
103  float matvect[4];
104  matvect[0] = materialinfo[number].ar*ambient.r*ambient.a;
105  matvect[1] = materialinfo[number].ag*ambient.g*ambient.a;
106  matvect[2] = materialinfo[number].ab*ambient.b*ambient.a;
107  matvect[3] = materialinfo[number].aa*ambient.a;
108  glMaterialfv( GL_FRONT, GL_AMBIENT, matvect );
109 
110  matvect[0] = materialinfo[number].dr*diffuse.r*diffuse.a;
111  matvect[1] = materialinfo[number].dg*diffuse.g*diffuse.a;
112  matvect[2] = materialinfo[number].db*diffuse.b*diffuse.a;
113  matvect[3] = materialinfo[number].da*diffuse.a;
114  glMaterialfv( GL_FRONT, GL_DIFFUSE, matvect );
115 
116  matvect[0] = materialinfo[number].sr*specular.r*specular.a;
117  matvect[1] = materialinfo[number].sg*specular.g*specular.a;
118  matvect[2] = materialinfo[number].sb*specular.b*specular.a;
119  matvect[3] = materialinfo[number].sa*specular.a;
120  glMaterialfv( GL_FRONT, GL_SPECULAR, matvect );
121 
122  matvect[0] = emissive.r*emissive.a;
123  matvect[1] = emissive.g*emissive.a;
124  matvect[2] = emissive.b*emissive.a;
125  matvect[3] = emissive.a;
126  glMaterialfv( GL_FRONT, GL_EMISSION, matvect );
127 
128  glMaterialfv( GL_FRONT, GL_SHININESS, &materialinfo[number].power );
129 }
void GFXSelectTexture ( int  handle,
int  stage = 0 
)

Selects the current texture as being "active" so further drawn objects will have it.

Definition at line 1126 of file gl_texture.cpp.

References activetexture, GFXActiveTexture(), gl_options, gl_options_t::Multitexture, and textures.

Referenced by StreamTexture::MakeActive(), PipelinedTexture::MakeActive(), Texture::MakeActive(), PipelinedTexture::MakeBothActive(), and PipelinedTexture::MakeLastActive().

1127 {
1128  if (stage && stage >= static_cast<int>(gl_options.Multitexture)) return;
1129  if (activetexture[stage] != handle) {
1130  GFXActiveTexture( stage );
1131  activetexture[stage] = handle;
1132  if ( gl_options.Multitexture || (stage == 0) )
1133  glBindTexture( textures[handle].targets, textures[handle].name );
1134  }
1135 }
GFXBOOL GFXSetCutoff ( const float  cutoff)

Sets the intensity cutoff before picked lights are ignored.

Definition at line 214 of file gl_light.cpp.

References GFXFALSE, GFXTRUE, and intensity_cutoff.

Referenced by SetupGLLightGlobals().

215 {
216  if (ttcutoff < 0)
217  return GFXFALSE;
218  intensity_cutoff = ttcutoff;
219  return GFXTRUE;
220 }
GFXBOOL GFXSetLight ( const int  light,
const enum  LIGHT_TARGET,
const GFXColor color 
)

Modifies the parameters of the given light.

Definition at line 287 of file gl_light.cpp.

References _llights, GFXFALSE, and GFXTRUE.

Referenced by GamePlanet::Draw().

288 {
289  if ( (*_llights)[light].Target() == -2 )
290  return GFXFALSE;
291  (*_llights)[light].ResetProperties( lt, color );
292 
293  return GFXTRUE;
294 }
void GFXSetLightContext ( const int  con_number)

Sets active light context (restores all gllights in such context)

Definition at line 336 of file gl_light.cpp.

References _ambient_light, _currentContext, _llights, _local_lights_dat, GFX_MAX_LIGHTS, OpenGLL::GLL_OFF, i, OpenGLLights::index, lighttable, OpenGLLights::options, and unpicklights().

Referenced by ClientServerSetLightContext(), GFXCreateLightContext(), GameUniverse::StartGFX(), and GameStarSystem::SwapIn().

337 {
338  unpicklights();
339  int GLLindex = 0;
340  unsigned int i;
341  lighttable.Clear();
342  _currentContext = con_number;
343  _llights = &_local_lights_dat[con_number];
344  glLightModelfv( GL_LIGHT_MODEL_AMBIENT, (GLfloat*) &(_ambient_light[con_number]) );
345  //reset all lights so they arean't in GLLights
346  for (i = 0; i < _llights->size(); i++)
347  (*_llights)[i].Target() = -1;
348  for (i = 0; i < _llights->size() && GLLindex < GFX_MAX_LIGHTS; i++)
349  if ( (*_llights)[i].enabled() ) {
350  if ( (*_llights)[i].LocalLight() ) {
351  (*_llights)[i].AddToTable();
352  } else {
353  GLLights[GLLindex].index = -1; //make it clobber completley! no trace of old light.
354  (*_llights)[i].ClobberGLLight( GLLindex );
355  GLLindex++;
356  }
357  }
358  for (; GLLindex < GFX_MAX_LIGHTS; GLLindex++) {
359  GLLights[GLLindex].index = -1;
360  GLLights[GLLindex].options = OpenGLL::GLL_OFF;
361  glDisable( GL_LIGHT0+GLLindex );
362  }
363 }
void GFXSetMaterial ( unsigned int number,
const GFXMaterial material 
)

Creates a new material given a material struct. Will search through already made materials for matching materials to minimize switching.

Definition at line 71 of file gfxlib_struct_server.cpp.

References i, int, and materialinfo.

Referenced by Mesh::PostProcessLoading(), Mesh::SetMaterial(), and GameUniverse::StartGFX().

71 {}
void GFXSetOptimalIntensity ( const float  newint,
const float  saturatevalue 
)

Sets the optimal intensity given that Optimal number of lights is fulfilled.

Definition at line 222 of file gl_light.cpp.

References optintense, optsat, and saturate().

Referenced by SetupGLLightGlobals().

223 {
224  optintense = intensity;
225  optsat = saturate;
226 }
GFXBOOL GFXSetOptimalNumLights ( const int  numlights)

Sets number of lights graphics can handle optimally.

Definition at line 228 of file gl_light.cpp.

References GFX_MAX_LIGHTS, GFX_OPTIMAL_LIGHTS, GFXFALSE, and GFXTRUE.

Referenced by SetupGLLightGlobals().

229 {
230  if (numLights > GFX_MAX_LIGHTS || numLights < 0)
231  return GFXFALSE;
232  GFX_OPTIMAL_LIGHTS = numLights;
233  return GFXTRUE;
234 }
void GFXSetPickName ( int  name)

Definition at line 41 of file gl_pick.cpp.

42 {
43  glInitNames();
44  glPushName( name );
45  glLoadName( name );
46  glGetError();
47 }
GFXBOOL GFXSetSeparateSpecularColor ( const GFXBOOL  spec)

Sets the light model to have separate specular color (if available)

Definition at line 236 of file gl_light.cpp.

References GFXFALSE, and GFXTRUE.

Referenced by RestoreEnvmapState(), RestoreSpecMapState(), SetupEnvmapPass(), SetupGLLightGlobals(), SetupSpecMapFirstPass(), and SetupSpecMapSecondPass().

237 {
238 #if !defined (_WIN32) && !defined (__CYGWIN__)
239  if (spec) {
240  glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR );
241  } else {
242  glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR );
243  return GFXFALSE;
244  }
245 #else
246  return GFXFALSE;
247 #endif
248  return GFXTRUE;
249 }
int GFXShaderConstant ( int  name,
Vector  value 
)

Definition at line 556 of file gl_program.cpp.

References GFXShaderConstant().

Referenced by GFXShaderConstant().

557 {
558  return GFXShaderConstant( name, v.i, v.j, v.k, 0 );
559 }
int GFXShaderConstant ( int  name,
GFXColor  value 
)

Definition at line 551 of file gl_program.cpp.

References GFXColor::a, GFXColor::b, GFXColor::g, GFXShaderConstant(), and GFXColor::r.

552 {
553  return GFXShaderConstant( name, v.r, v.g, v.b, v.a );
554 }
int GFXShaderConstant ( int  name,
const float value 
)

Definition at line 546 of file gl_program.cpp.

References GFXShaderConstant().

547 {
548  return GFXShaderConstant( name, values[0], values[1], values[2], values[3] );
549 }
int GFXShaderConstant ( int  name,
float  v1,
float  v2,
float  v3,
float  v4 
)

Definition at line 533 of file gl_program.cpp.

References glUniform4f_p.

534 {
535  if (1
536 #ifndef __APPLE__
537  && glUniform4f_p
538 #endif
539  ) {
540  glUniform4f_p( name, v1, v2, v3, v4 );
541  return 1;
542  }
543  return 0;
544 }
int GFXShaderConstant ( int  name,
float  v1 
)

Definition at line 561 of file gl_program.cpp.

References glUniform1f_p.

562 {
563  if (1
564 #ifndef __APPLE__
565  && glUniform1f_p
566 #endif
567  ) {
568  glUniform1f_p( name, v1 );
569  return 1;
570  }
571  return 0;
572 }
int GFXShaderConstant4v ( int  name,
unsigned int  numvals,
const float value 
)

Definition at line 587 of file gl_program.cpp.

References glUniform4fv_p.

Referenced by GFXUploadLightState().

588 {
589  if (1
590 #ifndef __APPLE__
591  && glUniform4fv_p
592 #endif
593  ) {
594  glUniform4fv_p( name, count, values );
595  return 1;
596  }
597  return 0;
598 }
int GFXShaderConstanti ( int  name,
int  value 
)

Definition at line 600 of file gl_program.cpp.

References glUniform1i_p.

Referenced by GFXUploadLightState().

601 {
602  if (1
603 #ifndef __APPLE__
604  && glUniform1i_p
605 #endif
606  ) {
607  glUniform1i_p( name, value );
608  return 1;
609  }
610  return 0;
611 }
int GFXShaderConstantv ( int  name,
unsigned int  numvals,
const float value 
)

Definition at line 574 of file gl_program.cpp.

References glUniform1fv_p.

Referenced by GFXUploadLightState().

575 {
576  if (1
577 #ifndef __APPLE__
578  && glUniform1fv_p
579 #endif
580  ) {
581  glUniform1fv_p( name, count, values );
582  return 1;
583  }
584  return 0;
585 }
int GFXShaderConstantv ( int  name,
unsigned int  numvals,
const int value 
)

Definition at line 613 of file gl_program.cpp.

References glUniform1i_p, and glUniform1iv_p.

614 {
615  if (1
616 #ifndef __APPLE__
617  && glUniform1i_p
618 #endif
619  ) {
620  glUniform1iv_p( name, count, (GLint*) value );
621  return 1;
622  }
623  return 0;
624 }
bool GFXShaderReloaded ( )

Definition at line 463 of file gl_program.cpp.

References defaultprog, VegaConfig::getVariable(), GFXActivateShader(), GFXGetFramerate(), hifiprog, lowfiprog, XMLSupport::parse_bool(), programChanged, TOOFAST, TOOSLOW, and vs_config.

464 {
465  bool retval = programChanged;
466  static bool framerate_changes_shader =
467  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "framerate_changes_shader", "false" ) );
468  if (framerate_changes_shader) {
469  switch ( GFXGetFramerate() )
470  {
471  case TOOSLOW:
472  if (defaultprog) {
473  retval = true;
474  if (defaultprog == hifiprog)
476  else
477  defaultprog = 0;
478  GFXActivateShader( (char*) NULL );
479  }
480  break;
481  case TOOFAST:
482  if (defaultprog != hifiprog) {
483  retval = true;
484  if (defaultprog == 0)
486  else
488  GFXActivateShader( (char*) NULL );
489  }
490  break;
491  default:
492  break;
493  }
494  }
495  programChanged = false;
496  return retval;
497 }
void GFXShutdown ( )

Shuts down the graphics subsystem.

Definition at line 748 of file gl_init.cpp.

References gl_options_t::fullscreen, GFXDestroyAllLights(), GFXDestroyAllTextures(), gl_options, and winsys_shutdown().

Referenced by GameUniverse::~GameUniverse().

749 {
750  extern void GFXDestroyAllLights();
751 
755  winsys_shutdown();
756 }
float GFXSphereInFrustum ( const QVector Center,
float  Radius 
)

checks if a sphere is in the currently loaded Frustum given its center and radius

Definition at line 10 of file gl_clip.cpp.

References frust, and GFXSphereInFrustum().

Referenced by ContinuousTerrain::Draw(), GameUnit< UnitType >::Draw(), GameUnit< UnitType >::DrawNow(), GFXSphereInFrustum(), and GameUnit< UnitType >::queryFrustum().

11 {
12  return GFXSphereInFrustum( frust, Cnt, radius );
13 }
float GFXSphereInFrustum ( double  f[6][4],
const QVector Center,
float  Radius 
)

Checks if a sphere is in the given frustum calculated by GFXCalculateFrustum. Used in Unit clipping.

Definition at line 140 of file gl_clip.cpp.

References d.

141 {
142  /*
143  * static float lasttime = GetElapsedTime();
144  * if (lasttime!=GetElapsedTime()) {
145  * DrawFrustum (f);
146  * lasttime = GetElapsedTime();
147  * }*/
148  int p;
149  double d;
150  for (p = 0; p < 5; p++) {
151  //does not evaluate for yon
152  d = f[p][0]*Cnt.i+f[p][1]*Cnt.j+f[p][2]*Cnt.k+f[p][3];
153  if (d < 0) {
154  //VSFileSystem::Fprintf (stderr,"cin %f",d);
155  if (d <= -radius)
156  return 0;
157  }
158  }
159  return d;
160 }
CLIPSTATE GFXSpherePartiallyInFrustum ( const Vector cent,
const float  r 
)
CLIPSTATE GFXSpherePartiallyInFrustum ( double  f[6][4],
const Vector cent,
const float  r 
)

Definition at line 32 of file gl_clip.cpp.

References d, GFX_NOT_VISIBLE, GFX_PARTIALLY_VISIBLE, and GFX_TOTALLY_VISIBLE.

33 {
34  int p;
35  float d;
37  for (p = 0; p < 6; p++) {
38  //does not evaluate for yon
39  d = f[p][0]*Cnt.i+f[p][1]*Cnt.j+f[p][2]*Cnt.k+f[p][3];
40  if (d <= -radius)
41  return GFX_NOT_VISIBLE;
42  else if (d <= radius)
43  retval = GFX_PARTIALLY_VISIBLE;
44  }
45  return retval;
46 }
enum DEPTHFUNC GFXStencilFunc ( )

Returns the current stencil test function.

Definition at line 444 of file gl_state.cpp.

References cur_stencil_func.

445 {
446  return cur_stencil_func;
447 }
void GFXStencilFunc ( enum DEPTHFUNC pFunc,
int pRef,
int pMask 
)

Gets details about the current stancil compare function - Specify NULL for unwanted fields.

Definition at line 449 of file gl_state.cpp.

References cur_stencil_func, cur_stencil_func_mask, and cur_stencil_func_ref.

450 {
451  if (pFunc) *pFunc = cur_stencil_func;
452  if (pRef) *pRef = cur_stencil_func_ref;
453  if (pMask) *pMask = cur_stencil_func_mask;
454 }
void GFXStencilFunc ( enum DEPTHFUNC  sfunc,
int  ref,
unsigned int  mask 
)

Sets up a stencil compare function.

Definition at line 456 of file gl_state.cpp.

References ALWAYS, cur_stencil_func, cur_stencil_func_mask, cur_stencil_func_ref, EQUAL, GEQUAL, GREATER, LEQUAL, LESS, NEQUAL, and NEVER.

457 {
458  GLenum func;
459  switch (sfunc)
460  {
461  case NEVER:
462  func = GL_NEVER;
463  break;
464  case LESS:
465  func = GL_LESS;
466  break;
467  case EQUAL:
468  func = GL_EQUAL;
469  break;
470  case LEQUAL:
471  func = GL_LEQUAL;
472  break;
473  case GREATER:
474  func = GL_GREATER;
475  break;
476  case NEQUAL:
477  func = GL_NOTEQUAL;
478  break;
479  case GEQUAL:
480  func = GL_GEQUAL;
481  break;
482  case ALWAYS:
483  func = GL_ALWAYS;
484  break;
485  default:
486  func = GL_NEVER;
487  break;
488  }
489  glStencilFunc( func, (GLint) ref, (GLuint) mask );
490  cur_stencil_func = sfunc;
491  cur_stencil_func_ref = ref;
492  cur_stencil_func_mask = mask;
493 }
unsigned int GFXStencilMask ( )

Returns the current stencil write mask.

Definition at line 583 of file gl_state.cpp.

References cur_stencil_mask.

584 {
585  return cur_stencil_mask;
586 }
void GFXStencilMask ( unsigned int  mask)

Sets the stencil write mask.

Definition at line 588 of file gl_state.cpp.

References cur_stencil_mask.

589 {
590  glStencilMask( (GLuint) mask );
591  cur_stencil_mask = mask;
592 }
void GFXStencilOp ( enum STENCILOP pFail,
enum STENCILOP pZfail,
enum STENCILOP pZpass 
)

Gets the current stencil write operations - Specify NULL for unwanted fields.

Definition at line 495 of file gl_state.cpp.

References cur_stencil_op_f, cur_stencil_op_zf, and cur_stencil_op_zp.

496 {
497  if (pFail) *pFail = cur_stencil_op_f;
498  if (pZfail) *pZfail = cur_stencil_op_zf;
499  if (pZpass) *pZpass = cur_stencil_op_zp;
500 }
void GFXStencilOp ( enum STENCILOP  fail,
enum STENCILOP  zfail,
enum STENCILOP  zpass 
)

Sets up the stencil write operations.

Definition at line 502 of file gl_state.cpp.

References CLEAR, cur_stencil_op_f, cur_stencil_op_zf, cur_stencil_op_zp, DECR, INCR, INVERT, KEEP, and REPLACE.

503 {
504  GLenum ffunc, zffunc, zpfunc;
505  switch (fail)
506  {
507  case KEEP:
508  ffunc = GL_KEEP;
509  break;
510  case CLEAR:
511  ffunc = GL_ZERO;
512  break;
513  case REPLACE:
514  ffunc = GL_REPLACE;
515  break;
516  case INCR:
517  ffunc = GL_INCR;
518  break;
519  case DECR:
520  ffunc = GL_DECR;
521  break;
522  case INVERT:
523  ffunc = GL_INVERT;
524  break;
525  default:
526  ffunc = GL_KEEP;
527  break;
528  }
529  switch (zfail)
530  {
531  case KEEP:
532  zffunc = GL_KEEP;
533  break;
534  case CLEAR:
535  zffunc = GL_ZERO;
536  break;
537  case REPLACE:
538  zffunc = GL_REPLACE;
539  break;
540  case INCR:
541  zffunc = GL_INCR;
542  break;
543  case DECR:
544  zffunc = GL_DECR;
545  break;
546  case INVERT:
547  zffunc = GL_INVERT;
548  break;
549  default:
550  zffunc = GL_KEEP;
551  break;
552  }
553  switch (zpass)
554  {
555  case KEEP:
556  zpfunc = GL_KEEP;
557  break;
558  case CLEAR:
559  zpfunc = GL_ZERO;
560  break;
561  case REPLACE:
562  zpfunc = GL_REPLACE;
563  break;
564  case INCR:
565  zpfunc = GL_INCR;
566  break;
567  case DECR:
568  zpfunc = GL_DECR;
569  break;
570  case INVERT:
571  zpfunc = GL_INVERT;
572  break;
573  default:
574  zpfunc = GL_KEEP;
575  break;
576  }
577  glStencilOp( ffunc, zffunc, zpfunc );
578  cur_stencil_op_f = fail;
579  cur_stencil_op_zf = zfail;
580  cur_stencil_op_zp = zpass;
581 }
void GFXSubwindow ( int  x,
int  y,
int  xsize,
int  ysize 
)

Creates a subwindow with the current parameters for center and size.

Definition at line 327 of file gl_misc.cpp.

References g_game, game_data_t::x_resolution, and game_data_t::y_resolution.

Referenced by GFXSubwindow(), Camera::RestoreViewPort(), and Camera::UpdateGFX().

328 {
329  glViewport( x, y, xsize, ysize );
330  glScissor( x, y, xsize, ysize );
331  if (x == 0 && y == 0 && xsize == g_game.x_resolution && ysize == g_game.y_resolution)
332  glDisable( GL_SCISSOR_TEST );
333  else
334  glEnable( GL_SCISSOR_TEST );
335 }
void GFXSubwindow ( float  x,
float  y,
float  xsize,
float  ysize 
)

Definition at line 337 of file gl_misc.cpp.

References g_game, GFXSubwindow(), game_data_t::x_resolution, and game_data_t::y_resolution.

338 {
340  int(ysize*g_game.y_resolution) );
341 }
void GFXTexCoord224f ( const float  s,
const float  t,
const float  s2,
const float  t2,
const float  s3,
const float  t3,
const float  u3,
const float  v3 
)

Specifies four texture coordinates for a given vertex (3 textures)

Definition at line 237 of file gl_misc.cpp.

References gl_options, glMultiTexCoord2fARB_p, glMultiTexCoord4fARB_p, and gl_options_t::Multitexture.

Referenced by GFXVertexList::RefreshDisplayList().

245 {
246 #if !defined (IRIX)
247  if (gl_options.Multitexture) {
248  glMultiTexCoord2fARB_p( GL_TEXTURE0_ARB, s, t );
249  glMultiTexCoord2fARB_p( GL_TEXTURE1_ARB, s2, t2 );
250  glMultiTexCoord4fARB_p( GL_TEXTURE2_ARB, s3, t3, u3, v3 );
251  } else
252 #endif
253  {
254  glTexCoord2f( s, t );
255  }
256 }
void GFXTexCoord2f ( const float  s,
const float  t 
)

Specifies a pair of texture coordinates for given vertex.

Definition at line 219 of file gl_misc.cpp.

Referenced by AnimationDraw(), ParticlePoint::Draw(), GuiTexture::draw(), VSSprite::Draw(), Animation::DrawAsVSSprite(), DrawDamageFlash(), DrawHUDSprite(), Animation::DrawNoTransform(), and Animation::DrawNow().

220 {
221  glTexCoord2f( s, t );
222 }
void GFXTexCoord4f ( const float  s,
const float  t,
const float  u,
const float  v 
)

Specifies four texture coordinates for a given vertex (2 textures)

Definition at line 224 of file gl_misc.cpp.

References gl_options, glMultiTexCoord2fARB_p, and gl_options_t::Multitexture.

Referenced by VSSprite::Draw(), Animation::DrawAsVSSprite(), Animation::DrawNoTransform(), and Animation::DrawNow().

225 {
226 #if !defined (IRIX)
227  if (gl_options.Multitexture) {
228  glMultiTexCoord2fARB_p( GL_TEXTURE0_ARB, s, t );
229  glMultiTexCoord2fARB_p( GL_TEXTURE1_ARB, u, v );
230  } else
231 #endif
232  {
233  glTexCoord2f( s, t );
234  }
235 }
void GFXTextureAddressMode ( const ADDRESSMODE  mode,
enum TEXTURE_TARGET  target = TEXTURE2D 
)

Sets texture to clamp or wrap texture coordinates.

Definition at line 258 of file gl_state.cpp.

References _GFXActiveTextureValid(), BORDER, CLAMP, CUBEMAP, DEFAULT_ADDRESS_MODE, GetGLTextureTarget(), GL_CLAMP_TO_BORDER_ARB, GL_CLAMP_TO_EDGE_EXT, MIRROR, TEXTURE1D, TEXTURE3D, and WRAP.

Referenced by Background::Draw(), GFXCreateTexture(), and Texture::MakeActive().

259 {
260  if ( !_GFXActiveTextureValid() ) return;
261  GLenum tt = GetGLTextureTarget( target );
262  float BColor[4] = {0, 0, 0, 0}; //set border color to clear... dunno if we wanna change?
263  GLenum wm1, wm2;
264  switch (mode)
265  {
267  case WRAP:
268  wm1 = GL_REPEAT;
269  wm2 = 0;
270  break;
271  case BORDER:
272  wm1 = GL_CLAMP;
274  glTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, BColor );
275  //nobreak
276  case CLAMP:
277  wm1 = GL_CLAMP;
278  wm2 = GL_CLAMP_TO_EDGE_EXT;
279  break;
280  case MIRROR: //nope not goin here I hope nVidia extension?
281  default:
282  return; //won't work
283  }
284  glTexParameteri( tt, GL_TEXTURE_WRAP_S, wm1 );
285  if (target != TEXTURE1D)
286  glTexParameteri( tt, GL_TEXTURE_WRAP_T, wm1 );
287  if (target == TEXTURE3D || target == CUBEMAP)
288  glTexParameteri( tt, GL_TEXTURE_WRAP_R, wm1 );
289  if (wm2) {
290  glTexParameteri( tt, GL_TEXTURE_WRAP_S, wm2 );
291  if (target != TEXTURE1D)
292  glTexParameteri( tt, GL_TEXTURE_WRAP_T, wm2 );
293  if (target == TEXTURE3D || target == CUBEMAP)
294  glTexParameteri( tt, GL_TEXTURE_WRAP_R, wm2 );
295  }
296 }
void GFXTextureCoordGenMode ( int  stage,
GFXTEXTURECOORDMODE  tex,
const float  params[4],
const float  paramt[4] 
)

Definition at line 1075 of file gl_texture.cpp.

References CUBE_MAP_GEN, EYE_LINEAR_GEN, GFXActiveTexture(), gl_options, gl_options_t::Multitexture, NO_GEN, OBJECT_LINEAR_GEN, and SPHERE_MAP_GEN.

Referenced by GameStarSystem::activateLightMap(), Background::Draw(), VSSprite::Draw(), Animation::DrawAsVSSprite(), Animation::DrawNoTransform(), Animation::DrawNow(), GFXInit(), RestoreEnvmapState(), RestoreSpecMapState(), and SetupSpecMapFirstPass().

1076 {
1077  if (stage && stage >= static_cast<int>(gl_options.Multitexture)) return;
1078  GFXActiveTexture( stage );
1079  switch (tex)
1080  {
1081  case NO_GEN:
1082  glDisable( GL_TEXTURE_GEN_S );
1083  glDisable( GL_TEXTURE_GEN_T );
1084  glDisable( GL_TEXTURE_GEN_R );
1085  break;
1086  case EYE_LINEAR_GEN:
1087  glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
1088  glTexGenfv( GL_S, GL_EYE_PLANE, params );
1089  glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR );
1090  glTexGenfv( GL_T, GL_EYE_PLANE, paramt );
1091  glEnable( GL_TEXTURE_GEN_S );
1092  glEnable( GL_TEXTURE_GEN_T );
1093  glDisable( GL_TEXTURE_GEN_R );
1094  break;
1095  case OBJECT_LINEAR_GEN:
1096  glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
1097  glTexGenfv( GL_S, GL_OBJECT_PLANE, params );
1098  glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
1099  glTexGenfv( GL_T, GL_OBJECT_PLANE, paramt );
1100  glEnable( GL_TEXTURE_GEN_S );
1101  glEnable( GL_TEXTURE_GEN_T );
1102  glDisable( GL_TEXTURE_GEN_R );
1103  break;
1104  case SPHERE_MAP_GEN:
1105  glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
1106  glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
1107  glEnable( GL_TEXTURE_GEN_S );
1108  glEnable( GL_TEXTURE_GEN_T );
1109  glDisable( GL_TEXTURE_GEN_R );
1110  break;
1111  case CUBE_MAP_GEN:
1112 #ifdef NV_CUBE_MAP
1113  glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV );
1114  glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV );
1115  glTexGeni( GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV );
1116  glEnable( GL_TEXTURE_GEN_S );
1117  glEnable( GL_TEXTURE_GEN_T );
1118  glEnable( GL_TEXTURE_GEN_R );
1119 #else
1120  assert( 0 );
1121 #endif
1122  break;
1123  }
1124 }
void GFXTextureEnv ( int  stage,
GFXTEXTUREENVMODES  mode,
float  arg2 = 0 
)

Definition at line 1137 of file gl_texture.cpp.

References GFXActiveTexture(), GFXADDSIGNEDTEXTURE, GFXADDTEXTURE, GFXCOMPOSITETEXTURE, GFXDETAILTEXTURE, GFXINTERPOLATETEXTURE, GFXMODULATETEXTURE, GFXREPLACETEXTURE, gl_options, and gl_options_t::Multitexture.

Referenced by GameStarSystem::activateLightMap(), AnimationDraw(), Background::Draw(), VSSprite::Draw(), Animation::DrawAsVSSprite(), Animation::DrawNoTransform(), Animation::DrawNow(), Mesh::DrawNow(), GFXInit(), AnimatedTexture::MakeActive(), Beam::ProcessDrawQueue(), RestoreEnvmapState(), RestoreSpecMapState(), SetupEnvmapPass(), AnimatedTexture::SetupPass(), SetupSpecMapFirstPass(), and SetupSpecMapSecondPass().

1138 {
1139  if (stage && stage >= static_cast<int>(gl_options.Multitexture)) return;
1140  GLenum type;
1141  GFXActiveTexture( stage );
1142  switch (mode)
1143  {
1144  case GFXREPLACETEXTURE:
1145  type = GL_REPLACE;
1146  goto ENVMODE;
1147  case GFXADDTEXTURE:
1148  type = GL_ADD;
1149  goto ENVMODE;
1150  case GFXMODULATETEXTURE:
1151  type = GL_MODULATE;
1152 ENVMODE:
1153  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, type );
1154  break;
1155  case GFXINTERPOLATETEXTURE:
1156  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1157  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1158  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1159  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB );
1160  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA );
1161  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1162  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1163  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE );
1164  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_SRC_ALPHA );
1165  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_CONSTANT );
1166  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA );
1167  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, GL_CONSTANT );
1168  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, GL_SRC_ALPHA );
1169  {
1170  GLfloat arg2v[4] = {
1171  0, 0, 0, 1.0-arg2
1172  };
1173  glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, arg2v );
1174  }
1175  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );
1176  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_INTERPOLATE_ARB );
1177  glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1 );
1178  glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 );
1179  break;
1180  case GFXCOMPOSITETEXTURE:
1181  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1182  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1183  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1184  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_CONSTANT );
1185  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA );
1186  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1187  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1188  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE );
1189  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA );
1190  {
1191  GLfloat arg2v[4] = {
1192  0, 0, 0, arg2
1193  };
1194  glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, arg2v );
1195  }
1196  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );
1197  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE );
1198  glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1 );
1199  glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 );
1200  break;
1201  case GFXADDSIGNEDTEXTURE:
1202  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1203  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1204  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1205  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB );
1206  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1207  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1208  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB );
1209  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE );
1210  glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1 );
1211  glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1 );
1212  break;
1213  case GFXDETAILTEXTURE:
1214  glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
1215  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
1216  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB );
1217  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );
1218  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA );
1219  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
1220  glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE );
1221  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );
1222  glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_SRC_ALPHA );
1223  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE );
1224  glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE );
1225  glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2 );
1226  glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, 2 );
1227  break;
1228  }
1229 }
void GFXTextureWrap ( int  stage,
GFXTEXTUREWRAPMODES  mode,
enum TEXTURE_TARGET  target = TEXTURE2D 
)

Definition at line 1238 of file gl_texture.cpp.

References GetGLTextureTarget(), GFXActiveTexture(), GFXBORDERTEXTURE, GFXCLAMPTEXTURE, GFXREPEATTEXTURE, GL_CLAMP_TO_BORDER_ARB, GL_CLAMP_TO_EDGE_EXT, gl_options, gl_options_t::Multitexture, TEXTURE1D, and TEXTURE3D.

1239 {
1240  if (stage && stage >= static_cast<int>(gl_options.Multitexture)) return;
1241  GFXActiveTexture( stage );
1242  GLenum tt = GetGLTextureTarget( target );
1243  GLenum e1 = GL_REPEAT;
1244  GLenum e2 = 0;
1245  switch (mode)
1246  {
1247  case GFXCLAMPTEXTURE:
1248  e1 = GL_CLAMP;
1249  e2 = GL_CLAMP_TO_EDGE_EXT;
1250  break;
1251  case GFXREPEATTEXTURE:
1252  e1 = GL_REPEAT;
1253  e2 = 0;
1254  break;
1255  case GFXBORDERTEXTURE:
1256  e1 = GL_CLAMP;
1258  break;
1259  }
1260  glTexParameteri( tt, GL_TEXTURE_WRAP_S, e1 );
1261  if (target != TEXTURE1D) glTexParameteri( tt, GL_TEXTURE_WRAP_T, e1 );
1262  if (target == TEXTURE3D) glTexParameteri( tt, GL_TEXTURE_WRAP_R, e1 );
1263  if (e2) {
1264  glTexParameteri( tt, GL_TEXTURE_WRAP_S, e2 );
1265  if (target != TEXTURE1D) glTexParameteri( tt, GL_TEXTURE_WRAP_T, e2 );
1266  if (target == TEXTURE3D) glTexParameteri( tt, GL_TEXTURE_WRAP_R, e2 );
1267  }
1268 }
void GFXToggleTexture ( bool  enable,
int  whichstage,
enum TEXTURE_TARGET  target = TEXTURE2D 
)

Definition at line 167 of file gl_state.cpp.

References bTex, GetGLTextureTarget(), GFXActiveTexture(), gl_options, and gl_options_t::Multitexture.

Referenced by GameStarSystem::activateLightMap(), Bolt::Draw(), Background::Draw(), VSSprite::Draw(), Animation::DrawAsVSSprite(), PaintText::drawLines(), Animation::DrawNoTransform(), Animation::DrawNow(), Mesh::DrawNow(), GFXInit(), Beam::ProcessDrawQueue(), Mesh::ProcessDrawQueue(), RestoreEnvmapState(), RestoreFirstPassState(), SetupEnvmapPass(), and SetupSpecMapFirstPass().

168 {
169  if ( (whichstage < static_cast<int>(gl_options.Multitexture)) || (whichstage == 0) ) {
170  GLenum tt = GetGLTextureTarget( target );
171  GLenum btt = (enable ? tt : 0);
172  if (bTex[whichstage] != btt) {
173  GFXActiveTexture( whichstage );
174  if (bTex[whichstage])
175  glDisable( bTex[whichstage] );
176  if (enable)
177  glEnable( bTex[whichstage] = tt );
178 
179  else
180  bTex[whichstage] = 0;
181  }
182  }
183 }
GFXBOOL GFXTransferSubTexture ( unsigned char *  buffer,
int  handle,
int  x,
int  y,
unsigned int  width,
unsigned int  height,
enum TEXTURE_IMAGE_TARGET  image2D = TEXTURE_2D 
)

Definition at line 683 of file gl_texture.cpp.

References GetImageTarget(), GFXTRUE, and textures.

Referenced by PipelinedTexture::endMutate().

690 {
691  GLenum image2D = GetImageTarget( imagetarget );
692  glBindTexture( textures[handle].targets, textures[handle].name );
693 
694 //internalformat = GetTextureFormat (handle);
695 
696  glTexSubImage2D( image2D, 0, x, y, width, height, textures[handle].textureformat, GL_UNSIGNED_BYTE, buffer );
697  return GFXTRUE;
698 }
GFXBOOL GFXTransferTexture ( unsigned char *  buffer,
int  handle,
int  inWidth,
int  inHeight,
enum TEXTUREFORMAT  internalformat,
enum TEXTURE_IMAGE_TARGET  image2D = TEXTURE_2D,
int  max_texture_dimension = 65536,
GFXBOOL  detailtexture = GFXFALSE,
unsigned int  pageIndex = 0 
)

Transfers texture to the graphics card with given buffer in previously specified format. Scales texture approrpiately to Max texture sizes gotten from vid card

Definition at line 700 of file gl_texture.cpp.

References gl_options_t::compression, ddsDecompress(), DownSampleTexture(), DXT1, DXT1RGBA, DXT3, DXT5, GetImageTarget(), GetImageTargetName(), GetTextureFormat(), VegaConfig::getVariable(), GFXFALSE, GFXTransferTexture(), GFXTRUE, gl_options, glColorTable_p, glCompressedTexImage2D_p, i, isPowerOfTwo(), j, gl_options_t::max_texture_dimension, MAX_TEXTURE_SIZE, gl_options_t::mipmap, MIPMAP, PALETTE8, gl_options_t::PaletteExt, XMLSupport::parse_bool(), XMLSupport::parse_int(), PNGPALETTE8, PNGRGB24, PNGRGBA32, RGB16, RGB24, RGB32, RGBA16, RGBA32, gl_options_t::s3tc, size, textures, TRILINEAR, vs_config, and VSFileSystem::vs_dprintf().

Referenced by PipelinedTexture::Clone(), GFXTransferTexture(), PipelinedTexture::PipelinedTexture(), StreamTexture::StreamTexture(), Texture::Transfer(), and StreamTexture::UnMap().

709 {
710  if (handle < 0)
711  return GFXFALSE;
712  int error = 0;
713 
714  int logsize = 1;
715  int logwid = 1;
716  unsigned char *data = NULL;
717  unsigned char *tempbuf = NULL;
718  GLenum internalformat;
719  GLenum image2D = GetImageTarget( imagetarget );
720  glBindTexture( textures[handle].targets, textures[handle].name );
721  int blocksize = 16;
722  bool comptemp = gl_options.compression;
723 
724  //Read in the number of mipmaps from buffer
725  int offset1 = 2;
726  int offset2;
727  int mips = 0;
728  if (internformat >= DXT1 && internformat <= DXT5) {
729  mips = 0;
730  if (buffer[0]) mips = mips*10+(buffer[0]-'0');
731  if (buffer[1]) mips = mips*10+(buffer[1]-'0');
732  }
733  if (inWidth > 0)
734  textures[handle].iwidth = textures[handle].width = inWidth;
735  if (inHeight > 0)
736  textures[handle].iheight = textures[handle].height = inHeight;
737  //This code i believe is executed if our texture isn't power of two
738  if ( ( textures[handle].mipmapped&(TRILINEAR|MIPMAP) )
739  && ( !isPowerOfTwo( textures[handle].width, logwid ) || !isPowerOfTwo( textures[handle].height, logsize ) ) ) {
740  static unsigned char NONPOWEROFTWO[1024] = {
741  255, 127, 127, 255,
742  255, 255, 0, 255,
743  255, 255, 0, 255,
744  255, 127, 127, 255
745  };
746  buffer = NONPOWEROFTWO;
747  textures[handle].width = 2;
748  textures[handle].height = 2;
749  //assert (false);
750  }
751  logsize = logsize > logwid ? logsize : logwid;
752  //By default, if we have no limit set, aux_texture sends us a high number
753  //for the max dimension, so that we know to grep the GL max number.
754  //Otherwise maxdimension is set by some user argument based on quality settings.
755  if (maxdimension == 65536)
756  maxdimension = gl_options.max_texture_dimension;
758  "Transferring %dx%d texture, page %d (eff: %dx%d - limited at %d - %d mips), onto name %d (%s)\n",
759  textures[handle].iwidth,
760  textures[handle].iheight,
761  pageIndex,
762  textures[handle].width,
763  textures[handle].height,
764  maxdimension,
765  mips,
766  textures[handle].name,
767  GetImageTargetName( imagetarget )
768  );
769  if (maxdimension == 44) {
770  detail_texture = 0;
771  maxdimension = 256;
772  if (internformat == DXT1 || internformat == DXT1RGBA)
773  blocksize = 8;
774  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
775  glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
776  if (internformat >= DXT1 && internformat <= DXT5) {
777  if (textures[handle].width > 8 && textures[handle].height > 8 && mips > 0) {
778  offset1 += ( (textures[handle].width+3)/4 )*( (textures[handle].height+3)/4 )*blocksize;
779  if (textures[handle].width > 1) textures[handle].width >>= 1;
780  if (textures[handle].height > 1) textures[handle].height >>= 1;
781  if (textures[handle].iwidth > 1) textures[handle].iwidth >>= 1;
782  if (textures[handle].iheight > 1) textures[handle].iheight >>= 1;
783  --mips;
784  }
785  }
786  }
787  //If we are DDS, we can scale to max dimension by choosing a pre-made mipmap.
788  if (internformat == DXT1 || internformat == DXT1RGBA)
789  blocksize = 8;
790  if (internformat >= DXT1 && internformat <= DXT5) {
791  while ( (textures[handle].width > maxdimension || textures[handle].height > maxdimension) && mips > 0 ) {
792  offset1 += ( (textures[handle].width+3)/4 )*( (textures[handle].height+3)/4 )*blocksize;
793  if (textures[handle].width > 1) textures[handle].width >>= 1;
794  if (textures[handle].height > 1) textures[handle].height >>= 1;
795  if (textures[handle].iwidth > 1) textures[handle].iwidth >>= 1;
796  if (textures[handle].iheight > 1) textures[handle].iheight >>= 1;
797  --mips;
798  }
799  offset2 = offset1;
800  int w = textures[handle].width;
801  int h = textures[handle].height;
802  for (int i = 0; i < mips; ++i) {
803  offset2 += ( (w+3)/4 )*( (h+3)/4 )*blocksize;
804  if (w > 1) w >>= 1;
805  if (h > 1) h >>= 1;
806  }
807  } else {
808  //If we're not DDS, we have to generate a scaled version of the image
809  if (textures[handle].iwidth > maxdimension || textures[handle].iheight > maxdimension || textures[handle].iwidth
810  > MAX_TEXTURE_SIZE || textures[handle].iheight > MAX_TEXTURE_SIZE) {
811 #if !defined (GL_COLOR_INDEX8_EXT)
812  if (internformat != PALETTE8) {
813 #else
814  if (internformat != PALETTE8 || gl_options.PaletteExt) {
815 #endif
816  textures[handle].height = textures[handle].iheight;
817  textures[handle].width = textures[handle].iwidth;
818  DownSampleTexture( &tempbuf,
819  buffer,
820  textures[handle].height,
821  textures[handle].width,
822  ( internformat == PALETTE8 ? 1 : (internformat == RGBA32 ? 4 : 3) )*sizeof (unsigned char),
823  handle,
824  maxdimension,
825  maxdimension,
826  1 );
827  buffer = tempbuf;
828  VSFileSystem::vs_dprintf( 2, "Downsampled %dx%d texture (target: %dx%d - limited at %d)\n",
829  textures[handle].iwidth,
830  textures[handle].iheight,
831  textures[handle].width,
832  textures[handle].height,
833  maxdimension
834  );
835  }
836  offset2 = 2;
837  } else {
838  offset2 = offset1;
839  int w = textures[handle].width;
840  int h = textures[handle].height;
841  switch (internformat)
842  {
843  case PALETTE8:
844  offset2 += (w*h);
845  break;
846  case RGB16:
847  case RGBA16:
848  offset2 += (w*h)*2;
849  break;
850  case RGB24:
851  offset2 += (w*h)*3;
852  break;
853  case RGBA32:
854  case RGB32:
855  offset2 += (w*h)*4;
856  break;
857  case DXT1:
858  case DXT1RGBA:
859  offset2 += ( ( (w+3)/4 )*( (h+3)/4 ) )*8;
860  break;
861  case DXT3:
862  case DXT5:
863  offset2 += ( ( (w+3)/4 )*( (h+3)/4 ) )*16;
864  break;
865  case PNGPALETTE8:
866  offset2 += (w*h);
867  break;
868  case PNGRGB24:
869  offset2 += (w*h)*3;
870  break;
871  case PNGRGBA32:
872  offset2 += (w*h)*4;
873  break;
874  default:
875  offset2 = 2;
876  }
877  }
878  }
879  //skip to desired page
880  offset1 += pageIndex*(offset2-2);
881 
882  int height = textures[handle].height;
883  int width = textures[handle].width;
884  //If s3tc compression is disabled, our DDS files must be software decompressed
885  if (internformat >= DXT1 && internformat <= DXT5 && !gl_options.s3tc) {
886  unsigned char *tmpbuffer = buffer+offset1;
887  ddsDecompress( tmpbuffer, data, internformat, textures[handle].height, textures[handle].width );
888  buffer = data;
889  internformat = RGBA32;
890  textures[handle].textureformat = GL_RGBA;
891  }
892  if (internformat != PALETTE8 && internformat != PNGPALETTE8) {
893  internalformat = GetTextureFormat( internformat );
894  if ( ( ( textures[handle].mipmapped&(TRILINEAR|MIPMAP) ) && gl_options.mipmap >= 2 ) || detail_texture ) {
895  if (detail_texture) {
896  static FILTER fil =
897  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "detail_texture_trilinear",
898  "true" ) ) ? TRILINEAR : MIPMAP;
899  textures[handle].mipmapped = fil;
900  glTexParameteri( textures[handle].targets, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
901  if (fil&TRILINEAR)
902  glTexParameteri( textures[handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
903  else
904  glTexParameteri( textures[handle].targets, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
905  }
906  XMLSupport::parse_int( vs_config->getVariable( "graphics", "detail_texture_full_color", "1" ) );
907  //If we are DDS and we need to generate mipmaps (almost everything gets sent here, even non-3d visuals)
908  if (internformat >= DXT1 && internformat <= DXT5) {
909  int size = 0;
910  int i = 0;
911  unsigned int offset = 0;
912  //The following takes into account C/C++'s catenation of floats to int
913  //by adding 3, we ensure that when width or height is 1, we get a 1 rather than 0
914  //from the division by 4. Because of catenation, all other numbers will result with
915  //the expected number as if the +3 wasn't there. same as max(1,width/4)
916  size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
917  for (i = 0; i < mips; ++i) {
918  glCompressedTexImage2D_p( image2D, i, internalformat, width, height, 0, size, buffer+offset1+offset );
919  //We halve width and height until they reach 1, or i == mips
920  if (width != 1)
921  width >>= 1;
922  if (height != 1)
923  height >>= 1;
924  if (i < mips-1)
925  offset += size;
926  size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
927  }
928  /* HACK */
929  //This is a workaround for ani_texture which hates not having
930  //mipmaps.
931  if (mips == 0) {
932  size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
933  //We need to reverse some parameters that are set cuz
934  //we're supposed to have mipmaps here. But ani_texture hates us.
935  glTexParameteri( textures[handle].targets, GL_TEXTURE_BASE_LEVEL, 0 );
936  glTexParameteri( textures[handle].targets, GL_TEXTURE_MAX_LEVEL, 0 );
937  glCompressedTexImage2D_p( image2D, 0, internalformat, width, height, 0, size, buffer+offset1 );
938  }
939  /* END HACK */
940  } else {
941  //We want mipmaps but we have uncompressed data
942  gluBuild2DMipmaps( image2D,
943  internalformat,
944  textures[handle].width,
945  textures[handle].height,
946  textures[handle].textureformat,
947  GL_UNSIGNED_BYTE,
948  buffer );
949  }
950  if (tempbuf)
951  free( tempbuf );
952  tempbuf = NULL;
953  } else {
954  //WE HAVE NO MIPMAPS HERE
955  if (internformat >= DXT1 && internformat <= DXT5) {
956  int size = 0;
957  size = ( (width+3)/4 )*( (height+3)/4 )*blocksize;
958  //force GL to only display our one texture (just in case)
959  glTexParameteri( textures[handle].targets, GL_TEXTURE_BASE_LEVEL, 0 );
960  glTexParameteri( textures[handle].targets, GL_TEXTURE_MAX_LEVEL, 0 );
961  glCompressedTexImage2D_p( image2D, 0, internalformat, width, height, 0, size, buffer+offset1 );
962  } else {
963  glTexImage2D( image2D,
964  0,
965  internalformat,
966  textures[handle].width,
967  textures[handle].height,
968  0,
969  textures[handle].textureformat,
970  GL_UNSIGNED_BYTE,
971  buffer );
972  }
973  }
974  } else {
975  //THIS IS 8bpp LAND
976  internalformat = GetTextureFormat( internformat );
977  //IRIX has no GL_COLOR_INDEX8 extension
978 #if defined (GL_COLOR_INDEX8_EXT)
979  if (gl_options.PaletteExt) {
980  error = glGetError();
981  glColorTable_p( textures[handle].targets, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, textures[handle].palette );
982  error = glGetError();
983  if (error) {
984  if (tempbuf)
985  free( tempbuf );
986  gl_options.compression = comptemp;
987  if (data)
988  free( data );
989  return GFXFALSE;
990  }
991  if ( ( textures[handle].mipmapped&(MIPMAP|TRILINEAR) ) && gl_options.mipmap >= 2 )
992  gluBuild2DMipmaps( image2D,
993  GL_COLOR_INDEX8_EXT,
994  textures[handle].width,
995  textures[handle].height,
996  GL_COLOR_INDEX,
997  GL_UNSIGNED_BYTE,
998  buffer );
999  else
1000  glTexImage2D( image2D,
1001  0,
1002  GL_COLOR_INDEX8_EXT,
1003  textures[handle].width,
1004  textures[handle].height,
1005  0,
1006  GL_COLOR_INDEX,
1007  GL_UNSIGNED_BYTE,
1008  buffer );
1009  } else
1010 #endif
1011  {
1012  int nsize = 4*textures[handle].iheight*textures[handle].iwidth;
1013  unsigned char *tbuf = (unsigned char*) malloc( sizeof (unsigned char)*nsize );
1014  //textures[handle].texture = tbuf;
1015  int j = 0;
1016  for (int i = 0; i < nsize; i += 4) {
1017  tbuf[i] = textures[handle].palette[4*buffer[j]];
1018  tbuf[i+1] = textures[handle].palette[4*buffer[j]+1];
1019  tbuf[i+2] = textures[handle].palette[4*buffer[j]+2];
1020  //used to be 255
1021  tbuf[i+3] = textures[handle].palette[4*buffer[j]+3];
1022  j++;
1023  }
1025  tbuf, handle,
1026  textures[handle].iwidth, textures[handle].iheight,
1027  RGBA32, imagetarget, maxdimension, detail_texture );
1028  free( tbuf );
1029  }
1030  }
1031  if (tempbuf)
1032  free( tempbuf );
1033  gl_options.compression = comptemp;
1034  if (data)
1035  free( data );
1036  return GFXTRUE;
1037 }
CLIPSTATE GFXTransformedBoxInFrustum ( const Vector min,
const Vector max 
)

Definition at line 18 of file gl_clip.cpp.

References frust, and GFXBoxInFrustum().

19 {
20  return GFXBoxInFrustum( frust, min, max );
21 }
CLIPSTATE GFXTransformedSpherePartiallyInFrustum ( const Vector cent,
const float  r 
)

Definition at line 27 of file gl_clip.cpp.

References frust, and GFXSpherePartiallyInFrustum().

28 {
29  return GFXSpherePartiallyInFrustum( frust, Cnt, radius );
30 }
void GFXTranslateModel ( const QVector r)

Definition at line 175 of file gl_matrix.cpp.

References GFXMatrices::model, Matrix::p, TransformNormal(), and ViewToModel().

Referenced by Stars::Draw(), and ParticleTrail::DrawAndUpdate().

176 {
177  model.p += TransformNormal( model, a );
178  ViewToModel();
179 }
void GFXTranslateProjection ( const Vector r)

Translates the current "mode" matrix by a given vector.

Definition at line 181 of file gl_matrix.cpp.

References ConstructAndLoadProjection(), and GFXMatrices::projection.

182 {
183  projection[12] += a.i*projection[0]+a.j*projection[4]+a.k*projection[8];
184  projection[13] += a.i*projection[1]+a.j*projection[5]+a.k*projection[9];
185  projection[14] += a.i*projection[2]+a.j*projection[6]+a.k*projection[10];
187 }
void GFXTranslateView ( const QVector r)

Definition at line 165 of file gl_matrix.cpp.

References Matrix::p, TransformNormal(), GFXMatrices::view, and ViewToModel().

166 {
167  view.p += TransformNormal( view, a );
168  //glPopMatrix();
169  //glLoadIdentity();
170  //glTranslatef(-view[12],-view[13],-view[14]);
171  //glPushMatrix();
172  ViewToModel();
173 }
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 
)

Definition at line 14 of file gl_light_state.cpp.

References gfx_light::ContextSwitchClobberLight(), gfx_light::enabled(), float, GFXLight::getPosition(), GFXLight::getSize(), GFX_MAX_LIGHTS, GFXGetMatrixModel(), GFXLoadIdentity(), GFXLoadMatrixModel(), GFXShaderConstant4v(), GFXShaderConstanti(), GFXShaderConstantv(), i, M_PI, MODEL, Matrix::p, QVector, and UniverseUtil::sqrt().

15 {
16  // FIXME: (klauss) Very bad thing: static variables initialized with heap-allocated arrays...
17  static GLint *lightData = new GLint[GFX_MAX_LIGHTS];
18  static float *lightSizes = new float[GFX_MAX_LIGHTS*4];
19 
20  Matrix modelview;
21 
22  // if we're using shaders, we'll need the modelview matrix
23  // to properly compute light-model apparent light sizes
24  GFXGetMatrixModel(modelview);
25 
26  size_t maxval = 0;
27  size_t i = 0;
28 
29  for (vector<int>::const_iterator lightit = begin; lightit != end; ++i, ++lightit) {
30  const gfx_light &light = (*_llights)[*lightit];
31  if (light.enabled()) {
32  lightData[i] = 1;
33  maxval = i;
34 
35  // Only bother with apparent light size if there is a shader
36  if (shader) {
37  // We'll compute apparent light size by transforming the origin
38  // position by the modelview matrix, and computing the apparent
39  // size of a lightsource to that center and the proper size
40  // as entered in _gllights.
41  //
42  // This assumes the modelview matrix will be already set to
43  // the proper value when the light is enabled. It should.
44  //
45  // NOTE: We explicitly ignore rotation and scaling parts of the
46  // matrix. For one, rotation is meaningless for this calculation.
47  // For two, scaling would be nullified when scaling both distance
48  // and light size, so it would only waste time.
49 
50  QVector lightPos = light.getPosition() - modelview.p;
51 
52  double lightDistance = lightPos.Magnitude();
53  double lightSize = light.getSize() * 0.5;
54  double lightCosAngle;
55  double lightSolidAngle;
56  if (lightSize <= 0.0) {
57  // Point light always has zero solid angle
58  lightCosAngle = 1.0;
59  lightSolidAngle = 0.0;
60  } else {
61  // NOTE: assuming lightSize > 0, the following condition
62  // assures a nonzero distance to light, which would produce
63  // NaNs in the following math.
64  if (lightDistance > lightSize) {
65  // Light cos angle is:
66  // Vector(1, 0, 0) . Vector(lightDistance, lightSize, 0).Normalize()
67  // Which happens to resolve to:
68  //lightCosAngle = float(lightDistance / (lightDistance + lightSize));
69  lightCosAngle = lightDistance / sqrt( lightDistance*lightDistance + lightSize*lightSize );
70  lightSolidAngle = 2.0 * M_PI * ( 1.0 - lightCosAngle );
71  // Light steradians is:
72  // Steradians = Fractional Area * 4 * Pi
73  // Fractional Area = Apparent light area / Sky area at light distance
74  // Apparent light area = Pi * lightSize^2
75  // Sky area = 4 * Pi * lightDistance^2
76  // Do the math...
77  /*lightSolidAngle = float(M_PI
78  * ( lightSize / lightDistance )
79  * ( lightSize / lightDistance ));*/
80  } else {
81  // nil distance, avoid infinites that kill shaders
82  // NOTE: the constants aren't capricious, they're the right
83  // constants for a light coming from all around.
84  lightCosAngle = 0.0;
85  lightSolidAngle = 2.0 * M_PI;
86  }
87  }
88  lightSizes[i*4+0] = float(lightSize);
89  lightSizes[i*4+1] = float(lightCosAngle);
90  lightSizes[i*4+2] = float(lightSolidAngle);
91  lightSizes[i*4+3] = 0.f;
92  }
93  }
94  else {
95  lightData[i] = 0;
96  lightSizes[i*4+0] = 0.f;
97  lightSizes[i*4+1] = 0.f;
98  lightSizes[i*4+2] = 0.f;
99  lightSizes[i*4+3] = 0.f;
100  }
101  }
102 
103  for (; i < (size_t)GFX_MAX_LIGHTS; ++i) {
104  lightData[i] = 0;
105  lightSizes[i*4+0] = 0.f;
106  lightSizes[i*4+1] = 0.f;
107  lightSizes[i*4+2] = 0.f;
108  lightSizes[i*4+3] = 0.f;
109  }
110 
111  if (!shader) {
112  //only bother with actual GL state in the event of lack of shaders
113  for (size_t i = 0; i < (size_t) GFX_MAX_LIGHTS; ++i) {
114  int isenabled = glIsEnabled( GL_LIGHT0+i );
115  if (isenabled && !lightData[i])
116  glDisable( GL_LIGHT0+i );
117  else if (lightData[i] && !isenabled)
118  glEnable( GL_LIGHT0+i );
119  }
120  } else {
121  //only bother with shader constants it there is a shader
123  for (size_t i = 0; i <= maxval; ++i) {
124  if (lightData[i]) {
125  const gfx_light &light = (*_llights)[*(begin+i)];
126  light.ContextSwitchClobberLight(GL_LIGHT0+i, -1);
127  }
128  }
129  GFXLoadMatrixModel( modelview );
130  if (active_light_array >= 0)
131  GFXShaderConstantv( active_light_array, GFX_MAX_LIGHTS, (int*) lightData );
132  if (max_light_location >= 0)
133  GFXShaderConstanti( max_light_location, maxval );
134  if (apparent_light_size_array >= 0)
135  GFXShaderConstant4v( apparent_light_size_array, GFX_MAX_LIGHTS, (float*)lightSizes );
136  }
137 }
void GFXVertex3d ( const double  x,
const double  y,
const double  z = 1.0 
)

Definition at line 278 of file gl_misc.cpp.

Referenced by ParticlePoint::Draw(), DrawGun(), and DrawShield().

279 {
280  glVertex3d( x, y, z );
281 }
void GFXVertex3f ( const double  x,
const double  y,
const double  z = 1.0 
)

Definition at line 273 of file gl_misc.cpp.

274 {
275  glVertex3d( x, y, z );
276 }
void GFXVertexf ( const QVector v)

Definition at line 288 of file gl_misc.cpp.

289 {
290  glVertex3d( v.i, v.j, v.k );
291 }
void GFXViewPort ( int  minx,
int  miny,
int  maxx,
int  maxy 
)

Sets the final translation to screen coordinates, Also adjusts range of clearing.

Definition at line 219 of file gl_matrix.cpp.

Referenced by GameCockpit::SetupViewPort().

220 {
221  glViewport( minx, miny, maxx, maxy );
222 }