7
7
#include " SPlisHSPlasH/TriangleMesh.h"
8
8
9
9
#ifdef USE_DOUBLE
10
- #define glNormal3v glNormal3dv
11
- #define glVertex3v glVertex3dv
12
- #define glVertex3 glVertex3d
13
- #define glMultMatrix glMultMatrixd
14
10
#define glGetRealv glGetDoublev
15
- #define glLoadMatrix glLoadMatrixd
16
- #define glTranslate glTranslated
17
11
#define GL_REAL GL_DOUBLE
18
12
#else
19
- #define glNormal3v glNormal3fv
20
- #define glVertex3v glVertex3fv
21
- #define glVertex3 glVertex3f
22
- #define glMultMatrix glMultMatrixf
23
13
#define glGetRealv glGetFloatv
24
- #define glLoadMatrix glLoadMatrixf
25
- #define glTranslate glTranslatef
26
14
#define GL_REAL GL_FLOAT
27
15
#endif
28
16
29
17
struct GLFWwindow ;
30
- typedef class GLUquadric GLUquadricObj;
31
18
32
19
namespace SPH
33
20
{
@@ -93,6 +80,9 @@ namespace SPH
93
80
static std::vector<MouseWheelFct> m_mouseWheelFct;
94
81
static int m_width;
95
82
static int m_height;
83
+ static int m_windowWidth;
84
+ static int m_windowHeight;
85
+ static Real m_devicePixelRatio;
96
86
static Vector3r m_translation;
97
87
static Quaternionr m_rotation;
98
88
static Real m_zoom;
@@ -118,10 +108,22 @@ namespace SPH
118
108
static int m_context_profile;
119
109
static bool m_breakPointActive;
120
110
static bool m_breakPointLoop;
121
- static GLUquadricObj* m_sphereQuadric;
122
111
static GLFWwindow* m_glfw_window;
123
112
static bool m_vsync;
124
113
static double m_lastTime;
114
+ static Shader m_shader;
115
+ static Shader m_shader_screen;
116
+ static Matrix4r m_modelview_matrix;
117
+ static Matrix4r m_projection_matrix;
118
+ static Vector3r m_ambientIntensity;
119
+ static unsigned int m_numLights;
120
+ static VectorXr m_diffuseIntensity;
121
+ static VectorXr m_specularIntensity;
122
+ static VectorXr m_lightPosition;
123
+ static GLuint m_vao;
124
+ static GLuint m_vbo_vertices;
125
+ static GLuint m_vbo_normals;
126
+ static GLuint m_vbo_faces;
125
127
126
128
static void reshape (GLFWwindow* glfw_window, int w, int h);
127
129
static void keyboard (GLFWwindow* window, int key, int scancode, int action, int mods);
@@ -139,7 +141,7 @@ namespace SPH
139
141
static void drawVector (const Vector3r &a, const Vector3r &b, const float w, float *color);
140
142
/* * Renders a closed cylinder between two points.
141
143
*/
142
- static void drawCylinder (const Vector3r &a, const Vector3r &b, const float *color, const float radius = 0.02 , const unsigned int subdivisions = 8 );
144
+ static void drawCylinder (const Vector3r &a, const Vector3r &b, const float *color, const float radius = 0.02 , const unsigned int subdivisions = 8 , const bool lighting = true );
143
145
static void drawSphere (const Vector3r &translation, float radius, float *color, const unsigned int subDivision = 16 );
144
146
static void drawQuad (const Vector3r &a, const Vector3r &b, const Vector3r &c, const Vector3r &d, const Vector3r &norm, float *color);
145
147
/* * Draw a tetrahedron.
@@ -174,6 +176,7 @@ namespace SPH
174
176
static void setSelectionFunc (void (*func) (const Vector2i&, const Vector2i&, void *), void *clientData);
175
177
static void setMouseMoveFunc (int button, void (*func) (int , int , void *));
176
178
static void unproject (const int x, const int y, Vector3r &pos);
179
+ static void unproject (const Vector3r& win, Vector3r& pos);
177
180
static float getZNear ();
178
181
static float getZFar ();
179
182
static void hsvToRgb (float h, float s, float v, float *rgb);
@@ -199,6 +202,7 @@ namespace SPH
199
202
200
203
static int getWidth () { return m_width; }
201
204
static int getHeight () { return m_height; }
205
+ static Real getDevicePixelRatio () { return m_devicePixelRatio; }
202
206
203
207
static int getDrawMode () { return drawMode; }
204
208
static void setDrawMode (int val) { drawMode = val; }
@@ -217,6 +221,31 @@ namespace SPH
217
221
static void setWindowSize (int w, int h);
218
222
static bool getWindowMaximized ();
219
223
static void setWindowMaximized (const bool b);
224
+
225
+ static const Matrix4r& getModelviewMatrix () { return m_modelview_matrix; }
226
+ static const Matrix4r& getProjectionMatrix () { return m_projection_matrix; }
227
+
228
+ static void initShaders (const std::string& shaderPath);
229
+ static void enableShader (const Vector3r& ambientReflectance, const Vector3r& diffuseReflectance, const Vector3r& specularReflectance, const Real shininess, const Real pointSize=1.0 );
230
+ static void disableShader ();
231
+ static void enableScreenShader (const Vector3r& color);
232
+ static void disableScreenShader ();
233
+
234
+ static const GLuint getVao () { return m_vao; }
235
+ static const GLuint getVboVertices () { return m_vbo_vertices; }
236
+ static const GLuint getVboNormals () { return m_vbo_normals; }
237
+ static const GLuint getVboFaces () { return m_vbo_faces; }
238
+
239
+ // Fill a VBO with vector data and map to the VAO attribute at the specified index.
240
+ static void supplyVectors (GLuint index, GLuint vbo, unsigned int dim, unsigned int n, const Real* data);
241
+ // Fill the dedicated VBO with 3D vertex data and map to the VAO attribute at the specified index.
242
+ static void supplyVertices (GLuint index, unsigned int numVectors, const Real* data);
243
+ // Fill the dedicated VBO with 3D normal data and map to the VAO attribute at the specified index.
244
+ static void supplyNormals (GLuint index, unsigned int numVectors, const Real* data);
245
+ // Fill a VBO with index data.
246
+ static void supplyIndices (GLuint vbo, unsigned int n, const unsigned int * data);
247
+ // Fill the dedicated VBO with face index data.
248
+ static void supplyFaces (unsigned int numIndices, const unsigned int * data);
220
249
};
221
250
}
222
251
0 commit comments