Homebrew RELEASE libcross2d: a little cross platform 2d library

cpasjuste

Well-Known Member
OP
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France

libcross2d.png


libcross2d is a c++ cross platform 2d graphic, input and audio library (and more) which run on Windows, Linux, Nintendo Switch, Nintendo 3DS and Sony PS Vita. It's getting released for the
GBAtemp Homebrew Bounty: 2018 Switch Edition

I'v been working since a while on a little C++ 2D cross platform development library for a few devices. All started with the Sony PS Vita and Nintendo 3DS. I wanted to ease the development/deployment process on those devices, and did write psp2shell for the vita, and libctrshell for the 3ds to do so. They allow printing over a WiFi shell for simple debugging, easily load/reload applications and so on. While they do the job, when i started the pFBA project (which didn't had a name yet), it was not enough. I still had to write a lot of custom stuff (graphics, inputs, audio, io...) to handle each devices for doing the same thing but also loose a lot of time to setup, test code and deploy on all of them. Making a simple but functional user interface was also a pain, loosing, again, some precious time for the real stuff (probably because i'm bad at UI too :)).

So i started to write a simple cross platform library (libcross2d) for my own use, with a primarily goal: run on desktop to bypass all the previously mentioned restrictions, abstracting the targets graphics, inputs, etc..., allowing testing the application on the real device once a week... Then, it needed to be simple to use, and i think it achieve that as you can see in the texture example!

Since all is about 2D and UI's, i needed a good base to handle this job. It's why the 2D rendering code (textures, shapes, transformations..) is based on SFML which is perfect to handle this task, and libcross2d use hardware acceleration to render this on all the supported devices (desktop, switch, 3ds, vita...). But libcross2d also handle/abstract inputs, ttf fonts, config files, clocks/timers, basic tweening (position, rotate, scale, color..), and a very few widgets. There is no extensive documentation yet, but i did take some time to write some simple examples and how to, which should really be enough to start.

With the gbatemp homebrew competition announced, i though it could now be a good timing to make this work public, and so i worked hard since it's announcement to make a first public release of this library. I Hope people will be able to make great applications/games with it, adding the comfort of "working" on any computer around and focusing on the real stuff, and maybe submitting some cool stuff to the homebrew bounty using libcross2d !

libcross2d main features
  • a c++ cross platform 2d graphic, input, audio and config library
  • run on Windows, Linux, Nintendo Switch, Nintendo 3DS and Sony PS Vita
  • draw textures, rectangles, circles, texts (TrueType) and more
  • basic tween engine (move, rotate, scale, color)
  • clock/timer classes
  • configuration file handling
  • pack your application (zip) for release on any target, including resources (data/common)
  • quickly prototype your application on desktop (Linux and Windows)
  • use hardware acceleration on Linux, Windows, Switch, 3DS and PS Vita
  • use some of the great sfml library stuff (fonts, shapes, matrices)
  • use tweeny for the (minimal) tween engine
  • use some of the great libretro shaders (Linux, Switch)
  • use some citro2d code for the 3ds renderer
  • use some vita2d code for the vita renderer
  • use libconfig for the configuration classes
  • preliminary developed for my own use, still a work in progress

If you need any help and want to discuss, the main discussion thread is here! If you find bugs or want new features, use github issues please. A first release (version 1.0) is located in the gbatemp download center, and on github.

!! READ THE README !!

 
Last edited by cpasjuste,

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,858
Trophies
2
XP
28,891
Country
United Kingdom
Glad to give this a bump, as it deserves more attention.

I've been fiddling with this to get it to work on Mac, mostly just messing with the CMake files, but I did have to change the required GL version in sdl2_gl_renderer.cpp from 4.3 to 3.3 to get the GL display stuff running on my old Mac. Do you know if there's anything in your library that actually requires GL newer than 3.3?
 
  • Like
Reactions: matt!

cpasjuste

Well-Known Member
OP
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
Glad to give this a bump, as it deserves more attention.

I've been fiddling with this to get it to work on Mac, mostly just messing with the CMake files, but I did have to change the required GL version in sdl2_gl_renderer.cpp from 4.3 to 3.3 to get the GL display stuff running on my old Mac. Do you know if there's anything in your library that actually requires GL newer than 3.3?

Hi, cool, some report! :)

I think 3.3 should be fine, I'll try to take a closer look tomorrow (I did use 4.3 when I moved to new style opengl for the switch, which have a 4.3 main core profile). Lowering down as much as possible is wanted, I think 3.30 is the minimum for shaders.
Also, if you know how to, feel free to do a "Mac" pull request on github :)
 
Last edited by cpasjuste,

cpasjuste

Well-Known Member
OP
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
Hey, congratulations, great project!

I'm the author of Tweeny and I'm really happy to see it used in your project and also how you used it.

I wish you success.
Hi,

It's awesome to see you here :) I still have some work to implement it better (add callbacks, tween curves and such) but it will be done in time ..
 

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,858
Trophies
2
XP
28,891
Country
United Kingdom
I've been rebuilding my old puzzle game for cross2d, and just been testing the first playable build on my Switch. Playing my own game on my Switch feels awesome.
My game uses proc genned levels, and I copied the code for random numbers from your "crazy" example - but I noticed when I ran it on switch, it came out with the same sequence of levels on every startup. I had to change
Code:
std::random_device rd;
std::mt19937 mt(rd());
to
Code:
std::mt19937 mt(time(0));

It seems random_device isn't random on Switch, thought you might want to know.
 

cpasjuste

Well-Known Member
OP
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
I've been rebuilding my old puzzle game for cross2d, and just been testing the first playable build on my Switch. Playing my own game on my Switch feels awesome.
My game uses proc genned levels, and I copied the code for random numbers from your "crazy" example - but I noticed when I ran it on switch, it came out with the same sequence of levels on every startup. I had to change
Code:
std::random_device rd;
std::mt19937 mt(rd());
to
Code:
std::mt19937 mt(time(0));

It seems random_device isn't random on Switch, thought you might want to know.
Hi,

Yes this is good to know, i didn't notice that :) Else I'll be happy to see how you implemented cross2d!
 
  • Like
Reactions: hippy dave

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/@legolambs