Vuo  1.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Macros | Typedefs | Functions | Variables
VuoShader.cc File Reference

Description

VuoShader implementation.

Macros

#define DEFINE_PROGRAM()
 Defines a program variable and initializes it with the relevant program based on inputPrimitiveMode.
 

Typedefs

typedef std::map< VuoGlContext,
GLuint > 
VuoShaderContextType
 Type for VuoShaderContextMap.
 

Functions

void VuoShader_free (void *shader)
 Frees the CPU memory and GPU objects associated with the shader.
 
VuoShader VuoShader_make (const char *name)
 Creates a shader object, which contains multiple GL Program Objects.
 
VuoShader VuoShader_make_VuoColor (VuoColor color)
 Creates an unlit color shader object.
 
VuoShader VuoShader_make_VuoShader (VuoShader shader)
 Returns the passed shader (does not make a copy).
 
VuoShader VuoShader_make_VuoImage (VuoImage image)
 Creates an unlit image shader.
 
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.
 
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.
 
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.
 
unsigned int VuoShader_getExpectedOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode)
 Returns the number of primitives the geometry shader is expected to produce per invocation.
 
bool VuoShader_getMayChangeOutputPrimitiveCount (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode)
 Returns true if the geometry shader may not output the expected primitive count.
 
bool VuoShader_isTransformFeedback (VuoShader shader)
 Returns true if each of shader's defined inputPrimitiveModes has a vertex shader (and optionally a geometry shader) but lacks a fragment shader.
 
static bool VuoShader_ensureUploaded (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext)
 Ensures that the source code for the specified inputPrimitiveMode is compiled, linked, and uploaded.
 
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()).
 
void VuoShader_initPerlinTexture (CGLContextObj cgl_ctx)
 Create and load a 2D texture for a combined index permutation and gradient lookup table.
 
void VuoShader_initGradTexture (CGLContextObj cgl_ctx)
 Create and load a 2D texture for a 4D gradient lookup table.
 
static void __attribute__ ((constructor)) VuoShaderContext_init(void)
 Initializes VuoShaderContext_semaphore.
 
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.
 
void VuoShader_deactivate (VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext)
 Deactivates the shader program on the specified glContext, and unbinds the shader's images from their texture units.
 
void VuoShader_cleanupContext (VuoGlContext glContext)
 Returns the context's shader state to normal (and clears VuoShader's internal cache).
 
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.
 
json_objectVuoShader_getJson (const VuoShader value)
 Encodes value as a JSON object.
 
json_objectVuoShader_getInterprocessJson (const VuoShader value)
 Calls VuoShader_getJson().
 
char * VuoShader_getSummary (const VuoShader value)
 Returns a summary of the shader: the text description provided to VuoShader_make.
 
VuoPoint2d VuoShader_samplerCoordinatesFromVuoCoordinates (VuoPoint2d vuoCoordinates, VuoImage image)
 Converts the provided vuoCoordinates into GLSL Sampler Coordinates relative to the provided image.
 
VuoReal VuoShader_samplerSizeFromVuoSize (VuoReal vuoSize)
 Converts an x-axis distance in Vuo Coordinates into GLSL Sampler Coordinates.
 

Variables

static GLuint VuoShader_perlinTexture
 GL texture name for the Perlin permutation table.
 
static GLuint VuoShader_gradTexture
 GL texture name for the Simplex permutation table.
 
static VuoShaderContextType VuoShaderContextMap
 The currently-active shader on each context.
 
static dispatch_semaphore_t VuoShaderContext_semaphore
 Serializes access to VuoShaderContextMap.
 

Macro Definition Documentation

#define DEFINE_PROGRAM ( )
Value:
VuoSubshader *program; \
program = &shader->triangleProgram; \
else if (epm == VuoMesh_IndividualLines) \
program = &shader->lineProgram; \
else /* if (inputPrimitiveMode == VuoMesh_Points) */ \
program = &shader->pointProgram;

Defines a program variable and initializes it with the relevant program based on inputPrimitiveMode.

Typedef Documentation

typedef std::map<VuoGlContext, GLuint> VuoShaderContextType

Type for VuoShaderContextMap.

Function Documentation

static void __attribute__ ( (constructor)  )
static

Initializes VuoShaderContext_semaphore.

static bool VuoShader_ensureUploaded ( VuoShader  shader,
const VuoMesh_ElementAssemblyMethod  inputPrimitiveMode,
VuoGlContext  glContext 
)
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.

void VuoShader_free ( void *  shader)

Frees the CPU memory and GPU objects associated with the shader.

This function may be called from any thread.

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.nosp@m.@itn.nosp@m..liu..nosp@m.se) 2004, 2005, 2011 ("The C code in "noisevsnoise.c" is public domain.")

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.nosp@m.@itn.nosp@m..liu..nosp@m.se) 2004, 2005, 2011 ("The C code in "noisevsnoise.c" is public domain.")

Variable Documentation

GLuint VuoShader_gradTexture
static

GL texture name for the Simplex permutation table.

GLuint VuoShader_perlinTexture
static

GL texture name for the Perlin permutation table.

dispatch_semaphore_t VuoShaderContext_semaphore
static

Serializes access to VuoShaderContextMap.

VuoShaderContextType VuoShaderContextMap
static

The currently-active shader on each context.