Created
June 21, 2017 15:50
-
-
Save tai2/2aab96c3c2b714926a5471b4b9d2fbe5 to your computer and use it in GitHub Desktop.
GLFW template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc hello_opengl.c -o hello_opengl -lglfw -framework OpenGL | |
#include <GLFW/glfw3.h> | |
int main(void) | |
{ | |
GLFWwindow* window; | |
/* Initialize the library */ | |
if (!glfwInit()) | |
return -1; | |
/* Create a windowed mode window and its OpenGL context */ | |
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); | |
if (!window) | |
{ | |
glfwTerminate(); | |
return -1; | |
} | |
/* Make the window's context current */ | |
glfwMakeContextCurrent(window); | |
/* Loop until the user closes the window */ | |
while (!glfwWindowShouldClose(window)) | |
{ | |
/* Render here */ | |
glClear(GL_COLOR_BUFFER_BIT); | |
/* Swap front and back buffers */ | |
glfwSwapBuffers(window); | |
/* Poll for and process events */ | |
glfwPollEvents(); | |
} | |
glfwTerminate(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment