Zadanie 1 stable code

This commit is contained in:
Władysław Kuczerenko 2024-06-09 22:56:47 +02:00
parent 23be099698
commit a0923537f4
1 changed files with 18 additions and 2 deletions

View File

@ -3,20 +3,28 @@
#include <cmath>
#include <iostream>
#include <vector>
#include "shader.h"
// Konstante
const float g = 9.81f; // przyspieszenie ziemskie
const float r = 1.0f; // długość nici
const float r = 0.6f; // długość nici
const float dt = 0.01f; // krok czasowy
// Zmienne globalne
float theta = 0.5f; // początkowy kąt
float omega = 0.0f; // początkowa prędkość kątowa
GLuint VBO, VAO, EBO;
GLuint VBO, VAO, EBO, shaderProgram;
void compileShaders(){
Shader shader("pendulum_vs.glsl", "pendulum_fs.glsl");
shaderProgram = shader.programID();
}
void initOpenGL()
{
compileShaders();
// Setup Vertex Array Object and Vertex Buffer Object
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
@ -88,6 +96,7 @@ void drawPendulum()
glBindBuffer(GL_ARRAY_BUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(shaderProgram);
glBindVertexArray(VAO);
glDrawArrays(GL_LINES, 0, 2);
@ -104,6 +113,13 @@ int main()
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Wahadło Matematyczne", NULL, NULL);
if (!window)
{