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

filfat

CTO @ Nordcom Group Inc.
Member
Joined
Nov 24, 2012
Messages
1,261
Trophies
1
Location
Gothenburg, Sweden
Website
www.sweetsideofsweden.com
XP
1,749
Country
Sweden
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
 

Cid2mizard

Well-Known Member
Member
Joined
Aug 16, 2007
Messages
401
Trophies
1
Age
43
Location
Maubeuge
XP
2,439
Country
France
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.
 

filfat

CTO @ Nordcom Group Inc.
Member
Joined
Nov 24, 2012
Messages
1,261
Trophies
1
Location
Gothenburg, Sweden
Website
www.sweetsideofsweden.com
XP
1,749
Country
Sweden
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

KingOfHell

Well-Known Member
Newcomer
Joined
Mar 15, 2015
Messages
74
Trophies
0
Age
36
XP
83
Country
United States
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.
 

filfat

CTO @ Nordcom Group Inc.
Member
Joined
Nov 24, 2012
Messages
1,261
Trophies
1
Location
Gothenburg, Sweden
Website
www.sweetsideofsweden.com
XP
1,749
Country
Sweden
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

daxtsu

Well-Known Member
Member
Joined
Jun 9, 2007
Messages
5,627
Trophies
2
XP
5,194
Country
Antarctica
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.
 

Cid2mizard

Well-Known Member
Member
Joined
Aug 16, 2007
Messages
401
Trophies
1
Age
43
Location
Maubeuge
XP
2,439
Country
France
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: 202

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
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

General chit-chat
Help Users
  • No one is chatting at the moment.
    OctoAori20 @ OctoAori20: Nice nice-