qmlfrontend/engine_instance.cpp
author unc0rr
Sun, 25 Nov 2018 22:32:49 +0100
changeset 14315 21be7838a127
parent 14311 92e5682810d4
child 14319 00b56ec8b7df
permissions -rw-r--r--
Add advance_simulation() function to engine lib, some WIP on frontend

#include "engine_instance.h"

extern "C" void (*getProcAddress())(const char* fn) { return nullptr; }

EngineInstance::EngineInstance(QObject* parent)
    : QObject(parent), m_instance(Engine::start_engine()) {}

EngineInstance::~EngineInstance() { Engine::cleanup(m_instance); }

void EngineInstance::sendConfig(const GameConfig& config) {
  for (auto b : config.config()) {
    Engine::send_ipc(m_instance, reinterpret_cast<uint8_t*>(b.data()),
                     static_cast<size_t>(b.size()));
  }
}

void EngineInstance::advance(quint32 ticks) {}

void EngineInstance::renderFrame() {}

void EngineInstance::setOpenGLContext(QOpenGLContext* context) {
  Engine::setup_current_gl_context(m_instance, 0, 0, &getProcAddress);
}

Engine::PreviewInfo EngineInstance::generatePreview() {
  Engine::PreviewInfo pinfo;

  Engine::generate_preview(m_instance, &pinfo);

  return pinfo;
}