I'd like to share the 2D library we started using at our college for beginner and advanced programming students.
Students find it easy to use and seem to get quick results.
It is written in C using OpenGL,
It is very new, I update it quite often, download it from here for newer versions
http://involuntaryexercise.com/apps/reni2d.zip
added: very easy to use pixel shader support, see example code
added: fast pixel perfect collision detection
check out example code
feature list:
- very clean and straight forward api
- simple and plain state machine
- no classes, no inheritance, no custom data types, no constants
- hardware accelerated 2D sprites
- pixel perfect collision detection (can be batched and baked)
- easy to use pixel shaders
- alpha blending and tinting
- texture sampling operations (easy tiles,sprite/font sheets,sliding)
- mouse and keyboard input (including hardware polled mouse movements)
- random numbers, rotation operations, bitmap loading
edit:
I finally tested reni2D's performance against something out there.
I hear a lot about Haaf's engine, so I took his "Thousands of Hares" example and replaced drawing calls with reni2D. Test app is running 2000 sprites by default, "SPACE KEY" flips between blending mode 0 and 2.
http://hge.relishgames.com/doc/html/tutorials_tut07.html
It performed great, even slightly faster. Here is the test executable,images and the ported example code:
http://involuntaryexercise.com/apps/reni2dhgetest.zip
mode 0
mode 2
here is all the code needed to create the following effect:
unsigned int s=raGetShader("raColor.xyz = raArg0.z*raColor/distance(raArg0.xy,raPixelPos.xy); ");raSetShader(s);
shader test screen shots (20000 sprites!)- lighting
here is the entire code for the example image:
#include "reni2D.h"int RA_MAIN() { unsigned int betty = 0; float x,y; float a=0; //init engine raInit(800,600); //load sampler betty = raGetSamplerFromFile("betty.bmp"); raSetSampler(betty); //white opaque color multiplier raSetDrawColor(255,255,255,255); while(raRun()) { raClear(); //draw 64x64 quad raSetQuadSize(32,32); raSetQuadRot(-90); //big betty, at center, rotated -90 around origin raDrawQuad(400,300); //using dummy point to do pivot rotation of 45 degress 50 units from origin raResetDummy(); raMoveDummy(50,0); raRotateDummy(a); a+=0.5; //resulting coordinates are based on 0,0 , now move the altered dummy to center of screen raMoveDummy(400,300); //get the results x = raGetDummyX(); y = raGetDummyY(); //small betty //draw 16x16 quad raSetQuadSize(8,8); raSetQuadRot(45); raDrawQuad(x,y); } }
If you have time, please give it a try and throw some feedback,
Thanks
Levent
(edit4: api overhaul reflected in example code)
[Edited by - lvnt on November 2, 2010 5:29:58 PM]