Radium Engine  1.5.20
Loading...
Searching...
No Matches
CLIViewer.hpp
1#pragma once
2
3#include <Core/Tasks/TaskQueue.hpp>
4#include <Headless/CLIBaseApplication.hpp>
5#include <Headless/OpenGLContext/OpenGLContext.hpp>
6
7#include <Core/Utils/Index.hpp>
8
9#include <functional>
10
11#include <glbinding/Version.h>
12
13namespace Ra {
14namespace Core {
15namespace Asset {
16class FileLoaderInterface;
17class Camera;
18} // namespace Asset
19} // namespace Core
20
21namespace Engine {
22class RadiumEngine;
23namespace Rendering {
24class Renderer;
25}
26} // namespace Engine
27
28namespace Headless {
29
37class HEADLESS_API CLIRadiumEngineApp : public CLIBaseApplication
38{
39 public:
46 virtual ~CLIRadiumEngineApp();
47
49 const Engine::RadiumEngine* getEngine() const { return m_engine; }
50
66 int init( int argc, const char* argv[] ) override;
67
71 void openGlAddOns( std::function<void()> f );
72
74 void bindOpenGLContext( bool on = true );
75
76 // private:
77 protected:
80
82 bool m_engineInitialized { false };
83
86};
87
88class HEADLESS_API CLIViewer : public CLIRadiumEngineApp
89{
90 public:
91 struct ViewerParameters {
93 bool m_animationEnable { false };
95 std::array<int, 2> m_size { { 512, 512 } };
97 std::string m_imgPrefix { "frame" };
99 std::string m_dataFile = { "" };
100 };
101
102 public:
107 explicit CLIViewer( std::unique_ptr<OpenGLContext> context );
109 virtual ~CLIViewer();
110
126 int init( int argc, const char* argv[] ) override;
127
135 int oneFrame( float timeStep = 1.f / 60.f );
136
141 void setRenderer( Ra::Engine::Rendering::Renderer* renderer );
142
146 void addDataFileLoader( Ra::Core::Asset::FileLoaderInterface* loader );
147
152 void loadScene();
153
157 void compileScene();
158
165 Ra::Core::Utils::Index setCamera( Ra::Core::Utils::Index camIdx = 0 );
166
168 void setImageNamePrefix( std::string s );
169
171 const ViewerParameters& getCommandLineParameters() const;
172
174 std::unique_ptr<unsigned char[]> grabFrame( size_t& w, size_t& h ) const;
175
177 void showWindow( bool on = true,
178 OpenGLContext::EventMode mode = OpenGLContext::EventMode::POLL,
179 float delay = 1.f / 60.f );
180
188 inline OpenGLContext& getWindow();
189
191 void renderLoop( std::function<void( float )> render );
192
196 inline std::string getDataFileName() const;
197
201 inline void setDataFileName( std::string filename );
202
203 protected:
205 void resize( int width, int height );
206
207 private:
210
212 Ra::Core::Asset::Camera* m_camera { nullptr };
213
215 ViewerParameters m_parameters;
216
218 bool m_exposedWindow { false };
219};
220
221inline std::string CLIViewer::getDataFileName() const {
222 return m_parameters.m_dataFile;
223}
224
225inline void CLIViewer::setDataFileName( std::string filename ) {
226 m_parameters.m_dataFile = std::move( filename );
227}
228
229inline OpenGLContext& CLIViewer::getWindow() {
230 return *m_glContext;
231}
232
233} // namespace Headless
234} // namespace Ra
Camera class storing the Camera frame and the projection properties The view direction is -z in camer...
Definition Camera.hpp:16
Ra::Engine::RadiumEngine * m_engine
Instance of the radium engine.
Definition CLIViewer.hpp:85
std::unique_ptr< OpenGLContext > m_glContext
Headless OpenGLContext.
Definition CLIViewer.hpp:79
const Engine::RadiumEngine * getEngine() const
To have the same API to access Engine than in Qt based application.
Definition CLIViewer.hpp:49
T move(T... args)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3