@ -25,39 +25,41 @@ GLFW.
#include <GLFW/glfw3.h>
#include <GLFW/glfw3.h>
@endcode
@endcode
This header declares the GLFW API and by default also includes the OpenGL header
This header defines all the constants and declares all the types and function
from your development environment. See below for how to control this.
prototypes of the GLFW API. By default it also includes the OpenGL header from
your development environment. See [option macros](@ref build_macros) below for
how to select OpenGL ES headers and more.
The GLFW header also defines any platform-specific macros needed by your OpenGL
The GLFW header also defines any platform-specific macros needed by your OpenGL
header, so it can be included without needing any window system headers.
header, so that it can be included without needing any window system headers.
For example, under Windows you are normally required to include `windows.h`
It does this only when needed, so if window system headers are included, the
before the OpenGL header, which would bring in the whole Win32 API. The GLFW
GLFW header does not try to redefine those symbols. The reverse is not true,
header duplicates the small number of macros needed.
i.e. `windows.h` cannot cope if any Win32 symbols have already been defined.
It does this only when needed, so if `windows.h` _is_ included, the GLFW header
does not try to redefine those symbols. The reverse is not true, i.e.
`windows.h` cannot cope if any of its symbols have already been defined.
In other words:
In other words:
- Do _not_ include the OpenGL headers yourself, as GLFW does this for you
- Use the GLFW header to include OpenGL or OpenGL ES headers portably
- Do _not_ include `windows.h` or other platform-specific headers unless you
- Do not include window system headers unless you will use those APIs directly
plan on using those APIs directly
- If you do need such headers, include them before the GLFW header
- If you _do_ need to include such headers, do it _before_ including
the GLFW header and it will handle this
If you are using an OpenGL extension loading library such as
If you are using an OpenGL extension loading library such as
[glad](https://github.com/Dav1dde/glad), the extension loader header should
[glad](https://github.com/Dav1dde/glad), the extension loader header should
be included _before_ the GLFW one.
be included before the GLFW one. GLFW attempts to detect any OpenGL or OpenGL
ES header or extension loader header included before it and will then disable
the inclusion of the default OpenGL header. Most extension loaders also define
macros that disable similar headers below it.
@code
@code
#include <glad/gl.h>
#include <glad/gl.h>
#include <GLFW/glfw3.h>
#include <GLFW/glfw3.h>
@endcode
@endcode
Alternatively the @ref GLFW_INCLUDE_NONE macro (described below) can be used to
Both of these mechanisms depend on the extension loader header defining a known
prevent the GLFW header from including the OpenGL header.
macro. If yours doesn't or you don't know which one your users will pick, the
@ref GLFW_INCLUDE_NONE macro will explicitly to prevent the GLFW header from
including the OpenGL header. This will also allow you to include the two
headers in any order.
@code
@code
#define GLFW_INCLUDE_NONE
#define GLFW_INCLUDE_NONE
@ -113,7 +115,8 @@ __GLFW_INCLUDE_NONE__ makes the GLFW header not include any OpenGL or OpenGL ES
API header. This is useful in combination with an extension loading library.
API header. This is useful in combination with an extension loading library.
If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h`
If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h`
header (`OpenGL/gl.h` on macOS) is included.
header (`OpenGL/gl.h` on macOS) is included, unless GLFW detects the inclusion
guards of any OpenGL, OpenGL ES or extension loader header it knows about.
The following macros control the inclusion of additional API headers. Any
The following macros control the inclusion of additional API headers. Any
number of these may be defined simultaneously, and/or together with one of the
number of these may be defined simultaneously, and/or together with one of the