mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
logged error handle for window module
This commit is contained in:
@@ -8,6 +8,9 @@
|
|||||||
using namespace e2d;
|
using namespace e2d;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
modules::initialize<debug>();
|
||||||
|
the<debug>().add_sink<debug_console_sink>();
|
||||||
|
|
||||||
window w{{640, 480}, "Enduro2D", false};
|
window w{{640, 480}, "Enduro2D", false};
|
||||||
while ( !w.should_close() ) {
|
while ( !w.should_close() ) {
|
||||||
w.swap_buffers();
|
w.swap_buffers();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <enduro2d/core/debug.hpp>
|
||||||
#include <enduro2d/core/window.hpp>
|
#include <enduro2d/core/window.hpp>
|
||||||
|
|
||||||
#define E2D_WINDOW_MODE_NONE 1
|
#define E2D_WINDOW_MODE_NONE 1
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace
|
|||||||
class glfw_state : private noncopyable {
|
class glfw_state : private noncopyable {
|
||||||
public:
|
public:
|
||||||
glfw_state() {
|
glfw_state() {
|
||||||
|
glfwSetErrorCallback(error_handler);
|
||||||
if ( !glfwInit() ) {
|
if ( !glfwInit() ) {
|
||||||
throw bad_window_operation();
|
throw bad_window_operation();
|
||||||
}
|
}
|
||||||
@@ -27,6 +28,7 @@ namespace
|
|||||||
|
|
||||||
~glfw_state() noexcept {
|
~glfw_state() noexcept {
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
glfwSetErrorCallback(nullptr);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
static bool poll_events() noexcept {
|
static bool poll_events() noexcept {
|
||||||
@@ -48,6 +50,16 @@ namespace
|
|||||||
private:
|
private:
|
||||||
static std::mutex mutex_;
|
static std::mutex mutex_;
|
||||||
static std::shared_ptr<glfw_state> shared_state_;
|
static std::shared_ptr<glfw_state> shared_state_;
|
||||||
|
private:
|
||||||
|
static void error_handler(int error, const char* message) noexcept {
|
||||||
|
try {
|
||||||
|
the<debug>().error(
|
||||||
|
"GLFW: error(%0) message(%1)",
|
||||||
|
error, message);
|
||||||
|
} catch (...) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::mutex glfw_state::mutex_;
|
std::mutex glfw_state::mutex_;
|
||||||
|
|||||||
Reference in New Issue
Block a user