1 Star 5 Fork 3

chen227 / OpenglAndQml

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
openglwindow.h 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
chen227 提交于 2018-05-23 16:57 . Opengl 和 Qml 混合编程
#ifndef OPENGLWINDOW_H
#define OPENGLWINDOW_H
#include <QtGui/QWindow>
#include <QtGui/QOpenGLFunctions>
#include <QtGui/QOpenGLExtraFunctions>
#include <QQuickView>
QT_BEGIN_NAMESPACE
class QPainter;
class QOpenGLContext;
class QOpenGLPaintDevice;
QT_END_NAMESPACE
class Openglwindow : public QObject, protected QOpenGLExtraFunctions
{
Q_OBJECT
public:
explicit Openglwindow();
~Openglwindow();
//基于QPainter渲染
virtual void render(QPainter *parent);
//基于opengl渲染
virtual void render();
//初始化
virtual void initialize();
//设置动画
void setAnimating(bool animating);
void setViewportSize(const QSize &size) { m_viewportSize = size; }
QSize getViewportSize(){ return m_viewportSize; }
public slots:
//立刻渲染
void renderNow();
void renderLater();
private:
//动画状态位
bool m_animating;
QSize m_viewportSize;
//OpenGL 上下文
QOpenGLContext *m_context;
//OpenGL画笔设备,能使用QPainter在上下文里画东西
QOpenGLPaintDevice *m_device;
bool needsInitialize;
};
#endif // OPENGLWINDOW_H
1
https://gitee.com/chen227/OpenglAndQml.git
git@gitee.com:chen227/OpenglAndQml.git
chen227
OpenglAndQml
OpenglAndQml
master

搜索帮助