|
LightsprintSDK 2021.08.08
|
#include <TextureRenderer.h>
Public Member Functions | |
| TextureRenderer (const rr::RRString &pathToShaders) | |
| ~TextureRenderer () | |
| bool | renderEnvironment (const rr::RRCamera &camera, const Texture *texture0, float angleRad0, const Texture *texture1, float angleRad1, float blendFactor, const rr::RRVec4 *brightness, float gamma, bool allowDepthTest) |
| void | render2D (const Texture *texture, const ToneParameters *tp, float x, float y, float w, float h, float z=-1, const char *extraDefines=nullptr, float fisheyeFovDeg=180) |
| Program * | render2dBegin (const ToneParameters *tp, const char *extraDefines=nullptr, float fisheyeFovDeg=180) |
| void | render2dQuad (const Texture *texture, float x, float y, float w, float h, float z=-1) |
| void | render2dEnd () |
Static Public Member Functions | |
| static void | renderQuad (const float *positions=nullptr) |
Public Attributes | |
| UberProgram * | skyProgram |
| UberProgram * | twodProgram |
Helper for render of 2D or cube (skybox) texture.
It handles resource (shader) allocation/freeing. Needs sky.vs/fs and texture.vs/fs shaders on disk.
| rr_gl::TextureRenderer::TextureRenderer | ( | const rr::RRString & | pathToShaders | ) |
Initializes renderer, loading shaders from disk.
| pathToShaders | Path to directory with shaders. Must be terminated with slash (or be empty for current dir). |
| rr_gl::TextureRenderer::~TextureRenderer | ( | ) |
Shutdowns renderer, freeing shaders.
| bool rr_gl::TextureRenderer::renderEnvironment | ( | const rr::RRCamera & | camera, |
| const Texture * | texture0, | ||
| float | angleRad0, | ||
| const Texture * | texture1, | ||
| float | angleRad1, | ||
| float | blendFactor, | ||
| const rr::RRVec4 * | brightness, | ||
| float | gamma, | ||
| bool | allowDepthTest | ||
| ) |
Renders cubemap, equirectangular 2d texture or blend of two such maps as if camera is in center.
Use blendFactor=0 to render only texture0, texture1 then may be nullptr. For non-nullptr color, texture color is multiplied by color. Color is finally gamma corrected by gamma, 1 = no correction. Angles rotate environments around top/down axis.
| void rr_gl::TextureRenderer::render2D | ( | const Texture * | texture, |
| const ToneParameters * | tp, | ||
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | z = -1, |
||
| const char * | extraDefines = nullptr, |
||
| float | fisheyeFovDeg = 180 |
||
| ) |
Renders 2d texture into rectangle, using current blending/alpha testing/depth testing/masking etc modes.
render2D() internally calls render2dBegin() + render2dQuad() + render2dEnd(). For rendering N textures, it's possible to simply call render2D() N times, but render2dBegin() + N*render2dQuad() + render2dEnd() is slightly faster.
| texture | Texture (2d or cube) to be rendered. Cube textures are rendered in equirectangular projection. It is legal to pass nullptr texture as long as you glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,id); ahead of rendering. |
| tp | For non-nullptr tp, output is tonemapped using given parameters. |
| x | Position of texture's left side in viewport, 0=leftmost, 1=rightmost. |
| y | Position of texture's bottom side in viewport, 0=bottom, 1=top. |
| w | x+w is position of texture's right side in viewport, 0=leftmost, 1=rightmost. Negative w is supported. |
| h | y+h is position of texture's top side in viewport, 0=bottom, 1=top. Negative h is supported. |
| z | Depth in 0..1 range to be assigned to all rendered fragments. Additional effect of z in render2D() (not in render2dQuad()) is: "if (z<0) temporarily disable GL_DEPTH_TEST" |
| extraDefines | Usually nullptr, may be additional glsl code inserted at the beginning of shader, to enable special rendering paths. |
| fisheyeFovDeg | For internal use. |
| Program * rr_gl::TextureRenderer::render2dBegin | ( | const ToneParameters * | tp, |
| const char * | extraDefines = nullptr, |
||
| float | fisheyeFovDeg = 180 |
||
| ) |
Component of render2D(), initializes pipeline.
| void rr_gl::TextureRenderer::render2dQuad | ( | const Texture * | texture, |
| float | x, | ||
| float | y, | ||
| float | w, | ||
| float | h, | ||
| float | z = -1 |
||
| ) |
Component of render2D(), renders textured quad. May be called multiple times between render2dBegin() and render2dEnd().
| void rr_gl::TextureRenderer::render2dEnd | ( | ) |
Component of render2D(), restores pipeline.
|
static |
Helper, renders quad, identical to glBegin();4x glVertex();glEnd(); with coordinates from -1,-1 to 1,1. Optional parameter lets you provide your own coordinates.
| UberProgram* rr_gl::TextureRenderer::skyProgram |
sky.* uberprogram, only for reading, feel free to render with it directly.
| UberProgram* rr_gl::TextureRenderer::twodProgram |
texture.* uberprogram, only for reading, feel free to render with it directly.