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
mesh_gfx.cpp File Reference
#include <algorithm>
#include "mesh.h"
#include "aux_texture.h"
#include "aux_logo.h"
#include "lin_time.h"
#include "configxml.h"
#include "vs_globals.h"
#include "cmd/nebula_generic.h"
#include "gfx/camera.h"
#include "gfx/animation.h"
#include "gfx/technique.h"
#include "mesh_xml.h"
#include "gldrv/gl_globals.h"
#include "gldrv/gl_light.h"
#include "universe_util.h"
#include <utility>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <exception>

Go to the source code of this file.

Classes

class  Exception
 
class  MissingTexture
 
class  OrigMeshContainer
 
struct  OrigMeshPainterSort
 
struct  MeshDrawContextPainterSort
 

Macros

#define SLESSX(a, b)
 
#define PLESSX(a, b)
 
#define SLESS(f)   SLESSX( f, b.f )
 
#define PLESS(f)   PLESSX( f, b.f )
 
#define NUM_PASSES   (4)
 
#define BASE_PASS   (0)
 
#define ENVSPEC_PASS   (1)
 
#define DAMAGE_PASS   (2)
 
#define GLOW_PASS   (3)
 
#define BASE_TEX   (0)
 
#define ENVSPEC_TEX   (1)
 
#define DAMAGE_TEX   (2)
 
#define GLOW_TEX   (3)
 
#define NORMAL_TEX   (4)
 
#define NUM_TEX   (5)
 
#define GETDECAL(pass)   ( (Decal[pass]) )
 
#define HASDECAL(pass)   ( ( (NUM_PASSES > pass) && Decal[pass] ) )
 
#define SAFEDECAL(pass)   ( (HASDECAL( pass ) ? Decal[pass] : black) )
 

Typedefs

typedef std::vector
< OrigMeshContainer
OrigMeshVector
 

Functions

TexturecreateTexture (const char *filename, int stage=0, enum FILTER f1=MIPMAP, enum TEXTURE_TARGET t0=TEXTURE2D, enum TEXTURE_IMAGE_TARGET t=TEXTURE_2D, unsigned char c=GFXFALSE, int i=65536)
 
LogocreateLogo (int numberlogos, Vector *center, Vector *normal, float *sizes, float *rotations, float offset, Texture *Dec, Vector *Ref)
 
TexturecreateTexture (char const *ccc, char const *cc, int k=0, enum FILTER f1=MIPMAP, enum TEXTURE_TARGET t0=TEXTURE2D, enum TEXTURE_IMAGE_TARGET t=TEXTURE_2D, float f=1, int j=0, unsigned char c=GFXFALSE, int i=65536)
 
AnimatedTexturecreateAnimatedTexture (char const *c, int i, enum FILTER f)
 
template<typename T >
bool rangesOverlap (T min1, T max1, T min2, T max2)
 
void SetupCloakState (char cloaked, const GFXColor &CloakFX, vector< int > &specialfxlight, unsigned char hulldamage, unsigned int matnum)
 
static void RestoreCloakState (char cloaked, bool envMap, unsigned char damage)
 
static void SetupFogState (char cloaked)
 
bool SetupSpecMapFirstPass (Texture **decal, size_t decalSize, unsigned int mat, bool envMap, float polygon_offset, Texture *detailTexture, const vector< Vector > &detailPlanes, bool &skip_glowpass, bool nomultienv)
 
void RestoreFirstPassState (Texture *detailTexture, const vector< Vector > &detailPlanes, bool skipped_glowpass, bool nomultienv)
 
void SetupEnvmapPass (Texture *decal, unsigned int mat, int passno)
 
void RestoreEnvmapState ()
 
void SetupSpecMapSecondPass (Texture *decal, unsigned int mat, BLENDFUNC blendsrc, bool envMap, const GFXColor &cloakFX, float polygon_offset)
 
void SetupGlowMapFourthPass (Texture *decal, unsigned int mat, BLENDFUNC blendsrc, const GFXColor &cloakFX, float polygon_offset)
 
void SetupDamageMapThirdPass (Texture *decal, unsigned int mat, float polygon_offset)
 
void RestoreGlowMapState (bool write_to_depthmap, float polygonoffset, float NOT_USED_BUT_BY_HELPER=3)
 
void RestoreDamageMapState (bool write_to_depthmap, float polygonoffset)
 
void RestoreSpecMapState (bool envMap, bool write_to_depthmap, float polygonoffset)
 
static void setupGLState (const Technique::Pass &pass, bool zwrite, BLENDFUNC blendSrc, BLENDFUNC blendDst, int material, unsigned char alphatest, int whichdrawqueue)
 

Variables

vector< Logo * > undrawn_logos
 
const int UNDRAWN_MESHES_SIZE = NUM_MESH_SEQUENCE
 
OrigMeshVector undrawn_meshes [NUM_MESH_SEQUENCE]
 
Hashtable< std::string,
std::vector< Mesh * >
, MESH_HASTHABLE_SIZE
bfxmHashTable
 

Macro Definition Documentation

#define BASE_PASS   (0)

Definition at line 190 of file mesh_gfx.cpp.

#define BASE_TEX   (0)

Definition at line 194 of file mesh_gfx.cpp.

#define DAMAGE_PASS   (2)

Definition at line 192 of file mesh_gfx.cpp.

Referenced by RestoreDamageMapState().

#define DAMAGE_TEX   (2)

Definition at line 196 of file mesh_gfx.cpp.

#define ENVSPEC_PASS   (1)

Definition at line 191 of file mesh_gfx.cpp.

#define ENVSPEC_TEX   (1)

Definition at line 195 of file mesh_gfx.cpp.

#define GETDECAL (   pass)    ( (Decal[pass]) )

Definition at line 1465 of file mesh_gfx.cpp.

#define GLOW_PASS   (3)

Definition at line 193 of file mesh_gfx.cpp.

Referenced by SetupSpecMapFirstPass().

#define GLOW_TEX   (3)

Definition at line 197 of file mesh_gfx.cpp.

#define HASDECAL (   pass)    ( ( (NUM_PASSES > pass) && Decal[pass] ) )

Definition at line 1466 of file mesh_gfx.cpp.

#define NORMAL_TEX   (4)

Definition at line 198 of file mesh_gfx.cpp.

#define NUM_PASSES   (4)

Definition at line 189 of file mesh_gfx.cpp.

#define NUM_TEX   (5)

Definition at line 199 of file mesh_gfx.cpp.

#define PLESS (   f)    PLESSX( f, b.f )

Definition at line 107 of file mesh_gfx.cpp.

Referenced by OrigMeshContainer::operator<().

#define PLESSX (   a,
  b 
)
Value:
do {SLESSX( bool(a), bool(b) ); if ( bool(a) ) SLESSX( *a, *b ); \
} \
while (0)

Definition at line 100 of file mesh_gfx.cpp.

Referenced by OrigMeshContainer::operator<().

#define SAFEDECAL (   pass)    ( (HASDECAL( pass ) ? Decal[pass] : black) )

Definition at line 1467 of file mesh_gfx.cpp.

#define SLESS (   f)    SLESSX( f, b.f )

Definition at line 105 of file mesh_gfx.cpp.

Referenced by OrigMeshContainer::operator<().

#define SLESSX (   a,
  b 
)
Value:
do {if ( !( (a) == (b) ) ) return ( (a) < (b) ); \
} \
while (0)

Definition at line 95 of file mesh_gfx.cpp.

Referenced by OrigMeshContainer::operator<().

Typedef Documentation

typedef std::vector< OrigMeshContainer > OrigMeshVector

Definition at line 187 of file mesh_gfx.cpp.

Function Documentation

AnimatedTexture* createAnimatedTexture ( char const *  c,
int  i,
enum FILTER  f 
)

Definition at line 353 of file mesh_gfx.cpp.

Referenced by SphereMesh::InitSphere().

354 {
355  return new AnimatedTexture( c, i, f );
356 }
Logo* createLogo ( int  numberlogos,
Vector center,
Vector normal,
float sizes,
float rotations,
float  offset,
Texture Dec,
Vector Ref 
)

Definition at line 327 of file mesh_gfx.cpp.

335 {
336  return new Logo( numberlogos, center, normal, sizes, rotations, offset, Dec, Ref );
337 }
Texture* createTexture ( const char *  filename,
int  stage = 0,
enum FILTER  f1 = MIPMAP,
enum TEXTURE_TARGET  t0 = TEXTURE2D,
enum TEXTURE_IMAGE_TARGET  t = TEXTURE_2D,
unsigned char  c = GFXFALSE,
int  i = 65536 
)

