From 3f0221ccc0672c6fe30ca14a40eb874f6d3cbd83 Mon Sep 17 00:00:00 2001
From: Camilla Berglund Welcome to version 2.7 Lite of the GLFW OpenGL framework. GLFW is
-a free, open source, portable framework for OpenGL application development. In
-short, it is a library that constitutes a powerful API for handling operating
-system specific tasks, such as opening an OpenGL window, reading keyboard and
-mouse input, and more. Welcome to version 3.0 of the GLFW library. GLFW is a free, open source,
+portable library for OpenGL application development. It provides a powerful
+API for handling operating system specific tasks, such as opening an OpenGL
+window, reading keyboard, mouse, joystick and time input, and more. Please note that this is the Lite version of GLFW, which
-means that some areas of functionality present in 2.x mainline versions of GLFW
-have been removed. This is an experimental series intended to allow the new API to
+settle. Note that the threading and image loading APIs from the 2.x
+series have been removed. To compile GLFW and the accompanying example programs, you will need the CMake build system. To compile GLFW and the accompanying example programs, you will need the
+CMake build system. A rudimentary installation target is provided for all supported platforms
via the CMake build system. For Unix-like platforms, the command is:GLFW 2.7 Lite
+GLFW 3.0 source distribution
-
-
+
1. Introduction
-2. Compiling GLFW and the example programs
-3. Installing GLFW
$ make install
Note that you may need to run this command as root or via
-sudo(1)
in order to install GLFW into the various system
-directories.
For Visual C++ and other integrated development environments, an installation -target should appear in the by CMake generated project files.
- - +There are two aspects to using GLFW: +
There are two aspects to using GLFW:
-
The first point is covered in the GLFW -Users Guide and the GLFW Reference -Manual, and we suggest that you read at least the Users Guide, since -it's a good introduction to the GLFW API.
+The first point is covered in the +GLFW Users Guide and the +GLFW Reference Manual, and we suggest +that you read at least the Users Guide, since it's a good introduction to the +GLFW API.
Designing and compiling programs that use GLFW is not very difficult. A few rules for successfully designing GLFW-based programs are presented in the following sections.
-GL/glfw.h
In your program, you should include GL/glfw.h
like this:
In the files of your program where you use OpenGL or GLFW, you should
+include the GL/glfw.h
header file, i.e.:
#include <GL/glfw.h>+
#include <GL/glfw.h>
-This include file defines all the necessary constants, types and prototypes
-that are used to interact with the GLFW API. It also includes
- This defines all the constants, types and function prototypes of the GLFW
+API. It also includes the For instance, under Windows you are normally required to include
- For example, under Microsoft Windows you are normally required to include
+ In other words:
GL/gl.h
and GL/glu.h
, and - it defines all the
-necessary constants and types that are necessary for OpenGL to work on
+gl.h
and GL/glu.h header
+files, and - this is very important - it defines all the necessary
+constants and types that are necessary for the OpenGL headers to work on
different platforms.windows.h
before you include GL/gl.h
. If you write
-such a program, it would not compile under e.g. Linux since
-windows.h
does not exist under Linux. GL/glfw.h
-takes care of these things for you. Note however that it does not actually
-include windows.h
, it merely mimics the parts of it that are
-needed for GL/gl.h
and GL/glu.h
(this way we do not
-get the thousands of constants, types and prototypes that could otherwise
-possibly interfere with our own declarations).windows.h
before you include GL/gl.h
. This would
+however make your code dependent on the Windows platform, or at least require
+your program to check which platform it is being compiled on.
+
+The GLFW header file takes care of this for you, not by including
+windows.h
, but rather by itself duplicating the necessary parts of
+it. This way, the namespace won't be cluttered by the entire Windows API.
GL/gl.h
or GL/glu.h
- (GLFW does it for you)windows.h
unless you need
- to write Win32-specific codewindows.h
unless you actually need
+ direct access to the Windows APIwindows.h
, do it
- before including GL/glfw.h
.GL/glfw.h
and the GLFW header will
+ detect this.
Also note that if you are using an OpenGL extension loading library such as
+GLEW, you should include the GLEW
+header before the GLFW one. The GLEW header defines macros that
+disable any gl.h
that the GLFW header includes and GLEW will work
+as expected.
When linking a program under Windows that uses the static version of GLFW,
you must also link with the following libraries: opengl32
,
-user32
and kernel32
. Some of these libraries may be
+user32
and kernel32
. Some of these libraries may be
linked with by default by your compiler. In the table below you can see the
minimum required link options for each supported Windows compiler (you may want
to add other libraries as well, such as glu32
):