Easy3D 2.6.1
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
offscreen.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_VIEWER_OFFSCREEN_H
28#define EASY3D_VIEWER_OFFSCREEN_H
29
30#include <memory>
31#include <easy3d/viewer/viewer.h>
32
33
34namespace easy3d {
35
50 class OffScreen : protected Viewer
51 {
52 public:
58 explicit OffScreen(int width = 800, int height = 600);
59
61
62
63 Camera* camera();
65 const Camera* camera() const;
67
84 bool render(const std::string& file_name, float scaling = 1.0f, int samples = 4, int back_ground = 1, bool expand = true) const;
85
86
88
89
93 void resize(int w, int h);
94
96 int width() const;
98 int height() const;
99
104 void set_background_color(const easy3d::vec4& color);
105
110 const easy3d::vec4& background_color() const;
112
114
115
136 virtual Model* add_model(const std::string& file_name, bool create_default_drawables = true);
137
157 Model* add_model(std::shared_ptr<Model> model, bool create_default_drawables = true);
158
165 bool delete_model(Model* model);
166
171 const std::vector< std::shared_ptr<Model> >& models() const;
172
179 Model* current_model() const;
181
183
184
195 Drawable* add_drawable(std::shared_ptr<Drawable> drawable);
196
202 bool delete_drawable(Drawable* drawable);
203
208 const std::vector<std::shared_ptr<Drawable> >& drawables() const;
209
213 void clear_scene();
215 };
216
217}
218
219
220#endif // EASY3D_VIEWER_OFFSCREEN_H
A perspective or orthographic camera.
Definition camera.h:113
The base class for drawable objects. A drawable represent a set of points, line segments,...
Definition drawable.h:58
The base class of renderable 3D models.
Definition model.h:50
bool render(const std::string &file_name, float scaling=1.0f, int samples=4, int back_ground=1, bool expand=true) const
Render the current scene into an image file. Supported image format: png, jpg, bmp,...
Definition offscreen.cpp:50
const easy3d::vec4 & background_color() const
Query the background color of the offscreen renderer.
Definition offscreen.cpp:75
OffScreen(int width=800, int height=600)
Constructor.
Definition offscreen.cpp:32
void clear_scene()
Delete all visual contents of the offscreen renderer (all models and drawables).
Definition offscreen.cpp:122
bool delete_drawable(Drawable *drawable)
Definition offscreen.cpp:112
Model * current_model() const
Query the active model.
Definition offscreen.cpp:102
const std::vector< std::shared_ptr< Drawable > > & drawables() const
Query the drawables managed by this offscreen renderer.
Definition offscreen.cpp:117
const std::vector< std::shared_ptr< Model > > & models() const
Query the models managed by this offscreen renderer.
Definition offscreen.cpp:97
void resize(int w, int h)
Set/Change the size of the offscreen renderer.
Definition offscreen.cpp:55
void set_background_color(const easy3d::vec4 &color)
Set the background color of the offscreen renderer.
Definition offscreen.cpp:70
bool delete_model(Model *model)
Delete a model. The memory of the model will be released and its existing drawables also be deleted.
Definition offscreen.cpp:92
virtual Model * add_model(const std::string &file_name, bool create_default_drawables=true)
Add a model from a file to the offscreen renderer. On success, the offscreen renderer will be in char...
Definition offscreen.cpp:80
Camera * camera()
Returns the camera used by the offscreen renderer. See Camera.
Definition offscreen.cpp:40
int height() const
Returns the height of the offscreen renderer.
Definition offscreen.cpp:65
int width() const
Returns the width of the offscreen renderer.
Definition offscreen.cpp:60
Drawable * add_drawable(std::shared_ptr< Drawable > drawable)
Add a drawable to the offscreen renderer. On success, the offscreen renderer will be in charge of its...
Definition offscreen.cpp:107
int samples() const
Query the actual samples of the viewer.
Definition viewer.h:160
Viewer(const std::string &title="Easy3D Viewer", int samples=4, int gl_major=3, int gl_minor=2, bool full_screen=false, bool resizable=true, int depth_bits=24, int stencil_bits=8, int width=800, int height=600)
Constructor.
Definition viewer.cpp:75
Definition collider.cpp:182
Vec< 4, float > vec4
A 4D point/vector of float type.
Definition types.h:46