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

Description

VuoGlContext implementation.

Classes

class  VuoGlContextPool
 A process-wide set of mutually-shared OpenGL contexts. More...
 

Macros

#define VuoGlContext_checkGL(cap, value)
 Logs a warning if the specified OpenGL capability doesn't have value.
 
#define VuoGlContext_checkGLInt(key, value)
 Logs a warning if the specified OpenGL key doesn't have value.
 
#define VuoGlCheckBinding(pname)
 Check whether the specified attachment point pname is still bound.
 
#define VuoGlCheckTextureBinding(pname, unit)
 Check whether the specified attachment point pname is still bound.
 

Typedefs

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

Functions

static void VuoGlContext_renderers (void)
 Logs info about all available renderers.
 
void VuoGlContext_reconfig (CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo)
 Called when display settings change (a display is plugged in or unplugged, resolution is changed, …).
 
void VuoGlContext_setGlobalRootContext (void *rootContext)
 Specifies a platform-specific context to be used as the base for all of Vuo's shared GL contexts.
 
VuoGlContext VuoGlContext_use (void)
 Finds an unused GL context in the process-wide shared context pool (or creates one if none is available), marks it used, and returns it.
 
void VuoGlContext_perform (void(^function)(CGLContextObj cgl_ctx))
 Executes code using the global OpenGL context.
 
void VuoGlContext_disuseF (VuoGlContext glContext, const char *file, const unsigned int linenumber, const char *func)
 Helper for VuoGlContext_disuse.
 
int VuoGlContext_getMaximumSupportedMultisampling (VuoGlContext context)
 Returns the maximum supported multisampling level for this GPU.
 
void * VuoGlContext_makePlatformPixelFormat (bool hasDepthBuffer, bool openGL32Core, GLint displayMask)
 Returns a platform-specific OpenGL pixelformat description.
 
void _VGL_describe (GLenum error, CGLContextObj cgl_ctx, const char *file, const unsigned int linenumber, const char *func)
 Logs text describing the specified OpenGL error.
 
void _VGL (CGLContextObj cgl_ctx, const char *file, const unsigned int linenumber, const char *func)
 Helper for VGL().
 

Variables

static dispatch_once_t VuoGlContextPoolCreated = 0
 Make sure this process only has a single GL Context Pool.
 
VuoShaderContextType VuoShaderContextMap
 The currently-active shader on each context.
 

Macro Definition Documentation

#define VuoGlCheckBinding (   pname)
Value:
{ \
GLint value; \
glGetIntegerv(pname, &value); \
if (value) \
{ \
VuoLog(file, linenumber, func, #pname " (value %d) was still active when the context was disused. (This may result in leaks.)", value); \
VuoLog_backtrace(); \
} \
}

Check whether the specified attachment point pname is still bound.

(This is defined as a macro in order to stringify the argument.)

#define VuoGlCheckTextureBinding (   pname,
  unit 
)
Value:
{ \
GLint value; \
glGetIntegerv(pname, &value); \
if (value) \
{ \
VuoLog(file, linenumber, func, #pname " (texture %d on unit %d) was still active when the context was disused. (This may result in leaks.)", value, unit); \
VuoLog_backtrace(); \
} \
}

Check whether the specified attachment point pname is still bound.

(This is defined as a macro in order to stringify the argument.)

#define VuoGlContext_checkGL (   cap,
  value 
)
Value:
do { \
if (glIsEnabled(cap) != value) \
VUserLog("Warning: Caller incorrectly left %s %s", #cap, value ? "disabled" : "enabled"); \
} while (0)

Logs a warning if the specified OpenGL capability doesn't have value.

#define VuoGlContext_checkGLInt (   key,
  value 
)
Value:
do { \
GLint actualValue; \
glGetIntegerv(key, &actualValue); \
if (actualValue != value) \
VUserLog("Warning: Caller incorrectly left %s set to something other than %s", #key, #value); \
} while (0)

Logs a warning if the specified OpenGL key doesn't have value.

Typedef Documentation

typedef std::map<VuoGlContext, GLuint> VuoShaderContextType

Type for VuoShaderContextMap.

Function Documentation

void _VGL ( CGLContextObj  cgl_ctx,
const char *  file,
const unsigned int  linenumber,
const char *  func 
)

Helper for VGL().

void _VGL_describe ( GLenum  error,
CGLContextObj  cgl_ctx,
const char *  file,
const unsigned int  linenumber,
const char *  func 
)

Logs text describing the specified OpenGL error.

void VuoGlContext_disuseF ( VuoGlContext  glContext,
const char *  file,
const unsigned int  linenumber,
const char *  func 
)

Helper for VuoGlContext_disuse.

int VuoGlContext_getMaximumSupportedMultisampling ( VuoGlContext  context)

Returns the maximum supported multisampling level for this GPU.

Multisampling is known to break point rendering on some GPUs, so we intentionally disable it on those.

void* VuoGlContext_makePlatformPixelFormat ( bool  hasDepthBuffer,
bool  openGL32Core,
GLint  displayMask 
)

Returns a platform-specific OpenGL pixelformat description.

On Mac OS X, this is a CGLPixelFormatObj.

Parameters
hasDepthBufferIf true, the returned context will have a depth buffer.
openGL32CoreIf true, the returned context will be OpenGL 3.2 Core Profile. If false, OpenGL 2.1.
displayMaskIf -1, the context will not be restricted by display. If nonzero, the context will be restricted to the specified displays (CGDisplayIDToOpenGLDisplayMask()). If 0xff, the context will use the Apple Software Renderer.
Returns
-1 if the displayMask is invalid. NULL if another error occurred.
void VuoGlContext_perform ( void(^)(CGLContextObj cgl_ctx)  function)

Executes code using the global OpenGL context.

Example:
VuoGlContext_perform(^(CGLContextObj cgl_ctx){
glClear(…);
});
void VuoGlContext_reconfig ( CGDirectDisplayID  display,
CGDisplayChangeSummaryFlags  flags,
void *  userInfo 
)

Called when display settings change (a display is plugged in or unplugged, resolution is changed, …).

static void VuoGlContext_renderers ( void  )
static

Logs info about all available renderers.

void VuoGlContext_setGlobalRootContext ( void *  rootContext)

Specifies a platform-specific context to be used as the base for all of Vuo's shared GL contexts.

On Mac, this should be a CGLContext. The CGLContext must be unlocked when calling this function, but after that you may lock it at any time (Vuo doesn't require it to be locked or unlocked).

Must be called before any Vuo composition is loaded, and before any other VuoGlContext_* methods.

This function may be called from any thread.

VuoGlContext VuoGlContext_use ( void  )

Finds an unused GL context in the process-wide shared context pool (or creates one if none is available), marks it used, and returns it.

This function may be called from any thread.

Variable Documentation

dispatch_once_t VuoGlContextPoolCreated = 0
static

Make sure this process only has a single GL Context Pool.

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.