Neo  0.5.0
Developer Documentation
Neo::PostProcessor Class Reference

The MPostProcessor class contains functionality used to render the current scene to a texture to allow applying GLSL post effects when rendering the final image to the screen. More...

#include <PostProcessor.h>

Classes

struct  float_uniform_t
 
struct  int_uniform_t
 
struct  uniform_t
 

Public Member Functions

 PostProcessor ()
 
bool draw (OCamera *camera)
 Renders the current scene to a texture and then to the screen after applying the post effects shader. More...
 
bool loadShader (const char *vertShad, const char *fragShad)
 Loads, compiles and links a shader pair to the GPU. More...
 
bool loadShaderFile (const char *vertShad, const char *fragShad)
 Loads, compiles and links a shader pair to the GPU. More...
 
void updateResolution ()
 Updates the color and depth texture to fit the current screen/window resolution. Needs to be called after MPostProcessor::eraseTextures()! More...
 
void eraseTextures ()
 Deletes the color and depth texture. That allows them to be recreated for example when the resolution changes. More...
 
void addFloatUniform (const char *name)
 Adds a uniform of the type float to the uniform list. More...
 
void setFloatUniformValue (const char *name, float value)
 Sets the value of a uniform with the type float. More...
 
float getFloatUniformValue (int idx)
 Gets the float value of the uniform at the index. More...
 
void addIntUniform (const char *name)
 Adds a uniform of the type int to the uniform list. More...
 
void setIntUniformValue (const char *name, float value)
 Sets the value of a uniform with the type int. More...
 
int getIntUniformValue (int idx)
 Gets the int value of the uniform at the index. More...
 
int getNumUniforms ()
 Returns the number of currently registered uniform variables. Increases whenever one of the "add*Uniform" gets called. More...
 
const char * getUniformName (int idx)
 Returns the name of the specified uniform variable. More...
 
M_VARIABLE_TYPE getUniformType (int idx)
 Returns the type of the specified uniform variable.
See also: M_VARIABLE_TYPE. More...
 
void clear ()
 Deletes all uniform variables currently registered. More...
 
const char * getVertexShader ()
 
const char * getFragmentShader ()
 
void setShaderPath (const char *vertPath, const char *fragPath)
 Sets the path to the vertex shader and the fragment shader without loading them. More...
 
int getFX ()
 
float getResolutionMultiplier ()
 
void setResolutionMultiplier (float res)
 Sets the current resolution multiplier. More...
 

Protected Member Functions

void set2D (unsigned int w, unsigned int h)
 
void drawQuad (Vector2 scale)
 
void sendUniforms ()
 

Protected Attributes

unsigned int m_BufferID
 
unsigned int m_ColourTexID
 
unsigned int m_DepthTexID
 
unsigned int m_fx
 
unsigned int m_fragShad
 
unsigned int m_vertShad
 
int m_Resolution
 
float m_ResolutionMultiplier
 
String m_vertShadPath
 
String m_fragShadPath
 
vector< uintptr_t > m_UniformList
 
Vector2 m_texCoords [4]
 
Vector2 m_vertices [4]
 

Detailed Description

The MPostProcessor class contains functionality used to render the current scene to a texture to allow applying GLSL post effects when rendering the final image to the screen.

Constructor & Destructor Documentation

Neo::PostProcessor::PostProcessor ( )

Member Function Documentation

void Neo::PostProcessor::addFloatUniform ( const char *  name)

Adds a uniform of the type float to the uniform list.

Parameters
nameThe name of the new uniform variable.
void Neo::PostProcessor::addIntUniform ( const char *  name)

Adds a uniform of the type int to the uniform list.

Parameters
nameThe name of the new uniform variable.
void Neo::PostProcessor::clear ( )

Deletes all uniform variables currently registered.

bool Neo::PostProcessor::draw ( OCamera camera)

Renders the current scene to a texture and then to the screen after applying the post effects shader.

Parameters
cameraThe camera to use.
Returns
Returns true if it rendered properly, false if it didn't.
void Neo::PostProcessor::drawQuad ( Vector2  scale)
protected
void Neo::PostProcessor::eraseTextures ( )

Deletes the color and depth texture. That allows them to be recreated for example when the resolution changes.

float Neo::PostProcessor::getFloatUniformValue ( int  idx)

Gets the float value of the uniform at the index.

