-
- GLuint VertexArrayID;
- glGenVertexArrays(1, &VertexArrayID);
- glBindVertexArray(VertexArrayID);
-
-
- GLuint vtx_buf;
- glGenBuffers(1, &vtx_buf);
- glBindBuffer(GL_ARRAY_BUFFER, vtx_buf);
- glBufferData(GL_ARRAY_BUFFER, sizeof(vtx_coords), vtx_coords, GL_STATIC_DRAW);
-
-
- glm::mat4 projection = glm::perspective(
- 45.0f, // FOV in degrees
- 1.0f, // aspect ratio
- 0.1f, // near clip
- 100.0f // far clip
- );
- glm::mat4 view = glm::lookAt(
- glm::vec3(0, 0, 0), // observer
- glm::vec3(0, 0, -1), // target
- glm::vec3(0, 1, 0) // up
- );
- glm::mat4 model(1.0f); // identity: no transformation
- glm::mat4 mvp = projection * view * model;
-
- GLuint mvp_id = program.UniformLocation("MVP");
-
-
- glClearColor(0.0, 0.0, 0.0, 1.0);
-
-
- bool running = true;
- Uint32 last = SDL_GetTicks();
- while (running) {
- Uint32 now = SDL_GetTicks();
- int delta = now - last;
-
- SDL_Event event;
- while (SDL_PollEvent(&event)) {
- switch (event.type) {
- case SDL_QUIT:
- running = false;
- break;
- default:
- break;
- }