#include #include #include void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); glColor3f(1.0, 0.0, 0.0); glVertex2f(-0.5, -0.5); glColor3f(0.0, 1.0, 0.0); glVertex2f(0.5, -0.5); glColor3f(0.0, 0.0, 1.0); glVertex2f(0.0, 0.5); glEnd(); glFlush(); } /*void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); }*/ void processInput(GLFWwindow *window) { if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); } int main(int argc, char** argv) { GLFWwindow* window; if (!glfwInit()) return -1; window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); if (!window) { glfwTerminate(); return -1; } glfwMakeContextCurrent(window); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW error: %s\n", glewGetErrorString(err)); return 1; } glViewport(0, 0, 800, 600); while (!glfwWindowShouldClose(window)) { processInput(window); /* Render here */ glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); /* Poll for and process events */ glfwPollEvents(); glfwSwapBuffers(window); } glfwTerminate(); }