Click here to Skip to main content
15,867,308 members
Articles / Programming Languages / C++

Kigs Framework Introduction (1/8)

Rate me:
Please Sign up or sign in to vote.
4.58/5 (19 votes)
1 Mar 2023MIT6 min read 105K   37   19
A multi purpose, cross-platform, free and Open Source C++ framework
Kigs framework a lightweight, fast, scalable framework that was ported to different platforms. Kigs is a basement framework for rapid application development and for educational / experimental development. We used it as a base to build professional projects from Nintendo DSi games to industrial robots simulator. This entry is a basic introduction of the series which will go over: Core Features, Prerequisites, Creating a new project, and how to build and run the new project.

Kigs Logo

Table of Contents

Introduction

Kigs is a basement framework for rapid application development. It gives access to high-level architecture and functionalities ( modules, serialization, reflection, instances factory, upgradors, aggregates... ) while maintaining low-level control (optimizations, platform-specific customization, easy C/C++ extern libraries usage ...).

Today, it is possible to develop 2D or 3D mobile applications, multi-platform games ... quite simply thanks to commercial (Unreal, Unity ...) or open source (OpenSceneGraph, Ogre3D ...) 3D engines.

These engines obviously have all their advantages, but also their disadvantages:

  • Some are not free.
  • Some are black boxes and you only have access to exposed functionality.
  • Some are very scene graph/rendering oriented and not really multi-purpose.

