layout | title | description |
---|---|---|
default |
Documentation |
GLFW API documentation. |
The HTML documentation contains both tutorials, guides for different topics and an API reference.
GLFW is under the zlib/libpng license, which permits modification, distribution and use in closed source software.
Below is a short example of setting up a window and OpenGL context with GLFW. There are many more functions than those used here. For a quick introduction to GLFW, see Getting started in the HTML documentation.
{% highlight c %} #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;
} {% endhighlight %}