Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Enumerations | Functions | Variables
shader.hpp File Reference

Header for the internal GLSL shader organisation. More...

#include <SDL.h>
#include <SDL_opengl.h>
#include <limits.h>
#include <string.h>
#include <algorithm>
#include "inexor/engine/glexts.hpp"
#include "inexor/network/SharedVar.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_types.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/geom.hpp"

Go to the source code of this file.

Classes

struct  GlobalShaderParamState
 
struct  ShaderParamBinding
 
struct  GlobalShaderParamUse
 
struct  LocalShaderParamState
 
struct  SlotShaderParam
 
struct  SlotShaderParamState
 
struct  UniformLoc
 
struct  AttribLoc
 
struct  Shader
 
struct  GlobalShaderParam
 
struct  LocalShaderParam
 
union  GlobalShaderParamState.__unnamed__
 

Macros

#define MAXSHADERDETAIL   3
 
#define MAXVARIANTROWS   5
 
#define LOCALPARAM(name, vals)   do { static LocalShaderParam param( #name ); param.set(vals); } while(0)
 
#define LOCALPARAMF(name,...)   do { static LocalShaderParam param( #name ); param.setf(__VA_ARGS__); } while(0)
 
#define LOCALPARAMI(name,...)   do { static LocalShaderParam param( #name ); param.seti(__VA_ARGS__); } while(0)
 
#define LOCALPARAMV(name, vals, num)   do { static LocalShaderParam param( #name ); param.setv(vals, num); } while(0)
 
#define GLOBALPARAM(name, vals)   do { static GlobalShaderParam param( #name ); param.set(vals); } while(0)
 
#define GLOBALPARAMF(name,...)   do { static GlobalShaderParam param( #name ); param.setf(__VA_ARGS__); } while(0)
 
#define GLOBALPARAMI(name,...)   do { static GlobalShaderParam param( #name ); param.seti(__VA_ARGS__); } while(0)
 
#define GLOBALPARAMV(name, vals, num)   do { static GlobalShaderParam param( #name ); param.setv(vals, num); } while(0)
 
#define SETSHADER(name,...)
 
#define SETVARIANT(name,...)
 
#define MAXDYNLIGHTS   5
 
#define DYNLIGHTBITS   6
 
#define DYNLIGHTMASK   ((1<<DYNLIGHTBITS)-1)
 
#define MAXBLURRADIUS   7
 

Enumerations

enum  {
  SHADER_DEFAULT = 0, SHADER_NORMALSLMS = 1<<0, SHADER_ENVMAP = 1<<1, SHADER_OPTION = 1<<3,
  SHADER_INVALID = 1<<8, SHADER_DEFERRED = 1<<9
}
 

Functions

Shaderlookupshaderbyname (const char *name)
 
Shaderuseshaderbyname (const char *name)
 
Shadergenerateshader (const char *name, const char *cmd,...)
 
void resetslotshader ()
 
void setslotshader (Slot &s)
 
void linkslotshader (Slot &s, bool load=true)
 
void linkvslotshader (VSlot &s, bool load=true)
 
void linkslotshaders ()
 
const char * getshaderparamname (const char *name, bool insert=true)
 
void setupblurkernel (int radius, float sigma, float *weights, float *offsets)
 
void setblurshader (int pass, int size, int radius, float *weights, float *offsets)
 
void loadshaders ()
 
void renderpostfx ()
 

Variables

SharedVar< int > shaderdetail
 
Shadernullshader
 
Shaderhudshader
 
Shaderhudnotextureshader
 
Shadertextureshader
 
Shadernotextureshader
 
Shadernocolorshader
 
Shaderfoggedshader
 
Shaderfoggednotextureshader
 
Shaderstdworldshader
 
SharedVar< int > reservevpparams
 
SharedVar< int > maxvsuniforms
 
SharedVar< int > maxfsuniforms
 
Slot dummyslot
 
VSlot dummyvslot
 

Detailed Description

Header for the internal GLSL shader organisation.


Class Documentation

struct SlotShaderParam
Class Members
int loc
const char * name
float val[4]
union GlobalShaderParamState.__unnamed__
Class Members
uchar buf[32 *sizeof(float)]
float fval[32]
int ival[32]
uint uval[32]

Macro Definition Documentation

#define DYNLIGHTBITS   6

Referenced by calcdynlightmask(), and setdynlights().

#define DYNLIGHTMASK   ((1<<DYNLIGHTBITS)-1)

Referenced by finddynlights(), and setdynlights().

