module Allegro

Overview

Allegro 5, game engine

Defined in:

Constant Summary

AT_EXIT = Proc(Proc(Nil), Void).new do |func| ::at_exit do func.call end end

Crystal at_exit wrapper for C atexit interface

PI = 3.14159265358979323846

Math PI value defined for Allegro library

The value can be different from Crystal's Math::PI

PKGVERSION = "5.2.6"

Version information obtained by pkg-config, at compile-time

PKGVERSION_MAJOR = 5

Major version of allegro, used at compile-time

PKGVERSION_MINOR = 2

Minor version of allegro, used at compile-time

PKGVERSION_PATCH = 6

Patch version of allegro, used at compile-time

TRACE_HANDLER = ->(expr : ::Pointer(UInt8)) do STDERR.puts(String.new(expr)) end
VERSION = "0.1.0"

Version number of the crystal binding library

VERSION_INT = (((((ALLEGRO_VERSION << 24) | (ALLEGRO_SUB_VERSION << 16)) | (ALLEGRO_WIP_VERSION << 8)) | ALLEGRO_RELEASE_NUMBER) | ALLEGRO_UNSTABLE_BIT)

Scrambled version number

Class Method Summary

Macro Summary

Class Method Detail

def self.finalize #

Uninitialize Allegro

Usually, you do not have to call this method manually.

It is safe to call this method multiple times.

Returns true if Allegro was initialized.


def self.id(a, b, c, d) #

Implements AL_ID. We assumes that this will never change.


def self.initialize #

Initialize Allegro library.

It is safe to call this method multiple times.


def self.initialized? #

Returns true if Allegro is initialized.


def self.main(argc : Int32, argv : Pointer(Pointer(UInt8)), &block : Int32, Pointer(Pointer(UInt8)) -> Int32) #

Main function wrapper of Allegro

Normally, you don't have to call this method.

You can implement your .main function with adding -Dno_auto_allegro_main flag. Typically, your .main function looks like:

fun main(argc : Int32, argv : UInt8**) : Int32
  # Some additional process before initialize Allegro
  Allegro.main(argc, argv) do |ac, av|
    # Some additional process before initialize Crystal
    # (note: code inside `Allegro.main` may be run on a different
    #  thread from the one executed `main`. See Allegro's doc for
    #  `al_run_main`.)
    Crystal.main do
      # Some additional process before running user code
      Crystal.main_user_code(ac, av)
      # Some additional process after running user code
    rescue e : Exception
      # Catch up unhandled exceptions
    end
    # Some additional process after cleanup Crystal
    # (note: Allegro is already cleaned up here too)
  end
  # Some additional process after running main function.
end

If your environment does not properly initialize Crystal matter, adding -Dno_auto_allegro_main and try to implement the .main function proper way. Please report an issue in this case.

See also the documentation of Crystal.main.


def self.version : Tuple(UInt32, UInt32, UInt32, UInt32) #

Runtime version of Allegro

Returns tuple of Major, Minor, Revision and Release versions


def self.version_to_tuple(ver : UInt32) #

Macro Detail

macro al_id(a, b, c, d) #

Macro implementation of Allegro.id for make literal values


macro define_core_macros(data) #

macro get_macro_defs(cflags, headerfile, &) #