diff --git a/Engine/engine/constants.hpp b/Engine/engine/constants.hpp index c0a5f7b..4285abf 100644 --- a/Engine/engine/constants.hpp +++ b/Engine/engine/constants.hpp @@ -95,6 +95,8 @@ namespace constants inline constexpr size_t SQUARE_VERTICES_SIZE = { sizeof(SQUARE_VERTICES) }; + inline constexpr int MAX_DRAW_CALL = { 2 }; + } #endif \ No newline at end of file diff --git a/Engine/engine/draw.cpp b/Engine/engine/draw.cpp index 5a3d0a6..f81c27f 100644 --- a/Engine/engine/draw.cpp +++ b/Engine/engine/draw.cpp @@ -9,25 +9,19 @@ #include "constants.hpp" #include "misc.hpp" -int drawFigure(const bool whatToDraw) +int drawFigure(const int whatToDraw) { - if (whatToDraw) + switch (whatToDraw) { - if (drawTriangle() == -1) - { - print("Error with drawing triangle! "); - return -1; - } + case 0: + return drawTriangle(); + case 1: + return drawSquare(); + case constants::MAX_DRAW_CALL: + return drawTriangle(); + default: + throw "No function for this draw call"; } - else - { - if (drawSquare() == -1) - { - print("Error with drawing square! "); - return -1; - } - } - return 0; } int drawSquare() diff --git a/Engine/engine/draw.hpp b/Engine/engine/draw.hpp index 634f778..f28bb3b 100644 --- a/Engine/engine/draw.hpp +++ b/Engine/engine/draw.hpp @@ -3,7 +3,7 @@ #include #include -int drawFigure(const bool whatToDraw); +int drawFigure(const int whatToDraw); int drawSquare(); void doDrawElements(const unsigned int shaderProgram, const unsigned int vertexArrayObject, const GLenum drawArrayMode, const GLenum drawType, const int numberOfElementsToDraw); int drawTriangle(); diff --git a/Engine/engine/match b/Engine/engine/match index 5314c3a..8dabe42 100755 Binary files a/Engine/engine/match and b/Engine/engine/match differ diff --git a/Engine/engine/renderLoop.cpp b/Engine/engine/renderLoop.cpp index 61016fc..72371b8 100644 --- a/Engine/engine/renderLoop.cpp +++ b/Engine/engine/renderLoop.cpp @@ -9,7 +9,7 @@ #include "constants.hpp" #include "misc.hpp" -bool processInput(GLFWwindow *window, const bool whatToDraw) +bool processInput(GLFWwindow *window, const int whatToDraw) { // glfwGetKey takes window and key as an input and checks is currently being pressed // if the user pressed escape we close window @@ -18,7 +18,7 @@ bool processInput(GLFWwindow *window, const bool whatToDraw) if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS) - return !whatToDraw; + return (whatToDraw == constants::MAX_DRAW_CALL ? 0 : whatToDraw + 1); return whatToDraw; } @@ -96,7 +96,7 @@ void copyVerticesArray(const unsigned int vertexBufferObject, const float vertic glBufferData(boundBufferTarget, sizeOfVertices, vertices, GL_STATIC_DRAW); } -bool renderLoopInside(GLFWwindow *window, bool whatToDraw) +bool renderLoopInside(GLFWwindow *window, int whatToDraw) { // input whatToDraw = processInput(window, whatToDraw); @@ -124,7 +124,7 @@ bool renderLoopInside(GLFWwindow *window, bool whatToDraw) void renderLoop(GLFWwindow *window) { - bool whatToDraw = true; + int whatToDraw = 0; // glfwWindowShouldClose checks if GLFW was instructed to close while (!glfwWindowShouldClose(window)) { diff --git a/Engine/engine/renderLoop.hpp b/Engine/engine/renderLoop.hpp index c17cd3b..39112c4 100644 --- a/Engine/engine/renderLoop.hpp +++ b/Engine/engine/renderLoop.hpp @@ -3,18 +3,14 @@ #include #include - - -void renderLoop(GLFWwindow* window); -bool renderLoopInside(GLFWwindow* window, bool whatToDraw); +void renderLoop(GLFWwindow *window); +bool renderLoopInside(GLFWwindow *window, int whatToDraw); void copyVerticesArray(unsigned int vertexBufferObject, const float vertices[], const size_t sizeOfVertices, const GLenum boundBufferTarget); unsigned int generateBindVAO(); void configureVertexAttribute(); -bool processInput(GLFWwindow *window, bool whatToDraw); - +bool processInput(GLFWwindow *window, int whatToDraw); unsigned int copyVerticesMemory(const float vertices[], const size_t sizeOfVertices, const GLenum boundBufferTarget); unsigned int copyVerticesMemory(const unsigned int vertices[], const size_t sizeOfVertices, const GLenum boundBufferTarget); - -#endif \ No newline at end of file +#endif \ No newline at end of file