RayZaler 0.1
The free opto-mechanical simulation framework
GLModel.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 _GL_MODEL_H
20#define _GL_MODEL_H
21
22#ifdef __APPLE_CC__
23#include <GLUT/glut.h>
24#else
25#include <GL/glut.h>
26#endif
27
28#include "IncrementalRotation.h"
29#include "Element.h"
30
31namespace RZ {
33 public:
34 virtual void tick() = 0;
35 };
36
37 class GLModel {
38 GLModelEventListener *m_listener = nullptr;
39 GLfloat m_refMatrix[16];
40 GLfloat m_apertureColor[4] = {0, 0, 1, 1};
41 unsigned int m_thickness = 3;
42
43 protected:
44 void tick();
45 void drawElementApertures(const Element *);
46
47 public:
48 void setOrientationAndCenter(RZ::Matrix3 const &R, RZ::Vec3 const &O);
49 void pushReferenceFrameMatrix(const RZ::ReferenceFrame *frame);
50 void pushElementMatrix(Element *);
51 void popElementMatrix();
52
53 GLfloat *refMatrix();
54 void updateRefMatrix();
55
56 void setApertureColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
57 void setApertureColor(const GLfloat *rgb);
58 void setApertureColor(Vec3 const &);
59 void setApertureThickness(unsigned int);
60
61 void setEventListener(GLModelEventListener *listener);
62 virtual void configureLighting();
63 virtual void display() = 0;
64 };
65}
66
67#endif // _GL_MODEL_H
Definition: Element.h:173
Definition: GLModel.h:32
Definition: GLModel.h:37
Definition: ReferenceFrame.h:59
Definition: Matrix.h:48
Definition: Vector.h:66