-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwindow.h
More file actions
60 lines (43 loc) · 1.55 KB
/
Copy pathwindow.h
File metadata and controls
60 lines (43 loc) · 1.55 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
#ifndef _WINDOW_H_
#define _WINDOW_H_
#include <stdio.h>
#include <array>
#include "wasmgl_gl.h"
#include <GLFW/glfw3.h>
#include <memory>
class Window
{
public:
Window();
Window(GLint windowWidth, GLint windowHeight);
int Initialise();
/** Refresh from GLFW; call each frame on wasm so canvas / DPR resizes match the GL viewport. */
void syncFramebufferSize();
GLint getBufferWidth() { return bufferWidth; }
GLint getBufferHeight() { return bufferHeight; }
GLFWwindow *getGLFWWindow() const { return mainWindow; }
bool getShouldClose() { return glfwWindowShouldClose(mainWindow); }
inline std::shared_ptr<std::array<bool, 1024>> getKeys() const { return pKeys; }
GLfloat getXChange();
GLfloat getYChange();
GLfloat getScrollY();
bool isLeftButtonPressed() const { return leftButtonPressed; }
bool isRightButtonPressed() const { return rightButtonPressed; }
void swapBuffers() { glfwSwapBuffers(mainWindow); }
~Window();
private:
GLFWwindow *mainWindow;
GLint width, height;
GLint bufferWidth, bufferHeight;
std::shared_ptr<std::array<bool, 1024>> pKeys;
GLfloat lastX, lastY, xChange, yChange;
GLfloat scrollY;
bool leftButtonPressed, rightButtonPressed;
bool mouseFirstMoved;
void createCallbacks();
static void handleKeys(GLFWwindow *window, int key, int code, int action, int mode);
static void handleMouseMovement(GLFWwindow *window, double xPos, double yPos);
static void handleMouseButton(GLFWwindow *window, int button, int action, int mods);
static void handleScroll(GLFWwindow *window, double xOffset, double yOffset);
};
#endif