mirror of
https://github.com/kuhyx/engineer-thesis-WUT.git
synced 2026-07-04 15:23:13 +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 size_t SQUARE_VERTICES_SIZE = { sizeof(SQUARE_VERTICES) };
|
||||||
|
|
||||||
|
inline constexpr int MAX_DRAW_CALL = { 2 };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -9,25 +9,19 @@
|
|||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "misc.hpp"
|
#include "misc.hpp"
|
||||||
|
|
||||||
int drawFigure(const bool whatToDraw)
|
int drawFigure(const int whatToDraw)
|
||||||
{
|
{
|
||||||
if (whatToDraw)
|
switch (whatToDraw)
|
||||||
{
|
{
|
||||||
if (drawTriangle() == -1)
|
case 0:
|
||||||
{
|
return drawTriangle();
|
||||||
print("Error with drawing triangle! ");
|
case 1:
|
||||||
return -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()
|
int drawSquare()
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
int drawFigure(const bool whatToDraw);
|
int drawFigure(const int whatToDraw);
|
||||||
int drawSquare();
|
int drawSquare();
|
||||||
void doDrawElements(const unsigned int shaderProgram, const unsigned int vertexArrayObject, const GLenum drawArrayMode, const GLenum drawType, const int numberOfElementsToDraw);
|
void doDrawElements(const unsigned int shaderProgram, const unsigned int vertexArrayObject, const GLenum drawArrayMode, const GLenum drawType, const int numberOfElementsToDraw);
|
||||||
int drawTriangle();
|
int drawTriangle();
|
||||||
|
|||||||
Binary file not shown.
@ -9,7 +9,7 @@
|
|||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include "misc.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
|
// glfwGetKey takes window and key as an input and checks is currently being pressed
|
||||||
// if the user pressed escape we close window
|
// 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)
|
if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS)
|
||||||
glfwSetWindowShouldClose(window, true);
|
glfwSetWindowShouldClose(window, true);
|
||||||
if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS)
|
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;
|
return whatToDraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ void copyVerticesArray(const unsigned int vertexBufferObject, const float vertic
|
|||||||
glBufferData(boundBufferTarget, sizeOfVertices, vertices, GL_STATIC_DRAW);
|
glBufferData(boundBufferTarget, sizeOfVertices, vertices, GL_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool renderLoopInside(GLFWwindow *window, bool whatToDraw)
|
bool renderLoopInside(GLFWwindow *window, int whatToDraw)
|
||||||
{
|
{
|
||||||
// input
|
// input
|
||||||
whatToDraw = processInput(window, whatToDraw);
|
whatToDraw = processInput(window, whatToDraw);
|
||||||
@ -124,7 +124,7 @@ bool renderLoopInside(GLFWwindow *window, bool whatToDraw)
|
|||||||
|
|
||||||
void renderLoop(GLFWwindow *window)
|
void renderLoop(GLFWwindow *window)
|
||||||
{
|
{
|
||||||
bool whatToDraw = true;
|
int whatToDraw = 0;
|
||||||
// glfwWindowShouldClose checks if GLFW was instructed to close
|
// glfwWindowShouldClose checks if GLFW was instructed to close
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,18 +3,14 @@
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
void renderLoop(GLFWwindow *window);
|
||||||
|
bool renderLoopInside(GLFWwindow *window, int whatToDraw);
|
||||||
void renderLoop(GLFWwindow* window);
|
|
||||||
bool renderLoopInside(GLFWwindow* window, bool whatToDraw);
|
|
||||||
void copyVerticesArray(unsigned int vertexBufferObject, const float vertices[], const size_t sizeOfVertices, const GLenum boundBufferTarget);
|
void copyVerticesArray(unsigned int vertexBufferObject, const float vertices[], const size_t sizeOfVertices, const GLenum boundBufferTarget);
|
||||||
unsigned int generateBindVAO();
|
unsigned int generateBindVAO();
|
||||||
void configureVertexAttribute();
|
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 float vertices[], const size_t sizeOfVertices, const GLenum boundBufferTarget);
|
||||||
unsigned int copyVerticesMemory(const unsigned int 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