Functions to exchange data between CUDA and OpenGL. More...
Functions | |
static System::Void | Rx::Net::ApiLF::RxGlGetContext () |
Assigns the OpenGL context created by Rx::Net::ApiLF::RxCudaSelectDevice to the calling thread. More... | |
static System::Void | Rx::Net::ApiLF::RxGlGetTextureID (Rx::Net::ApiLF::EImgID eImgID, System::UInt32 &uGlTextureID) |
Get the OpenGl texture ID corresponding to given parameter eImgID. The content of this texture can be updated with the Rx::Net::ApiLF::RxGlUpdateTex function. More... | |
static System::Void | Rx::Net::ApiLF::RxGlGetTextureID (Rx::Net::ApiLF::EImgID eImgID, System::UInt32% uGlTextureID) |
Get the OpenGl texture ID corresponding to given parameter eImgID. The content of this texture can be updated with the Rx::Net::ApiLF::RxGlUpdateTex function. More... | |
static System::UInt32 | Rx::Net::ApiLF::RxGlGetTextureID (Rx::Net::ApiLF::EImgID eImgID) |
Get the OpenGl texture ID corresponding to given parameter eImgID. The content of this texture can be updated with the Rx::Net::ApiLF::RxGlUpdateTex function. More... | |
static System::Void | Rx::Net::ApiLF::RxGlGetVersion (System::Int32% iMajor, System::Int32% iMinor) |
Get OpenGL version of current OpenGL rendering context. More... | |
static System::Void | Rx::Net::ApiLF::RxGlReleaseContext () |
Releases the OpenGL context owned by the calling thread. More... | |
static System::Void | Rx::Net::ApiLF::RxGlUpdateTex (System::UInt32 uIntImgIDs) |
Copy CUDA result images to OpenGL textures. More... | |
static System::Void | Rx::Net::ApiLF::RxGlUpdateTex (System::UInt32 uIntImgIDs, bool bCreateMipmaps) |
Copy CUDA result images to OpenGL textures. More... | |
Functions to exchange data between CUDA and OpenGL.
CUDA/OpenGL interop. works as follows. After calling Rx::Net::ApiLF::RxCudaSelectDevice with bUseGL set to true
, create an OpenGL rendering context. It is then possible for the Raytrix API to write directly to textures defined by OpenGL, which can in turn be displayed through OpenGL. This avoids having to copy CUDA result images from the CUDA device to host memory and then back again to display them. To work with OpenGL textures you can use Rx::Net::ApiLF::RxGlGetTextureID with the image id (Rx::Net::ApiLF::EImgID) of your choice, to receive the corresponding OpenGL texture id. For example if you want to work with the Rx::Net::ApiLF::EImgID::RefocusBasic_VirtualSpace image you can generate it, using Rx::Net::ApiLF::RxRefocusBasic. The result of this operation is stored on the device.
Call the Rx::Net::ApiLF::RxGlUpdateTex function each time the internal refocused image has changed.
On the OpenGL side you have to display the texture by mapping it to a plane or some other geometric object. However, note that CUDA currently only supports writing to unnormalized textures, which means that you have to define a shader to display a texture written to by the Raytrix API. The texture is initialized by the Raytrix API with the appropriate size and type, the first time Rx::Net::ApiLF::RxGlUpdateTex is called, or if the internal result image size of the Raytrix API has changed. For example, for an RGBA image with 8bit per color channel, and dimensions iWidth
by iHeight
, the texture is created internally as
The most basic shader to display such a texture on the OpenGL side is shown below. First of all, the vertex shader:
The fragment shader for color images:
The fragment shader for luminance images:
|
static |
Assigns the OpenGL context created by Rx::Net::ApiLF::RxCudaSelectDevice to the calling thread.
|
static |
Get the OpenGl texture ID corresponding to given parameter eImgID. The content of this texture can be updated with the Rx::Net::ApiLF::RxGlUpdateTex function.
eImgID | Identifier for the image. | |
[out] | uGlTextureID | Identifier for the gl texture. |
|
static |
Get the OpenGl texture ID corresponding to given parameter eImgID. The content of this texture can be updated with the Rx::Net::ApiLF::RxGlUpdateTex function.
eImgID | Identifier for the image. | |
[out] | uGlTextureID | Identifier for the gl texture. |
|
static |
Get the OpenGl texture ID corresponding to given parameter eImgID. The content of this texture can be updated with the Rx::Net::ApiLF::RxGlUpdateTex function.
eImgID | Identifier for the image. |
|
static |
Get OpenGL version of current OpenGL rendering context.
[out] | iMajor | On return contains the OpenGL major version. |
[out] | iMinor | On return contains the OpenGL minor version. |
|
static |
Releases the OpenGL context owned by the calling thread.
|
static |
Copy CUDA result images to OpenGL textures.
The internal image IDs that can be used with this function are those declared in Rx::Net::ApiLF::EImgID. Combining a number of image IDs by OR, updates all the related textures.
uIntImgIDs | Internal image ID. A number of internal image IDs can be combined with OR operation. |
|
static |
Copy CUDA result images to OpenGL textures.
The internal image IDs that can be used with this function are those declared in Rx::Net::ApiLF::EImgID. Combining a number of image IDs by OR, updates all the related textures.
uIntImgIDs | Internal image ID. A number of internal image IDs can be combined with OR operation. |
bCreateMipmaps | the create mipmaps flag. |