Browse Source

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

master
Riyyi 2 years ago
parent
commit
900dbde54b
  1. 11
      assets/scene/scene1.json
  2. 15
      src/ppu.cpp

11
assets/scene/scene1.json

@ -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 ]
}
]
} }

15
src/ppu.cpp

@ -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()
{ {
} }

Loading…
Cancel
Save