Exploring SFML Graphics in C++ – Refactoring Wave 1

The previous article, Exploring SFML Graphics in C++, covered a basic window and input demo using C++98 and the SFML Library. That demo was a small, concise exploration of graphics concepts using SFML but was hardly shaped for a more structured software project. That article concluded with a visual roadmap of how a more structured solution may be defined. We presented a new structure in a UML diagram. After pursuing a new structure in C++11 using both the SFML demo code and the diagram as an initial guide, we have a refined version.

First, lets look the project at a glance. Below are screenshots that show all the files organized within the Code::Blocks IDE. We have C++ header and implementation files that together realizes a working solution. This solution is a mapping of SFML capabilities to an application level framework for generic visual interfaces. We have essentially refactored the demo code into a new structure that will be more easily reviewed, modified, and reused.

Listing of Header Files in Code::Blocks

Listing of Implementation Files in Code::Blocks


Next, comes the full text of the header and source files. They are listed in links as there is a sizable amount of text in aggregate. The next article on this subject will cover the individual files in detail in a version that is more fully developed.

Software Code Listing

The code is divided into the main program and the application level framework.

Gautier SFML Program

The program starts in the main function which references the program implementation. The program implementation is in a class called Program declared in program.h and defined in program.cpp.

Visual Common

Many of the common types for the management of visual mechanisms and geometric types are aliased or declared in the visualcommon.h header file. A small extract of this file is as follows:

Gautier SFML App Framework

The application framework is the initial beginnings of a reusable means to apply the SFML library to efforts targeting general application building. It contains a regular structure that intends to be both practical and holding cyclomatic complexity in balance. The framework emphasizes stack based allocation while striving to reduce the appearance of heap oriented structures or underlying framework mechanisms for a cleaner interface. In a subsequent iteration, virtual functions may have to be introduced to allow the processing of dynamic UI views.

All other code files are listed with links to their contents :

RangeQuad has only a header declaration of C++ templates with no definition needed at this time.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s