VuoShader implementation.
Definition in file VuoShader.cc.
Go to the source code of this file.
Macros | |
#define | DEFINE_PROGRAM() |
Defines a program variable and initializes it with the relevant program based on inputPrimitiveMode . More... | |
Typedefs | |
typedef std::map< VuoGlContext, GLuint > | VuoShaderContextType |
Type for VuoShaderContextMap. More... | |
Functions | |
void | VuoShader_free (void *shader) |
Frees the CPU memory and GPU objects associated with the shader. More... | |
VuoShader | VuoShader_make (const char *name) |
Creates a shader object, which contains multiple GL Program Objects. More... | |
VuoShader | VuoShader_makeFromFile (VuoShaderFile *shaderFile) |
Creates a shader object from a VuoShaderFile. More... | |
VuoShader | VuoShader_make_VuoColor (VuoColor color) |
Creates an unlit color shader object. More... | |
VuoShader | VuoShader_make_VuoShader (VuoShader shader) |
Returns the passed shader (does not make a copy). More... | |
VuoShader | VuoShader_make_VuoImage (VuoImage image) |
Creates an unlit image shader. More... | |
void | VuoShader_addSource (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const char *vertexShaderSource, const char *geometryShaderSource, const char *fragmentShaderSource) |
Associates GLSL shader source code with the specified inputPrimitiveMode of the specified shader . More... | |
void | VuoShader_setExpectedOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const unsigned int expectedOutputPrimitiveCount) |
Specifies the number of primitives the geometry shader is expected to produce per invocation. More... | |
void | VuoShader_setMayChangeOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const bool mayChangeOutputPrimitiveCount) |
Specifies whether the geometry shader may dynamically choose to skip outputting some primitives or output additional primitives. More... | |
void | VuoShader_setTransparent (VuoShader shader, const bool isTransparent) |
See VuoShader::isTransparent. More... | |
unsigned int | VuoShader_getExpectedOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode) |
Returns the number of primitives the geometry shader is expected to produce per invocation. More... | |
bool | VuoShader_getMayChangeOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode) |
Returns true if the geometry shader may not output the expected primitive count. More... | |
bool | VuoShader_isTransformFeedback (VuoShader shader) |
Returns true if each of shader 's defined inputPrimitiveMode s has a vertex shader (and optionally a geometry shader) but lacks a fragment shader. More... | |
static void | VuoShader_replaceImageMacro (VuoShader shader, string &source, map< string, GLint > &imagesToDeclare, string beforeFunction, bool isThis, string afterFunction2D, string afterFunctionRect, VuoShaderFile::Stage stage, VuoShaderIssues *outIssues) |
Converts gl_FragColor = beforeFunction(inputImage, isf_FragNormCoord.xy); to gl_FragColor = afterFunction2D(inputImage, _inputImage_imgRect, _inputImage_imgSize, _inputImage_flip, isf_FragNormCoord.xy); or afterFunctionRect , depending on the sampler type. More... | |
static void | VuoShader_replaceSizeMacro (VuoShader shader, string &source, string before, string after) |
Replaces IMG_SIZE(someImage) with _someImage_imgSize . More... | |
static void | VuoShader_replaceImageMacros (VuoShader shader, string &source, VuoShaderFile::Stage stage, VuoShaderIssues *outIssues) |
Replaces the IMG_PIXEL and IMG_NORM_PIXEL macros with the appropriate function call depending on the image's OpenGL target, and fill in the placeholder image declarations. More... | |
static bool | VuoShader_ensureUploaded (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, VuoShaderIssues *outIssues) |
Ensures that the source code for the specified inputPrimitiveMode is compiled, linked, and uploaded. More... | |
bool | VuoShader_upload (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, void *outIssues) |
Compiles and uploads the shader, outputting any issues in a VuoShaderIssues instance. More... | |
bool | VuoShader_getAttributeLocations (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, int *positionLocation, int *normalLocation, int *tangentLocation, int *bitangentLocation, int *textureCoordinateLocation) |
Outputs the shader program's vertex attribute locations (the same values as glGetAttribLocation() ). More... | |
void | VuoShader_initPerlinTexture (CGLContextObj cgl_ctx) |
Create and load a 2D texture for a combined index permutation and gradient lookup table. More... | |
void | VuoShader_initGradTexture (CGLContextObj cgl_ctx) |
Create and load a 2D texture for a 4D gradient lookup table. More... | |
static void | __attribute__ ((constructor)) VuoShaderContext_init(void) |
Initializes VuoShaderContext_semaphore. More... | |
bool | VuoShader_activate (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, VuoGlProgram *outputProgram) |
Activates the shader program (glUseProgram() ) on the specified glContext , binds the shader's images to texture units, and uploads its unforms, so that the shader is ready for use in rendering. More... | |
void | VuoShader_deactivate (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext) |
Unbinds the shader's images from their texture units. More... | |
void | VuoShader_resetContext (VuoGlContext glContext) |
Disuses whatever shader (if any) is currently active on glContext . More... | |
VuoShader | VuoShader_makeFromJson (json_object *js) |
Decodes the JSON object js , expected to contain a 64-bit integer (memory address or 0), to create a new VuoShader . More... | |
json_object * | VuoShader_getJson (const VuoShader value) |
Encodes value as a JSON object. More... | |
json_object * | VuoShader_getInterprocessJson (const VuoShader value) |
Calls VuoShader_getJson(). More... | |
char * | VuoShader_getSummary (const VuoShader value) |
Returns a summary of the shader: the text description provided to VuoShader_make. More... | |
VuoPoint2d | VuoShader_samplerCoordinatesFromVuoCoordinates (VuoPoint2d vuoCoordinates, VuoImage image) |
Converts the provided vuoCoordinates into GLSL Sampler Coordinates relative to the provided image . More... | |
VuoReal | VuoShader_samplerSizeFromVuoSize (VuoReal vuoSize) |
Converts an x-axis distance in Vuo Coordinates into GLSL Sampler Coordinates. More... | |
VuoPoint2d | VuoShader_samplerRectCoordinatesFromNormalizedCoordinates (VuoPoint2d c, VuoInteger imageWidth, VuoInteger imageHeight) |
Converts the provided normalizedCoordinates into GLSL sampler2DRect coordinates relative to the provided width/height. More... | |
bool | VuoShader_isOpaque (VuoShader shader) |
Returns true if the shader, as configured, will produce fully opaque output. More... | |
Variables | |
static GLuint | VuoShader_perlinTexture |
GL texture name for the Perlin permutation table. More... | |
static GLuint | VuoShader_gradTexture |
GL texture name for the Simplex permutation table. More... | |
VuoShaderContextType | VuoShaderContextMap |
The currently-active shader on each context. More... | |
static dispatch_semaphore_t | VuoShaderContext_semaphore |
Serializes access to VuoShaderContextMap. More... | |
#define DEFINE_PROGRAM | ( | ) |
Defines a program
variable and initializes it with the relevant program based on inputPrimitiveMode
.
Definition at line 213 of file VuoShader.cc.
typedef std::map<VuoGlContext, GLuint> VuoShaderContextType |
Type for VuoShaderContextMap.
Definition at line 891 of file VuoShader.cc.
|
static |
Initializes VuoShaderContext_semaphore.
Definition at line 897 of file VuoShader.cc.
|
static |
Ensures that the source code for the specified inputPrimitiveMode
is compiled, linked, and uploaded.
If the shader is NULL, or there is no source code for the specified inputPrimitiveMode
, or it fails to compile or link, returns false
.
Must be called while shader->lock
is locked.
Definition at line 632 of file VuoShader.cc.
void VuoShader_free | ( | void * | shader | ) |
Frees the CPU memory and GPU objects associated with the shader.
This function may be called from any thread.
Definition at line 72 of file VuoShader.cc.
void VuoShader_initGradTexture | ( | CGLContextObj | cgl_ctx | ) |
Create and load a 2D texture for a 4D gradient lookup table.
This is used for 4D noise only.
Author: Stefan Gustavson (stegu) 2004, 2005, 2011 ("The C code in "noisevsnoise.c" is public domain.") @itn .liu. se
Definition at line 840 of file VuoShader.cc.
void VuoShader_initPerlinTexture | ( | CGLContextObj | cgl_ctx | ) |
Create and load a 2D texture for a combined index permutation and gradient lookup table.
This texture is used for 2D and 3D noise, both classic and simplex.
Author: Stefan Gustavson (stegu) 2004, 2005, 2011 ("The C code in "noisevsnoise.c" is public domain.") @itn .liu. se
Definition at line 786 of file VuoShader.cc.
|
static |
Converts gl_FragColor = beforeFunction(inputImage, isf_FragNormCoord.xy);
to gl_FragColor = afterFunction2D(inputImage, _inputImage_imgRect, _inputImage_imgSize, _inputImage_flip, isf_FragNormCoord.xy);
or afterFunctionRect
, depending on the sampler type.
If isThis
is true, the function is expected to have 1 argument (the texture coordinate is implicit).
Definition at line 507 of file VuoShader.cc.
|
static |
Replaces the IMG_PIXEL
and IMG_NORM_PIXEL
macros with the appropriate function call depending on the image's OpenGL target, and fill in the placeholder image declarations.
Definition at line 590 of file VuoShader.cc.
|
static |
Replaces IMG_SIZE(someImage)
with _someImage_imgSize
.
Definition at line 569 of file VuoShader.cc.
|
static |
GL texture name for the Simplex permutation table.
Definition at line 833 of file VuoShader.cc.
|
static |
GL texture name for the Perlin permutation table.
Definition at line 778 of file VuoShader.cc.
|
static |
Serializes access to VuoShaderContextMap.
Definition at line 893 of file VuoShader.cc.
VuoShaderContextType VuoShaderContextMap |
The currently-active shader on each context.
This is placed in VuoGlContext (a dylib) instead of VuoShader (a static module) to ensure there's only one instance per process.
Definition at line 838 of file VuoGlContext.cc.