Definition at line 316 of file mesh_gfx.cpp.

323 {
324  return new Texture( filename, stage, f1, t0, t, c, i );
325 }
Texture* createTexture ( char const *  ccc,
char const *  cc,
int  k = 0,
enum FILTER  f1 = MIPMAP,
enum TEXTURE_TARGET  t0 = TEXTURE2D,
enum TEXTURE_IMAGE_TARGET  t = TEXTURE_2D,
float  f = 1,
int  j = 0,
unsigned char  c = GFXFALSE,
int  i = 65536 
)

Definition at line 339 of file mesh_gfx.cpp.

349 {
350  return new Texture( ccc, cc, k, f1, t0, t, f, j, c, i );
351 }
template<typename T >
bool rangesOverlap ( min1,
max1,
min2,
max2 
)
inline

Definition at line 554 of file mesh_gfx.cpp.

555 {
556  return !( ( (min1 < min2) == (max1 < min2) )
557  && ( (min1 < max2) == (max1 < max2) )
558  && ( (min1 < min2) == (min1 < max2) ) );
559 }
static void RestoreCloakState ( char  cloaked,
bool  envMap,
unsigned char  damage 
)
static

Definition at line 671 of file mesh_gfx.cpp.

References MeshDrawContext::CLOAK, GFXColorMaterial(), GFXEnable(), GFXPopBlendMode(), and TEXTURE1.

672 {
673  if (cloaked&MeshDrawContext::CLOAK) {
674  GFXColorMaterial( 0 );
675  if (envMap)
676  GFXEnable( TEXTURE1 );
677  GFXPopBlendMode();
678 #if defined (CG_SUPPORT)
679  cgGLDisableProfile( cloak_cg->vertexProfile );
680 #endif
681  }
682  if (damage)
683  GFXColorMaterial( 0 );
684 }
void RestoreDamageMapState ( bool  write_to_depthmap,
float  polygonoffset 
)

Definition at line 926 of file mesh_gfx.cpp.

References DAMAGE_PASS, and RestoreGlowMapState().

927 {
928  RestoreGlowMapState( write_to_depthmap, polygonoffset, DAMAGE_PASS );
929 }
void RestoreEnvmapState ( )

Definition at line 824 of file mesh_gfx.cpp.

References VegaConfig::getVariable(), GFXDepthFunc(), GFXEnable(), GFXFALSE, GFXMODULATETEXTURE, GFXPopBlendMode(), GFXSetSeparateSpecularColor(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXToggleTexture(), GFXTRUE, LEQUAL, LIGHTING, NO_GEN, XMLSupport::parse_bool(), and vs_config.

825 {
826  float dummy[4];
827  static bool separatespec =
828  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "separatespecularcolor", "false" ) ) ? GFXTRUE : GFXFALSE;
829  GFXSetSeparateSpecularColor( separatespec );
830  GFXEnable( LIGHTING );
831  GFXTextureCoordGenMode( 0, NO_GEN, dummy, dummy );
833  GFXDepthFunc( LEQUAL );
834  GFXPopBlendMode();
835  GFXToggleTexture( false, 0 );
836 }
void RestoreFirstPassState ( Texture detailTexture,
const vector< Vector > &  detailPlanes,
bool  skipped_glowpass,
bool  nomultienv 
)

Definition at line 774 of file mesh_gfx.cpp.

References _Universe, StarSystem::activateLightMap(), Universe::activeStarSystem(), GFXDepthFunc(), GFXPopBlendMode(), GFXToggleTexture(), i, and LEQUAL.

778 {
779  GFXPopBlendMode();
780  if (!nomultienv) GFXDepthFunc( LEQUAL );
781  if (detailTexture || skipped_glowpass) {
782  static float tempo[4] = {1, 0, 0, 0};
784  }
785  if (detailTexture) {
786  unsigned int sizeplus1 = detailPlanes.size()/2+1;
787  for (unsigned int i = 1; i < sizeplus1; i++)
788  GFXToggleTexture( false, i+1 ); //turn off high detial tex
789  }
790 }
void RestoreGlowMapState ( bool  write_to_depthmap,
float  polygonoffset,
float  NOT_USED_BUT_BY_HELPER = 3 
)

