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,447
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,447
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
  • Veho @ Veho:
    Before a hit they're like zombies, persistent but slow.
    +1
  • Veho @ Veho:
    It's a tradeoff.
    +1
  • The Real Jdbye @ The Real Jdbye:
    no i mean, before a hit is after the previous hit
    +1
  • The Real Jdbye @ The Real Jdbye:
    if you keep them well enough fed, it's the same thing
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    By the power of Florida Man, I have the power!!! *Lifts up meth pipe* Meth Man!!! lol
  • BakerMan @ BakerMan:
    Guys, I just learned my little brother is in the hospital because he had a seizure last night.
  • cearp @ cearp:
    Sorry to hear that BakerMan
    +2
  • BakerMan @ BakerMan:
    Just found out he's doing alright, doing a lot of complaining too, rightfully so. Who wouldn't complain after having a seizure and being hospitalized?
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    Glad he is OK and complaining is cool :)
    +1
  • K3Nv2 @ K3Nv2:
    Yeah been there had that no fun
    +1
  • K3Nv2 @ K3Nv2:
    They'll give him sleep studies eegs and possibly one week hospital stay
    +1
  • BakerMan @ BakerMan:
    I hope it's not a week.
  • K3Nv2 @ K3Nv2:
    It's standard so doctors can get a idea about what's going on
  • BakerMan @ BakerMan:
    understood
  • BakerMan @ BakerMan:
    well, i'm glad he seems to be doing fine, and ig i'm going to start spewing goofy shit again
  • BakerMan @ BakerMan:
    Update: Turns out he's epileptic
  • K3Nv2 @ K3Nv2:
    Get a 2nd opinion run mris etc they told me that also
  • Psionic Roshambo @ Psionic Roshambo:
    Also a food allergy study would be a good idea
  • K3Nv2 @ K3Nv2:
    Turns out you can't sprinkle methamphetamine on McDonald's French fries
    +1
  • ZeroT21 @ ZeroT21:
    they wouldn't be called french fries at that point
    +1
  • ZeroT21 @ ZeroT21:
    Probably just meth fries
    +1
  • K3Nv2 @ K3Nv2:
    White fries hold up
    +1
  • The Real Jdbye @ The Real Jdbye:
    @K3Nv2 sure you can
    The Real Jdbye @ The Real Jdbye: @K3Nv2 sure you can