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).

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,
const char *  file,
int  line 
)
inline

OpenGL error-checking messsage function.

◆ glCheckError() [2/2]

bool glCheckError ( const char *  msg)
inline

OpenGL error check + logging.

◆ 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.