This is part of a series of articles looking at the SFML library in C++. The previous article, Exploring SFML Graphics in C++ – Refactoring Wave 1, showed how we take exploratory code shown in the article, Exploring SFML Graphics in C++, and improve the structure of that code. This article focuses on the organization of the code into folders within the CodeBlocks IDE. This change does not affect how the code is stored on the computer but how it is represented in the code editor. The following is a listing of where files are placed in the code editor, changes to the project configurations, and test of the code at the end.
SFML App Framework
The previous version had the user interface test code and the framework in one project. The goal however is to have a workable application level framework contains common processes in application level user interface operations. I have separated the user interface program into the SFMLEvalProgram project shown in the screen shot below. The SFMLApp_v1 project which contains the common user interface framework. This framework has sub folders for the major areas of the framework.
Generic concepts of size and position.
Interaction Device Fundamentals
Generic concepts of windows, keyboards, mice, and peripherals containing the current disposition of those things.
Maps the software application to the data in MVC Models produced by entities in Interaction Device Fundamentals.
Contains models specific to device peripherals in the context of a event loop based graphical window.
Implementation of core visualization functions that represent information and operations visually.
Structure of Visual Software Programs
The framework in SFMLApp_v1 is a means to structure functionality needed in a software program. SFML itself already has the functionality. The goal here is to adapt SFML in such a way as to influence the way a software program that is based on it is designed. I have the beginnings of an example program that will validate the framework I have defined and shape how that framework is structured and function.
I could have defined a program directly in terms of SFML which I did in the article, Exploring SFML Graphics in C++. What I have done here however is de-couple some details of SFML from the software application by concentrating the majority of the accesses to the SFML library into a set of codes (a library) separate from the software application. I have encapsulated SFML but not entirely as I directly access certain elements of SFML from the software application.
The project for the evaluation software program is shown below. This program is a scaffold to serve as a test harness for the framework and define an approach for building software programs using the framework. I am creating an immediate feedback loop that will allow me to iterate on the code in such a way as to improve both mechanisms. This is my informal method I have used over 15 years that begins with a Waterfall based approach shown in the article, Exploring SFML Graphics in C++ – Refactoring Wave 1, and then drifts into a somewhat basic form of an Agile based approach with a greater emphasizes on the iteration build model. It is an approach that draws from multiple methodologies and perspectives to produce an effective solution.
As shown below we have a few areas of focus. The Program folder contains the starting point of the software. The main.cpp module contains code that conforms to the systems model of having a main method. Java, C#, .NET, C, all of them require compliance with this model in some way. An desirable practice is to minimize what runs in the main method and incorporate a majority of start-up and fundamental execution requirements in an class. I have done this by creating a type named program that defines the overall domain execution model of the software.
Parameters that conform the program to operational criteria are centralized within a configuration process. The initial concepts of a configuration system is listed below in types defined under the ProgramConfiguration folder.
Each screen will be defined as a view. One of the goals is to have a view operate according to data presented through an MVC Model. While the software is presently oriented towards models defined in the framework I am defining, the views are not limited to a single model. As well, the views may produce and contribute to a model pipeline consisting of graphic outputs for the main program module to interpret and forward to SFML for display.
SFML Application Framework Library
I have adjusted the framework output from a graphic program to a static library.
The new evaluation program project now has a output type of GUI application under CodeBlocks.
Link In SFML
I had to tweak the project to refer to the SFML libraries installed on the system under Xubuntu.
Headers from the Application Framework
I added the framework’s file path to the application configuration for resolving dependencies.
Link In the Application Framework (Debug)
The library output for the framework is linked into the application linker input. I have an entry corresponding to the debug configuration.
Link In the Application Framework (Release)
The library output for the framework is linked into the application linker input. I have an entry corresponding to the release configuration.
Test All of This
The important thing at the end of the day is does this work. I have run a test to verify that all the changes work to produce a result. After this, the next goal will be to incorporate the keyboard functionality demonstrated in the original article, Exploring SFML Graphics in C++. In order to do that well, I am going to create a design for views that will result in a view containing a form field. Once that is done, I will have evolved this work into a more productive direction.
- Exploring SFML Graphics in C++
- Exploring SFML Graphics in C++ – Refactoring Wave 1 | Gautier Talks Technology
- Exploring SFML Graphics in C++ – Refactoring Wave 2 | Gautier Talks Technology
- Exploring SFML Graphics in C++ – Refactoring Wave 3 | Gautier Talks Technology
- Exploring SFML Graphics in C++ – Refactoring Wave 4 | Gautier Talks Technology
- Exploring SFML Graphics in C++ – Refactoring Wave 5 | Gautier Talks Technology