GlistEngine
Loading...
Searching...
No Matches
gGLFWWindow.h
Go to the documentation of this file.
1/*
2 * gGLFWWindow.h
3 *
4 * Created on: May 6, 2020
5 * Author: noyan
6 */
7
8#ifndef ENGINE_CORE_GGLFWWINDOW_H_
9#define ENGINE_CORE_GGLFWWINDOW_H_
10
11#include "gBaseWindow.h"
12// Above GLFW on purpose: glfw3.h includes GL/gl.h unless GLEW is already in,
13// and glew.h refuses to come after gl.h.
14#include <GL/glew.h>
15#include <GLFW/glfw3.h>
16#include "gCamera.h"
17#include "gImage.h"
18
24
25class gGLFWWindow : public gBaseWindow {
26public:
31
33 ~gGLFWWindow() override;
34
42 void initialize(int width, int height, int windowMode, bool isResizable) override;
43
49 bool getShouldClose() override;
50
54 void update() override;
55
59 void close() override;
60 bool supportsVulkan() const override;
61 void getVulkanInstanceExtensions(std::vector<const char*>& extensions) const override;
62 bool createVulkanSurface(void* instance, void* surface) override;
63
64 void setVsync(bool vsync) override;
65
66 void setCursor(int cursorNo) override;
67 void setCursorMode(gCursorMode cursorMode) override;
68 void setCursorPos(int x, int y) override;
69
70 void setCustomCursor(gImage& image, int hotspotX = 0, int hotspotY = 0) override;
71
72 void setClipboardString(std::string text) override;
73 std::string getClipboardString() override;
74
75 void setWindowSize(int width, int height) override;
76 void setWindowResizable(bool isResizable) override;
77 void setWindowSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) override;
78
79 void setIcon(std::string pngFullpath) override;
80 void setIcon(unsigned char* imageData, int w, int h) override;
81
82 void setTitle(const std::string& windowTitle) override;
83
84 bool isJoystickPresent(int joystickId) override;
85 bool isGamepadButtonPressed(int joystickId, int buttonId) override;
86 const float* getJoystickAxes(int joystickId, int* axisCountPtr) override;
87
88 float getScaleX() const {
89 return scalex;
90 }
91 float getScaleY() const {
92 return scaley;
93 }
94
95 void setScale(float x, float y);
96
97 // The Vulkan backend needs the raw handle to create its surface.
98 GLFWwindow* getGLFWWindow() const { return window; }
99 // Called by the GLFW cursor callback with the raw (unscaled) position.
100 void handleCursorPos(double xpos, double ypos);
101
102 private:
103 GLFWwindow* window;
104 GLFWcursor** cursor;
105 float scalex, scaley;
106 // Previous virtual cursor position, relative mode reports the delta from it.
107 double lastcursorx, lastcursory;
108
109};
110
111#endif /* ENGINE_CORE_GGLFWWINDOW_H_ */
bool getShouldClose() override
void setIcon(unsigned char *imageData, int w, int h) override
bool isGamepadButtonPressed(int joystickId, int buttonId) override
GLFWwindow * getGLFWWindow() const
Definition gGLFWWindow.h:98
void setIcon(std::string pngFullpath) override
void update() override
void initialize(int width, int height, int windowMode, bool isResizable) override
void setWindowSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) override
void getVulkanInstanceExtensions(std::vector< const char * > &extensions) const override
void setCursorPos(int x, int y) override
static constexpr gCursorMode CURSORMODE_RELATIVE
Definition gGLFWWindow.h:30
static constexpr gCursorMode CURSORMODE_HIDDEN
Definition gGLFWWindow.h:28
void setTitle(const std::string &windowTitle) override
void handleCursorPos(double xpos, double ypos)
void setWindowSize(int width, int height) override
~gGLFWWindow() override
void setWindowResizable(bool isResizable) override
static constexpr gCursorMode CURSORMODE_NORMAL
Definition gGLFWWindow.h:27
void setCustomCursor(gImage &image, int hotspotX=0, int hotspotY=0) override
static constexpr gCursorMode CURSORMODE_DISABLED
Definition gGLFWWindow.h:29
void setCursor(int cursorNo) override
bool supportsVulkan() const override
void setCursorMode(gCursorMode cursorMode) override
bool createVulkanSurface(void *instance, void *surface) override
void setVsync(bool vsync) override
void close() override
float getScaleX() const
Definition gGLFWWindow.h:88
const float * getJoystickAxes(int joystickId, int *axisCountPtr) override
bool isJoystickPresent(int joystickId) override
void setClipboardString(std::string text) override
void setScale(float x, float y)
float getScaleY() const
Definition gGLFWWindow.h:91
std::string getClipboardString() override
Definition gImage.h:34
gCursorMode
Definition gWindowEvents.h:14
@ CURSORMODE_NORMAL
Definition gWindowEvents.h:15
@ CURSORMODE_HIDDEN
Definition gWindowEvents.h:16
@ CURSORMODE_DISABLED
Definition gWindowEvents.h:17
@ CURSORMODE_RELATIVE
Definition gWindowEvents.h:18