Nori  24
render.h
1 /*
2  This file is part of Nori, a simple educational ray tracer
3 
4  Copyright (c) 2015 by Romain Prévost
5 
6  Nori is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Nori is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #if !defined(__NORI_RENDER_H)
20 #define __NORI_RENDER_H
21 
22 #include <nori/common.h>
23 #include <thread>
24 #include <nori/block.h>
25 #include <atomic>
26 
27 NORI_NAMESPACE_BEGIN
28 
29 class RenderThread {
30 
31 public:
32  RenderThread(ImageBlock & block);
33  ~RenderThread();
34 
35  void renderScene(const std::string & filename);
36 
37  bool isBusy();
38  void stopRendering();
39 
40  float getProgress();
41 
42 protected:
43  Scene* m_scene = nullptr;
44  ImageBlock & m_block;
45  std::thread m_render_thread;
46  std::atomic<int> m_render_status; // 0: free, 1: busy, 2: interruption, 3: done
47  std::atomic<float> m_progress;
48 
49 };
50 
51 NORI_NAMESPACE_END
52 
53 #endif //__NORI_RENDER_H
Weighted pixel storage for a rectangular subregion of an image.
Definition: block.h:48
void renderScene(const std::string &filename)
Definition: render.cpp:102
Main scene data structure.
Definition: scene.h:34