Game and multimedia framework for Nit

Redefined classes

redef class App

gamnit :: gamnit $ App

App subclasses are cross-platform applications
redef class Sys

gamnit :: gamnit $ Sys

The main class of the program.

All class definitions

redef class App

gamnit :: gamnit $ App

App subclasses are cross-platform applications
redef class Sys

gamnit :: gamnit $ Sys

The main class of the program.
package_diagram gamnit::gamnit gamnit app app gamnit::gamnit->app gamnit::textures textures gamnit::gamnit->gamnit::textures gamnit::programs programs gamnit::gamnit->gamnit::programs core core app->core serialization serialization app->serialization pthreads pthreads app->pthreads json json app->json android android app->android gamnit::display display gamnit::textures->gamnit::display gamnit::programs->gamnit::display matrix matrix gamnit::programs->matrix more_collections more_collections gamnit::programs->more_collections ...core ... ...core->core ...serialization ... ...serialization->serialization ...pthreads ... ...pthreads->pthreads ...json ... ...json->json ...android ... ...android->android ...gamnit::display ... ...gamnit::display->gamnit::display ...matrix ... ...matrix->matrix ...more_collections ... ...more_collections->more_collections gamnit::gamnit_android gamnit_android gamnit::gamnit_android->gamnit::gamnit gamnit::dynamic_resolution dynamic_resolution gamnit::dynamic_resolution->gamnit::gamnit gamnit::camera_control camera_control gamnit::camera_control->gamnit::gamnit gamnit::gamnit_linux gamnit_linux gamnit::gamnit_linux->gamnit::gamnit gamnit::gamnit_ios gamnit_ios gamnit::gamnit_ios->gamnit::gamnit gamnit::keys keys gamnit::keys->gamnit::gamnit gamnit::limit_fps limit_fps gamnit::limit_fps->gamnit::gamnit android::sensors sensors android::sensors->gamnit::gamnit_android gamnit::android19 android19 gamnit::android19->gamnit::gamnit_android gamnit::camera_control_android camera_control_android gamnit::camera_control_android->gamnit::gamnit_android gamnit::camera_control_android->gamnit::camera_control android::sensors... ... android::sensors...->android::sensors gamnit::android19... ... gamnit::android19...->gamnit::android19 gamnit::camera_control_android... ... gamnit::camera_control_android...->gamnit::camera_control_android gamnit::flat_core flat_core gamnit::flat_core->gamnit::dynamic_resolution gamnit::flat_core... ... gamnit::flat_core...->gamnit::flat_core gamnit::camera_control_linux camera_control_linux gamnit::camera_control_linux->gamnit::camera_control gamnit::camera_control_linux->gamnit::gamnit_linux gamnit::flat flat gamnit::flat->gamnit::camera_control gamnit::flat->gamnit::keys gamnit::flat->gamnit::limit_fps gamnit::camera_control_linux... ... gamnit::camera_control_linux...->gamnit::camera_control_linux gamnit::flat... ... gamnit::flat...->gamnit::flat gamnit::input_ios input_ios gamnit::input_ios->gamnit::gamnit_ios a_star-m a_star-m a_star-m->gamnit::gamnit_ios gamnit::input_ios... ... gamnit::input_ios...->gamnit::input_ios a_star-m... ... a_star-m...->a_star-m

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module app_base

app :: app_base

Base of the app.nit framework, defines App
module array

core :: array

This module introduces the standard array structure.
module assets

app :: assets

Portable services to load resources from the assets folder
module aware

android :: aware

Android compatibility module
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module c

c :: c

Structures and services for compatibility with the C language
module caching

serialization :: caching

Services for caching serialization engines
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module display

gamnit :: display

Abstract display services
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module glesv2

glesv2 :: glesv2

OpenGL graphics rendering library for embedded systems, version 2.0
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module input

mnit :: input

Defines abstract classes for user and general inputs to the application.
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module list

core :: list

This module handle double linked lists
module math

core :: math

Mathematical operations
module matrix

matrix :: matrix

Services for matrices of Float values
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module more_collections

more_collections :: more_collections

Highly specific, but useful, collections-related classes.
module native

core :: native

Native structures for text and bytes
module numeric

core :: numeric

Advanced services for Numeric types
module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module serialization

serialization :: serialization

General serialization services
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O

Parents

module app

app :: app

app.nit is a framework to create cross-platform applications
module programs

gamnit :: programs

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

gamnit :: textures

Load textures, create subtextures and manage their life-cycle

Children

module camera_control

gamnit :: camera_control

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

gamnit :: dynamic_resolution

Virtual screen with a resolution independent from the real screen
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 keys

gamnit :: keys

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

gamnit :: limit_fps

Frame-rate control for applications

Descendants

module a_star-m

a_star-m

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_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 cardboard

