Skip to content

Commit

Permalink
Tidy DebugRendering classes
Browse files Browse the repository at this point in the history
Tidy logging constants
Tidy some generic opengl version debug logs
Some other small cleaning
  • Loading branch information
ConniBug committed Oct 16, 2023
1 parent 75240ae commit 58d7c20
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ set(SOURCE_FILES

src/CollisionEngine.cpp include/CollisionEngine.h

src/DebugRendering.cpp
include/DebugRendering.h

include/DebugRendering/DebugBox.h
src/DebugRendering/DebugBox.cpp

include/DebugRendering/DebugEntry.h
src/DebugRendering/DebugEntry.cpp
src/DebugRendering/DebugLine.cpp
include/DebugRendering/DebugLine.h
Scenes/star_viewer.cpp
Scenes/star_viewer.h
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// Created by Conni Bilham on 15/07/2023.
// Created by Conni Bilham on 16/10/2023.
//

#ifndef INC_2D_ENGINE_DEBUGRENDERING_H
#define INC_2D_ENGINE_DEBUGRENDERING_H
#ifndef INC_2D_ENGINE_DEBUGLINE_H
#define INC_2D_ENGINE_DEBUGLINE_H

#include <iostream>
#include "vec3.hpp"
Expand All @@ -26,4 +26,4 @@ class DebugLine : public DebugEntry {
};


#endif //INC_2D_ENGINE_DEBUGRENDERING_H
#endif //INC_2D_ENGINE_DEBUGLINE_H
2 changes: 1 addition & 1 deletion include/Storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Storage {
public:
unsigned int major = 0;
unsigned int minor = 2;
unsigned int patch = 1;
unsigned int patch = 2;

unsigned int build = 1;
} version;
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

Storage* storage;

#define T_STR(v) std::to_string(storage->get()->version.v)
#define T_STR(v) std::to_string(storage->version.v)
#define BUILD_STRING T_STR(major) + "." + T_STR(minor) + "." + T_STR(patch) + " Build " + T_STR(build)
int main() {
storage = new Storage();
Expand Down
10 changes: 6 additions & 4 deletions src/DebugRendering/DebugBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
// Created by Conni Bilham on 28/08/2023.
//

#include "DebugRendering.h"
#include <iostream>
#include "DebugRendering/DebugBox.h"
#include "glad/glad.h"

#include "../include/logging.h"

DebugBox::DebugBox(unsigned int shader_id, glm::vec3 start, glm::vec3 end) {
this->shader_id = shader_id;
this->start = start;
this->end = end;
}

DebugBox::~DebugBox() {
std::cout << "Box::~Box()" << std::endl;
logging::verbose("Box::~Box()");
}

void DebugBox::load() {
std::cout << "Box::load()" << std::endl;
logging::verbose("Box::load()");
float vertices[] = {
start.x, start.y, 0.0f,
end.x, start.y, 0.0f,
Expand Down Expand Up @@ -66,5 +68,5 @@ void DebugBox::draw() {
}

void DebugBox::init() {
std::cout << "Box::init()" << std::endl;
logging::verbose("Box::init()");
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by Conni Bilham on 15/07/2023.
//

#include "DebugRendering.h"
#include "DebugRendering/DebugLine.h"
#include "glad/glad.h"

DebugLine::DebugLine(unsigned int shader_id, glm::vec3 start, glm::vec3 end) {
Expand Down
18 changes: 8 additions & 10 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
//

#define RESET "\033[0m"
#define BLACK "\033[30m" /* Black */
#define RED "\033[31m" /* Red */
#define GREEN "\033[32m" /* Green */
#define YELLOW "\033[33m" /* Yellow */
#define BLUE "\033[34m" /* Blue */
#define MAGENTA "\033[35m" /* Magenta */
#define CYAN "\033[36m" /* Cyan */
#define WHITE "\033[37m" /* White */
#define BLACK "\033[30m" /* Black */
#define RED "\033[31m" /* Red */
#define GREEN "\033[32m" /* Green */
#define YELLOW "\033[33m" /* Yellow */
#define BLUE "\033[34m" /* Blue */
#define MAGENTA "\033[35m" /* Magenta */
#define CYAN "\033[36m" /* Cyan */
#define WHITE "\033[37m" /* White */
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
#define BOLDRED "\033[1m\033[31m" /* Bold Red */
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
Expand All @@ -23,8 +23,6 @@
#include <iomanip>
#include "../include/logging.h"

// TODO: Add colour

void logging::log(const std::string& message) {
auto c_time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::cout << BOLDWHITE << "[" << std::put_time(std::localtime(&c_time), "%F %T") << "] " << RESET << message << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Window::Window(int width, int height, std::string title, int fullscreen, Camera*
return;
}

logging::debug("OpenGL Version: " + std::string((char*)glGetString(GL_VERSION)));
logging::debug("OpenGL Vendor: " + std::string((char*)glGetString(GL_VENDOR)));
logging::debug("OpenGL Version: " + std::string((char*)glGetString(GL_VERSION)));
logging::debug("OpenGL Vendor: " + std::string((char*)glGetString(GL_VENDOR)));
logging::debug("OpenGL Renderer: " + std::string((char*)glGetString(GL_RENDERER)));
logging::debug("OpenGL Shading Language Version: " + std::string((char*)glGetString(GL_SHADING_LANGUAGE_VERSION)));
logging::debug("GL Shading VRS: " + std::string((char*)glGetString(GL_SHADING_LANGUAGE_VERSION)));

glfwSetKeyCallback(window, key_callback);
glfwSetCharCallback(window, character_callback);
Expand Down

0 comments on commit 58d7c20

Please sign in to comment.