30#include "engine_audio.hpp"
31#include "engine_input.hpp"
32#include "engine_logger.hpp"
36using namespace Brenta;
42void Screen::Init(
int SCR_WIDTH,
int SCR_HEIGHT,
bool isMouseCaptured,
43 const char *title,
bool msaa,
bool vsync)
48 if (glfwInit() == GLFW_FALSE)
50 ERROR(
"Failed to initialize GLFW on init");
53 SetContextVersion(3, 3);
58 glfwWindowHint(GLFW_SAMPLES, 4);
65 INFO(
"Disabled VSync");
72 CreateWindow(SCR_WIDTH, SCR_HEIGHT, title);
102 return reinterpret_cast<void (*)()
>(glfwGetProcAddress);
124 INFO(
"Set framebuffer size callback");
131 glfwSetInputMode(
Screen::window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
133 INFO(
"Mouse captured");
137 glfwSetInputMode(
Screen::window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
138 INFO(
"Mouse not captured");
150 INFO(
"Screen terminated");
163void Screen::SetContextVersion(
int major,
int minor)
165 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major);
166 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor);
168 INFO(
"Set context to OpenGL version: ", major,
".", minor);
181void Screen::UseCoreProfile()
183 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
185 INFO(
"Set OpenGL profile to core");
188void Screen::SetHintsApple()
190 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
193void Screen::CreateWindow(
int SCR_WIDTH,
int SCR_HEIGHT,
const char *title)
195 Screen::window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, title, NULL, NULL);
198 ERROR(
"Failed to create GLFW window");
203void Screen::MakeContextCurrent()
208void Screen::Framebuffer_size_callback(GLFWwindow *window,
int width,
211 glViewport(0, 0, width, height);
215 INFO(
"Set viewport: ", width,
"x", height);
static void SetClose()
Set the window close flag.
static int GetHeight()
Get the height of the window.
static GLFWglproc GetProcAddress()
Get the OpenGL function pointer.
static void SetMouseCapture(bool isCaptured)
Set the mouse capture.
static int HEIGHT
Height of the window.
static void SetMousePosCallback(GLFWcursorposfun callback)
Set the mouse position callback.
static void SetMouseCallback(GLFWcursorposfun callback)
Set the mouse callback.
static int GetWidth()
Get the width of the window.
static bool isWindowClosed()
Check if the window is closed.
static void PollEvents()
Poll all pending events.
static GLFWwindow * GetWindow()
Get the window.
static GLFWwindow * window
Pointer to the window.
static float GetTime()
Get the time.
static void SetSizeCallback(GLFWframebuffersizefun callback)
Set the key callback.
static void Init(int SCR_WIDTH, int SCR_HEIGHT, bool isMouseCaptured=false, const char *title="OpenGL", bool msaa=false, bool vsync=false)
Initialize the window.
static void Terminate()
Terminate the window.
static bool isKeyPressed(int key)
Check if a key is pressed.
static void SetKeyCallback(GLFWkeyfun callback)
Set the key callback.
static void SwapBuffers()
Swap the front and back buffers.
static int WIDTH
Width of the window.