Qt5下OpenGL程序的新写法可参考:
https://blog.csdn.net/caoshangpa/article/details/51103402
我们添加了一个三角形和一个四边形。也许你认为这很简单,但你已经迈出了一大步,要知道任何在OpenGL中绘制的模型都会被分解为这两种简单的图形。
lesson1.h
#ifndef LESSON1_H
#define LESSON1_H
#include <QWindow>
#include <QOpenGLFunctions_1_0>
class QPainter;
class QOpenGLContext;
class QOpenGLPaintDevice;
class Lesson1 : public QWindow, QOpenGLFunctions_1_0
{
Q_OBJECT
public:
explicit Lesson1(QWindow *parent = 0);
~Lesson1();
virtual void render(QPainter *);
virtual void render();
virtual void initialize();
public slots:
void renderNow();
protected:
void exposeEvent(QExposeEvent *);
void resizeEvent(QResizeEvent *);
private:
void myPerspective( GLdouble fov, GLdouble aspectRatio, GLdouble zNear, GLdouble zFar );
private:
QOpenGLContext *m_context;
};