Vuo  1.2.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Macros | Typedefs | Enumerations | Functions
VuoGlPool.h File Reference

Description

VuoGlPool interface.

Classes

struct  VuoGlProgram
 Information about a pooled GL Program Object. More...
 

Macros

#define VuoGlPool_retain(glBufferName)   VuoGlPool_retainF(glBufferName, __FILE__, __LINE__, __func__);
 Increments the reference count for glBufferName.
 
#define VuoGlPool_release(type, size, glBufferName)   VuoGlPool_releaseF(type, size, glBufferName, __FILE__, __LINE__, __func__);
 Decrements the reference count for glBufferName.
 

Typedefs

typedef void * VuoIoSurface
 A Mac OS X IOSurface.
 

Enumerations

enum  VuoGlPoolType { VuoGlPool_ArrayBuffer, VuoGlPool_ElementArrayBuffer }
 Types of OpenGL objects supported by Vuo's GL object pool. More...
 

Functions

GLuint VuoGlPool_use (VuoGlPoolType type, unsigned long size)
 Returns an OpenGL Buffer Object of type type.
 
void VuoGlPool_retainF (GLuint glBufferName, const char *file, unsigned int line, const char *func)
 Helper for VuoGlPool_retain.
 
void VuoGlPool_releaseF (VuoGlPoolType type, unsigned long size, GLuint glBufferName, const char *file, unsigned int line, const char *func)
 Helper for VuoGlPool_release.
 
GLuint VuoGlTexturePool_use (VuoGlContext glContext, GLenum internalformat, unsigned short width, unsigned short height, GLenum format)
 Returns an OpenGL texture.
 
GLuint VuoGlTexture_getType (GLuint format)
 Returns the OpenGL texture data type corresponding with OpenGL texture format.
 
unsigned char VuoGlTexture_getChannelCount (GLuint format)
 Returns the number of color+alpha channels in the specified OpenGL texture format.
 
unsigned char VuoGlTexture_getBytesPerPixel (GLuint internalformat, GLuint format)
 Returns the number of bytes required to store each pixel of the specified OpenGL texture format.
 
unsigned long VuoGlTexture_getMaximumTextureBytes (VuoGlContext glContext)
 Returns the maximum number of bytes in Video RAM that a texture can occupy.
 
void VuoGlTexture_retain (GLuint glTextureName, VuoImage_freeCallback freeCallback, void *freeCallbackContext)
 Increments the reference count for glTextureName.
 
void VuoGlTexture_release (GLenum internalformat, unsigned short width, unsigned short height, GLuint glTextureName, GLuint glTextureTarget)
 Decrements the reference count for glTextureName.
 
void VuoGlTexture_disown (GLuint glTextureName)
 Removes glTextureName from Vuo's reference count table (without deleting it like VuoGlTexture_release does).
 
VuoIoSurface VuoIoSurfacePool_use (VuoGlContext glContext, unsigned short pixelsWide, unsigned short pixelsHigh, GLuint *outputTexture)
 Returns an IOSurface (backed by outputTexture) with the specified dimensions.
 
uint32_t VuoIoSurfacePool_getId (VuoIoSurface ioSurface)
 Returns the IOSurface's interprocess ID.
 
void VuoIoSurfacePool_disuse (VuoGlContext glContext, unsigned short pixelsWide, unsigned short pixelsHigh, VuoIoSurface ioSurface, GLuint texture)
 Called by the sending end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture.
 
void VuoIoSurfacePool_signal (VuoIoSurface ioSurface)
 Called by the receiving end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture.
 
GLuint VuoGlShader_use (VuoGlContext glContext, GLenum type, const char *source)
 Returns an OpenGL Shader Object representing the specified source.
 
VuoGlProgram VuoGlProgram_use (VuoGlContext glContext, const char *description, GLuint vertexShaderName, GLuint geometryShaderName, GLuint fragmentShaderName, VuoMesh_ElementAssemblyMethod assemblyMethod, unsigned int expectedOutputPrimitiveCount)
 Links shaders together into a program (or finds an existing program if one already exists for the given shaders, element assembly method, and output primitive count), and returns the GL Program Object.
 
