├── Day01
├── gl.frag
├── gl.vert
├── shader.qrc
├── main.cpp
├── widget.h
├── .gitignore
├── widget.cpp
└── Day01.pro
├── Day02
├── gl.frag
├── gl.vert
├── shader.qrc
├── main.cpp
├── widget.h
├── .gitignore
├── Day02.pro
├── widget.cpp
├── Day02.pro.user
└── Day02.user
├── Day03
├── OpenGL.jpg
├── gl.frag
├── gl.vert
├── shader.qrc
├── main.cpp
├── widget.h
├── .gitignore
├── Day03.pro
├── widget.cpp
└── Day03.user
├── .gitmodules
├── GLTool
├── Test
│ ├── image.png
│ ├── res.qrc
│ ├── main.cpp
│ ├── TestWidget.h
│ └── TestWidget.cpp
├── debug
│ └── GLTool.lib
├── release
│ └── GLTool.lib
├── TextureTool.h
├── GLTool.pro
├── .gitignore
├── GLFilter.cpp
├── GLTool.cpp
├── GLTool.h
├── TextureTool.cpp
└── GLFilter.h
├── WaveEffect
├── background.jpg
├── wave.vert
├── render.vert
├── main.cpp
├── shader.qrc
├── WaveEffect.pro
├── wave.frag
├── render.frag
├── .gitignore
├── widget.h
└── widget.cpp
├── Day04_GLSLSandbox
├── shader.qrc
├── main.cpp
├── widget.h
├── GLSLSandbox.frag
├── .gitignore
├── Day04_GLSLSandbox.pro
└── widget.cpp
├── Day03_Text2D
├── shader.qrc
├── text.frag
├── text.vert
├── main.cpp
├── widget.h
├── .gitignore
├── Day03_Text2D.pro
└── widget.cpp
├── OpenGLInstance
├── shader.qrc
├── gl.frag
├── main.cpp
├── gl.vert
├── widget.h
├── .gitignore
├── OpenGLInstance.pro
└── widget.cpp
├── Section7_GPUParticleSystem
├── ParticleRender.frag
├── shader.qrc
├── main.cpp
├── ParticleRender.vert
├── ParticleRunner.vert
├── Section7_GPUParticleSystem.pro
├── ParticleRunner.geom
├── .gitignore
├── Widget.h
└── Widget.cpp
├── README.md
├── OpenGLTransformFeedback
├── feedback.vert
├── main.cpp
├── feedback.geom
├── widget.h
├── .gitignore
├── OpenGLTransformFeedback.pro
└── widget.cpp
├── Day04
├── main.cpp
├── widget.h
├── .gitignore
├── Day04.pro
└── widget.cpp
├── Section6_GlowEffect
├── main.cpp
├── widget.h
├── .gitignore
├── Section6_GlowEffect.pro
└── widget.cpp
└── Section4_2DTextByTool
├── main.cpp
├── widget.h
├── .gitignore
├── Section4_2DTextByTool.pro
└── widget.cpp
/Day01/gl.frag:
--------------------------------------------------------------------------------
1 | void main(void)
2 | {
3 | gl_FragColor = vec4(1.0,0.0,1.0,1.0);
4 | }
5 |
--------------------------------------------------------------------------------
/Day02/gl.frag:
--------------------------------------------------------------------------------
1 | void main(void)
2 | {
3 | gl_FragColor = vec4(1.0,0.0,1.0,1.0);
4 | }
5 |
--------------------------------------------------------------------------------
/Day02/gl.vert:
--------------------------------------------------------------------------------
1 | attribute vec3 pos;
2 | void main()
3 | {
4 | gl_Position = vec4(pos,1.0);
5 | }
6 |
--------------------------------------------------------------------------------
/Day03/OpenGL.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Italink/QtOpenGL-Essential-Training/HEAD/Day03/OpenGL.jpg
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "IKEngine"]
2 | path = IKEngine
3 | url = https://github.com/Italink/IKEngine.git
4 |
--------------------------------------------------------------------------------
/Day01/gl.vert:
--------------------------------------------------------------------------------
1 | attribute vec3 pos;
2 |
3 |
4 | void main()
5 | {
6 | gl_Position = vec4(pos,1.0);
7 | }
8 |
--------------------------------------------------------------------------------
/GLTool/Test/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Italink/QtOpenGL-Essential-Training/HEAD/GLTool/Test/image.png
--------------------------------------------------------------------------------
/GLTool/debug/GLTool.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Italink/QtOpenGL-Essential-Training/HEAD/GLTool/debug/GLTool.lib
--------------------------------------------------------------------------------
/GLTool/release/GLTool.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Italink/QtOpenGL-Essential-Training/HEAD/GLTool/release/GLTool.lib
--------------------------------------------------------------------------------
/WaveEffect/background.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Italink/QtOpenGL-Essential-Training/HEAD/WaveEffect/background.jpg
--------------------------------------------------------------------------------
/GLTool/Test/res.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | image.png
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Day04_GLSLSandbox/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | GLSLSandbox.frag
4 |
5 |
6 |
--------------------------------------------------------------------------------
/WaveEffect/wave.vert:
--------------------------------------------------------------------------------
1 | #version 450
2 | layout(location=0) in vec2 pos;
3 |
4 | void main(void)
5 | {
6 | gl_Position = vec4(pos,0.0,1.0);
7 | }
8 |
--------------------------------------------------------------------------------
/Day02/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | gl.vert
4 | gl.frag
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Day03/gl.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D texture;
2 | varying vec2 outCoord;
3 |
4 | void main(void)
5 | {
6 | gl_FragColor = texture2D(texture,outCoord);
7 | }
8 |
--------------------------------------------------------------------------------
/Day03_Text2D/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | text.frag
4 | text.vert
5 |
6 |
7 |
--------------------------------------------------------------------------------
/OpenGLInstance/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | gl.vert
4 | gl.frag
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Day03_Text2D/text.frag:
--------------------------------------------------------------------------------
1 | uniform sampler2D texture;
2 | varying vec2 outCoord;
3 |
4 | void main(void)
5 | {
6 | gl_FragColor = texture2D(texture, outCoord);
7 | }
8 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/ParticleRender.frag:
--------------------------------------------------------------------------------
1 | #version 400 core
2 |
3 | in vec4 outColor;
4 | out vec4 fragColor;
5 | void main(){
6 | fragColor = outColor;
7 | }
8 |
--------------------------------------------------------------------------------
/OpenGLInstance/gl.frag:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | out vec4 FragColor;
3 |
4 | in vec3 fColor;
5 |
6 | void main()
7 | {
8 | FragColor = vec4(fColor, 1.0);
9 | }
10 |
--------------------------------------------------------------------------------
/Day01/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | gl.vert
4 | gl.frag
5 | s.vsh
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Day03/gl.vert:
--------------------------------------------------------------------------------
1 | attribute vec3 pos;
2 | attribute vec2 texCoord;
3 | varying vec2 outCoord;
4 | void main()
5 | {
6 | gl_Position = vec4(pos,1.0);
7 | outCoord=texCoord;
8 | }
9 |
--------------------------------------------------------------------------------
/Day03/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | gl.vert
4 | gl.frag
5 | OpenGL.jpg
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QtOpenGL-Essential-Training
2 | 笔者想通过自己学习OpenGL的一些经验来总结一个Qt平台下的OpenGL教程
3 |
4 | #笔者博客:https://blog.csdn.net/qq_40946921
5 | #笔者B站链接:https://www.bilibili.com/read/cv10397591
6 |
--------------------------------------------------------------------------------
/WaveEffect/render.vert:
--------------------------------------------------------------------------------
1 | #version 450
2 | layout(location=0) in vec2 pos;
3 | out vec2 waveCoord;
4 | void main(void)
5 | {
6 | gl_Position = vec4(pos,0.0,1.0);
7 | waveCoord = (pos+vec2(1))/2;
8 | }
9 |
--------------------------------------------------------------------------------
/Day03_Text2D/text.vert:
--------------------------------------------------------------------------------
1 | attribute vec2 pos;
2 | attribute vec2 texCoord;
3 | varying vec2 outCoord;
4 |
5 | void main(void)
6 | {
7 | gl_Position = vec4(pos,1.0,1.0);
8 | outCoord = texCoord;
9 | }
10 |
--------------------------------------------------------------------------------
/OpenGLTransformFeedback/feedback.vert:
--------------------------------------------------------------------------------
1 | #version 400 core
2 | layout(location = 0) in float inValue;
3 | out OUT{
4 | float value;
5 | }vs_out;
6 |
7 | void main(void)
8 | {
9 | vs_out.value=inValue;
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/Day01/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/Day02/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/Day03/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/Day04/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/GLTool/Test/main.cpp:
--------------------------------------------------------------------------------
1 | #include "TestWidget.h"
2 | #include
3 |
4 | int main(int argc, char *argv[])
5 | {
6 | QApplication a(argc, argv);
7 | Widget w;
8 | w.show();
9 | return a.exec();
10 | }
11 |
--------------------------------------------------------------------------------
/OpenGLInstance/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 | #include
3 |
4 | int main(int argc, char *argv[])
5 | {
6 | QApplication a(argc, argv);
7 | Widget w;
8 | w.show();
9 | return a.exec();
10 | }
11 |
--------------------------------------------------------------------------------
/Day03_Text2D/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/WaveEffect/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/Day04_GLSLSandbox/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/Section6_GlowEffect/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/OpenGLTransformFeedback/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/Section4_2DTextByTool/main.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget w;
9 | w.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/WaveEffect/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | wave.vert
4 | wave.frag
5 | render.vert
6 | render.frag
7 | background.jpg
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/shader.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | ParticleRender.vert
4 | ParticleRender.frag
5 | ParticleRunner.geom
6 | ParticleRunner.vert
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/main.cpp:
--------------------------------------------------------------------------------
1 | #include "Widget.h"
2 | #include
3 | #include
4 |
5 | int main(int argc, char *argv[])
6 | {
7 | QApplication a(argc, argv);
8 | Widget openglWidget;
9 | openglWidget.show();
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/OpenGLInstance/gl.vert:
--------------------------------------------------------------------------------
1 | #version 330 core
2 | layout (location = 0) in vec2 aPos;
3 | layout (location = 1) in vec3 aColor;
4 | layout (location = 2) in mat4 aOffset;
5 |
6 | out vec3 fColor;
7 |
8 | void main()
9 | {
10 | gl_Position = aOffset*vec4(aPos,1.0,1.0);
11 | fColor = aColor;
12 | }
13 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/ParticleRender.vert:
--------------------------------------------------------------------------------
1 | #version 400
2 |
3 | layout(location = 0) in vec3 position;
4 | layout(location = 2) in float size;
5 | layout(location = 4) in vec4 color;
6 |
7 | uniform mat4 VP;
8 |
9 | out vec4 outColor;
10 |
11 | void main(){
12 | gl_Position = VP * vec4(position,1.0);
13 | gl_PointSize = size ;
14 | outColor = color;
15 | }
16 |
--------------------------------------------------------------------------------
/OpenGLTransformFeedback/feedback.geom:
--------------------------------------------------------------------------------
1 | #version 400 core
2 |
3 | layout(points) in;
4 | layout(points, max_vertices = 4) out;
5 |
6 | in OUT{
7 | float value;
8 | }vs_in[];
9 |
10 | out float outValue;
11 |
12 | void main(){
13 | outValue=1.0;
14 | EmitVertex();
15 | outValue=vs_in[0].value+2;
16 | EmitVertex();
17 | outValue=vs_in[0].value+3;
18 | EmitVertex();
19 | outValue=vs_in[0].value+4;
20 | EmitVertex();
21 | EndPrimitive();
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/Day04_GLSLSandbox/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | class Widget : public QOpenGLWidget, protected QOpenGLExtraFunctions
8 | {
9 | Q_OBJECT
10 | public:
11 | Widget(QWidget *parent = nullptr);
12 | ~Widget();
13 | protected:
14 | virtual void initializeGL() override;
15 | virtual void paintGL() override;
16 | virtual void resizeGL(int w, int h) override;
17 | QOpenGLShaderProgram shaderProgram;
18 | };
19 | #endif // WIDGET_H
20 |
--------------------------------------------------------------------------------
/GLTool/TextureTool.h:
--------------------------------------------------------------------------------
1 | #ifndef TEXTURETOOL_H
2 | #define TEXTURETOOL_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | class TextureTool
10 | {
11 | public:
12 | TextureTool();
13 | void drawTexture(GLuint textureId, QRectF geomtry=QRectF(-1,-1,2,2), float rotation=0);
14 | void drawImage(QImage image, QRectF geomtry=QRectF(-1,-1,2,2), float rotation=0);
15 | private:
16 | QOpenGLVertexArrayObject VAO;
17 | QOpenGLBuffer VBO;
18 | QOpenGLShaderProgram program;
19 | };
20 |
21 | #endif // TEXTURETOOL_H
22 |
--------------------------------------------------------------------------------
/Day01/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | Widget(QWidget *parent = nullptr);
16 | ~Widget();
17 | protected:
18 | virtual void initializeGL() override;
19 | virtual void paintGL() override;
20 | virtual void resizeGL(int w, int h) override;
21 | private:
22 | QOpenGLShaderProgram shaderProgram;
23 |
24 | };
25 | #endif // WIDGET_H
26 |
--------------------------------------------------------------------------------
/GLTool/Test/TestWidget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include "GLFilter.h"
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | class Widget : public QOpenGLWidget, protected QOpenGLExtraFunctions
11 | {
12 | Q_OBJECT
13 | public:
14 | Widget(QWidget *parent = nullptr);
15 | ~Widget();
16 |
17 | // QOpenGLWidget interface
18 | protected:
19 | virtual void initializeGL() override;
20 | virtual void resizeGL(int w, int h) override;
21 | virtual void paintGL() override;
22 | private:
23 | QOpenGLTexture texture;
24 | GLFilter* filter;
25 | };
26 | #endif // WIDGET_H
27 |
--------------------------------------------------------------------------------
/WaveEffect/WaveEffect.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # You can make your code fail to compile if it uses deprecated APIs.
8 | # In order to do so, uncomment the following line.
9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10 |
11 | SOURCES += \
12 | main.cpp \
13 | widget.cpp
14 |
15 | HEADERS += \
16 | widget.h
17 |
18 | # Default rules for deployment.
19 | qnx: target.path = /tmp/$${TARGET}/bin
20 | else: unix:!android: target.path = /opt/$${TARGET}/bin
21 | !isEmpty(target.path): INSTALLS += target
22 |
23 | RESOURCES += \
24 | shader.qrc
25 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/ParticleRunner.vert:
--------------------------------------------------------------------------------
1 | #version 400 core
2 | layout(location = 0) in vec3 position;
3 | layout(location = 1) in vec3 velocity;
4 | layout(location = 2) in float size;
5 | layout(location = 3) in float life;
6 | layout(location = 4) in vec4 color;
7 |
8 | out Particle{
9 | vec3 position;
10 | vec3 velocity;
11 | float size;
12 | float life;
13 | vec4 color;
14 | }particle;
15 |
16 | uniform float duration;
17 |
18 | void main(){
19 | particle.position = position + velocity;
20 | particle.velocity = velocity + vec3(0,-0.01,0);
21 |
22 | particle.size = size;
23 | particle.life = life + duration;
24 | particle.color = color;
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/Section7_GPUParticleSystem.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # You can make your code fail to compile if it uses deprecated APIs.
8 | # In order to do so, uncomment the following line.
9 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
10 |
11 | SOURCES += \
12 | main.cpp \
13 | Widget.cpp
14 |
15 | HEADERS += \
16 | Widget.h
17 |
18 | # Default rules for deployment.
19 | qnx: target.path = /tmp/$${TARGET}/bin
20 | else: unix:!android: target.path = /opt/$${TARGET}/bin
21 | !isEmpty(target.path): INSTALLS += target
22 |
23 | RESOURCES += \
24 | shader.qrc
25 |
--------------------------------------------------------------------------------
/Section4_2DTextByTool/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
13 | {
14 | Q_OBJECT
15 | public:
16 | Widget(QWidget *parent = nullptr);
17 | ~Widget();
18 | protected:
19 | virtual void initializeGL() override;
20 | virtual void paintGL() override;
21 | virtual void resizeGL(int w, int h) override;
22 | private:
23 | QOpenGLTexture texture;
24 | QTimer timer;
25 | };
26 |
27 |
28 | #endif // WIDGET_H
29 |
--------------------------------------------------------------------------------
/Day02/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | Widget(QWidget *parent = nullptr);
16 | ~Widget();
17 | protected:
18 | virtual void initializeGL() override;
19 | virtual void paintGL() override;
20 | virtual void resizeGL(int w, int h) override;
21 | private:
22 | QOpenGLShaderProgram shaderProgram;
23 | QOpenGLVertexArrayObject VAO;
24 | QOpenGLBuffer VBO;
25 | QOpenGLBuffer EBO;
26 | };
27 | #endif // WIDGET_H
28 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/ParticleRunner.geom:
--------------------------------------------------------------------------------
1 | #version 400 core
2 | layout(points) in;
3 | layout(points, max_vertices = 1) out;
4 |
5 | in Particle{
6 | vec3 position;
7 | vec3 velocity;
8 | float size;
9 | float life;
10 | vec4 color;
11 | }particle[];
12 |
13 | out vec3 position;
14 | out vec3 velocity;
15 | out float size;
16 | out float life;
17 | out vec4 color;
18 |
19 | uniform float lifetime;
20 |
21 | void main(){
22 | if(particle[0].life>lifetime)
23 | return;
24 | position = particle[0].position;
25 | velocity = particle[0].velocity;
26 | size = particle[0].size;
27 | life = particle[0].life;
28 | color = particle[0].color;
29 | EmitVertex();
30 | EndPrimitive();
31 | }
32 |
--------------------------------------------------------------------------------
/OpenGLInstance/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class Widget : public QOpenGLWidget,protected QOpenGLExtraFunctions
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | Widget(QWidget *parent = nullptr);
16 | ~Widget();
17 | protected:
18 | virtual void initializeGL() override;
19 | virtual void paintGL() override;
20 | virtual void resizeGL(int w, int h) override;
21 | private:
22 | QOpenGLVertexArrayObject VAO;
23 | QOpenGLBuffer VBO;
24 | QOpenGLShaderProgram shaderProgram;
25 | QOpenGLBuffer instanceVBO;
26 | };
27 | #endif // WIDGET_H
28 |
--------------------------------------------------------------------------------
/OpenGLTransformFeedback/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | Widget(QWidget *parent = nullptr);
16 | ~Widget();
17 | protected:
18 | virtual void initializeGL() override;
19 | virtual void paintGL() override;
20 | virtual void resizeGL(int w, int h) override;
21 | private:
22 | QOpenGLShaderProgram shaderProgram;
23 | QOpenGLVertexArrayObject VAO;
24 | QOpenGLBuffer VBO;
25 | QOpenGLBuffer VBOBuffer;
26 | };
27 | #endif // WIDGET_H
28 |
--------------------------------------------------------------------------------
/GLTool/GLTool.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | TEMPLATE = lib
6 | CONFIG += staticlib
7 |
8 | CONFIG += c++11
9 |
10 | # You can make your code fail to compile if it uses deprecated APIs.
11 | # In order to do so, uncomment the following line.
12 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
13 |
14 | SOURCES += \
15 | GLFilter.cpp \
16 | TextureTool.cpp \
17 | GLTool.cpp \
18 |
19 | HEADERS += \
20 | GLFilter.h \
21 | TextureTool.h \
22 | GLTool.h
23 |
24 | # Default rules for deployment.
25 | qnx: target.path = /tmp/$${TARGET}/bin
26 | else: unix:!android: target.path = /opt/$${TARGET}/bin
27 | !isEmpty(target.path): INSTALLS += target
28 |
--------------------------------------------------------------------------------
/WaveEffect/wave.frag:
--------------------------------------------------------------------------------
1 | #version 450
2 | #define MAX_SIZE 50
3 | uniform vec3 mouse[50];
4 | uniform int size;
5 | uniform float frequency; //频率
6 | uniform float amplitude; //最大振幅
7 | uniform float wave_width; //波纹的宽度
8 | uniform float speed; //水纹的移动速度
9 | out float outHeight;
10 |
11 | void main(void)
12 | {
13 | outHeight = 0;
14 | for(int i=0;i
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | Widget(QWidget *parent = nullptr);
17 | ~Widget();
18 | protected:
19 | virtual void initializeGL() override;
20 | virtual void paintGL() override;
21 | virtual void resizeGL(int w, int h) override;
22 | private:
23 | QOpenGLShaderProgram shaderProgram;
24 | QOpenGLVertexArrayObject VAO;
25 | QOpenGLBuffer VBO;
26 | QOpenGLBuffer EBO;
27 | QOpenGLTexture texture;
28 | };
29 | #endif // WIDGET_H
30 |
--------------------------------------------------------------------------------
/Day03_Text2D/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
13 | {
14 | Q_OBJECT
15 | public:
16 | Widget(QWidget *parent = nullptr);
17 | ~Widget();
18 | protected:
19 | virtual void initializeGL() override;
20 | virtual void paintGL() override;
21 | virtual void resizeGL(int w, int h) override;
22 | void flushTexture();
23 | private:
24 | QOpenGLVertexArrayObject VAO;
25 | QOpenGLBuffer VBO;
26 | QOpenGLShaderProgram shaderProgram;
27 | QOpenGLTexture texture;
28 | QTimer timer;
29 | };
30 |
31 |
32 | #endif // WIDGET_H
33 |
--------------------------------------------------------------------------------
/WaveEffect/render.frag:
--------------------------------------------------------------------------------
1 | #version 450
2 | uniform sampler2D wave;
3 | uniform sampler2D background;
4 | uniform vec2 screen_size;
5 | uniform float depth;
6 | in vec2 waveCoord;
7 | out vec4 FragColor;
8 |
9 | void main(void)
10 | {
11 | float height = texture2D(wave,waveCoord).x;
12 | vec2 offset= vec2(1.0/screen_size.x,1.0/screen_size.y);
13 |
14 | float upHeight = texture2D(wave,waveCoord+vec2(0,offset.y)).x;
15 | float rightHeight = texture2D(wave,waveCoord+vec2(offset.x,0)).x;
16 |
17 | vec3 up = vec3(0,1,upHeight-height);
18 | vec3 right = vec3(1,0,rightHeight-height);
19 |
20 | vec3 normal = cross(up,right);
21 |
22 | vec3 view = vec3(0,0,-1);
23 |
24 | vec3 re = refract(view,normal,1.33);
25 |
26 | vec2 coordOffset = re.xy*((height+depth)/re.z);
27 |
28 | FragColor = texture2D(background,waveCoord+coordOffset);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/Day04/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | Widget(QWidget *parent = nullptr);
18 | ~Widget();
19 | protected:
20 | virtual void initializeGL() override;
21 | virtual void paintGL() override;
22 | virtual void resizeGL(int w, int h) override;
23 | private:
24 | QOpenGLShaderProgram shaderProgram;
25 | QOpenGLVertexArrayObject VAO;
26 | QOpenGLBuffer VBO;
27 | QOpenGLBuffer EBO;
28 | QOpenGLTexture texture;
29 | QTimer timer;
30 | };
31 | #endif // WIDGET_H
32 |
--------------------------------------------------------------------------------
/Section6_GlowEffect/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | class Widget : public QOpenGLWidget , protected QOpenGLExtraFunctions
14 | {
15 | Q_OBJECT
16 | public:
17 | Widget(QWidget *parent = nullptr);
18 | ~Widget();
19 | void setBlurRadius(int radius);
20 | protected:
21 | virtual void initializeGL() override;
22 | virtual void paintGL() override;
23 | virtual void resizeGL(int w, int h) override;
24 | private:
25 | QTimer timer;
26 | QOpenGLFramebufferObject* xBlurBuffer;
27 | QOpenGLFramebufferObject* yBlurBuffer;
28 | GLFilter* blurFilter;
29 | GLFilter* glowFilter;
30 | QVector guassWeight;
31 | };
32 |
33 | #endif // WIDGET_H
34 |
--------------------------------------------------------------------------------
/Day04_GLSLSandbox/GLSLSandbox.frag:
--------------------------------------------------------------------------------
1 | #ifdef GL_ES
2 | precision mediump float;
3 | #endif
4 |
5 | // glslsandbox uniforms
6 | uniform float time;
7 | uniform vec2 resolution;
8 |
9 | vec3 outCol = vec3 (.0);
10 |
11 | void yonatansFractal (float t, vec2 FC, vec2 r, inout vec3 o)
12 | {
13 | float g=0., e, s, k = t*.2;
14 | for(float i=0.; i < 59.;++i) {
15 | vec3 p = vec3(g*(FC.xy - .5*r)/r.y + .2,g - 1.);
16 | p.xz *= mat2(cos(k),sin(k),-sin(k),cos(k));
17 | s = 3.;
18 | for(int i=0; i < 4; ++i ) {
19 | s *= e = max(1.,(11.-2.*cos(k))/dot(p,p*5.));
20 | p = vec3(2,4,.1) - abs(abs(p)*e - vec3(4,4,2) );
21 | }
22 | g += min(length(p.xz), p.y)/s;
23 | o.rg += (s + .9, 11.3, s/5e4);
24 | }
25 | }
26 |
27 | void main(void)
28 | {
29 | yonatansFractal(time+50., gl_FragCoord.xy, resolution.xy, outCol);
30 | gl_FragColor = vec4(outCol + gl_FragCoord.xyz/resolution.xyy*0.12, 1.)*vec4(0.7,1.5,0,1);
31 | }
32 |
--------------------------------------------------------------------------------
/Day01/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Day02/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Day03/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Day04/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/GLTool/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/WaveEffect/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Day01/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | Widget::Widget(QWidget *parent)
4 | : QOpenGLWidget(parent)
5 | {
6 | }
7 |
8 | Widget::~Widget()
9 | {
10 | }
11 |
12 | void Widget::initializeGL()
13 | {
14 | initializeOpenGLFunctions();
15 | glClearColor(0.0f,0.5f,0.9f,1.0f);
16 | glClear(GL_COLOR_BUFFER_BIT);
17 |
18 | shaderProgram.create();
19 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/gl.vert");
20 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/gl.frag");
21 | shaderProgram.link();
22 | shaderProgram.enableAttributeArray(0);
23 | }
24 |
25 | void Widget::paintGL()
26 | {
27 | shaderProgram.bind();
28 |
29 | float vertices[]={
30 | 0.5f, 0.5f, 0.0f, // 右上角
31 | 0.5f, -0.5f, 0.0f, // 右下角
32 | -0.5f, 0.5f, 0.0f, // 左上角
33 | -0.5f, -0.5f, 0.0f, // 左下角
34 | };
35 | shaderProgram.setAttributeArray(0,GL_FLOAT,vertices,3);
36 | glDrawArrays(GL_TRIANGLE_STRIP,0,4);
37 | }
38 |
39 | void Widget::resizeGL(int w, int h)
40 | {
41 | glViewport(0,0,w,h);
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/Day03_Text2D/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/OpenGLInstance/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Day04_GLSLSandbox/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Section6_GlowEffect/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/OpenGLTransformFeedback/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Section4_2DTextByTool/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/.gitignore:
--------------------------------------------------------------------------------
1 | # This file is used to ignore files which are generated
2 | # ----------------------------------------------------------------------------
3 |
4 | *~
5 | *.autosave
6 | *.a
7 | *.core
8 | *.moc
9 | *.o
10 | *.obj
11 | *.orig
12 | *.rej
13 | *.so
14 | *.so.*
15 | *_pch.h.cpp
16 | *_resource.rc
17 | *.qm
18 | .#*
19 | *.*#
20 | core
21 | !core/
22 | tags
23 | .DS_Store
24 | .directory
25 | *.debug
26 | Makefile*
27 | *.prl
28 | *.app
29 | moc_*.cpp
30 | ui_*.h
31 | qrc_*.cpp
32 | Thumbs.db
33 | *.res
34 | *.rc
35 | /.qmake.cache
36 | /.qmake.stash
37 |
38 | # qtcreator generated files
39 | *.pro.user*
40 |
41 | # xemacs temporary files
42 | *.flc
43 |
44 | # Vim temporary files
45 | .*.swp
46 |
47 | # Visual Studio generated files
48 | *.ib_pdb_index
49 | *.idb
50 | *.ilk
51 | *.pdb
52 | *.sln
53 | *.suo
54 | *.vcproj
55 | *vcproj.*.*.user
56 | *.ncb
57 | *.sdf
58 | *.opensdf
59 | *.vcxproj
60 | *vcxproj.*
61 |
62 | # MinGW generated files
63 | *.Debug
64 | *.Release
65 |
66 | # Python byte code
67 | *.pyc
68 |
69 | # Binaries
70 | # --------
71 | *.dll
72 | *.exe
73 |
74 |
--------------------------------------------------------------------------------
/Day01/Day01.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/Day02/Day02.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/Day03/Day03.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/Day04/Day04.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/Day03_Text2D/Day03_Text2D.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/OpenGLInstance/OpenGLInstance.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/Day04_GLSLSandbox/Day04_GLSLSandbox.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/OpenGLTransformFeedback/OpenGLTransformFeedback.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | RESOURCES += \
31 | shader.qrc
32 |
--------------------------------------------------------------------------------
/GLTool/Test/TestWidget.cpp:
--------------------------------------------------------------------------------
1 | #include "GLTool.h"
2 | #include "TestWidget.h"
3 | Widget::Widget(QWidget *parent)
4 | : QOpenGLWidget(parent)
5 | , texture(QOpenGLTexture::Target2D)
6 | {
7 | }
8 |
9 | Widget::~Widget()
10 | {
11 | }
12 |
13 | void Widget::initializeGL()
14 | {
15 | initializeOpenGLFunctions();
16 | texture.create();
17 | texture.setData(QImage(":image.png").mirrored());
18 |
19 | filter=GLTool::createFilter( //创建一个取反色的滤镜
20 | "#version 450 core\n"
21 | "in vec2 texCoord;\n"
22 | "uniform sampler2D pre;\n"
23 | "out vec4 FragColor;\n"
24 | "void main(){\n"
25 | " FragColor=vec4(1)-vec4(texture(pre,texCoord).xyz,0);\n"
26 | "}");
27 | }
28 |
29 | void Widget::resizeGL(int w, int h)
30 | {
31 | glViewport(0,0,w,h);
32 | }
33 |
34 | void Widget::paintGL()
35 | {
36 | glClear(GL_COLOR_BUFFER_BIT);
37 | GLTool::drawTexture(texture.textureId(),QRectF(-1,-1,1,1),90);
38 | GLTool::drawImage(QImage(":image.png"),QRectF(0,0,1,1),0);
39 | GLTool::drawText("hello",QFont(),QColor(10,100,200),QRectF(0,-1,1,1));
40 | filter->runFilter(rect()); //这里的区域是窗口大小而非标准化坐标
41 | }
42 |
--------------------------------------------------------------------------------
/GLTool/GLFilter.cpp:
--------------------------------------------------------------------------------
1 | #include "GLFilter.h"
2 |
3 |
4 |
5 | GLFilter::GLFilter(const QByteArray& filterCode)
6 | {
7 | VAO.create();
8 | VBO.create();
9 | VAO.bind();
10 | GLfloat vertices[]={
11 | -1, 1, //左上
12 | -1,-1, //左下
13 | 1, 1, //右上
14 | 1,-1 //右下
15 | };
16 | VBO.bind();
17 | VBO.allocate(vertices,sizeof (vertices));
18 | program.create();
19 | program.addShaderFromSourceCode(QOpenGLShader::Vertex,
20 | "#version 450 core\n"
21 | "in layout(location = 0 ) vec2 pos;\n"
22 | "out vec2 texCoord;\n"
23 | "void main(){\n"
24 | " gl_Position=vec4(pos,0,1);\n"
25 | " texCoord=(pos+1)/2;"
26 | "}\n");
27 |
28 | program.addShaderFromSourceCode(QOpenGLShader::Fragment,
29 | filterCode);
30 | program.link();
31 | program.enableAttributeArray(0);
32 | program.setAttributeBuffer(0,GL_FLOAT,0,2);
33 | VAO.release();
34 | VBO.release();
35 | }
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/WaveEffect/widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | class Widget : public QOpenGLWidget ,protected QOpenGLExtraFunctions
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | Widget(QWidget *parent = nullptr);
18 | ~Widget();
19 | protected:
20 | virtual void initializeGL() override;
21 | virtual void paintGL() override;
22 | virtual void resizeGL(int w,int h) override;
23 | virtual void mousePressEvent(QMouseEvent*) override;
24 |
25 | private:
26 | void runMousePoints();
27 | private:
28 | QOpenGLFramebufferObject* FBO;
29 | QOpenGLVertexArrayObject VAO;
30 | QOpenGLBuffer VBO;
31 | QOpenGLTexture background;
32 | QOpenGLShaderProgram waveProgram;
33 | QOpenGLShaderProgram renderProgram;
34 | QVector mouse;
35 | float frequency = 0.1; //频率
36 | float amplitude = 0.1; //最大振幅
37 | float wave_width = 100; //波纹的宽度
38 | float depth = 1; //水平面距离背景图片的深度
39 | float speed = 1000; //水纹的移动速度
40 | float lifetime = 1000;
41 | float lastTime;
42 | };
43 | #endif // WIDGET_H
44 |
--------------------------------------------------------------------------------
/Section6_GlowEffect/Section6_GlowEffect.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 | win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../GLTool/release/ -lGLTool
31 | else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../GLTool/debug/ -lGLTool
32 |
33 | INCLUDEPATH += $$PWD/../GLTool
34 | DEPENDPATH += $$PWD/../GLTool
35 |
--------------------------------------------------------------------------------
/Section4_2DTextByTool/Section4_2DTextByTool.pro:
--------------------------------------------------------------------------------
1 | QT += core gui
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | main.cpp \
20 | widget.cpp
21 |
22 | HEADERS += \
23 | widget.h
24 |
25 | # Default rules for deployment.
26 | qnx: target.path = /tmp/$${TARGET}/bin
27 | else: unix:!android: target.path = /opt/$${TARGET}/bin
28 | !isEmpty(target.path): INSTALLS += target
29 |
30 |
31 | win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../GLTool/release/ -lGLTool
32 | else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../GLTool/debug/ -lGLTool
33 |
34 | INCLUDEPATH += $$PWD/../GLTool
35 | DEPENDPATH += $$PWD/../GLTool
36 |
37 |
--------------------------------------------------------------------------------
/Section4_2DTextByTool/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 | #include
3 | #include
4 | #include "GLTool.h"
5 | Widget::Widget(QWidget *parent)
6 | : QOpenGLWidget(parent)
7 | , texture(QOpenGLTexture::Target2D)
8 | {
9 | timer.setInterval(20); //设置定时器刷新间隔
10 | //定时调用重绘函数repaint(也可以调用update,只不过update不是直接响应)
11 | connect(&timer,&QTimer::timeout,this,static_cast(&QWidget::repaint));
12 | timer.start();
13 | }
14 |
15 | Widget::~Widget()
16 | {
17 | }
18 |
19 | void Widget::initializeGL()
20 | {
21 | initializeOpenGLFunctions();
22 | glClearColor(0,0,0,0);
23 | glClear(GL_COLOR_BUFFER_BIT);
24 | }
25 |
26 | void Widget::paintGL()
27 | {
28 | QString text=QTime::currentTime().toString();
29 | QFont font("微软雅黑",40);
30 | QFontMetrics fontMetrics(font); //Qt中用来测量字体尺寸的
31 | QRect bounding=fontMetrics.boundingRect(text);
32 | QRect viewport(0,0,bounding.width(),bounding.height()); //将OpenGL的视口调整为文字区域,且在屏幕中心
33 | viewport.moveCenter(rect().center());
34 | glViewport(viewport.x(),viewport.y(),viewport.width(),viewport.height());
35 | GLTool::drawText(text,font,QColor(50,100,200)); //绘制纹理,填充整个视口(viewport)
36 | }
37 |
38 | void Widget::resizeGL(int w, int h)
39 | {
40 | glViewport(0,0,w,h);
41 | }
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/Widget.h:
--------------------------------------------------------------------------------
1 | #ifndef WIDGET_H
2 | #define WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | class Widget : public QOpenGLWidget, public QOpenGLExtraFunctions
15 | {
16 | Q_OBJECT
17 |
18 | public:
19 | Widget(QWidget *parent = nullptr);
20 | ~Widget();
21 | int numOfPerFrame = 100;
22 | float lifetime = 1;
23 | double defaultSize=5;
24 | // QOpenGLWidget interface
25 | protected:
26 | virtual void initializeGL() override;
27 | virtual void resizeGL(int w, int h) override;
28 | virtual void paintGL() override;
29 |
30 | protected:
31 | void createParticles();
32 | void updateParticles();
33 | void renderParticles();
34 |
35 | private:
36 | struct Particle{
37 | QVector3D position;
38 | QVector3D velocity;
39 | float size;
40 | float life;
41 | QVector4D color;
42 | };
43 |
44 | QOpenGLShaderProgram updateProgram;
45 | QOpenGLShaderProgram renderProgram;
46 | QOpenGLVertexArrayObject VAO;
47 |
48 | QOpenGLBuffer VBO;
49 | QOpenGLBuffer VBOBuffer;
50 |
51 | GLuint particleQuery;
52 | GLuint currentNumOfParticles = 0;
53 | QTime timeOfLastFrame;
54 | };
55 |
56 | #endif // WIDGET_H
57 |
--------------------------------------------------------------------------------
/Day02/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 | Widget::Widget(QWidget *parent)
3 | : QOpenGLWidget(parent)
4 | , VBO(QOpenGLBuffer::VertexBuffer)
5 | , EBO(QOpenGLBuffer::IndexBuffer)
6 | {
7 | }
8 |
9 | Widget::~Widget()
10 | {
11 | makeCurrent();
12 | }
13 |
14 | void Widget::initializeGL()
15 | {
16 | initializeOpenGLFunctions();
17 | glClearColor(0.0f,0.5f,0.9f,1.0f);
18 | GL_TEXTURE_2D
19 | glClear(GL_COLOR_BUFFER_BIT);
20 | VAO.create();
21 | VAO.bind();
22 | VBO.create();
23 | VBO.bind();
24 | EBO.create();
25 | EBO.bind();
26 | uint elements[]={0,1,3};
27 |
28 | EBO.allocate(elements,sizeof(elements));
29 | float vertices[]={
30 | 0.5f, 0.5f, 0.0f, // 右上角
31 | 0.5f, -0.5f, 0.0f, // 右下角
32 | -0.5f, 0.5f, 0.0f, // 左上角
33 | -0.5f, -0.5f, 0.0f, // 左下角
34 | };
35 | VBO.allocate(vertices,sizeof (vertices));
36 |
37 | shaderProgram.create();
38 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/gl.vert");
39 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/gl.frag");
40 | shaderProgram.link();
41 | shaderProgram.enableAttributeArray(0);
42 | shaderProgram.setAttributeBuffer(0,GL_FLOAT,0,3); //将VBO和EBO的id,以及解析格式存储到VAO中
43 | VAO.release();
44 | VBO.release();
45 | EBO.release();
46 | }
47 |
48 | void Widget::paintGL()
49 | {
50 | shaderProgram.bind();
51 | QOpenGLVertexArrayObject::Binder bind(&VAO);
52 | glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_INT,nullptr);
53 | }
54 |
55 | void Widget::resizeGL(int w, int h)
56 | {
57 | glViewport(0,0,w,h);
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/GLTool/GLTool.cpp:
--------------------------------------------------------------------------------
1 | #include "GLTool.h"
2 | #include
3 | #include
4 | #include
5 | namespace GLTool {
6 | TextureTool* textureTool=nullptr;
7 |
8 | void drawTexture(const QOpenGLTexture &texture, QRectF geomtry, float rotation)
9 | {
10 | drawTexture(texture.textureId(),geomtry, rotation);
11 | }
12 |
13 | GLFilter *createFilter(const QByteArray &code)
14 | {
15 | return new GLFilter(code);
16 | }
17 |
18 | void drawTexture(GLuint textureId, QRectF geomtry, float rotation)
19 | {
20 | if(textureTool==nullptr)
21 | textureTool=new TextureTool();
22 | textureTool->drawTexture(textureId,geomtry,rotation);
23 | }
24 |
25 | void drawImage(QImage image, QRectF geomtry, float rotation)
26 | {
27 | if(textureTool==nullptr)
28 | textureTool=new TextureTool();
29 | textureTool->drawImage(image,geomtry,rotation);
30 | }
31 |
32 | QImage createTextImgae(QString text, QFont font, QColor fontColor)
33 | {
34 | QFontMetrics fontMetrics(font); //Qt中用来测量字体尺寸的
35 | QRect bounding=fontMetrics.boundingRect(text); //获取到字符串的外包矩形
36 | QImage image(bounding.size(),QImage::Format_ARGB32);
37 | image.fill(Qt::transparent); //使用透明色填充Image
38 | QPainter painter(&image);
39 | painter.setRenderHints(QPainter::TextAntialiasing|QPainter::Antialiasing); //开启抗锯齿
40 | painter.setFont(font);
41 | painter.setPen(fontColor);
42 | painter.drawText(QRect(0,0,image.width(),image.height()),Qt::AlignCenter,text);
43 | painter.end();
44 | return image;
45 | }
46 |
47 | void drawText(QString text, QFont font, QColor fontColor, QRectF geomtry, float rotation)
48 | {
49 | if(textureTool==nullptr)
50 | textureTool=new TextureTool();
51 | textureTool->drawImage(createTextImgae(text,font,fontColor),geomtry,rotation);
52 | }
53 |
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/GLTool/GLTool.h:
--------------------------------------------------------------------------------
1 | #ifndef GLTOOL_H
2 | #define GLTOOL_H
3 |
4 | #include "TextureTool.h"
5 | #include "GLFilter.h"
6 | #include
7 | #include
8 | #include
9 |
10 | /**
11 | * 所有的工具函数接口将置于此命名空间中
12 | */
13 |
14 | namespace GLTool {
15 | extern TextureTool* textureTool;
16 |
17 | /**
18 | * @brief drawTexture 该函数用于在指定区域绘制纹理图形
19 | * @param texture 纹理对象
20 | * @param geomtry 图像将绘制在该标准化坐标区域
21 | * @param rotation 按纹理中心进行旋转的旋转角度
22 | */
23 | void drawTexture(const QOpenGLTexture& texture, QRectF geomtry=QRectF(-1,-1,2,2), float rotation=0);
24 |
25 | /**
26 | * @brief drawTexture 该函数用于在指定区域绘制纹理图形
27 | * @param textureId 纹理对象的id
28 | * @param geomtry 图像将绘制在该标准化坐标区域
29 | * @param rotation 按纹理中心进行旋转的旋转角度
30 | */
31 | void drawTexture(GLuint textureId, QRectF geomtry=QRectF(-1,-1,2,2), float rotation=0);
32 |
33 | /**
34 | * @brief drawImage 该函数用于在指定区域绘制QImage
35 | * @param image QImage对象
36 | * @param geomtry 图像将绘制在该标准化坐标区域
37 | * @param rotation 按纹理中心进行旋转的旋转角度
38 | */
39 | void drawImage(QImage image, QRectF geomtry=QRectF(-1,-1,2,2), float rotation=0);
40 |
41 | /**
42 | * @brief drawText 该函数用于在指定区域绘制文字
43 | * @param text 文字内容
44 | * @param font 字体属性(包含字体类型,字体大小,加粗,斜体等数据)
45 | * @param fontColor 字体颜色
46 | * @param geomtry 图像将绘制在该标准化坐标区域
47 | * @param rotation 按纹理中心进行旋转的旋转角度
48 | */
49 | void drawText(QString text, QFont font=QFont(), QColor fontColor=Qt::red, QRectF geomtry=QRectF(-1,-1,2,2), float rotation=0);
50 |
51 | /**
52 | * @brief createTextImgae 该函数用于创建文字的QImage图像,使用该Image能实现3D文字的显示
53 | * @param text 文字内容
54 | * @param font 字体属性(包含字体类型,字体大小,加粗,斜体等数据)
55 | * @param fontColor 字体颜色
56 | * @return 返回文字的QImage
57 | */
58 | QImage createTextImgae(QString text, QFont font=QFont(), QColor fontColor=Qt::red);
59 | GLFilter* createFilter(const QByteArray& code);
60 | }
61 |
62 | #endif // GLTOOL_H
63 |
--------------------------------------------------------------------------------
/Day04_GLSLSandbox/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 | #include
3 | #include
4 |
5 | Widget::Widget(QWidget *parent)
6 | : QOpenGLWidget(parent)
7 | {
8 | QTimer *timer=new QTimer;
9 | connect(timer,&QTimer::timeout,this,static_cast(&QWidget::repaint));
10 | timer->setInterval(17);
11 | timer->start();
12 | }
13 |
14 | Widget::~Widget()
15 | {
16 | }
17 |
18 | void Widget::initializeGL()
19 | {
20 | initializeOpenGLFunctions();
21 | glClearColor(0,0,0,0);
22 | shaderProgram.create();
23 |
24 | shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex,"#version 450 core\n"
25 | "layout(location = 0) in vec2 aPos;\n"
26 | "void main(){\n"
27 | " gl_Position = vec4(aPos,0,1); \n"
28 | "}");
29 |
30 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/GLSLSandbox.frag");
31 | shaderProgram.link();
32 | shaderProgram.enableAttributeArray(0); //开启0号顶点数据
33 | }
34 |
35 | void Widget::paintGL()
36 | {
37 | glClear(GL_COLOR_BUFFER_BIT);
38 | shaderProgram.bind();
39 |
40 | float time=QTime::currentTime().msecsSinceStartOfDay()/1000.0f;
41 | shaderProgram.setUniformValue("time",time); //输入时间
42 |
43 | QVector2D resolution(this->width(),this->height()); //输入窗口分辨率
44 | shaderProgram.setUniformValue("resolution",resolution);
45 |
46 | QVector2D vertices[4]={
47 | {-1,-1},
48 | {-1, 1},
49 | { 1,-1},
50 | { 1, 1}};
51 |
52 | shaderProgram.setAttributeArray(0,vertices); //从客户端传递顶点数据
53 |
54 | glDrawArrays(GL_TRIANGLE_STRIP,0,4); //需要保证没有绑定VAO和VBO
55 |
56 | shaderProgram.release();
57 | }
58 |
59 | void Widget::resizeGL(int w, int h)
60 | {
61 | glViewport(0,0,w,h);
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/OpenGLTransformFeedback/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | Widget::Widget(QWidget *parent)
4 | : QOpenGLWidget(parent)
5 | , VBO(QOpenGLBuffer::VertexBuffer)
6 | , VBOBuffer(QOpenGLBuffer::IndexBuffer)
7 | {
8 | }
9 |
10 | Widget::~Widget()
11 | {
12 | makeCurrent();
13 | }
14 |
15 | void Widget::initializeGL()
16 | {
17 | initializeOpenGLFunctions();
18 | glClearColor(0.0f,0.5f,0.9f,1.0f);
19 | glClear(GL_COLOR_BUFFER_BIT);
20 | float vertices[]={
21 | 0.5f, 0.5f, 0.0f, // 右上角
22 | 0.5f, -0.5f, 0.0f, // 右下角
23 | -0.5f, 0.5f, 0.0f, // 左上角
24 | -0.5f, -0.5f, 0.0f, // 左下角
25 | };
26 | VAO.create();
27 | VAO.bind();
28 | VBO.create();
29 | VBO.bind();
30 | VBO.allocate(vertices,sizeof (vertices));
31 |
32 | shaderProgram.create();
33 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/feedback.vert");
34 |
35 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Geometry,":/feedback.geom");
36 |
37 | const char* var[]={"outValue"};
38 |
39 | glTransformFeedbackVaryings(shaderProgram.programId(),1,var,GL_INTERLEAVED_ATTRIBS);
40 | shaderProgram.link();
41 | shaderProgram.enableAttributeArray(0);
42 | shaderProgram.setAttributeBuffer(0,GL_FLOAT,0,1); //将VBO和EBO的id,以及解析格式存储到VAO中
43 | VBOBuffer.create();
44 | VBOBuffer.bind();
45 | VBOBuffer.allocate(sizeof (vertices));
46 | VAO.release();
47 | VBO.release();
48 | VBOBuffer.release();
49 | }
50 |
51 | void Widget::paintGL()
52 | {
53 | shaderProgram.bind();
54 | QOpenGLVertexArrayObject::Binder bind(&VAO);
55 | glEnable(GL_RASTERIZER_DISCARD);
56 | glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,0,VBOBuffer.bufferId());
57 | glBeginTransformFeedback(GL_POINTS);
58 | glDrawArrays(GL_POINTS,0,3);
59 | glEndTransformFeedback();
60 | glDisable(GL_RASTERIZER_DISCARD);
61 | VBOBuffer.bind();
62 | float s[12]={0};
63 | VBOBuffer.read(0,s,48);
64 | for(int i=0;i<12;i++)
65 | qDebug()<
3 | #include
4 |
5 | TextureTool::TextureTool()
6 | {
7 | VAO.create();
8 | VBO.create();
9 | VAO.bind();
10 | GLfloat vertices[]={
11 | -1, 1, //左上
12 | -1,-1, //左下
13 | 1, 1, //右上
14 | 1,-1 //右下
15 | };
16 | VBO.bind();
17 | VBO.allocate(vertices,sizeof (vertices));
18 | program.create();
19 | program.addShaderFromSourceCode(QOpenGLShader::Vertex,
20 | "#version 450 core\n"
21 | "in layout(location = 0 ) vec2 pos;\n"
22 | "out vec2 texCoord;\n"
23 | "uniform mat4 model;\n"
24 | "void main(){\n"
25 | " gl_Position=model*vec4(pos,0,1);\n"
26 | " texCoord=(pos+1)/2;"
27 | "}\n");
28 |
29 | program.addShaderFromSourceCode(QOpenGLShader::Fragment,
30 | "#version 450 core\n"
31 | "in vec2 texCoord;\n"
32 | "uniform sampler2D tex;\n"
33 | "out vec4 FragColor;\n"
34 | "void main(){\n"
35 | " FragColor=texture(tex,texCoord);\n"
36 | "}\n");
37 | program.link();
38 | program.enableAttributeArray(0);
39 | program.setAttributeBuffer(0,GL_FLOAT,0,2);
40 | VAO.release();
41 | VBO.release();
42 | }
43 |
44 | void TextureTool::drawTexture(GLuint textureId, QRectF geomtry, float rotation)
45 | {
46 | QOpenGLFunctions *func =QOpenGLContext::currentContext()->functions();
47 | QOpenGLVertexArrayObject::Binder bind(&VAO);
48 | program.bind();
49 | QMatrix4x4 model;
50 | model.translate(geomtry.center().x(),geomtry.center().y());
51 | model.rotate(rotation,QVector3D(0,0,1));
52 | model.scale(geomtry.width()/2,geomtry.height()/2);
53 | program.setUniformValue("model",model);
54 | func->glActiveTexture(GL_TEXTURE0);
55 | func->glBindTexture(GL_TEXTURE_2D,textureId);
56 | func->glDrawArrays(GL_TRIANGLE_STRIP,0,4);
57 | program.release();
58 | }
59 |
60 | void TextureTool::drawImage(QImage image, QRectF geomtry, float rotation)
61 | {
62 | QOpenGLTexture texture(QOpenGLTexture::Target2D);
63 | texture.create();
64 | texture.setMinMagFilters(QOpenGLTexture::Linear,QOpenGLTexture::Linear);
65 | texture.setData(image.mirrored());
66 | drawTexture(texture.textureId(),geomtry,rotation);
67 | }
68 |
--------------------------------------------------------------------------------
/Day03_Text2D/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 | #include
3 | #include
4 |
5 |
6 | Widget::Widget(QWidget *parent)
7 | : QOpenGLWidget(parent)
8 | , texture(QOpenGLTexture::Target2D)
9 | {
10 | timer.setInterval(20); //设置定时器刷新间隔
11 | //定时调用重绘函数repaint(也可以调用update,只不过update不是直接响应)
12 | connect(&timer,&QTimer::timeout,this,static_cast(&QWidget::repaint));
13 | timer.start();
14 | }
15 |
16 | Widget::~Widget()
17 | {
18 | }
19 |
20 | void Widget::initializeGL()
21 | {
22 | initializeOpenGLFunctions();
23 | glClearColor(0,0,0,0);
24 | glClear(GL_COLOR_BUFFER_BIT);
25 |
26 | VAO.create();
27 | QOpenGLVertexArrayObject::Binder bind(&VAO);
28 | VBO.create();
29 | VBO.bind();
30 | float vertex[]={
31 | //顶点 //纹理坐标
32 | -1.0f,-1.0f, 0.0f,0.0f, //左下
33 | -1.0f, 1.0f, 0.0f,1.0f, //左上
34 | 1.0f,-1.0f, 1.0f,0.0f, //右下
35 | 1.0f, 1.0f, 1.0f,1.0f //右上
36 | };
37 |
38 | VBO.allocate(vertex,sizeof (vertex));
39 | shaderProgram.create();
40 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/text.vert");
41 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/text.frag");
42 | shaderProgram.link();
43 | shaderProgram.enableAttributeArray(0);
44 | shaderProgram.enableAttributeArray(1);
45 | shaderProgram.setAttributeBuffer(0,GL_FLOAT,0, 2,4*sizeof (float));
46 | shaderProgram.setAttributeBuffer(1,GL_FLOAT,2*sizeof (float),2,4*sizeof (float));
47 | VBO.release();
48 | }
49 |
50 | void Widget::paintGL()
51 | {
52 | shaderProgram.bind();
53 | flushTexture();
54 | texture.bind(0);
55 | shaderProgram.setUniformValue("texture",0);
56 | QOpenGLVertexArrayObject::Binder bind(&VAO);
57 | glDrawArrays(GL_TRIANGLE_STRIP,0,4);
58 | shaderProgram.release();
59 | }
60 |
61 | void Widget::resizeGL(int w, int h)
62 | {
63 | glViewport(0,0,w,h);
64 | }
65 |
66 | void Widget::flushTexture()
67 | {
68 | QString text=QTime::currentTime().toString();
69 | QFont font("微软雅黑",50);
70 | QFontMetrics fontMetrics(font); //Qt中用来测量字体尺寸的
71 | QRect bounding=fontMetrics.boundingRect(text); //获取到字符串的外包矩形
72 | QImage image(bounding.size(),QImage::Format_ARGB32);
73 | image.fill(Qt::transparent); //使用透明色填充Image
74 | QPainter painter(&image);
75 | painter.setFont(font);
76 | painter.setPen(QColor(0,90,200));
77 | painter.drawText(QRect(0,0,image.width(),image.height()),Qt::AlignCenter,text);
78 | painter.end();
79 | if(texture.isCreated())
80 | texture.destroy(); //销毁纹理,重新分配存储
81 | texture.create(); //通过这种方法来实现动态纹理适应于纹理尺寸会动态变化的情况,内存分配会占用一定性能,但在这里影响微乎其微(如果是绘制视频帧,那么就需要提前分配存储,之后动态上传像素数据)
82 | texture.setData(image.mirrored());
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/OpenGLInstance/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | Widget::Widget(QWidget *parent)
4 | : QOpenGLWidget(parent)
5 | {
6 | }
7 |
8 | Widget::~Widget()
9 | {
10 | }
11 |
12 | void Widget::initializeGL()
13 | {
14 | initializeOpenGLFunctions();
15 | glClearColor(0,0,0,1);
16 |
17 | float quadVertices[] = {
18 | // 位置 // 颜色
19 | -0.05f, 0.05f, 1.0f, 0.0f, 0.0f,
20 | 0.05f, -0.05f, 0.0f, 1.0f, 0.0f,
21 | -0.05f, -0.05f, 0.0f, 0.0f, 1.0f,
22 |
23 | -0.05f, 0.05f, 1.0f, 0.0f, 0.0f,
24 | 0.05f, -0.05f, 0.0f, 1.0f, 0.0f,
25 | 0.05f, 0.05f, 0.0f, 1.0f, 1.0f
26 | };
27 | VAO.create();
28 | VAO.bind();
29 | VBO.create();
30 | VBO.bind();
31 | VBO.allocate(quadVertices,sizeof (quadVertices));
32 |
33 | shaderProgram.create();
34 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/gl.vert");
35 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/gl.frag");
36 | shaderProgram.link();
37 | shaderProgram.enableAttributeArray(0);
38 | shaderProgram.enableAttributeArray(1);
39 | shaderProgram.setAttributeBuffer(0,GL_FLOAT,0,2,5*sizeof (float));
40 | shaderProgram.setAttributeBuffer(1,GL_FLOAT,2*sizeof (float),3,5*sizeof (float));
41 |
42 |
43 |
44 | float offset = 0.1f;
45 | QVector vec;
46 | for(int y = -10; y < 10; y += 2)
47 | {
48 | for(int x = -10; x < 10; x += 2)
49 | {
50 | QMatrix4x4 mat;
51 | mat.translate(x/ 10.0f + offset,y / 10.0f + offset);
52 | mat.rotate((x+y)*10,QVector3D(0,0,1));
53 | vec.push_back(mat.column(0));
54 | vec.push_back(mat.column(1));
55 | vec.push_back(mat.column(2));
56 | vec.push_back(mat.column(3));
57 | }
58 | }
59 |
60 | instanceVBO.create();
61 | instanceVBO.bind();
62 | instanceVBO.allocate(vec.data(),vec.size()*sizeof (QVector4D));
63 | shaderProgram.enableAttributeArray(2);
64 | shaderProgram.setAttributeBuffer(2,GL_FLOAT,0,4,4*sizeof (QVector4D));
65 | glVertexAttribDivisor(2,1);
66 |
67 | shaderProgram.enableAttributeArray(3);
68 | shaderProgram.setAttributeBuffer(3,GL_FLOAT,1*sizeof (QVector4D),4,4*sizeof (QVector4D));
69 | glVertexAttribDivisor(3,1);
70 |
71 | shaderProgram.enableAttributeArray(4);
72 | shaderProgram.setAttributeBuffer(4,GL_FLOAT,2*sizeof (QVector4D),4,4*sizeof (QVector4D));
73 | glVertexAttribDivisor(4,1);
74 |
75 | shaderProgram.enableAttributeArray(5);
76 | shaderProgram.setAttributeBuffer(5,GL_FLOAT,3*sizeof (QVector4D),4,4*sizeof (QVector4D));
77 | glVertexAttribDivisor(5,1);
78 |
79 | instanceVBO.release();
80 |
81 | }
82 |
83 | void Widget::paintGL()
84 | {
85 | VAO.bind();
86 | shaderProgram.bind();
87 | glDrawArraysInstanced(GL_TRIANGLES,0,6,100);
88 | }
89 |
90 | void Widget::resizeGL(int w, int h)
91 | {
92 | glViewport(0,0,w,h);
93 | }
94 |
95 |
--------------------------------------------------------------------------------
/Day04/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 | #include
3 | #include
4 |
5 | Widget::Widget(QWidget *parent)
6 | : QOpenGLWidget(parent)
7 | , VBO(QOpenGLBuffer::VertexBuffer)
8 | , EBO(QOpenGLBuffer::IndexBuffer)
9 | , texture(QOpenGLTexture::Target2D)
10 | {
11 | connect(&timer,&QTimer::timeout,this,static_cast(&QWidget::repaint));
12 | timer.setInterval(17); //设置刷新间隔为17ms,约为60帧
13 | timer.start();
14 | }
15 |
16 | Widget::~Widget()
17 | {
18 | makeCurrent();
19 | }
20 |
21 | void Widget::initializeGL()
22 | {
23 | initializeOpenGLFunctions(); //初始化QOpenGLFunctions,其本质是将QOpenGLFunctions与当前OpenGL上下文进行绑定
24 | glClearColor(0.0f,0.5f,0.9f,1.0f); //设置清屏颜色
25 | glClear(GL_COLOR_BUFFER_BIT); //清空颜色缓存区
26 | VAO.create();
27 | VAO.bind();
28 | VBO.create();
29 | VBO.bind();
30 | EBO.create();
31 | EBO.bind();
32 |
33 | uint elements[]={0,1,2,3};
34 | EBO.allocate(elements,sizeof(elements));//向GPU申请分配EBO内存,并把索引数组写入到EBO中
35 |
36 | float vertices[]={
37 | 0.5f, 0.5f, 0.0f, 1.0f, 1.0f, // 右上角
38 | 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, // 右下角
39 | -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, // 左上角
40 | -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, // 左下角
41 | };
42 |
43 | VBO.allocate(vertices,sizeof (vertices));
44 |
45 | texture.create(); //向GPU申请创建纹理对象
46 | texture.setData(QImage(":/OpenGL.jpg").mirrored()); //从QImage导入像素数据(内部会自动设置格式和分配存储)
47 |
48 | shaderProgram.create();
49 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/gl.vert");
50 | shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/gl.frag");
51 | shaderProgram.link();
52 |
53 | shaderProgram.enableAttributeArray(0);
54 | shaderProgram.setAttributeBuffer(0,GL_FLOAT,0,3,5*sizeof (float)); //将VBO和EBO的id,以及解析格式存储到当前VAO中
55 |
56 | shaderProgram.enableAttributeArray(1);
57 | shaderProgram.setAttributeBuffer(1,GL_FLOAT,3*sizeof (float),2,5*sizeof (float));
58 |
59 | VAO.release();
60 | VBO.release(); //作用同 QOpenGLBuffer::release(QOpenGLBuffer::VertexBuffer)
61 | EBO.release(); //作用同 QOpenGLBuffer::release(QOpenGLBuffer::IndexBuffer)
62 | }
63 |
64 | void Widget::paintGL()
65 | {
66 | shaderProgram.bind();
67 | texture.bind(0); //将纹理对象绑定到0号纹理单元
68 | shaderProgram.setUniformValue("texture",0); //设置采样器[sample texture]从0号纹理单元获取数据
69 |
70 | double sec=QTime::currentTime().msecsSinceStartOfDay()/1000.0; //获取当前时间的毫秒数,除以1000.0得到精度为0.001的秒数。
71 | float mValue = qAbs(qSin(sec)); //setUniformValue并没有以double为参数的封装,因此需要使用float
72 | shaderProgram.setUniformValue("mValue",mValue); //设置uniform中【mValue】的值
73 |
74 | QOpenGLVertexArrayObject::Binder bind(&VAO); //构造时调用VAO.bind(),析构时调用VAO.release()
75 | glDrawElements(GL_TRIANGLE_STRIP,4,GL_UNSIGNED_INT,nullptr);
76 | }
77 |
78 | void Widget::resizeGL(int w, int h)
79 | {
80 | glViewport(0,0,w,h);
81 | }
82 |
83 |
--------------------------------------------------------------------------------
/GLTool/GLFilter.h:
--------------------------------------------------------------------------------
1 | #ifndef GLFILTER_H
2 | #define GLFILTER_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class GLFilter
11 | {
12 | public:
13 | GLFilter(const QByteArray &filterCode);
14 | template>
15 | void runFilter(QOpenGLFramebufferObject * readFBO, QRect readGeomtry, QOpenGLFramebufferObject * writeFBO, QRect drawGeomtry,ShaderProgramFunction function=[](QOpenGLShaderProgram&){})
16 | {
17 | QOpenGLFunctions* func=QOpenGLContext::currentContext()->functions();
18 | if(fbo!=nullptr&&fbo->size()!=readGeomtry.size())
19 | delete fbo;
20 | if(fbo==nullptr)
21 | fbo=new QOpenGLFramebufferObject(readGeomtry.width(),readGeomtry.height());
22 | QOpenGLFramebufferObject::blitFramebuffer(fbo,QRect(0,0,fbo->width(),fbo->height()),readFBO,readGeomtry);
23 | if(writeFBO!=nullptr)
24 | writeFBO->bind();
25 |
26 | program.bind();
27 | func->glActiveTexture(GL_TEXTURE0);
28 | func->glBindTexture(GL_TEXTURE_2D,fbo->texture());
29 | function(program);
30 | QOpenGLVertexArrayObject::Binder binder(&VAO);
31 | func->glDrawArrays(GL_TRIANGLE_STRIP,0,4);
32 | if(writeFBO!=nullptr)
33 | writeFBO->release();
34 | program.release();
35 | }
36 |
37 | template>
38 | void runFilter(QRect geomtry,ShaderProgramFunction function=[](QOpenGLShaderProgram&){})
39 | {
40 | QOpenGLFunctions* func=QOpenGLContext::currentContext()->functions();
41 | if(fbo!=nullptr&&fbo->size()!=geomtry.size())
42 | delete fbo;
43 |
44 | GLuint prevFbo = 0; //获取当前绑定的FBO
45 | func->glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *) &prevFbo);
46 | if(fbo==nullptr)
47 | fbo=new QOpenGLFramebufferObject(geomtry.width(),geomtry.height()); //由于Qt创建FBO的同时会进行绑定
48 | QOpenGLFramebufferObject::blitFramebuffer(fbo,QRect(0,0,fbo->width(),fbo->height()),nullptr,geomtry);
49 |
50 | func->glBindFramebuffer(GL_FRAMEBUFFER,prevFbo); //所以要在这里进行复原
51 |
52 | GLint preViewport[4] = {0};
53 | func->glGetIntegerv(GL_VIEWPORT, preViewport); //获取当前的viewport数据
54 |
55 | func->glViewport(geomtry.x(),geomtry.y(),geomtry.width(),geomtry.height());
56 |
57 | func->glScissor(geomtry.x(),geomtry.y(),geomtry.width(),geomtry.height()); //清除指定区域
58 | func->glEnable(GL_SCISSOR_TEST);
59 | func->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
60 | func->glDisable(GL_SCISSOR_TEST);
61 | program.bind();
62 |
63 | func->glActiveTexture(GL_TEXTURE0);
64 | func->glBindTexture(GL_TEXTURE_2D,fbo->texture());
65 |
66 | function(program);
67 |
68 | QOpenGLVertexArrayObject::Binder binder(&VAO);
69 |
70 | func->glDrawArrays(GL_TRIANGLE_STRIP,0,4);
71 | program.release();
72 | func->glViewport(preViewport[0],preViewport[1],preViewport[2],preViewport[3]);
73 | }
74 | private:
75 | QOpenGLVertexArrayObject VAO;
76 | QOpenGLBuffer VBO;
77 | QOpenGLShaderProgram program;
78 | QOpenGLFramebufferObject* fbo=nullptr;
79 | };
80 |
81 | #endif // GLFILTER_H
82 |
--------------------------------------------------------------------------------
/WaveEffect/widget.cpp:
--------------------------------------------------------------------------------
1 | #include "widget.h"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | Widget::Widget(QWidget *parent)
8 | : QOpenGLWidget(parent)
9 | , background(QOpenGLTexture::Target2D)
10 | {
11 | QTimer *timer = new QTimer();
12 | connect(timer,&QTimer::timeout,this,static_cast(&QWidget::repaint));
13 | timer->setInterval(17);
14 | timer->start();
15 | }
16 |
17 | Widget::~Widget()
18 | {
19 | makeCurrent();
20 | }
21 |
22 | void Widget::initializeGL()
23 | {
24 | initializeOpenGLFunctions ();
25 | VAO.create ();
26 | VBO.create ();
27 | FBO=new QOpenGLFramebufferObject(size(),QOpenGLFramebufferObject::NoAttachment,GL_TEXTURE_2D,GL_RED);
28 | waveProgram.create();
29 | renderProgram.create();
30 | waveProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/wave.vert");
31 | waveProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/wave.frag");
32 | waveProgram.link();
33 |
34 | renderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/render.vert");
35 | renderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/render.frag");
36 | renderProgram.link();
37 |
38 | background.create();
39 | background.setWrapMode(QOpenGLTexture::MirroredRepeat);
40 | background.setMinMagFilters(QOpenGLTexture::Linear,QOpenGLTexture::Linear);
41 | background.setData(QImage(":/background.jpg").mirrored());
42 |
43 | VAO.bind ();
44 | VBO.bind ();
45 | float vertices[]={
46 | -1,-1,
47 | 1,-1,
48 | -1, 1,
49 | 1, 1,
50 | };
51 |
52 | VBO.allocate (vertices,sizeof (vertices));
53 | waveProgram.setAttributeBuffer(0,GL_FLOAT,0,2,2*sizeof (float));
54 | waveProgram.enableAttributeArray(0);
55 | renderProgram.enableAttributeArray(0);;
56 | VBO.release();
57 | VAO.release();
58 |
59 | lastTime=QTime::currentTime().msecsSinceStartOfDay();
60 |
61 | }
62 |
63 | void Widget::paintGL()
64 | {
65 | glClear(GL_COLOR_BUFFER_BIT);
66 | QOpenGLVertexArrayObject::Binder bind(&VAO);
67 | FBO->bind();
68 | waveProgram.bind();
69 | waveProgram.setUniformValueArray("mouse",mouse.data(),mouse.size());
70 | waveProgram.setUniformValue("size",mouse.size());
71 | waveProgram.setUniformValue("frequency",frequency);
72 | waveProgram.setUniformValue("amplitude",amplitude);
73 | waveProgram.setUniformValue("wave_width",wave_width);
74 | waveProgram.setUniformValue("speed",speed);
75 | glDrawArrays(GL_TRIANGLE_STRIP,0,4);
76 | FBO->release();
77 |
78 | renderProgram.bind();
79 | glActiveTexture(GL_TEXTURE0);
80 | glBindTexture(GL_TEXTURE_2D,FBO->texture());
81 | background.bind(1);
82 | renderProgram.setUniformValue("wave",0);
83 | renderProgram.setUniformValue("background",1);
84 | renderProgram.setUniformValue("screen_width",QVector2D(width(),height()));
85 | renderProgram.setUniformValue("depth",depth);
86 | GL_RGBA
87 | glDrawArrays(GL_TRIANGLE_STRIP,0,4);
88 | runMousePoints();
89 | }
90 |
91 | void Widget::resizeGL(int w, int h)
92 | {
93 | glViewport (0,0,w,h);
94 | delete FBO;
95 | FBO=new QOpenGLFramebufferObject(w,h,QOpenGLFramebufferObject::NoAttachment,GL_TEXTURE_2D,GL_RED);
96 | }
97 |
98 | void Widget::mousePressEvent(QMouseEvent *e)
99 | {
100 | mouse.push_back(QVector3D(e->x(),height()-e->y(),0));
101 | }
102 |
103 | void Widget::runMousePoints()
104 | {
105 | float currentTime=QTime::currentTime().msecsSinceStartOfDay();
106 | float dure=currentTime-lastTime;
107 | float run=dure/lifetime;
108 | QVector temp;
109 | for(auto it:mouse){
110 | QVector3D m=it+QVector3D(0,0,run);
111 | if(m.z()<=1)
112 | temp.push_back(m);
113 | }
114 | mouse=temp;
115 | lastTime=currentTime;
116 | }
117 |
118 |
--------------------------------------------------------------------------------
/Section7_GPUParticleSystem/Widget.cpp:
--------------------------------------------------------------------------------
1 | #include "Widget.h"
2 |
3 | #include
4 |
5 | const int MAX_PARTICLES_SIZE = 1000000;
6 |
7 | Widget::Widget(QWidget *parent)
8 | : QOpenGLWidget(parent)
9 | {
10 | setMinimumSize(800,600);
11 | QTimer *timer=new QTimer(this);
12 | timer->setInterval(18); //设置定时器刷新间隔
13 | //定时调用重绘函数repaint(也可以调用update,只不过update不是直接响应)
14 | connect(timer,&QTimer::timeout,this,static_cast(&QWidget::repaint));
15 | timer->start();
16 | }
17 |
18 | Widget::~Widget()
19 | {
20 | }
21 |
22 | void Widget::initializeGL()
23 | {
24 | initializeOpenGLFunctions();
25 |
26 | VBO.create();
27 | VBO.bind();
28 | VBO.setUsagePattern(QOpenGLBuffer::DynamicDraw);
29 | VBO.allocate(sizeof (Particle)*MAX_PARTICLES_SIZE);
30 |
31 | VBOBuffer.create();
32 | VBOBuffer.bind();
33 | VBOBuffer.setUsagePattern(QOpenGLBuffer::DynamicDraw);
34 | VBOBuffer.allocate(sizeof (Particle)*MAX_PARTICLES_SIZE);
35 |
36 | glGenQueries(1,&particleQuery);
37 |
38 | VAO.create();
39 | VAO.bind();
40 |
41 | updateProgram.create();
42 | updateProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/ParticleRunner.vert");
43 | updateProgram.addShaderFromSourceFile(QOpenGLShader::Geometry,":/ParticleRunner.geom");
44 |
45 | const char* feedbackVar[5]={"position","velocity","size","life","color"};
46 | glTransformFeedbackVaryings(updateProgram.programId(),5,feedbackVar,GL_INTERLEAVED_ATTRIBS);
47 | updateProgram.link();
48 |
49 | VBO.bind();
50 | updateProgram.enableAttributeArray(0);
51 | updateProgram.enableAttributeArray(1);
52 | updateProgram.enableAttributeArray(2);
53 | updateProgram.enableAttributeArray(3);
54 | updateProgram.enableAttributeArray(4);
55 |
56 | renderProgram.create();
57 | renderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/ParticleRender.vert");
58 | renderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/ParticleRender.frag");
59 | renderProgram.link();
60 |
61 | timeOfLastFrame=QTime::currentTime();
62 |
63 | glEnable(GL_PROGRAM_POINT_SIZE);
64 | }
65 |
66 | void Widget::resizeGL(int w, int h)
67 | {
68 | glViewport(0,0,w,h);
69 | }
70 |
71 | void Widget::paintGL()
72 | {
73 | createParticles();
74 | updateParticles();
75 | renderParticles();
76 | }
77 |
78 | void Widget::createParticles()
79 | {
80 | VAO.bind();
81 | VBO.bind();
82 | QVector createBuffer;
83 | for(int i=0;i
3 | #include
4 | #include
5 | #include "GLTool.h"
6 | Widget::Widget(QWidget *parent)
7 | : QOpenGLWidget(parent)
8 | {
9 | timer.setInterval(20); //设置定时器刷新间隔
10 | //定时调用重绘函数repaint(也可以调用update,只不过update不是直接响应)
11 | connect(&timer,&QTimer::timeout,this,static_cast(&QWidget::repaint));
12 | timer.start();
13 |
14 | QSurfaceFormat format;
15 | format.setSamples(10);
16 | this->setFormat(format);
17 | }
18 |
19 | Widget::~Widget()
20 | {
21 | }
22 |
23 | void Widget::setBlurRadius(int radius)
24 | {
25 | Q_ASSERT(radius>=1);
26 | guassWeight.resize(radius); //由于高斯函数是对称,所以只要存取一半
27 | guassWeight[0]=1; //初始化第一个值
28 | float sum=guassWeight[0];
29 | for(int i=1;irunFilter(xBlurBuffer,rect(),yBlurBuffer,rect(),[this](QOpenGLShaderProgram& program){
104 | program.setUniformValue("horizontal",true);
105 | program.setUniformValueArray("guassWeight",guassWeight.data(),guassWeight.size(),1);
106 | program.setUniformValue("blurRadius",guassWeight.size());
107 | });
108 |
109 | blurFilter->runFilter(yBlurBuffer,rect(),xBlurBuffer,rect(),[](QOpenGLShaderProgram& program){
110 | program.setUniformValue("horizontal",false);
111 | });
112 | }
113 |
114 |
115 | // GLTool::drawTexture(xBlurBuffer->texture());
116 | glowFilter->runFilter(rect(),[this](QOpenGLShaderProgram& program){
117 | glActiveTexture(GL_TEXTURE1);
118 | glBindTexture(GL_TEXTURE_2D,xBlurBuffer->texture());
119 | program.setUniformValue("blurTex",1);
120 | program.setUniformValue("exposure",10.0f);
121 | program.setUniformValue("gamma",0.9f);
122 | });
123 |
124 | }
125 |
126 | void Widget::resizeGL(int w, int h)
127 | {
128 | glViewport(0,0,w,h);
129 |
130 | delete xBlurBuffer;
131 | xBlurBuffer=new QOpenGLFramebufferObject(w,h); //重新帧缓存对象
132 |
133 | delete yBlurBuffer;
134 | yBlurBuffer=new QOpenGLFramebufferObject(w,h);
135 | }
136 |
137 |
138 |
--------------------------------------------------------------------------------
/Day02/Day02.pro.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EnvironmentId
7 | {5c12fb76-d31c-402c-94e9-10f732a8a47a}
8 |
9 |
10 | ProjectExplorer.Project.ActiveTarget
11 | 0
12 |
13 |
14 | ProjectExplorer.Project.EditorSettings
15 |
16 | true
17 | false
18 | true
19 |
20 | Cpp
21 |
22 | CppGlobal
23 |
24 |
25 |
26 | QmlJS
27 |
28 | QmlJSGlobal
29 |
30 |
31 | 2
32 | UTF-8
33 | false
34 | 4
35 | false
36 | 80
37 | true
38 | true
39 | 1
40 | true
41 | false
42 | 0
43 | true
44 | true
45 | 0
46 | 8
47 | true
48 | 1
49 | true
50 | true
51 | true
52 | *.md, *.MD, Makefile
53 | false
54 | true
55 |
56 |
57 |
58 | ProjectExplorer.Project.PluginSettings
59 |
60 |
61 | true
62 | true
63 | true
64 | true
65 | true
66 |
67 |
68 | 0
69 | true
70 |
71 | -fno-delayed-template-parsing
72 |
73 | true
74 | Builtin.Questionable
75 |
76 | true
77 | true
78 | Builtin.DefaultTidyAndClazy
79 | 2
80 |
81 |
82 |
83 | true
84 |
85 |
86 |
87 |
88 | ProjectExplorer.Project.Target.0
89 |
90 | Desktop
91 | Desktop Qt 5.14.2 MinGW 32-bit
92 | Desktop Qt 5.14.2 MinGW 32-bit
93 | qt.qt5.5142.win32_mingw73_kit
94 | 0
95 | 0
96 | 0
97 |
98 | 0
99 | E:\QtOpenGL-Essential-Training\build-Day02-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
100 | E:/QtOpenGL-Essential-Training/build-Day02-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
101 |
102 |
103 | true
104 | QtProjectManager.QMakeBuildStep
105 |
106 | false
107 |
108 |
109 |
110 | true
111 | Qt4ProjectManager.MakeStep
112 |
113 | 2
114 | Build
115 | Build
116 | ProjectExplorer.BuildSteps.Build
117 |
118 |
119 |
120 | true
121 | Qt4ProjectManager.MakeStep
122 | clean
123 |
124 | 1
125 | Clean
126 | Clean
127 | ProjectExplorer.BuildSteps.Clean
128 |
129 | 2
130 | false
131 |
132 |
133 | Debug
134 | Qt4ProjectManager.Qt4BuildConfiguration
135 | 2
136 | 0
137 |
138 |
139 | E:\QtOpenGL-Essential-Training\build-Day02-Desktop_Qt_5_14_2_MinGW_32_bit-Release
140 | E:/QtOpenGL-Essential-Training/build-Day02-Desktop_Qt_5_14_2_MinGW_32_bit-Release
141 |
142 |
143 | true
144 | QtProjectManager.QMakeBuildStep
145 |
146 | false
147 |
148 |
149 |
150 | true
151 | Qt4ProjectManager.MakeStep
152 |
153 | 2
154 | Build
155 | Build
156 | ProjectExplorer.BuildSteps.Build
157 |
158 |
159 |
160 | true
161 | Qt4ProjectManager.MakeStep
162 | clean
163 |
164 | 1
165 | Clean
166 | Clean
167 | ProjectExplorer.BuildSteps.Clean
168 |
169 | 2
170 | false
171 |
172 |
173 | Release
174 | Qt4ProjectManager.Qt4BuildConfiguration
175 | 0
176 | 0
177 | 0
178 |
179 |
180 | 0
181 | E:\QtOpenGL-Essential-Training\build-Day02-Desktop_Qt_5_14_2_MinGW_32_bit-Profile
182 | E:/QtOpenGL-Essential-Training/build-Day02-Desktop_Qt_5_14_2_MinGW_32_bit-Profile
183 |
184 |
185 | true
186 | QtProjectManager.QMakeBuildStep
187 |
188 | false
189 |
190 |
191 |
192 | true
193 | Qt4ProjectManager.MakeStep
194 |
195 | 2
196 | Build
197 | Build
198 | ProjectExplorer.BuildSteps.Build
199 |
200 |
201 |
202 | true
203 | Qt4ProjectManager.MakeStep
204 | clean
205 |
206 | 1
207 | Clean
208 | Clean
209 | ProjectExplorer.BuildSteps.Clean
210 |
211 | 2
212 | false
213 |
214 |
215 | Profile
216 | Qt4ProjectManager.Qt4BuildConfiguration
217 | 0
218 | 0
219 | 0
220 | 0
221 |
222 | 3
223 |
224 |
225 | 0
226 | Deploy
227 | Deploy
228 | ProjectExplorer.BuildSteps.Deploy
229 |
230 | 1
231 |
232 | false
233 | ProjectExplorer.DefaultDeployConfiguration
234 |
235 | 1
236 |
237 | dwarf
238 |
239 | cpu-cycles
240 |
241 |
242 | 250
243 |
244 | -e
245 | cpu-cycles
246 | --call-graph
247 | dwarf,4096
248 | -F
249 | 250
250 |
251 | -F
252 | true
253 | 4096
254 | false
255 | false
256 | 1000
257 |
258 | true
259 |
260 | false
261 | false
262 | false
263 | false
264 | true
265 | 0.01
266 | 10
267 | true
268 | kcachegrind
269 | 1
270 | 25
271 |
272 | 1
273 | true
274 | false
275 | true
276 | valgrind
277 |
278 | 0
279 | 1
280 | 2
281 | 3
282 | 4
283 | 5
284 | 6
285 | 7
286 | 8
287 | 9
288 | 10
289 | 11
290 | 12
291 | 13
292 | 14
293 |
294 |
295 | 2
296 |
297 | Qt4ProjectManager.Qt4RunConfiguration:E:/QtOpenGL-Essential-Training/Day02/Day02.pro
298 | E:/QtOpenGL-Essential-Training/Day02/Day02.pro
299 | false
300 | true
301 | true
302 | false
303 | true
304 | E:/QtOpenGL-Essential-Training/build-Day02-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
305 |
306 | 1
307 |
308 |
309 |
310 | ProjectExplorer.Project.TargetCount
311 | 1
312 |
313 |
314 | ProjectExplorer.Project.Updater.FileVersion
315 | 22
316 |
317 |
318 | Version
319 | 22
320 |
321 |
322 |
--------------------------------------------------------------------------------
/Day02/Day02.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EnvironmentId
7 | {88dc5806-c7dd-4b36-aa09-5757eb02e06d}
8 |
9 |
10 | ProjectExplorer.Project.ActiveTarget
11 | 0
12 |
13 |
14 | ProjectExplorer.Project.EditorSettings
15 |
16 | true
17 | false
18 | true
19 |
20 | Cpp
21 |
22 | CppGlobal
23 |
24 |
25 |
26 | QmlJS
27 |
28 | QmlJSGlobal
29 |
30 |
31 | 2
32 | UTF-8
33 | false
34 | 4
35 | false
36 | 80
37 | true
38 | true
39 | 1
40 | true
41 | false
42 | 0
43 | true
44 | true
45 | 0
46 | 8
47 | true
48 | 1
49 | true
50 | true
51 | true
52 | false
53 |
54 |
55 |
56 | ProjectExplorer.Project.PluginSettings
57 |
58 |
59 | -fno-delayed-template-parsing
60 |
61 | true
62 |
63 |
64 |
65 | ProjectExplorer.Project.Target.0
66 |
67 | Desktop Qt 5.14.2 MinGW 32-bit
68 | Desktop Qt 5.14.2 MinGW 32-bit
69 | qt.qt5.5142.win32_mingw73_kit
70 | 0
71 | 0
72 | 0
73 |
74 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
75 |
76 |
77 | true
78 | QtProjectManager.QMakeBuildStep
79 | true
80 |
81 | false
82 | false
83 | false
84 |
85 |
86 | true
87 | Qt4ProjectManager.MakeStep
88 |
89 | false
90 |
91 |
92 | false
93 |
94 | 2
95 | Build
96 | Build
97 | ProjectExplorer.BuildSteps.Build
98 |
99 |
100 |
101 | true
102 | Qt4ProjectManager.MakeStep
103 |
104 | true
105 | clean
106 |
107 | false
108 |
109 | 1
110 | Clean
111 | Clean
112 | ProjectExplorer.BuildSteps.Clean
113 |
114 | 2
115 | false
116 |
117 | Debug
118 | Qt4ProjectManager.Qt4BuildConfiguration
119 | 2
120 |
121 |
122 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Release
123 |
124 |
125 | true
126 | QtProjectManager.QMakeBuildStep
127 | false
128 |
129 | false
130 | false
131 | true
132 |
133 |
134 | true
135 | Qt4ProjectManager.MakeStep
136 |
137 | false
138 |
139 |
140 | false
141 |
142 | 2
143 | Build
144 | Build
145 | ProjectExplorer.BuildSteps.Build
146 |
147 |
148 |
149 | true
150 | Qt4ProjectManager.MakeStep
151 |
152 | true
153 | clean
154 |
155 | false
156 |
157 | 1
158 | Clean
159 | Clean
160 | ProjectExplorer.BuildSteps.Clean
161 |
162 | 2
163 | false
164 |
165 | Release
166 | Qt4ProjectManager.Qt4BuildConfiguration
167 | 0
168 |
169 |
170 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Profile
171 |
172 |
173 | true
174 | QtProjectManager.QMakeBuildStep
175 | true
176 |
177 | false
178 | true
179 | true
180 |
181 |
182 | true
183 | Qt4ProjectManager.MakeStep
184 |
185 | false
186 |
187 |
188 | false
189 |
190 | 2
191 | Build
192 | Build
193 | ProjectExplorer.BuildSteps.Build
194 |
195 |
196 |
197 | true
198 | Qt4ProjectManager.MakeStep
199 |
200 | true
201 | clean
202 |
203 | false
204 |
205 | 1
206 | Clean
207 | Clean
208 | ProjectExplorer.BuildSteps.Clean
209 |
210 | 2
211 | false
212 |
213 | Profile
214 | Qt4ProjectManager.Qt4BuildConfiguration
215 | 0
216 |
217 | 3
218 |
219 |
220 | 0
221 | Deploy
222 | Deploy
223 | ProjectExplorer.BuildSteps.Deploy
224 |
225 | 1
226 | ProjectExplorer.DefaultDeployConfiguration
227 |
228 | 1
229 |
230 |
231 | dwarf
232 |
233 | cpu-cycles
234 |
235 |
236 | 250
237 |
238 | -e
239 | cpu-cycles
240 | --call-graph
241 | dwarf,4096
242 | -F
243 | 250
244 |
245 | -F
246 | true
247 | 4096
248 | false
249 | false
250 | 1000
251 |
252 | true
253 |
254 | false
255 | false
256 | false
257 | false
258 | true
259 | 0.01
260 | 10
261 | true
262 | kcachegrind
263 | 1
264 | 25
265 |
266 | 1
267 | true
268 | false
269 | true
270 | valgrind
271 |
272 | 0
273 | 1
274 | 2
275 | 3
276 | 4
277 | 5
278 | 6
279 | 7
280 | 8
281 | 9
282 | 10
283 | 11
284 | 12
285 | 13
286 | 14
287 |
288 | 2
289 |
290 | Qt4ProjectManager.Qt4RunConfiguration:E:/QtOpenGL-Essential-Training/Day01/Day01.pro
291 | E:/QtOpenGL-Essential-Training/Day01/Day01.pro
292 |
293 | false
294 |
295 | false
296 | true
297 | true
298 | false
299 | false
300 | true
301 |
302 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
303 |
304 | 1
305 |
306 |
307 |
308 | ProjectExplorer.Project.TargetCount
309 | 1
310 |
311 |
312 | ProjectExplorer.Project.Updater.FileVersion
313 | 22
314 |
315 |
316 | Version
317 | 22
318 |
319 |
320 |
--------------------------------------------------------------------------------
/Day03/Day03.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EnvironmentId
7 | {88dc5806-c7dd-4b36-aa09-5757eb02e06d}
8 |
9 |
10 | ProjectExplorer.Project.ActiveTarget
11 | 0
12 |
13 |
14 | ProjectExplorer.Project.EditorSettings
15 |
16 | true
17 | false
18 | true
19 |
20 | Cpp
21 |
22 | CppGlobal
23 |
24 |
25 |
26 | QmlJS
27 |
28 | QmlJSGlobal
29 |
30 |
31 | 2
32 | UTF-8
33 | false
34 | 4
35 | false
36 | 80
37 | true
38 | true
39 | 1
40 | true
41 | false
42 | 0
43 | true
44 | true
45 | 0
46 | 8
47 | true
48 | 1
49 | true
50 | true
51 | true
52 | false
53 |
54 |
55 |
56 | ProjectExplorer.Project.PluginSettings
57 |
58 |
59 | -fno-delayed-template-parsing
60 |
61 | true
62 |
63 |
64 |
65 | ProjectExplorer.Project.Target.0
66 |
67 | Desktop Qt 5.14.2 MinGW 32-bit
68 | Desktop Qt 5.14.2 MinGW 32-bit
69 | qt.qt5.5142.win32_mingw73_kit
70 | 0
71 | 0
72 | 0
73 |
74 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
75 |
76 |
77 | true
78 | QtProjectManager.QMakeBuildStep
79 | true
80 |
81 | false
82 | false
83 | false
84 |
85 |
86 | true
87 | Qt4ProjectManager.MakeStep
88 |
89 | false
90 |
91 |
92 | false
93 |
94 | 2
95 | Build
96 | Build
97 | ProjectExplorer.BuildSteps.Build
98 |
99 |
100 |
101 | true
102 | Qt4ProjectManager.MakeStep
103 |
104 | true
105 | clean
106 |
107 | false
108 |
109 | 1
110 | Clean
111 | Clean
112 | ProjectExplorer.BuildSteps.Clean
113 |
114 | 2
115 | false
116 |
117 | Debug
118 | Qt4ProjectManager.Qt4BuildConfiguration
119 | 2
120 |
121 |
122 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Release
123 |
124 |
125 | true
126 | QtProjectManager.QMakeBuildStep
127 | false
128 |
129 | false
130 | false
131 | true
132 |
133 |
134 | true
135 | Qt4ProjectManager.MakeStep
136 |
137 | false
138 |
139 |
140 | false
141 |
142 | 2
143 | Build
144 | Build
145 | ProjectExplorer.BuildSteps.Build
146 |
147 |
148 |
149 | true
150 | Qt4ProjectManager.MakeStep
151 |
152 | true
153 | clean
154 |
155 | false
156 |
157 | 1
158 | Clean
159 | Clean
160 | ProjectExplorer.BuildSteps.Clean
161 |
162 | 2
163 | false
164 |
165 | Release
166 | Qt4ProjectManager.Qt4BuildConfiguration
167 | 0
168 |
169 |
170 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Profile
171 |
172 |
173 | true
174 | QtProjectManager.QMakeBuildStep
175 | true
176 |
177 | false
178 | true
179 | true
180 |
181 |
182 | true
183 | Qt4ProjectManager.MakeStep
184 |
185 | false
186 |
187 |
188 | false
189 |
190 | 2
191 | Build
192 | Build
193 | ProjectExplorer.BuildSteps.Build
194 |
195 |
196 |
197 | true
198 | Qt4ProjectManager.MakeStep
199 |
200 | true
201 | clean
202 |
203 | false
204 |
205 | 1
206 | Clean
207 | Clean
208 | ProjectExplorer.BuildSteps.Clean
209 |
210 | 2
211 | false
212 |
213 | Profile
214 | Qt4ProjectManager.Qt4BuildConfiguration
215 | 0
216 |
217 | 3
218 |
219 |
220 | 0
221 | Deploy
222 | Deploy
223 | ProjectExplorer.BuildSteps.Deploy
224 |
225 | 1
226 | ProjectExplorer.DefaultDeployConfiguration
227 |
228 | 1
229 |
230 |
231 | dwarf
232 |
233 | cpu-cycles
234 |
235 |
236 | 250
237 |
238 | -e
239 | cpu-cycles
240 | --call-graph
241 | dwarf,4096
242 | -F
243 | 250
244 |
245 | -F
246 | true
247 | 4096
248 | false
249 | false
250 | 1000
251 |
252 | true
253 |
254 | false
255 | false
256 | false
257 | false
258 | true
259 | 0.01
260 | 10
261 | true
262 | kcachegrind
263 | 1
264 | 25
265 |
266 | 1
267 | true
268 | false
269 | true
270 | valgrind
271 |
272 | 0
273 | 1
274 | 2
275 | 3
276 | 4
277 | 5
278 | 6
279 | 7
280 | 8
281 | 9
282 | 10
283 | 11
284 | 12
285 | 13
286 | 14
287 |
288 | 2
289 |
290 | Qt4ProjectManager.Qt4RunConfiguration:E:/QtOpenGL-Essential-Training/Day01/Day01.pro
291 | E:/QtOpenGL-Essential-Training/Day01/Day01.pro
292 |
293 | false
294 |
295 | false
296 | true
297 | true
298 | false
299 | false
300 | true
301 |
302 | E:/QtOpenGL-Essential-Training/build-Day01-Desktop_Qt_5_14_2_MinGW_32_bit-Debug
303 |
304 | 1
305 |
306 |
307 |
308 | ProjectExplorer.Project.TargetCount
309 | 1
310 |
311 |
312 | ProjectExplorer.Project.Updater.FileVersion
313 | 22
314 |
315 |
316 | Version
317 | 22
318 |
319 |
320 |
--------------------------------------------------------------------------------