Parameters
idxThe index of the uniform.
Returns
The float value
const char* Neo::PostProcessor::getFragmentShader ( )
inline
Returns
The fragment shaders file path
int Neo::PostProcessor::getFX ( )
inline
Returns
The internal FX ID.
int Neo::PostProcessor::getIntUniformValue ( int  idx)

Gets the int value of the uniform at the index.

Parameters
idxThe index of the uniform.
Returns
The int value
int Neo::PostProcessor::getNumUniforms ( )
inline

Returns the number of currently registered uniform variables. Increases whenever one of the "add*Uniform" gets called.

Returns
The number of all registered uniforms.
float Neo::PostProcessor::getResolutionMultiplier ( )
inline
Returns
The resolution multiplier.
const char* Neo::PostProcessor::getUniformName ( int  idx)

Returns the name of the specified uniform variable.

Parameters
idxThe index of the uniform variable.
Returns
The name of the uniform variable.
M_VARIABLE_TYPE Neo::PostProcessor::getUniformType ( int  idx)

Returns the type of the specified uniform variable.
See also: M_VARIABLE_TYPE.

Parameters
idxThe index of the uniform variable.
Returns
The type of the uniform variable.
const char* Neo::PostProcessor::getVertexShader ( )
inline
Returns
The vertex shaders file path
bool Neo::PostProcessor::loadShader ( const char *  vertShad,
const char *  fragShad 
)

Loads, compiles and links a shader pair to the GPU.

Parameters
vertShadThe sources of the vertex shader.
fragShadThe sources of the fragment shader.
Returns
Returns true if both shader loaded properly, false if they didn't.
bool Neo::PostProcessor::loadShaderFile ( const char *  vertShad,
const char *  fragShad 
)

Loads, compiles and links a shader pair to the GPU.

Parameters
vertShadThe path to the file containing the vertex shader sources.
fragShadThe path to the file containing the fragment shader sources.
Returns
Returns true if both shader loaded properly, false if they didn't.
void Neo::PostProcessor::sendUniforms ( )
protected
void Neo::PostProcessor::set2D ( unsigned int  w,
unsigned int  h 
)
protected
void Neo::PostProcessor::setFloatUniformValue ( const char *  name,
float  value 
)

Sets the value of a uniform with the type float.

Parameters
nameThe name of the uniform. This is the same name given when calling MPostProcessor::addFloatUniform().
valueThe value to apply.
void Neo::PostProcessor::setIntUniformValue ( const char *  name,
float  value 
)

Sets the value of a uniform with the type int.

Parameters
nameThe name of the uniform. This is the same name given when calling MPostProcessor::addIntUniform().
valueThe value to apply.
void Neo::PostProcessor::setResolutionMultiplier ( float  res)
inline

Sets the current resolution multiplier.

For this value to apply you need to call MPostProcessor::eraseTextures() and MPostProcessor::updateResolution().
This value is multiplied with the screen resolution, that means that value = 1.0 is the full resolution and value = 0.5 is the half of the full resolution etc.

Parameters
resThe new resolution multiplier.
void Neo::PostProcessor::setShaderPath ( const char *  vertPath,
const char *  fragPath 
)

Sets the path to the vertex shader and the fragment shader without loading them.

Parameters
vertPathThe path to the vertex shader.
fragPathThe path to the fragment shader.
void Neo::PostProcessor::updateResolution ( )

Updates the color and depth texture to fit the current screen/window resolution. Needs to be called after MPostProcessor::eraseTextures()!

Member Data Documentation

unsigned int Neo::PostProcessor::m_BufferID
protected
unsigned int Neo::PostProcessor::m_ColourTexID
protected
unsigned int Neo::PostProcessor::m_DepthTexID
protected
unsigned int Neo::PostProcessor::m_fragShad
protected
String Neo::PostProcessor::m_fragShadPath
protected
unsigned int Neo::PostProcessor::m_fx
protected
int Neo::PostProcessor::m_Resolution
protected
float Neo::PostProcessor::m_ResolutionMultiplier
protected
Vector2 Neo::PostProcessor::m_texCoords[4]
protected
vector<uintptr_t> Neo::PostProcessor::m_UniformList
protected
Vector2 Neo::PostProcessor::m_vertices[4]
protected
unsigned int Neo::PostProcessor::m_vertShad
protected
String Neo::PostProcessor::m_vertShadPath
protected

The documentation for this class was generated from the following file: