Nim bindings to SFML multimedia/game library
See introduction, examples, documentation, wiki.
This library consists of class wrappers implemented as ptr object
. Because Nim does not allow attaching pointers to the garbage collector, disposal of objects is not implemented and needs to be manual, by calling the destroy
methods. Standard memory management caveats apply: destroying objects that are still used will break things, forgetting to destroy is a memory leak.
This library is not under active development, but detailed bug reports will be given proper attention.
nim-csfml allows you to use SFML, which is a library made in C++. So most information and tutorials for SFML revolve around C++. It is a good idea to get familiar with SFML itself first.
The API attempts to be very similar to SFML’s, but some general changes are present:
sf::SomeType x(param)
), use a corresponding procedure (there are 2 variations):var x = newSomeType(param)
, which means it is a ptr object
.destroy
called to properly dispose of them.new
.var x = someType(param)
, which means it is an object
(in CSFML it corresponds to a simple struct
).Vector2(i|f)
, Vector3f
and (Int|Float)Rect
should be created using special vec2
, vec3
and rect
procs.loadFromFile
, that are used for initialization, are also represented as constructor procs described above.x.getSomeProperty()
and x.isSomeProperty()
both become x.someProperty
.x.setSomeProperty(v)
becomes x.someProperty = v
.type
: kind
, object
: obj
, string
: str
, bind
: bindGL
.enum
names were taken from CSFML, but changed to remove their common prefix to resemble SFML’s values.enum
s are all pure
: use EnumType.Value
.enum
s are just represented as a list of constants, because they are not really enumerations.enum
values as bitmasks. You can combine them using the |
(not or
) operator defined for BitMaskU32
in the util module.sf::String
or strange conversions):cint
and cfloat
will be present everywhere, so explicit conversions to/from Nim’s normal types may be required.unsigned int
is mapped as cint
, etc., so you don’t have to bother with unsigned conversions. This shouldn’t cause problems, but it might.sfBool
which is defined as int
, is mapped to the IntBool
type with conversions to Nim’s bool
.See examples to learn more.
The files private/*_gen.nim are automatically generated from CSFML’s header files. They provide the base CSFML API. The files csfml_*.nim build upon them, adding compatibility with SFML API.
csfml.nim automatically imports system, window and graphics; audio should be imported separately; network is not implemented.
nim-csfml‘s version number (x.y.z
): x.y
corresponds to the supported CSFML version; z
is for the project’s own point releases.
nim-csfml supports CSFML 2.5; there are older releases, down to CSFML 2.1. It has been tested on Linux 64-bit.
This library can be installed using nimble install csfml
.
CSFML 2.5, which requires SFML 2.5, must be installed to use it.
On Windows you can just download CSFML and put the DLLs (which seem to be statically linked with SFML) in your project folder instead.
License: zlib/libpng
This library uses and is based on SFML and CSFML.
nimrod-sfml was a great source of knowledge.