You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
#include <GL/glew.h>
|
|
#include <GLFW/glfw3.h>
|
|
#include "utils.h"
|
|
#include <algorithm>
|
|
|
|
#define numVAOs 1
|
|
|
|
GLuint renderingProgram;
|
|
GLuint vao[numVAOs];
|
|
|
|
void init(GLFWwindow* window) {
|
|
renderingProgram=utils::createShaderProgram("vertShader.glsl","fragShader.glsl");
|
|
glGenVertexArrays(numVAOs,vao);
|
|
glBindVertexArray(vao[0]);
|
|
}
|
|
|
|
float size=0;
|
|
float inc=150;
|
|
double lastTime=0;
|
|
|
|
void display(GLFWwindow* window, double currentTime) {
|
|
double elapsedTime=currentTime-lastTime;
|
|
lastTime=currentTime;
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT);
|
|
glClearColor(0,0,0.2,1);
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
glUseProgram(renderingProgram);
|
|
size+=inc*elapsedTime;
|
|
if(size>300||size<1){inc*=-1;size=std::clamp(size,1.f,300.f);}
|
|
glPointSize(size);
|
|
|
|
glDrawArrays(GL_POINTS,0,1);
|
|
}
|
|
|
|
int main(void) {
|
|
if (!glfwInit()) { exit(EXIT_FAILURE); }
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
|
GLFWwindow* window = glfwCreateWindow(300, 300, "Expanding Dot", NULL, NULL);
|
|
glfwMakeContextCurrent(window);
|
|
if (glewInit() != GLEW_OK) { exit(EXIT_FAILURE); }
|
|
glfwSwapInterval(1);
|
|
|
|
init(window);
|
|
|
|
while (!glfwWindowShouldClose(window)) {
|
|
display(window,glfwGetTime());
|
|
glfwSwapBuffers(window);
|
|
glfwPollEvents();
|
|
}
|
|
|
|
glfwDestroyWindow(window);
|
|
glfwTerminate();
|
|
exit(EXIT_SUCCESS);
|
|
} |