Begin the documentation
This commit is contained in:
@ -12,12 +12,27 @@ namespace Dawn {
|
|||||||
class RenderManager {
|
class RenderManager {
|
||||||
public:
|
public:
|
||||||
std::weak_ptr<DawnGame> game;
|
std::weak_ptr<DawnGame> game;
|
||||||
|
|
||||||
RenderManager(std::weak_ptr<DawnGame>);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new RenderManager for a game instance.
|
||||||
|
*
|
||||||
|
* @param game Game instance this render manager belongs to.
|
||||||
|
*/
|
||||||
|
RenderManager(std::weak_ptr<DawnGame> game);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize this render manager.
|
||||||
|
*/
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a synchronous frame update on the render manager.
|
||||||
|
*/
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy a previously initialized RenderManager.
|
||||||
|
*/
|
||||||
~RenderManager();
|
~RenderManager();
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -9,6 +9,11 @@
|
|||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
class TriangleMesh {
|
class TriangleMesh {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Initializes a mesh to hold a single triangle.
|
||||||
|
*
|
||||||
|
* @param mesh Mesh to initialize as a triangle.
|
||||||
|
*/
|
||||||
static void createTriangleMesh(std::shared_ptr<Mesh> mesh);
|
static void createTriangleMesh(std::shared_ptr<Mesh> mesh);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -25,11 +25,40 @@ namespace Dawn {
|
|||||||
public:
|
public:
|
||||||
RenderManager renderManager;
|
RenderManager renderManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new instance of the DawnGame.
|
||||||
|
*
|
||||||
|
* @param host Weak pointer to the host that is running this game.
|
||||||
|
*/
|
||||||
DawnGame(std::weak_ptr<DawnHost> host);
|
DawnGame(std::weak_ptr<DawnHost> host);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the game. This is performed by the host at a time that is
|
||||||
|
* deemed to have the host ready for the game's initialization. This will
|
||||||
|
* return an initialize result, where DAWN_GAME_INIT_RESULT_SUCCESS is
|
||||||
|
* the only "successful" result, anything else is deemed a failure state.
|
||||||
|
*
|
||||||
|
* @return The game initialize result.
|
||||||
|
*/
|
||||||
int32_t init();
|
int32_t init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a game update operation. This operation should occur exactly
|
||||||
|
* once per frame, synchronously on the main thread. Updates can only
|
||||||
|
* have two valid exit results, either DAWN_GAME_UPDATE_RESULT_SUCCESS for
|
||||||
|
* a successful update, and request that we continue to update, or
|
||||||
|
* DAWN_GAME_UPDATE_RESULT_EXIT for a successful update but to request
|
||||||
|
* that no more update operations occur. Any other result is considered a
|
||||||
|
* failure state.
|
||||||
|
*
|
||||||
|
* @param delta Time delta to tick the game by.
|
||||||
|
* @return The game update result.
|
||||||
|
*/
|
||||||
int32_t update(float_t delta);
|
int32_t update(float_t delta);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup the memory of the DawnGame instance.
|
||||||
|
*/
|
||||||
~DawnGame();
|
~DawnGame();
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -35,10 +35,6 @@ std::shared_ptr<SceneItem> Scene::createSceneItem() {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::removeSceneItem(SceneItem *item) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Scene::~Scene() {
|
Scene::~Scene() {
|
||||||
|
|
||||||
}
|
}
|
@ -20,14 +20,34 @@ namespace Dawn {
|
|||||||
public:
|
public:
|
||||||
std::weak_ptr<DawnGame> game;
|
std::weak_ptr<DawnGame> game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new Scene instance.
|
||||||
|
*
|
||||||
|
* @param game Weak pointer to the game that this scene belongs to.
|
||||||
|
*/
|
||||||
Scene(std::weak_ptr<DawnGame> game);
|
Scene(std::weak_ptr<DawnGame> game);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a one frame synchronous tick on the current scene. This may
|
||||||
|
* change in future to be more event-like.
|
||||||
|
*/
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Scene Item object and add to the current scene.
|
||||||
|
*
|
||||||
|
* @return A shared pointer to the created SceneItem.
|
||||||
|
*/
|
||||||
std::shared_ptr<SceneItem> createSceneItem();
|
std::shared_ptr<SceneItem> createSceneItem();
|
||||||
|
|
||||||
void removeSceneItem(SceneItem *item);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds an existing component on the scene (Root Level Only) that has a
|
||||||
|
* component matching the given component type. Returns nullptr if no item
|
||||||
|
* with the specified component could be found.
|
||||||
|
*
|
||||||
|
* @tparam Component type to look for.
|
||||||
|
* @return Pointer to the found component (and by extension the item).
|
||||||
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
std::shared_ptr<T> findComponent() {
|
std::shared_ptr<T> findComponent() {
|
||||||
auto it = this->items.begin();
|
auto it = this->items.begin();
|
||||||
@ -39,6 +59,9 @@ namespace Dawn {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys a previously initialized Scene.
|
||||||
|
*/
|
||||||
~Scene();
|
~Scene();
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -21,10 +21,31 @@ namespace Dawn {
|
|||||||
std::weak_ptr<Scene> scene;
|
std::weak_ptr<Scene> scene;
|
||||||
sceneitemid_t id;
|
sceneitemid_t id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for a SceneItem. Scene Items should only be called and
|
||||||
|
* initialized by the scene itself.
|
||||||
|
*
|
||||||
|
* @param scene Weak pointer to the Scene that this SceneItem belongs to.
|
||||||
|
* @param id Scene Item ID that the Scene assigned this SceneItem.
|
||||||
|
*/
|
||||||
SceneItem(std::weak_ptr<Scene> scene, sceneitemid_t id);
|
SceneItem(std::weak_ptr<Scene> scene, sceneitemid_t id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the Scene the frame after we were constructed so we can begin
|
||||||
|
* existing.
|
||||||
|
*/
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a component to this scene item. Components will only have their
|
||||||
|
* init methods invoked on the first frame we enter the scene. If you add
|
||||||
|
* a component to this item after this time you will either need to try
|
||||||
|
* manually invoking its' init method, or ensure the component is aware of
|
||||||
|
* the entire SceneItem lifecycle and listen for added callbacks.
|
||||||
|
*
|
||||||
|
* @tparam T Type of component being added to this scene item.
|
||||||
|
* @return A shared pointer to the newly added component.
|
||||||
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
std::shared_ptr<T> addComponent() {
|
std::shared_ptr<T> addComponent() {
|
||||||
auto component = std::make_shared<T>(weak_from_this());
|
auto component = std::make_shared<T>(weak_from_this());
|
||||||
@ -32,6 +53,14 @@ namespace Dawn {
|
|||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a component attached to this SceneItem. This method will return
|
||||||
|
* either a shared pointer to the component, or nullptr if the item does
|
||||||
|
* not have the queried component.
|
||||||
|
*
|
||||||
|
* @tparam T Type of component to be fetched.
|
||||||
|
* @return A shared pointer to the component, or nullptr if not found.
|
||||||
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
std::shared_ptr<T> getComponent() {
|
std::shared_ptr<T> getComponent() {
|
||||||
auto it = this->components.begin();
|
auto it = this->components.begin();
|
||||||
@ -43,6 +72,9 @@ namespace Dawn {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy this SceneItem.
|
||||||
|
*/
|
||||||
~SceneItem();
|
~SceneItem();
|
||||||
};
|
};
|
||||||
}
|
}
|
Reference in New Issue
Block a user