#ifndef QOPENGLBUFFERBASE_H
#define QOPENGLBUFFERBASE_H

#include <QObject>

#include "qopengltexturebutton.h"
#include "qglslshader.h"
#include <QOpenGLFramebufferObject>
#include <QOffscreenSurface>

#include <QTime>

namespace SOPENGL
{
    class QOpenGLBufferBase : public QObject
    {
        Q_OBJECT
    public:
        explicit QOpenGLBufferBase(QOpenGLContext* pContext, QSurfaceFormat surfaceformat, QObject *parent = 0);
        virtual ~QOpenGLBufferBase();

        virtual void initializeGL();

        virtual float MakeNormalize(int nPos, int nRange);
        virtual void MakeRectNormal(const QRect& rect, QSize rectSize);
        virtual void MakeRectNormalFlip(const QRect& rect, QSize rectSize);
        virtual void MakeRectNormalWithOffset(const QRect& rect, QSize rectSize, QSize rectOffset);

    signals:

    public slots:

    protected:
        QOpenGLFramebufferObject* m_pFBO;
        QOffscreenSurface* m_pOffScreen;
        QOpenGLContext* m_pContext;
        QSurfaceFormat m_SurfaceFormatParent;


        GLfloat m_fNormalRect[18];
        GLfloat m_fNormalRectTexture[12];

        QGLSLShader* m_pShaderThumbnail;
        QOpenGLBuffer m_VBOThumbnail;
        QRect m_rectDisplay;
    };
}


#endif // QOPENGLBUFFERBASE_H
