ALL OBEY XERPI!I have updated some libraries to the latest versions, also I've finally uploaded the precompiled portlibs for both Linux and Windows here: https://github.com/xerpi/3ds_portlibs/releases/tag/1
Just download your version and unzip it to the devkitpro folder, easy as pie.
I'm encountering a problem: i succesfully compile and run the sample of SFTDLIB on Citra but on my 3ds it gets stuck on a yellow bottom screen and white top screen. The 3ds doesn't get stuck when it reaches sftd_init(), the program just doesn't start at all if any function of sftd is called into the code. Nothing is wrong with my enviroment and with my sf2dlib installation because i can succesfully compile and run sf2dlib samples on my 3ds. i just don't know where to start.
o3ds with ninjhax 2.5 launched through themehax2, latest ctrulib, sf2dlib and sftdlib from the master branch. It happens indifferently with pre-compiled and compiled portlib. Note that i compiled my code on two different enviroments (windows and linux) and it happened in any case. Any idea?
i will try but i'm not confident it will work as the problem occurs with sftdlib and not with sf2dlib.
I mean: the program starts and runs normally if i draw a regular texture
It's working here (I've tried with 3dslink). Try updating the Homebrew Launcher version to the latest.These are the binaries generated by compiling the sample. I even edited the struct accordingly to the post and makeinstalled sf2dlib and sftdlib all over again. No results.
Does it looks like that running on hardware too?Are there any tricks or online resources for improving draw speeds?
I'm trying to draw a large quantity of circles/squares/textures but it it's killing the performance. I think I might be going about this wrong, but I'm just not sure where to look for more information.
I made an example program for testing this with 1500 circles/squares.
https://github.com/Fittings/CircleRenderTest3DS#circlerendertest3ds
This is just calling draw_fill_circle on each circle on each cycle.
Cheers.
Does it looks like that running on hardware too?
Well, there are ways to improve speed, but none currently compatible with sf2dlib afaik.
Easy way: You could make your own vertex array and include all objects, making only one draw call. Still requires a lot of CPU to generate the array and calculate positioning, but less time and less redundant calls.
Hard way: If everything drawn is relatively identical, using a geometry shader would probably be best. Instead of passingwill process this stuff faster than CPU. But shader scripts aren't the easiest thing to write, I probably all vertices calculated yourself, you can essentially pass one "vertex" per object and have the shader generate the object vertices around it. You could even pass color or partial texcoords with the position to get variation. I haven't tested, but you can probably be sure that the shader/GPU wouldn't bother if you're using trig functions, maybe just use predefined trig values in shader constants or something.
The concepts are the same if you want to learn about geometry shaders or shaders in general. And the concepts around vertices are the same too. The scripting languages are obviously different.Thanks, this is a great response.
At the moment I'm at square one with understanding how shaders work. This is a bit over my head at the moment, but it gives me a good starting point for things to read up on.,
Is this similar enough to openGL that I should be checking for info on openGL topics?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <3ds.h>
#include <sf2d.h>
#include <sfil.h>
#include <sftd.h>
#include "FreeSans_ttf.h"
#include "citra_jpeg.h"
#include "3dbrew_png.h"
int main()
{
// Set the random seed based on the time
srand(time(NULL));
sf2d_init();
sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
sf2d_texture *tex1 = sfil_load_JPEG_buffer(citra_jpeg, citra_jpeg_size, SF2D_PLACE_RAM);
sf2d_texture *tex2 = sfil_load_PNG_buffer(_3dbrew_png, SF2D_PLACE_RAM);
sftd_init();
sftd_font *font = sftd_load_font_mem(FreeSans_ttf, FreeSans_ttf_size);
u32 held;
while (aptMainLoop()) {
hidScanInput();
held = hidKeysHeld();
if (held & KEY_START) {
break;
}
sf2d_start_frame(GFX_TOP, GFX_LEFT);
sftd_draw_textf(font, 10, 10, RGBA8(0, 255, 0, 255), 20, "FPS %f", sf2d_get_fps());
sf2d_draw_texture(tex1, 400/2 - tex1->width/2, 240/2 - tex1->height/2);
sf2d_end_frame();
sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
sf2d_draw_texture(tex2, 320/2 - tex2->width/2, 240/2 - tex2->height/2);
sf2d_end_frame();
sf2d_swapbuffers();
}
sftd_free_font(font);
sftd_fini();
sf2d_free_texture(tex1);
sf2d_free_texture(tex2);
sf2d_fini();
return 0;
}
I have a problem with sftdlib.
When i try to draw an image or something other, into the same frame, i want to draw text in, it will compile correctly, but if i start the homebrew, i get just black screen. But if i draw only text to the top screen, and an image to the bottom one, it works flawlessly. Any help?
Code:#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <3ds.h> #include <sf2d.h> #include <sfil.h> #include <sftd.h> #include "FreeSans_ttf.h" #include "citra_jpeg.h" #include "3dbrew_png.h" int main() { // Set the random seed based on the time srand(time(NULL)); sf2d_init(); sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF)); sf2d_texture *tex1 = sfil_load_JPEG_buffer(citra_jpeg, citra_jpeg_size, SF2D_PLACE_RAM); sf2d_texture *tex2 = sfil_load_PNG_buffer(_3dbrew_png, SF2D_PLACE_RAM); sftd_init(); sftd_font *font = sftd_load_font_mem(FreeSans_ttf, FreeSans_ttf_size); u32 held; while (aptMainLoop()) { hidScanInput(); held = hidKeysHeld(); if (held & KEY_START) { break; } sf2d_start_frame(GFX_TOP, GFX_LEFT); sftd_draw_textf(font, 10, 10, RGBA8(0, 255, 0, 255), 20, "FPS %f", sf2d_get_fps()); sf2d_draw_texture(tex1, 400/2 - tex1->width/2, 240/2 - tex1->height/2); sf2d_end_frame(); sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); sf2d_draw_texture(tex2, 320/2 - tex2->width/2, 240/2 - tex2->height/2); sf2d_end_frame(); sf2d_swapbuffers(); } sftd_free_font(font); sftd_fini(); sf2d_free_texture(tex1); sf2d_free_texture(tex2); sf2d_fini(); return 0; }
No, i call sf2d_init(); once and then i call sftd_init(); like in the sftd sample. If i remove sftd_init(); it doesn't work anymore (obviously). But still thanks for your help.You are calling sf2d_init(); two times here, try removing the second sf2d_init(); call.
True, sorry I misread it. Can you better explain the problem or link a zip of the code?No, i call sf2d_init(); once and then i call sftd_init(); like in the sftd sample. If i remove sftd_init(); it doesn't work anymore (obviously). But still thanks for your help.
Try changing the init and fini commands on their place, like this:I have a problem with sftdlib.
When i try to draw an image or something other, into the same frame, i want to draw text in, it will compile correctly, but if i start the homebrew, i get just black screen. But if i draw only text to the top screen, and an image to the bottom one, it works flawlessly. Any help?
Code:#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <math.h> #include <3ds.h> #include <sf2d.h> #include <sfil.h> #include <sftd.h> #include "FreeSans_ttf.h" #include "citra_jpeg.h" #include "3dbrew_png.h" int main() { // Set the random seed based on the time srand(time(NULL)); sf2d_init(); sf2d_set_vblank_wait(0); sftd_init(); sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF)); sf2d_texture *tex1 = sfil_load_JPEG_buffer(citra_jpeg, citra_jpeg_size, SF2D_PLACE_RAM); sf2d_texture *tex2 = sfil_load_PNG_buffer(_3dbrew_png, SF2D_PLACE_RAM); sftd_font *font = sftd_load_font_mem(FreeSans_ttf, FreeSans_ttf_size); u32 held; while (aptMainLoop()) { hidScanInput(); held = hidKeysHeld(); if (held & KEY_START) { break; } sf2d_start_frame(GFX_TOP, GFX_LEFT); sftd_draw_textf(font, 10, 10, RGBA8(0, 255, 0, 255), 20, "FPS %f", sf2d_get_fps()); sf2d_draw_texture(tex1, 400/2 - tex1->width/2, 240/2 - tex1->height/2); sf2d_end_frame(); sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); sf2d_draw_texture(tex2, 320/2 - tex2->width/2, 240/2 - tex2->height/2); sf2d_end_frame(); sf2d_swapbuffers(); } sftd_free_font(font); sftd_fini(); sf2d_free_texture(tex1); sf2d_free_texture(tex2); sf2d_fini(); return 0; }
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <3ds.h>
#include <sf2d.h>
#include <sfil.h>
#include <sftd.h>
#include "FreeSans_ttf.h"
#include "citra_jpeg.h"
#include "3dbrew_png.h"
int main()
{
// Set the random seed based on the time
srand(time(NULL));
sf2d_init();
sftd_init();
sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
sf2d_texture *tex1 = sfil_load_JPEG_buffer(citra_jpeg, citra_jpeg_size, SF2D_PLACE_RAM);
sf2d_texture *tex2 = sfil_load_PNG_buffer(_3dbrew_png, SF2D_PLACE_RAM);
sftd_font *font = sftd_load_font_mem(FreeSans_ttf, FreeSans_ttf_size);
u32 held;
while (aptMainLoop()) {
hidScanInput();
held = hidKeysHeld();
if (held & KEY_START) {
break;
}
sf2d_start_frame(GFX_TOP, GFX_LEFT);
sftd_draw_textf(font, 10, 10, RGBA8(0, 255, 0, 255), 20, "FPS %f", sf2d_get_fps());
sf2d_draw_texture(tex1, 400/2 - tex1->width/2, 240/2 - tex1->height/2);
sf2d_end_frame();
sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
sf2d_draw_texture(tex2, 320/2 - tex2->width/2, 240/2 - tex2->height/2);
sf2d_end_frame();
sf2d_swapbuffers();
}
sf2d_free_texture(tex1);
sf2d_free_texture(tex2);
sftd_free_font(font);
sf2d_fini();
sftd_fini();
return 0;
}