Skip to content

Commit

Permalink
safe guard code + make internal private
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Feb 24, 2024
1 parent 639249b commit 7dbbebf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
14 changes: 12 additions & 2 deletions package/cpp/core/RendererWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ void RendererWrapper::loadHybridMethods() {
}

bool RendererWrapper::beginFrame(std::shared_ptr<SwapChainWrapper> swapChain, double frameTimeNanos) {
return _renderer->beginFrame(swapChain->getSwapChain().get(), frameTimeNanos);
if (swapChain->getSwapChain() == nullptr) {
throw std::runtime_error("SwapChain is null");
}

SwapChain* swapChainPtr = swapChain->getSwapChain().get();
return _renderer->beginFrame(swapChainPtr, frameTimeNanos);
}
void RendererWrapper::render(std::shared_ptr<ViewWrapper> view) {
_renderer->render(view->getView().get());
if (view->getView() == nullptr) {
throw std::runtime_error("View is null");
}

View* viewPtr = view->getView().get();
_renderer->render(viewPtr);
}
void RendererWrapper::endFrame() {
_renderer->endFrame();
Expand Down
2 changes: 1 addition & 1 deletion package/cpp/core/SceneWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ void margelo::SceneWrapper::loadHybridMethods() {
}

void margelo::SceneWrapper::addEntity(std::shared_ptr<EntityWrapper> entity) {
_scene->addEntity(entity->entity);
_scene->addEntity(entity->getEntity());
}
2 changes: 1 addition & 1 deletion package/cpp/core/ViewWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace filament;

class ViewWrapper : public HybridObject {
public:
explicit ViewWrapper(const std::shared_ptr<View>& view) : _view(std::move(view)) {}
explicit ViewWrapper(std::shared_ptr<View> view) : _view(view) {}

void loadHybridMethods() override;

Expand Down
9 changes: 7 additions & 2 deletions package/cpp/core/utils/EntityWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ using namespace utils;

class EntityWrapper : public HybridObject {
public:
explicit EntityWrapper(Entity entity) : entity(entity) {}
explicit EntityWrapper(Entity entity) : _entity(entity) {}

void loadHybridMethods() override;

Entity entity;
const Entity& getEntity() {
return _entity;
}

private:
Entity _entity;
};
} // namespace margelo

0 comments on commit 7dbbebf

Please sign in to comment.