epic: refactor SDL2_Renderer usage to IRenderer and queued texture rendering

- Updated the testing guide to clarify the testing framework's organization and execution methods, improving user understanding.
- Refactored CMakeLists to include new platform-specific files, ensuring proper integration of the rendering backend.
- Modified main application files to utilize the new IRenderer interface, enhancing flexibility in rendering operations.
- Implemented deferred texture management in various components, allowing for more efficient graphics handling and improved performance.
- Introduced new methods for texture creation and updates, streamlining the rendering process across the application.
- Enhanced logging and error handling in the rendering pipeline to facilitate better debugging and diagnostics.
This commit is contained in:
scawful
2025-10-07 17:15:11 -04:00
parent 9e6f538520
commit 6c331f1fd0
101 changed files with 1401 additions and 2677 deletions

View File

@@ -1,4 +1,5 @@
#include "app/gui/widgets/dungeon_object_emulator_preview.h"
#include "app/gfx/backend/irenderer.h"
#include "app/zelda3/dungeon/room.h"
#include "app/zelda3/dungeon/room_object.h"
@@ -11,23 +12,22 @@ namespace gui {
DungeonObjectEmulatorPreview::DungeonObjectEmulatorPreview() {
snes_instance_ = std::make_unique<emu::Snes>();
object_texture_ = SDL_CreateTexture(core::Renderer::Get().renderer(),
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, 256, 256);
}
DungeonObjectEmulatorPreview::~DungeonObjectEmulatorPreview() {
if (object_texture_) {
SDL_DestroyTexture(object_texture_);
}
// if (object_texture_) {
// renderer_->DestroyTexture(object_texture_);
// }
}
void DungeonObjectEmulatorPreview::Initialize(Rom* rom) {
rom_ = rom;
if (rom_ && rom_->is_loaded()) {
auto rom_data = rom_->vector();
snes_instance_->Init(rom_data);
}
void DungeonObjectEmulatorPreview::Initialize(gfx::IRenderer* renderer, Rom* rom) {
renderer_ = renderer;
rom_ = rom;
snes_instance_ = std::make_unique<emu::Snes>();
std::vector<uint8_t> rom_data = rom->vector();
snes_instance_->Init(rom_data);
// object_texture_ = renderer_->CreateTexture(256, 256);
}
void DungeonObjectEmulatorPreview::Render() {
@@ -286,9 +286,9 @@ void DungeonObjectEmulatorPreview::TriggerEmulatedRender() {
// 15. Get the rendered pixels from PPU
void* pixels = nullptr;
int pitch = 0;
if (SDL_LockTexture(object_texture_, nullptr, &pixels, &pitch) == 0) {
if (renderer_->LockTexture(object_texture_, nullptr, &pixels, &pitch)) {
snes_instance_->SetPixels(static_cast<uint8_t*>(pixels));
SDL_UnlockTexture(object_texture_);
renderer_->UnlockTexture(object_texture_);
}
}