Jetson Inference
DNN Vision Library
glDisplay Class Reference

OpenGL display window / video viewer. More...

#include <glDisplay.h>

Public Member Functions

 ~glDisplay ()
 Destroy window. More...
 
void BeginRender (bool userEvents=true)
 Clear window and begin rendering a frame. More...
 
void EndRender ()
 Finish rendering and refresh / flip the backbuffer. More...
 
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=5.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...
 
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...
 
void UserEvents ()
 Process UI events. More...
 
void onEvent (uint msg, int a, int b)
 UI event handler. More...
 
bool IsOpen () const
 Returns true if the window is open. More...
 
bool IsClosed () const
 Returns true if the window has been closed. More...
 
float GetFPS () const
 Get the average frame time (in milliseconds). More...
 
uint32_t GetWidth () const
 Get the width of the window (in pixels) More...
 
uint32_t GetHeight () const
 Get the height of the window (in pixels) More...
 
void SetTitle (const char *str)
 Set the window title string. More...
 
void SetBackgroundColor (float r, float g, float b, float a)
 Set the background color. More...
 

Static Public Member Functions

static glDisplayCreate (float r=0.05f, float g=0.05f, float b=0.05f, float a=1.0f)
 Create a new maximized openGL display window. More...
 
static glDisplayCreate (const char *title, float r=0.05f, float g=0.05f, float b=0.05f, float a=1.0f)
 Create a new maximized openGL display window. More...
 

Static Public Attributes

static const char * DEFAULT_TITLE
 Default title bar name. More...
 

Protected Member Functions

 glDisplay ()
 
bool initWindow ()
 
bool initGL ()
 

Protected Attributes

Display * mDisplayX
 
Screen * mScreenX
 
XVisualInfo * mVisualX
 
Window mWindowX
 
GLXContext mContextGL
 
glTexturemInteropTex
 
bool mWindowClosed
 
Atom mWindowClosedMsg
 
uint32_t mWidth
 
uint32_t mHeight
 
timespec mLastTime
 
float mAvgTime
 
float mBgColor [4]
 

Static Protected Attributes

static const int screenIdx = 0
 

Detailed Description

OpenGL display window / video viewer.

Constructor & Destructor Documentation

◆ ~glDisplay()

glDisplay::~glDisplay ( )

Destroy window.

◆ glDisplay()

glDisplay::glDisplay ( )
protected

Member Function Documentation

◆ BeginRender()

void glDisplay::BeginRender ( bool  userEvents = true)

Clear window and begin rendering a frame.

If userEvents is true, UserEvents() will automatically be processed.

◆ Create() [1/2]

static glDisplay* glDisplay::Create ( float  r = 0.05f,
float  g = 0.05f,
float  b = 0.05f,
float  a = 1.0f 
)
static

Create a new maximized openGL display window.

Parameters
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 char *  title,
float  r = 0.05f,
float  g = 0.05f,
float  b = 0.05f,
float  a = 1.0f 
)
static

Create a new maximized openGL display window.

Parameters
titlewindow title bar label string
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)

◆ EndRender()

void glDisplay::EndRender ( )

Finish rendering and refresh / flip the backbuffer.

◆ GetFPS()

float glDisplay::GetFPS ( ) const
inline

Get the average frame time (in milliseconds).

◆ GetHeight()

uint32_t glDisplay::GetHeight ( ) const
inline

Get the height of the window (in pixels)

◆ GetWidth()

uint32_t glDisplay::GetWidth ( ) const
inline

Get the width of the window (in pixels)

◆ initGL()

bool glDisplay::initGL ( )
protected

◆ initWindow()

bool glDisplay::initWindow ( )
protected

◆ IsClosed()

bool glDisplay::IsClosed ( ) const
inline

Returns true if the window has been closed.

◆ IsOpen()

bool glDisplay::IsOpen ( ) const
inline

Returns true if the window is open.

◆ onEvent()

void glDisplay::onEvent ( uint  msg,
int  a,
int  b 
)

UI event handler.

◆ Render() [1/2]

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() [2/2]

void glDisplay::Render ( float *  image,
uint32_t  width,
uint32_t  height,
float  x = 5.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.

◆ RenderOnce()

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

◆ SetBackgroundColor()

void glDisplay::SetBackgroundColor ( float  r,
float  g,
float  b,
float  a 
)
inline

Set the 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)

◆ SetTitle()

void glDisplay::SetTitle ( const char *  str)

Set the window title string.

◆ UserEvents()

void glDisplay::UserEvents ( )

Process UI events.

Member Data Documentation

◆ DEFAULT_TITLE

const char* glDisplay::DEFAULT_TITLE
static

Default title bar name.

◆ mAvgTime

float glDisplay::mAvgTime
protected

◆ mBgColor

float glDisplay::mBgColor[4]
protected

◆ mContextGL

GLXContext glDisplay::mContextGL
protected

◆ mDisplayX

Display* glDisplay::mDisplayX
protected

◆ mHeight

uint32_t glDisplay::mHeight
protected

◆ mInteropTex

glTexture* glDisplay::mInteropTex
protected

◆ mLastTime

timespec glDisplay::mLastTime
protected

◆ mScreenX

Screen* glDisplay::mScreenX
protected

◆ mVisualX

XVisualInfo* glDisplay::mVisualX
protected

◆ mWidth

uint32_t glDisplay::mWidth
protected

◆ mWindowClosed

bool glDisplay::mWindowClosed
protected

◆ mWindowClosedMsg

Atom glDisplay::mWindowClosedMsg
protected

◆ mWindowX

Window glDisplay::mWindowX
protected

◆ screenIdx

const int glDisplay::screenIdx = 0
staticprotected

The documentation for this class was generated from the following file: