This version of documentation describes older release of the framework. Please consider upgrading to the latest release.
Corresponding class for Windows platform is here.
Implements renderer. This renderer support shader programs. Please find more information about them after the class decription.
You can find more information in comments below. Overrided methods can be found in corresponding base interface.
class CRenderer :public virtual IRenderer
{
public:
IWindow * getWindow() override;
ITexture *getRenderTarget() override;
Rect getViewport() override;
Color getClearColor() override;
TECHNOLOGY_TYPE getTechnology() const override; // Return ttOpenGL
Point getMinVersion() const override; // Return { 3, 1 }
Point getVersion() override;
// Since 1.3.0
IShaderProgram *getShaderProgram() override;
// Since 6.0.0
INativeGraphics *getNativeGraphics() override; // Return instance of IOpenGLES interface
bool setWindow(IWindow *value) override;
bool setRenderTarget(ITexture *value) override;
void setClearColor(const Color &value) override;
// Since 1.3.0
bool setShaderProgram(IShaderProgram *value) override;
IPlatformFont *FontCreate( // If font is not found, may create default one
const String &fontname, // Filename with path(to font directory in your apk) and extension. If not found, default one will be created
const int height,
const FONT_WEIGHT weight, // Only fwNormal and fwBold are supported. Usually bold and normal(regular) versions of a font are located in different files
const bool italic, // Usually italiced font also have different fontname
const bool underline,
const bool strikeout,
const bool monospace) override;
ITexture *TextureCreate(const int width, const int height, const AnsiString &format) override;
ITexture *TextureCreate(const Bitmap &data) override;
// Since 1.3.0
IShaderProgram *ShaderProgramCreate(const AnsiString &vertex, const AnsiString &fragment, const bool utils) override;
IShaderProgram *ShaderProgramCreate(const AnsiString &fragment) override;
void Release() override;
bool DrawBegin(Rect &viewport) override;
bool DrawEnd() override;
bool Present() override;
IRenderer *CreateInstance() override;
bool PushMask(ITexture *mask, const Matrix &matrix) override;
void PopMask() override;
// Since 6.0.0
void RestoreState() override;
// Since 7.0.0
bool BeginSplineLimitation(const CUBIC_BEZIER_SPLINE &spline1, const CUBIC_BEZIER_SPLINE &spline2, const bool apply_to_y_direction) override;
bool EndSplineLimitation() override;
void Clear() override;
void Clear(const Color &color) override;
void Line(const PointF &p1, const PointF &p2, const Color &color, const BLOCK *block) override;
void Line(const PointF &p1, const PointF &p2, const Color &color, const Matrix &m, const BLOCK *block) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const BLOCK *block) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const Matrix &m, const BLOCK *block) override;
// Since 3.0.0
void Line(const PointF &p1, const PointF &p2, const Color &color, const BLOCK *block, const unsigned int bitmask) override;
void Line(const PointF &p1, const PointF &p2, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const BLOCK *block, const unsigned int bitmask) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const Matrix &m, const BLOCK *block, const unsigned int bitmask) override;
// Since 7.0.0
void Line(const PointF &p1, const PointF &p2, const Color &color, const BLOCK *block, ITexture *mask) override;
void Line(const PointF &p1, const PointF &p2, const Color &color, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const BLOCK *block, ITexture *mask) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Line(const PointF &p1, const PointF &p2, const Color &color, const BLOCK *block, const unsigned int bitmask, ITexture *mask) override;
void Line(const PointF &p1, const PointF &p2, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask, ITexture *mask) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const BLOCK *block, const unsigned int bitmask, ITexture *mask) override;
void Line(const PointF &p1, const PointF &p2, const Color &c1, const Color &c2, const Matrix &m, const BLOCK *block, const unsigned int bitmask, ITexture *mask) override;
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const BLOCK *block) override;
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const Matrix &m, const BLOCK *block) override;
// Since 3.0.0
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const BLOCK *block, const unsigned int bitmask) override;
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const Matrix &m, const BLOCK *block, const unsigned int bitmask) override;
// Since 7.0.0
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const BLOCK *block, ITexture *mask) override;
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const BLOCK *block, const unsigned int bitmask, ITexture *mask) override;
void Lines(const std::vector<PointF> &points, const Color &color, const bool loop, const Matrix &m, const BLOCK *block, const unsigned int bitmask, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const BLOCK *block) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const Matrix &m, const BLOCK *block) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const BLOCK *block) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const Matrix &m, const BLOCK *block) override;
// Since 3.0.0
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const Matrix &m, const BLOCK *block,
const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form) override;
// Since 7.0.0
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const BLOCK *block, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const BLOCK *block, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Triangle(const PointF &p1, const PointF &p2, const PointF &p3, const Color &c1, const Color &c2, const Color &c3, const Matrix &m, const BLOCK *block,
const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &color, const BLOCK *block) override;
void Rectangle(const RectF &rect, const Color &color, const Matrix &m, const BLOCK *block) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const BLOCK *block) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const Matrix &m, const BLOCK *block) override;
// Since 3.0.0
void Rectangle(const RectF &rect, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form) override;
void Rectangle(const RectF &rect, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form) override;
// Since 7.0.0
void Rectangle(const RectF &rect, const Color &color, const BLOCK *block, ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &color, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const BLOCK *block, ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Rectangle(const RectF &rect, const Color &c1, const Color &c2, const Color &c3, const Color &c4, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Gradient(const RectF &rect, nitisa::Gradient &g, const BLOCK *block) override;
void Gradient(const RectF &rect, nitisa::Gradient &g, const Matrix &m, const BLOCK *block) override;
// Since 3.0.0
void Gradient(const RectF &rect, nitisa::Gradient &g, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form) override;
void Gradient(const RectF &rect, nitisa::Gradient &g, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
// Since 7.0.0
void Gradient(const RectF &rect, nitisa::Gradient &g, const BLOCK *block, ITexture *mask) override;
void Gradient(const RectF &rect, nitisa::Gradient &g, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Gradient(const RectF &rect, nitisa::Gradient &g, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
void Gradient(const RectF &rect, nitisa::Gradient &g, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
void Image(ITexture *image, const PointF &p, const float transparency, const BLOCK *block) override;
void Image(ITexture *image, const Matrix &m, const float transparency, const BLOCK *block) override;
void Image(ITexture *image, const RectF &part, const PointF &p, const float transparency, const BLOCK *block) override;
void Image(ITexture *image, const RectF &part, const Matrix &m, const float transparency, const BLOCK *block) override;
// Since 3.0.0
void Image(ITexture *image, const PointF &p, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Image(ITexture *image, const Matrix &m, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Image(ITexture *image, const RectF &part, const PointF &p, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Image(ITexture *image, const RectF &part, const Matrix &m, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
// Since 7.0.0
void Image(ITexture *image, const PointF &p, const float transparency, const BLOCK *block, ITexture *mask) override;
void Image(ITexture *image, const Matrix &m, const float transparency, const BLOCK *block, ITexture *mask) override;
void Image(ITexture *image, const RectF &part, const PointF &p, const float transparency, const BLOCK *block, ITexture *mask) override;
void Image(ITexture *image, const RectF &part, const Matrix &m, const float transparency, const BLOCK *block, ITexture *mask) override;
void Image(ITexture *image, const PointF &p, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
void Image(ITexture *image, const Matrix &m, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
void Image(ITexture *image, const RectF &part, const PointF &p, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form, ITexture *mask) override;
void Image(ITexture *image, const RectF &part, const Matrix &m, const float transparency, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form, ITexture *mask) override;
void Block(const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors) override;
void Block(const RectF &rect, const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors) override;
// Since 3.0.0
void Block(const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Block(const RectF &rect, const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
// Since 7.0.0
void Block(const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors, ITexture *mask) override;
void Block(const RectF &rect, const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors, ITexture *mask) override;
void Block(const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form, ITexture *mask) override;
void Block(const RectF &rect, const RectF &block, const RectF &border, const RectF &radius, const BlockColors &colors, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form, ITexture *mask) override;
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const PointF &p, const BLOCK *block) override;
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const Matrix &m, const BLOCK *block) override;
// Since 3.0.0
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const PointF &p, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form) override;
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form) override;
// Since 7.0.0
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const PointF &p, const BLOCK *block, ITexture *mask) override;
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const Matrix &m, const BLOCK *block, ITexture *mask) override;
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const PointF &p, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Text(const String &text, IPlatformFont *font, const float distance, const Color &color, const Matrix &m, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Blur(ITexture *image, const int radius, const BLUR_TYPE type) override;
void Blur(ITexture *target, ITexture *source, const int radius, const BLUR_TYPE type) override;
// Since 3.0.0
void Blur(ITexture *image, const int radius, const BLUR_TYPE type, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form) override;
void Blur(ITexture *target, ITexture *source, const int radius, const BLUR_TYPE type, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
// Since 7.0.0
void Blur(ITexture *image, const int radius, const BLUR_TYPE type, ITexture *mask) override;
void Blur(ITexture *target, ITexture *source, const int radius, const BLUR_TYPE type, ITexture *mask) override;
void Blur(ITexture *image, const int radius, const BLUR_TYPE type, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
void Blur(ITexture *target, ITexture *source, const int radius, const BLUR_TYPE type, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
// Since 7.0.0
void Polygon(const std::vector<PointF> &points, const Color &color, const BLOCK *block) override;
void Polygon(const std::vector<PointF> &points, const Matrix &m, const Color &color, const BLOCK *block) override;
void Polygon(const std::vector<PointF> &points, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Polygon(const std::vector<PointF> &points, const Matrix &m, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Polygon(const std::vector<PointF> &points, const Color &color, const BLOCK *block, ITexture *mask) override;
void Polygon(const std::vector<PointF> &points, const Matrix &m, const Color &color, const BLOCK *block, ITexture *mask) override;
void Polygon(const std::vector<PointF> &points, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y, const bool bitmask_form,
ITexture *mask) override;
void Polygon(const std::vector<PointF> &points, const Matrix &m, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form, ITexture *mask) override;
// Since 7.0.0
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Color &color, const BLOCK *block) override;
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Matrix &m, const Color &color, const BLOCK *block) override;
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form) override;
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Matrix &m, const Color &color, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form) override;
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Color &color, const BLOCK *block, ITexture *mask) override;
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Matrix &m, const Color &color, const BLOCK *block, ITexture *mask) override;
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Color &color, const BLOCK *block, const unsigned int bitmask_x, const unsigned int bitmask_y,
const bool bitmask_form, ITexture *mask) override;
void Polygons(const std::vector<std::vector<PointF>> &polygons, const Matrix &m, const Color &color, const BLOCK *block, const unsigned int bitmask_x,
const unsigned int bitmask_y, const bool bitmask_form, ITexture *mask) override;
CRenderer();
virtual ~CRenderer();
};
There are couple of utility shader functions available. They allow to find out at which part of the block current pixel is.
int BlockPointLocation(vec2 p);
This function gets current pixel coordinates(which could be found in var_FormCoord variable if you created shader program using the second(with one argument, method) and returns integer indicating where point is. Possible results are: 0 - point is on left border, 1 - point is on top border, 2 - point is on right border, 3 - point is on bottom border, 4 - point is inside, 5 - point is outside. When you create complete custom shader(using the first method with 3 arguments) you should specifiy options described below to be able to use this function properly. Here they are.
vec4 app_BlockRect;
Block rectanglevec4 app_BlockBorder;
Block border widthsvec4 app_BlockRadius;
Block corner radiusesvec2 app_BlockInnerEllipse[4];
Precalculated value. You can find how to calculate in in renderer implementation source codevec2 app_BlockCornerCenter[4];
Precalculated value. You can find how to calculate in in renderer implementation source codevec2 app_BlockOuterRCenter[4];
Precalculated value. You can find how to calculate in in renderer implementation source codebvec4 app_BlockHasInner;
Whether inner corner is round or sharp. You can find how to calculate in in renderer implementation source code
vec4 BlockPointColor(vec2 p);
This function gets current pixel coordinates and return corresponding color depending on where the pixel is of the block. The same conditions are applied to this function as they are for previous one. Additionaly it requires one more option to be specified.
vec4 app_BlockColors[6];
Colors for block parts
All this options are automatically added to your shader program if you created the program using method with one argument. If you would like to add this utilities to your extended shader program created by extended IRenderer::ShaderProgramCreate method, you have to set the last utils
argument to true and also specify {utils} placeholder in your shader program text where the utilities should be injected.
When you create shader program using second creation method the source code should have this function
vec4 CalculateColor(vec2 tex_coord, vec2 form_coord, vec4 color);
It will be supplied with pixel texture coordinates, pixel form/render target coordinates, and interpolated color. The function should return final premultiplied color(red, green, and blue components should be multiplied by alpha; if you get color from texture, do not premultiply it because all textures have already premultiplied pixels). Also block and mask will be applied as well. Additionally in this case following option name should not be used: app_BlockPointLocation, app_Mask, app_MaskSize, app_FormToGL, app_Primitive, app_MaskInv.
The minimum shader language version should be #version 310 es
.
This renderer uses following texture indices when performing drawing operations. Either avoid using them when activating textures for your custom shader programs or consider they may be changed during drawing operations described below.
The renderer does not provide any checking of arguments validity. A caller is responsible for such a checking. If you use invalid argument in most cases nothing will be drawn. But in some case you may get fatal error. For example if you use nullptr
instead of texture.
Namespace: | nitisa::standard::android::gles |
Include: | Standard/Platform/Android/OpenGL/Renderer.h |