int VuoGlProgram_getUniformLocation (VuoGlProgram program, const char *uniformIdentifier)
 Returns the location (suitable for use with glUniform*()) for a given uniform identifier, or -1 if the uniform isn't found.
 
void VuoGlProgram_lock (GLuint programName)
 Waits for the process-wide lock for this GL program to become available, and claims it.
 
void VuoGlProgram_unlock (GLuint programName)
 Releases the process-wide lock for this GL program.
 
char * VuoGl_stringForConstant (GLenum constant)
 Returns a string for the specified OpenGL constant.
 

Class Documentation

struct VuoGlProgram
Class Members
GLuint programName
void * uniforms

Macro Definition Documentation

#define VuoGlPool_release (   type,
  size,
  glBufferName 
)    VuoGlPool_releaseF(type, size, glBufferName, __FILE__, __LINE__, __func__);

Decrements the reference count for glBufferName.

This function may be called from any thread.

#define VuoGlPool_retain (   glBufferName)    VuoGlPool_retainF(glBufferName, __FILE__, __LINE__, __func__);

Increments the reference count for glBufferName.

This function may be called from any thread.

Typedef Documentation

typedef void* VuoIoSurface

A Mac OS X IOSurface.

Enumeration Type Documentation

Types of OpenGL objects supported by Vuo's GL object pool.

Function Documentation

char* VuoGl_stringForConstant ( GLenum  constant)

Returns a string for the specified OpenGL constant.

The caller is responsible for freeing the string returned by this function.

void VuoGlPool_releaseF ( VuoGlPoolType  type,
unsigned long  size,
GLuint  glBufferName,
const char *  file,
unsigned int  line,
const char *  func 
)

Helper for VuoGlPool_release.

void VuoGlPool_retainF ( GLuint  glBufferName,
const char *  file,
unsigned int  line,
const char *  func 
)

Helper for VuoGlPool_retain.

GLuint VuoGlPool_use ( VuoGlPoolType  type,
unsigned long  size 
)

Returns an OpenGL Buffer Object of type type.

If an existing, unused buffer of the specified type and size is available, it is returned. Otherwise, a new buffer is created.

Todo:
https://b33p.net/kosada/node/6901 The returned buffer's storage ~~is~~ will be preallocated (so the caller can efficiently upload data using glBufferSubData),

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Todo:
https://b33p.net/kosada/node/6901
int VuoGlProgram_getUniformLocation ( VuoGlProgram  program,
const char *  uniformIdentifier 
)

Returns the location (suitable for use with glUniform*()) for a given uniform identifier, or -1 if the uniform isn't found.

void VuoGlProgram_lock ( GLuint  programName)

Waits for the process-wide lock for this GL program to become available, and claims it.

void VuoGlProgram_unlock ( GLuint  programName)

Releases the process-wide lock for this GL program.

VuoGlProgram VuoGlProgram_use ( VuoGlContext  glContext,
const char *  description,
GLuint  vertexShaderName,
GLuint  geometryShaderName,
GLuint  fragmentShaderName,
VuoMesh_ElementAssemblyMethod  assemblyMethod,
unsigned int  expectedOutputPrimitiveCount 
)

Links shaders together into a program (or finds an existing program if one already exists for the given shaders, element assembly method, and output primitive count), and returns the GL Program Object.

vertexShaderName must be nonzero, but it's OK for geometryShaderName and/or fragmentShaderName to be 0 (same rules as VuoShader_addSource).

description is used just to print errors/warnings; it is not used for cache matching.

Do not call glDeleteShaders() on the returned program; it's expected to persist throughout the lifetime of the process.

Be sure to call VuoGlProgram_lock() before you call glUseProgram().

GLuint VuoGlShader_use ( VuoGlContext  glContext,
GLenum  type,
const char *  source 
)

Returns an OpenGL Shader Object representing the specified source.

