Game Development Reference
In-Depth Information
Using OpenGL inside SFML
Before we start using any of the OpenGL calls, we need to make sure that the graphics con-
text is initialized. The context holds the data (states, default framebuffer, and so on) which
allows OpenGL to function. This is done automatically when we create a window in-
stance:
To use any OpenGL calls, we need to include <SFML/OpenGL.hpp> . This is the com-
mon header file that SFML provides for us to use on all platforms. It is also important to
mention that we do not need to use the familiar RenderWindow class if we are going to
render everything using only OpenGL. The Window class will suite us just fine. On the
other hand, if we want to use OpenGL with the graphics module for some reason, then we
can go back to RenderWindow . In this example, we are only going to use the window
module, which holds the Window class.
Note that the window takes an instance of ContextSettings (an optional parameter).
We talked a little bit about this in Chapter 1 , Getting Started with SFML , but let's see what
these settings mean in more detail. The ContextSettings structure class has the fol-
lowing five fields that we can change.
Search WWH ::




Custom Search