diff --git a/docs/Tasks.todo b/docs/Tasks.todo index 6f411ef..41978a8 100644 --- a/docs/Tasks.todo +++ b/docs/Tasks.todo @@ -1,14 +1,59 @@ +Build System: + ☐ Add a build option to do a build without the editor + Core: ☐ Add log settings to the state file + Graphics: + ☐ Dear ImGui class with basic initialization + ✔ 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) + ✔ Add a new class for font loading/management and text rendering @done (9/7/2021, 3:57:08 PM) + ✔ Make the text renderer smarter about breaking up words on multiple lines @low @done (9/8/2021, 2:23:03 PM) + ☐ Implement the Image creation methods + + Input: + ☐ Port over the Element2D input system and adjust it to use glfw + + Audio: + + Scripting: + Script Managment class: + ☐ Manage LUA states + ☐ Initialize new scripts + + Interface Class: + ☐ Provide Methods that give access to the C++ code + + Resource Managment: + +Game: + ☐ Load game project data + ☐ Manage list of scenes + ☐ Manage global scripts + + Scene: + ☐ Manage scene scripts + Manage list of Regions: + ☐ Track which regions should be loaded + + + Region: + ☐ List of renderable images for each layer + + Game Object: + ☐ List of components + + Components: + ☐ Transform + ☐ Image + ☐ Animation Controller + + Animations: + ☐ Animated Sprite class + -Graphics: - ☐ Dear ImGui class with basic initialization - ✔ 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) - ✔ Add a new class for font loading/management and text rendering @done (9/7/2021, 3:57:08 PM) - ☐ Make the text renderer smarter about breaking up words on multiple lines @low +Editor: -Input: - ☐ Port over the Element2D input system and adjust it to use glfw \ No newline at end of file + \ No newline at end of file diff --git a/src/core/core.cpp b/src/core/core.cpp index de1f290..dfc59ae 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -40,9 +40,11 @@ namespace lunarium Logger::Log(LogCategory::CORE, LogLevel::INFO, "Lunarium is shutting down!"); // Shutdown subsystems + mpInstance->mpGraphics->Shutdown(); delete mpInstance->mpGraphics; mpInstance->mpGraphics = nullptr; + mpInstance->mpWindow->Shutdown(); delete mpInstance->mpWindow; mpInstance->mpWindow = nullptr; @@ -171,6 +173,18 @@ namespace lunarium mpWindow->SetShouldCloseFlag(true); } + // DEBUG: Graphics testing + static int width = 500; + if (glfwGetKey(mpWindow->GetWindow(), GLFW_KEY_LEFT) == GLFW_PRESS) + { + width -= 10; + } + + if (glfwGetKey(mpWindow->GetWindow(), GLFW_KEY_RIGHT) == GLFW_PRESS) + { + width += 10; + } + // Update game state // Render @@ -178,7 +192,7 @@ namespace lunarium // DEBUG: Graphics tests mpGraphics->DrawFilledEllipse(glm::vec2(600, 300), glm::vec2(100, 150), Color(1.0f, 0.0f, 1.0f, 1.0f), 100); - mpGraphics->DrawString("This is a test of the text renderer!", Rectangle(100, 200, 500, 300), + mpGraphics->DrawString("This is a test of the text renderer!", Rectangle(100, 200, width, 300), Color(0.0f, 1.0f, 1.0f, 1.0f), 0.5f, mpGraphics->DefaultFont()); mpGraphics->EndDraw(); diff --git a/src/graphics/glText.cpp b/src/graphics/glText.cpp index 612fcb7..f9115ea 100644 --- a/src/graphics/glText.cpp +++ b/src/graphics/glText.cpp @@ -170,20 +170,35 @@ namespace lunarium int len = (int)strlen(text); for (int c = 0; c < len; c++) { - Character ch = mFonts[fontID].CharSet[text[c]]; - - GLfloat advance = (ch.Advance >> 6) * scale; - if (curX + advance > botRight.x) + // if the last character was a space then we must + // be starting a new word + if (c > 0 && ' ' == text[c - 1]) { - curX = topLeft.x; - curY += lineSize; + // check the total advance of this word to see if + // it would go beyond the right boundry + GLfloat totalAdvance = 0; + for (int i = c; text[i] != ' ' && text[i] != '\0'; i++) + { + Character ch = mFonts[fontID].CharSet[text[c]]; + + totalAdvance += (ch.Advance >> 6) * scale; + } + + + if (curX + totalAdvance > botRight.x) + { + curX = topLeft.x; + curY += lineSize; + } + + if (curY + lineSize > botRight.y) + { + break; + } } - if (curY + lineSize > botRight.y) - { - break; - } + Character ch = mFonts[fontID].CharSet[text[c]]; GLfloat xpos = curX + ch.Bearing.x * scale; GLfloat ypos = curY + (mFonts[fontID].MaxHeight - ch.Size.Height) * scale; diff --git a/src/main.cpp b/src/main.cpp index f284ad8..4a77bcf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,23 +12,9 @@ #include #include -// TESTING -// #include -// #include FT_FREETYPE_H int main(int argc, char** argv) { - // TESTING -- FREETYPE - // FT_Library ft; - // if (FT_Init_FreeType(&ft)) - // { - // std::cout << "Could not init FreeType Library\n"; - // return -1; - // } - // std::cout << "Freetype library sucessfully initialized!\n"; - //////////////// - - // Switch the currrent working directory to the directory // containing the lunarium.exe file because the data and state // file should be in that location