diff --git a/Hohmann b/Hohmann index 46d95cc..f2f99d1 100755 Binary files a/Hohmann and b/Hohmann differ diff --git a/src/main.cpp b/src/main.cpp index af8f9ee..98cd761 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,72 @@ -#include +#include #include +#include + +#define WINDOW_WIDTH 640 +#define WINDOW_HEIGHT 480 + +float verts[] = { + -0.5f, -0.5f, 0.0f, + 0.5f, -0.5f, 0.0f, + 0.0f, 0.5f, 0.0f +}; + +void framebuffer_size_callback(GLFWwindow* win, int w, int h) { + glViewport(0, 0, w, h); +} + +void processInput(GLFWwindow *win) { + int action = glfwGetKey(win, GLFW_KEY_ESCAPE); + if (action == GLFW_PRESS) { + glfwSetWindowShouldClose(win, true); + } +} + +void renderCallback(GLFWwindow *win) { + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + unsigned int VBO; + glGenBuffers(1, &VBO); + + glBindBuffer(GL_ARRAY_BUFFER, VBO); +} int main() { + glfwInit(); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + + GLFWwindow* win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Hohmann", NULL, NULL); + if (win == NULL) { + printf("Failed to create a window."); + glfwTerminate(); + return 1; + } + + glfwMakeContextCurrent(win); + + if ( !gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) ) { + printf("Failed to init GLAD."); + return 1; + } + + glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); + glfwSetFramebufferSizeCallback(win, framebuffer_size_callback); + + while (!glfwWindowShouldClose(win)) { + // Handle input + processInput(win); + + // rendering + renderCallback(win); + + // glfw + glfwSwapBuffers(win); + glfwPollEvents(); + } + + glfwTerminate(); return 0; }