Related tags
History
Inspirational quotes
“Yeah, awesome!”
me

“What do you mean by 'this is not a real quote'?”
mini-me

“All your websites are belong to us.”
Anonymous

“I will sue you for using my meme!!!”
Cats
← The WebsiteArt Style →
  Technical choices
Fri 12th October 2012 at 18:15   
In this article I will explain some basic technological choice I made for The 2d Game.

Did you say "direct media"?

SDL1 is the reference library for anyone starting a portable multimedia project.

It provides numerous data types and basic functions (timers, audio, graphics) that are guaranteed to work the same on about any SDL supported platform.


At the core of the SDL graphics is system is the software blitter API: As long as you want to just display a bit of graphics on the screen and refresh from time to time, it's ok.

If what you want is to move around hundreds of small sprites at 50 frames per second, then it's definitely not ok.

All I wanted was an easy to use library that would give me a reasonably efficient way to draw a lot of small 2D elements.
My first prototype of tilemap rendering engine using SDL was horrible, both from an architectural and performance point of view.

After searching around on the forums I found out that in order to achieve real performance you could use SDL with native OpenGL calls.
At this point you wonder why you used SDL in fist place if you have to do direct OpenGL calls. Which brings me to...

SeuFeuMeuLeu

SFML2 is a very nice little library I discovered about two months ago, after I decided that SDL was definitely not for me.

Feature wise SFML is quite different from SDL. It provides things like a network api, but it does not provide any abstracted file system.
The rationale from the author is that SFML provides only things related to 'multimedia', for the rest you should use either the standard C++ library or some external libraries if you wish so.

SFML is written in C++, comes with nice samples, is hardware accelerated by default, supports shaders, sprites, image loading and saving, event handling...
I think the whole API is relatively elegant and is flexible enough to be used in various ways (ex: you can handle mouse events in the event loop, but you can get directly the mouse position if you want as well).


The only issues I had so far have been with the event system which sometimes for unknown reason will make the application run extremely slowly for a short while, and then suddenly everything will run smoothly again.
I suppose this is a bug, and since the source code is available I will definitely look under the hood to see what the heck happens.


The 2D Prototype

I do have a running prototype of code that shows that using SFML it is perfectly possible to draw a tilemap using a custom shader, at full frame rate, using one single rectangle on the screen.


Since apparently a number of people are trying to make this kind of thing using cpu loops, indexed vertex buffers, sprite batching, ... and probably other things I don't even want to imagine, I decided I will share my method and provide full explanations on how that works.

I will explain all that in my next post, stay tuned :)



1. Simple Directmedia Layer
2. Simple and Fast Multimedia Library
comments powered by Disqus
Tag Cloud
More quotes
“Some other temporary content to make it looks like there is something to read.”
The Webmaster

“That's a very 1999 design.”
Rain

“Oh, the logo changes everytime! haha cool.”
fallahn