LightsprintSDK 2021.08.08
|
#include <Program.h>
Public Member Functions | |
~Program () | |
bool | isValid () |
void | useIt () |
unsigned | sendTexture (const char *name, const class Texture *t, int code=-1) |
void | unsendTexture (int code) |
void | sendUniform (const char *name, float x) |
void | sendUniform (const char *name, float x, float y) |
void | sendUniform (const char *name, const rr::RRVec3 &xyz) |
void | sendUniform (const char *name, const rr::RRVec4 &xyzw) |
void | sendUniform (const char *name, int x) |
void | sendUniform (const char *name, int x, int y) |
void | sendUniform (const char *name, const float *m, bool transp=false, int size=4) |
void | sendUniformArray (const char *name, int count, const GLint *x) |
void | sendUniformArray (const char *name, int count, const GLfloat *x) |
void | sendUniformArray (const char *name, int count, const rr::RRVec2 *x) |
void | sendUniformArray (const char *name, int count, const rr::RRVec3 *x) |
void | sendUniformArray (const char *name, int count, const rr::RRVec4 *x) |
bool | uniformExists (const char *uniformName) |
Public Member Functions inherited from rr::RRUniformlyAllocated | |
void * | operator new (std::size_t n) |
void * | operator new[] (std::size_t n) |
void | operator delete (void *p, std::size_t n) |
void | operator delete[] (void *p, std::size_t n) |
Static Public Member Functions | |
static Program * | create (const char *defines, const rr::RRString &vertexShader, const rr::RRString &fragmentShader) |
static void | logMessages (bool enable) |
Additional Inherited Members | |
Protected Member Functions inherited from rr::RRUniformlyAllocatedNonCopyable | |
RRUniformlyAllocatedNonCopyable () | |
~RRUniformlyAllocatedNonCopyable () | |
GLSL program.
GLSL is language used by OpenGL API for writing shaders. Program is one or more shaders linked together, see OpenGL for more details.
rr_gl::Program::~Program | ( | ) |
|
static |
Creates GLSL program by linking one vertex and one fragment shader together. Shaders are created by concatenating string defines and contents of file vertexShader / fragmentShader.
defines | String inserted before compilation at the beginning of shader source code. May be nullptr. |
vertexShader | Name of text file with GLSL vertex shader. May be empty for fixed pipeline. |
fragmentShader | Name of text file with GLSL fragment shader. May be empty for fixed pipeline. |
bool rr_gl::Program::isValid | ( | ) |
Validates program and returns true only when it was successful, see OpenGL for more details on validation. Validation is optional process used mainly for debugging.
void rr_gl::Program::useIt | ( | ) |
Sets rendering pipeline so that program will be used for following primitives rendered. Program must be linked before use.
unsigned rr_gl::Program::sendTexture | ( | const char * | name, |
const class Texture * | t, | ||
int | code = -1 |
||
) |
Sets uniform texture (activates texture unit, binds texture), returns texture unit used.
First call after useIt() uses texture unit 0, next one uses unit 1 etc. If code in range 0..15 is entered, all textures with the same code are sent to the same unit.
Following fragments of code do the same
When doing multiple renders that differ only in textures, use codes
void rr_gl::Program::unsendTexture | ( | int | code | ) |
Unbinds texture previously sent via sendTexture(,,code);.
void rr_gl::Program::sendUniform | ( | const char * | name, |
float | x | ||
) |
Sets uniform of type float.
void rr_gl::Program::sendUniform | ( | const char * | name, |
float | x, | ||
float | y | ||
) |
Sets uniform of type vec2.
void rr_gl::Program::sendUniform | ( | const char * | name, |
const rr::RRVec3 & | xyz | ||
) |
Sets uniform of type vec3.
void rr_gl::Program::sendUniform | ( | const char * | name, |
const rr::RRVec4 & | xyzw | ||
) |
Sets uniform of type vec4.
void rr_gl::Program::sendUniform | ( | const char * | name, |
int | x | ||
) |
Sets uniform of type int or sampler2D or samplerCube or sampler2DShadow.
void rr_gl::Program::sendUniform | ( | const char * | name, |
int | x, | ||
int | y | ||
) |
Sets uniform of type int2.
void rr_gl::Program::sendUniform | ( | const char * | name, |
const float * | m, | ||
bool | transp = false , |
||
int | size = 4 |
||
) |
Sets uniform of type mat2, mat3 or mat4.
void rr_gl::Program::sendUniformArray | ( | const char * | name, |
int | count, | ||
const GLint * | x | ||
) |
Sets array of uniforms of type int or sampler2D or samplerCube or sampler2DShadow.
void rr_gl::Program::sendUniformArray | ( | const char * | name, |
int | count, | ||
const GLfloat * | x | ||
) |
void rr_gl::Program::sendUniformArray | ( | const char * | name, |
int | count, | ||
const rr::RRVec2 * | x | ||
) |
void rr_gl::Program::sendUniformArray | ( | const char * | name, |
int | count, | ||
const rr::RRVec3 * | x | ||
) |
void rr_gl::Program::sendUniformArray | ( | const char * | name, |
int | count, | ||
const rr::RRVec4 * | x | ||
) |
bool rr_gl::Program::uniformExists | ( | const char * | uniformName | ) |
Does uniform exist in program?
|
static |
Print OpenGL log to console. False by default. Set true for debugging.