Homebrew [Release] {beta} sf2dlib - Simple and Fast 2D library (using the GPU)

  • Thread starter Thread starter xerpi
  • Start date Start date
  • Views Views 97,197
  • Replies Replies 501
  • Likes Likes 32
Is there a function for printing text that plays nice with this lib? The lib seems nice so far!
Alright, I just finished a basic bitmap font renderer, have some cleanup todo; but its really simple (Like two or three functions)
I haven't planed to open source the UI library I'm working on just yet. However if you really need the code I could always share that publicly before I release the code for my lib :)

EDIT: clarified my post
 
There is a bug with .3ds bluid when pressing on Home and Resume , all graphics disappear , only
void sf2d_set_clear_color(u32 color); still present.

I also have a problem with color graphics, RGBA displayed code is not the one you want .

For example: RGBA8 ( 0x94 , 0x94 , 0x94 , 0xFF ) to give me a light gray , but I has a very dark gray ...

I love the new function for the tilemap thank you , I'll really need a function to display text ...

Congratulations for your excellent work.
 
There is a bug with .3ds bluid when pressing on Home and Resume , all graphics disappear , only
void sf2d_set_clear_color(u32 color); still present.

I also have a problem with color graphics, RGBA displayed code is not the one you want .

For example: RGBA8 ( 0x94 , 0x94 , 0x94 , 0xFF ) to give me a light gray , but I has a very dark gray ...

I love the new function for the tilemap thank you , I'll really need a function to display text ...

Congratulations for your excellent work.


Alright, here is what my current code can produce:
eGf6EF7.png


Code: https://gist.github.com/filfat/05676067e0a8614a1a8f

You will have to use F2IBuilder to generate the bitmap (Example) and then use GIMP to convert it to a .c file (havent tested with the .h option , example )
If you use this code anywhere please give me credits for the code.



Oh and btw its licensed under "The Artistic License 2.0"; feel free to contact me if you want to join my 3DS-UI project :)
 
  • Like
Reactions: Margen67
Alright, here is what my current code can produce:
eGf6EF7.png


Code: https://gist.github.com/filfat/05676067e0a8614a1a8f

You will have to use F2IBuilder to generate the bitmap (Example) and then use GIMP to convert it to a .c file (havent tested with the .h option , example )
If you use this code anywhere please give me credits for the code.



Oh and btw its licensed under "The Artistic License 2.0"; feel free to contact me if you want to join my 3DS-UI project :)

That's pretty neat. Shouldn't be too hard to implement kerning and font sizing.

The sad thing is I'm actually writing a bitmap font rendering system in openGL for a project that's completely unreleated to 3ds development right now.
 
That's pretty neat. Shouldn't be too hard to implement kerning and font sizing.

The sad thing is I'm actually writing a bitmap font rendering system in openGL for a project that's completely unreleated to 3ds development right now.

Thanks. Just asked xerpi about texture scaling; he said he'll implement a function for that, so theres that :)

Cool.
 
  • Like
Reactions: Margen67
yea works on ninjhax fine.. just not on GW emu or my CIA CFW emu .. ctrulib has always been a pain like that though.

I guess Cubic Ninja is kinda initializing the GPU for us, then ctrulib lays on top of that, I'm not sure thought :/
 
Thanks for this library, I got it up and running with minimal effort, but I have a question about textures: Is it possible to lock a texture with this library so that we can manipulate its pixel contents directly, similar to SDL?

I came up with a "solution" for it, but it makes the screen flicker one time every few seconds (it's poorly coded on my part, I admit..):

https://gist.github.com/thedax/241347fe1995c3249d00

Edit: I wonder if that slow pixel generating code I have is why it's flickering; maybe it's taking more than one vblank's worth of time..

Edit 2: That seems to be it. I sped up the loop by doing two pixels per iteration and the flickering stopped. Also using the memory allocated to the texture directly now: https://gist.github.com/thedax/2f5e6f5d6822449a98a7

Edit 3: Also, using ctrulib's built in console on the bottom screen while things draw on the top screen works fantastically.
 
I return again to the color problem with a simple example...

Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <3ds.h>
#include <sf2d.h>
 
 
int main()
{
    sf2d_init();
    sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0x40));
 
    while (aptMainLoop()) {
 
        hidScanInput();
        if (hidKeysDown() & KEY_START) break;
 
        sf2d_start_frame(GFX_TOP, GFX_LEFT);
            sf2d_draw_rectangle(0, 0, 200, 240, RGBA8(0x40, 0x40, 0x40, 0x40));
        sf2d_end_frame();
 
        sf2d_swapbuffers();
    }
 
    sf2d_fini();
    return 0;
}

in this example, I display a bottom and a rectangle with the same value RGBA yet the result is not the same.
This problem destroys the charm of my next puzzle game.
 

Attachments

  • color.png
    color.png
    550 bytes · Views: 225
I return again to the color problem with a simple example...

Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <3ds.h>
#include <sf2d.h>
 
 
int main()
{
    sf2d_init();
    sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0x40));
 
    while (aptMainLoop()) {
 
        hidScanInput();
        if (hidKeysDown() & KEY_START) break;
 
        sf2d_start_frame(GFX_TOP, GFX_LEFT);
            sf2d_draw_rectangle(0, 0, 200, 240, RGBA8(0x40, 0x40, 0x40, 0x40));
        sf2d_end_frame();
 
        sf2d_swapbuffers();
    }
 
    sf2d_fini();
    return 0;
}

in this example, I display a bottom and a rectangle with the same value RGBA yet the result is not the same.
This problem destroys the charm of my next puzzle game.

You call an alpha blending on an alpha blended surface, it's obviously different...
 

Site & Scene News

Popular threads in this forum