Name

cgCreateBuffer - create a buffer object managed by the runtime

Synopsis

#include <Cg/cg.h>

CGbuffer cgCreateBuffer( CGcontext context,
                         int size,
                         const void *data,
                         CGbufferusage bufferUsage );

Parameters

context
The context to which the new buffer will be added.
size
The length in bytes of the buffer to create.
data
Pointer to inital buffer data. NULL will fill the buffer with zero.
bufferUsage
Indicates the intended usage method of the buffer.
Can be one of the following types:
  • CG_BUFFER_USAGE_STREAM_DRAW
  • CG_BUFFER_USAGE_STREAM_READ
  • CG_BUFFER_USAGE_STREAM_COPY
  • CG_BUFFER_USAGE_STATIC_DRAW
  • CG_BUFFER_USAGE_STATIC_READ
  • CG_BUFFER_USAGE_STATIC_COPY
  • CG_BUFFER_USAGE_DYNAMIC_DRAW
  • CG_BUFFER_USAGE_DYNAMIC_READ
  • CG_BUFFER_USAGE_DYNAMIC_COPY

Return Values

Returns a CGbuffer handle on success.

Returns NULL if an error occurs.

Description

cgCreateBuffer creates a runtime managed Cg buffer object.

There is no way to query the 3D API-specific resource for a managed buffer. cgGLCreateBuffer should be used if the application wishes to later query the 3D API-specific resource for the buffer.

Examples

CGbuffer myBuffer = cgCreateBuffer( myCgContext, sizeof( float ) * 16,
                                    initalData, CG_BUFFER_USAGE_STATIC_DRAW );

Errors

CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context.

History

cgCreateBuffer was introduced in Cg 2.0.

See Also

cgGLCreateBuffer, cgDestroyBuffer