We developed the Kigs framework because we wanted a lightweight, fast, scalable framework that we could port to different platforms (that's why we used C++, available on almost all platforms), and we could use as a basement to build all our projects from Nintendo DSi games:

Rollway Puzzle

to industrial robots simulator (have a look here: https://kigs-framework.org/Projects). We also wanted to remain totally independent, and keep full control over all our projects code.

We decided some weeks ago to open source (MIT license) the main modules of our framework for Windows (x86, x64, for OpenGL and D3D, WUP D3D), and HTML5/Web Assembly (Emscripten) platforms. A functional (not anymore, we did not had the time to maintain it, and would be happy to get some help for this) Android version and an unmaintained iOS version are now also available. Here is the GitHub repository:

What's new ?

We spent some times during the last few months to refactor the framework:

  • Removed some useless/buggy/deprecated code (There are probably some left !).
  • Added some namespaces: Kigs as a general one, then one for each module.
  • Added a new way to manage CoreModifiable attributes (mapping existing member variables).
  • Used more modern C++ to manage attributes (less copy/paste code).
  • ...

  •  

Why Use the Kigs Framework?

  • You are a C++ developer and want to have access to high-level functionality such as serialization, instance factory, signals/slots management, scenegraph/rendering, Lua scripting ...
  • You want to learn game development using C++ and Lua scripting.
  • You want to experiment with new ideas without starting from scratch.
  • You are curious to see how we implemented this or that feature and perhaps want to help improve the framework.

We would be happy if others take over our framework, improve it and adapt it to their desires and their needs.

General Architecture

The Kigs framework is divided into different modules, each grouping functionalities in a particular domain (Input, Rendering, GUI...). There are two main module types: Generic and Specific.

Generic Modules

A generic module defines API/SDK/System independent classes, and/or base classes (interface) for API/SDK/System dependent classes.

Specific Modules

Of course, specific modules do the exact opposite: they define API/SDK/System dependent classes, often inheriting from generic classes.

Base Modules

The main modules are Core, FileManager, Timer, XML. Then Input (with specific InputWindows, InputWUP...), GUI (GuiWindows, GUIWUP...), SceneGraph, Renderer (RendererOpenGL3, RendererDirectX11)...

Core Features

Core features are mainly supported by KigsCore and CoreModifiable classes.

Instance Factory

Classes with CoreModifiable inheritance can be registered to instance factory. Ask KigsCore to create a new instance of the wanted class is then easy:

C++
// Ask for an instance of class Timer called "localtimer" 
CMSP localtimer = KigsCore::GetInstanceOf("localtimer", "Timer");

Here localtimer is returned as a CMSP (CoreModifiable SmartPointer). If no more reference are retained, the localtimer instance will be deleted when code exits localtimer scope.

CoreModifiable Trees

CoreModifiable instances can be organized in parent/sons trees like this:

C++
// add localtimer instance to this (this must inherit CoreModifiable too of course)
addItem(localtimer);

addItem adds a reference to the reference count of the instance. localtimer instance will be destroyed when its references count reach 0, so in our case when parent class is destroyed.

CoreModifiable should be initialized before use:

C++
// init localtimer (timer is started)
localtimer->Init();

Then localtimer can then be retrieved in another part of the code with different kind of research functions:

C++
// search son with given name
Timer* localtimer=GetFirstSonByName("Timer", "localtimer")->as<Timer>();

or:

C++
// search first instance found with given name
CMSP localtimer = GetFirstInstanceByName("Timer", "localtimer");

All instances of a given type can also be retrieved in one call:

C++
// search all instances of Timer
std::vector<CMSP> alltimers = GetInstances("Timer");

CoreModifiable Attributes

CoreModifiable can have "compile-time" attributes that can be get or set by their names:

C++
// retrieve "Sample1Value" value on this
int _value;
testInstance->getValue("Sample1Value", _value);
_value = 4 * _value - 12;
// change "Sample1Value" value with _value
testInstance->setValue("Sample1Value",  _value);

Attributes can also be added or removed at runtime:

C++
// add a dynamic attribute on instance of localtimer
localtimer->AddDynamicAttribute(ATTRIBUTE_TYPE::FLOAT, "floatValue", 12.0f);
// retrieve dynamic attribute value on localtimer
float timervalue=localtimer->getValue<float>("floatValue");
// set dynamic float attribute with string
localtimer->setValue("floatValue","24");

Serialization

CoreModifiable trees with all their attributes can be exported in XML files:

C++
// export this and its sons in "Sample1.xml" file
CoreModifiable::Export("Sample1.xml", this, true);

And of course, import CoreModifiable trees from an XML file is also possible:

C++
// import instances from file "Sample1.xml"
CMSP imported=CoreModifiable::Import("Sample1.xml");

CoreModifiable Methods

Methods can be added to CoreModifiable and then accessed at runtime only by their names (without knowing the exact type of the instance the method is called on).

The easy way to call such a method is:

C++
// call SimpleSampleClass AddValue method directly on CoreModifiable
float result = simpleclass->SimpleCall<float>("AddValue", 10, 12.0f);
printf("result of calling AddValue = %f\n", result);

Find all the sample code from this introduction in the "Sample1" project on GitHub (browse the code).

Getting Started

Prerequisites

We will focus on the main development platform we have used: Windows.

Our scripts need Visual Studio C++ 2022 (Community edition is OK).

A recent version of CMake (3.15.5 is set up in our case).

Creating a New Project

After cloning the repository, go to the kigs\projects folder.

Launch one of the two present scripts: CreateNewConsoleProject.vbs (for a command-line type project) or CreateNewDDProject.vbs (for a graphical data-driven project).

Enter a name for the project: a new folder with this name will be created. For example "SimpleTest" and press OK.

Now open "kigs\projects\CMakeLists.txt" file in a text editor and add the line:

C++
add_subdirectory(MyProjectName)

replacing "MyProjectName" by the name of the project (SimpleTest in our example).

Save and close "CMakeLists.txt" file.

Then go to kigs\scripts folder and launch one of the following scripts:

  • generateWinCMake.bat for a win32 (opengl) application
  • generateWinCMake64.bat for a win64 (opengl) application
  • generateWinD3DCMake.bat for a win32 (D3D) application
  • generateWinD3DCMake64.bat for a win64 (D3D) application
  • generateWUPD3DCMake.bat for a Universal Windows Platform D3D application (only for graphical data driven project)

A new Build\[solutionType] folder is created at the same level as kigs folder.

Build and Run the New Project

Browse in this folder to reach Build\[solutionType]\kigs\projects\"MyProjectName" and choose "MyProjectName".sln to open it in Visual Studio.

Once the solution is loaded in Visual Studio, set "MyProjectName" as your startup project, choose the build configuration you want: StaticDebug (for a compilation with full debug info), StaticReleaseTools (for a compilation with optimization, but keeping all the export functionalities), StaticRelease (for full optimization but no export functionality).

Build, launch. That's it!

What's Next

In the next articles of this series, we will explore the advanced features of the framework:

  • CoreModifiable class details
  • CoreModifiable attributes
  • CoreModifiable methods
  • CoreItem
  • Signal / slot / notification
  • Lua binding
  • Data-driven application
  • ...

Already Published in this Series

  1. Kigs Framework Introduction (1/8) - Overview
  2. Kigs Framework Introduction (2/8) - CoreModifiable
  3. Kigs Framework Introduction (3/8) - Attributes
  4. Kigs Framework Introduction (4/8) - Methods
  5. Kigs Framework Introduction (5/8) - CoreItem
  6. Kigs Framework Introduction (6/8) - Signal, Slot, Notification
  7. Kigs Framework Introduction (7/8) - Lua Binding
  8. Kigs Framework Introduction (8/8) - Data Driven Application

History

  • 24th January, 2020: Initial version
  • 29th January, 2020: Added Table of Contents
  • 1st February, 2020: Added Already Published in this Series
  • 7th February, 2020: Article (3/8) added to the series
  • 8th February, 2020: Added screenshot from Rollway Puzzle and fixed link to Projects page
  • 14th February, 2020: Article (4/8) added to the series
  • 21st February, 2020: Article (5/8) added to the series and small bug fix in code
  • 2nd March, 2020: Article (6/8) added to the series
  • 6th March, 2020: New Android/iOS platforms released and article (7/8) added to the series
  • 19th March, 2020: all GetInstances methods now returns CMSP or std::vector<CMSP> 
  • 1st May, 2020 : GitHub repository moved.
  • 17th June, 2020 : Added final article of the series 
  • 19th June, 2020 : Changed introduction to make it clearer 
  • 1st March, 2023 : Update articles after framework refactory.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior) LVCim
France France
Senior software developer.
Kigs framework is an educational/experimental/RAD open source C++ framework.

Comments and Discussions

 
QuestionNeeds a rewrite Pin
john morrison leon6-Mar-23 0:42
john morrison leon6-Mar-23 0:42 
AnswerRe: Needs a rewrite Pin
Stephane Capo6-Mar-23 2:57
professionalStephane Capo6-Mar-23 2:57 
QuestionWhat problem are you solving? Pin
charlieg17-Jun-20 12:52
charlieg17-Jun-20 12:52 
AnswerRe: What problem are you solving? Pin
Stephane Capo17-Jun-20 21:28
professionalStephane Capo17-Jun-20 21:28 
GeneralRe: What problem are you solving? Pin
Asday18-Jun-20 1:52
Asday18-Jun-20 1:52 
GeneralRe: What problem are you solving? Pin
Stephane Capo18-Jun-20 2:16
professionalStephane Capo18-Jun-20 2:16 
GeneralRe: What problem are you solving? Pin
Asday18-Jun-20 3:24
Asday18-Jun-20 3:24 
GeneralRe: What problem are you solving? Pin
Stephane Capo18-Jun-20 3:58
professionalStephane Capo18-Jun-20 3:58 
GeneralRe: What problem are you solving? Pin
charlieg26-Jun-20 5:53
charlieg26-Jun-20 5:53 
GeneralRe: What problem are you solving? Pin
Stephane Capo6-Jul-20 0:06
professionalStephane Capo6-Jul-20 0:06 
GeneralMy vote of 5 Pin
FenderBaba20-Mar-20 22:36
FenderBaba20-Mar-20 22:36 
Questionthis is not multi-platform open-source free when it's only for Windows and SPA ! Pin
BillWoodruff3-Mar-20 7:53
professionalBillWoodruff3-Mar-20 7:53 
AnswerRe: this is not multi-platform open-source free when it's only for Windows and SPA ! Pin
Stephane Capo3-Mar-20 21:31
professionalStephane Capo3-Mar-20 21:31 
GeneralRe: this is not multi-platform open-source free when it's only for Windows and SPA ! Pin
BillWoodruff4-Mar-20 3:52
professionalBillWoodruff4-Mar-20 3:52 
GeneralRe: this is not multi-platform open-source free when it's only for Windows and SPA ! Pin
Stephane Capo4-Mar-20 4:15
professionalStephane Capo4-Mar-20 4:15 
PraiseMy vote of 5 Pin
Guirec14-Feb-20 5:10
professionalGuirec14-Feb-20 5:10 
GeneralRe: My vote of 5 Pin
Stephane Capo14-Feb-20 7:28
professionalStephane Capo14-Feb-20 7:28 
GeneralMy vote of 4 Pin
KarstenK28-Jan-20 22:11
mveKarstenK28-Jan-20 22:11 
GeneralRe: My vote of 4 Pin
Stephane Capo28-Jan-20 23:33
professionalStephane Capo28-Jan-20 23:33 
Thanks,

the article should be updated soon.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.