Jetson Linux API Reference

32.7.5 Release
NvEglRenderer Class Reference

Detailed Description

NvEglRenderer is a helper class for rendering using EGL and OpenGL ES 2.0.

The renderer requires the file descriptor (FD) of a buffer as an input. The rendering rate, in frames per second (fps), is configurable.

The renderer creates an X Window of its own. The width, height, horizontal offset, and vertical offset of the window are configurable.

All EGL calls must be made through one thread only. This class internally creates a thread which performs all EGL/GL initializations, gets EGLImage objects from FD, renders the EGLImage objects, and then deinitializes all the EGL/GL structures.

Definition at line 74 of file NvEglRenderer.h.

Inheritance diagram for NvEglRenderer:
Collaboration diagram for NvEglRenderer:

Public Member Functions

 ~NvEglRenderer ()
 
int render (int fd)
 Renders a buffer. More...
 
int setFPS (float fps)
 Sets the rendering rate in frames per second (fps). More...
 
EGLDisplay getEGLDisplay ()
 Gets underlying EGLDisplay. More...
 
int setOverlayText (char *str, uint32_t x, uint32_t y)
 Sets the overlay string. More...
 
virtual int isInError ()
 Indicates whether the element encountered an error during its operation. More...
 
void getProfilingData (NvElementProfiler::NvElementProfilerData &data)
 Gets profiling data for the element. More...
 
void printProfilingStats (std::ostream &out_stream=std::cout)
 Prints profiling data for the element to an output stream. More...
 
virtual void enableProfiling ()
 Enables profiling for the element. More...
 
bool isProfilingEnabled ()
 Checks whether profiling is enabled for the element. More...
 

Static Public Member Functions

static NvEglRenderercreateEglRenderer (const char *name, uint32_t width, uint32_t height, uint32_t x_offset, uint32_t y_offset)
 Creates a new EGL-based renderer named name. More...
 
static int getDisplayResolution (uint32_t &width, uint32_t &height)
 Gets the display resolution. More...
 

Protected Attributes

int is_in_error
 Indicates if an error was encountered during the operation of the element. More...
 
const char * comp_name
 Specifies the name of the component, for debugging. More...
 
NvElementProfiler profiler
 Profiler for the element. More...
 

Constructor & Destructor Documentation

◆ ~NvEglRenderer()

NvEglRenderer::~NvEglRenderer ( )

Member Function Documentation

◆ createEglRenderer()

static NvEglRenderer* NvEglRenderer::createEglRenderer ( const char *  name,
uint32_t  width,
uint32_t  height,
uint32_t  x_offset,
uint32_t  y_offset 
)
static

Creates a new EGL-based renderer named name.

This method creates a new X window for rendering, of size width and height, that is offset by x_offset and y_offset. If width or height is zero, a full screen window is created with x_offset and y_offset set to zero.

It internally initializes EGL, creates an eglContext, an eglSurface, a GL texture, and shaders for rendering.

Parameters
[in]nameSpecifies a pointer to a unique name to identity the element instance.
[in]widthSpecifies the width of the window in pixels.
[in]heightSpecifies the height of the window in pixels.
[in]x_offsetSpecifies the horizontal offset of the window in pixels.
[in]y_offsetSpecifies the vertical offset of the window in pixels.
Returns
A reference to the newly created renderer object, otherwise NULL in case of failure during initialization.

◆ enableProfiling()

virtual void NvElement::enableProfiling ( )
virtualinherited

Enables profiling for the element.

Reimplemented in NvV4l2Element.

◆ getDisplayResolution()

static int NvEglRenderer::getDisplayResolution ( uint32_t &  width,
uint32_t &  height 
)
static

Gets the display resolution.

Parameters
[out]widthA pointer to the full screen width, in pixels.
[out]heightA pointer to the full screen height, in pixels.
Returns
0 for success, -1 otherwise.

◆ getEGLDisplay()

EGLDisplay NvEglRenderer::getEGLDisplay ( )
inline

Gets underlying EGLDisplay.

Returns
EGLDisplay handle

Definition at line 132 of file NvEglRenderer.h.

◆ getProfilingData()

void NvElement::getProfilingData ( NvElementProfiler::NvElementProfilerData data)
inherited

Gets profiling data for the element.

Returns
A constant reference to the element's profiling data.

◆ isInError()

virtual int NvElement::isInError ( )
inlinevirtualinherited

Indicates whether the element encountered an error during its operation.

Returns
0 if no error was encountered, a non-zero value if an error was encountered.

Reimplemented in NvV4l2Element.

Definition at line 72 of file NvElement.h.

References NvElement::is_in_error.

◆ isProfilingEnabled()

bool NvElement::isProfilingEnabled ( )
inherited

Checks whether profiling is enabled for the element.

Returns
Boolean value indicating if profiling is enabled.

◆ printProfilingStats()

void NvElement::printProfilingStats ( std::ostream &  out_stream = std::cout)
inherited

Prints profiling data for the element to an output stream.

Parameters
[in]out_streamOutput stream of type std::ostream to print the data to. It takes the default value std::cout if not specified.

◆ render()

int NvEglRenderer::render ( int  fd)

Renders a buffer.

This method waits until the rendering time of the next buffer, caluclated from the rendering time of the last buffer and the render rate in frames per second (fps). This is a blocking call.

Parameters
[in]fdSpecifies the file descriptor (FD) of the exported buffer to render.
Returns
0 for success, -1 otherwise.

◆ setFPS()

int NvEglRenderer::setFPS ( float  fps)

Sets the rendering rate in frames per second (fps).

Warning
An fps of zero is not allowed.
Parameters
[in]fpsSpecifies the render rate in fps.
Returns
0 for success, -1 otherwise.

◆ setOverlayText()

int NvEglRenderer::setOverlayText ( char *  str,
uint32_t  x,
uint32_t  y 
)

Sets the overlay string.

Parameters
[in]strA pointer to the overlay text.
[in]xHorizontal offset, in pixels.
[in]yVertical offset, in pixels.
Returns
0 for success, -1 otherwise.

Field Documentation

◆ comp_name

const char* NvElement::comp_name
protectedinherited

Specifies the name of the component, for debugging.

Definition at line 122 of file NvElement.h.

◆ is_in_error

int NvElement::is_in_error
protectedinherited

Indicates if an error was encountered during the operation of the element.

Definition at line 120 of file NvElement.h.

Referenced by NvElement::isInError().

◆ profiler

NvElementProfiler NvElement::profiler
protectedinherited

Profiler for the element.

Definition at line 124 of file NvElement.h.


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