Portable game and multimedia framework for Nit

gamnit is a modular framework to create portable 2D or 3D apps in Nit. It is based on the portability framework app.nit and the OpenGL ES 2.0 standard.

System configuration

To compile the gamnit apps packaged with the Nit repository on GNU/Linux you need to install the dev version of a few libraries and some tools. On Debian 8.2, this command should install everything needed:

apt-get install libgles2-mesa-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev inkscape

On Windows 64 bits, using msys2, you can install the required packages with:

pacman -S mingw-w64-x86_64-angleproject-git mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer

While macOS isn't supported, it can create iOS apps. You need to install and setup Xcode, and you may install the GLSL shader validation tool via brew:

brew install glslang

Services by submodules

gamnit is modular, different services of the framework are available through different submodules:

  • The main entrypoint gamnit provides low-level abstractions over some services of OpenGL ES 2.0, like textures, shaders and programs. It defines the basic methods to implement in order to obtain a working game: App::frame_core to update the screen and App::accept_event to receive user inputs.

  • flat provides an easy to use API for 2D games based on sprites. Clients of this API redefine App::update to update the game logic and fill lists of sprites with objects to draw.

    App::sprites lists the sprites of the game world, they are drawn form the point of view of the world_camera. This camera can be moved around in the world by updating the x and y of its position, and the zoom can easily be set using reset_depth(desired_world_units_on_y) or the z of its position

    App::ui_sprites lists the UI sprites drawn from the point of view of ui_camera. By default, this camera is pixel-perfect with the origin in the top left corner of the window. However to support screens with different DPI, it is recommended to standardize the display size using reset_depth(height_of_reference_display).

  • depth defines an API for 3D games based on instances of Actor.

    This framework is build upon flat, see the doc of this submodule first (just above). As such, clients should still implement update with the game logic, and fill ui_sprites for UI elements.

    At each frame, elements in the list actors are drawn to screen. Each Actor is composed of a Model and other information specific to this instance: position in the world, rotation and scaling.

  • limit_fps refines existing services of gamnit to limit the framerate to a customizable value.

  • keys provides app.pressed_keys keeping track of the currently pressed keys.

  • model_parsers provides services to read and parse models from the asset folder.

  • network provides a simple communication framework for multiplayer client/server games.

All groups and modules

module android19

gamnit :: android19

Variation using features from Android API 19
module bmfont

gamnit :: bmfont

Parse Angel Code BMFont format and draw text
module camera_control

gamnit :: camera_control

Simple camera control for user, as the method accept_scroll_and_zoom
module camera_control_android

gamnit :: camera_control_android

Two fingers camera manipulation, pinch to zoom and slide to scroll
module camera_control_linux

gamnit :: camera_control_linux

Mouse wheel and middle mouse button to control camera
module cameras

gamnit :: cameras

Camera services producing Model-View-Projection matrices
module cameras_cache

gamnit :: cameras_cache

Cache the Matrix produced by Camera::mvp_matrix
group depth

gamnit > depth

gamnit depth, a framework to create portable 3D games in Nit.
module display

gamnit :: display

Abstract display services
module display_android

gamnit :: display_android

Gamnit display implementation for Android
module display_ios

gamnit :: display_ios

Gamnit display implementation for iOS
module display_linux

gamnit :: display_linux

Gamnit display implementation for GNU/Linux using egl, sdl and x11
module dynamic_resolution

gamnit :: dynamic_resolution

Virtual screen with a resolution independent from the real screen
module egl

gamnit :: egl

Use of EGL to implement Gamnit on GNU/Linux and Android
group flat

gamnit > flat

Simple API for 2D games, built around Sprite and App::update
module font

gamnit :: font

Abstract font drawing services, implemented by bmfont and tileset
module gamnit

gamnit :: gamnit

Game and multimedia framework for Nit
module gamnit_android

gamnit :: gamnit_android

Support services for Gamnit on Android
module gamnit_ios

gamnit :: gamnit_ios

Support services for gamnit on iOS
module gamnit_linux

gamnit :: gamnit_linux

Support services for Gamnit on GNU/Linux
module input_ios

gamnit :: input_ios

Gamnit event support for iOS
module keys

gamnit :: keys

Simple service keeping track of which keys are currently pressed
module landscape

gamnit :: landscape

Lock the application in the landscape orientation
module limit_fps

gamnit :: limit_fps

Frame-rate control for applications
group network

gamnit > network

Easy client/server logic for games and simple distributed applications
module portrait

gamnit :: portrait

Lock the application in the portrait orientation
module programs

gamnit :: programs

Services for graphical programs with shaders, attributes and uniforms
module texture_atlas_parser

gamnit :: texture_atlas_parser

Tool to parse XML texture atlas and generated Nit code to access subtextures
module textures

gamnit :: textures

Load textures, create subtextures and manage their life-cycle
module tileset

gamnit :: tileset

Support for TileSet, TileSetFont and drawing text with TextSprites
group virtual_gamepad

gamnit > virtual_gamepad

Virtual gamepad mapped to keyboard keys for quick and dirty mobile support
package_diagram gamnit gamnit ...gamnit ... ...gamnit->gamnit android android android->gamnit app app app->android egl egl egl->android glesv2 glesv2 glesv2->android app... ... app...->app egl... ... egl...->egl glesv2... ... glesv2...->glesv2


package binary


Read and write binary data with any Reader and Writer
package c


Structures and services for compatibility with the C language
package cocoa


Cocoa API, the development layer of OS X
package curl


Data transfer powered by the native curl library
package gtk


GTK+ widgets and services
package java


Supporting services for the FFI with Java and to access Java libraries
package json


read and write JSON formatted text
package jvm


Java Virtual Machine invocation API and others services from the JNI C API
package meta


Simple user-defined meta-level to manipulate types of instances as object.
package pipeline


Pipelined filters and operations on iterators.
package poset


Pre order sets and partial order set (ie hierarchies)
package pthreads


POSIX Threads support
package serialization


Abstract serialization services
package sqlite3


Services to manipulate a Sqlite3 database
package template


Basic template system
package xdg_basedir


Services for using the XDG Base Directory specification


package android


Android platform support and APIs
package app


app.nit, a framework for portable applications
package core


Nit common library of core classes and methods
package dom


Easy XML DOM parser
package egl


Interface between rendering APIs (OpenGL, OpenGL ES, etc.) and the native windowing system.
package gen_nit


Support to generate and otherwise manipulate Nit code
package geometry


Basic geometry data structures and services.
package glesv2


OpenGL graphics rendering library for embedded systems, version 2.0
package ios


iOS support for app.nit
package linux


Implementation of app.nit for the Linux platform
package matrix


Services for matrices of Float values
package mnit


package more_collections


Highly specific, but useful, collections-related classes.
package msgpack


MessagePack, an efficient binary serialization format
package opts


Management of options on the command line
package parser_base


Simple base for hand-made parsers of all kinds
package performance_analysis


Services to gather information on the performance of events by categories
package realtime


Services to keep time of the wall clock time
package sdl2


This is a low-level wrapper of the SDL 2.0 library (as sdl2) and SDL_image 2.0 (as sdl2::image).
package socket


Socket services


package android


Android platform support and APIs


package app


app.nit, a framework for portable applications
package egl


Interface between rendering APIs (OpenGL, OpenGL ES, etc.) and the native windowing system.
package glesv2


OpenGL graphics rendering library for embedded systems, version 2.0
package ios


iOS support for app.nit
package linux


Implementation of app.nit for the Linux platform