Код: Выделить всё
// Includes
#include "../Libraries/GLAD/glad.h"
#include "../Libraries/STB/stb_image.h"
#include
#include "../../Header Files/Sprites/Shader.hpp"
#include "../../Header Files/Sprites/VertexArray.hpp"
#include "../../Header Files/Sprites/VertexBuffer.hpp"
#include "../../Header Files/Sprites/ElementBuffer.hpp"
#include "../../Header Files/Sprites/Texture.hpp"
// The Global variables of the project.
#include "../Header Files/Global.hpp"
// The vertices of our square.
GLfloat vertices[] =
{ // COORDINATES / COLORS // TEXTURE COORDINATES
-0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, // Lower left corner
-0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // Upper left corner
0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, // Upper right corner
0.5f, -0.5f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, // Lower right corner
};
// The order the program will draw the indices of the square.
const GLuint indices[] =
{
0, 2, 1,
0, 3, 2,
};
// Get the amount of vertices from the vertices variable.
const GLint amountOfVertices = 6;
int main()
{
// Initialize GLFW.
if (!glfwInit())
{
return 0;
}
// Specify to GLFW the version of OpenGL. (v3)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
// Specify to GLFW the profile we want to use. (Core to get the modern functions.)
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Create the window.
GLFWwindow* window = glfwCreateWindow(WINDOW::WIDTH, WINDOW::HEIGHT, WINDOW::TITLE.c_str(), NULL, NULL);
// Check if the window was successfully created.
if (window == NULL)
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79008501/image-stretching-when-the-window-is-not-a-square[/url]