20 #include "../gpu/program.h"
21 #include "../gpu/bgl.h"
32 "uniform " + INPUT_IMAGE_DECL_TYPE +
" " + INPUT_IMAGE_ID +
";\n" +
36 bool str_replace(std::string&
str,
const std::string& from,
const std::string& to) {
37 size_t start_pos =
str.find(from);
38 if (start_pos == std::string::npos)
40 str.replace(start_pos, from.length(), to);
47 (
float)outputClipRect.
getX1() /
out.getWidth(),
48 (
float)outputClipRect.
getY1() /
out.getHeight(),
49 (
float)outputClipRect.
getX2() /
out.getWidth(),
50 (
float)outputClipRect.
getY2() /
out.getHeight()
56 recycleBin(recycleBin),
59 inputFormat(GL::TextureHandler::TextureFormat::RGBx8)
129 gpu.
bind(*input, 0, texParam);
A very basic class for any image.
const ImageResolution getSize() const
Returns the bitmap resolution within ImageResolution object.
2x3 affine mapping containing a 2x2 matrix and a 2D point
AffineMapping getInverse() const
Returns inverse mapping.
static const AffineMapping IDENTITY
Basic class: task and memory management, any kind of static data.
static const CustomRectangle UNIT_SQUARE
void setInteger(const std::string &name, const int value, bool safe=false)
Assigns a value to a specific integer variable in the program.
void enable(const GraphicPipeline &gpu)
void setIntegerArray(const std::string &name, const int *values, const int length)
void setMatrix3(const std::string &name, const Matrix2 &mat, const Point &pos)
static const char * DIALECT_SAMPLER_DECL_TYPE
glsl type name to declare a texture in Beatmup dialect
Stores references to GPU resources that will not be used anymore and needed to be recycled in a threa...
void put(Item *item)
Puts an item into the recycle bin.
GLSL program to render images Makes use of default vertex attributes to pass the texture coordinates ...
void link(const GraphicPipeline &gpu, const FragmentShader &)
void blend(bool onScreen)
static const char * DECLARE_TEXTURE_COORDINATES_IN_FRAG
Declaring texture coordinates in fragment shader.
static const char * MODELVIEW_MATRIX_ID
Modelview matrix (mapping input geometry to output) shader variable name in vertex shader.
virtual const TextureFormat getTextureFormat() const =0
Returns the texture format specifying how the shader must interpret the data.
void apply(Program &program)
Internal low-level GPU control API.
const ImageResolution & getDisplayResolution() const
void bindOutput(AbstractBitmap &bitmap)
Binds a bitmap to the pipeline output.
void setTextureCoordinates(const Rectangle &coords)
Specifies texture coordinates for the next rendering pass.
void bind(GL::TextureHandler &texture, size_t texUnit, const TextureParam param)
Represents image size in pixels.
Expection thrown if no shader source is provided.
A GLSL program to process images.
void process(GraphicPipeline &gpu)
Apply the shader to produce an image.
bool upToDate
if true, the program is up-to-date with respect to the source code
void setOutputClipping(const IntRectangle &rectangle)
Sets output clipping area.
void prepare(GraphicPipeline &gpu, GL::TextureHandler *input, const TextureParam texParam, AbstractBitmap *output, const AffineMapping &mapping)
Conducts required preparations for blending.
static const std::string CODE_HEADER
Shader code header containing necessary declarations.
GL::TextureHandler::TextureFormat inputFormat
last used input texture format; when changed, the shader is recompiled
void setSourceCode(const std::string &sourceCode)
Passes new source code to the fragment shader.
GL::RecycleBin & recycleBin
std::string sourceCode
last passed fragment shader source code
IntRectangle outputClipRect
output clip rectangle: only this specified area of the output image will be changed
GL::RenderingProgram * program
static const std::string INPUT_IMAGE_DECL_TYPE
A virtual input image type defined at shader compile time by ordinary texture or OES texture sampler ...
ImageShader(const ImageShader &)=delete
disabling copying constructor
void bindSamplerArray(const char *uniformId, int startingUnit, int numUnits)
Binds a bunch of texture units to a uniform sampler array variable.
static const std::string INPUT_IMAGE_ID
Shader variable name referring to the input image.
static AffineMapping getOutputCropMapping(const ImageResolution &out, const IntRectangle &outputClipRect)
bool str_replace(std::string &str, const std::string &from, const std::string &to)
Extensions
Supported OpenGL estensions.
@ BEATMUP_DIALECT
pseudo-extension enabling Beatmup GLSL dialect
@ EXTERNAL_TEXTURE
GL_OES_EGL_image_external_essl3 if available or GL_OES_EGL_image_external.
TextureParam
Parameters of binding a texture to a texture unit on GPU.
@ INTERP_LINEAR
bilinear pixel interpolation
ctx getGpuRecycleBin() -> emptyBin()
Beatmup::AffineMapping & mapping
JNIEnv jobject jstring str