Compare commits
2 commits
30c9196af0
...
7f7eb8439c
Author | SHA1 | Date | |
---|---|---|---|
7f7eb8439c | |||
26d180ef2f |
8 changed files with 32 additions and 281 deletions
|
@ -1,16 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#ifndef LIGHT_CONFIG_H
|
|
||||||
#define LIGHT_CONFIG_H
|
|
||||||
|
|
||||||
//
|
|
||||||
// you can uncomment any of these definitions to config the project to your
|
|
||||||
// liking
|
|
||||||
//
|
|
||||||
|
|
||||||
// suppress undefined debug trap
|
|
||||||
#define LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP
|
|
||||||
|
|
||||||
// log opengl shader compile info
|
|
||||||
// #define LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,155 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#ifndef LIGHT_DEBUG_TRAP_H
|
|
||||||
#define LIGHT_DEBUG_TRAP_H
|
|
||||||
|
|
||||||
// https://github.com/nemequ/portable-snippets/tree/master/debug-trap
|
|
||||||
|
|
||||||
#ifdef LIGHT_DIST
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define lt_debug_trap() \
|
|
||||||
LT_FILE_CRITICAL( \
|
|
||||||
"DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \
|
|
||||||
__FUNCSIG__, \
|
|
||||||
__FILE__, \
|
|
||||||
__LINE__ \
|
|
||||||
) // or __FUNCSIG__
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define lt_debug_trap() \
|
|
||||||
LT_FILE_CRITICAL("DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(lt_debug_trap) && defined(__has_builtin) && !defined(__ibmxl__)
|
|
||||||
#if __has_builtin(__builtin_debugtrap)
|
|
||||||
#define lt_debug_trap() __builtin_debugtrap()
|
|
||||||
|
|
||||||
#elif __has_builtin(__debugbreak)
|
|
||||||
#define lt_debug_trap() __debugbreak()
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(lt_debug_trap)
|
|
||||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
|
||||||
#define lt_debug_trap() __debugbreak()
|
|
||||||
|
|
||||||
#elif defined(__ARMCC_VERSION)
|
|
||||||
#define lt_debug_trap() __breakpoint(42)
|
|
||||||
|
|
||||||
#elif defined(__ibmxl__) || defined(__xlC__)
|
|
||||||
#include <builtins.h>
|
|
||||||
#define lt_debug_trap() __trap(42)
|
|
||||||
|
|
||||||
#elif defined(__DMC__) && defined(_M_IX86)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm int 3h;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__i386__) || defined(__x86_64__)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__("int3");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__thumb__)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(".inst 0xde01");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__aarch64__)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(".inst 0xd4200000");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__arm__)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(".inst 0xe7f001f0");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__alpha__) && !defined(__osf__)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__("bpt");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_54_)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__("ESTOP");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_55_)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(";\n .if (.MNEMONIC)\n estop_1\n .else\n estop_1()\n .endif\n NOP");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_64P_)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__("SWBP 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_6x_)
|
|
||||||
static inline void lt_debug_trap(void)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__("NOP\n .word 0x10000000");
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(__STDC_HOSTED__) && (__STDC_HOSTED__ == 0) && defined(__GNUC__)
|
|
||||||
#define lt_debug_trap() __builtin_trap()
|
|
||||||
|
|
||||||
#else
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#if defined(SIGTRAP)
|
|
||||||
#define lt_debug_trap() raise(SIGTRAP)
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define lt_debug_trap() raise(SIGABRT)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(lt_debug_trap)
|
|
||||||
#if !defined(LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP)
|
|
||||||
#error "failed to define LT_BREAK, define LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP in Config.h to disable this error"
|
|
||||||
|
|
||||||
#elif defined(LIGHT_DIST)
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define lt_debug_trap() \
|
|
||||||
log_crt( \
|
|
||||||
"DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \
|
|
||||||
__FUNCSIG__, \
|
|
||||||
__FILE__, \
|
|
||||||
__LINE__ \
|
|
||||||
) // or __FUNCSIG__
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define lt_debug_trap() log_crt("DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#else /* !defined(LIGHT_DIST) */
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define lt_debug_trap() \
|
|
||||||
log_crt( \
|
|
||||||
"DEBUG_TRAP REQUESTED AT: {}, FILE: {}, LINE: {}", \
|
|
||||||
__FUNCSIG__, \
|
|
||||||
__FILE__, \
|
|
||||||
__LINE__ \
|
|
||||||
) // or __FUNCSIG__
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define lt_debug_trap() log_crt("DEBUG_TRAP REQUESTED AT: {}", __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -9,12 +9,6 @@ struct FailedAssertion: std::exception
|
||||||
FailedAssertion(const char *file, int line);
|
FailedAssertion(const char *file, int line);
|
||||||
};
|
};
|
||||||
|
|
||||||
// OpenGL
|
|
||||||
struct glException: std::exception
|
|
||||||
{
|
|
||||||
glException(unsigned int source, unsigned int type, unsigned int id, const char *msg);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define lt_assert(x, ...) \
|
#define lt_assert(x, ...) \
|
||||||
{ \
|
{ \
|
||||||
if (!(x)) \
|
if (!(x)) \
|
||||||
|
|
|
@ -27,6 +27,8 @@ public:
|
||||||
|
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
|
|
||||||
|
[[nodiscard]] auto sanity_check() const -> bool;
|
||||||
|
|
||||||
void game_loop();
|
void game_loop();
|
||||||
|
|
||||||
[[nodiscard]] auto get_window() -> Window &
|
[[nodiscard]] auto get_window() -> Window &
|
||||||
|
|
|
@ -1,90 +1,27 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef LIGHT_PLATFORM_WINDOWS
|
|
||||||
|
|
||||||
#include <engine/engine.hpp>
|
#include <engine/engine.hpp>
|
||||||
|
|
||||||
// to be defined in client project
|
int main(int argc, char *argv[]) // NOLINT
|
||||||
extern auto lt::create_application() -> lt::Scope<lt::Application>;
|
|
||||||
|
|
||||||
// #todo: use windows specific stuff
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
auto application = lt::Scope<lt::Application> {};
|
|
||||||
int exitCode = 0;
|
|
||||||
|
|
||||||
std::vector<std::string> args;
|
|
||||||
|
|
||||||
if (argc > 1)
|
|
||||||
args.assign(argv + 1, argv + argc);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
application = lt::create_application();
|
std::ignore = argc;
|
||||||
lt_assert(application, "lt::Application is not intialized");
|
std::ignore = argv;
|
||||||
|
|
||||||
for (int i = 0; i < argc; i++)
|
|
||||||
log_inf("argv[{}]: {}", i, argv[i]);
|
|
||||||
|
|
||||||
application->game_loop();
|
|
||||||
}
|
|
||||||
// failed engine assertion
|
|
||||||
catch (lt::FailedAssertion)
|
|
||||||
{
|
|
||||||
log_crt("Terminating due to unhandled 'FailedEngineAssertion'");
|
|
||||||
exitCode = -1;
|
|
||||||
}
|
|
||||||
// gl exception
|
|
||||||
catch (lt::glException)
|
|
||||||
{
|
|
||||||
log_crt("Terminating due to unhandled 'glException'");
|
|
||||||
exitCode = -3;
|
|
||||||
}
|
|
||||||
// dx exception
|
|
||||||
catch (lt::dxException)
|
|
||||||
{
|
|
||||||
log_crt("Terminating due to unhandled 'dxException'");
|
|
||||||
exitCode = -4;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete application;
|
|
||||||
return exitCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(LIGHT_PLATFORM_LINUX)
|
|
||||||
|
|
||||||
#include <engine/engine.hpp>
|
|
||||||
|
|
||||||
// to be defined in client project
|
|
||||||
extern auto lt::create_application() -> lt::Scope<lt::Application>;
|
|
||||||
|
|
||||||
// #todo: use linux specific stuff
|
|
||||||
int main(int /*argc*/, char * /*argv*/[])
|
|
||||||
{
|
|
||||||
auto application = lt::Scope<lt::Application> {};
|
auto application = lt::Scope<lt::Application> {};
|
||||||
int exitCode = 0;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
application = lt::create_application();
|
application = lt::create_application();
|
||||||
lt_assert(application, "lt::Application is not intialized");
|
|
||||||
|
lt_assert(application, "Failed to create application");
|
||||||
|
lt_assert(application->sanity_check(), "Failed to verify the sanity of the application");
|
||||||
|
|
||||||
application->game_loop();
|
application->game_loop();
|
||||||
}
|
|
||||||
// failed engine assertion
|
|
||||||
catch (lt::FailedAssertion)
|
|
||||||
{
|
|
||||||
log_crt("Exitting due to unhandled 'FailedEngineAssertion'");
|
|
||||||
exitCode = -1;
|
|
||||||
}
|
|
||||||
// gl exception
|
|
||||||
catch (lt::glException)
|
|
||||||
{
|
|
||||||
log_crt("main: exitting due to unhandled 'glException'");
|
|
||||||
exitCode = -3;
|
|
||||||
}
|
|
||||||
|
|
||||||
return exitCode;
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
catch (const std::exception &exp)
|
||||||
|
{
|
||||||
|
log_crt("Terminating due to uncaught exception:");
|
||||||
|
log_crt("\texception.what(): {}", exp.what());
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <asset_manager/asset_manager.hpp>
|
#include <asset_manager/asset_manager.hpp>
|
||||||
|
#include <debug/assertions.hpp>
|
||||||
#include <engine/core/application.hpp>
|
#include <engine/core/application.hpp>
|
||||||
#include <engine/core/window.hpp>
|
#include <engine/core/window.hpp>
|
||||||
#include <engine/debug/instrumentor.hpp>
|
#include <engine/debug/instrumentor.hpp>
|
||||||
|
@ -7,7 +8,6 @@
|
||||||
#include <input/events/event.hpp>
|
#include <input/events/event.hpp>
|
||||||
#include <input/events/keyboard.hpp>
|
#include <input/events/keyboard.hpp>
|
||||||
#include <input/events/window.hpp>
|
#include <input/events/window.hpp>
|
||||||
#include <debug/assertions.hpp>
|
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <renderer/blender.hpp>
|
#include <renderer/blender.hpp>
|
||||||
#include <renderer/graphics_context.hpp>
|
#include <renderer/graphics_context.hpp>
|
||||||
|
@ -186,6 +186,12 @@ void Application::on_event(const Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto Application::sanity_check() const -> bool
|
||||||
|
{
|
||||||
|
// TODO(Light): verify sanity of the application state
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Application::log_debug_data()
|
void Application::log_debug_data()
|
||||||
{
|
{
|
||||||
log_inf("Platform::");
|
log_inf("Platform::");
|
||||||
|
|
|
@ -12,24 +12,6 @@ FailedAssertion::FailedAssertion(const char *file, int line)
|
||||||
log_crt("Assertion failed in: {} (line {})", file, line);
|
log_crt("Assertion failed in: {} (line {})", file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
glException::glException(unsigned int source, unsigned int type, unsigned int id, const char *msg)
|
|
||||||
{
|
|
||||||
// #todo: improve
|
|
||||||
log_crt("________________________________________");
|
|
||||||
log_crt("glException::glException::");
|
|
||||||
// log_crt(" Severity: {}",
|
|
||||||
// Stringifier::glDebugMsgSeverity(GL_DEBUG_SEVERITY_HIGH));
|
|
||||||
// log_crt(" Source : {}", Stringifier::glDebugMsgSource(source));
|
|
||||||
// log_crt(" Type : {}", Stringifier::glDebugMsgType(type));
|
|
||||||
log_crt(" ID : {}", id);
|
|
||||||
// log_crt(" Vendor : {}", glGetString(GL_VENDOR));
|
|
||||||
// log_crt(" renderer: {}", glGetString(GL_RENDERER));
|
|
||||||
// log_crt(" Version : {}", glGetString(GL_VERSION));
|
|
||||||
// log_crt(" critical, SVersion: {}", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
|
||||||
log_crt(" {}", msg);
|
|
||||||
log_crt("________________________________________");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LIGHT_PLATFORM_WINDOWS
|
#ifdef LIGHT_PLATFORM_WINDOWS
|
||||||
dxException::dxException(long hr, const char *file, int line)
|
dxException::dxException(long hr, const char *file, int line)
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,7 +74,8 @@ void glGraphicsContext::set_debug_message_callback()
|
||||||
switch (severity)
|
switch (severity)
|
||||||
{
|
{
|
||||||
case GL_DEBUG_SEVERITY_HIGH:
|
case GL_DEBUG_SEVERITY_HIGH:
|
||||||
// throw glException(source, type, id, message);
|
// TODO(Light): Add gl exception class
|
||||||
|
throw std::runtime_error { "gl exception" };
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case GL_DEBUG_SEVERITY_MEDIUM:
|
case GL_DEBUG_SEVERITY_MEDIUM:
|
||||||
|
|
Loading…
Add table
Reference in a new issue