• Stars
    star
    116
  • Rank 302,731 (Top 6 %)
  • Language
    C++
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

some Qt OpenGL Demo

Qt5 OpenGL

Qt5写的一些OpenGL小例子集合, 参考LearnOpenGL教程

CI徽章

License Windows MacOS Ubuntu Android IOS
license-badge win-badge macos-badge ubuntu-badge android-badge ios-badge

工程列表

HelloTexture

以QOpenGLWidget为框架,简单的纹理贴图,使用定时器控制纹理旋转。 HelloTexture

HelloCube

立方体贴图的例子,自己用画板画了一个图,然后贴成一个Cube。可以用鼠标控制立方体旋转。

HelloCube

HelloMix

绘制了10个立方体,每个立方体的每个表面使用2张纹理混合贴图。混合比例按数字键1/2进行调节。

HelloMix

QuickOpenGL

qml中添加自定义OpenGL渲染控件。

QuickOpenGL

用的是QQuickWindow的beforeRendering信号。

知道了QQuickFramebufferObject之后,基本上这种方式就被抛弃了。(默认渲染区域是整个window,要自己控制viewport。来自Qml的旋转、平移、缩放也要自己做支持。不方便。)

这里保留项目仅作为观赏,建议参考下面FrameBufferObject。

FrameBufferObject

效果与上一个例子QuickOpenGL 类似,多了全屏放大功能,纹理沿着三个坐标轴旋转的功能。

FrameBufferObject

使用QQuickFramebufferObject 作为OpenGL自绘制控件(相当于QQuickItem了)。

QQuickFramebufferObject是 Qt封装好的,需要理解其使用架构。

这里大概说一下用法:

1. 继承QQuickFramebufferObject实现一个自定义item,并注册到QML中使用。Item在Qml中的旋转、平移、缩放都能支持。
2. 继承QQuickFramebufferObject::Renderer,实现一个自定义Renderer
3. 自定义Renderer内部再封装一个OpenGL相关的渲染类。Renderer是在Scene Graph线程工作,始终拥有OpenGL上下文环境,所以渲染类写在Renderer内部,非常方便。
(Item工作在主线程,Renderer 工作在Scene Graph绘图线程。注意线程交互)

light

Shader光照的例子。  一个立方体的前面, 放一个移动的光源。

light

lightCasters

手电筒光源

lightCasters

mulitLight

镜面反射、漫反射,手电筒的集合 mulitLight

material

材质的使用,边缘部分发光,中间部分不发光

material

DepthTest

利用深度测试,后面的箱子边缘部分用红色绘制出来

DepthTest

SkyBox

天空盒, 可以键盘和鼠标操作

SkyBox

HelloFBO

帧缓冲的使用

反相处理效果如下:

HelloFBO

赞助

如果您觉得这个项目还不错,请打赏一下作者。

联系作者

- -
作者 武威的涛哥
博客 https://jaredtao.github.io/
博客-gitee镜像 https://jaredtao.gitee.io
知乎专栏 https://zhuanlan.zhihu.com/TaoQt
QQ群 734623697(高质量群,大佬多、不灌水)
邮箱 [email protected]
微信 xsd2410421
QQ、TIM 759378563

More Repositories

1

TaoQuick

a cool QtQuick/qml component library and demo(一套酷炫的QtQuick/Qml基础库和示例)
QML
1,285
star
2

DesignPattern

C++11全套设计模式-23种指针的用法(a full DesignPattern implement with c++11)
C++
908
star
3

HelloActions-Qt

Qt use github-actions(Qt项目使用github的持续集成)
PowerShell
145
star
4

TableEdit

qml TableView 表格编辑器
QML
106
star
5

TaoLogger

Qt自制简易好看的日志系统(Implement a simple and beautify log system with Qt )
C++
92
star
6

TreeEdit

Qml TreeEdit with Controls2 (Qml树结构编辑器,使用Controls2实现)
QML
65
star
7

QmlFFmpegPlayer

ffmpeg decode, Qml/opengl convert yuv to rgb and render
C
64
star
8

Qt3D-learn

Qt3D-learn
QML
43
star
9

TaoCommon

整理的一些常用后端Qt代码段
C++
29
star
10

QtWeb

Qt with Web
C++
25
star
11

MulitProcessTab

Qt 多进程标签页 MulitProcess Tab
C++
24
star
12

HelloCI

持续集成教程 Travis-Qt Appveyor-Qt github-Action
QMake
15
star
13

QmlAssimp

Qml and Assimp render 3D model
C++
15
star
14

TaoShaderToy

transplant ShaderToy to Qml with ShaderEffect . Support Android
QML
14
star
15

TaoQuickPreview

TaoQuick Preview (TaoQuick项目的预览效果,单独放置)
13
star
16

MulitThreadTCP

Qt多线程TCP
C++
12
star
17

UniqueApp

UniqueApp Qt 全局唯一APP实例
C++
9
star
18

QObject2TypeScript

QObject convert to TypeScript
C++
9
star
19

Transer

自动翻译器
Go
9
star
20

TaoModule

Qml模块简单示例(Qml Module Sample Demo)
QMake
7
star
21

QtSsh

QtSsh
C++
6
star
22

HelloDirectX

HelloDirectX
C++
6
star
23

I18n

Qt 5.10 qml dynamic mulit Language translate
C++
5
star
24

Processbar

QtWidget ProcessBar
C++
5
star
25

ChineseToArab

中文数字转阿拉伯数字
C++
3
star
26

Dashboard

Dashboard
C++
3
star
27

LianLianKan

Qt qml 连连看
C
2
star
28

PlaneFight

飞机大战-王校长吃面包版
C++
2
star
29

jaredtao

jaredtao
2
star
30

jaredtao.github.io

jared blog
HTML
2
star
31

CalcRow

CalcRow golang代码行数统计
Go
1
star
32

TaoQuick.Net

TaoQuick for .Net
QML
1
star
33

Breakout

Qt打砖块 Breakout
QML
1
star