Definition at line 912 of file mesh_gfx.cpp.

References a, b, DEPTHWRITE, VegaConfig::getVariable(), GFXDepthFunc(), GFXEnable(), GFXPopBlendMode(), LEQUAL, XMLSupport::parse_bool(), TEXTURE1, and vs_config.

Referenced by RestoreDamageMapState().

913 {
914  float a, b;
915  //GFXGetPolygonOffset(&a,&b);
916  //GFXPolygonOffset (a, b+polygonoffset+NOT_USED_BUT_BY_HELPER);
917  GFXDepthFunc( LEQUAL ); //By Klauss - restore original depth function
918  static bool force_write_to_depthmap =
919  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "force_glowmap_restore_write_to_depthmap", "true" ) );
920  if (force_write_to_depthmap || write_to_depthmap)
922  GFXEnable( TEXTURE1 );
923  GFXPopBlendMode();
924 }
void RestoreSpecMapState ( bool  envMap,
bool  write_to_depthmap,
float  polygonoffset 
)

Definition at line 931 of file mesh_gfx.cpp.

References DEPTHWRITE, VegaConfig::getVariable(), GFXActiveTexture(), GFXADDTEXTURE, GFXDepthFunc(), GFXEnable(), GFXFALSE, GFXPopBlendMode(), GFXSetSeparateSpecularColor(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXTRUE, gl_options, LEQUAL, gl_options_t::Multitexture, NO_GEN, XMLSupport::parse_bool(), TEXTURE0, and vs_config.

932 {
933  //float a,b;
934  //GFXGetPolygonOffset(&a,&b);
935  //GFXPolygonOffset (a, b+1+polygonoffset); //Not needed anymore, since InitSpecMapSecondPass() no longer messes with polygon offsets
936  GFXDepthFunc( LEQUAL ); //By Klauss - restore original depth function
937  if (envMap) {
938  if (gl_options.Multitexture) {
939  GFXActiveTexture( 1 );
940  GFXTextureEnv( 1, GFXADDTEXTURE ); //restore modulate
941  } else {
942  float dummy[4];
943  GFXTextureCoordGenMode( 0, NO_GEN, dummy, dummy );
944  }
945  } else {
946  static bool separatespec =
947  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "separatespecularcolor",
948  "false" ) ) ? GFXTRUE : GFXFALSE;
949  GFXSetSeparateSpecularColor( separatespec );
950  }
951  if (write_to_depthmap)
953  GFXEnable( TEXTURE0 );
954  GFXPopBlendMode();
955 }
void SetupCloakState ( char  cloaked,
const GFXColor CloakFX,
vector< int > &  specialfxlight,
unsigned char  hulldamage,
unsigned int  matnum 
)

Definition at line 621 of file mesh_gfx.cpp.

References GFXColor::a, AMBIENT, GFXColor::b, MeshDrawContext::CLOAK, CULLFACE, DIFFUSE, GFXColor::g, GFXBlendMode(), GFXColor4f(), GFXColorf(), GFXColorMaterial(), GFXCreateLight(), GFXDisable(), GFXEnable(), GFXPushBlendMode(), GFXSelectMaterialHighlights(), MeshDrawContext::GLASSCLOAK, INVSRCALPHA, LIGHTING, MeshDrawContext::NEARINVIS, ONE, GFXColor::r, SRCALPHA, TEXTURE0, and TEXTURE1.