To improve performance, this function keeps a cache of precompiled shaders. If a precompiled shader exists for the specified source, that shader is returned. Otherwise, source is passed off to OpenGL to be compiled.

Do not call glDeleteShaders() on the returned shader; it's expected to persist throughout the lifetime of the process.

Todo:
prefix the following with VuoGlsl_
void VuoGlTexture_disown ( GLuint  glTextureName)

Removes glTextureName from Vuo's reference count table (without deleting it like VuoGlTexture_release does).

glTextureName must have a reference count of exactly 1 (i.e., a texture being used in multiple places throughout Vuo cannot be disowned).

After Vuo disowns the texture, the caller is responsible for eventually deleting it.

This function may be called from any thread.

unsigned char VuoGlTexture_getBytesPerPixel ( GLuint  internalformat,
GLuint  format 
)

Returns the number of bytes required to store each pixel of the specified OpenGL texture format.

unsigned char VuoGlTexture_getChannelCount ( GLuint  format)

Returns the number of color+alpha channels in the specified OpenGL texture format.

unsigned long VuoGlTexture_getMaximumTextureBytes ( VuoGlContext  glContext)

Returns the maximum number of bytes in Video RAM that a texture can occupy.

GLuint VuoGlTexture_getType ( GLuint  format)

Returns the OpenGL texture data type corresponding with OpenGL texture format.

void VuoGlTexture_release ( GLenum  internalformat,
unsigned short  width,
unsigned short  height,
GLuint  glTextureName,
GLuint  glTextureTarget 
)

Decrements the reference count for glTextureName.

This function may be called from any thread.

void VuoGlTexture_retain ( GLuint  glTextureName,
VuoImage_freeCallback  freeCallback,
void *  freeCallbackContext 
)

Increments the reference count for glTextureName.

This function may be called from any thread.

GLuint VuoGlTexturePool_use ( VuoGlContext  glContext,
GLenum  internalformat,
unsigned short  width,
unsigned short  height,
GLenum  format 
)

Returns an OpenGL texture.

If an existing, unused texture matching the specified internalformat, width, and height is available, it is returned. Otherwise, a new texture is created.

The returned texture's storage is preallocated (so the caller can efficiently upload data using glTexSubImage2D), and its texturing properties are set to the defaults:

  • wrapping: clamp to border
  • filtering: linear

See glTexImage2D for information about internalformat and format.

Returns 0 if the texture would be too large to fit in Video RAM.

This function may be called from any thread. (However, the caller is responsible for ensuring that the GL context is not used simultaneously on multiple threads.)

Todo:
Better error handling per https://b33p.net/kosada/node/4724
Todo:
Better error handling per https://b33p.net/kosada/node/4724
void VuoIoSurfacePool_disuse ( VuoGlContext  glContext,
unsigned short  pixelsWide,
unsigned short  pixelsHigh,
VuoIoSurface  ioSurface,
GLuint  texture 
)

Called by the sending end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture.

This enables the IOSurface to be reused for another texture transfer (once the receiving end indicates it is done with it, via VuoIoSurfacePool_signal()).

uint32_t VuoIoSurfacePool_getId ( VuoIoSurface  ioSurface)

Returns the IOSurface's interprocess ID.

void VuoIoSurfacePool_signal ( VuoIoSurface  ioSurface)

Called by the receiving end of an IOSurface texture transfer to indicate that it is finished using the IOSurface's texture.

This enables the sender to reuse the IOSurface for another texture transfer.

VuoIoSurface VuoIoSurfacePool_use ( VuoGlContext  glContext,
unsigned short  pixelsWide,
unsigned short  pixelsHigh,
GLuint *  outputTexture 
)

Returns an IOSurface (backed by outputTexture) with the specified dimensions.

Uses an IOSurface from the pool, if possible. If not, creates a new IOSurface.

Todo:
kIOSurfaceIsGlobal is deprecated on 10.11; replace int32 lookup with IOSurfaceCreateXPCObject or something. http://lists.apple.com/archives/mac-opengl/2009/Sep/msg00110.html