Added DEBUG mode to logging
This commit is contained in:
parent
3e24014492
commit
593eec8b8e
@ -3,7 +3,7 @@
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-DDEBUG")
|
||||
set(CMAKE_CXX_FLAGS "-D_DEBUG -Wall")
|
||||
|
||||
project(Pleascach)
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ Renderer::Renderer(Window& win) : win(win) {
|
||||
}
|
||||
|
||||
/* query and enable available layers if in DEBUG mode */
|
||||
#ifdef DEBUG
|
||||
#ifdef _DEBUG
|
||||
|
||||
auto layers = vk::enumerateInstanceLayerProperties();
|
||||
Log::info("%zu available instance layers\n", layers.size());
|
||||
@ -221,9 +221,12 @@ Renderer::Renderer(Window& win) : win(win) {
|
||||
}
|
||||
|
||||
void Renderer::draw() {
|
||||
Log::info("draw() called \n");
|
||||
Log::debug("draw() called \n");
|
||||
|
||||
if(dev.waitForFences(render_fence, true, UINT64_MAX) != vk::Result::eSuccess) {
|
||||
Log::error("Failed to wait for fences in draw()\n");
|
||||
}
|
||||
|
||||
dev.waitForFences(render_fence, true, UINT64_MAX);
|
||||
dev.resetFences(render_fence);
|
||||
|
||||
/* check if the swapchain is still good (no resize) */
|
||||
@ -296,7 +299,7 @@ void Renderer::draw() {
|
||||
}
|
||||
|
||||
void Renderer::present() {
|
||||
Log::info("present() called \n");
|
||||
Log::debug("present() called \n");
|
||||
auto present_info = vk::PresentInfoKHR{
|
||||
.waitSemaphoreCount = 1,
|
||||
.pWaitSemaphores = &render_wait_semaphore,
|
||||
|
||||
@ -31,6 +31,9 @@ int main(int argc, char* argv[]) {
|
||||
case InputEvent::Tag::EXIT:
|
||||
win.close();
|
||||
break;
|
||||
case InputEvent::Tag::CURSOR:
|
||||
case InputEvent::Tag::BUTTON:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
17
util/log.hpp
17
util/log.hpp
@ -5,6 +5,7 @@ namespace Log {
|
||||
enum MessageLevelBit {
|
||||
ERROR = 0x01,
|
||||
INFO = 0x02,
|
||||
DEBUG = 0x04,
|
||||
};
|
||||
|
||||
static const MessageLevelBit log_mask = static_cast<MessageLevelBit>(~0);
|
||||
@ -17,11 +18,14 @@ namespace Log {
|
||||
/* appearently C++ doesn't have designated array indices :( */
|
||||
const char* level_txt = "[UNKNOWN] ";
|
||||
switch (level) {
|
||||
case ERROR:
|
||||
level_txt = "[ERROR] ";
|
||||
case ERROR:
|
||||
level_txt = "[ERROR] ";
|
||||
break;
|
||||
case INFO:
|
||||
level_txt = "[INFO] ";
|
||||
case INFO:
|
||||
level_txt = "[INFO] ";
|
||||
break;
|
||||
case DEBUG:
|
||||
level_txt = "[DEBUG] ";
|
||||
break;
|
||||
}
|
||||
std::fprintf(stderr, level_txt);
|
||||
@ -40,4 +44,9 @@ namespace Log {
|
||||
static void info(const std::string& fmt, Args... args) {
|
||||
print(MessageLevelBit::INFO, fmt, args...);
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
static void debug(const std::string& fmt, Args... args) {
|
||||
print(MessageLevelBit::DEBUG, fmt, args...);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user