Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn OpenGL

You're reading from   Learn OpenGL Beginner's guide to 3D rendering and game development with OpenGL and C++

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789340365
Length 208 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Frahaan Hussain Frahaan Hussain
Author Profile Icon Frahaan Hussain
Frahaan Hussain
Arrow right icon
View More author details
Toc

Setting up OpenGL using SFML on Windows

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.

Downloading the SFML library

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.

Linking the SFML and GLEW libraries to the project

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.

Adding a DLL file to the project

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.

You have been reading a chapter from
Learn OpenGL
Published in: Aug 2018
Publisher: Packt
ISBN-13: 9781789340365
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime