renderiranje - nazaj na singlethreaded ker me SDL ne mara :(

This commit is contained in:
2026-03-11 20:19:15 +01:00
parent d748ca63a0
commit 834f0b29c3
18 changed files with 230 additions and 75 deletions

View File

@@ -1,7 +1,7 @@
#pragma once
#include <shared_mutex>
#include <vector>
#include <memory>
#include <utils.hpp>
#include <object/entity.hpp>
@@ -10,15 +10,14 @@ namespace Game::State {
public:
static GameState& getInstance() { static GameState instance; return instance; }
// Retrieve a COPY of the entities - Only used by renderer, use getAtIndex() for generic access
const std::vector<Object::Entity>& getEntities();
// Retrieve a REFERENCE of the entities; DANGEROUS!
std::vector<Object::Entity>* getEntitiesRef();
std::vector<std::unique_ptr<Object::Entity>>* getEntitiesRef();
// Update entity at index, by REFERENCE
Object::Entity* getAtIndex(size_t at);
void addEntity(std::unique_ptr<Object::Entity> entity);
private:
mutable std::shared_mutex mMutex;
std::vector<Object::Entity> mEntities;
std::vector<std::unique_ptr<Object::Entity>> mEntities;
};
}