refactor: remove debug/exceptions from engine module
This commit is contained in:
parent
eb428d11d6
commit
320295ad73
5 changed files with 7 additions and 65 deletions
|
@ -6,7 +6,10 @@ namespace lt {
|
||||||
|
|
||||||
struct FailedAssertion: std::exception
|
struct FailedAssertion: std::exception
|
||||||
{
|
{
|
||||||
FailedAssertion(const char *file, int line);
|
FailedAssertion(const char *file, int line)
|
||||||
|
{
|
||||||
|
log_crt("Assertion failed in: {} (line {})", file, line);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define lt_assert(x, ...) \
|
#define lt_assert(x, ...) \
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
add_library_module(engine
|
add_library_module(engine
|
||||||
core/application.cpp
|
core/application.cpp
|
||||||
debug/exceptions.cpp
|
|
||||||
debug/instrumentor.cpp
|
debug/instrumentor.cpp
|
||||||
layer/layer.cpp
|
layer/layer.cpp
|
||||||
layer/layer_stack.cpp
|
layer/layer_stack.cpp
|
||||||
|
@ -11,7 +10,6 @@ if(NOT WIN32)
|
||||||
else()
|
else()
|
||||||
add_library_module(engine
|
add_library_module(engine
|
||||||
core/application.cpp
|
core/application.cpp
|
||||||
debug/exceptions.cpp
|
|
||||||
debug/instrumentor.cpp
|
debug/instrumentor.cpp
|
||||||
layer/layer.cpp
|
layer/layer.cpp
|
||||||
layer/layer_stack.cpp
|
layer/layer_stack.cpp
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define dxc(x) dxc_no_redifinition(x, __LINE__)
|
|
||||||
|
|
||||||
#define dxc_no_redifinition(x, line) dxc_no_redifinition2(x, line)
|
|
||||||
|
|
||||||
#define dxc_no_redifinition2(x, line) \
|
|
||||||
HRESULT hr##line; \
|
|
||||||
if (FAILED(hr##line = x)) \
|
|
||||||
throw dxException(hr##line, __FILE__, line)
|
|
||||||
|
|
||||||
namespace lt {
|
|
||||||
|
|
||||||
#ifdef LIGHT_PLATFORM_WINDOWS
|
|
||||||
// DirectX
|
|
||||||
struct dxException: std::exception
|
|
||||||
{
|
|
||||||
dxException(long hr, const char *file, int line);
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace lt
|
|
|
@ -1,40 +0,0 @@
|
||||||
#include <engine/debug/exceptions.hpp>
|
|
||||||
#include <glad/gl.h>
|
|
||||||
|
|
||||||
#ifdef LIGHT_PLATFORM_WINDOWS
|
|
||||||
#include <Windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace lt {
|
|
||||||
|
|
||||||
FailedAssertion::FailedAssertion(const char *file, int line)
|
|
||||||
{
|
|
||||||
log_crt("Assertion failed in: {} (line {})", file, line);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LIGHT_PLATFORM_WINDOWS
|
|
||||||
dxException::dxException(long hr, const char *file, int line)
|
|
||||||
{
|
|
||||||
char *message;
|
|
||||||
FormatMessageA(
|
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
nullptr,
|
|
||||||
hr,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
||||||
(LPSTR)(&message),
|
|
||||||
NULL,
|
|
||||||
nullptr
|
|
||||||
);
|
|
||||||
|
|
||||||
// #todo: improve
|
|
||||||
log_crt("________________________________________");
|
|
||||||
log_crt("dxException::dxException::");
|
|
||||||
log_crt(" File: {}, Line: {}", file, line);
|
|
||||||
log_crt(" {}", message);
|
|
||||||
log_crt("________________________________________");
|
|
||||||
|
|
||||||
LocalFree(message);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace lt
|
|
|
@ -5,6 +5,9 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(window PUBLIC
|
target_link_libraries(window PUBLIC
|
||||||
|
glm::glm
|
||||||
|
|
||||||
|
PRIVATE
|
||||||
glfw
|
glfw
|
||||||
logger
|
logger
|
||||||
lt_debug
|
lt_debug
|
||||||
|
|
Loading…
Add table
Reference in a new issue