这一课将把如下图片做成一个飘动的旗帜,其实主要还是用到了纹理映射。
lesson10.h
#ifndef LESSON10_H
#define LESSON10_H
#include <QWindow>
#include <QOpenGLFunctions_1_1>
#include <QKeyEvent>
class QPainter;
class QOpenGLContext;
class QOpenGLPaintDevice;
class Lesson10 : public QWindow, QOpenGLFunctions_1_1
{
Q_OBJECT
public:
explicit Lesson10(QWindow *parent = 0);
~Lesson10();
virtual void render(QPainter *);
virtual void render();
virtual void initialize();
public slots:
void renderNow();
protected:
void exposeEvent(QExposeEvent *);
void resizeEvent(QResizeEvent *);
void keyPressEvent(QKeyEvent *); // 键盘事件
void timerEvent(QTimerEvent *); // 定时器
private:
void loadGLTexture();
private:
QOpenGLContext *m_context;
GLfloat m_x_rotate;
GLfloat m_y_rotate;
GLfloat m_z_