Skip to content
Snippets Groups Projects
Kernel.cpp 1.13 KiB
Newer Older
  • Learn to ignore specific revisions
  • BATON Theau's avatar
    BATON Theau committed
    #include "Kernel.hpp"
    
    namespace megu::kernel {
        Kernel::Kernel(Window & window) 
        : _window(window), _pEngine(), _gEngine(window) {
            this->_pEngine.boot(*this);
            this->_gEngine.boot(*this);
        }
    
        Kernel::~Kernel() {
            this->_pEngine.stop(*this);
            this->_pEngine.stop(*this);
        }
    
        void Kernel::step() {
    
            double time = Window::Time();
    
    BATON Theau's avatar
    BATON Theau committed
    
            if(this->_window.isOpen()) {
    
                this->_gEngine.step(*this, time);
                this->_gResolver.resolve(*this, this->_gEngine, time);
    
            this->_pEngine.step(*this, time);
            this->_pResolver.resolve(*this, this->_pEngine, time);
    
        void Kernel::add(Prop * props) {
    
    BATON Theau's avatar
    BATON Theau committed
            this->_props[props->id()] = props;
    
    BATON Theau's avatar
    BATON Theau committed
            auto * pComponent = props->getPhysicComponent();
            if(pComponent != nullptr) {
                this->_pEngine.add(*this, *pComponent);
    
                this->_pResolver.add(*pComponent);
    
    BATON Theau's avatar
    BATON Theau committed
            }
            
            auto * gComponent = props->getGraphicComponent();
            if(gComponent != nullptr) {
                this->_gEngine.add(*this, *gComponent);
    
                this->_gResolver.add(*gComponent);
    
    BATON Theau's avatar
    BATON Theau committed
            }