-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOpenGLParse3DObjectModel.h
113 lines (67 loc) · 1.88 KB
/
OpenGLParse3DObjectModel.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
#pragma once
#include <QtWidgets/QWidget>
#include "ui_OpenGLParse3DObjectModel.h"
#include <Windows.h>
#include <GL/eglew.h>
#include "QtEvent.h"
#include "cutil.h"
#include "camera.h"
#include "cshader.h"
#include "cmodel.h"
#include "ctexture.h"
//是否优化过后的代码
#define MODEL_APP (1)
class OpenGLParse3DObjectModel : public QWidget
{
Q_OBJECT
public:
OpenGLParse3DObjectModel(QWidget *parent = nullptr);
~OpenGLParse3DObjectModel();
// // 设置这个就不能使用QT渲染的了 就需要重新实现QPaintEngine函数
//setAttribute(Qt::WA_PaintOnScreen);
virtual QPaintEngine* paintEngine() const { return NULL; }
virtual void resizeEvent(QResizeEvent* event);
void showEvent(QShowEvent* event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
public:
void Renderer();
bool event(QEvent* event);
bool initializeGL();
private:
bool CreateGLContext();
bool _gl_update();
private slots:
void Tick();
private:
Ui::OpenGLParse3DObjectModelClass ui;
HDC dc;
HGLRC rc;
HWND hwnd;
GLuint VBO, VAO, EBO;
GLuint program;
chen::ctexture* tex1;
chen::ctexture *tex2;
GLint smp1, smp2;
GLuint modelLocation;
GLuint viewLocation;
GLuint projLocation;
chen::Camera camera;
bool isPressW = false;
bool isPressS = false;
bool isPressA = false;
bool isPressD = false;
bool isPressQ = false;
bool isPressE = false;
float speed = 1.0f;
float rotateSpeed = 0.2f;
QPoint lastPoint;
struct chen::Mesh* mesh = NULL;
chen::cshader1* shader = NULL;
chen::cmodel* model = NULL;
//绘制两个图形
chen::cshader1* shader2 = NULL;
chen::cmodel* model2 = NULL;
};