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 is_mouse_captured,
43 const char *title,
bool msaa,
bool vsync)
48 if (glfwInit() == GLFW_FALSE)
50 ERROR(
"Failed to initialize GLFW on init");
53 set_context_version(3, 3);
58 glfwWindowHint(GLFW_SAMPLES, 4);
65 INFO(
"Disabled VSync");
72 create_window(SCR_WIDTH, SCR_HEIGHT, title);
73 make_context_current();
102 return reinterpret_cast<void (*)()
>(glfwGetProcAddress);
124 INFO(
"Set framebuffer size callback");
131 glfwSetInputMode(
screen::window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
132 INFO(
"Mouse captured");
136 glfwSetInputMode(
screen::window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
137 INFO(
"Mouse not captured");
148 INFO(
"Terminating screen");
151 INFO(
"screen terminated");
164void screen::set_context_version(
int major,
int minor)
166 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major);
167 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor);
169 INFO(
"Set context to OpenGL version: {}.{}", major, minor);
182void screen::use_core_profile()
184 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
186 INFO(
"Set OpenGL profile to core");
189void screen::set_hints_apple()
191 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
194void screen::create_window(
int SCR_WIDTH,
int SCR_HEIGHT,
const char *title)
196 screen::window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, title, NULL, NULL);
199 ERROR(
"Failed to create GLFW window");
204void screen::make_context_current()
209void screen::framebuffer_size_callback(GLFWwindow *window,
int width,
213 glViewport(0, 0, width, height);
static int WIDTH
Width of the window.
static void poll_events()
Poll all pending events.
static void set_key_callback(GLFWkeyfun callback)
Set the key callback.
static GLFWwindow * get_window()
Get the window.
static void terminate()
Terminate the window.
static void set_close()
Set the window close flag.
static GLFWglproc get_proc_address()
Get the OpenGL function pointer.
static void init(int SCR_WIDTH, int SCR_HEIGHT, bool is_mouse_captured=false, const char *title="OpenGL", bool msaa=false, bool vsync=false)
Initialize the window.
static void set_mouse_capture(bool is_captured)
Set the mouse capture.
static void set_mouse_pos_callback(GLFWcursorposfun callback)
Set the mouse position callback.
static int get_width()
Get the width of the window.
static GLFWwindow * window
Pointer to the window.
static void set_mouse_callback(GLFWcursorposfun callback)
Set the mouse callback.
static int HEIGHT
Height of the window.
static void set_size_callback(GLFWframebuffersizefun callback)
Set the key callback.
static float get_time()
Get the time.
static bool is_window_closed()
Check if the window is closed.
static bool is_key_pressed(int key)
Check if a key is pressed.
static int get_height()
Get the height of the window.
static void swap_buffers()
Swap the front and back buffers.