Home

Awesome

libdhcore: darkHAMMER Core 'C' library

Version 0.5.2-dev
http://www.hmrengine.com
https://github.com/septag/libdhcore

Description

libdhcore is a lightweight and cross-platform C (C99) library with C++ wrappers, mainly targeted to game developers. It is used in darkHAMMER game engine, I don't know how mature it is, but it is being used and tested for 2 years in various projects.
It can be built with GCC, MSVC and Clang compilers, on x86, x86-64 and ARM platforms, including windows, linux, MacOS and RaspberryPI.
Source code License is BSD.

Here's a list of library modules and their descriptions:

Installation

Linux/Waf

Install the packages listed below before proceeding to build and install the library :

After checking for above packages, run these commands, and change /install/path to your preferred path on disk (for example: --prefix=/usr) :

git clone git@github.com:septag/libdhcore.git
cd libdhcore
waf configure --prefix=/install/path
waf build
sudo waf install

To build debug libraries, which will have -dbg suffix after their names, use the commands below instead of last two lines:

waf build_debug
sudo waf install_debug

To build test applications ($(prefix)/bin/dhcore-test) , use --build-tests argument in waf configure.

To use a Cross Compiler, like for example compiling for RaspberryPI device, use CC and CXX enviroment variables, and --platform argument in configure and provide platform code for builder.
For example, I have a ARMv6 cross compiler named armv6-rpi-linux-gnueabi-gcc, I use below command to configure the build for RaspberryPI device (under unix):

CC=armv6-rpi-linux-gnueabi-gcc CXX=armv6-rpi-linux-gnueabi-g++ waf configure --platform=linux_rpi

For more configure options, run waf --help when you are in libdhcore directory to see more command line arguments.

Linux/QtCreator

The code can also be built with Qt Creator. Fetch the code from github, open the project file libdhcore.pro and build.

Windows/Visual Studio

There is also Visual Studio 2013 projects under vs2013 folder. Open the solution. Choose your configuration and build.
The code can also be built with Qt Creator. Just open the project file libdhcore.pro and build.

MacOS/Xcode

There are xcode project files under xcode directory.
The code can also be built with Qt Creator. Just open the project file libdhcore.pro and build.

Usage

Make sure the you have setup include and library paths of libdhcore in your compiler. Then include any header file from dhcore directory into your source. And link your program to dhcore.

Main include file is dhcore/core.h, and before everything else you must Initialize core lib at the beginning of your program and Release it after everything else is done:

#include <stdio.h>
#include "dhcore/core.h"

int main(int argc, char** argv)
{
    result_t r = core_init(CORE_INIT_ALL);
    if (IS_FAIL(r))
        exit(-1);

    puts("Hello world");

    core_release(TRUE); // pass TRUE for leak report
    return 0;
}

C++ Wrappers

Some data types have C++ wrappers, like containers (array, hashtable), allocators (freelist, stack, pool) and math primitives (vectors, matrix, geometric). So C++ programmers can use those and benefit from cleaner syntax and easier functionality.

Documentation

For API documentation (which is at it's early stage), check out this API Documentation.
You can also build the documentation by installing doxygen and cd to /path/to/libdhcore/doc directory and run:

doxygen doxygen-core.conf

After that, HTML documentation will be ready at doc/html directory

Credits