gamnit :: cardboard

Update the orientation of world_camera at each frame using the head position given by android::cardboard
module depth

gamnit :: depth

Framework for 3D games in Nit
module depth_core

gamnit :: depth_core

Base entities of the depth 3D game framework
module flat

gamnit :: flat

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

gamnit :: flat_core

Core services for the flat API for 2D games
module font

gamnit :: font

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

gamnit :: input_ios

Gamnit event support for iOS
module model_dimensions

gamnit :: model_dimensions

Dimensions related services for Model and Mesh
module more_lights

gamnit :: more_lights

More implementations of Light
module more_materials

gamnit :: more_materials

Various material implementations
module more_meshes

gamnit :: more_meshes

More simple geometric meshes
module more_models

gamnit :: more_models

Services to load models from the assets folder
module particles

gamnit :: particles

Particle effects
module selection

gamnit :: selection

Select Actor from a screen coordinate
module sensors

android :: sensors

Access Android sensors
module shadow

gamnit :: shadow

Shadow mapping using a depth texture
module stereoscopic_view

gamnit :: stereoscopic_view

Refine EulerCamera and App::frame_core_draw to get a stereoscopic view
module tileset

gamnit :: tileset

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

gamnit :: virtual_gamepad

Virtual gamepad mapped to keyboard keys for quick and dirty mobile support
module vr

gamnit :: vr

VR support for gamnit depth, for Android only
# Game and multimedia framework for Nit
module gamnit

import app

import display
import textures
import programs

import gamnit_android is conditional(android)
import gamnit_linux is conditional(linux)
import gamnit_ios is conditional(ios)
import input_ios is conditional(ios)

redef class App

	# Main `GamnitDisplay` initialized by `create_gamnit`
	var display: nullable GamnitDisplay = null

	# Hook to setup the OpenGL context: compiling shaders, creating VBO, reloading textures, etc.
	#
	# The gamnit services redefine this method to prepare optimizations and more.
	# Clients may also refine this method to prepare custom OpenGL resources.
	fun create_gamnit do end

	# Hook to prepare for recreating the OpenGL context
	#
	# Some gamnit services refine this method to reset caches before the
	# next call to `create_gamnit`.
	fun recreate_gamnit do end

	# Create and set `self.display`
	fun create_display
	do
		var display = new GamnitDisplay
		display.setup
		self.display = display

		# Print the current GL configuration, for debugging
		print "GL vendor: {glGetString(gl_VENDOR)}"
		print "GL renderer: {glGetString(gl_RENDERER)}"
		print "GL version: {glGetString(gl_VERSION)}"
		print "GLSL version: {glGetString(gl_SHADING_LANGUAGE_VERSION)}"
		print "GL extensions: {glGetString(gl_EXTENSIONS)}"
		print "GL max texture size: {glGetIntegerv(gl_MAX_TEXTURE_SIZE, 0)}"
	end

	# Hook for client programs to setup the scene
	#
	# Refine this method to build the game world or the main menu,
	# creating instances of `Sprite` and `Actor` as needed.
	#
	# This method is called only once per execution of the program and it should
	# be considered as the entry point of most game logic.
	fun create_scene do end

	# Core of the frame logic, executed only when the display is visible
	#
	# This method should be redefined by user modules to customize the behavior of the game.
	protected fun frame_core(display: GamnitDisplay) do end

	# Full frame logic, executed even if the display is not visible
	#
	# This method wraps `frame_core` and other services to be executed in the main app loop.
	#
	# To customize the behavior on each turn, it is preferable to redefined `frame_core`.
	# Still, `frame_full` can be redefined with care for more control.
	protected fun frame_full
	do
		var display = display
		if display != null then frame_core(display)

		feed_events
	end

	redef fun run
	do
		# TODO manage exit condition
		loop frame_full
	end

	# Loop on available events and feed them back to the app
	#
	# The implementation varies per platform.
	private fun feed_events do end

	# Hook to receive and respond to `event` triggered by the user or system
	#
	# Returns whether or not the event is used or intercepted.
	# If `true`, the event will not be processed further by the system.
	# Returns `false` to intercepts events like the back key on mobile devices.
	#
	# The instances passed as `event` may be freed (or overwritten),
	# right after this method returns. They should not be preserved.
	fun accept_event(event: InputEvent): Bool do return false

	# The window has been resized by the user or system
	#
	# The framework handles resizing the viewport automatically.
	fun on_resize(display: GamnitDisplay) do end
end

# Portable indirection to `glBindFramebuffer(gl_FRAMEBUFFER, fbo)`
#
# This is implemented differently on iOS.
fun bind_screen_framebuffer(fbo: Int) do glBindFramebuffer(gl_FRAMEBUFFER, fbo)
lib/gamnit/gamnit.nit:15,1--120,79