-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglgamewidget.h
39 lines (36 loc) · 1.14 KB
/
glgamewidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef GLGAMEWIDGET_H
#define GLGAMEWIDGET_H
#include <QGLWidget>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLBuffer>
#include <QHash>
#include <QMediaPlayer>
class GLGameWidget : public QGLWidget{
Q_OBJECT
private:
GLGameWidget(QWidget *parent = 0) ;//QWidget *parent = 0);
static GLGameWidget* UniqueGLWidget ;
public:
static GLGameWidget* MakeUniqueGLWidget (QWidget *parent = 0);
static GLGameWidget* getUniqueGLWidget(){return UniqueGLWidget;}
QSize sizeHint() const{return QSize(w,h);}
void setSize(int w,int h){if(w < 0 || h < 0) return;this->w = w;this->h = h; }
void refresh ();
void drawRect(int x ,int y,int w,int h,QColor color);
int loadImage(QString path);
void drawImage(int x, int y, int handle);
bool getKeyDown(int keyCode);
QMediaPlayer mp;
protected:
void keyPressEvent( QKeyEvent *event );
void keyReleaseEvent(QKeyEvent *event);
QHash<int,bool> keyPushHash;
void initializeGL();
void resizeGL(int width,int height);
void paintGL(){}
private:
QHash<unsigned int,QSize> imageSizeHash;
int w = 600, h = 400;
};
#endif // GLGAMEWIDGET_H