RayZaler 0.1
The free opto-mechanical simulation framework
ModelRenderer.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _RZ_MODEL_RENDERER_H
20#define _RZ_MODEL_RENDERER_H
21
22#include <list>
23#include <vector>
24#include <cstdint>
25#include <GL/gl.h>
26#include <GL/osmesa.h>
27#include "GLRenderEngine.h"
28
29namespace RZ {
30 class OMModel;
31 class Element;
32 class GLModel;
33 class RZGLModel;
34
36 OSMesaContext m_ctx;
37 RZGLModel *m_ownModel;
38 unsigned int m_width = 680;
39 unsigned int m_height = 480;
40 bool m_fixedLight = false;
41
42 std::vector<uint32_t> m_pixels;
43 void showScreen();
44 void adjustViewPort();
45
46 ModelRenderer(unsigned int width, unsigned int height, RZGLModel *own = nullptr);
47
48 public:
50
51 inline unsigned
52 width() const {
53 return m_width;
54 }
55
56 inline unsigned
57 height() const {
58 return m_height;
59 }
60
61 void render();
62 void zoomToContents();
63 void zoomToElement(Element const *);
64 void setHighlightedBoundingBox(Element *);
65 void setShowElements(bool);
66 void setShowApertures(bool);
67 bool savePNG(const char *path);
68 const uint32_t *pixels() const;
69
70 static ModelRenderer *fromOMModel(
71 OMModel *,
72 unsigned,
73 unsigned,
74 bool showElements = true,
75 bool showApertures = false);
76 };
77}
78
79#endif // _RZ_MODEL_RENDERER_H
Definition: Element.h:173
Definition: GLRenderEngine.h:94
Definition: ModelRenderer.h:35
Definition: OMModel.h:204
Definition: RZGLModel.h:29