sf2dlib
sf2dlib copied to clipboard
Calling "sf2d_fill_texture_from_RGBA8" more then once corrupts the texture content
This doesn't work:
// Called once
main_texture = sf2d_create_texture(width, height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
// Called each frame
sf2d_fill_texture_from_RGBA8(main_texture, pixels, width, height);
sf2d_start_frame(GFX_TOP, GFX_LEFT);
// This renders garbage starting from the 2nd frame
sf2d_draw_texture(main_texture, 40, 0);
sf2d_end_frame();
sf2d_swapbuffers();
This works but is slower due to the memory alloc each frame:
// Called each frame
main_texture = sf2d_create_texture_mem_RGBA8(pixels, width, height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
sf2d_start_frame(GFX_TOP, GFX_LEFT);
sf2d_draw_texture(main_texture, 40, 0);
sf2d_end_frame();
sf2d_free_texture(main_texture);
sf2d_swapbuffers();
Can this be fixed? A use case is when some graphic manipulation is done via the CPU (and the texture uploaded each frame)
I think the problem is that the texture needs to be tiled after sf2d_fill_texture_from_RGBA8.