mirror of
https://github.com/kuhyx/engineer-thesis-WUT.git
synced 2026-07-04 13:03:07 +02:00
feat: change whatToDraw to int
This commit is contained in:
parent
7225191a23
commit
a0a3c20b03
@ -95,6 +95,8 @@ namespace constants
|
||||
|
||||
inline constexpr size_t SQUARE_VERTICES_SIZE = { sizeof(SQUARE_VERTICES) };
|
||||
|
||||
inline constexpr int MAX_DRAW_CALL = { 2 };
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -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()
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
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();
|
||||
|
||||
Binary file not shown.
@ -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))
|
||||
{
|
||||
|
||||
@ -3,18 +3,14 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
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
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user