626 {
627  if (cloaked&MeshDrawContext::CLOAK) {
629  GFXDisable( CULLFACE );
630 
631  GFXEnable( LIGHTING );
632  GFXEnable( TEXTURE0 );
633  GFXEnable( TEXTURE1 );
634 
635  if (cloaked&MeshDrawContext::GLASSCLOAK) {
636  GFXDisable( TEXTURE1 );
637  int ligh;
638  GFXCreateLight( ligh,
639  GFXLight( true,
640  GFXColor( 0, 0, 0,
641  1 ), GFXColor( 0, 0, 0, 1 ), GFXColor( 0, 0, 0, 1 ), CloakFX, GFXColor( 1,
642  0,
643  0 ) ),
644  true );
645  specialfxlight.push_back( ligh );
646  GFXBlendMode( ONE, ONE );
648  GFXColor( 1, 1, 1, 1 ),
649  GFXColor( 1, 1, 1, 1 ),
650  GFXColor( 1, 1, 1, 1 ),
651  CloakFX );
652  } else {
653  GFXEnable( TEXTURE1 );
654  if (cloaked&MeshDrawContext::NEARINVIS) {
655  //NOT sure I like teh jump this produces GFXDisable (TEXTURE1);
656  }
659  if (hulldamage)
660  GFXColor4f( CloakFX.r, CloakFX.g, CloakFX.b, CloakFX.a*hulldamage/255 );
661  else
662  GFXColorf( CloakFX );
663  }
664  } else if (hulldamage) {
665  //ok now we go in and do the dirtying
667  GFXColor4f( 1, 1, 1, hulldamage/255. );
668  }
669 }
void SetupDamageMapThirdPass ( Texture decal,
unsigned int  mat,
float  polygon_offset 
)

Definition at line 899 of file mesh_gfx.cpp.

References DEPTHWRITE, GFXBlendMode(), GFXDepthFunc(), GFXDisable(), GFXPushBlendMode(), INVSRCALPHA, LEQUAL, Texture::MakeActive(), SRCALPHA, and TEXTURE1.

900 {
903  if (decal) decal->MakeActive();
904  //float a,b;
905  //GFXGetPolygonOffset(&a,&b);
906  //GFXPolygonOffset (a, b-DAMAGE_PASS-polygon_offset);
907  GFXDepthFunc( LEQUAL ); //By Klauss - this, with invariance, assures correct rendering (and avoids z-buffer artifacts at low res)
909  GFXDisable( TEXTURE1 );
910 }
void SetupEnvmapPass ( Texture decal,
unsigned int  mat,
int  passno 
)

Definition at line 792 of file mesh_gfx.cpp.

References _Universe, Universe::activateLightMap(), GFXBlendMode(), GFXDepthFunc(), GFXDisable(), GFXFALSE, GFXMODULATETEXTURE, GFXPushBlendMode(), GFXREPLACETEXTURE, GFXSelectMaterialHighlights(), GFXSetSeparateSpecularColor(), GFXTextureEnv(), GFXToggleTexture(), LEQUAL, LIGHTING, Texture::MakeActive(), ONE, SRCCOLOR, and ZERO.

793 {
794  assert( passno >= 0 && passno <= 2 );
795 
796  //This is only used when there's no multitexturing... so don't use multitexturing
799  GFXColor( 0, 0, 0, 0 ),
800  GFXColor( 0, 0, 0, 0 ),
801  (passno == 2) ? GFXColor( 1, 1, 1, 1 ) : GFXColor( 0, 0, 0, 0 ),
802  (passno == 2) ? GFXColor( 0, 0, 0, 0 ) : GFXColor( 1, 1, 1, 1 ) );
803  if (passno == 2)
805  if (passno != 2)
806  GFXDisable( LIGHTING );
807  if (decal)
808  GFXBlendMode( (passno != 1) ? ONE : ZERO, (passno == 1) ? SRCCOLOR : (passno ? ONE : ZERO) );
809 
810  else
811  GFXBlendMode( ONE, ONE );
812  if ( decal && ( (passno == 0) || (passno == 2) ) ) {
813  decal->MakeActive( 0 );
814  GFXToggleTexture( true, 0 );
815  } else if (passno == 1) {
817  } else {
818  GFXToggleTexture( false, 0 );
819  }
820  GFXTextureEnv( 0, ( (passno != 2) ? GFXREPLACETEXTURE : GFXMODULATETEXTURE ) );
821  GFXDepthFunc( LEQUAL );
822 }
static void SetupFogState ( char  cloaked)
static

Definition at line 686 of file mesh_gfx.cpp.

References _Universe, Universe::AccessCamera(), MeshDrawContext::FOG, FOG_OFF, Camera::GetNebula(), GFXFogMode(), and Nebula::SetFogState().

687 {
688  if (cloaked&MeshDrawContext::FOG) {
690  if (t)
691  t->SetFogState();
692  } else {
693  GFXFogMode( FOG_OFF );
694  }
695 }
void SetupGlowMapFourthPass ( Texture decal,
unsigned int  mat,
BLENDFUNC  blendsrc,
const GFXColor cloakFX,
float  polygon_offset 
)

