|
@@ -1,5 +1,3 @@
|
|
|
-#include <iostream>
|
|
|
-
|
|
|
#define GLFW_INCLUDE_NONE
|
|
|
#include <GLFW/glfw3.h>
|
|
|
#include <glad/glad.h>
|
|
@@ -16,12 +14,10 @@
|
|
|
|
|
|
void process_input(GLFWwindow* window);
|
|
|
|
|
|
-
|
|
|
int main() {
|
|
|
|
|
|
if (!glfwInit()) {
|
|
|
spdlog::error("Could not intialize GLFW.");
|
|
|
- glfwTerminate();
|
|
|
return EXIT_FAILURE;
|
|
|
}
|
|
|
glfwSetErrorCallback(error_callback);
|
|
@@ -37,7 +33,7 @@ int main() {
|
|
|
return EXIT_FAILURE;
|
|
|
}
|
|
|
glfwMakeContextCurrent(window);
|
|
|
-
|
|
|
+
|
|
|
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
|
|
spdlog::error("Failed to initialize GLAD");
|
|
|
return EXIT_FAILURE;
|
|
@@ -45,7 +41,7 @@ int main() {
|
|
|
glfwSetKeyCallback(window, key_callback);
|
|
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
|
|
|
|
|
-
|
|
|
+
|
|
|
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
|
|
|
glEnable(GL_BLEND);
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
@@ -58,15 +54,13 @@ int main() {
|
|
|
static_cast<float>(WINDOW_HEIGHT), 0.0f, -1.0f, 1.0f);
|
|
|
basic.setMatrix4("projection", projection);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
Renderer r = Renderer(basic);
|
|
|
float deltaTime = 0.0f;
|
|
|
float lastFrame = 0.0f;
|
|
|
|
|
|
while (!glfwWindowShouldClose(window)) {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
float currentFrame = glfwGetTime();
|
|
|
deltaTime = currentFrame - lastFrame;
|
|
|
lastFrame = currentFrame;
|
|
@@ -78,19 +72,14 @@ int main() {
|
|
|
glm::vec2 size(400.0f, 300.0f);
|
|
|
glm::vec3 color(0.5f, 0.5f, 0.5f);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
r.draw(pos, size, 0.0f, color);
|
|
|
|
|
|
+ spdlog::warn("deltaTime {}", 1.0f/deltaTime);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
glfwSwapBuffers(window);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
glfwDestroyWindow(window);
|
|
@@ -102,4 +91,4 @@ int main() {
|
|
|
void process_input(GLFWwindow* window) {
|
|
|
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
|
|
glfwSetWindowShouldClose(window, true);
|
|
|
-}
|
|
|
+}
|