Emulator: Set camera zoom-level and screen flip in scene JSON

This commit is contained in:
Riyyi
2022-10-16 12:47:21 +02:00
parent 16db21fcab
commit 900dbde54b
2 changed files with 12 additions and 14 deletions
+9 -2
View File
@@ -4,6 +4,13 @@
"translate": [ 0.0, 0.0, -1.0 ], "translate": [ 0.0, 0.0, -1.0 ],
"rotate": [ 0.0, 0.0, 0.0 ], "rotate": [ 0.0, 0.0, 0.0 ],
"scale": [ 1.0, 1.0, 1.0 ], "scale": [ 1.0, 1.0, 1.0 ],
"type": "orthographic" "type": "orthographic",
} "zoom-level": 0.45
},
"quad" : [
{
"name": "Screen",
"scale": [ 1.0, -0.9, 1.0 ]
}
]
} }
+3 -12
View File
@@ -20,25 +20,16 @@
#include "ppu.h" #include "ppu.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
PPU ::PPU(uint32_t frequency) PPU::PPU(uint32_t frequency)
: ProcessingUnit(frequency) : ProcessingUnit(frequency)
{ {
m_shared_registers.emplace("LY", &m_lcd_y_coordinate); m_shared_registers.emplace("LY", &m_lcd_y_coordinate);
// Setup screen
auto& scene = Inferno::Application::the().scene(); auto& scene = Inferno::Application::the().scene();
m_entity = scene.createEntity("Screen"); m_entity = scene.findEntity("Screen");
// Flip the screen to accommodate OpenGL's coordinate system
auto& transform = scene.getComponent<Inferno::TransformComponent>(m_entity);
transform.scale.y = -1.0f;
auto texture = std::make_shared<Inferno::Texture>(m_screen.data(), SCREEN_WIDTH, SCREEN_HEIGHT, FORMAT_SIZE);
scene.addComponent<Inferno::SpriteComponent>(m_entity, glm::vec4 { 1.0f }, texture);
} }
PPU ::~PPU() PPU::~PPU()
{ {
} }