Skip to content

wiimag/framework

Repository files navigation

Application Framework

C/C++ Application Frameowork for Windows, MacOS, and Linux.

This is a framework for building cross-platform applications in C/C++ which provide a common set of features and tools to build applications with. It is designed to be used as a submodule in other projects.

The framework is designed to be as lite and efficient as possible. It uses Dear ImGui and bgfx to render the UI and graphics. Most of the cross platform code is written in C/C++ and uses foundation_lib for the common platform code and basic structures.

On top of these libraries, the framework provides a set of common tools and features to build applications with. These include:

  • A common application framework with a common set of features and tools.
  • A built-in console for logging and debugging.
  • A built-in profiler for performance analysis.
  • A built-in test runner to run unit and integration tests.
  • A localization system to support multiple languages.
  • A minimal document model system to render tabs, windows, and documents.
  • Extensions on top of imgui and glfw to provide a common set of UI widgets and controls.
  • Some concurrent data structures and algorithms.

Requirements

I also recommend using Visual Studio Code as an editor to modify CMakelists.txt files, bash scripts, etc.

Windows

MacOS (OSX)

Using

Getting Started

Clone the repository

git clone git@github.com:Infineis/framework.git <app_name>

Edit build settings

Edit the config/build.settings file to set the application name, version, etc.

Edit sources

Then you usually want to start editing sources under sources/. As a starting point, you can edit the example.cpp file to get a feel for how the framework works.

Basically, you need to have a cpp file that implements minimally the following functions:

  • app_title - Returns the application title.
  • app_exception_handler - Defines how the application handles crashes.
  • app_configure - Defines how the application and foundation is configured.
  • app_initialize - Defines how the application is initialized (i.e. initialize services and modules once, etc).
  • app_shutdown - Defines how the application is finalized (i.e. shutdown services and modules once, etc).
  • app_update - Defines how the application is updated prior to render each frames.
  • app_render - Defines how the application is rendered each frame.
  • app_render_3rdparty_libs - Entry point to render additional 3rd party libraries used for your specific application.

Build and run

Then you can build and run the application using the ./run script.

./run generate build debug start --verbose --console

Getting confident

Once you are more confident with the framework, you can rename the example.cpp file to something more appropriate for your application and start adding your own code as module, etc...

You can also edit the sources/CMakelists.txt file to add your own modules, customine the build, etc...

Remember to re-generate the solution after editing the sources/CMakelists.txt file.

./run generate

Documentation

You can find more documentation about the application framework under docs

Run Command (./run --help)

Generate Solution

./run generate

The solution will be generated in the projects/.build folder.

Note that currently the ./run scripts only supports the Visual Studio 2022 generator on Windows and the Xcode generator on MacOS. If you want to use another generator, you will have to use cmake directly. Here's a few examples for older versions of Visual Studio:

Visual Studio 2019

cmake --no-warn-unused-cli -DBUILD_MAX_JOB_THREADS=4 -DBUILD_MAX_QUERY_THREADS=8 -S./ -B./projects/.build -G "Visual Studio 16 2019" -A x64

Xcode

cmake --no-warn-unused-cli -DBUILD_MAX_JOB_THREADS=4 -DBUILD_MAX_QUERY_THREADS=4 -S./ -B./projects/.build -G "Xcode"

Build Solution (In Release)

./run build

In case the ./run script doesn't work, you can also use cmake directly:

cmake --build ./projects/.build --config Release --target wallet -j 10

Build Solution In Debug

./run build debug

Build Solution and Run Tests

./run build tests

You can also simply run test when the solution is already built

./run tests --verbose --bgfx-ignore-logs

Or simply run the solution (if already built)

./run --console --log-debug

Open Solution Workspace

./run generate open workspace

Build Distribution Package

You can build an installation package on Windows using the ./scripts/build-package.sh scripts or simply by running the following command:

./run package

Batch it all!

./run generate build release tests open workspace start --verbose --console

This will generate the solution, build it, run the tests, open the workspace, and start the application (or course if everything went well!).