Definition at line 877 of file mesh_gfx.cpp.

References DEPTHWRITE, GFXBlendMode(), GFXDepthFunc(), GFXDisable(), GFXPushBlendMode(), GFXSelectMaterialHighlights(), LEQUAL, Texture::MakeActive(), ONE, and TEXTURE1.

882 {
885  GFXColor( 0, 0, 0, 0 ),
886  GFXColor( 0, 0, 0, 0 ),
887  GFXColor( 0, 0, 0, 0 ),
888  cloakFX );
889  GFXBlendMode( ONE, ONE );
890  if (decal) decal->MakeActive();
891  //float a,b;
892  //GFXGetPolygonOffset(&a,&b);
893  //GFXPolygonOffset (a, b-2-polygon_offset);
894  GFXDepthFunc( LEQUAL ); //By Klauss - this, with invariance, assures correct rendering (and avoids z-buffer artifacts at low res)
896  GFXDisable( TEXTURE1 );
897 }
static void setupGLState ( const Technique::Pass pass,
bool  zwrite,
BLENDFUNC  blendSrc,
BLENDFUNC  blendDst,
int  material,
unsigned char  alphatest,
int  whichdrawqueue 
)
static

Definition at line 1064 of file mesh_gfx.cpp.

References Technique::Pass::Add, Technique::Pass::AlphaBlend, Technique::Pass::Always, ALWAYS, Technique::Pass::Back, Technique::Pass::blendMode, Technique::Pass::colorWrite, COLORWRITE, CULLFACE, Technique::Pass::cullMode, Technique::Pass::Decal, Technique::Pass::Default, Technique::Pass::DefaultFace, Technique::Pass::depthFunction, DEPTHWRITE, DESTCOLOR, Technique::Pass::Equal, EQUAL, gl_options_t::ext_srgb_framebuffer, Technique::Pass::Fill, Technique::Pass::Front, Technique::Pass::FrontAndBack, Technique::Pass::GEqual, GEQUAL, GFXAlphaTest(), GFXBACK, GFXBlendMode(), GFXCullFace(), GFXDepthFunc(), GFXDisable(), GFXEnable(), GFXFILLMODE, GFXFRONT, GFXFRONTANDBACK, GFXLINEMODE, GFXLineWidth(), GFXPOINTMODE, GFXPolygonMode(), GFXPolygonOffset(), GFXSelectMaterial(), GL_FRAMEBUFFER_SRGB_EXT, gl_options, Technique::Pass::Greater, GREATER, INVSRCALPHA, Technique::Pass::LEqual, LEQUAL, Technique::Pass::Less, LESS, LIGHTING, Technique::Pass::Line, Technique::Pass::lineWidth, Technique::Pass::MultiAlphaBlend, Technique::Pass::Multiply, Technique::Pass::Never, NEVER, Technique::Pass::None, Technique::Pass::offsetFactor, Technique::Pass::offsetUnits, ONE, Technique::Pass::Point, Technique::Pass::polyMode, Technique::Pass::PremultAlphaBlend, SRCALPHA, Technique::Pass::sRGBAware, and ZERO.