#define GLOBALPARAM (   name,
  vals 
)    do { static GlobalShaderParam param( #name ); param.set(vals); } while(0)
#define GLOBALPARAMF (   name,
  ... 
)    do { static GlobalShaderParam param( #name ); param.setf(__VA_ARGS__); } while(0)
#define GLOBALPARAMI (   name,
  ... 
)    do { static GlobalShaderParam param( #name ); param.seti(__VA_ARGS__); } while(0)
#define GLOBALPARAMV (   name,
  vals,
  num 
)    do { static GlobalShaderParam param( #name ); param.setv(vals, num); } while(0)

Referenced by setdynlights().

#define LOCALPARAM (   name,
  vals 
)    do { static LocalShaderParam param( #name ); param.set(vals); } while(0)
#define LOCALPARAMF (   name,
  ... 
)    do { static LocalShaderParam param( #name ); param.setf(__VA_ARGS__); } while(0)
#define LOCALPARAMI (   name,
  ... 
)    do { static LocalShaderParam param( #name ); param.seti(__VA_ARGS__); } while(0)
#define LOCALPARAMV (   name,
  vals,
  num 
)    do { static LocalShaderParam param( #name ); param.setv(vals, num); } while(0)

Referenced by setblurshader().

#define MAXBLURRADIUS   7

Referenced by setblurshader(), and setupblurkernel().

#define MAXDYNLIGHTS   5
#define MAXSHADERDETAIL   3
#define MAXVARIANTROWS   5
#define SETSHADER (   name,
  ... 
)
Value:
do { \
static Shader *name##shader = NULL; \
if(!name##shader) name##shader = lookupshaderbyname(#name); \
name##shader->set(__VA_ARGS__); \
} while(0)
#define NULL
Definition: cube_types.hpp:35
Shader * lookupshaderbyname(const char *name)
Definition: shader.cpp:73
void shader(int *type, char *name, char *vs, char *ps)
Definition: shader.cpp:1060
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
Definition: shader.hpp:142

Referenced by addglare(), addmotionblur(), drawfogdome(), drawfogoverlay(), drawskybox(), forcecubemapload(), gui::previewslot(), recorder::readbuffer(), decalrenderer::render(), renderblendbrush(), renderdepthobstacles(), rendergrass(), rendermaterials(), renderparticles(), renderprefab(), rendershadowmapreceivers(), rendertexturepanel(), setupcaustics(), startbb(), and fireballrenderer::startrender().

#define SETVARIANT (   name,
  ... 
)
Value:
do { \
static Shader *name##shader = NULL; \
if(!name##shader) name##shader = lookupshaderbyname(#name); \
name##shader->setvariant(__VA_ARGS__); \
} while(0)
#define NULL
Definition: cube_types.hpp:35
Shader * lookupshaderbyname(const char *name)
Definition: shader.cpp:73
void shader(int *type, char *name, char *vs, char *ps)
Definition: shader.cpp:1060
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
Definition: shader.hpp:142

Enumeration Type Documentation

anonymous enum
Enumerator
SHADER_DEFAULT 
SHADER_NORMALSLMS 
SHADER_ENVMAP 
SHADER_OPTION 
SHADER_INVALID 
SHADER_DEFERRED 

Function Documentation

Shader* generateshader ( const char *  name,
const char *  cmd,
  ... 
)
const char* getshaderparamname ( const char *  name,
bool  insert = true 
)
void linkslotshader ( Slot s,
bool  load = true 
)
void linkslotshaders ( )
void linkvslotshader ( VSlot s,
bool  load = true 
)
void loadshaders ( )
Shader* lookupshaderbyname ( const char *  name)
void renderpostfx ( )
void resetslotshader ( )
void setblurshader ( int  pass,
int  size,
int  radius,
float *  weights,
float *  offsets 
)
void setslotshader ( Slot s)
void setupblurkernel ( int  radius,
float  sigma,
float *  weights,
float *  offsets 
)

References loopi(), and MAXBLURRADIUS.

Referenced by rendertarget::blur().

Shader* useshaderbyname ( const char *  name)

Variable Documentation

VSlot dummyvslot & dummyslot
VSlot dummyvslot

Referenced by texturegui::gui(), and lookupvslot().

Shader * foggednotextureshader
Shader * foggedshader
Shader * hudnotextureshader
Shader * hudshader
SharedVar<int> maxfsuniforms

Referenced by setupshaders().

SharedVar<int> maxvsuniforms
Shader * nocolorshader
Shader * notextureshader
Shader* nullshader
SharedVar<int> reservevpparams
SharedVar<int> shaderdetail

Referenced by Shader::fixdetailshader().

Shader * stdworldshader
Shader * textureshader