Book Image

Mastering SFML Game Development

By : Raimondas Pupius
Book Image

Mastering SFML Game Development

By: Raimondas Pupius

Overview of this book

SFML is a cross-platform software development library written in C++ with bindings available for many programming languages. It provides a simple interface to the various components of your PC, to ease the development of games and multimedia applications. This book will help you become an expert of SFML by using all of its features to its full potential. It begins by going over some of the foundational code necessary in order to make our RPG project run. By the end of chapter 3, we will have successfully picked up and deployed a fast and efficient particle system that makes the game look much more ‘alive’. Throughout the next couple of chapters, you will be successfully editing the game maps with ease, all thanks to the custom tools we’re going to be building. From this point on, it’s all about making the game look good. After being introduced to the use of shaders and raw OpenGL, you will be guided through implementing dynamic scene lighting, the use of normal and specular maps, and dynamic soft shadows. However, no project is complete without being optimized first. The very last chapter will wrap up our project by making it lightning fast and efficient.
Table of Contents (17 chapters)
Mastering SFML Game Development
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Multi-pass shading


Much like C/C++ code, GLSL does support the use of data arrays. Using them can seem like an obvious choice to just push information about multiple light streams into the shader and have it all done in one pass. Unlike C++, however, GLSL needs to know the sizes of these arrays at compile time, which is very much like C. At the time of writing, dynamic size arrays aren't supported. While this information can put a damper on a naive plan of handling multiple light sources with ease, there are still options to choose from, obviously.

One approach to combat this may be to have a very large, statically sized array of data. Only some of that data would be filled in and the shader would process it by looping over the array while using a uniform integer that tells it how many lights were actually passed to it. This idea comes with a few obvious bottlenecks. First, there would be a threshold for the maximum number of light streams allowed on the screen. The second issue is performance...