FS2_Open
Open source remastering of the Freespace 2 engine
gropenglshader.h File Reference
#include "globalincs/pstypes.h"
#include "graphics/gropengl.h"
#include <string>

Go to the source code of this file.

Classes

struct  geometry_sdr_params
 
struct  opengl_shader_type_t
 
struct  opengl_shader_variant_t
 
struct  opengl_shader_file_t
 
struct  opengl_shader_uniform_reference_t
 
struct  opengl_shader_uniform_t
 
struct  opengl_shader_t
 

Macros

#define MAX_SHADER_UNIFORMS   20
 
#define SDR_ATTRIB_RADIUS   0
 
#define SDR_ATTRIB_SUBMODEL   1
 
#define MAX_SDR_ATTRIBUTES   5
 
#define MAX_SDR_UNIFORM_BLOCKS   5
 
#define ANIMATED_SHADER_LOADOUTSELECT_FS1   0
 
#define ANIMATED_SHADER_LOADOUTSELECT_FS2   1
 
#define ANIMATED_SHADER_CLOAK   2
 

Typedefs

typedef struct opengl_shader_uniform_t opengl_shader_uniform_t
 
typedef struct opengl_shader_t opengl_shader_t
 

Functions

int gr_opengl_maybe_create_shader (shader_type shader_t, unsigned int flags)
 
void opengl_delete_shader (int sdr_handle)
 
void opengl_shader_set_current (opengl_shader_t *shader_obj=NULL)
 
void opengl_shader_set_current (int handle)
 
void opengl_shader_init ()
 
void opengl_shader_shutdown ()
 
int opengl_compile_shader (shader_type sdr, uint flags)
 
void opengl_shader_init_attribute (const char *attribute_text)
 
GLint opengl_shader_get_attribute (const char *attribute_text)
 
void opengl_shader_init_uniform (const char *uniform_text)
 
GLint opengl_shader_get_uniform (const char *uniform_text)
 
void opengl_shader_init_uniform_block (const char *uniform_text)
 
GLint opengl_shader_get_uniform_block (const char *uniform_text)
 
void gr_opengl_shader_set_animated_effect (int effect, float timer)
 
int opengl_shader_get_animated_effect ()
 
float opengl_shader_get_animated_timer ()
 
void opengl_shader_compile_deferred_light_shader ()
 
void opengl_shader_compile_deferred_light_clear_shader ()
 

Variables

SCP_vector< opengl_shader_tGL_shader
 
opengl_shader_tCurrent_shader
 
geometry_sdr_paramsCurrent_geo_sdr_params
 

Macro Definition Documentation

#define ANIMATED_SHADER_CLOAK   2

Definition at line 160 of file gropenglshader.h.

#define ANIMATED_SHADER_LOADOUTSELECT_FS1   0

Definition at line 158 of file gropenglshader.h.

#define ANIMATED_SHADER_LOADOUTSELECT_FS2   1

Definition at line 159 of file gropenglshader.h.

#define MAX_SDR_ATTRIBUTES   5

Definition at line 24 of file gropenglshader.h.

#define MAX_SDR_UNIFORM_BLOCKS   5

Definition at line 26 of file gropenglshader.h.

#define MAX_SHADER_UNIFORMS   20

Definition at line 19 of file gropenglshader.h.

#define SDR_ATTRIB_RADIUS   0

Definition at line 21 of file gropenglshader.h.

#define SDR_ATTRIB_SUBMODEL   1

Definition at line 22 of file gropenglshader.h.

Typedef Documentation

Function Documentation

int gr_opengl_maybe_create_shader ( shader_type  shader_t,
unsigned int  flags 
)

Given a set of flags, determine whether a shader with these flags exists within the GL_shader vector. If no shader with the requested flags exists, attempt to compile one.

Parameters
shader_tshader_type variable, a reference to the shader program needed
flagsInteger variable, holding a combination of SDR_* flags
Returns
Index into GL_shader, referencing a valid shader, or -1 if shader compilation failed

Definition at line 229 of file gropenglshader.cpp.

