diff --git a/src/Makefile.am b/src/Makefile.am index 55f43977..ecd5dc24 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,7 +63,7 @@ liblol_core_headers = \ lol/gpu/all.h \ lol/gpu/shader.h lol/gpu/indexbuffer.h lol/gpu/vertexbuffer.h \ lol/gpu/framebuffer.h lol/gpu/texture.h lol/gpu/lolfx.h \ - lol/gpu/renderer.h lol/gpu/rendercontext.h \ + lol/gpu/renderer.h lol/gpu/rendercontext.h lol/gpu/debug.h \ \ lol/debug/all.h \ lol/debug/lines.h @@ -95,7 +95,7 @@ liblol_core_sources = \ \ gpu/shader.cpp gpu/indexbuffer.cpp gpu/vertexbuffer.cpp \ gpu/framebuffer.cpp gpu/texture.cpp gpu/renderer.cpp \ - gpu/rendercontext.cpp \ + gpu/rendercontext.cpp gpu/debug.cpp \ \ audio/audio.cpp audio/sample.cpp \ \ diff --git a/src/gpu/debug.cpp b/src/gpu/debug.cpp new file mode 100644 index 00000000..ffe6a5b8 --- /dev/null +++ b/src/gpu/debug.cpp @@ -0,0 +1,26 @@ +// +// Lol Engine +// +// Copyright © 2010—2019 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#include + +#include "lolgl.h" + +namespace lol +{ + +void gpu::error(char const *msg, int error) +{ + msg::error("%s: GL error 0x%04x\n", msg, error); +} + +} + diff --git a/src/lol-core.vcxproj b/src/lol-core.vcxproj index abc95d9b..a302416f 100644 --- a/src/lol-core.vcxproj +++ b/src/lol-core.vcxproj @@ -129,6 +129,7 @@ + @@ -261,6 +262,7 @@ + diff --git a/src/lol-core.vcxproj.filters b/src/lol-core.vcxproj.filters index f5ec1f79..18bfd650 100644 --- a/src/lol-core.vcxproj.filters +++ b/src/lol-core.vcxproj.filters @@ -79,6 +79,9 @@ + + gpu + gpu @@ -387,6 +390,9 @@ lol\gpu + + lol\gpu + lol\gpu diff --git a/src/lol/gpu/all.h b/src/lol/gpu/all.h index 7e964e33..fde2422d 100644 --- a/src/lol/gpu/all.h +++ b/src/lol/gpu/all.h @@ -10,6 +10,7 @@ #pragma once +#include #include #include #include diff --git a/src/lol/gpu/debug.h b/src/lol/gpu/debug.h new file mode 100644 index 00000000..ab840071 --- /dev/null +++ b/src/lol/gpu/debug.h @@ -0,0 +1,26 @@ +// +// Lol Engine +// +// Copyright © 2010—2019 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +namespace lol +{ + +namespace gpu +{ + +void error(char const *msg, int error); + +} // namespace gpu + +} // namespace lol + diff --git a/src/lolgl.h b/src/lolgl.h index af012909..3fa4e88d 100644 --- a/src/lolgl.h +++ b/src/lolgl.h @@ -61,9 +61,13 @@ # endif #endif +#define LOL_STRINGIFY_INNER(n) #n +#define LOL_STRINGIFY(n) LOL_STRINGIFY_INNER(n) + #define LOL_CHECK_GLERROR() \ { \ GLenum error = glGetError(); \ - ASSERT(error == GL_NO_ERROR, "OpenGL error: 0x%04x\n", error); \ + if (error != GL_NO_ERROR) \ + lol::gpu::error(__FILE__ ":" LOL_STRINGIFY(__LINE__), (int)error); \ }