Public domain image and OGG Vorbis loading

Well, another change to SIEGE, this time without screenshots — namely, SIEGE has now received public domain image (via stb_image) and OGG Vorbis (via stb_vorbis) loading!

All the example programs have been modified to use this instead now, to be able to use SIEGE with image, audio (and, from before, font) loading without any external libraries!

Posted in SIEGE. Comments Off »

Public Domain font loading and other improvements

A couple of days ago, SIEGE has received Public Domain font rendering via the excellent stb_truetype library; other improvements have been added to both the STB and Freetype modules and implementations, however:

  • Kerning has been implemented
  • User-provided DPI setting for glyph rendering (default is 96)
  • Loading fonts from generic streams (SGStream — see the previous post)
  • Major cleanup of text-rendering and related (text size, offset position, …) functions in siege/graphics/font.c
  • Fixed a bug with rendering artefacts on the left-hand side of some glyphs

The new module is named “STB-TrueType” — in order to use it, simply replace “Freetype” in the sgLoadModule() call with “STB-TrueType”.

The changes are spread across multiple commits, but this is the largest: https://github.com/SIEGE/siege/commit/34e31681738a7b4b479780a8c7069f50acbc6be6.

And finally, a screenshot of the new module in action with all the improvements:

As you may have noticed, the new module does create a bit more “blurry” text, which may be (depending on the situation and the style of the game) a good or a bad thing. If that is a problem, simply use the Freetype module, which is still available (and will be available — I have no intention of removing it). I will probably be changing all the SIEGE examples to use this by default for one very simple reason — no external dependencies, everything is included with the module.

Posted in SIEGE. Comments Off »

SIEGE Streams

SIEGE has just received a new feature — streams. They allow the user to load, say, textures and audio, directly from sockets, memory and whatnot, without any issues.

Of course, existing functions will remain for loading, as it is much more convenient to simply use the file load function rather than who-knows-what when advanced functionality isn’t required; internally, it now all uses streams, however.

The API is very simple and can be seen here: https://github.com/SIEGE/siege/blob/master/include/siege/util/stream.h.

Posted in SIEGE. Comments Off »

SIEGE version 0.7.0 is out

SIEGE version 0.7.0 is out! The following features have been added or changed:

  • evDraw is now called between evTick and evTickEnd — this allows the user to do things after the drawing has already been completed, in preparation for the next tick.
  • SGBank has been added for resource management. This is a conveniency wrapper which allows the programmer to load resources on-demand. For example:
// try data/sprites/<name>.png and data/sprites/<name>.jpg in sequence
SGBank* sprites = sgBankCreate("data/sprites/%s.png|data/sprites/%s.jpg", loadSprite, unloadSprite);

// data/sprites/player.png or data/sprites/player.jpg
// NULL is an opaque data pointer, passed in to loadSprite
SGSprite* player1 = sgBankLoad(sprites, "player", NULL);

// ...

// "player" has already been loaded, so we return that sprite instead of loading again
SGSprite* player2 = sgBankLoad(sprites, "player", NULL);

// automatically calls unloadSprite for each loaded image
sgBankDestroy(sprites);
  • SGEntity now has an (optional) name, so that entities can be looked up by name.
sgEntitySetName(tanks[0], "tank");
sgEntitySetName(tanks[1], "tank");

// ...

SGList* tanks = sgEntityFind("tank");
  • sgDrawSetAlphaTest and sgDrawSetAlphaFunc have been added, which enable the use of some interesting effects such as metaballs
  • Timers for easier handling of timed things (examples being animations, gun reload times, timed doors, elevators, …)
  • Texture atlases (they are not yet used within SIEGE, so they are mostly useless, but they will eventually be used for sprites and fonts)
  • Other minor changes and fixes
Posted in SIEGE. Comments Off »

Recent updates

Hey there, no updates in a while, I know.

SIEGE has gone through quite a lot of refactoring and updates — to name a few:

  • joystick support has been completed (note: POV-hats are still not supported, I’ll get to those later)
  • Entity priorities have been removed, which means that entity creation and destruction is now O(1) instead of O(n)
  • SGEvent, which was never ever used by anyone (not counting uses within SIEGE) has been removed and merged into SGEntity

