forked from LuxCoreRender/LuxCore
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathluxcoreapp.h
More file actions
237 lines (188 loc) · 7.55 KB
/
Copy pathluxcoreapp.h
File metadata and controls
237 lines (188 loc) · 7.55 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/***************************************************************************
* Copyright 1998-2018 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxCoreRender. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#ifndef _LUXCOREAPP_H
#define _LUXCOREAPP_H
#include <GLFW/glfw3.h>
#include <imgui.h>
#include <luxrays/utils/utils.h>
#include <luxcore/luxcore.h>
#include "logwindow.h"
#include "statswindow.h"
#include "pixelfilterwindow.h"
#include "renderenginewindow.h"
#include "samplerwindow.h"
#include "helpwindow.h"
#include "ocldevicewindow.h"
#include "epsilonwindow.h"
#include "lightstrategywindow.h"
#include "acceleratorwindow.h"
#include "filmoutputswindow.h"
#include "filmchannelswindow.h"
#include "filmradiancegroupswindow.h"
#include "haltconditionswindow.h"
#include "importancewindow.h"
#define LA_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*_ARR)))
using luxcore::RenderConfigRPtr;
using luxcore::RenderSessionRPtr;
class LuxCoreApp {
public:
LuxCoreApp(RenderConfigRPtr & renderConfig);
~LuxCoreApp();
void RunApp(
std::shared_ptr<luxcore::RenderState> startState = nullptr,
const std::unique_ptr<luxcore::Film> & startFilm = nullptr
);
bool isGPURenderingAvailable() const { return isOpenCLAvailable || isCUDAAvailable; }
void SetRefreshInterval(int interval);
static void LogHandler(const char *msg);
static void ColoredLabelText(const ImVec4 &col, const char *label, const char *fmt, ...);
static void ColoredLabelText(const char *label, const char *fmt, ...);
static void HelpMarker(const char *desc);
static ImVec4 colLabel;
// Mouse "grab" mode. This is the natural way cameras are usually manipulated
// The flag is off by default but can be turned on by using the -m switch
bool optMouseGrabMode;
bool optFullScreen;
friend class AcceleratorWindow;
friend class EpsilonWindow;
friend class FilmChannelWindow;
friend class FilmChannelsWindow;
friend class FilmOutputWindow;
friend class FilmOutputsWindow;
friend class FilmRadianceGroupsWindow;
friend class ImageWindow;
friend class LightStrategyWindow;
friend class OCLDeviceWindow;
friend class PixelFilterWindow;
friend class RenderEngineWindow;
friend class SamplerWindow;
friend class HaltConditionsWindow;
friend class StatsWindow;
friend class UserImportancePaintWindow;
private:
typedef enum {
TOOL_CAMERA_EDIT,
TOOL_OBJECT_SELECTION,
TOOL_IMAGE_VIEW,
TOOL_USER_IMPORTANCE_PAINT
} AppToolType;
static void ToolCameraEditKeys(GLFWwindow *window, int key, int scanCode, int action, int mods);
static void GLFW_KeyCallBack(GLFWwindow *window, int key, int scanCode, int action, int mods);
static void GLFW_MouseButtonCallBack(GLFWwindow *window, int button, int action, int mods);
static void GLFW_MousePositionCallBack(GLFWwindow *window, double x, double y);
void DrawBackgroundLogo();
void UpdateMoveStep();
void SetRenderingEngineType(const std::string &engineType);
void RenderConfigParse(const std::unique_ptr<luxrays::Properties> & samplerProps);
void RenderSessionParse(const std::unique_ptr<luxrays::Properties> & samplerProps);
void AdjustFilmResolutionToWindowSize(unsigned int *filmWidth, unsigned int *filmHeight);
void SetFilmResolution(const unsigned int filmWidth, const unsigned int filmHeight);
void IncScreenRefreshInterval();
void DecScreenRefreshInterval();
void CloseAllRenderConfigEditors();
void LoadRenderConfig(const std::string &configFileName, const std::string &configFilePath);
void StartRendering(
std::shared_ptr<luxcore::RenderState> startState = nullptr,
const std::unique_ptr<luxcore::Film> & startFilm = nullptr
);
void DeleteRendering();
void RefreshRenderingTexture();
void DrawRendering();
void DrawTiles(const luxrays::Property &propCoords,
const luxrays::Property &propPasses,
const luxrays::Property &propPendingPasses,
const luxrays::Property &propErrors,
const unsigned int tileCount, const unsigned int tileWidth, const unsigned int tileHeight,
const ImU32 col);
void DrawTiles();
void DrawCaptions();
void MenuRendering();
void MenuEngine();
void MenuSampler();
void MenuCamera();
void MenuTiles();
void MenuFilm();
void MenuImagePipelines();
void MenuScreen();
void MenuTool();
void MenuWindow();
void MainMenuBar();
void BakeAllSceneObjects();
static LogWindow *currentLogWindow;
bool isOpenCLAvailable, isCUDAAvailable;
AcceleratorWindow acceleratorWindow;
EpsilonWindow epsilonWindow;
FilmChannelsWindow filmChannelsWindow;
FilmOutputsWindow filmOutputsWindow;
FilmRadianceGroupsWindow filmRadianceGroupsWindow;
LightStrategyWindow lightStrategyWindow;
OCLDeviceWindow oclDeviceWindow;
PixelFilterWindow pixelFilterWindow;
RenderEngineWindow renderEngineWindow;
SamplerWindow samplerWindow;
HaltConditionsWindow haltConditionsWindow;
StatsWindow statsWindow;
LogWindow logWindow;
HelpWindow helpWindow;
UserImportancePaintWindow userImportancePaintWindow;
RenderConfigRPtr & config;
RenderSessionRPtr session;
GLuint renderFrameBufferTexID;
GLenum renderFrameBufferTexMinFilter, renderFrameBufferTexMagFilter;
GLuint backgroundLogoTexID;
unsigned int renderImageWidth, renderImageHeight;
float *renderImageBuffer;
GLFWwindow *window;
AppToolType currentTool;
// ImGui height information
int menuBarHeight, captionHeight;
bool mouseHoverRenderingWindow;
bool popupMenuBar;
// ImGui inputs
int menuFilmWidth, menuFilmHeight;
int targetFilmWidth, targetFilmHeight;
bool optRealTimeMode;
// Used by RT modes to keep track of dropped frames (or not). '+' sign means
// dropped frames while '-' not dropped
int droppedFramesCount;
unsigned int refreshDecoupling;
// Mouse related information
float optMoveScale;
float optMoveStep;
float optRotateStep;
bool mouseButton0, mouseButton2;
double mouseGrabLastX, mouseGrabLastY;
double lastMouseUpdate;
// The index of the image pipeline to show
unsigned int imagePipelineIndex;
// Same GUI loop statistic
double guiLoopTimeShortAvg, guiLoopTimeLongAvg, guiSleepTime, guiFilmUpdateTime;
};
#define LA_LOG(a) { std::stringstream _LUXCOREUI_LOG_LOCAL_SS; _LUXCOREUI_LOG_LOCAL_SS << a; LuxCoreApp::LogHandler(_LUXCOREUI_LOG_LOCAL_SS.str().c_str()); }
template <class T> inline std::string ToString(const T &t) {
std::ostringstream ss;
ss << t;
return ss.str();
}
inline std::string ToString(const float t) {
std::ostringstream ss;
ss << std::setprecision(std::numeric_limits<float>::digits10 + 1) << t;
return ss.str();
}
#endif /* _LUXCOREAPP_H */
// vim: autoindent noexpandtab tabstop=4 shiftwidth=4