2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
126 lines
3.2 KiB
C++
126 lines
3.2 KiB
C++
#ifndef _OpenGLView_H_
|
|
#define _OpenGLView_H_
|
|
|
|
#include <QtOpenGL/QGL>
|
|
#include <QGLFunctions>
|
|
#include <QOpenGLBuffer>
|
|
|
|
#include <QTimer>
|
|
|
|
#include "GCycleQueue.h"
|
|
#include "CommSerialDef.h"
|
|
#include "CommDef.h"
|
|
|
|
#define MAX_FILE_NAME 256
|
|
#define MAX_TEXTURES 128
|
|
|
|
enum eViewOrder
|
|
{
|
|
eViewOrder_Origin = 1, // 原始图像
|
|
eViewOrder_LeftRightRevert = 2, // 左右反转
|
|
eViewOrder_UpDownRevert = 3, // 上下反转
|
|
eViewOrder_AllRevert = 4, // 上下左右反转
|
|
};
|
|
|
|
class CTexture
|
|
{
|
|
public:
|
|
CTexture();
|
|
virtual ~CTexture();
|
|
|
|
void Init(int nTextureNum);
|
|
void Unint();
|
|
bool GenTextureData(int nTextureIndex, int nTextureWidth, int nTextureHeight, int nDataWidth);
|
|
bool UpdataTextureGray(int nTextureIndex, char* pTextureData, int nTextureWidth, int nTextureHeight);
|
|
bool UpdataTexture(int nTextureIndex, char* pTextureData, int nTextureWidth, int nTextureHeight);
|
|
GLuint CurrentTexture();
|
|
|
|
protected:
|
|
GLuint m_nTextures[MAX_TEXTURES];
|
|
|
|
int m_nTextureNum; //纹理贴图个数
|
|
int m_nCurrentTextureIndex;
|
|
bool m_bInit;
|
|
bool m_bGenTextureData;
|
|
};
|
|
|
|
// 目标信息回调
|
|
typedef void (*MouseEventCallback)(int id, QEvent* event, QWidget *widget);
|
|
|
|
class OpenGLView : public QGLWidget, protected QGLFunctions
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit OpenGLView(QWidget *parent = Q_NULLPTR, int iID = 0, Qt::WindowFlags f = Qt::WindowFlags() );
|
|
virtual ~OpenGLView();
|
|
bool Init(int nImageWidth, int nImageHeight);
|
|
void UpdateImageData(byte* pImageData, bool bTryFresh = false);
|
|
void SetCallbackFunc(MouseEventCallback callback);
|
|
void SetViewOrder(eViewOrder viewOrder);
|
|
|
|
inline int ImageWidthValue(){return m_nImageWidth;}
|
|
inline int ImageHeightValue(){return m_nImageWidth;}
|
|
|
|
inline int PosX(){return m_nXPos;}
|
|
inline int PosY(){return m_nYPos;}
|
|
inline double ViewRatio(){return m_dRatio;}
|
|
|
|
|
|
protected:
|
|
virtual void initializeGL();
|
|
virtual void resizeGL(int width, int height);
|
|
virtual void paintGL();
|
|
virtual bool event(QEvent* event);
|
|
|
|
private:
|
|
bool InitGLRes();
|
|
void UninitGLRes();
|
|
void draw();
|
|
|
|
void Uninit();
|
|
|
|
private slots:
|
|
void OnTimer_Update();
|
|
void OnTimer_InitGLRes();
|
|
|
|
private:
|
|
byte* m_pImageDataBuffer;
|
|
float m_fScreenWid;
|
|
|
|
//PBO
|
|
QOpenGLBuffer* m_pPBOBuffer[2];
|
|
int m_nPBO_Now;
|
|
int m_nPBO_Next;
|
|
|
|
int m_nXPos;
|
|
int m_nYPos;
|
|
double m_dRatio;
|
|
|
|
//
|
|
bool m_bInit;
|
|
int m_nImageWidth;
|
|
int m_nImageHeight;
|
|
int m_nImageDataSize;
|
|
CTexture m_varTexture;
|
|
|
|
//
|
|
bool m_bInitedGLRes;
|
|
|
|
int m_nRefreshCount;
|
|
|
|
GCycleQueue m_varImageData;
|
|
|
|
QTimer m_varTimer;
|
|
QImage m_varImage;
|
|
ImageAssessRect m_varImageAssessRect;
|
|
|
|
//窗口个性设计
|
|
QWidget* m_parentWidget; //父窗口指针
|
|
MouseEventCallback OnMouseCallback;
|
|
|
|
eViewOrder m_eViewOrder;
|
|
};
|
|
|
|
#endif // _OpenGLView_H_
|