There are still some minor changes to be done with events, socket support has to be finished and texture atlases + sprite sheets added to the engine; the latter (sprite sheets) should make loading sprite animations, tilesets, etc… much easier than earlier.

Posted in SIEGE. Comments Off »

Window icons

New updates bring SIEGE to version 0.4.0:

  • initialization has been changed so that it no longer opens a window by itself (thus, the number of parameters has been reduced to 1 – flags)
  • new API added to leverage SIEGE’s image loading functionality directly
  • window icon functionality added (by request from bernardh)

Here’s a short example of the new API:

// old initialization
// sgInit(width, height, bpp, flags);

// new initialization (we'll open the window later)
sgInit(flags);

// image loading
SGImageData* idata = sgImageDataCreateFile("data/sprites/whatever.png");
/*
 * Set the icon (this has to be done *before* the window is opened).
 * Note that in Windows, this is required to be 32x32; also note that there might
 * be some changes in the API in the future.
 */
sgWindowSetIcon(idata);
sgImageDataDestroy(idata);

// now we can finally open the window!
sgWindowOpen(width, height, bpp, flags);

And finally, a screenshot:

Example of the window icon functionality in SIEGE - note the small yellow icon in the top-left.

Posted in SIEGE. Comments Off »

Moved across servers

If you haven’t been able to reach the website during the last few days, it was due to DNS propagation and because I’ve been fiddling with the new server.

And by fiddling, I mean that the website has been moved to a new server, and I still had (and have) to configure some things. You’ll also notice that the theme is currently semi-broken (the title bar, for example, should have a dark background) – I’m working on that.

The good news is that SIEGE is now on a much better server than before (it’s a dedicated server), which means that I’ll be able to put up, say, a bugtracker which doesn’t use PHP (there’s a lot to choose from though).

Posted in Website. Comments Off »

Threading API added

SIEGE has just (well, actually a few days ago) received new functionality, all related to threading. The following are now available:

  • threads (suprise, suprise!)
  • thread-local storage
  • mutexes
  • semaphores

The API is cross-platform – it works both in Windows and on POSIX systems. I won’t be quoting all the functions added here because there is quite a lot of those – if you want to see all of them, check out these files: /include/siege/util/thread.h, /include/siege/util/threadkey.h, /include/siege/util/mutex.h and /include/siege/util/semaphore.h.

As you may know, SIEGE does not actually use threads – yet, so what do I need this API for? Well, I’m working on getting a separate rendering thread running in SIEGE (optional, controlled by a flag, so you don’t have to worry about thread-safety if you don’t want to and instead disable multithreading). Furthermore, I want to eventually make SIEGE completely event-based (again, controlled by flags) so that event handlers can run from a thread pool and use messages for communication.

Posted in SIEGE. Comments Off »

Un-hardcoded module search path

Until now, the module search path has been hardcoded to the “modules” directory; I have now changed that so that it can be changed by the user. Furthermore, multiple paths can be provided – if SIEGE cannot find the module in the first path, it continues seeking in the second path and so on.

Furthermore, four new functions are added:

/*
 * Try "ndirs" directories in order - if the module cannot be found in the first,
 * continue to second, if it's not there, continue to third, et cetera...
 *
 * Up to 256 directories can be provided.
 */
void sgModuleSetLoadDirsv(size_t ndirs, va_list args);
void sgModuleSetLoadDirs(size_t ndirs, ...);
// same as calling sgModuleSetLoadDirs(1, dir)
void sgModuleSetLoadDir(const char* dir);
// get the current list of dirs
char** sgModuleGetLoadDirs(size_t* ndirs);

I am also going to un-hardcode the prefix (the “[lib]SGModule-” bit) soon.

UPDATE: The prefixes are now un-hardcoded (though the code hasn’t been tested well); the API is similar to the directories, only replace “Dir”/”Dirs” with “Prefix”/”Prefixes”.

Posted in SIEGE. Comments Off »

Lights are in

Okay, I’ve decided to stop looking for a better API for lights and just put them into master.

Here are the relevant commits:

Some changes are still pending, but the API is going to remain as it is, at least for the time being.

Posted in SIEGE. Comments Off »