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

  • Thread starter Thread starter xerpi
  • Start date Start date
  • Views Views 97,229
  • Replies Replies 501
  • Likes Likes 32
Sorry for double post, but it's another (noob?) question this time, so I wanted to separate it from my reply.

How do I create a texture on VRAM? When I use sf2d_create_texture_mem_RGBA8 I can set the place of allocation to SF2D_PLACE_VRAM instead of SF2D_PLACE_RAM, but it freezes/crashes the program.
Are you writing to the texture after placing it in VRAM? The ARM CPU can't access VRAM directly, you have to request a DMA transfer through the GX engine to move data from main memory to VRAM and vice versa.
 
Are you writing to the texture after placing it in VRAM? The ARM CPU can't access VRAM directly, you have to request a DMA transfer through the GX engine to move data from main memory to VRAM and vice versa.

You got me! I was trying to make some pixels transparent :P How can I move the texture from RAM to VRAM and vice versa?
 
You got me! I was trying to make some pixels transparent :P How can I move the texture from RAM to VRAM and vice versa?
You have to call GX_RequestDma(u32 *src, u32 *dst, u32 len) then wait for the DMA event. However, ctrulib's GX_RequestDma doesn't set the flush cache bit for the request so it will often transfer broken bits of texture that weren't flush from the cache to main memory (I've set the bit for VRAM textures in Caelina). So, you may want to implement a DMA+flush request or just modify your texture before you send it to VRAM with sf2dlib.
 
thanks for the work, this is very helpful!
and, @xerpi - is your 3ds sdl port ready/finished/useable? (and how about your vita port?)
i want to port a game that uses sdl to 3ds, but @nop90 said there was some problems last time they tested, and used this lib and your others instead of sdl.
:)
 
Last edited by cearp,
Does color transparency work with this library? I ask this because I loaded an image with transparency using sf2dlib and sfillib, and in my program, the image showed white where it should have been transparent.
 
Does color transparency work with this library? I ask this because I loaded an image with transparency using sf2dlib and sfillib, and in my program, the image showed white where it should have been transparent.
yes transparency does work. i'm not sure about with images but i guess so, i don't see why not.
 
Does color transparency work with this library? I ask this because I loaded an image with transparency using sf2dlib and sfillib, and in my program, the image showed white where it should have been transparent.

Yes, I don't think there's even a way to turn off transparency :S

Edit: ninja'd :P gg wp :ninja:
 
Thanks, guys, for the quick reply. Guess I'm going to have to look for a workaround.

It may be stupid, but have you tried sf2d_draw_texture_blend? I never looked into replacing sf2d_draw_texture_blend with sf2d_draw_texture (since Jan. 26), but it's worth a try :P
 
It may be stupid, but have you tried sf2d_draw_texture_blend? I never looked into replacing sf2d_draw_texture_blend with sf2d_draw_texture (since Jan. 26), but it's worth a try :P

Tried blending with black, made it completely invisible against my background. :/
 
Tried blending with black, made it completely invisible against my background. :/

C:
void drawicona(u8* buf, IIcon icon, s16 x, s16 y, u8 a)
{
  sf2d_draw_texture_blend(icon.img, x, 240 - (y + icon.h), 0x00FFFFFF | (a << 24));
}

Don't worry about the other arguments, just see the last argument :P a==0 means the image is invisible, a==0xFF means the image is drawn without any transparency :D
 
It's a JPEG.

Well, I think that's your problem then :P I don't think JPEG supports transparency :/ Try png, it's lossless :P

Edit: yes, JPEG doesn't support transparency AT ALL! Why are people using JPEG nowdays anyways? It's lossy and doesn't support transparency!
Convert your image to png, it's lossless, and it supports transparency :D
 
Last edited by Sono,
Well, I think that's your problem then :P I don't think JPEG supports transparency :/ Try png, it's lossless :P

Edit: yes, JPEG doesn't support transparency AT ALL! Why are people using JPEG nowdays anyways? It's lossy and doesn't support transparency!
Convert your image to png, it's lossless, and it supports transparency :D

Nope, converted to PNG, still there.
 
Hey, I'm having some trouble compiling applications that use SF2D.

I have updated Citro3D and libctru to their most recent versions, and it appears that everything should be fine. However, when I try to compile an app, say, the sample included with libsf2d, I get one error:

"Undefined reference to C3D_SafeDisplayTransfer."

My LIBS section of the makefile looks like this:

LIBS := -lsf2d -lcitro3d -lctru -lm​

If I get rid of-lcitro3d, the issue gets worse, with everything having to do with Citro3D giving the undefined error. I'm just at a loss as to what to do, since the chain of #includes should mean that the compiler can find C3D_SafeDisplayTransfer. It can find everything else.

Does anyone have any suggestions?
 

Site & Scene News

Popular threads in this forum