Jetson Inference
DNN Vision Library

OpenGL textures and display window (X11/GLX). More...

Classes

class  glBuffer
 OpenGL buffer with CUDA interoperability. More...
 
class  glCamera
 OpenGL perspective camera supporting Look-At, Yaw/Pitch/Roll, and Ortho modes. More...
 
class  glDisplay
 OpenGL display window and image/video renderer with CUDA interoperability. More...
 
class  glTexture
 OpenGL texture with CUDA interoperability. More...
 
class  glWidget
 OpenGL graphics widget for rendering moveable/resizable shapes. More...
 

Macros

#define GL_VERTEX_BUFFER   GL_ARRAY_BUFFER
 Alias for vertex buffers. More...
 
#define GL_INDEX_BUFFER   GL_ELEMENT_ARRAY_BUFFER
 Alias for index buffers. More...
 
#define GL_MAP_CPU   0x1
 Map the buffer to CPU address space. More...
 
#define GL_MAP_CUDA   0x2
 Map the buffer to CUDA address space. More...
 
#define GL_FROM_CPU   0x3
 Copy the buffer from CPU to OpenGL. More...
 
#define GL_FROM_CUDA   0x4
 Copy the buffer from CUDA to OpenGL. More...
 
#define GL_TO_CPU   0x5
 Copy the buffer to CPU from OpenGL. More...
 
#define GL_TO_CUDA   0x6
 Copy the buffer to CUDA from OpenGL. More...
 
#define GL_WRITE_DISCARD   (GL_READ_WRITE + 0xff)
 Map the buffer as write-only and discard previous contents. More...
 
#define GL_WRITE_ONLY   GL_WRITE_ONLY_ARB
 Map the buffer with write-only access. More...
 
#define GL_READ_ONLY   GL_READ_ONLY_ARB
 Map the buffer with read-only access. More...
 
#define GL_READ_WRITE   GL_READ_WRITE_ARB
 Map the buffer with read/write access. More...
 
#define KEY_PRESSED   1
 Define for KEY_STATE and KEY_RAW events when key is pressed. More...
 
#define KEY_RELEASED   0
 Define for KEY_STATE and KEY_RAW events when key is released. More...
 
#define MOUSE_PRESSED   1
 Define for MOUSE_BUTTON event when button is pressed. More...
 
#define MOUSE_RELEASED   0
 Define for MOUSE_BUTTON event when button is released. More...
 
#define MOUSE_LEFT   1
 Define for the left mouse button number. More...
 
#define MOUSE_MIDDLE   2
 Define for the middle mouse button (or scroll wheel button) More...
 
#define MOUSE_RIGHT   3
 Define for the right mouse button number. More...
 
#define MOUSE_WHEEL_UP   4
 Define for the mouse wheel scroll up button number. More...
 
#define MOUSE_WHEEL_DOWN   5
 Define for the mouse wheel scroll down button number. More...
 
#define GL_RGB32F   GL_RGB32F_ARB
 Alias for GL_RGB32F. More...
 
#define GL_RGBA32F   GL_RGBA32F_ARB
 Alias for GL_RGBA32F. More...
 
#define LOG_GL   "[OpenGL] "
 OpenGL logging prefix. More...
 
#define GL(x)   { x; glCheckError( #x, __FILE__, __LINE__ ); }
 OpenGL error-checking macro. More...
 
#define GL_VERIFY(x)   { x; if(glCheckError( #x, __FILE__, __LINE__ )) return false; }
 Return false on OpenGL error. More...
 
#define GL_VERIFYN(x)   { x; if(glCheckError( #x, __FILE__, __LINE__ )) return NULL; }
 OpenGL NULL on OpenGL error. More...
 
#define GL_CHECK(msg)   { glCheckError(msg, __FILE__, __LINE__); }
 Print a message on OpenGL error. More...
 

Typedefs

typedef bool(* glEventHandler) (uint16_t event, int a, int b, void *user)
 Event message handler callback for recieving UI messages from a window. More...
 

Enumerations

enum  glEventType {
  MOUSE_MOVE = 0, MOUSE_ABSOLUTE, MOUSE_BUTTON, MOUSE_DRAG,
  MOUSE_WHEEL, KEY_STATE, KEY_MODIFIED, KEY_CHAR,
  WIDGET_CREATED, WIDGET_SELECTED, WIDGET_MOVED, WIDGET_RESIZED,
  WINDOW_RESIZED, WINDOW_CLOSED
}
 User interface event message types. More...
 

Functions

glDisplayglGetDisplay (uint32_t display=0)
 Retrieve a display window object. More...
 
uint32_t glGetNumDisplays ()
 Return the number of created glDisplay windows. More...
 
bool glCheckError (const char *msg, const char *file, int line)
 OpenGL error-checking messsage function. More...
 
bool glCheckError (const char *msg)
 OpenGL error check + logging. More...
 
void glPrintFreeMem ()
 Print the amount of free GPU memory. More...
 
void glDrawLine (float x1, float y1, float x2, float y2, float r, float g, float b, float a=1.0f, float thickness=2.0f)
 Render a line in screen coordinates with the specified color. More...
 
void glDrawOutline (float x, float y, float width, float height, float r, float g, float b, float a=1.0f, float thickness=2.0f)
 Render the outline of a rect in screen coordinates with the specified color. More...
 
void glDrawRect (float x, float y, float width, float height, float r, float g, float b, float a=1.0f)
 Render a filled rect in screen coordinates with the specified color. More...
 

Detailed Description

OpenGL textures and display window (X11/GLX).


Class Documentation

◆ glBuffer

class glBuffer

OpenGL buffer with CUDA interoperability.

Public Member Functions

 ~glBuffer ()
 Free the buffer. More...
 
bool Bind ()
 Activate using the buffer. More...
 
void Unbind ()
 Deactivate using the buffer. More...
 
uint32_t GetID () const
 Retrieve the OpenGL resource handle of the buffer. More...
 
uint32_t GetType () const
 Retrieve the buffer type (GL_VERTEX_BUFFER or GL_INDEX_BUFFER) More...
 
uint32_t GetSize () const
 Retrieve the total size in bytes of the buffer. More...
 
