Beatmup
|
A GLSL program to process images. More...
#include <image_shader.h>
Classes | |
class | NoSource |
Expection thrown if no shader source is provided. More... | |
Public Member Functions | |
ImageShader (GL::RecycleBin &recycleBin) | |
ImageShader (Context &ctx) | |
~ImageShader () | |
void | setSourceCode (const std::string &sourceCode) |
Passes new source code to the fragment shader. More... | |
void | setOutputClipping (const IntRectangle &rectangle) |
Sets output clipping area. More... | |
void | prepare (GraphicPipeline &gpu, GL::TextureHandler *input, const TextureParam texParam, AbstractBitmap *output, const AffineMapping &mapping) |
Conducts required preparations for blending. More... | |
void | prepare (GraphicPipeline &gpu, GL::TextureHandler *input, AbstractBitmap *output) |
void | prepare (GraphicPipeline &gpu, AbstractBitmap *output) |
Conducts required preparations for blending. More... | |
void | bindSamplerArray (const char *uniformId, int startingUnit, int numUnits) |
Binds a bunch of texture units to a uniform sampler array variable. More... | |
void | process (GraphicPipeline &gpu) |
Apply the shader to produce an image. More... | |
bool | usesContext (Context &context) const |
Returns true if the shader has ressources attached to a given context. More... | |
Public Member Functions inherited from Beatmup::GL::VariablesBundle | |
void | clear () |
Removes all stored variables. More... | |
void | setInteger (std::string name, int value) |
Sets a scalar integer uniform value. More... | |
void | setInteger (std::string name, int x, int y) |
void | setInteger (std::string name, int x, int y, int z) |
void | setInteger (std::string name, int x, int y, int z, int w) |
void | setFloat (std::string name, float value) |
Sets a scalar float uniform value. More... | |
void | setFloat (std::string name, float x, float y) |
void | setFloat (std::string name, float x, float y, float z) |
void | setFloat (std::string name, float x, float y, float z, float w) |
void | setFloatMatrix2 (std::string name, const float matrix[4]) |
Sets a float 2*2 matrix variable value. More... | |
void | setFloatMatrix3 (std::string name, const float matrix[9]) |
Sets a float 3*3 matrix variable value. More... | |
void | setFloatMatrix4 (std::string name, const float matrix[16]) |
Sets a float 4*4 matrix variable value. More... | |
void | setFloatMatrix4 (std::string name, const Color::Matrix &matrix) |
Sets a float 4*4 matrix variable value from a Color::Matrix instance. More... | |
void | setFloatArray (std::string name, const std::vector< float > &values) |
Sets a float array variable value. More... | |
float | getFloat (const std::string &name) const |
Retrieves a value of a scalar float uniform variable by its name. More... | |
Public Member Functions inherited from Beatmup::LockableObject | |
void | lock () |
void | unlock () |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Static Public Attributes | |
static const std::string | INPUT_IMAGE_DECL_TYPE = GL::FragmentShader::DIALECT_SAMPLER_DECL_TYPE |
A virtual input image type defined at shader compile time by ordinary texture or OES texture sampler depending on the input bound. More... | |
static const std::string | INPUT_IMAGE_ID = "image" |
Shader variable name referring to the input image. More... | |
static const std::string | CODE_HEADER |
Shader code header containing necessary declarations. More... | |
Private Member Functions | |
ImageShader (const ImageShader &)=delete | |
disabling copying constructor More... | |
Private Attributes | |
GL::RecycleBin & | recycleBin |
GL::RenderingProgram * | program |
std::string | sourceCode |
last passed fragment shader source code More... | |
bool | upToDate |
if true , the program is up-to-date with respect to the source code More... | |
GL::TextureHandler::TextureFormat | inputFormat |
last used input texture format; when changed, the shader is recompiled More... | |
IntRectangle | outputClipRect |
output clip rectangle: only this specified area of the output image will be changed More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Beatmup::GL::VariablesBundle | |
void | apply (Program &program) |
A GLSL program to process images.
Definition at line 34 of file image_shader.h.
|
privatedelete |
disabling copying constructor
ImageShader::ImageShader | ( | GL::RecycleBin & | recycleBin | ) |
Definition at line 55 of file image_shader.cpp.
ImageShader::ImageShader | ( | Context & | ctx | ) |
Definition at line 63 of file image_shader.cpp.
ImageShader::~ImageShader | ( | ) |
Definition at line 68 of file image_shader.cpp.
void ImageShader::setSourceCode | ( | const std::string & | sourceCode | ) |
Passes new source code to the fragment shader.
The new source code will be compiled and linked when next rendering occurs.
Definition at line 73 of file image_shader.cpp.
void ImageShader::setOutputClipping | ( | const IntRectangle & | rectangle | ) |
Sets output clipping area.
Only this specified area of the output bitmap will be changed by executing the shader. This must be called before prepare().
[in] | rectangle | The output clipping area in pixels |
Definition at line 81 of file image_shader.cpp.
void ImageShader::prepare | ( | GraphicPipeline & | gpu, |
GL::TextureHandler * | input, | ||
const TextureParam | texParam, | ||
AbstractBitmap * | output, | ||
const AffineMapping & | mapping | ||
) |
Conducts required preparations for blending.
Compiles shaders and links the rendering program if not yet.
gpu | Graphic pipeline instance |
input | Shader input image. This is optional, but the shader is considered to have at least one input image if this function is used. |
texParam | Input texture parameter |
output | Image to write shader output to (optional) |
mapping | Geometric transformation to apply when filling output |
Definition at line 86 of file image_shader.cpp.
void ImageShader::prepare | ( | GraphicPipeline & | gpu, |
GL::TextureHandler * | input, | ||
AbstractBitmap * | output | ||
) |
Definition at line 143 of file image_shader.cpp.
void ImageShader::prepare | ( | GraphicPipeline & | gpu, |
AbstractBitmap * | output | ||
) |
Conducts required preparations for blending.
Compiles shaders and links the rendering program if not yet. This function is used for shaders having no inputs.
gpu | Graphic pipeline instance |
output | Image to write shader output to (optional) |
Definition at line 148 of file image_shader.cpp.
void ImageShader::bindSamplerArray | ( | const char * | uniformId, |
int | startingUnit, | ||
int | numUnits | ||
) |
Binds a bunch of texture units to a uniform sampler array variable.
[in] | uniformId | The uniform array variable name |
[in] | startingUnit | First texture unit to be bound to the first element of the array |
[in] | numUnits | Number of texture units to bind (likely matches the length of the array) |
Definition at line 190 of file image_shader.cpp.
void ImageShader::process | ( | GraphicPipeline & | gpu | ) |
Apply the shader to produce an image.
gpu | A graphic pipeline instance |
Definition at line 195 of file image_shader.cpp.
|
inline |
Returns true
if the shader has ressources attached to a given context.
Definition at line 98 of file image_shader.h.
|
private |
Definition at line 37 of file image_shader.h.
|
private |
Definition at line 38 of file image_shader.h.
|
private |
last passed fragment shader source code
Definition at line 39 of file image_shader.h.
|
private |
if true
, the program is up-to-date with respect to the source code
Definition at line 40 of file image_shader.h.
|
private |
last used input texture format; when changed, the shader is recompiled
Definition at line 41 of file image_shader.h.
|
private |
output clip rectangle: only this specified area of the output image will be changed
Definition at line 42 of file image_shader.h.
|
static |
A virtual input image type defined at shader compile time by ordinary texture or OES texture sampler depending on the input bound.
Definition at line 104 of file image_shader.h.
|
static |
Shader variable name referring to the input image.
Definition at line 109 of file image_shader.h.
|
static |
Shader code header containing necessary declarations.
Definition at line 114 of file image_shader.h.