Gles2D, An Opengl(Es) Cross Platform 2D Library


Cpasjuste

Member
Joined
Apr 20, 2007
Messages
266
Hi !

I'm working for some time now on a 2D library for the pandora, which is now cross platform so we can build and run code on an i386 linux with an openGL based card.

I'm actually releasing the first official release, only the i386 binary for now, so people can try it, report back problem's and begin some cool games :)

You'll have to run linux and compile SDL 1.3 to use it ( svn checkout http://svn.libsdl.org/trunk/SDL ).

The header files are not really commented for now, but you can take a look at the exemples in the archive, i think they are pretty easy to understand.


Download : http://mydedibox.fr/index.php?option=com_docman&task=doc_download&gid=17&Itemid=29
Source Code : http://github.com/Cpasjuste/libGLES2D

Code:
GLES2D is a cross platform library in developement. It use openGL(ES) for 2D rendering.
It actually run on the pandora gaming console, and on any linux distributions.
To run it on linux distribution, you'll need an openGL card and 
compile sdl 1.3 (svn checkout http://svn.libsdl.org/trunk/SDL)

Currently supported feature :

- Simple function to init the screen.
- Load and draw textures with ease.
- Load and draw sprites with ease.
- Load ttf and bitmap fonts with ease (need to be optimised).
- Scale, rotate, blend textures, fonts and sprites.
- Load and draw tile based map (only map made with mappy is currently supported : http://www.tilemap.co.uk/mappy.php )
- Simple texture, sprite and tile map collision detection.
- Handle PC/PANDORA keyboard and gamepad.
- Handle PANDORA touchscreen.

Build 20090919 :

- Added better collision detection for textures and sprites, including pixel perfect detection and pixel color perfect detection.
- Added examples for collision detection.
- Texture structure changes : texture->w is now the actual drawing width and texture->wsrc is the original width.

Download : http://mydedibox.fr/index.php?option=com_docman&task=doc_download&gid=18&Itemid=29

sprite.png
 
Nice, this seems to be exactly what I need :)
Your samples are very clear and readable, I'll try to use it at the weekend and give some feedback.
 
Fantastic! Thanks Cpasjuste. Libraries like are just the ticket to spawn hordes of high-quality homebrew. I'll check it out as soon as I get a break from work.
 
So you're saying, for example, if a game is made using this library, it will run on both the PC as well as the Pandora? That's awesome! This will be such a big help to many developers!
 
Interesting. It looks pretty nice and clean. You may want to be explicit about it being C.

Some points that tripped me up initially:
  • You set a texture's coordinates for collision detection by calling the draw function?
  • The map and its position is global state? It's not entirely clear to me what state it contains.
  • (Sorry, spelling nitpicks;) I'd expect it to be 'TileMap', not 'TilesMap'. And 'exemples' would more commonly be spelled 'examples'.
Do you intend to release the source at some time? Any particular licence in mind?
 
An Opengl card, you say? Man I need a new laptop, even a netbook would do at this point :D

The game in that screenshot looks very nice, is it something you're working on?
 
HealyHQ said:
So you're saying, for example, if a game is made using this library, it will run on both the PC as well as the Pandora? That's awesome! This will be such a big help to many developers!

Yes, that's it !


Multiplex said:
Interesting. It looks pretty nice and clean. You may want to be explicit about it being C.

Some points that tripped me up initially:
  • You set a texture's coordinates for collision detection by calling the draw function?
  • The map and its position is global state? It's not entirely clear to me what state it contains.
  • (Sorry, spelling nitpicks;) I'd expect it to be 'TileMap', not 'TilesMap'. And 'exemples' would more commonly be spelled 'examples'.
Do you intend to release the source at some time? Any particular licence in mind?


I'm not sure to understand your first question but here is how it work :

There is no saved textures coordinates, i just use "glTranslatef" every time we draw one to set the texture at the right place, and i hold the texture destination (for collision and for everything we might need) in the texture structure.

For exemple for this code:

Code:
GLES2D_Texture *mytexture = GLES2D_LoadTexture( "cool.png", RGBA8888 );
GLES2D_DrawTextureSimple( mytexture, 100, 110 );

"mytexture->x" : would return 100
"mytexture->y" : would return 110
"mytexture->scaled_w" : would return the with of the texture when it was drawn, i mean not the original texture(image) width.
"mytexture->scaled_h" : same as before but for height.
"mytexture->w" : would return the original texture width (original loaded image width);
"mytexture->h" : same as before but for height.

I think i should swap the pointer's name "->w" and "->h" for the scaled width/height since it may be more used.

I'm not sure to understand your second question too :p

For the third one, thanks ! As you can see, my english is far from being perfect :)

Else i'm not planning to release the sources for now, but if you need any help on anything i'll be more than happy to do it.

Alex. said:
An Opengl card, you say? Man I need a new laptop, even a netbook would do at this point :D

The game in that screenshot looks very nice, is it something you're working on?

The screenshot is just the sprite example, but it's very basic and with some bugs left :p


Note that there is for sure a lot of bugs left, but i'll try to improve the library as much as i can.
See you !
 
Last edited by a moderator:
Cpasjuste said:
Else i'm not planning to release the sources for now, but if you need any help on anything i'll be more than happy to do it.
If you aren't planning to release the source, do you intend to make a Windows binary at some point? I like the option to develop with Visual Studio, but more importantly (if my games are any good) I'd like to be able to release a Windows build. Anyway, I'm looking forward to having a go with this at the weekend.
 
Last edited by a moderator:
Cpasjuste said:
Else i'm not planning to release the sources for now, but if you need any help on anything i'll be more than happy to do it.
I actually wouldn't mind some general pointers in drawing stuff using GLES if you have some time to spare (and don't mind). I've been putting off writing the GLES(2) backend for Penjin...
 
Last edited by a moderator:
PokeParadox said:
Cpasjuste said:
Else i'm not planning to release the sources for now, but if you need any help on anything i'll be more than happy to do it.
I actually wouldn't mind some general pointers in drawing stuff using GLES if you have some time to spare (and don't mind). I've been putting off writing the GLES(2) backend for Penjin...
How about just using cpasjuste's library?
 
Last edited by a moderator:
You should split hardware functions from game related functions and put the hardware stuff into a pandora.h with logic and good function names.
But that might only be me.
 
I would like to test this on my Win machine. I have SDL running. Could you create a Win build please?
 
HaCo said:
I would like to test this on my Win machine. I have SDL running. Could you create a Win build please?
SDL 1.3?

From reading Cpasjustes other thread it seems like getting a Windows binary for SDL 1.3 is the real blocker to a Windows port.
 
Last edited by a moderator:
I didn't tried to compile sdl 1.3 under cygwin but i bet it should be possible.

The library needed are : libpng, libtiff, libjpeg, libfreetype, libz and libGL.
If they are available for cygwin it should be ok. I will try to compile it soon.
 
HaCo said:
No, I use the 1.2.13.
What Cpasjuste means is that you'd have to recompile SDL 1.3 from libsdl source trunk (and not use Cygwin package) to be able to even think of using his library :)
 
Last edited by a moderator:
Ok :)

Didn't play much with the SDL, just looked at the examples. Took me some time to get it compiled on my Vista machine tough. Is cygwin the preferred environment to develop software for pandora on Win?
 
Back
Top