uint32_t GetNumElements () const
 Retrieve the number of elements (i.e. More...
 
uint32_t GetElementSize () const
 Retrieve the size in bytes of each element. More...
 
void * Map (uint32_t device, uint32_t flags)
 Map the buffer for accessing from the CPU or CUDA. More...
 
void Unmap ()
 Unmap the buffer from CPU/CUDA access. More...
 
bool Copy (void *ptr, uint32_t flags)
 Copy entire contents of the buffer to/from CPU or CUDA memory. More...
 
bool Copy (void *ptr, uint32_t size, uint32_t flags)
 Copy contents of the buffer to/from CPU or CUDA memory. More...
 
bool Copy (void *ptr, uint32_t offset, uint32_t size, uint32_t flags)
 Copy contents of the buffer to/from CPU or CUDA memory. More...
 

Static Public Member Functions

static glBufferCreate (uint32_t type, uint32_t size, void *data=NULL, uint32_t usage=GL_STATIC_DRAW)
 Allocate an OpenGL buffer. More...
 
static glBufferCreate (uint32_t type, uint32_t numElements, uint32_t elementSize, void *data=NULL, uint32_t usage=GL_STATIC_DRAW)
 Allocate an OpenGL buffer. More...
 

Constructor & Destructor Documentation

◆ ~glBuffer()

glBuffer::~glBuffer ( )

Free the buffer.

Member Function Documentation

◆ Bind()

bool glBuffer::Bind ( )

Activate using the buffer.

◆ Copy() [1/3]

bool glBuffer::Copy ( void *  ptr,
uint32_t  flags 
)

Copy entire contents of the buffer to/from CPU or CUDA memory.

Parameters
ptrthe 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.
flagsshould 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 glBuffer::Copy ( void *  ptr,
uint32_t  offset,
uint32_t  size,
uint32_t  flags 
)

Copy contents of the buffer to/from CPU or CUDA memory.

Parameters
ptrthe memory buffer to copy to/from, either in CPU or CUDA address space depending on flags
offsetthe offset into the OpenGL buffer to copy. It is assumed any offset to the CPU/CUDA pointer argument has already been applied.
sizethe number of bytes to copy
flagsshould 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 glBuffer::Copy ( void *  ptr,
uint32_t  size,
uint32_t  flags 
)

Copy contents of the buffer to/from CPU or CUDA memory.

Parameters
ptrthe memory pointer to copy to/from, either in CPU or CUDA address space depending on flags.
sizethe number of bytes to copy
flagsshould 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() [1/2]

static glBuffer* glBuffer::Create ( uint32_t  type,
uint32_t  numElements,
uint32_t  elementSize,
void *  data = NULL,
uint32_t  usage = GL_STATIC_DRAW 
)
static

Allocate an OpenGL buffer.

Parameters
typeeither GL_VERTEX_BUFFER for a vertex buffer, or GL_INDEX_BUFFER for an index buffer
numElementsthe number of elements (i.e. vertices or indices) in the buffer
elementSizethe size in bytes of each element
datapointer to the initial memory of this buffer
usageGL_STATIC_DRAW (never updated), GL_STREAM_DRAW (occasional updates), or GL_DYNAMIC_DRAW (per-frame updates)

◆ Create() [2/2]

static glBuffer* glBuffer::Create ( uint32_t  type,
uint32_t  size,
void *  data = NULL,
uint32_t  usage = GL_STATIC_DRAW 
)
static

Allocate an OpenGL buffer.

Parameters
typeeither GL_VERTEX_BUFFER for a vertex buffer, or GL_INDEX_BUFFER for an index buffer
sizethe size in bytes to allocated for the buffer
datapointer to the initial memory of this buffer
usageGL_STATIC_DRAW (never updated), GL_STREAM_DRAW (occasional updates), or GL_DYNAMIC_DRAW (per-frame updates)

◆ GetElementSize()

uint32_t glBuffer::GetElementSize ( ) const
inline

Retrieve the size in bytes of each element.

Note
if the element size wasn't specified while creating the buffer, GetElementSize() will be equal to 1

◆ GetID()

uint32_t glBuffer::GetID ( ) const
inline

Retrieve the OpenGL resource handle of the buffer.

◆ GetNumElements()

uint32_t glBuffer::GetNumElements ( ) const
inline

Retrieve the number of elements (i.e.

vertices or indices)

Note
if the number of elements weren't specified while creating the buffer, GetNumElements() will be equal to GetSize()

◆ GetSize()

uint32_t glBuffer::GetSize ( ) const
inline

Retrieve the total size in bytes of the buffer.

◆ GetType()

uint32_t glBuffer::GetType ( ) const
inline

Retrieve the buffer type (GL_VERTEX_BUFFER or GL_INDEX_BUFFER)

◆ Map()

void* glBuffer::Map ( uint32_t  device,
uint32_t  flags 
)

Map the buffer for accessing from the CPU or CUDA.

Parameters
deviceeither GL_MAP_CPU or GL_MAP_CUDA
flagsshould 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.

◆ Unbind()

void glBuffer::Unbind ( )

Deactivate using the buffer.

◆ Unmap()

void glBuffer::Unmap ( )

Unmap the buffer from CPU/CUDA access.

Note
the buffer will be unbound after calling Unmap()

◆ glCamera

class glCamera

OpenGL perspective camera supporting Look-At, Yaw/Pitch/Roll, and Ortho modes.

Public Types

enum  CameraMode { LookAt, YawPitchRoll, Ortho }
 Enum specifying the camera mode. More...
 

Public Member Functions

 ~glCamera ()
 Free the camera. More...
 
void Activate ()
 Activate GL_PROJECTION and GL_MODELVIEW matrices. More...
 
void Activate (CameraMode mode)
 Activate GL_PROJECTION and GL_MODELVIEW matrices. More...
 
void Deactivate ()
 Restore previous GL_PROJECTION and GL_MODELVIEW matrices. More...
 
CameraMode GetCameraMode () const
 Get the camera mode. More...
 
void SetCameraMode (CameraMode mode)
 Set the camera mode. More...
 
void SetFOV (float fov)
 Set the field of view (FOV), in degrees. More...
 
void SetClippingPlane (float near, float far)
 Set the near/far z-clipping plane. More...
 
void SetNear (float near)
 Set the distance to the near clipping plane. More...
 
void SetFar (float far)
 Set the distance to the far clipping plane. More...
 
void SetEye (float x, float y, float z)
 Set the eye position. More...
 
void SetLookAt (float x, float y, float z)
 Set the look-at point. More...
 
void SetRotation (float yaw, float pitch, float roll)
 Set the yaw/pitch/roll angles, in radians. More...
 
void SetYaw (float yaw)
 Set the yaw angle, in radians. More...
 
void SetPitch (float pitch)
 Set the pitch angle, in radians. More...
 
void SetRoll (float roll)
 Set the roll angle, in radians. More...
 
void SetMovementSpeed (float speed)
 Set the movement speed (in world units) More...
 
void SetMovementEnabled (bool enabled)
 Enable or disable movement from user input. More...
 
void StoreDefaults ()
 Store the current configuration as defaults. More...
 
void Reset ()
 Reset camera orientation to defaults. More...
 
void RegisterEvents (uint32_t display=0)
 Register to recieve input events (enable movement) More...
 

Static Public Member Functions

static glCameraCreate (CameraMode mode, int registerEvents=0)
 Create OpenGL camera object with the specified CameraMode. More...
 
static glCameraCreate (int registerEvents=0)
 Create OpenGL camera object. More...
 

Member Enumeration Documentation

◆ CameraMode

Enum specifying the camera mode.

Enumerator
LookAt 

LookAt (orbit)

YawPitchRoll 

YawPitchRoll (first person.

Ortho 

Ortho (2D)

Constructor & Destructor Documentation

◆ ~glCamera()

glCamera::~glCamera ( )

Free the camera.

Member Function Documentation

◆ Activate() [1/2]

void glCamera::Activate ( )

Activate GL_PROJECTION and GL_MODELVIEW matrices.

◆ Activate() [2/2]

void glCamera::Activate ( CameraMode  mode)

Activate GL_PROJECTION and GL_MODELVIEW matrices.

◆ Create() [1/2]

static glCamera* glCamera::Create ( CameraMode  mode,
int  registerEvents = 0 
)
static

Create OpenGL camera object with the specified CameraMode.

Parameters
registerEventsthe ID of the glDisplay window to register with to recieve input events (for moving the camera around with keyboard/mouse), or -1 to not register for input events.

◆ Create() [2/2]

static glCamera* glCamera::Create ( int  registerEvents = 0)
static

Create OpenGL camera object.

Parameters
registerEventsthe ID of the glDisplay window to register with to recieve input events (for moving the camera around with keyboard/mouse), or -1 to not register for input events.

◆ Deactivate()

void glCamera::Deactivate ( )

Restore previous GL_PROJECTION and GL_MODELVIEW matrices.

◆ GetCameraMode()

CameraMode glCamera::GetCameraMode ( ) const
inline

Get the camera mode.

◆ RegisterEvents()

void glCamera::RegisterEvents ( uint32_t  display = 0)

Register to recieve input events (enable movement)

◆ Reset()

void glCamera::Reset ( )

Reset camera orientation to defaults.

◆ SetCameraMode()

void glCamera::SetCameraMode ( CameraMode  mode)
inline

Set the camera mode.

◆ SetClippingPlane()

void glCamera::SetClippingPlane ( float  near,
float  far 
)
inline

Set the near/far z-clipping plane.

◆ SetEye()

void glCamera::SetEye ( float  x,
float  y,
float  z 
)
inline

Set the eye position.

◆ SetFar()

void glCamera::SetFar ( float  far)
inline

Set the distance to the far clipping plane.

◆ SetFOV()

void glCamera::SetFOV ( float  fov)
inline

Set the field of view (FOV), in degrees.

◆ SetLookAt()

void glCamera::SetLookAt ( float  x,
float  y,
float  z 
)
inline

Set the look-at point.

◆ SetMovementEnabled()

void glCamera::SetMovementEnabled ( bool  enabled)
inline

Enable or disable movement from user input.

◆ SetMovementSpeed()

void glCamera::SetMovementSpeed ( float  speed)
inline

Set the movement speed (in world units)

◆ SetNear()

void glCamera::SetNear ( float  near)
inline

Set the distance to the near clipping plane.

◆ SetPitch()

void glCamera::SetPitch ( float  pitch)
inline

Set the pitch angle, in radians.

◆ SetRoll()

void glCamera::SetRoll ( float  roll)
inline

Set the roll angle, in radians.

◆ SetRotation()

void glCamera::SetRotation ( float  yaw,
float  pitch,
float  roll 
)
inline

Set the yaw/pitch/roll angles, in radians.

◆ SetYaw()

void glCamera::SetYaw ( float  yaw)
inline

Set the yaw angle, in radians.

◆ StoreDefaults()

void glCamera::StoreDefaults ( )

Store the current configuration as defaults.

◆ glDisplay

class glDisplay

OpenGL display window and image/video renderer with CUDA interoperability.

Note
glDisplay implements the videoOutput interface and is intended to be used through that as opposed to directly. videoOutput implements additional command-line parsing of videoOptions to construct instances.
See also
videoOutput
Inheritance diagram for glDisplay:
videoOutput

Public Member Functions

 ~glDisplay ()
 Destroy window. More...
 
virtual bool Open ()
 Open the window. More...
 
bool IsOpen () const
 Returns true if the window is open. More...
 
bool IsClosed () const
 Returns true if the window has been closed. More...
 
bool IsRendering () const
 Returns true if between BeginRender() and EndRender() More...
 
float GetFPS () const
 Get the average frame time (in milliseconds). More...
 
uint32_t GetID () const
 Get the ID of this display instance into glGetDisplay() More...
 
virtual uint32_t GetType () const
 Return the interface type (glDisplay::Type) More...
 
Frame Begin + End
void BeginRender (bool processEvents=true)
 Clear window and begin rendering a frame. More...
 
void EndRender ()
 Finish rendering and refresh / flip the backbuffer. More...
 
Image Rendering
void Render (glTexture *texture, float x=5.0f, float y=30.0f)
 Render an OpenGL texture. More...
 
void Render (float *image, uint32_t width, uint32_t height, float x=0.0f, float y=30.0f, bool normalize=true)
 Render a CUDA float4 image using OpenGL interop If normalize is true, the image's pixel values will be rescaled from the range of [0-255] to [0-1] If normalize is false, the image's pixel values are assumed to already be in the range of [0-1] Note that if normalization is selected to be performed, it will be done in-place on the image. More...
 
template<typename T >
bool Render (T *image, uint32_t width, uint32_t height)
 Render a CUDA image (uchar3, uchar4, float3, float4) using OpenGL interop. More...
 
virtual bool Render (void *image, uint32_t width, uint32_t height, imageFormat format)
 Render a CUDA image (uchar3, uchar4, float3, float4) using OpenGL interop. More...
 
void RenderImage (void *image, uint32_t width, uint32_t height, imageFormat format, float x=0.0f, float y=30.0f, bool normalize=true)
 Render a CUDA image (uchar3, uchar4, float3, float4) using OpenGL interop. More...
 
void RenderOnce (void *image, uint32_t width, uint32_t height, imageFormat format, float x=5.0f, float y=30.0f, bool normalize=true)
 Begin the frame, render one CUDA image using OpenGL interop, and end the frame. More...
 
void RenderOnce (float *image, uint32_t width, uint32_t height, float x=5.0f, float y=30.0f, bool normalize=true)
 Begin the frame, render one CUDA float4 image using OpenGL interop, and end the frame. More...
 
Vector Rendering
void RenderLine (float x1, float y1, float x2, float y2, float r, float g, float b, float a=1.0f, float thickness=2.0f)
 Render a line in screen coordinates with the specified color. More...
 
void RenderOutline (float x, float y, float width, float height, float r, float g, float b, float a=1.0f, float thickness=2.0f)
 Render the outline of a rect in screen coordinates with the specified color. More...
 
void RenderRect (float x, float y, float width, float height, float r, float g, float b, float a=1.0f)
 Render a filled rect in screen coordinates with the specified color. More...
 
void RenderRect (float r, float g, float b, float a=1.0f)
 Render a filled rect covering the current viewport with the specified color. More...
 
Window Resizing
void SetSize (uint32_t width, uint32_t height)
 Set the window's size. More...
 
void SetMaximized (bool maximized)
 Maximize or un-maximize the window. More...
 
bool IsMaximized ()
 Determine if the window is maximized or not. More...
 
void SetFullscreen (bool fullscreen)
 Set the window to fullscreen mode or not. More...
 
bool IsFullscreen ()
 Determine if the window is fullscreen or not. More...
 
Viewport Options
void GetBackgroundColor (float *r, float *g, float *b, float *a=NULL)
 Retrieve the window's background color. More...
 
void SetBackgroundColor (float r, float g, float b, float a=1.0f)
 Set the window's background color. More...
 
void SetViewport (int left, int top, int right, int bottom)
 Set the active viewport being rendered to. More...
 
void ResetViewport ()
 Reset to the full viewport (and change back GL_PROJECTION) More...
 
Event Handling
void ProcessEvents ()
 Process UI event messages. More...
 
void AddEventHandler (glEventHandler callback, void *user=NULL)
 Register an event message handler that will be called by ProcessEvents() More...
 
void RemoveEventHandler (glEventHandler callback, void *user=NULL)
 Remove an event message handler from being called by ProcessEvents() RemoveEventHandler() will search for previously registered event handlers that have the same function pointer and/or user pointer, and remove them for being called again in the future. More...
 
Mouse + Keyboard State
const int * GetMousePosition () const
 Get the mouse position. More...
 
void GetMousePosition (int *x, int *y) const
 Get the mouse position. More...
 
bool GetMouseButton (uint32_t button) const
 Get the mouse button state. More...
 
bool GetKey (uint32_t key) const
 Get the state of a key (lowercase, without modifiers applied) More...
 
Mouse Cursor
void SetCursor (uint32_t cursor)
 Set the active mouse cursor. More...
 
void SetDefaultCursor (uint32_t cursor, bool activate=true)
 Set the default mouse cursor that gets used by ResetCursor() More...
 
void ResetCursor ()
 Reset the mouse cursor back to it's default. More...
 
void ResetDefaultCursor (bool activate=true)
 Reset the default cursor back to it's original, the arrow. More...
 
Widgets
glWidgetAddWidget (glWidget *widget)
 Add a widget to the window that recieves events and is rendered. More...
 
void RemoveWidget (glWidget *widget, bool deleteWidget=true)
 Remove a widget from the window (and optionally delete it) More...
 
void RemoveWidget (uint32_t index, bool deleteWidget=true)
 Remove a widget from the window (and optionally delete it) More...
 
void RemoveAllWidgets (bool deleteWidgets=true)
 Remove all widgets from the window (and optionally delete them) More...
 
uint32_t GetNumWidgets () const
 Retrieve the number of widgets. More...
 
glWidgetGetWidget (const uint32_t index) const
 Retrieve a widget. More...
 
int GetWidgetIndex (const glWidget *widget) const
 Retrieve the index of a widget (or -1 if not found) More...
 
glWidgetFindWidget (int x, int y)
 Find first widget by coordinate, or NULL if no widget overlaps with that coordinate. More...
 
std::vector< glWidget * > FindWidgets (int x, int y)
 Find all widgets by coordinate, or NULL if no widget overlaps with that coordinate. More...
 
- Public Member Functions inherited from videoOutput
virtual ~videoOutput ()
 Destroy interface and release all resources. More...
 
template<typename T >
bool Render (T *image, uint32_t width, uint32_t height)
 Render and output the next frame to the stream. More...
 
virtual void Close ()
 Stop streaming the device. More...
 
bool IsStreaming () const
 Check if the device is actively streaming or not. More...
 
uint32_t GetWidth () const
 Return the width of the stream, in pixels. More...
 
uint32_t GetHeight () const
 Return the height of the stream, in pixels. More...
 
float GetFrameRate () const
 Return the framerate, in Hz or FPS. More...
 
uint64_t GetFrameCount () const
 Return the number of frames output. More...
 
const URIGetResource () const
 Return the resource URI of the stream. More...
 
const videoOptionsGetOptions () const
 Return the videoOptions of the stream. More...
 
void AddOutput (videoOutput *output)
 Add an output sub-stream. More...
 
uint32_t GetNumOutputs () const
 Return the number of sub-streams. More...
 
videoOutputGetOutput (uint32_t index) const
 Return a sub-stream. More...
 
bool IsType (uint32_t type) const
 Check if this stream is of a particular type. More...
 
template<typename T >
bool IsType () const
 Check if a this stream is of a particular type. More...
 
const char * TypeToStr () const
 Convert this stream's class type to string. More...
 

Static Public Member Functions

static glDisplayCreate (const char *title=NULL, int width=-1, int height=-1, float r=0.05f, float g=0.05f, float b=0.05f, float a=1.0f)
 Create a new OpenGL display window with the specified options. More...
 
static glDisplayCreate (const videoOptions &options)
 Create a new OpenGL display window with the specified options. More...
 
- Static Public Member Functions inherited from videoOutput
static videoOutputCreate (const videoOptions &options)
 Create videoOutput interface from a videoOptions struct that's already been filled out. More...
 
static videoOutputCreate (const char *URI, const videoOptions &options=videoOptions())
 Create videoOutput interface from a resource URI string and optional videoOptions. More...
 
static videoOutputCreate (const char *URI, const commandLine &cmdLine)
 Create videoOutput interface from a resource URI string and parsing command line arguments. More...
 
static videoOutputCreate (const char *URI, const int argc, char **argv)
 Create videoOutput interface from a resource URI string and parsing command line arguments. More...
 
static videoOutputCreate (const int argc, char **argv, int positionArg=-1)
 Create videoOutput interface by parsing command line arguments, including the resource URI. More...
 
static videoOutputCreate (const commandLine &cmdLine, int positionArg=-1)
 Create videoOutput interface by parsing command line arguments, including the resource URI. More...
 
static videoOutputCreateNullOutput ()
 Create videoOutput interface that acts as a NULL output and does nothing with incoming frames. More...
 
static const char * Usage ()
 Usage string for command line arguments to Create() More...
 
static const char * TypeToStr (uint32_t type)
 Convert a class type to a string. More...
 

Static Public Attributes

static const uint32_t Type = (1 << 3)
 Unique type identifier of glDisplay class. More...
 

Protected Member Functions

 glDisplay (const videoOptions &options)
 
bool initWindow ()
 
bool initGL ()
 
glTextureallocTexture (uint32_t width, uint32_t height, imageFormat format)
 
void activateViewport ()
 
void dispatchEvent (uint16_t msg, int a, int b)
 
- Protected Member Functions inherited from videoOutput
 videoOutput (const videoOptions &options)
 

Static Protected Member Functions

static bool onEvent (uint16_t msg, int a, int b, void *user)
 

Protected Attributes

Display * mDisplayX
 
Screen * mScreenX
 
XVisualInfo * mVisualX
 
Window mWindowX
 
GLXContext mContextGL
 
Cursor mCursors [256]
 
int mActiveCursor
 
int mDefaultCursor
 
bool mInitialShow
 
bool mRendering
 
bool mResizedToFeed
 
Atom mWindowClosedMsg
 
DragMode mDragMode
 
uint32_t mID
 
uint32_t mScreenWidth
 
uint32_t mScreenHeight
 
timespec mLastTime
 
float mAvgTime
 
float mBgColor [4]
 
int mViewport [4]
 
int mMousePos [2]
 
int mMouseDrag [2]
 
int mMouseDragOrigin [2]
 
bool mMouseButtons [16]
 
bool mKeyStates [1024]
 
float * mNormalizedCUDA
 
uint32_t mNormalizedWidth
 
uint32_t mNormalizedHeight
 
std::vector< glWidget * > mWidgets
 
std::vector< glTexture * > mTextures
 
std::vector< eventHandlermEventHandlers
 
- Protected Attributes inherited from videoOutput
bool mStreaming
 
videoOptions mOptions
 
std::vector< videoOutput * > mOutputs
 

Static Protected Attributes

static const int screenIdx = 0
 

Status Bar Text

static const char * DEFAULT_TITLE
 Default title bar name. More...
 
virtual void SetStatus (const char *str)
 Set the window title string. More...
 
void SetTitle (const char *str)
 Set the window title string. More...
 

Mouse Dragging

enum  DragMode { DragDefault, DragDisabled, DragSelect, DragCreate }
 Drag behavior enum. More...
 
DragMode GetDragMode () const
 Get the dragging behavior mode. More...
 
void SetDragMode (DragMode mode)
 Set the dragging behavior mode. More...
 
bool IsDragging (DragMode mode=DragDefault) const
 Is the mouse currently dragging in the specified mode? More...
 
bool GetDragRect (int *x, int *y, int *width, int *height)
 Get the current dragging rectangle, or return false if not dragging. More...
 
bool GetDragCoords (int *x1, int *y1, int *x2, int *y2)
 Get the current dragging coordinates, or return false if not dragging. More...
 

Member Enumeration Documentation

◆ DragMode

Drag behavior enum.

See also
GetDragMode()
SetDragMode()
Enumerator
DragDefault 

Issue MOUSE_DRAG events, but nothing else.

DragDisabled 

Disable issuing all MOUSE_DRAG events.

DragSelect 

Select widgets from a dragging rectangle, and issue WIDGET_SELECTED events.

DragCreate 

Create a new widget from a dragging rectangle, and issue WIDGET_CREATED events.

Constructor & Destructor Documentation

◆ ~glDisplay()

glDisplay::~glDisplay ( )

Destroy window.

◆ glDisplay()

glDisplay::glDisplay ( const videoOptions options)
protected

Member Function Documentation

◆ activateViewport()

void glDisplay::activateViewport ( )
protected

◆ AddEventHandler()

void glDisplay::AddEventHandler ( glEventHandler  callback,
void *  user = NULL 
)

Register an event message handler that will be called by ProcessEvents()

Parameters
callbackfunction pointer to the event message handler callback
useroptional user-specified pointer that will be passed to all invocations of this event handler (typically an object)

◆ AddWidget()

glWidget* glDisplay::AddWidget ( glWidget widget)

Add a widget to the window that recieves events and is rendered.

◆ allocTexture()

glTexture* glDisplay::allocTexture ( uint32_t  width,
uint32_t  height,
imageFormat  format 
)
protected

◆ BeginRender()

void glDisplay::BeginRender ( bool  processEvents = true)

Clear window and begin rendering a frame.

If processEvents is true, ProcessEvents() will automatically be called.

◆ Create() [1/2]

static glDisplay* glDisplay::Create ( const char *  title = NULL,
int  width = -1,
int  height = -1,
float  r = 0.05f,
float  g = 0.05f,
float  b = 0.05f,
float  a = 1.0f 
)
static

Create a new OpenGL display window with the specified options.

Parameters
titlewindow title bar string, or NULL for a default title
widthdesired width of the window, or -1 to be maximized
heightdesired height of the window, or -1 to be maximized
rdefault background RGBA color, red component (0.0-1.0f)
gdefault background RGBA color, green component (0.0-1.0f)
bdefault background RGBA color, blue component (0.0-1.0f)
adefault background RGBA color, alpha component (0.0-1.0f)

◆ Create() [2/2]

static glDisplay* glDisplay::Create ( const videoOptions options)
static

Create a new OpenGL display window with the specified options.

◆ dispatchEvent()

void glDisplay::dispatchEvent ( uint16_t  msg,
int  a,
int  b 
)
protected

◆ EndRender()

void glDisplay::EndRender ( )

Finish rendering and refresh / flip the backbuffer.

◆ FindWidget()

glWidget* glDisplay::FindWidget ( int  x,
int  y 
)

Find first widget by coordinate, or NULL if no widget overlaps with that coordinate.

◆ FindWidgets()

std::vector<glWidget*> glDisplay::FindWidgets ( int  x,
int  y 
)

Find all widgets by coordinate, or NULL if no widget overlaps with that coordinate.

◆ GetBackgroundColor()

void glDisplay::GetBackgroundColor ( float *  r,
float *  g,
float *  b,
float *  a = NULL 
)

Retrieve the window's background color.

◆ GetDragCoords()

bool glDisplay::GetDragCoords ( int *  x1,
int *  y1,
int *  x2,
int *  y2 
)

Get the current dragging coordinates, or return false if not dragging.

◆ GetDragMode()

DragMode glDisplay::GetDragMode ( ) const
inline

Get the dragging behavior mode.

◆ GetDragRect()

bool glDisplay::GetDragRect ( int *  x,
int *  y,
int *  width,
int *  height 
)

Get the current dragging rectangle, or return false if not dragging.

◆ GetFPS()

float glDisplay::GetFPS ( ) const
inline

Get the average frame time (in milliseconds).

◆ GetID()

uint32_t glDisplay::GetID ( ) const
inline

Get the ID of this display instance into glGetDisplay()

◆ GetKey()

bool glDisplay::GetKey ( uint32_t  key) const
inline

Get the state of a key (lowercase, without modifiers applied)

Similar to glEvent::KEY_STATE, GetKey() queries the raw key state without being translated by modifier keys such as Shift, CapsLock, NumLock, ect. Alphanumeric keys will be left as lowercase, so query lowercase keys - uppercase keys will always return false.

Parameters
keythe XK_ key symbol (see /usr/include/X11/keysymdef.h)
       Uppercase keys like XK_A or XK_plus will always return false.
       Instead, query the lowercase keys such as XK_a, XK_1, ect.

       Other keys like F1-F12, shift, tab, ctrl/alt, arrow keys, 
       backspace, delete, escape, and enter can all be queried.

       GetKey() caches the first 1024 key symbols. Other keys will
       return false, but can be subscribed to through a glEventHander.
Returns
true if the key is pressed, otherwise false

◆ GetMouseButton()

bool glDisplay::GetMouseButton ( uint32_t  button) const
inline

Get the mouse button state.

Parameters
buttonthe button number, starting with 1. In X11, the left mouse button is 1. Here are the mouse button numbers:
  • 1 MOUSE_LEFT (left button)

2 MOUSE_MIDDLE (middle button / scroll wheel button)

  • 3 MOUSE_RIGHT (right button)
  • 4 MOUSE_WHEEL_UP (scroll wheel up)
  • 5 MOUSE_WHEEL_DOWN (scroll wheel down)
Returns
true if the button is pressed, otherwise false

◆ GetMousePosition() [1/2]

const int* glDisplay::GetMousePosition ( ) const
inline

Get the mouse position.

◆ GetMousePosition() [2/2]

void glDisplay::GetMousePosition ( int *  x,
int *  y 
) const
inline

Get the mouse position.

◆ GetNumWidgets()

uint32_t glDisplay::GetNumWidgets ( ) const
inline

Retrieve the number of widgets.

◆ GetType()

virtual uint32_t glDisplay::GetType ( ) const
inlinevirtual

Return the interface type (glDisplay::Type)

Reimplemented from videoOutput.

◆ GetWidget()

glWidget* glDisplay::GetWidget ( const uint32_t  index) const
inline

Retrieve a widget.

◆ GetWidgetIndex()

int glDisplay::GetWidgetIndex ( const glWidget widget) const

Retrieve the index of a widget (or -1 if not found)

◆ initGL()

bool glDisplay::initGL ( )
protected

◆ initWindow()

bool glDisplay::initWindow ( )
protected

◆ IsClosed()

bool glDisplay::IsClosed ( ) const
inline

Returns true if the window has been closed.

◆ IsDragging()

bool glDisplay::IsDragging ( DragMode  mode = DragDefault) const
inline

Is the mouse currently dragging in the specified mode?

◆ IsFullscreen()

bool glDisplay::IsFullscreen ( )

Determine if the window is fullscreen or not.

◆ IsMaximized()

bool glDisplay::IsMaximized ( )

Determine if the window is maximized or not.

◆ IsOpen()

bool glDisplay::IsOpen ( ) const
inline

Returns true if the window is open.

◆ IsRendering()

bool glDisplay::IsRendering ( ) const
inline

Returns true if between BeginRender() and EndRender()

◆ onEvent()

static bool glDisplay::onEvent ( uint16_t  msg,
int  a,
int  b,
void *  user 
)
staticprotected

◆ Open()

virtual bool glDisplay::Open ( )
virtual

Open the window.

See also
videoOutput::Open()

Reimplemented from videoOutput.

◆ ProcessEvents()

void glDisplay::ProcessEvents ( )

Process UI event messages.

Any queued events will be dispatched to the event message handlers that were registered with RegisterEventHandler()

ProcessEvents() usually gets called automatically by BeginFrame(), so it is not typically necessary to explicitly call it unless you passed false to BeginFrame() and wish to process events at another time of your choosing.

See also
glEventType
glEventHandler

◆ RemoveAllWidgets()

void glDisplay::RemoveAllWidgets ( bool  deleteWidgets = true)

Remove all widgets from the window (and optionally delete them)

◆ RemoveEventHandler()

void glDisplay::RemoveEventHandler ( glEventHandler  callback,
void *  user = NULL 
)

Remove an event message handler from being called by ProcessEvents() RemoveEventHandler() will search for previously registered event handlers that have the same function pointer and/or user pointer, and remove them for being called again in the future.

◆ RemoveWidget() [1/2]

void glDisplay::RemoveWidget ( glWidget widget,
bool  deleteWidget = true 
)

Remove a widget from the window (and optionally delete it)

◆ RemoveWidget() [2/2]

void glDisplay::RemoveWidget ( uint32_t  index,
bool  deleteWidget = true 
)

Remove a widget from the window (and optionally delete it)

◆ Render() [1/4]

void glDisplay::Render ( float *  image,
uint32_t  width,
uint32_t  height,
float  x = 0.0f,
float  y = 30.0f,
bool  normalize = true 
)

Render a CUDA float4 image using OpenGL interop If normalize is true, the image's pixel values will be rescaled from the range of [0-255] to [0-1] If normalize is false, the image's pixel values are assumed to already be in the range of [0-1] Note that if normalization is selected to be performed, it will be done in-place on the image.

◆ Render() [2/4]

void glDisplay::Render ( glTexture texture,
float  x = 5.0f,
float  y = 30.0f 
)

Render an OpenGL texture.

Note
for more texture rendering methods,
See also
glTexture

◆ Render() [3/4]

template<typename T >
bool glDisplay::Render ( T *  image,
uint32_t  width,
uint32_t  height 
)
inline

Render a CUDA image (uchar3, uchar4, float3, float4) using OpenGL interop.

This is similar to RenderOnce(), in that it will begin/end the frame also.

See also
videoOutput::Render

◆ Render() [4/4]

virtual bool glDisplay::Render ( void *  image,
uint32_t  width,
uint32_t  height,
imageFormat  format 
)
virtual

Render a CUDA image (uchar3, uchar4, float3, float4) using OpenGL interop.

This is similar to RenderOnce(), in that it will begin/end the frame also.

See also
videoOutput::Render

Reimplemented from videoOutput.

◆ RenderImage()

void glDisplay::RenderImage ( void *  image,
uint32_t  width,
uint32_t  height,
imageFormat  format,
float  x = 0.0f,
float  y = 30.0f,
bool  normalize = true 
)

Render a CUDA image (uchar3, uchar4, float3, float4) using OpenGL interop.

If normalize is true, the image's pixel values will be rescaled from the range of [0-255] to [0-1] If normalize is false, the image's pixel values are assumed to already be in the range of [0-1] Note that if normalization is selected to be performed, it will be done in-place on the image

◆ RenderLine()

void glDisplay::RenderLine ( float  x1,
float  y1,
float  x2,
float  y2,
float  r,
float  g,
float  b,
float  a = 1.0f,
float  thickness = 2.0f 
)

Render a line in screen coordinates with the specified color.

Note
the RGBA color values are expected to be in the range of [0-1]

◆ RenderOnce() [1/2]

void glDisplay::RenderOnce ( float *  image,
uint32_t  width,
uint32_t  height,
float  x = 5.0f,
float  y = 30.0f,
bool  normalize = true 
)

Begin the frame, render one CUDA float4 image using OpenGL interop, and end the frame.

Note that this function is only useful if you are rendering a single texture per frame. If normalize is true, the image's pixel values will be rescaled from the range of [0-255] to [0-1] If normalize is false, the image's pixel values are assumed to already be in the range of [0-1] Note that if normalization is selected to be performed, it will be done in-place on the image

◆ RenderOnce() [2/2]

void glDisplay::RenderOnce ( void *  image,
uint32_t  width,
uint32_t  height,
imageFormat  format,
float  x = 5.0f,
float  y = 30.0f,
bool  normalize = true 
)

Begin the frame, render one CUDA image using OpenGL interop, and end the frame.

Note that this function is only useful if you are rendering a single texture per frame. If normalize is true, the image's pixel values will be rescaled from the range of [0-255] to [0-1] If normalize is false, the image's pixel values are assumed to already be in the range of [0-1] Note that if normalization is selected to be performed, it will be done in-place on the image

◆ RenderOutline()

void glDisplay::RenderOutline ( float  x,
float  y,
float  width,
float  height,
float  r,
float  g,
float  b,
float  a = 1.0f,
float  thickness = 2.0f 
)

Render the outline of a rect in screen coordinates with the specified color.

Note
the RGBA color values are expected to be in the range of [0-1]

◆ RenderRect() [1/2]

void glDisplay::RenderRect ( float  r,
float  g,
float  b,
float  a = 1.0f 
)

Render a filled rect covering the current viewport with the specified color.

Note
the RGBA color values are expected to be in the range of [0-1]

◆ RenderRect() [2/2]

void glDisplay::RenderRect ( float  x,
float  y,
float  width,
float  height,
float  r,
float  g,
float  b,
float  a = 1.0f 
)

Render a filled rect in screen coordinates with the specified color.

Note
the RGBA color values are expected to be in the range of [0-1]

◆ ResetCursor()

void glDisplay::ResetCursor ( )

Reset the mouse cursor back to it's default.

The default mouse cursor is defined by SetDefaultCursor().

See also
SetDefaultCursor()
SetCursor()

◆ ResetDefaultCursor()

void glDisplay::ResetDefaultCursor ( bool  activate = true)

Reset the default cursor back to it's original, the arrow.

Parameters
activateif true (default), the active cursor will be changed to this new default cursor immediately. If false, the active cursor will stay the same until ResetCursor() gets called in the future.
See also
SetDefaultCursor()
SetCursor()
ResetCursor()

◆ ResetViewport()

void glDisplay::ResetViewport ( )

Reset to the full viewport (and change back GL_PROJECTION)

◆ SetBackgroundColor()

void glDisplay::SetBackgroundColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)

Set the window's background color.

Parameters
rbackground RGBA color, red component (0.0-1.0f)
gbackground RGBA color, green component (0.0-1.0f)
bbackground RGBA color, blue component (0.0-1.0f)
abackground RGBA color, alpha component (0.0-1.0f)

◆ SetCursor()

void glDisplay::SetCursor ( uint32_t  cursor)

Set the active mouse cursor.

Parameters
cursorone of the cursor ID's from X11/cursorfont.h
See also
ResetCursor() to restore the cursor back to default
SetDefaultCursor() to change the default cursor

◆ SetDefaultCursor()

void glDisplay::SetDefaultCursor ( uint32_t  cursor,
bool  activate = true 
)

Set the default mouse cursor that gets used by ResetCursor()

Parameters
cursorone of the cursor ID's from X11/cursorfont.h. This will be the default cursor that gets set when ResetCursor() is called.
activateif true (default), the active cursor will be changed to this new default cursor immediately. If false, the active cursor will stay the same until ResetCursor() gets called in the future.
See also
ResetCursor()
ResetDefaultCursor()
SetCursor()

◆ SetDragMode()

void glDisplay::SetDragMode ( DragMode  mode)
inline

Set the dragging behavior mode.

◆ SetFullscreen()

void glDisplay::SetFullscreen ( bool  fullscreen)

Set the window to fullscreen mode or not.

◆ SetMaximized()

void glDisplay::SetMaximized ( bool  maximized)

Maximize or un-maximize the window.

◆ SetSize()

void glDisplay::SetSize ( uint32_t  width,
uint32_t  height 
)

Set the window's size.

Parameters
widththe desired width of the window, in pixels.
heightthe desired height of the window, in pixels.
Note
modifying the window's size will reset the viewport to cover the full area of the new size of the window.

◆ SetStatus()

virtual void glDisplay::SetStatus ( const char *  str)
virtual

Set the window title string.

Reimplemented from videoOutput.

◆ SetTitle()

void glDisplay::SetTitle ( const char *  str)

Set the window title string.

Deprecated:
SetTitle() has been superceded by SetStatus() from videoOutput API. SetTitle() is functionally the same as SetStatus().

◆ SetViewport()

void glDisplay::SetViewport ( int  left,
int  top,
int  right,
int  bottom 
)

Set the active viewport being rendered to.

SetViewport() will update the GL_PROJECTION matrix with a new ortho matrix to reflect these changes.

After done rendering to this viewport, you should reset it back to it's original with ResetViewport()

Member Data Documentation

◆ DEFAULT_TITLE

const char* glDisplay::DEFAULT_TITLE
static

Default title bar name.

◆ mActiveCursor

int glDisplay::mActiveCursor
protected

◆ mAvgTime

float glDisplay::mAvgTime
protected

◆ mBgColor

float glDisplay::mBgColor[4]
protected

◆ mContextGL

GLXContext glDisplay::mContextGL
protected

◆ mCursors

Cursor glDisplay::mCursors[256]
protected

◆ mDefaultCursor

int glDisplay::mDefaultCursor
protected

◆ mDisplayX

Display* glDisplay::mDisplayX
protected

◆ mDragMode

DragMode glDisplay::mDragMode
protected

◆ mEventHandlers

std::vector<eventHandler> glDisplay::mEventHandlers
protected

◆ mID

uint32_t glDisplay::mID
protected

◆ mInitialShow

bool glDisplay::mInitialShow
protected

◆ mKeyStates

bool glDisplay::mKeyStates[1024]
protected

◆ mLastTime

timespec glDisplay::mLastTime
protected

◆ mMouseButtons

bool glDisplay::mMouseButtons[16]
protected

◆ mMouseDrag

int glDisplay::mMouseDrag[2]
protected

◆ mMouseDragOrigin

int glDisplay::mMouseDragOrigin[2]
protected

◆ mMousePos

int glDisplay::mMousePos[2]
protected

◆ mNormalizedCUDA

float* glDisplay::mNormalizedCUDA
protected

◆ mNormalizedHeight

uint32_t glDisplay::mNormalizedHeight
protected

◆ mNormalizedWidth

uint32_t glDisplay::mNormalizedWidth
protected

◆ mRendering

bool glDisplay::mRendering
protected

◆ mResizedToFeed

bool glDisplay::mResizedToFeed
protected

◆ mScreenHeight

uint32_t glDisplay::mScreenHeight
protected

◆ mScreenWidth

uint32_t glDisplay::mScreenWidth
protected

◆ mScreenX

Screen* glDisplay::mScreenX
protected

◆ mTextures

std::vector<glTexture*> glDisplay::mTextures
protected

◆ mViewport

int glDisplay::mViewport[4]
protected

◆ mVisualX

XVisualInfo* glDisplay::mVisualX
protected

◆ mWidgets

std::vector<glWidget*> glDisplay::mWidgets
protected

◆ mWindowClosedMsg

Atom glDisplay::mWindowClosedMsg
protected

◆ mWindowX

Window glDisplay::mWindowX
protected

◆ screenIdx

const int glDisplay::screenIdx = 0
staticprotected

◆ Type

const uint32_t glDisplay::Type = (1 << 3)
static

Unique type identifier of glDisplay class.

◆ glTexture

class glTexture

OpenGL texture with CUDA interoperability.

Public Member Functions

 ~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 Public Member Functions

static glTextureCreate (uint32_t width, uint32_t height, uint32_t format, void *data=NULL)
 Allocate an OpenGL texture. More...
 

Constructor & Destructor Documentation

◆ ~glTexture()

glTexture::~glTexture ( )

Free the texture.

Member Function Documentation

◆ Bind()

bool 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
ptrthe 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.
flagsshould 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
ptrthe memory buffer to copy to/from, either in CPU or CUDA address space depending on flags
offsetthe offset into the OpenGL buffer to copy. It is assumed any offset to the CPU/CUDA pointer argument has already been applied.
sizethe number of bytes to copy
flagsshould 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
ptrthe memory pointer to copy to/from, either in CPU or CUDA address space depending on flags.
sizethe number of bytes to copy
flagsshould 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
widththe width of the texture in pixels
heightthe height of the texture in pixels
formatGL_RGBA8, GL_RGBA32F, ect.
datainitialize 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
deviceeither GL_MAP_CPU or GL_MAP_CUDA
flagsshould 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()

◆ glWidget

class glWidget

OpenGL graphics widget for rendering moveable/resizable shapes.

Public Types

enum  Shape { Rect, Line, Ellipse }
 Shape enum. More...
 
typedef bool(* glWidgetEventHandler) (glWidget *widget, uint16_t event, int a, int b, void *user)
 Event message handler callback for recieving UI messages from widgets. More...
 

Public Member Functions

 glWidget (Shape shape=Rect)
 Constructor. More...
 
 glWidget (float x, float y, float width, float height, Shape shape=Rect)
 Constructor. More...
 
virtual ~glWidget ()
 Destructor. More...
 
bool Contains (float x, float y) const
 Test if the point is inside the widget. More...
 
void Move (float x, float y)
 Move the widget's position by the specified offset. More...
 
float X () const
 Get the widget's X coordinate. More...
 
float Y () const
 Get the widget's Y coordinate. More...
 
void SetX (float x)
 Set the widget's X coordinate. More...
 
void SetY (float y)
 Set the widget's Y coordinate. More...
 
float Width () const
 Get the widget's width. More...
 
float Height () const
 Get the widget's height. More...
 
void SetWidth (float width)
 Set the widget's width. More...
 
void SetHeight (float height)
 Set the widget's height. More...
 
void GetPosition (float *x, float *y) const
 Get position of widget in global window coordinates. More...
 
void SetPosition (float x, float y)
 Set position of widget in global window coordinates. More...
 
void GetCoords (float *x1, float *y1, float *x2, float *y2) const
 Get the bounding coordinates of the widget. More...
 
void SetCoords (float x1, float y1, float x2, float y2)
 Set the bounding coordinates of the widget. More...
 
void GetSize (float *width, float *height) const
 Get the widget's size. More...
 
void SetSize (float width, float height)
 Set the widget's size. More...
 
Shape GetShape () const
 Get the shape. More...
 
void SetShape (Shape shape)
 Set the shape. More...
 
void SetFillAlpha (float a)
 Set fill alpha. More...
 
void SetLineAlpha (float a)
 Set outline alpha. More...
 
void SetLineWidth (float width)
 Set outline width. More...
 
void SetFillColor (float r, float g, float b, float a=1.0f)
 Set fill color. More...
 
void SetLineColor (float r, float g, float b, float a=1.0f)
 Set outline color. More...
 
void SetSelectedFillColor (float r, float g, float b, float a=1.0f)
 Set selected fill color. More...
 
void SetSelectedLineColor (float r, float g, float b, float a=1.0f)
 Set selected outline color. More...
 
bool IsMoveable () const
 Is the widget moveable/draggable by the user? More...
 
void SetMoveable (bool moveable)
 Toggle if the user can move/drag the widget. More...
 
bool IsResizeable () const
 Is the widget resizeable by the user? More...
 
void SetResizeable (bool resizeable)
 Toggle if the user can resize the widget. More...
 
bool IsSelected () const
 Is the widget selected? More...
 
void SetSelected (bool selected)
 Select/de-select the widget. More...
 
bool IsVisible () const
 Is the widget visible. More...
 
void SetVisible (bool visible)
 Show/hide the widget. More...
 
void * GetUserData () const
 Retrieve user data. More...
 
void SetUserData (void *user)
 Set user-defined data. More...
 
glDisplayGetDisplay () const
 Get the root window of the widget. More...
 
int GetIndex () const
 Get the index of the widget in the window (or -1 if none) More...
 
void Render ()
 Render (automatically called by parent) More...
 
void GlobalToLocal (float x, float y, float *x_out, float *y_out) const
 Convert from global window coordinates to local widget offset. More...
 
void LocalToGlobal (float x, float y, float *x_out, float *y_out) const
 Convert from local widget offset to global window coordinates. More...
 
void AddEventHandler (glWidgetEventHandler callback, void *user=NULL)
 Register an event message handler the widget will send events to. More...
 
void RemoveEventHandler (glWidgetEventHandler callback, void *user=NULL)
 Remove an event message handler from being called by the widget. More...
 
bool OnEvent (uint16_t event, int a, int b, void *user)
 

Protected Types

enum  DragState {
  DragNone, DragMove, DragResizeN, DragResizeNW,
  DragResizeNE, DragResizeS, DragResizeSW, DragResizeSE,
  DragResizeW, DragResizeE
}
 

Protected Member Functions

void initDefaults ()
 
void setCursor (DragState cursor)
 
void setDisplay (glDisplay *display)
 
void dispatchEvent (uint16_t msg, int a, int b)
 
DragState coordToBorder (float x, float y, float max_distance=10.0f)
 

Protected Attributes

float mX
 
float mY
 
float mWidth
 
float mHeight
 
float mSelectedFillColor [4]
 
float mSelectedLineColor [4]
 
float mFillColor [4]
 
float mLineColor [4]
 
float mLineWidth
 
bool mMoveable
 
bool mResizeable
 
bool mSelected
 
bool mVisible
 
Shape mShape
 
void * mUserData
 
glDisplaymDisplay
 
DragState mDragState
 
std::vector< eventHandlermEventHandlers
 

Friends

class glDisplay
 

Member Typedef Documentation

◆ glWidgetEventHandler

typedef bool(* glWidget::glWidgetEventHandler) (glWidget *widget, uint16_t event, int a, int b, void *user)

Event message handler callback for recieving UI messages from widgets.

Recieves 4 parameters - the widget that sent the event, the event type, a & b message values (

See also
glEventType from glEvents.h), and a user-specified pointer from registration.

Event message handlers should return true if the message was handled, or false if the message was skipped or not handled.

See also
AddEventHandler
RemoveEventHandler

Member Enumeration Documentation

◆ DragState

enum glWidget::DragState
protected
Enumerator
DragNone 
DragMove 
DragResizeN 
DragResizeNW 
DragResizeNE 
DragResizeS 
DragResizeSW 
DragResizeSE 
DragResizeW 
DragResizeE 

◆ Shape

Shape enum.

Enumerator
Rect 
Line 
Ellipse 

Constructor & Destructor Documentation

◆ glWidget() [1/2]

glWidget::glWidget ( Shape  shape = Rect)

Constructor.

◆ glWidget() [2/2]

glWidget::glWidget ( float  x,
float  y,
float  width,
float  height,
Shape  shape = Rect 
)

Constructor.

◆ ~glWidget()

virtual glWidget::~glWidget ( )
virtual

Destructor.

Member Function Documentation

◆ AddEventHandler()

void glWidget::AddEventHandler ( glWidgetEventHandler  callback,
void *  user = NULL 
)

Register an event message handler the widget will send events to.

Parameters
callbackfunction pointer to the event message handler callback
useroptional user-specified pointer that will be passed to all invocations of this event handler (typically an object)

◆ Contains()

bool glWidget::Contains ( float  x,
float  y 
) const

Test if the point is inside the widget.

◆ coordToBorder()

DragState glWidget::coordToBorder ( float  x,
float  y,
float  max_distance = 10.0f 
)
protected

◆ dispatchEvent()

void glWidget::dispatchEvent ( uint16_t  msg,
int  a,
int  b 
)
protected

◆ GetCoords()

void glWidget::GetCoords ( float *  x1,
float *  y1,
float *  x2,
float *  y2 
) const
inline

Get the bounding coordinates of the widget.

◆ GetDisplay()

glDisplay* glWidget::GetDisplay ( ) const
inline

Get the root window of the widget.

◆ GetIndex()

int glWidget::GetIndex ( ) const

Get the index of the widget in the window (or -1 if none)

◆ GetPosition()

void glWidget::GetPosition ( float *  x,
float *  y 
) const
inline

Get position of widget in global window coordinates.

◆ GetShape()

Shape glWidget::GetShape ( ) const
inline

Get the shape.

◆ GetSize()

void glWidget::GetSize ( float *  width,
float *  height 
) const
inline

Get the widget's size.

◆ GetUserData()

void* glWidget::GetUserData ( ) const
inline

Retrieve user data.

◆ GlobalToLocal()

void glWidget::GlobalToLocal ( float  x,
float  y,
float *  x_out,
float *  y_out 
) const

Convert from global window coordinates to local widget offset.

◆ Height()

float glWidget::Height ( ) const
inline

Get the widget's height.

◆ initDefaults()

void glWidget::initDefaults ( )
protected

◆ IsMoveable()

bool glWidget::IsMoveable ( ) const
inline

Is the widget moveable/draggable by the user?

◆ IsResizeable()

bool glWidget::IsResizeable ( ) const
inline

Is the widget resizeable by the user?

◆ IsSelected()

bool glWidget::IsSelected ( ) const
inline

Is the widget selected?

◆ IsVisible()

bool glWidget::IsVisible ( ) const
inline

Is the widget visible.

◆ LocalToGlobal()

void glWidget::LocalToGlobal ( float  x,
float  y,
float *  x_out,
float *  y_out 
) const

Convert from local widget offset to global window coordinates.

◆ Move()

void glWidget::Move ( float  x,
float  y 
)
inline

Move the widget's position by the specified offset.

◆ OnEvent()

bool glWidget::OnEvent ( uint16_t  event,
int  a,
int  b,
void *  user 
)

◆ RemoveEventHandler()

void glWidget::RemoveEventHandler ( glWidgetEventHandler  callback,
void *  user = NULL 
)

Remove an event message handler from being called by the widget.

RemoveEventHandler() will search for previously registered event handlers that have the same function pointer and/or user pointer, and remove them for being called again in the future.

◆ Render()

void glWidget::Render ( )

Render (automatically called by parent)

◆ SetCoords()

void glWidget::SetCoords ( float  x1,
float  y1,
float  x2,
float  y2 
)
inline

Set the bounding coordinates of the widget.

◆ setCursor()

void glWidget::setCursor ( DragState  cursor)
protected

◆ setDisplay()

void glWidget::setDisplay ( glDisplay display)
protected

◆ SetFillAlpha()

void glWidget::SetFillAlpha ( float  a)
inline

Set fill alpha.

◆ SetFillColor()

void glWidget::SetFillColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set fill color.

◆ SetHeight()

void glWidget::SetHeight ( float  height)
inline

Set the widget's height.

◆ SetLineAlpha()

void glWidget::SetLineAlpha ( float  a)
inline

Set outline alpha.

◆ SetLineColor()

void glWidget::SetLineColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set outline color.

◆ SetLineWidth()

void glWidget::SetLineWidth ( float  width)
inline

Set outline width.

◆ SetMoveable()

void glWidget::SetMoveable ( bool  moveable)
inline

Toggle if the user can move/drag the widget.

◆ SetPosition()

void glWidget::SetPosition ( float  x,
float  y 
)
inline

Set position of widget in global window coordinates.

◆ SetResizeable()

void glWidget::SetResizeable ( bool  resizeable)
inline

Toggle if the user can resize the widget.

◆ SetSelected()

void glWidget::SetSelected ( bool  selected)
inline

Select/de-select the widget.

◆ SetSelectedFillColor()

void glWidget::SetSelectedFillColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set selected fill color.

◆ SetSelectedLineColor()

void glWidget::SetSelectedLineColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set selected outline color.

◆ SetShape()

void glWidget::SetShape ( Shape  shape)
inline

Set the shape.

◆ SetSize()

void glWidget::SetSize ( float  width,
float  height 
)
inline

Set the widget's size.

◆ SetUserData()

void glWidget::SetUserData ( void *  user)
inline

Set user-defined data.

◆ SetVisible()

void glWidget::SetVisible ( bool  visible)
inline

Show/hide the widget.

◆ SetWidth()

void glWidget::SetWidth ( float  width)
inline

Set the widget's width.

◆ SetX()

void glWidget::SetX ( float  x)
inline

Set the widget's X coordinate.

◆ SetY()

void glWidget::SetY ( float  y)
inline

Set the widget's Y coordinate.

◆ Width()

float glWidget::Width ( ) const
inline

Get the widget's width.

◆ X()

float glWidget::X ( ) const
inline

Get the widget's X coordinate.

◆ Y()

float glWidget::Y ( ) const
inline

Get the widget's Y coordinate.

Friends And Related Function Documentation

◆ glDisplay

friend class glDisplay
friend

Member Data Documentation

◆ mDisplay

glDisplay* glWidget::mDisplay
protected

◆ mDragState

DragState glWidget::mDragState
protected

◆ mEventHandlers

std::vector<eventHandler> glWidget::mEventHandlers
protected

◆ mFillColor

float glWidget::mFillColor[4]
protected

◆ mHeight

float glWidget::mHeight
protected

◆ mLineColor

float glWidget::mLineColor[4]
protected

◆ mLineWidth

float glWidget::mLineWidth
protected

◆ mMoveable

bool glWidget::mMoveable
protected

◆ mResizeable

bool glWidget::mResizeable
protected

◆ mSelected

bool glWidget::mSelected
protected

◆ mSelectedFillColor

float glWidget::mSelectedFillColor[4]
protected

◆ mSelectedLineColor

float glWidget::mSelectedLineColor[4]
protected

◆ mShape

Shape glWidget::mShape
protected

◆ mUserData

void* glWidget::mUserData
protected

◆ mVisible

bool glWidget::mVisible
protected

◆ mWidth

float glWidget::mWidth
protected

◆ mX

float glWidget::mX
protected

◆ mY

float glWidget::mY
protected

Macro Definition Documentation

◆ GL

#define GL (   x)    { x; glCheckError( #x, __FILE__, __LINE__ ); }

OpenGL error-checking macro.

◆ GL_CHECK

#define GL_CHECK (   msg)    { glCheckError(msg, __FILE__, __LINE__); }

Print a message on OpenGL error.

◆ GL_FROM_CPU

#define GL_FROM_CPU   0x3

Copy the buffer from CPU to OpenGL.

◆ GL_FROM_CUDA

#define GL_FROM_CUDA   0x4

Copy the buffer from CUDA to OpenGL.

◆ GL_INDEX_BUFFER

#define GL_INDEX_BUFFER   GL_ELEMENT_ARRAY_BUFFER

Alias for index buffers.

◆ GL_MAP_CPU

#define GL_MAP_CPU   0x1

Map the buffer to CPU address space.

◆ GL_MAP_CUDA

#define GL_MAP_CUDA   0x2

Map the buffer to CUDA address space.

◆ GL_READ_ONLY

#define GL_READ_ONLY   GL_READ_ONLY_ARB

Map the buffer with read-only access.

◆ GL_READ_WRITE

#define GL_READ_WRITE   GL_READ_WRITE_ARB

Map the buffer with read/write access.

◆ GL_RGB32F

#define GL_RGB32F   GL_RGB32F_ARB

Alias for GL_RGB32F.

◆ GL_RGBA32F

#define GL_RGBA32F   GL_RGBA32F_ARB

Alias for GL_RGBA32F.

◆ GL_TO_CPU

#define GL_TO_CPU   0x5

Copy the buffer to CPU from OpenGL.

◆ GL_TO_CUDA

#define GL_TO_CUDA   0x6

Copy the buffer to CUDA from OpenGL.

◆ GL_VERIFY

#define GL_VERIFY (   x)    { x; if(glCheckError( #x, __FILE__, __LINE__ )) return false; }

Return false on OpenGL error.

◆ GL_VERIFYN

#define GL_VERIFYN (   x)    { x; if(glCheckError( #x, __FILE__, __LINE__ )) return NULL; }

OpenGL NULL on OpenGL error.

◆ GL_VERTEX_BUFFER

#define GL_VERTEX_BUFFER   GL_ARRAY_BUFFER

Alias for vertex buffers.

◆ GL_WRITE_DISCARD

#define GL_WRITE_DISCARD   (GL_READ_WRITE + 0xff)

Map the buffer as write-only and discard previous contents.

◆ GL_WRITE_ONLY

#define GL_WRITE_ONLY   GL_WRITE_ONLY_ARB

Map the buffer with write-only access.

◆ KEY_PRESSED

#define KEY_PRESSED   1

Define for KEY_STATE and KEY_RAW events when key is pressed.

See also
glEventType::KEY_STATE

◆ KEY_RELEASED

#define KEY_RELEASED   0

Define for KEY_STATE and KEY_RAW events when key is released.

See also
glEventType::KEY_STATE

◆ LOG_GL

#define LOG_GL   "[OpenGL] "

OpenGL logging prefix.

◆ MOUSE_LEFT

#define MOUSE_LEFT   1

Define for the left mouse button number.

See also
glEventType::MOUSE_BUTTON

◆ MOUSE_MIDDLE

#define MOUSE_MIDDLE   2

Define for the middle mouse button (or scroll wheel button)

See also
glEventType::MOUSE_BUTTON

◆ MOUSE_PRESSED

#define MOUSE_PRESSED   1

Define for MOUSE_BUTTON event when button is pressed.

See also
glEventType::MOUSE_BUTTON

◆ MOUSE_RELEASED

#define MOUSE_RELEASED   0

Define for MOUSE_BUTTON event when button is released.

See also
glEventType::MOUSE_BUTTON

◆ MOUSE_RIGHT

#define MOUSE_RIGHT   3

Define for the right mouse button number.

See also
glEventType::MOUSE_BUTTON

◆ MOUSE_WHEEL_DOWN

#define MOUSE_WHEEL_DOWN   5

Define for the mouse wheel scroll down button number.

See also
glEventType::MOUSE_BUTTON

◆ MOUSE_WHEEL_UP

#define MOUSE_WHEEL_UP   4

Define for the mouse wheel scroll up button number.

See also
glEventType::MOUSE_BUTTON

Typedef Documentation

◆ glEventHandler

typedef bool(* glEventHandler) (uint16_t event, int a, int b, void *user)

Event message handler callback for recieving UI messages from a window.

Recieves 4 parameters - the event type, a & b message values (see above), and a user-specified pointer from registration.

Event message handlers should return true if the message was handled, or false if the message was skipped or not handled.

See also
glRegisterEvents
glRemoveEvents

Enumeration Type Documentation

◆ glEventType

User interface event message types.

Each event message consists of the event type, a & b message values, and a user-specified pointer. The event types and message values are desribed below for each type of message.

These event messages are dispatched at runtime to glEventHandler callbacks that have been registered via glRegisterEvents()

See also
glEventHandler
glRegisterEvents
Enumerator
MOUSE_MOVE 

Message when the mouse has moved (relative coordinates)

a = x position, relative to window top-left b = y position, relative to window top-left

Note
the mouse must be within the window to recieve this message, and the coordinates will be provided in coordinates relative to the top-left of the window
MOUSE_ABSOLUTE 

Message when the mouse has moved (absolute coordinates)

a = x position, in absolute screen coordinates b = y position, in absolute screen coordinates

Note
the mouse must be within the window to recieve this message, and the coordinates will be provided in absolute screen coordinates regardless of window.
MOUSE_BUTTON 

Message when a mouse button has been pressed/released.

a = button ID b = MOUSE_PRESSED or MOUSE_RELEASED

Here is the mapping of the mouse buttons to their ID:

 - 1 MOUSE_LEFT       (left button)
  • 2 MOUSE_MIDDLE (middle button / scroll wheel button)
  • 3 MOUSE_RIGHT (right button)
  • 4 MOUSE_WHEEL_UP (scroll wheel up)
  • 5 MOUSE_WHEEL_DOWN (scroll wheel down)
MOUSE_DRAG 

Message when the left mouse button has been dragged.

a = x delta (change in position) b = y delta (change in position)

Note
the mouse must be within the window to recieve this message, and the coordinates will be provided as a delta from the change in position from last message
MOUSE_WHEEL 

Message when the mouse wheel has been scrolled a = -1 for scrolled up, or +1 for scrolled down.

KEY_STATE 

Message when a key state has changed (raw, without modifiers applied)

a = raw key symbol (without modifier translation) b = KEY_PRESSED or KEY_RELEASED

These raw symbols are left unmodified, so they won't be changed by keys like Shift, CapsLock, NumLock, ect. Letters will always be reported as lowercase. For example if you press Shift + a, it will still be reported as XK_a (a)

See also
/usr/include/X11/keysymdef.h for the XK_ KeySym symbol definitions.
KEY_MODIFIED 

Message when a key has been pressed or released (with modifiers applied)

a = key symbol (with modifier translations) b = KEY_PRESSED or KEY_RELEASED

These symbols have modifiers applied (Shift, CapsLock, NumLock, ect), so for example if you press Shift + a, it will be reported as XK_A (A)

See also
/usr/include/X11/keysymdef.h for the XK_ KeySym symbol definitions.
KEY_CHAR 

Message when a keyboard ASCII character (0-255) was entered.

a = ASCII character (0-9, a-Z, !-?, ect.)

These will have modifiers applied (Shift, CapsLock, NumLock, ect), so for example if you press Shift + a, it will be reported as 'A'.

WIDGET_CREATED 

Message indicating that a widget has been created (e.g.

from dragging)

a = widget index into glDisplay::GetWidget() or glWidget::GetIndex()

Note
this message is sent by both glWidget and glDisplay.
See also
glWidget::AddEventHandler() to subscribe to widget events.
WIDGET_SELECTED 

Message indicating that a widget has been selected (e.g.

from dragging)

a = widget index into glDisplay::GetWidget() or glWidget::GetIndex()

Note
this message is sent by both glWidget and glDisplay.
See also
glWidget::AddEventHandler() to subscribe to widget events.
WIDGET_MOVED 

Message from a widget indicating that it's been moved by the user.

This event is only sent if the user moved the widget in the GUI (i.e. if glWidget::IsMoveable() was set), and not if the widget was moved programatically via glWidget::Move(), glWidget::SetPosition(), glWidget::SetX(), glWidget::SetY(), ect.

a = new X coordinate b = new Y coordinate

Note
this message is only sent by glWidget (not glDisplay).
See also
glWidget::AddEventHandler() to subscribe to widget events.
WIDGET_RESIZED 

Message from a widget indicating that it's been resized.

This event is only sent if the user resized the widget in the GUI (i.e. if glWidget::IsResizable() was set), and not if the widget was resized programatically via glWidget::SetSize(), glWidget::SetWidth(), or glWidget::SetHeight().

a = new width b = new height

Note
this message is only sent by glWidget (not glDisplay).
See also
glWidget::AddEventHandler() to subscribe to widget events.
WINDOW_RESIZED 

Message indicating that the window has been resized.

a = new width (in pixels) b = new height (in pixels)

WINDOW_CLOSED 

Message indicating that the window is closing.

(no parameters)

Function Documentation

◆ glCheckError() [1/2]

bool glCheckError ( const char *  msg)
inline

OpenGL error check + logging.

◆ glCheckError() [2/2]

bool glCheckError ( const char *  msg,
const char *  file,
int  line 
)
inline

OpenGL error-checking messsage function.

◆ glDrawLine()

void glDrawLine ( float  x1,
float  y1,
float  x2,
float  y2,
float  r,
float  g,
float  b,
float  a = 1.0f,
float  thickness = 2.0f 
)
inline

Render a line in screen coordinates with the specified color.

Note
the RGBA color values are expected to be in the range of [0-1]

◆ glDrawOutline()

void glDrawOutline ( float  x,
float  y,
float  width,
float  height,
float  r,
float  g,
float  b,
float  a = 1.0f,
float  thickness = 2.0f 
)
inline

Render the outline of a rect in screen coordinates with the specified color.

Note
the RGBA color values are expected to be in the range of [0-1]

◆ glDrawRect()

void glDrawRect ( float  x,
float  y,
float  width,
float  height,
float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Render a filled rect in screen coordinates with the specified color.

Note
the RGBA color values are expected to be in the range of [0-1]

◆ glGetDisplay()

glDisplay* glGetDisplay ( uint32_t  display = 0)

Retrieve a display window object.

◆ glGetNumDisplays()

uint32_t glGetNumDisplays ( )

Return the number of created glDisplay windows.

◆ glPrintFreeMem()

void glPrintFreeMem ( )
inline

Print the amount of free GPU memory.