Loading [MathJax]/extensions/TeX/AMSsymbols.js
Radium Engine  1.5.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Ra::Headless::CLIViewer Class Reference

#include <Headless/CLIViewer.hpp>

+ Inheritance diagram for Ra::Headless::CLIViewer:
+ Collaboration diagram for Ra::Headless::CLIViewer:

Public Member Functions

const Engine::RadiumEnginegetEngine () const
 To have the same API to access Engine than in Qt based application.
 
 CLIViewer (std::unique_ptr< OpenGLContext > context)
 Construct the viewer using an OpenGL context of the given version. More...
 
virtual ~CLIViewer ()
 Base destructor.
 
int init (int argc, const char *argv[]) override
 Application initialization method. More...
 
int oneFrame (float timeStep=1.f/60.f)
 
void setRenderer (Ra::Engine::Rendering::Renderer *renderer)
 
void addDataFileLoader (Ra::Core::Asset::FileLoaderInterface *loader)
 
void loadScene ()
 
void compileScene ()
 
void openGlAddOns (std::function< void()> f)
 
void bindOpenGLContext (bool on=true)
 
void setCamera (Ra::Core::Utils::Index camIdx=0)
 
void setImageNamePrefix (std::string s)
 
const ViewerParameters & getCommandLineParameters () const
 
std::unique_ptr< unsigned char[]> grabFrame (size_t &w, size_t &h) const
 
void showWindow (bool on=true, OpenGLContext::EventMode mode=OpenGLContext::EventMode::POLL, float delay=1.f/60.f)
 
OpenGLContextgetWindow ()
 Gives access to the window to add event processing callbacks. More...
 
void renderLoop (std::function< void(float)> render)
 
std::string getDataFileName () const
 
void setDataFileName (std::string filename)
 
- Public Member Functions inherited from Ra::Headless::CLIBaseApplication
 CLIBaseApplication ()=default
 Base constructor.
 
virtual ~CLIBaseApplication ()=default
 Base destructor.
 
template<typename... Args>
CLI::Option * addOption (Args &&... args)
 
template<typename... Args>
CLI::Option * addFlag (Args &&... args)
 

Public Attributes

Ra::Engine::RadiumEnginem_engine
 Instance of the radium engine.
 

Protected Member Functions

void resize (int width, int height)
 Observer of the resize event on the OpenGLContext.
 

Additional Inherited Members

- Protected Attributes inherited from Ra::Headless::CLIBaseApplication
CLI::App m_cmdLineParser
 

Detailed Description

Base class for radium based cmdline application.

This is the Headless pendant of the Ra::Gui::Viewer class, with only a very little interaction capabilities.

Definition at line 34 of file CLIViewer.hpp.

Constructor & Destructor Documentation

◆ CLIViewer()

Ra::Headless::CLIViewer::CLIViewer ( std::unique_ptr< OpenGLContext context)
explicit

Construct the viewer using an OpenGL context of the given version.

Parameters
glVersion

Definition at line 23 of file CLIViewer.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ addDataFileLoader()

void Ra::Headless::CLIViewer::addDataFileLoader ( Ra::Core::Asset::FileLoaderInterface *  loader)

Add a data loader to the engine

Definition at line 129 of file CLIViewer.cpp.

+ Here is the call graph for this function:

◆ bindOpenGLContext()

void Ra::Headless::CLIViewer::bindOpenGLContext ( bool  on = true)

Activate/deactivate the OpenGL context

Definition at line 156 of file CLIViewer.cpp.

◆ compileScene()

void Ra::Headless::CLIViewer::compileScene ( )

Instantiate the scene and prepare the rendering. This method prepare all render techniques for the active renderer.

Definition at line 137 of file CLIViewer.cpp.

+ Here is the call graph for this function:

◆ getCommandLineParameters()

const CLIViewer::ViewerParameters & Ra::Headless::CLIViewer::getCommandLineParameters ( ) const

Get the current viewer command line parameters parameters

Definition at line 42 of file CLIViewer.cpp.

◆ getDataFileName()

std::string Ra::Headless::CLIViewer::getDataFileName ( ) const
inline

