mirror of
https://github.com/kuhyx/engineer-thesis-WUT.git
synced 2026-07-04 16:23:14 +02:00
100 lines
2.9 KiB
C++
100 lines
2.9 KiB
C++
#ifndef CONSTANTS_HPP
|
|
#define CONSTANTS_HPP
|
|
#include <GLFW/glfw3.h>
|
|
#include <iostream>
|
|
#include <string_view>
|
|
|
|
namespace constants
|
|
{
|
|
inline constexpr int GLFW_MAJOR_VERSION { 3 };
|
|
inline constexpr int GLFW_MINOR_VERSION { 3 };
|
|
// best practice is to use inline constexpr std::string_view but glfwCreateWindow takes only char* as input
|
|
inline const char* MAIN_WINDOW_NAME { "Match" };
|
|
inline constexpr int MAIN_WINDOW_WIDTH { 800 };
|
|
inline constexpr int MAIN_WINDOW_HEIGHT { 600 };
|
|
inline constexpr struct {
|
|
GLfloat red = 1.0f;
|
|
GLfloat green = 0.0f;
|
|
GLfloat blue = 0.0f;
|
|
GLfloat alpha = 1.0f;
|
|
} RED;
|
|
|
|
inline constexpr struct {
|
|
GLfloat red = 1.0f;
|
|
GLfloat green = 1.0f;
|
|
GLfloat blue = 1.0f;
|
|
GLfloat alpha = 1.0f;
|
|
} WHITE;
|
|
|
|
inline constexpr struct {
|
|
GLfloat red = 0.2f;
|
|
GLfloat green = 0.3f;
|
|
GLfloat blue = 0.3f;
|
|
GLfloat alpha = 1.0f;
|
|
} LEARN_OPEN_GL_COLOR;
|
|
|
|
// we write vertex shader
|
|
// version of glsl (since ogl 3.3 same as ogl so we pick 330)
|
|
// in this shader we just forward input data to shader output
|
|
inline const char *vertexShaderSource { "#version 330 core\n"
|
|
"layout (location = 0) in vec3 aPos;\n"
|
|
"void main()\n"
|
|
"{\n"
|
|
" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
|
|
"}\0" } ;
|
|
|
|
// write fragment shader
|
|
// we set the color of each pixel to be orange
|
|
inline const char *fragmentShaderSource {
|
|
"#version 330 core\n"
|
|
"out vec4 FragColor;\n"
|
|
"void main()\n"
|
|
"{\n"
|
|
"FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
|
|
"}\0"
|
|
};
|
|
|
|
// we specify three vertices
|
|
// each of them with position in 3d space
|
|
// x y z
|
|
inline constexpr float TRIANGLE_VERTICES[] {
|
|
-0.5f, -0.5f, 0.0f,
|
|
0.5f, -0.5f, 0.0f,
|
|
0.0f, 0.5f, 0.0f
|
|
};
|
|
|
|
inline constexpr size_t TRIANGLE_VERTICES_SIZE = { sizeof(TRIANGLE_VERTICES) };
|
|
|
|
// compare with square done with only vertices:
|
|
/*
|
|
float vertices[] = {
|
|
// first triangle
|
|
0.5f, 0.5f, 0.0f, // top right
|
|
0.5f, -0.5f, 0.0f, // bottom right
|
|
-0.5f, 0.5f, 0.0f, // top left
|
|
// second triangle
|
|
0.5f, -0.5f, 0.0f, // bottom right
|
|
-0.5f, -0.5f, 0.0f, // bottom left
|
|
-0.5f, 0.5f, 0.0f // top left
|
|
};
|
|
bottom right and top left is specified twice !
|
|
*/
|
|
inline constexpr float SQUARE_VERTICES[] {
|
|
0.5f, 0.5f, 0.0f, // top right
|
|
0.5f, -0.5f, 0.0f, // bottom right
|
|
-0.5f, -0.5f, 0.0f, // bottom left
|
|
-0.5f, 0.5f, 0.0f // top left
|
|
};
|
|
|
|
inline constexpr unsigned int SQUARE_INDICES[] {
|
|
0, 1, 3, // first triangle
|
|
1, 2, 3 // second triangle
|
|
};
|
|
|
|
inline constexpr size_t SQUARE_INDICES_SIZE = { sizeof(SQUARE_INDICES) };
|
|
|
|
inline constexpr size_t SQUARE_VERTICES_SIZE = { sizeof(SQUARE_VERTICES) };
|
|
|
|
}
|
|
|
|
#endif |