cgD3D11CreateBufferFromObject
Keywords: cgD3D11CreateBufferFromObject, NVIDIA, NVIDIA Cg Toolkit, Cg Toolkit, Shader, Shader Programming, GPU Shader Programming, GPU Program

> ## Name

> cgD3D11CreateBufferFromObject - create a Cg buffer from a D3D11 buffer object

> ## Synopsis

>     #include <Cg/cgD3D11.h>

>     CGbuffer cgD3D11CreateBufferFromObject( CGcontext context,
>                                             ID3D11Buffer * obj,
>                                             CGbool manageObject );

> ## Parameters

> context
>   The context to which the new buffer will be added.
> obj
>   A D3D11 buffer object created by the application.
> manageObject
>   A boolean switch which controls whether obj will be deleted by the runtime when the CGbuffer object returned by cgD3D11CreateBufferFromObject is destroyed.

> ## Return Values

> Returns a CGbuffer handle on success.

> Returns NULL if any error occurs.

> ## Description

> cgD3D11CreateBufferFromObject creates a Cg buffer from a preexisting D3D11 buffer object. This D3D11 object will be deleted by the runtime when the Cg buffer is destroyed if manageObject is CG_TRUE. Otherwise the application is responsibile for deleting the D3D11 object obj.

> ## Examples

>       CGbuffer myBuffer = cgD3D11CreateBufferFromObject( myCgContext, d3d11BufferObj, CG_TRUE );

> ## Errors

> CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context.

> ## History

> cgD3D11CreateBufferFromObject was introduced in Cg 3.1.

> ## See Also

> cgCreateBuffer, cgDestroyBuffer, cgD3D11GetBufferByIndex