Vuo  0.5.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Macros | Typedefs | Functions

Description

A graphics shader program, specifying how to render a 3D object.

Classes

struct  _VuoShader
 A graphics shader program, specifying how to render a 3D object. More...
 

Macros

#define VUOSHADER_GLSL_SOURCE(version, source)   "#version " #version "\n" #source
 A macro to facilitate defining a GLSL shader in a C source file.
 

Typedefs

typedef struct _VuoShaderVuoShader
 A graphics shader program, specifying how to render a 3D object.
 

Functions

void VuoShader_free (void *shader)
 Decrements the retain count of the OpenGL Texture Object associated with the specified VuoImage, and frees the texture VuoImage struct.
 
void VuoShader_printShaderInfoLog (GLuint obj)
 Prints GLSL debug information to the console.
 
void VuoShader_printProgramInfoLog (GLuint obj)
 Prints GLSL debug information to the console.
 
VuoShader VuoShader_make (const char *summary, const char *vertexShaderSource, const char *fragmentShaderSource)
 Compiles, links, and uploads the specified shader sources.
 
VuoShader VuoShader_valueFromJson (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_object * VuoShader_jsonFromValue (const VuoShader value)
 Encodes value as a JSON object.
 
char * VuoShader_summaryFromValue (const VuoShader value)
 Returns a summary of the shader: the text description provided to VuoShader_make(), and the number of textures associated with the shader.
 
void VuoShader_setUniformFloat (VuoShader shader, const char *uniformIdentifier, float value)
 Sets a float uniform value on the specified shader.
 
void VuoShader_setUniformPoint2d (VuoShader shader, const char *uniformIdentifier, VuoPoint2d value)
 Sets a float uniform value on the specified shader.
 
const char * VuoShader_getDefaultVertexShader (void)
 Returns the default vertex shader, which projects verties and passes through texture coordinates.
 
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.
 
VuoShader VuoShader_makeImageShader (void)
 Returns a shader that renders objects with an image (ignoring lighting), specified by uniform texture.
 
void VuoShader_resetTextures (VuoShader shader)
 Empties the list of textures associated with shader.
 
void VuoShader_addTexture (VuoShader shader, VuoImage texture, const char *uniformIdentifier)
 Adds to shader an association between texture and uniformIdentifier.
 
void VuoShader_activateTextures (VuoShader shader)
 Assigns each of the shader's textures to a texture unit, and passes the texture unit number along to the shader.
 
void VuoShader_deactivateTextures (VuoShader shader)
 Unbinds the texture units used by this shader.
 
VuoShader VuoShader_valueFromString (const char *str)
 Automatically generated function.
 
char * VuoShader_stringFromValue (const VuoShader value)
 Automatically generated function.
 

Class Documentation

struct _VuoShader
Class Members
unsigned int glFragmentShaderName
unsigned int glProgramName
VuoList_VuoInteger glTextureUniformLocations
unsigned int glVertexShaderName
char * summary Text describing the shader, displayed in port popovers.
VuoList_VuoImage textures

Macro Definition Documentation

#define VUOSHADER_GLSL_SOURCE (   version,
  source 
)    "#version " #version "\n" #source

A macro to facilitate defining a GLSL shader in a C source file.

Typedef Documentation

typedef struct _VuoShader * VuoShader

A graphics shader program, specifying how to render a 3D object.

The struct is typedef'd to a pointer so that VuoShaders are reference-counted, enabling us to automatically delete the GL Program Objects when the last reference is released.

Function Documentation

void VuoShader_activateTextures ( VuoShader  shader)

Assigns each of the shader's textures to a texture unit, and passes the texture unit number along to the shader.

Must be called from a thread with an active GL Context.

void VuoShader_addTexture ( VuoShader  shader,
VuoImage  texture,
const char *  uniformIdentifier 
)

Adds to shader an association between texture and uniformIdentifier.

May be called from any thread (doesn't require an existing GL Context).

void VuoShader_deactivateTextures ( VuoShader  shader)

Unbinds the texture units used by this shader.

Must be called from a thread with an active GL Context.

void VuoShader_free ( void *  shader)

Decrements the retain count of the OpenGL Texture Object associated with the specified VuoImage, and frees the texture VuoImage struct.

Todo:
After we drop 10.6 support, switch back to gl3.h.

May be called from any thread (doesn't require an existing GL Context).

const char* VuoShader_getDefaultVertexShader ( void  )

Returns the default vertex shader, which projects verties and passes through texture coordinates.

struct json_object * VuoShader_jsonFromValue ( const VuoShader  value)
read

Encodes value as a JSON object.

Serializes the pointer to the VuoShader object, since we need to preserve its reference count.

VuoShader VuoShader_make ( const char *  summary,
const char *  vertexShaderSource,
const char *  fragmentShaderSource 
)

Compiles, links, and uploads the specified shader sources.

The vertex shader must define:

uniform mat4 projectionMatrix;
uniform mat4 modelviewMatrix;
attribute vec4 position;
attribute vec4 normal;
attribute vec4 tangent;
attribute vec4 bitangent;
attribute vec4 textureCoordinate;

May be called from any thread (doesn't require an existing GL Context).

VuoShader VuoShader_makeImageShader ( void  )

Returns a shader that renders objects with an image (ignoring lighting), specified by uniform texture.

void VuoShader_printProgramInfoLog ( GLuint  obj)

Prints GLSL debug information to the console.

Must be called from a thread with an active GL Context.

void VuoShader_printShaderInfoLog ( GLuint  obj)

Prints GLSL debug information to the console.

Must be called from a thread with an active GL Context.

void VuoShader_resetTextures ( VuoShader  shader)

Empties the list of textures associated with shader.

VuoPoint2d VuoShader_samplerCoordinatesFromVuoCoordinates ( VuoPoint2d  vuoCoordinates,
VuoImage  image 
)

Converts the provided vuoCoordinates into GLSL Sampler Coordinates relative to the provided image.

Vuo Coordinates range from (-1,-1/aspectRatio) in the bottom left to (1,1/aspectRatio) in the top right.

GLSL Sampler Coordinates range from (0,0) to (1,1).

If image is rendered in a scene, centered at (0,0,0), width 2, at its correct aspect ratio, this function will transform 2D coordinates along the XY plane (at Z=0) into correct sampler coordinates for that image.

VuoReal VuoShader_samplerSizeFromVuoSize ( VuoReal  vuoSize)

Converts an x-axis distance in Vuo Coordinates into GLSL Sampler Coordinates.

(Divides by 2.)

void VuoShader_setUniformFloat ( VuoShader  shader,
const char *  uniformIdentifier,
float  value 
)

Sets a float uniform value on the specified shader.

May be called from any thread (automatically uses and disuses a GL Context).

void VuoShader_setUniformPoint2d ( VuoShader  shader,
const char *  uniformIdentifier,
VuoPoint2d  value 
)

Sets a float uniform value on the specified shader.

May be called from any thread (automatically uses and disuses a GL Context).

char* VuoShader_stringFromValue ( const VuoShader  value)

Automatically generated function.

char * VuoShader_summaryFromValue ( const VuoShader  value)

Returns a summary of the shader: the text description provided to VuoShader_make(), and the number of textures associated with the shader.

VuoShader VuoShader_valueFromJson ( json_object *  js)

Decodes the JSON object js, expected to contain a 64-bit integer (memory address or 0), to create a new VuoShader.

VuoShader VuoShader_valueFromString ( const char *  str)

Automatically generated function.