Skip to content
forked from tankfeud/norx

A Nim wrapper of the ORX 2.5D game engine

License

Notifications You must be signed in to change notification settings

denise-amiga/norx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Norx

Norx is a Nim wrapper of the ORX 2.5D game engine library. ORX is written in C99, highly performant and cross platform. The wrapper consists of two parts:

  • The low level wrapper with basically one Nim module per ORX C header, almost 80 of them. All these are named o-xxx, like oinput or oobject.
  • The high level wrapper with one Nim module per low level wrapper. Currently each high level wrapper also exports the low level wrapper.

The low level wrapper uses "C types" and is automatically generated as much as possible from the C header files. The high level tries to use Nim style and Nim types as much as possible.

The only things you need to compile a Nim ORX game is this Nimble module and the ORX dynamic library files (liborx[p|d].so|dll) in a proper library path. However, for debugging etc it's more practical to also have the full ORX clone with ORX C sources etc.

Build and install ORX

First install ORX dlls. At the moment best is to build them from a master git clone of ORX since it is in sync with the wrapper.

This works on my Ubuntu 64 bit (after installing normal C tools needed):

  1. Clone ORX with git clone https://github.com/orx/orx.git.
  2. Run setup.sh in top level first, this pulls down more dependencies.
  3. Build with cd code/build/linux/gmake && make config=release64 (build also debug64 and profile64 to get those extra libraries). Same on OSX but in code/build/mac.
  4. Copy libraries to a library path with for example sudo cp -a $ORX/lib/dynamic/liborx* /usr/local/lib/ on Linux or OSX. May need to run sudo ldconfig after.

For other platforms, or if you get into trouble, follow official ORX instructions that give much more details!

Install Nim

Easiest is to use Choosenim curl https://nim-lang.org/choosenim/init.sh -sSf | sh or see Official download.

Install Norx

Install the Norx wrapper by running nimble install in this directory.

See samples directory for some samples using it!

How it was made

This wrapper was created through the following steps:

  1. Run convert.nim in this directory that uses common.c2nim.
  2. Modifications to the original header files using ifdefs.
  3. Eventually "abandon all hope" and start editing the generated Nim files manually.

Unfortunately this means that at this moment (due to step 3 above), updates to ORX header files does not mean we can just regenerate this wrapper automagically.

How to maintain

These are notes to "self". We track any changes to the include directory, for example if orxObject.h changes:

  1. cd headers
  2. cp ../../../include/object/orxObject.h object/orxObject.h
  3. Using your IDE, reapply modifications that was overwritten :) - this should be handled better of course.
  4. c2nim common.c2nim object/orxObject.h to reproduce orxObject.nim
  5. Merge parts into obj.nim that should be there using meld object/orxObject.nim ../src/norx/obj.nim

Todos

  • Do we add higher level wrappers on top? Or do we add highlevel wrap procs inside the modules?
  • orxBOOL, orxFLOAT, orxU32 etc etc... Nicer with Nim types
  • cstring vs string
  • Put argc/argc handling inside Norx
  • Demangle all the orxYadda_xxx into xxx?

About

A Nim wrapper of the ORX 2.5D game engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 33.6%
  • C 31.6%
  • Nim 29.4%
  • JavaScript 3.9%
  • CSS 1.3%
  • StringTemplate 0.2%