-
Notifications
You must be signed in to change notification settings - Fork 4
/
glview.h
51 lines (30 loc) · 957 Bytes
/
glview.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
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Compatibility>
#include <QOpenGLFunctions>
#include <QGLWidget>
#include <functional>
#if __APPLE__
class GLView : public QOpenGLWidget , public QOpenGLFunctions
#else
class GLView : public QOpenGLWidget , public QOpenGLFunctions_3_3_Compatibility
#endif
{
public:
GLView(int textureWidth, int textureHeight, std::function<void(GLView*)> initCallback);
GLuint createTexture(unsigned int width, unsigned int height);
void setPaintCallback(std::function<void(GLView*)> callback);
void setBaseTexture(GLuint newTextureId);
GLuint getBaseTexture() const;
protected:
void paintGL();
void initializeGL();
private:
void _checkErrors(const std::string & snippet);
private:
GLuint _glTexture;
int _textureWidth;
int _textureHeight;
std::function<void(GLView*)> _initCallback;
std::function<void(GLView*)> _paintCallback;
};