Get the filename given using the option –file <filename> or -f <filename>

Definition at line 185 of file CLIViewer.hpp.

◆ getWindow()

OpenGLContext & Ra::Headless::CLIViewer::getWindow ( )
inline

Gives access to the window to add event processing callbacks.

example :

idListener = getWindow().mouseListener.attach( mouseEventProcessingFunction );
int attach(Observer observer)
Definition: Observable.hpp:54
OpenGLContext & getWindow()
Gives access to the window to add event processing callbacks.
Definition: CLIViewer.hpp:193
Ra::Core::Utils::Observable< int, int, int, int, int > & mouseListener()

Definition at line 193 of file CLIViewer.hpp.

◆ grabFrame()

std::unique_ptr< unsigned char[]> Ra::Headless::CLIViewer::grabFrame ( size_t &  w,
size_t &  h 
) const

grab the last rendered frame

Definition at line 116 of file CLIViewer.cpp.

◆ init()

int Ra::Headless::CLIViewer::init ( int  argc,
const char *  argv[] 
)
overridevirtual

Application initialization method.

This method is called by the main function to initialize the app giving its parameters.

Parameters
argcnumber of parameter
argvarray of string representing the parameters
Returns
0 if the application is correctly initialized or an application dependant error code if something went wrong.

Supported command line parameters are –help and –file <filename> from CLIRadiumApplication and the following parameters :

  • –size <width x height> : the size of the rendered picture
  • –animation : load the Radium animation system
  • –env <env_map> : load and use the given environment map.

Reimplemented from Ra::Headless::CLIBaseApplication.

Definition at line 46 of file CLIViewer.cpp.

+ Here is the call graph for this function:

◆ loadScene()

void Ra::Headless::CLIViewer::loadScene ( )

Loads the scene from the datafile given at the command line or set using setDataFileName using the available loader (if any).

Definition at line 133 of file CLIViewer.cpp.

+ Here is the call graph for this function:

◆ oneFrame()

int Ra::Headless::CLIViewer::oneFrame ( float  timeStep = 1.f / 60.f)

Render one frame of the scene attached to the engine for the given time stamp.

Returns
0 if the image was correctly computed or an application dependant error code if something went wrong.

Definition at line 94 of file CLIViewer.cpp.

+ Here is the call graph for this function:

◆ openGlAddOns()

void Ra::Headless::CLIViewer::openGlAddOns ( std::function< void()>  f)

Register OpenGL addons The given functor will be called with the OpenGL context bound

Definition at line 150 of file CLIViewer.cpp.

◆ renderLoop()

void Ra::Headless::CLIViewer::renderLoop ( std::function< void(float)>  render)

If a window is shown, launch the interactive render loop

Definition at line 205 of file CLIViewer.cpp.

◆ setCamera()

void Ra::Headless::CLIViewer::setCamera ( Ra::Core::Utils::Index  camIdx = 0)

Define the cq;erq to be used for rendering. This method set the camera either using default camera or using the first one (at index 0) from the engine's camera manager and

Definition at line 161 of file CLIViewer.cpp.

+ Here is the call graph for this function:

◆ setDataFileName()

void Ra::Headless::CLIViewer::setDataFileName ( std::string  filename)
inline

Set the filename given using the option –file <filename> or -f <filename>

Definition at line 189 of file CLIViewer.hpp.

◆ setImageNamePrefix()

void Ra::Headless::CLIViewer::setImageNamePrefix ( std::string  s)

Set the image prefix ("frame" by default)

Definition at line 192 of file CLIViewer.cpp.

◆ setRenderer()

void Ra::Headless::CLIViewer::setRenderer ( Ra::Engine::Rendering::Renderer renderer)

Set the renderer to use to compute an image The app takes ownership of the give pointer.

Definition at line 120 of file CLIViewer.cpp.

◆ showWindow()

void Ra::Headless::CLIViewer::showWindow ( bool  on = true,
OpenGLContext::EventMode  mode = OpenGLContext::EventMode::POLL,
float  delay = 1.f / 60.f 
)

show/hide the opengl window

Definition at line 196 of file CLIViewer.cpp.


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