In this section, we'll study how to set up OpenGL using SFML and GLEW on a Windows machine. But, first, let's understand what SFML is. SFML is a simple and fast multimedia library. It's a software development library designed for cross-platform use to provide a programming interface for various multimedia components on the system. It allows you to do stuff like handle or render windows, so we can draw our OpenGL and handle events, such as various inputs, and it also allows us to handle textures.
Let's download the SFML library onto your system by visiting https://www.sfml-dev.org/index.php. Then, go to Download
, click on SFML 2.5.0
, and then select whichever Visual C++ version matches your Visual Studio version and system compatibility, and accordingly click on the link. The file will be downloaded as a ZIP file onto your system. Next, go to the OpenGL
folder (which we created in the previous sections) and inside it, create a folder called SFML
to extract and place our SFML files.
The steps to link the SFML and GLEW libraries to our project with absolute or relative linking are similar to what we discussed in the previous sections. The only difference will be in the step where we link up the .lib
files. For that, go to Additional Dependencies
and in the textbox, just type in opengl32.lib
. Then, we'll type glew32s.lib
. And to link SFML libraries, we'll type sfml-graphics.lib
, sfml-system.lib
, and sfml-window.lib
, and then click on OK
.
As seen in the previous sections, before we begin with coding, we need to place the dynamic link library into our project. To do that, go to C:\OpenGL\SFML\bin\
and copy sfml-graphics-2.dll
, sfml-system-2.dll
, and sfml-window-2.dll
, and paste them into the location in your system where the main.cpp
file of your project is located. We'll also have to copy and paste the glew32.dll
file here from the bin
folder of the GLEW
folder.
With this, we are all set to code our OpenGL rendering window using SFML.