void gr_opengl_shader_set_animated_effect ( int  effect,
float  timer 
)

Sets the currently active animated effect.

Parameters
effectEffect ID, needs to be implemented and checked for in the shader
timerTimer value to be passed to the shader

Definition at line 876 of file gropenglshader.cpp.

int opengl_compile_shader ( shader_type  sdr,
uint  flags 
)

Compiles a new shader, and creates an opengl_shader_t that will be put into the GL_shader vector if compilation is successful.

Parameters
sdrIdentifier defined with the program we wish to compile
flagsCombination of SDR_* flags

Definition at line 372 of file gropenglshader.cpp.

void opengl_delete_shader ( int  sdr_handle)

Definition at line 247 of file gropenglshader.cpp.

void opengl_shader_compile_deferred_light_clear_shader ( )
void opengl_shader_compile_deferred_light_shader ( )

Compile the deferred light shader.

Definition at line 903 of file gropenglshader.cpp.

int opengl_shader_get_animated_effect ( )

Returns the currently active animated effect ID.

Returns
Currently active effect ID

Definition at line 887 of file gropenglshader.cpp.

float opengl_shader_get_animated_timer ( )

Get the timer for animated effects.

Definition at line 895 of file gropenglshader.cpp.

GLint opengl_shader_get_attribute ( const char *  attribute_text)

Get the internal OpenGL location for a given attribute. Requires that the Current_shader global variable is valid

Parameters
attribute_textName of the attribute
Returns
Internal OpenGL location for the attribute

Definition at line 750 of file gropenglshader.cpp.

GLint opengl_shader_get_uniform ( const char *  uniform_text)

Get the internal OpenGL location for a given uniform. Requires that the Current_shader global variable is valid

Parameters
uniform_textName of the uniform
Returns
Internal OpenGL location for the uniform

Definition at line 799 of file gropenglshader.cpp.

GLint opengl_shader_get_uniform_block ( const char *  uniform_text)

Get the internal OpenGL location for a given uniform. Requires that the Current_shader global variable is valid

Parameters
uniform_textName of the uniform
Returns
Internal OpenGL location for the uniform

Definition at line 852 of file gropenglshader.cpp.

void opengl_shader_init ( )

Initializes the shader system. Creates a 1x1 texture that can be used as a fallback texture when framebuffer support is missing. Also compiles the shaders used for particle rendering.

Definition at line 487 of file gropenglshader.cpp.

void opengl_shader_init_attribute ( const char *  attribute_text)

Initialize a shader attribute. Requires that the Current_shader global variable is valid.

Parameters
attribute_textName of the attribute to be initialized

Definition at line 724 of file gropenglshader.cpp.

void opengl_shader_init_uniform ( const char *  uniform_text)

Initialize a shader uniform. Requires that the Current_shader global variable is valid.

Parameters
uniform_textName of the uniform to be initialized

Definition at line 773 of file gropenglshader.cpp.

void opengl_shader_init_uniform_block ( const char *  uniform_text)

Initialize a shader uniform. Requires that the Current_shader global variable is valid.

Parameters
uniform_textName of the uniform to be initialized

Definition at line 823 of file gropenglshader.cpp.

void opengl_shader_set_current ( opengl_shader_t shader_obj)

Set the currently active shader

Parameters
shader_objPointer to an opengl_shader_t object. This function calls glUseProgramARB with parameter 0 if shader_obj is NULL or if function is called without parameters, causing OpenGL to revert to fixed-function processing

Definition at line 180 of file gropenglshader.cpp.

void opengl_shader_set_current ( int  handle)

Definition at line 214 of file gropenglshader.cpp.

void opengl_shader_shutdown ( )

Go through GL_shader and call glDeleteObject() for all created shaders, then clear GL_shader

Definition at line 269 of file gropenglshader.cpp.

Variable Documentation

geometry_sdr_params* Current_geo_sdr_params

Definition at line 37 of file gropenglshader.cpp.

opengl_shader_t* Current_shader

Definition at line 170 of file gropenglshader.cpp.

Definition at line 28 of file gropenglshader.cpp.