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

  • Thread starter Thread starter xerpi
  • Start date Start date
  • Views Views 97,199
  • Replies Replies 501
  • Likes Likes 32
Don't textures have sized at a power of 2 anyways?

Cid2mizard, why not post a code sample of how you're loading/displaying the textures when it works with ctrulib, that might help solve some of the confusion.
 
Don't textures have sized at a power of 2 anyways?

Cid2mizard, why not post a code sample of how you're loading/displaying the textures when it works with ctrulib, that might help solve some of the confusion.
The sizes of the textures don't matter any more. The GPU doesn't render sprites but triangles with the textures on them.
 
The sizes of the textures don't matter any more. The GPU doesn't render sprites but triangles with the textures on them.

Yeah, last I checked the height and width of textures on modern GPUs was supposed to be a power of two. Unless they decided to change that and I didn't get the memo.
 
Don't textures have sized at a power of 2 anyways?

Cid2mizard, why not post a code sample of how you're loading/displaying the textures when it works with ctrulib, that might help solve some of the confusion.


Ok you can find Dawnlike 3DS source code with 50 tilemap and the big (floor.bin) 7184*16, compil and works on emu and hardware with only ctrulib...

http://3ds.nintendomax.com/CID/DawnLike_3DS_src.rar

Again , the code is not optimized , sorry if it stings the eyes ... I post the sources for getting things done ...
 
Yeah, I'm pretty sure that renders directly to the framebuffer by setting the individual pixels of the framebuffer accordingly, so the size of the image wouldn't be that much of an issue.

sf2dlib uses the actual GPU to render things to the framebuffer. I think you're going to have to re-work your tilemaps.
 
Ok you can find Dawnlike 3DS source code with 50 tilemap and the big (floor.bin) 7184*16, compil and works on emu and hardware with only ctrulib...

http://3ds.nintendomax.com/CID/DawnLike_3DS_src.rar

Again , the code is not optimized , sorry if it stings the eyes ... I post the sources for getting things done ...
the short answer is if you dont want to use smaller textures then you can't use this lib. the gpu can't handle large textures, it's only possible using 'software drawing' ie. writing the pixels of the screen manually.

Also I have a request: I am trying to port my framework that sits on top of a different lib to the 3ds using your code. But the other lib supports texture repeating. A sprite in it is just a subrect inside of a texture, and making the sprite twice as wide as the texture would show the texture repeated when the sprite is drawn. This is particularly useful for GUI code. Would it be possible to support this?
 
  • Like
Reactions: xerpi
the short answer is if you dont want to use smaller textures then you can't use this lib. the gpu can't handle large textures, it's only possible using 'software drawing' ie. writing the pixels of the screen manually.

Also I have a request: I am trying to port my framework that sits on top of a different lib to the 3ds using your code. But the other lib supports texture repeating. A sprite in it is just a subrect inside of a texture, and making the sprite twice as wide as the texture would show the texture repeated when the sprite is drawn. This is particularly useful for GUI code. Would it be possible to support this?


It should be possible, there's a constant in ctrulib for configuring textures to repeat: https://github.com/smealum/ctrulib/blob/master/libctru/include/3ds/gpu/gpu.h#L45
 
  • Like
Reactions: Margen67
the short answer is if you dont want to use smaller textures then you can't use this lib. the gpu can't handle large textures, it's only possible using 'software drawing' ie. writing the pixels of the screen manually.

Also I have a request: I am trying to port my framework that sits on top of a different lib to the 3ds using your code. But the other lib supports texture repeating. A sprite in it is just a subrect inside of a texture, and making the sprite twice as wide as the texture would show the texture repeated when the sprite is drawn. This is particularly useful for GUI code. Would it be possible to support this?

Yeah, I'll add support for that very soon!
 
Team

im new and im still learning, but i was finally able to code something that i like. I ported Non-Stop Nyan Cat using LIBSF2D. Thanks xerpi for the lib.


Download
https://www.dropbox.com/s/e400my3xm0zw74r/nyan_cat.zip?dl=0



jF5ixat.png
 
anyone have an example of loading an RGB binary file off the SD card into memory and using it as a texture or am I going to have to make .c files of all my textures?
 
  • Like
Reactions: xerpi
Alright, I've ported my image loading code from the YA2D PSP library to sf2d. This new library is called libsfil (Simple and Fast Image Loading)

API:
Code:
sf2d_texture *sfil_load_PNG_file(const char *filename, sf2d_place place);
sf2d_texture *sfil_load_PNG_buffer(const void *buffer, sf2d_place place);
 
sf2d_texture *sfil_load_JPEG_file(const char *filename, sf2d_place place);
sf2d_texture *sfil_load_JPEG_buffer(const void *buffer, unsigned long buffer_size, sf2d_place place);
 
sf2d_texture *sfil_load_BMP_file(const char *filename, sf2d_place place);
sf2d_texture *sfil_load_BMP_buffer(const void *buffer, sf2d_place place);

Source: https://github.com/xerpi/sfillib
 
Alright, I've ported my image loading code from the YA2D PSP library to sf2d. This new library is called libsfil (Simple and Fast Image Loading)

API:
Code:
sf2d_texture *sfil_load_PNG_file(const char *filename, sf2d_place place);
sf2d_texture *sfil_load_PNG_buffer(const void *buffer, sf2d_place place);
 
sf2d_texture *sfil_load_JPEG_file(const char *filename, sf2d_place place);
sf2d_texture *sfil_load_JPEG_buffer(const void *buffer, unsigned long buffer_size, sf2d_place place);
 
sf2d_texture *sfil_load_BMP_file(const char *filename, sf2d_place place);
sf2d_texture *sfil_load_BMP_buffer(const void *buffer, sf2d_place place);

Source: https://github.com/xerpi/sfillib

Great will integrate that into 3DS_UI's uiImage :)
 

Site & Scene News

Popular threads in this forum