forked from lquatrin/cpp_volume_rendering
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathrenderingmanager.h
More file actions
171 lines (128 loc) · 4.06 KB
/
renderingmanager.h
File metadata and controls
171 lines (128 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**
* Rendering Manager for Volume Rendering
*
* https://www.cg.tuwien.ac.at/research/vis/datasets/
**/
#ifndef RENDERING_MANAGER_H
#define RENDERING_MANAGER_H
#include "defines.h"
#include <gl_utils/arrayobject.h>
#include <gl_utils/pipelineshader.h>
#include <vis_utils/camera.h>
#include <glm/glm.hpp>
#include <vector>
#include <fstream>
#include <volvis_utils/datamanager.h>
#include <volvis_utils/renderingparameters.h>
#include <volvis_utils/camerastatelist.h>
#include <volvis_utils/lightsourcelist.h>
#include "utils/parameterspace.h"
class BaseVolumeRenderer;
class RenderingManager
{
public:
typedef void(*SwapBufferFunc) (void* data);
SwapBufferFunc f_swapbuffer;
void* d_swapbuffer;
typedef void(*RenderFunc) (void* data);
RenderFunc f_render[4];
/*! Returns the current instance of Viewer (lazy instantiation).
*/
static RenderingManager *Instance ();
/*! Verify if already exists an instance of the Viewer.
\return exist or not exist (true or false)
*/
static bool Exists ();
/*! Just Destroy the instance of the singleton.
*/
static void DestroyInstance ();
void InitGL ();
void InitData ();
void AddVolumeRenderer (BaseVolumeRenderer* volrend);
void Display ();
void Reshape (int w, int h);
void Keyboard (unsigned char key, int x, int y);
void KeyboardUp (unsigned char key, int x, int y);
void MouseButton (int bt, int st, int x, int y);
void MouseMotion (int x, int y);
void MouseWheel(int wheel, int direction, int x, int y);
void CloseFunc ();
void IdleFunc ();
void PostRedisplay ();
// Update the volume renderer with the current volume and transfer function
void UpdateDataAndResetCurrentVRMode ();
unsigned int GetScreenWidth ()
{
return curr_rdr_parameters.GetScreenWidth();
}
unsigned int GetScreenHeight ()
{
return curr_rdr_parameters.GetScreenHeight();
}
bool IdleRendering ()
{
return m_idle_rendering;
}
protected:
private:
void SaveScreenshot (std::string filename = "");
void UpdateLightSourceCameraVectors ();
void ResetGLStateConfig ();
std::string AddAbreviationName (std::string filename, std::string extension = ".png");
bool GenerateImgFile (std::string out_str, int w, int h, unsigned char *gl_data, bool alpha = true, std::string image_type = "PNG");
GLubyte* GetFrontBufferPixelData (bool alpha = true);
// Go to previous renderer
bool PreviousRenderer ();
// Go to next renderer
bool NextRenderer ();
// Set current volume renderer
void SetCurrentVolumeRenderer ();
int m_current_vr_method_id;
BaseVolumeRenderer* curr_vol_renderer;
std::vector<BaseVolumeRenderer*> m_vtr_vr_methods;
std::vector<std::string> m_vtr_vr_ui_names;
vis::RenderingParameters curr_rdr_parameters;
std::vector<std::string> m_std_cam_state_names;
int m_current_camera_state_id;
vis::CameraStateList m_camera_state_list;
std::vector<std::string> m_std_lsource_names;
int m_current_lightsource_data_id;
vis::LightSourceList m_light_source_list;
vis::DataManager m_data_mgr;
bool animate_camera_rotation;
ParameterSpace m_eval_paramspace;
bool m_eval_running;
int m_eval_numframes;
int m_eval_currframe;
int m_eval_currsample;
double m_eval_lasttime;
std::string m_eval_basedirectory;
std::string m_eval_imgdirectory;
std::ofstream m_eval_csvfile;
void SetImGuiInterface ();
void DrawImGuiInterface ();
void UpdateFrameRate ();
bool m_imgui_render_ui;
bool m_imgui_render_manager;
bool m_idle_rendering;
bool m_vsync;
double m_ts_current_time;
double m_ts_last_time;
int m_ts_n_frames;
double m_ts_window_fps;
double m_ts_window_ms;
bool m_imgui_data_window;
bool m_imgui_renderer_window;
std::vector<glm::vec4> s_ref_image;
static void SingleSampleRender (void* data);
static void MultiSampleRender (void* data);
static void DownScalingRender (void* data);
static void UpScalingRender (void* data);
/*! Constructor.*/
RenderingManager ();
/*! Destructor.*/
virtual ~RenderingManager ();
/*! The pointer to the singleton instance.*/
static RenderingManager* crr_instance;
};
#endif