-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglwidget.h
124 lines (92 loc) · 2.91 KB
/
glwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QtGui>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QTimer>
#include <GL/glu.h>
#include <QGLWidget>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <QOpenGLFunctions_1_3> // OpenGL 1.3 for support glMultiTexCoord2fv
class GLWidget : public QGLWidget
{
Q_OBJECT
public:
explicit GLWidget(QWidget *parent = 0);
~GLWidget();
void setMappingIndex(int);
void setTextureIndex(int);
// Позиции источника света и наблюдателя
void setLightPosition( float x, float y, float z );
void setEyePosition( float x, float y, float z );
void setSteps( float value );
void setScale( float value );
void setBias( float value );
// Управление таймерами
void startPerformanceTimers();
void stopPerformanceTimers();
public slots:
void setXRotation(GLfloat angle);
void setYRotation(GLfloat angle);
void setZRotation(GLfloat angle);
void onTimer();
signals:
void xRotationChanged(GLfloat angle);
void yRotationChanged(GLfloat angle);
void zRotationChanged(GLfloat angle);
protected:
void initializeGL();
void paintGL();
void resizeGL(int, int);
void mousePressEvent( QMouseEvent * );
void mouseMoveEvent( QMouseEvent * );
QOpenGLFunctions_1_3 *gl_functions;
bool gl_functions_isInitialized;
QOpenGLContext *gl_context;
private:
GLfloat xRot;
GLfloat yRot;
GLfloat zRot;
QPoint lastPos;
QVector3D eyePosition;
QVector3D lightPosition;
QVector3D from;
// Удалять невидимые грани
bool removeInvisibleFaces;
// Номер модели маппинга
int mappingIndex;
// Номер текстуры
int textureIndex;
// Обновление проекции
void updateProjection( int width, int height );
void updateProjection();
// Текстуры для parallax mapping
GLuint decalMap;
GLuint heightMap;
GLuint bumpMap;
GLint steps;
GLfloat scale;
GLfloat bias;
// Инициализация маппинга
void setMapping();
void updateMapping();
// Инициализация текстуры
void setTexture();
// Инициализация освещения
void initializeLight();
// Рисование осей координат
void drawAxes();
// Рисование фигуры
void drawFigure();
// Рисование источника света в виде куба с центром x, y, z
// и заданным цветом red, green, blue
void drawLight( QVector3D &position, QVector3D &color );
QOpenGLShaderProgram shaderProgram;
// Таймеры для измерения производительности
QTimer timer1;
QTimer timer2;
uint frames;
bool isPerformanceTest;
};
#endif // GLWIDGET_H