-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathglfw3windowbackend.cpp
More file actions
135 lines (106 loc) · 2.91 KB
/
glfw3windowbackend.cpp
File metadata and controls
135 lines (106 loc) · 2.91 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include<GLFW/glfw3.h>
#include <fea/ui/glfw3windowbackend.hpp>
namespace fea{
int key_press(KeyBoard::Code pkey_code ,bool psystem,bool pcontrol,bool pshift,bool palt )
{
KeyEvent Event;
Event.code =pKey_code;
Event.shift = pshift;
Event.control = pcontrol;
Event.alt = palt;
Event.system = psystem;
return Event;
}
void GLFW3WindowBackend::open(VideoMode mode, const std::string& title, uint32_t style, const ContextSettings& settings)
{
glfwInit();
window = glfwCreateWindow(mode.mWidth, mode.mHeight, title.c_str(), NULL, NULL);
}
void GLFW3WindowBackend::close()
{
glfwDestroyWindow(window);
}
bool GLFW3WindowBackend::isOpen() const
{
return window != nullptr;
}
const ContextSettings GLFW3WindowBackend::getSettings() const
{
// still looking on how to get and set context setings
}
Vec2I GLFW3WindowBackend::getPosition() const
{
Vec2I s;
s.x = 0;
s.y = 0;
if(isOpen())
glfwGetWindowPos(window, &s.x , &s.y );
return s;
}
void GLFW3WindowBackend::setPosition(int32_t x, int32_t y)
{
if(isOpen())
{
glfwSetWindowPos(window , x , y);
}
}
Vec2I GLFW3WindowBackend::getSize() const
{
Vec2I s;
s.x = 0;
s.y = 0;
if(isOpen())
glfwGetWindowSize(window, &s.x, &s.y);
return s;
}
void GLFW3WindowBackend::setSize(int32_t w, int32_t h)
{
glfwSetWindowSize(window, w, h);
}
void GLFW3WindowBackend::setTitle(const std::string& title)
{
glfwSetWindowTitle(window, title.c_str());
}
//void GLFW3WindowBackend::setIcon(const std::string &path_small , const std::string &path_big )
void GLFW3WindowBackend::setIcon(uint32_t width, uint32_t height, const uint8_t* pixels)
{
//images[0] = load_icon(path_big.c_str());
//images[1] = load_icon(path_small.c_str());
//glfwSetWindowIcon(window, 2 ,images)
}
void GLFW3WindowBackend::setVisible(bool visible)
{
// still working on it
}
void GLFW3WindowBackend::setVSyncEnabled(bool enabled)
{
// still woriking on it
}
void GLFW3WindowBackend::setMouseCursorVisible(bool visible)
{
// still working on it
}
void GLFW3WindowBackend::setFramerateLimit(uint32_t limit)
{
//still woriking on it
}
bool GLFW3WindowBackend::setRenderingActive(bool active) const
{
// still working on it
}
void GLFW3WindowBackend::swapBuffers()
{
glfwSwapBuffers(window);
}
void GLFW3WindowBackend::lockCursor(bool lock)
{
if(isOpen())
{
// still working on it
}
}
GLFW3WindowBackend::~GLFW3WindowBackend()
{
close();
}
}