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

  • Thread starter Thread starter xerpi
  • Start date Start date
  • Views Views 97,198
  • Replies Replies 501
  • Likes Likes 32
Different color is caused by shader. You can see it in action also on my Asteroids 3D i posted few posts ago.

New colors by shader are horrible !!!

As I understand it , there is no solution ? We can not get the original color ?

Edit : With no alpha, i have same result :

Code:
int main()
{
    sf2d_init();
    sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
 
    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, 0xFF));
        sf2d_end_frame();
 
        sf2d_swapbuffers();
    }
 
    sf2d_fini();
    return 0;
}
 

Attachments

  • 0xFF.png
    0xFF.png
    550 bytes · Views: 269
  • Like
Reactions: xerpi
New colors by shader are horrible !!!

As I understand it , there is no solution ? We can not get the original color ?

Edit : With no alpha, i have same result :

Code:
int main()
{
    sf2d_init();
    sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
 
    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, 0xFF));
        sf2d_end_frame();
 
        sf2d_swapbuffers();
    }
 
    sf2d_fini();
    return 0;
}

I think I got it, the problem was that I was using GPU_MODULATE when it was not necessary, I've changed it to GPU_REPLACE.
Update your sf2d and try again.
 
  • Like
Reactions: Cid2mizard
Anyone get screens switching working? (Something like blending some objects on top screen, after this blending some objects on bottom screen and after this blending some other objects on top screen?) Seems i get corrupted textures/objects if i do this :/ [Also has someone tried to combine GPU rendering with normal framebuffers rendering through CPU?]
 
Help¡ can anyone explain the process to convert images to c-source using GIMP to use this library. Please
 
Help¡ can anyone explain the process to convert images to c-source using GIMP to use this library. Please

Open your image, Export As, Select the type of project (bottom left), choose code source C and click Export, now you choose filename (ex : mysprite_img), you just check (alpha canal RVBA/RVB) and export...
 
Open your image, Export As, Select the type of project (bottom left), choose code source C and click Export, now you choose filename (ex : mysprite_img), you just check (alpha canal RVBA/RVB) and export...


After that you will get a .c file with something similar to this:
Code:
static const struct {
  unsigned int      width;
  unsigned int      height;
  unsigned int      bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
  unsigned char    pixel_data[128 * 128 * 4 + 1];
} mysprite_img = {
  128, 128, 4,
..........
Remove the static word and to not get warnings when you use the this struct, add:
Code:
extern const struct {
  unsigned int      width;
  unsigned int      height;
  unsigned int      bytes_per_pixel;
  unsigned char    pixel_data[];
} mysprite_img;
In your file (you can also add this extern in a header file).
 
After that you will get a .c file with something similar to this:
Code:
static const struct {
  unsigned int      width;
  unsigned int      height;
  unsigned int      bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
  unsigned char    pixel_data[128 * 128 * 4 + 1];
} mysprite_img = {
  128, 128, 4,
..........
Remove the static word and to not get warnings when you use the this struct, add:
Code:
extern const struct {
  unsigned int      width;
  unsigned int      height;
  unsigned int      bytes_per_pixel;
  unsigned char    pixel_data[];
} mysprite_img;
In your file (you can also add this extern in a header file).

Thanks a lot Cid2mizard & xerpi. I'm finally able to compile with my own images. Xerpi awesome work here.
 
  • Like
Reactions: xerpi
Weird, it may be linearMalloc's fault (returning NULL). I'll take a look asap but maybe it won't be until tomorrow because I'll be very busy today :/
 
  • Like
Reactions: Cid2mizard
I hope not ! Otherwise I have to rework all my tilemaps


Pretty sure it is. The max texture size for newer mobile devices is typically between 1024 and 4096 pixels, so I certainly doubt that the 3DS's is big enough for your texture.
 
Yeah I think this might be the problem, for example the max texture size was 512x512 on the PSP iirc.
 
Yeah I think this might be the problem, for example the max texture size was 512x512 on the PSP iirc.

I can load more than 50 tilemap are therefore more than 1024px just with libctru and it works with ninjhax / 3ds / cia . But if I load with sf2dlib , it blocks ... with 3ds and cia formats but not ninjhax.
 
I can load more than 50 tilemap are therefore more than 1024px just with libctru and it works with ninjhax / 3ds / cia . But if I load with sf2dlib , it blocks ... with 3ds and cia formats but not ninjhax.


The maximum size of a single texture is 1024x1024, not the maximum size of all textures combined. Also, this is a GPU limitation, not a memory limitation. Unless I'm mistaken, your libctru code probably wasn't using hardware rendering.
 
The maximum size of a single texture is 1024x1024, not the maximum size of all textures combined. Also, this is a GPU limitation, not a memory limitation. Unless I'm mistaken, your libctru code probably wasn't using hardware rendering.

It's works on real hardware...
 

Site & Scene News

Popular threads in this forum