-
Notifications
You must be signed in to change notification settings - Fork 0
/
GLContext.h
61 lines (45 loc) · 1.28 KB
/
GLContext.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
51
52
53
54
55
56
57
58
59
60
61
#ifndef GL_CONTEXT_H
#define GL_CONTEXT_H
#include <Windows.h>
#include <stdlib.h>
#include <stdint.h>
#if (_MSC_VER >= 1400)
#define THREAD_LOCAL __declspec(thread)
#endif
#include <memory>
#include <string>
#include <set>
#include <stdexcept>
#include <glbinding/gl33core/gl.h>
#include "HiddenWindow.h"
class GLContext
{
public:
std::set<gl::GLextension> extensions;
GLContext(std::shared_ptr<GLContext> parent = nullptr);
~GLContext();
void SetContext();
void DeleteContext();
private:
std::shared_ptr<GLContext> parent;
std::shared_ptr<HiddenWindow> window;
HDC hDC;
HGLRC hRC;
void Initialize();
};
class GLContextException : public std::runtime_error
{
public:
DWORD lastError;
explicit GLContextException(const std::string& message) : std::runtime_error(message) { }
explicit GLContextException(const char *message) : std::runtime_error(message) { }
explicit GLContextException(const std::string& message, DWORD lastError) : std::runtime_error(message)
{
this->lastError = lastError;
}
explicit GLContextException(const char *message, DWORD lastError) : std::runtime_error(message)
{
this->lastError = lastError;
}
};
#endif //GL_CONTEXT_H