1065 {
1066  //Setup color/z writes, culling, etc...
1067  if (pass.colorWrite)
1068  GFXEnable( COLORWRITE );
1069  else
1071  {
1072  DEPTHFUNC func;
1073  switch (pass.depthFunction)
1074  {
1076  func = ALWAYS;
1077  break;
1079  func = NEVER;
1080  break;
1081  case Technique::Pass::Less:
1082  func = LESS;
1083  break;
1085  func = GREATER;
1086  break;
1088  func = GEQUAL;
1089  break;
1091  func = EQUAL;
1092  break;
1093  default:
1095  func = LEQUAL;
1096  break;
1097  }
1098  GFXDepthFunc( func );
1099  }
1100  {
1101  POLYMODE mode;
1102  switch (pass.polyMode)
1103  {
1105  mode = GFXPOINTMODE;
1106  break;
1107  case Technique::Pass::Line:
1108  mode = GFXLINEMODE;
1109  break;
1110  default:
1111  case Technique::Pass::Fill:
1112  mode = GFXFILLMODE;
1113  break;
1114  }
1115  GFXPolygonMode( mode );
1116  }
1117  if (pass.polyMode == Technique::Pass::Line)
1118  GFXLineWidth( pass.lineWidth );
1119  if (pass.cullMode == Technique::Pass::None) {
1120  GFXDisable( CULLFACE );
1121  } else if (pass.cullMode == Technique::Pass::DefaultFace) {
1122  //Not handled by this helper function, since it depends on mesh data
1123  //SelectCullFace( whichdrawqueue );
1124  } else {
1125  POLYFACE face;
1126  GFXEnable( CULLFACE );
1127  switch (pass.cullMode)
1128  {
1130  face = GFXFRONT;
1131  break;
1133  face = GFXFRONTANDBACK;
1134  break;
1135  default:
1136  case Technique::Pass::Back:
1137  face = GFXBACK;
1138  break;
1139  }
1140  GFXCullFace( face );
1141  }
1143 
1144  if (zwrite)
1145  GFXEnable( DEPTHWRITE );
1146  else
1148 
1149  //Setup blend mode
1150  switch (pass.blendMode)
1151  {
1152  case Technique::Pass::Add:
1153  GFXBlendMode( ONE, ONE );
1154  break;
1158  break;
1160  GFXBlendMode( ONE, ZERO );
1161  break;
1164  break;
1167  break;
1169  default:
1170  GFXBlendMode( blendSrc, blendDst );
1171  break;
1172  }
1173 
1174  GFXEnable( LIGHTING );
1175  GFXSelectMaterial( material );
1176 
1177  //If we're doing zwrite, alpha test is more or less mandatory for correct results
1178  if (alphatest)
1179  GFXAlphaTest( GEQUAL, alphatest/255.0 );
1180  else if (zwrite)
1181  GFXAlphaTest( GREATER, 0 );
1182 
1184  if (pass.sRGBAware)
1185  glEnable( GL_FRAMEBUFFER_SRGB_EXT );
1186  else
1187  glDisable( GL_FRAMEBUFFER_SRGB_EXT );
1188  }
1189 }
bool SetupSpecMapFirstPass ( Texture **  decal,
size_t  decalSize,
unsigned int  mat,
bool  envMap,
float  polygon_offset,
Texture detailTexture,
const vector< Vector > &  detailPlanes,
bool skip_glowpass,
bool  nomultienv 
)

Definition at line 697 of file mesh_gfx.cpp.

References a, b, VegaConfig::getVariable(), GFXADDTEXTURE, GFXBlendMode(), GFXDepthFunc(), GFXDETAILTEXTURE, GFXDisable(), GFXFALSE, GFXGetPolygonOffset(), GFXPolygonOffset(), GFXPushBlendMode(), GFXSelectMaterialHighlights(), GFXSetSeparateSpecularColor(), GFXTextureCoordGenMode(), GFXTextureEnv(), GFXToggleTexture(), GFXTRUE, gl_options, GLOW_PASS, i, LEQUAL, Texture::MakeActive(), gl_options_t::Multitexture, NO_GEN, OBJECT_LINEAR_GEN, ONE, XMLSupport::parse_bool(), TEXTURE1, and vs_config.

