OpenGL texture with CUDA interoperability.
More...
#include <glTexture.h>
|
| ~glTexture () |
| Free the texture. More...
|
|
bool | Bind () |
| Activate using the texture. More...
|
|
void | Unbind () |
| Deactivate using the texture. More...
|
|
void | Render (float x, float y) |
| Render the texture at the specified window coordinates. More...
|
|
void | Render (float x, float y, float width, float height) |
| Render the texture with the specified position and size. More...
|
|
void | Render (const float4 &rect) |
| Render the texture to the specific screen rectangle. More...
|
|
uint32_t | GetID () const |
| Retrieve the OpenGL resource handle of the texture. More...
|
|
uint32_t | GetWidth () const |
| Retrieve the width in pixels of the texture. More...
|
|
uint32_t | GetHeight () const |
| Retrieve the height in pixels of the texture. More...
|
|
uint32_t | GetFormat () const |
| Retrieve the texture's format (e.g. More...
|
|
uint32_t | GetSize () const |
| Retrieve the size in bytes of the texture. More...
|
|
void * | Map (uint32_t device, uint32_t flags) |
| Map the texture for accessing from the CPU or CUDA. More...
|
|
void | Unmap () |
| Unmap the texture from CPU/CUDA access. More...
|
|
bool | Copy (void *ptr, uint32_t flags) |
| Copy entire contents of the texture to/from CPU or CUDA memory. More...
|
|
bool | Copy (void *ptr, uint32_t size, uint32_t flags) |
| Copy contents of the texture to/from CPU or CUDA memory. More...
|
|
bool | Copy (void *ptr, uint32_t offset, uint32_t size, uint32_t flags) |
| Copy contents of the texture to/from CPU or CUDA memory. More...
|
|
|
static glTexture * | Create (uint32_t width, uint32_t height, uint32_t format, void *data=NULL) |
| Allocate an OpenGL texture. More...
|
|
OpenGL texture with CUDA interoperability.
◆ ~glTexture()
glTexture::~glTexture |
( |
| ) |
|
◆ Bind()
Activate using the texture.
◆ Copy() [1/3]
bool glTexture::Copy |
( |
void * |
ptr, |
|
|
uint32_t |
flags |
|
) |
| |
Copy entire contents of the texture to/from CPU or CUDA memory.
- Parameters
-
ptr | the memory pointer to copy to/from, either in CPU or CUDA address space depending on flags. It's assumed that the size of the memory from this pointer is equal to GetSize(), and the entire contents of the buffer will be copied. |
flags | should be one of the following:
- GL_FROM_CPU (copy from CPU->OpenGL)
- GL_FROM_CUDA (copy from CUDA->OpenGL)
- GL_TO_CPU (copy from OpenGL->CPU)
- GL_TO_CUDA (copy from OpenGL->CUDA)
|
- Returns
- true on success, false on failure
◆ Copy() [2/3]
bool glTexture::Copy |
( |
void * |
ptr, |
|
|
uint32_t |
offset, |
|
|
uint32_t |
size, |
|
|
uint32_t |
flags |
|
) |
| |
Copy contents of the texture to/from CPU or CUDA memory.
- Parameters
-
ptr | the memory buffer to copy to/from, either in CPU or CUDA address space depending on flags |
offset | the offset into the OpenGL buffer to copy. It is assumed any offset to the CPU/CUDA pointer argument has already been applied. |
size | the number of bytes to copy |
flags | should be one of the following:
- GL_FROM_CPU (copy from CPU->OpenGL)
- GL_FROM_CUDA (copy from CUDA->OpenGL)
- GL_TO_CPU (copy from OpenGL->CPU)
- GL_TO_CUDA (copy from OpenGL->CUDA)
|
- Returns
- true on success, false on failure
◆ Copy() [3/3]
bool glTexture::Copy |
( |
void * |
ptr, |
|
|
uint32_t |
size, |
|
|
uint32_t |
flags |
|
) |
| |
Copy contents of the texture to/from CPU or CUDA memory.
- Parameters
-
ptr | the memory pointer to copy to/from, either in CPU or CUDA address space depending on flags. |
size | the number of bytes to copy |
flags | should be one of the following:
- GL_FROM_CPU (copy from CPU->OpenGL)
- GL_FROM_CUDA (copy from CUDA->OpenGL)
- GL_TO_CPU (copy from OpenGL->CPU)
- GL_TO_CUDA (copy from OpenGL->CUDA)
|
- Returns
- true on success, false on failure
◆ Create()
static glTexture* glTexture::Create |
( |
uint32_t |
width, |
|
|
uint32_t |
height, |
|
|
uint32_t |
format, |
|
|
void * |
data = NULL |
|
) |
| |
|
static |
Allocate an OpenGL texture.
- Parameters
-
width | the width of the texture in pixels |
height | the height of the texture in pixels |
format | GL_RGBA8, GL_RGBA32F, ect. |
data | initialize the texture's memory with this CPU pointer, size is width*height*bpp |
◆ GetFormat()
uint32_t glTexture::GetFormat |
( |
| ) |
const |
|
inline |
Retrieve the texture's format (e.g.
GL_RGBA8, GL_RGBA32F, ect.)
◆ GetHeight()
uint32_t glTexture::GetHeight |
( |
| ) |
const |
|
inline |
Retrieve the height in pixels of the texture.
◆ GetID()
uint32_t glTexture::GetID |
( |
| ) |
const |
|
inline |
Retrieve the OpenGL resource handle of the texture.
◆ GetSize()
uint32_t glTexture::GetSize |
( |
| ) |
const |
|
inline |
Retrieve the size in bytes of the texture.
◆ GetWidth()
uint32_t glTexture::GetWidth |
( |
| ) |
const |
|
inline |
Retrieve the width in pixels of the texture.
◆ Map()
void* glTexture::Map |
( |
uint32_t |
device, |
|
|
uint32_t |
flags |
|
) |
| |
Map the texture for accessing from the CPU or CUDA.
- Parameters
-
device | either GL_MAP_CPU or GL_MAP_CUDA |
flags | should be one of the following:
- GL_READ_WRITE
- GL_READ_ONLY
- GL_WRITE_ONLY
- GL_WRITE_DISCARD
|
- Returns
- CPU pointer to buffer if GL_MAP_CPU was specified, CUDA device pointer to buffer if GL_MAP_CUDA was specified, or NULL if an error occurred mapping the buffer.
◆ Render() [1/3]
void glTexture::Render |
( |
const float4 & |
rect | ) |
|
Render the texture to the specific screen rectangle.
◆ Render() [2/3]
void glTexture::Render |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
Render the texture at the specified window coordinates.
◆ Render() [3/3]
void glTexture::Render |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
width, |
|
|
float |
height |
|
) |
| |
Render the texture with the specified position and size.
◆ Unbind()
void glTexture::Unbind |
( |
| ) |
|
Deactivate using the texture.
◆ Unmap()
void glTexture::Unmap |
( |
| ) |
|
Unmap the texture from CPU/CUDA access.
- Note
- the texture will be unbound after calling Unmap()
The documentation for this class was generated from the following file: