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 | |
glDisplay * | glGetDisplay (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... | |
OpenGL textures and display window (X11/GLX).
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 glBuffer * | Create (uint32_t type, uint32_t size, void *data=NULL, uint32_t usage=GL_STATIC_DRAW) |
Allocate an OpenGL buffer. More... | |
static glBuffer * | Create (uint32_t type, uint32_t numElements, uint32_t elementSize, void *data=NULL, uint32_t usage=GL_STATIC_DRAW) |
Allocate an OpenGL buffer. More... | |
glBuffer::~glBuffer | ( | ) |
Free the buffer.
bool glBuffer::Bind | ( | ) |
Activate using the buffer.
bool glBuffer::Copy | ( | void * | ptr, |
uint32_t | flags | ||
) |
Copy entire contents of the buffer to/from CPU or CUDA memory.
ptr | the memory pointer to copy to/from, either in CPU or CUDA address space depending on flags. It's assumed that the size of the memory from this pointer is equal to GetSize(), and the entire contents of the buffer will be copied. |
flags | should be one of the following:
|
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.
ptr | the memory buffer to copy to/from, either in CPU or CUDA address space depending on flags |
offset | the offset into the OpenGL buffer to copy. It is assumed any offset to the CPU/CUDA pointer argument has already been applied. |
size | the number of bytes to copy |
flags | should be one of the following:
|
bool glBuffer::Copy | ( | void * | ptr, |
uint32_t | size, | ||
uint32_t | flags | ||
) |
Copy contents of the buffer to/from CPU or CUDA memory.
ptr | the memory pointer to copy to/from, either in CPU or CUDA address space depending on flags. |
size | the number of bytes to copy |
flags | should be one of the following:
|
|
static |
Allocate an OpenGL buffer.
type | either GL_VERTEX_BUFFER for a vertex buffer, or GL_INDEX_BUFFER for an index buffer |
numElements | the number of elements (i.e. vertices or indices) in the buffer |
elementSize | the size in bytes of each element |
data | pointer to the initial memory of this buffer |
usage | GL_STATIC_DRAW (never updated), GL_STREAM_DRAW (occasional updates), or GL_DYNAMIC_DRAW (per-frame updates) |
|
static |
Allocate an OpenGL buffer.
type | either GL_VERTEX_BUFFER for a vertex buffer, or GL_INDEX_BUFFER for an index buffer |
size | the size in bytes to allocated for the buffer |
data | pointer to the initial memory of this buffer |
usage | GL_STATIC_DRAW (never updated), GL_STREAM_DRAW (occasional updates), or GL_DYNAMIC_DRAW (per-frame updates) |
|
inline |
Retrieve the size in bytes of each element.
|
inline |
Retrieve the OpenGL resource handle of the buffer.
|
inline |
Retrieve the number of elements (i.e.
vertices or indices)
|
inline |
Retrieve the total size in bytes of the buffer.
|
inline |
Retrieve the buffer type (GL_VERTEX_BUFFER or GL_INDEX_BUFFER)
void* glBuffer::Map | ( | uint32_t | device, |
uint32_t | flags | ||
) |
Map the buffer for accessing from the CPU or CUDA.
device | either GL_MAP_CPU or GL_MAP_CUDA |
flags | should be one of the following:
|
void glBuffer::Unbind | ( | ) |
Deactivate using the buffer.
void glBuffer::Unmap | ( | ) |
Unmap the buffer from CPU/CUDA access.
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 glCamera * | Create (CameraMode mode, int registerEvents=0) |
Create OpenGL camera object with the specified CameraMode. More... | |
static glCamera * | Create (int registerEvents=0) |
Create OpenGL camera object. More... | |
enum glCamera::CameraMode |
glCamera::~glCamera | ( | ) |
Free the camera.
void glCamera::Activate | ( | ) |
Activate GL_PROJECTION and GL_MODELVIEW matrices.
void glCamera::Activate | ( | CameraMode | mode | ) |
Activate GL_PROJECTION and GL_MODELVIEW matrices.
|
static |
Create OpenGL camera object with the specified CameraMode.
registerEvents | the 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. |
|
static |
Create OpenGL camera object.
registerEvents | the 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. |
void glCamera::Deactivate | ( | ) |
Restore previous GL_PROJECTION and GL_MODELVIEW matrices.
|
inline |
Get the camera mode.
void glCamera::RegisterEvents | ( | uint32_t | display = 0 | ) |
Register to recieve input events (enable movement)
void glCamera::Reset | ( | ) |
Reset camera orientation to defaults.
|
inline |
Set the camera mode.
|
inline |
Set the near/far z-clipping plane.
|
inline |
Set the eye position.
|
inline |
Set the distance to the far clipping plane.
|
inline |
Set the field of view (FOV), in degrees.
|
inline |
Set the look-at point.
|
inline |
Enable or disable movement from user input.
|
inline |
Set the movement speed (in world units)
|
inline |
Set the distance to the near clipping plane.
|
inline |
Set the pitch angle, in radians.
|
inline |
Set the roll angle, in radians.
|
inline |
Set the yaw/pitch/roll angles, in radians.
|
inline |
Set the yaw angle, in radians.
void glCamera::StoreDefaults | ( | ) |
Store the current configuration as defaults.
class glDisplay |
OpenGL display window and image/video renderer with CUDA interoperability.
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 | |
glWidget * | AddWidget (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... | |
glWidget * | GetWidget (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... | |
glWidget * | FindWidget (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 URI & | GetResource () const |
Return the resource URI of the stream. More... | |
const videoOptions & | GetOptions () 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... | |
videoOutput * | GetOutput (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 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) |
Create a new OpenGL display window with the specified options. More... | |
static glDisplay * | Create (const videoOptions &options) |
Create a new OpenGL display window with the specified options. More... | |
Static Public Member Functions inherited from videoOutput | |
static videoOutput * | Create (const videoOptions &options) |
Create videoOutput interface from a videoOptions struct that's already been filled out. More... | |
static videoOutput * | Create (const char *URI, const videoOptions &options=videoOptions()) |
Create videoOutput interface from a resource URI string and optional videoOptions. More... | |
static videoOutput * | Create (const char *URI, const commandLine &cmdLine) |
Create videoOutput interface from a resource URI string and parsing command line arguments. More... | |
static videoOutput * | Create (const char *URI, const int argc, char **argv) |
Create videoOutput interface from a resource URI string and parsing command line arguments. More... | |
static videoOutput * | Create (const int argc, char **argv, int positionArg=-1) |
Create videoOutput interface by parsing command line arguments, including the resource URI. More... | |
static videoOutput * | Create (const commandLine &cmdLine, int positionArg=-1) |
Create videoOutput interface by parsing command line arguments, including the resource URI. More... | |
static videoOutput * | CreateNullOutput () |
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 () |
glTexture * | allocTexture (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< eventHandler > | mEventHandlers |
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... | |
enum glDisplay::DragMode |
Drag behavior enum.
glDisplay::~glDisplay | ( | ) |
Destroy window.
|
protected |
|
protected |
void glDisplay::AddEventHandler | ( | glEventHandler | callback, |
void * | user = NULL |
||
) |
Register an event message handler that will be called by ProcessEvents()
callback | function pointer to the event message handler callback |
user | optional user-specified pointer that will be passed to all invocations of this event handler (typically an object) |
Add a widget to the window that recieves events and is rendered.
|
protected |
void glDisplay::BeginRender | ( | bool | processEvents = true | ) |
Clear window and begin rendering a frame.
If processEvents is true, ProcessEvents() will automatically be called.
|
static |
Create a new OpenGL display window with the specified options.
title | window title bar string, or NULL for a default title |
width | desired width of the window, or -1 to be maximized |
height | desired height of the window, or -1 to be maximized |
r | default background RGBA color, red component (0.0-1.0f) |
g | default background RGBA color, green component (0.0-1.0f) |
b | default background RGBA color, blue component (0.0-1.0f) |
a | default background RGBA color, alpha component (0.0-1.0f) |
|
static |
Create a new OpenGL display window with the specified options.
|
protected |
void glDisplay::EndRender | ( | ) |
Finish rendering and refresh / flip the backbuffer.
glWidget* glDisplay::FindWidget | ( | int | x, |
int | y | ||
) |
Find first widget by coordinate, or NULL if no widget overlaps with that coordinate.
std::vector<glWidget*> glDisplay::FindWidgets | ( | int | x, |
int | y | ||
) |
Find all widgets by coordinate, or NULL if no widget overlaps with that coordinate.
void glDisplay::GetBackgroundColor | ( | float * | r, |
float * | g, | ||
float * | b, | ||
float * | a = NULL |
||
) |
Retrieve the window's background color.
bool glDisplay::GetDragCoords | ( | int * | x1, |
int * | y1, | ||
int * | x2, | ||
int * | y2 | ||
) |
Get the current dragging coordinates, or return false if not dragging.
|
inline |
Get the dragging behavior mode.
bool glDisplay::GetDragRect | ( | int * | x, |
int * | y, | ||
int * | width, | ||
int * | height | ||
) |
Get the current dragging rectangle, or return false if not dragging.
|
inline |
Get the average frame time (in milliseconds).
|
inline |
Get the ID of this display instance into glGetDisplay()
|
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.
key | the 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. |
|
inline |
Get the mouse button state.
button | the button number, starting with 1. In X11, the left mouse button is 1. Here are the mouse button numbers: |
2 MOUSE_MIDDLE (middle button / scroll wheel button)
|
inline |
Get the mouse position.
|
inline |
Get the mouse position.
|
inline |
Retrieve the number of widgets.
|
inlinevirtual |
Return the interface type (glDisplay::Type)
Reimplemented from videoOutput.
|
inline |
Retrieve a widget.
int glDisplay::GetWidgetIndex | ( | const glWidget * | widget | ) | const |
Retrieve the index of a widget (or -1 if not found)
|
protected |
|
protected |
|
inline |
Returns true if the window has been closed.
|
inline |
Is the mouse currently dragging in the specified mode?
bool glDisplay::IsFullscreen | ( | ) |
Determine if the window is fullscreen or not.
bool glDisplay::IsMaximized | ( | ) |
Determine if the window is maximized or not.
|
inline |
Returns true if the window is open.
|
inline |
Returns true if between BeginRender() and EndRender()
|
staticprotected |
|
virtual |
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.
void glDisplay::RemoveAllWidgets | ( | bool | deleteWidgets = true | ) |
Remove all widgets from the window (and optionally delete them)
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.
void glDisplay::RemoveWidget | ( | glWidget * | widget, |
bool | deleteWidget = true |
||
) |
Remove a widget from the window (and optionally delete it)
void glDisplay::RemoveWidget | ( | uint32_t | index, |
bool | deleteWidget = true |
||
) |
Remove a widget from the window (and optionally delete it)
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.
void glDisplay::Render | ( | glTexture * | texture, |
float | x = 5.0f , |
||
float | y = 30.0f |
||
) |
|
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.
|
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.
Reimplemented from videoOutput.
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
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.
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
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
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.
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.
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.
void glDisplay::ResetCursor | ( | ) |
Reset the mouse cursor back to it's default.
The default mouse cursor is defined by SetDefaultCursor().
void glDisplay::ResetDefaultCursor | ( | bool | activate = true | ) |
Reset the default cursor back to it's original, the arrow.
activate | if 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. |
void glDisplay::ResetViewport | ( | ) |
Reset to the full viewport (and change back GL_PROJECTION)
void glDisplay::SetBackgroundColor | ( | float | r, |
float | g, | ||
float | b, | ||
float | a = 1.0f |
||
) |
Set the window's background color.
r | background RGBA color, red component (0.0-1.0f) |
g | background RGBA color, green component (0.0-1.0f) |
b | background RGBA color, blue component (0.0-1.0f) |
a | background RGBA color, alpha component (0.0-1.0f) |
void glDisplay::SetCursor | ( | uint32_t | cursor | ) |
Set the active mouse cursor.
cursor | one of the cursor ID's from X11/cursorfont.h |
void glDisplay::SetDefaultCursor | ( | uint32_t | cursor, |
bool | activate = true |
||
) |
Set the default mouse cursor that gets used by ResetCursor()
cursor | one of the cursor ID's from X11/cursorfont.h . This will be the default cursor that gets set when ResetCursor() is called. |
activate | if 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. |
|
inline |
Set the dragging behavior mode.
void glDisplay::SetFullscreen | ( | bool | fullscreen | ) |
Set the window to fullscreen mode or not.
void glDisplay::SetMaximized | ( | bool | maximized | ) |
Maximize or un-maximize the window.
void glDisplay::SetSize | ( | uint32_t | width, |
uint32_t | height | ||
) |
Set the window's size.
width | the desired width of the window, in pixels. |
height | the desired height of the window, in pixels. |
|
virtual |
Set the window title string.
Reimplemented from videoOutput.
void glDisplay::SetTitle | ( | const char * | str | ) |
Set the window title string.
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()
|
static |
Default title bar name.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
static |
Unique type identifier of glDisplay class.
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 glTexture * | Create (uint32_t width, uint32_t height, uint32_t format, void *data=NULL) |
Allocate an OpenGL texture. More... | |
glTexture::~glTexture | ( | ) |
Free the texture.
bool glTexture::Bind | ( | ) |
Activate using the texture.
bool glTexture::Copy | ( | void * | ptr, |
uint32_t | flags | ||
) |
Copy entire contents of the texture to/from CPU or CUDA memory.
ptr | the memory pointer to copy to/from, either in CPU or CUDA address space depending on flags. It's assumed that the size of the memory from this pointer is equal to GetSize(), and the entire contents of the buffer will be copied. |
flags | should be one of the following:
|
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.
ptr | the memory buffer to copy to/from, either in CPU or CUDA address space depending on flags |
offset | the offset into the OpenGL buffer to copy. It is assumed any offset to the CPU/CUDA pointer argument has already been applied. |
size | the number of bytes to copy |
flags | should be one of the following:
|
bool glTexture::Copy | ( | void * | ptr, |
uint32_t | size, | ||
uint32_t | flags | ||
) |
Copy contents of the texture to/from CPU or CUDA memory.
ptr | the memory pointer to copy to/from, either in CPU or CUDA address space depending on flags. |
size | the number of bytes to copy |
flags | should be one of the following:
|
|
static |
Allocate an OpenGL texture.
width | the width of the texture in pixels |
height | the height of the texture in pixels |
format | GL_RGBA8, GL_RGBA32F, ect. |
data | initialize the texture's memory with this CPU pointer, size is width*height*bpp |
|
inline |
Retrieve the texture's format (e.g.
GL_RGBA8, GL_RGBA32F, ect.)
|
inline |
Retrieve the height in pixels of the texture.
|
inline |
Retrieve the OpenGL resource handle of the texture.
|
inline |
Retrieve the size in bytes of the texture.
|
inline |
Retrieve the width in pixels of the texture.
void* glTexture::Map | ( | uint32_t | device, |
uint32_t | flags | ||
) |
Map the texture for accessing from the CPU or CUDA.
device | either GL_MAP_CPU or GL_MAP_CUDA |
flags | should be one of the following:
|
void glTexture::Render | ( | const float4 & | rect | ) |
Render the texture to the specific screen rectangle.
void glTexture::Render | ( | float | x, |
float | y | ||
) |
Render the texture at the specified window coordinates.
void glTexture::Render | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) |
Render the texture with the specified position and size.
void glTexture::Unbind | ( | ) |
Deactivate using the texture.
void glTexture::Unmap | ( | ) |
Unmap the texture from CPU/CUDA access.
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... | |
glDisplay * | GetDisplay () 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 |
glDisplay * | mDisplay |
DragState | mDragState |
std::vector< eventHandler > | mEventHandlers |
Friends | |
class | glDisplay |
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 (
Event message handlers should return true
if the message was handled, or false
if the message was skipped or not handled.
|
protected |
enum glWidget::Shape |
|
virtual |
Destructor.
void glWidget::AddEventHandler | ( | glWidgetEventHandler | callback, |
void * | user = NULL |
||
) |
Register an event message handler the widget will send events to.
callback | function pointer to the event message handler callback |
user | optional user-specified pointer that will be passed to all invocations of this event handler (typically an object) |
bool glWidget::Contains | ( | float | x, |
float | y | ||
) | const |
Test if the point is inside the widget.
|
protected |
|
protected |
|
inline |
Get the bounding coordinates of the widget.
|
inline |
Get the root window of the widget.
int glWidget::GetIndex | ( | ) | const |
Get the index of the widget in the window (or -1 if none)
|
inline |
Get position of widget in global window coordinates.
|
inline |
Get the shape.
|
inline |
Get the widget's size.
|
inline |
Retrieve user data.
void glWidget::GlobalToLocal | ( | float | x, |
float | y, | ||
float * | x_out, | ||
float * | y_out | ||
) | const |
Convert from global window coordinates to local widget offset.
|
inline |
Get the widget's height.
|
protected |
|
inline |
Is the widget moveable/draggable by the user?
|
inline |
Is the widget resizeable by the user?
|
inline |
Is the widget selected?
|
inline |
Is the widget visible.
void glWidget::LocalToGlobal | ( | float | x, |
float | y, | ||
float * | x_out, | ||
float * | y_out | ||
) | const |
Convert from local widget offset to global window coordinates.
|
inline |
Move the widget's position by the specified offset.
bool glWidget::OnEvent | ( | uint16_t | event, |
int | a, | ||
int | b, | ||
void * | user | ||
) |
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.
void glWidget::Render | ( | ) |
Render (automatically called by parent)
|
inline |
Set the bounding coordinates of the widget.
|
protected |
|
protected |
|
inline |
Set fill alpha.
|
inline |
Set fill color.
|
inline |
Set the widget's height.
|
inline |
Set outline alpha.
|
inline |
Set outline color.
|
inline |
Set outline width.
|
inline |
Toggle if the user can move/drag the widget.
|
inline |
Set position of widget in global window coordinates.
|
inline |
Toggle if the user can resize the widget.
|
inline |
Select/de-select the widget.
|
inline |
Set selected fill color.
|
inline |
Set selected outline color.
|
inline |
Set the shape.
|
inline |
Set the widget's size.
|
inline |
Set user-defined data.
|
inline |
Show/hide the widget.
|
inline |
Set the widget's width.
|
inline |
Set the widget's X coordinate.
|
inline |
Set the widget's Y coordinate.
|
inline |
Get the widget's width.
|
inline |
Get the widget's X coordinate.
|
inline |
Get the widget's Y coordinate.
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
#define GL | ( | x | ) | { x; glCheckError( #x, __FILE__, __LINE__ ); } |
OpenGL error-checking macro.
#define GL_CHECK | ( | msg | ) | { glCheckError(msg, __FILE__, __LINE__); } |
Print a message on OpenGL error.
#define GL_FROM_CPU 0x3 |
Copy the buffer from CPU to OpenGL.
#define GL_FROM_CUDA 0x4 |
Copy the buffer from CUDA to OpenGL.
#define GL_INDEX_BUFFER GL_ELEMENT_ARRAY_BUFFER |
Alias for index buffers.
#define GL_MAP_CPU 0x1 |
Map the buffer to CPU address space.
#define GL_MAP_CUDA 0x2 |
Map the buffer to CUDA address space.
#define GL_READ_ONLY GL_READ_ONLY_ARB |
Map the buffer with read-only access.
#define GL_READ_WRITE GL_READ_WRITE_ARB |
Map the buffer with read/write access.
#define GL_RGB32F GL_RGB32F_ARB |
Alias for GL_RGB32F.
#define GL_RGBA32F GL_RGBA32F_ARB |
Alias for GL_RGBA32F.
#define GL_TO_CPU 0x5 |
Copy the buffer to CPU from OpenGL.
#define GL_TO_CUDA 0x6 |
Copy the buffer to CUDA from OpenGL.
#define GL_VERIFY | ( | x | ) | { x; if(glCheckError( #x, __FILE__, __LINE__ )) return false; } |
Return false on OpenGL error.
#define GL_VERIFYN | ( | x | ) | { x; if(glCheckError( #x, __FILE__, __LINE__ )) return NULL; } |
OpenGL NULL on OpenGL error.
#define GL_VERTEX_BUFFER GL_ARRAY_BUFFER |
Alias for vertex buffers.
#define GL_WRITE_DISCARD (GL_READ_WRITE + 0xff) |
Map the buffer as write-only and discard previous contents.
#define GL_WRITE_ONLY GL_WRITE_ONLY_ARB |
Map the buffer with write-only access.
#define KEY_PRESSED 1 |
Define for KEY_STATE and KEY_RAW events when key is pressed.
#define KEY_RELEASED 0 |
Define for KEY_STATE and KEY_RAW events when key is released.
#define LOG_GL "[OpenGL] " |
OpenGL logging prefix.
#define MOUSE_LEFT 1 |
Define for the left mouse button number.
#define MOUSE_MIDDLE 2 |
Define for the middle mouse button (or scroll wheel button)
#define MOUSE_PRESSED 1 |
Define for MOUSE_BUTTON event when button is pressed.
#define MOUSE_RELEASED 0 |
Define for MOUSE_BUTTON event when button is released.
#define MOUSE_RIGHT 3 |
Define for the right mouse button number.
#define MOUSE_WHEEL_DOWN 5 |
Define for the mouse wheel scroll down button number.
#define MOUSE_WHEEL_UP 4 |
Define for the mouse wheel scroll up button number.
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.
enum 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()
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
|
MOUSE_ABSOLUTE | Message when the mouse has moved (absolute coordinates) a = x position, in absolute screen coordinates b = y position, in absolute screen coordinates
|
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)
|
MOUSE_DRAG | Message when the left mouse button has been dragged. a = x delta (change in position) b = y delta (change in position)
|
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)
|
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)
|
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()
|
WIDGET_SELECTED | Message indicating that a widget has been selected (e.g. from dragging) a = widget index into glDisplay::GetWidget() or glWidget::GetIndex()
|
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
|
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
|
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) |
|
inline |
OpenGL error check + logging.
|
inline |
OpenGL error-checking messsage function.
|
inline |
Render a line in screen coordinates with the specified color.
|
inline |
Render the outline of a rect in screen coordinates with the specified color.
|
inline |
Render a filled rect in screen coordinates with the specified color.
glDisplay* glGetDisplay | ( | uint32_t | display = 0 | ) |
Retrieve a display window object.
uint32_t glGetNumDisplays | ( | ) |
Return the number of created glDisplay windows.
|
inline |
Print the amount of free GPU memory.