706 {
708 
709  static bool separatespec =
710  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "separatespecularcolor", "false" ) ) ? GFXTRUE : GFXFALSE;
711  GFXSetSeparateSpecularColor( separatespec );
712 
713  static bool multitex_glowpass = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "multitexture_glowmaps", "true" ) );
714  if (polygon_offset) {
715  float a, b;
716  GFXGetPolygonOffset( &a, &b );
717  GFXPolygonOffset( a, b-polygon_offset );
718  }
719  if (nomultienv) {
721  GFXColor( 1, 1, 1, 1 ),
722  GFXColor( 1, 1, 1, 1 ),
723  GFXColor( 0, 0, 0, 0 ),
724  GFXColor( 0, 0, 0, 0 ) );
725  GFXBlendMode( ONE, ONE );
726  GFXDepthFunc( LEQUAL );
727  }
728  bool retval = false;
729  skip_glowpass = false;
730  size_t detailoffset = 2;
731  if ( !nomultienv && (decalSize > 1) && (decal[1]) ) {
732  detailoffset = 1;
734  GFXColor( 1, 1, 1, 1 ),
735  GFXColor( 1, 1, 1, 1 ),
736  GFXColor( 0, 0, 0, 0 ),
737  GFXColor( 0, 0, 0, 0 ) );
738  retval = true;
739  if (envMap && detailTexture == NULL) {
740  if ( (decalSize > GLOW_PASS) && decal[GLOW_PASS] && gl_options.Multitexture && multitex_glowpass ) {
741  decal[GLOW_PASS]->MakeActive( 1 );
743  GFXToggleTexture( true, 1 );
744  GFXTextureCoordGenMode( 1, NO_GEN, NULL, NULL );
745  skip_glowpass = true;
746  } else {GFXDisable( TEXTURE1 ); }
747  }
748  if (decal[0]) {
749  decal[0]->MakeActive( 0 );
750  GFXToggleTexture( true, 0 );
751  } else {
752  GFXToggleTexture( false, 0 );
753  }
754  } else if (decalSize && decal[0]) {
755  GFXToggleTexture( true, 0 );
756  decal[0]->MakeActive( 0 );
757  } else {
758  GFXToggleTexture( false, 0 );
759  }
760  if ( detailTexture && (gl_options.Multitexture > detailoffset) ) {
761  for (unsigned int i = 1; i < detailPlanes.size(); i += 2) {
762  int stage = (i/2)+detailoffset;
763  const float params[4] = {detailPlanes[i-1].i, detailPlanes[i-1].j, detailPlanes[i-1].k, 0};
764  const float paramt[4] = {detailPlanes[i].i, detailPlanes[i].j, detailPlanes[i].k, 0};
765  GFXTextureCoordGenMode( stage, OBJECT_LINEAR_GEN, params, paramt );
766  detailTexture->MakeActive( stage );
768  GFXToggleTexture( true, stage );
769  }
770  }
771  return retval;
772 }
void SetupSpecMapSecondPass ( Texture decal,
unsigned int  mat,
BLENDFUNC  blendsrc,
bool  envMap,
const GFXColor cloakFX,
float  polygon_offset 
)

Definition at line 838 of file mesh_gfx.cpp.

References _Universe, Universe::activateLightMap(), DEPTHWRITE, GFXActiveTexture(), GFXBlendMode(), GFXDepthFunc(), GFXDisable(), GFXEnable(), GFXFALSE, GFXMODULATETEXTURE, GFXPushBlendMode(), GFXSelectMaterialHighlights(), GFXSetSeparateSpecularColor(), GFXTextureEnv(), gl_options, LEQUAL, Texture::MakeActive(), gl_options_t::Multitexture, ONE, TEXTURE0, and TEXTURE1.

844 {
847  GFXColor( 0, 0, 0, 0 ),
848  GFXColor( 0, 0, 0, 0 ),
849  cloakFX,
850  ( envMap ? GFXColor( 1, 1, 1, 1 ) : GFXColor( 0, 0, 0, 0 ) ) );
851  GFXBlendMode( ONE, ONE );
852  if (!envMap || gl_options.Multitexture)
853  if (decal) decal->MakeActive();
854  //float a,b;
855  //GFXGetPolygonOffset(&a,&b);
856  //GFXPolygonOffset (a, b-1-polygon_offset); //Not needed, since we use GL_EQUAL and appeal to invariance
857  GFXDepthFunc( LEQUAL ); //By Klauss - this, with invariance, assures correct rendering (and avoids z-buffer artifacts at low res)
859  if (envMap) {
860  int stage = gl_options.Multitexture ? 1 : 0;
863  GFXEnable( TEXTURE0 );
864  GFXActiveTexture( stage );
867  GFXEnable( TEXTURE1 );
868  } else {
871  GFXEnable( TEXTURE0 );
872  GFXActiveTexture( 1 );
873  GFXDisable( TEXTURE1 );
874  }
875 }

Variable Documentation

Hashtable< std::string, std::vector< Mesh* >, MESH_HASTHABLE_SIZE > bfxmHashTable

Definition at line 1256 of file mesh_xml.cpp.

vector< Logo* > undrawn_logos

Definition at line 31 of file aux_logo.cpp.

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

const int UNDRAWN_MESHES_SIZE = NUM_MESH_SEQUENCE

Definition at line 201 of file mesh_gfx.cpp.