Skip to content

bartez33a/OpenGL_Pendulum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenGL_Pendulum

It's a simulation of pendulum in OpenGL.

You can create Pendulum object via constructor:

Pendulum name(size_of_circle, length_of_pendulum, start_angle_in_degrees)

and then you have to write some code in rendering loop like this:

//uniform for translate pendulum
unsigned int transformLoc = glGetUniformLocation(s_p1.get_ID(), "transform");
glm::mat4 trans = glm::mat4(1.0f);
glm::vec3 tr_vec(p1.get_x_translate(), p1.get_y_translate(), p1.get_z_translate());
trans = glm::translate(trans, tr_vec);
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(trans));

//color of pendulum to fragment shader
unsigned int colorLoc = glGetUniformLocation(s_p1.get_ID(), "color");
glm::vec4 color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
glUniform4f(colorLoc, 1.0f, 0.0f, 0.0f, 0.0f);

p1.calculate_new_pos(glfwGetTime());
p1.draw_pendulum();

Examples:

image image image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages