mirror of
https://github.com/open-goal/jak-project
synced 2026-06-20 16:21:35 -04:00
9430b4772a
* Implement runtime display (test) * Update runtime.cpp * [game display] add "-nodisplay" argument * style fixes * Update gfx.cpp * [deci2server] fix deadlock when killing a Deci2Server * add libxrandr to linux github test * correct package name to libxrandr-dev * set g_main_thread_id in exec_runtime * add libxinerama to linux test packages * correct the name * add libxcursor1 package * Update linux-workflow.yaml * add libxi-dev * fix constructor for g_main_thread_id * fix submodules + use -nodisplay during tests * move the gfx loop to its own function and use a lambda for exit conditions * fix include * fix include * fix includes (for real this time)
55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
/*!
|
|
* @file display.cpp
|
|
* Display for graphics. This is the game window, distinct from the runtime console.
|
|
*/
|
|
|
|
#include "display.h"
|
|
|
|
#include "common/log/log.h"
|
|
|
|
namespace Display {
|
|
|
|
GLFWwindow* display = NULL;
|
|
|
|
void InitDisplay(int width, int height, char* title, GLFWwindow*& d) {
|
|
if (d) {
|
|
lg::warn("InitDisplay has already created a display window");
|
|
return;
|
|
}
|
|
|
|
// request OpenGL 3.0 (placeholder)
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
|
d = glfwCreateWindow(width, height, title, NULL, NULL);
|
|
|
|
if (!d) {
|
|
lg::error("InitDisplay failed - Could not create display window");
|
|
return;
|
|
}
|
|
|
|
glfwMakeContextCurrent(d);
|
|
if (!gladLoadGL()) {
|
|
lg::error("GL init fail");
|
|
KillDisplay(d);
|
|
return;
|
|
}
|
|
|
|
// enable vsync by default
|
|
glfwSwapInterval(1);
|
|
|
|
lg::debug("init display #x{}", (uintptr_t)d);
|
|
}
|
|
|
|
void KillDisplay(GLFWwindow*& d) {
|
|
lg::debug("kill display #x{}", (uintptr_t)d);
|
|
if (!d) {
|
|
lg::warn("KillDisplay called when no display was available");
|
|
return;
|
|
}
|
|
|
|
glfwDestroyWindow(d);
|
|
d = NULL;
|
|
}
|
|
|
|
} // namespace Display
|