diff --git a/CMakeLists.txt b/CMakeLists.txt index c73b09d..c30b34a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,6 @@ set(LUNARIUM_SRC "src/graphics/opengl/glGraphics.cpp" "src/graphics/opengl/glText.cpp" "src/graphics/opengl/glShader.cpp" -"src/internal_data/internal_font.cpp" "src/internal_data/data_manager.cpp" "src/input/keyboard.cpp" "src/input/input_manager.cpp" diff --git a/docs/tasks/core.todo b/docs/tasks/core.todo index c04d4af..3dc6b2d 100644 --- a/docs/tasks/core.todo +++ b/docs/tasks/core.todo @@ -26,6 +26,8 @@ Core: ✔ Read the window size and position on shutdown and write these to the state file @done (2/8/2022, 4:39:37 PM) Graphics: + ☐ Move the openGL reference out of the Image class (OpenGL ID) and make the ID more generic + ☐ Add layer to interface API for setting the Images ID in a generic way ☐ Implement batch rendering ✔ Decide on a font/text rendering system @done (9/7/2021, 1:39:53 PM) ✔ Add FreeType to the project @done (9/7/2021, 2:23:13 PM) @@ -108,14 +110,14 @@ Utils: Assets: - ✔ Internal Asset Manager @high @done (1/25/2022, 3:58:20 PM) - + ☐ Document Index.Dat and the AssetIndex class + ☐ Move the GenerateFont method from internal_font.h into data_manager.h Types: - Classes that represent each resource Types ✔ Image class @done (9/16/2021, 2:46:34 PM) - ✔ Decouple Image class from OGLRenderer @high @done (10/27/2021, 7:41:50 PM) + ✔ Decouple Image class from OGLRenderer @high @done (10/27/2021, 7:41:50 PM) ☐ Font class ☐ Sound class ✔ Script class @done (1/25/2022, 3:58:28 PM) diff --git a/docs/tasks/game.todo b/docs/tasks/game.todo index 2774262..12b219f 100644 --- a/docs/tasks/game.todo +++ b/docs/tasks/game.todo @@ -28,7 +28,11 @@ Game: To support larger region sizes without needing single images that are like 1048576x1048576 or some nonsense.] Game Object: - ☐ List of components + ✘ List of components @cancelled(22-05-16 20:01) + + Enitity: + ☐ Single UUID + ☐ Functionality for adding/working with components (through EnTT) Components: ☐ Transform diff --git a/src/internal_data/data_manager.cpp b/src/internal_data/data_manager.cpp index 94dba88..823692c 100644 --- a/src/internal_data/data_manager.cpp +++ b/src/internal_data/data_manager.cpp @@ -10,14 +10,19 @@ #include "data_manager.h" #include +#include #include #include // ASSETS +#include "data_headers/open_font.h" +#include "data_headers/roboto_font.h" #include "data_headers/folder16.h" #include "data_headers/new_dir_icon.h" #include "data_headers/up_arrow_icon.h" +#include + namespace lunarium { // Init asset pointers @@ -77,4 +82,33 @@ namespace lunarium delete mNewFolderIcon; delete mFolderIcon; } + + bool DataManager::GenerateFontFileAt(Font font, const char * filename) + { + std::ofstream ofs(filename, std::ios_base::binary); + + if (!ofs.is_open()) + { + Logger::Warn(LogCategory::GRAPHICS, "Could not generate the default font file at: %s", filename); + return false; + } + + + switch (font) + { + case Font::F_OPEN: + ofs.write((const char*)OpenFontData, OpenDataSize); + break; + + + case Font::F_ROBOTO: + ofs.write((const char*)RobotoFontData, RobotoDataSize); + break; + } + + ofs.close(); + ofs.clear(); + + return true; + } } \ No newline at end of file diff --git a/src/internal_data/data_manager.h b/src/internal_data/data_manager.h index 6a2b8fe..07c1407 100644 --- a/src/internal_data/data_manager.h +++ b/src/internal_data/data_manager.h @@ -13,6 +13,12 @@ namespace lunarium { + enum Font + { + F_OPEN, + F_ROBOTO, + }; + class Image; class DataManager { @@ -21,6 +27,8 @@ namespace lunarium static void Initialize(); static void Shutdown(); + + static bool GenerateFontFileAt(Font font, const char* filename); // DATA wrapped in asset types static Image* mFolderIcon; diff --git a/src/internal_data/internal_font.cpp b/src/internal_data/internal_font.cpp deleted file mode 100644 index 0896786..0000000 --- a/src/internal_data/internal_font.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/****************************************************************************** -* File - Internal_font.h -* Author - Joey Pollack -* Date - 2020/01/08 (y/m/d) -* Mod Date - 2021/09/07 (y/m/d) -* Description - Generates a font file (from OpenSans-Regular.ttf) -* -******************************************************************************/ - -#include "internal_font.h" -#include "data_headers/open_font.h" -#include "data_headers/roboto_font.h" -#include -#include - -namespace lunarium -{ - bool GenerateFontFileAt(Font font, const char * filename) - { - std::ofstream ofs(filename, std::ios_base::binary); - - if (!ofs.is_open()) - { - Logger::Warn(LogCategory::GRAPHICS, "Could not generate the default font file at: %s", filename); - return false; - } - - - switch (font) - { - case Font::F_OPEN: - ofs.write((const char*)OpenFontData, OpenDataSize); - break; - - - case Font::F_ROBOTO: - ofs.write((const char*)RobotoFontData, RobotoDataSize); - break; - } - - ofs.close(); - ofs.clear(); - - return true; - } -} - diff --git a/src/internal_data/internal_font.h b/src/internal_data/internal_font.h deleted file mode 100644 index 03b1cb9..0000000 --- a/src/internal_data/internal_font.h +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** -* File - internal_font.h -* Author - Joey Pollack -* Date - 2020/01/08 (y/m/d) -* Mod Date - 2020/01/08 (y/m/d) -* Description - Generates a font file (from OpenSans-Regular.ttf) -* -******************************************************************************/ - -#ifndef INTERNAL_FONT_H_ -#define INTERNAL_FONT_H_ - -namespace lunarium -{ - enum Font - { - F_OPEN, - F_ROBOTO, - }; - bool GenerateFontFileAt(Font font, const char* filename); -} - -#endif // INTERNAL_FONT_H_ \ No newline at end of file diff --git a/src/internal_libs/assets/types/image.cpp b/src/internal_libs/assets/types/image.cpp index 50a7c8c..b7c72bb 100644 --- a/src/internal_libs/assets/types/image.cpp +++ b/src/internal_libs/assets/types/image.cpp @@ -9,6 +9,7 @@ #include "image.h" #include +#include namespace lunarium { @@ -120,6 +121,7 @@ namespace lunarium void Image::SetGLTextureID(unsigned int id) { + Logger::Debug(LogCategory::GRAPHICS, "GLTexture ID set for Image"); mGLTextureID = id; } diff --git a/src/internal_libs/gui/gui.cpp b/src/internal_libs/gui/gui.cpp index a5adc4c..1940591 100644 --- a/src/internal_libs/gui/gui.cpp +++ b/src/internal_libs/gui/gui.cpp @@ -14,7 +14,7 @@ #include "dearimgui/imgui.h" #include "dearimgui/imgui_impl_glfw.h" #include "dearimgui/imgui_impl_opengl3.h" -#include +#include namespace lunarium { @@ -57,7 +57,7 @@ namespace lunarium io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows // NOTE: Generating a font file for now. Late might look into loading directly from memory - GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf"); + DataManager::GenerateFontFileAt(Font::F_ROBOTO, "robo.ttf"); //io.Fonts->AddFontFromFileTTF("open.ttf", 16.0f); io.Fonts->AddFontFromFileTTF("robo.ttf", 18.0f); //io.Fonts->AddFontFromFileTTF("Karla-Regular.ttf", 16.0f);