Fixed all my pointers
This commit is contained in:
@ -25,7 +25,7 @@ DawnHost::DawnHost() {
|
||||
this->data->window = nullptr;
|
||||
}
|
||||
|
||||
int32_t DawnHost::init(std::weak_ptr<DawnGame> game) {
|
||||
int32_t DawnHost::init(DawnGame &game) {
|
||||
// Init GLFW
|
||||
if(!glfwInit()) return DAWN_GLFW_INIT_RESULT_INIT_FAILED;
|
||||
|
||||
@ -51,22 +51,18 @@ int32_t DawnHost::init(std::weak_ptr<DawnGame> game) {
|
||||
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
|
||||
|
||||
// Initialize the game
|
||||
if(auto g = game.lock()) {
|
||||
auto result = g->init();
|
||||
if(result != DAWN_GAME_INIT_RESULT_SUCCESS) return result;
|
||||
auto result = game.init();
|
||||
if(result != DAWN_GAME_INIT_RESULT_SUCCESS) return result;
|
||||
|
||||
g->renderManager.renderTarget->setSize(
|
||||
DAWN_GLFW_WINDOW_WIDTH_DEFAULT,
|
||||
DAWN_GLFW_WINDOW_HEIGHT_DEFAULT
|
||||
);
|
||||
} else {
|
||||
return DAWN_GLFW_INIT_RESULT_GAME_LOCK_FAILED;
|
||||
}
|
||||
game.renderManager.backBuffer.setSize(
|
||||
DAWN_GLFW_WINDOW_WIDTH_DEFAULT,
|
||||
DAWN_GLFW_WINDOW_HEIGHT_DEFAULT
|
||||
);
|
||||
|
||||
return DAWN_HOST_INIT_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DawnHost::start(std::weak_ptr<DawnGame> game) {
|
||||
int32_t DawnHost::start(DawnGame &game) {
|
||||
double_t time, newTime;
|
||||
float_t fDelta;
|
||||
int32_t updateResult;
|
||||
@ -99,25 +95,21 @@ int32_t DawnHost::start(std::weak_ptr<DawnGame> game) {
|
||||
return DAWN_HOST_START_RESULT_EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DawnHost::update(std::weak_ptr<DawnGame> game, float_t delta) {
|
||||
if(auto g = game.lock()) {
|
||||
auto ret = g->update(delta);
|
||||
switch(ret) {
|
||||
case DAWN_GAME_UPDATE_RESULT_SUCCESS:
|
||||
return DAWN_HOST_UPDATE_RESULT_SUCCESS;
|
||||
|
||||
case DAWN_GAME_UPDATE_RESULT_EXIT:
|
||||
return DAWN_HOST_UPDATE_RESULT_EXIT;
|
||||
int32_t DawnHost::update(DawnGame &game, float_t delta) {
|
||||
auto ret = game.update(delta);
|
||||
switch(ret) {
|
||||
case DAWN_GAME_UPDATE_RESULT_SUCCESS:
|
||||
return DAWN_HOST_UPDATE_RESULT_SUCCESS;
|
||||
|
||||
case DAWN_GAME_UPDATE_RESULT_EXIT:
|
||||
return DAWN_HOST_UPDATE_RESULT_EXIT;
|
||||
|
||||
default:
|
||||
return ret;
|
||||
}
|
||||
default:
|
||||
return ret;
|
||||
}
|
||||
|
||||
return DAWN_GLFW_UPDATE_RESULT_GAME_LOCK_FAILED;
|
||||
}
|
||||
|
||||
void DawnHost::unload(std::weak_ptr<DawnGame> game) {
|
||||
void DawnHost::unload(DawnGame &game) {
|
||||
glfwDestroyWindow(this->data->window);
|
||||
this->data->window = nullptr;
|
||||
glfwTerminate();
|
||||
|
@ -14,12 +14,9 @@
|
||||
|
||||
#define DAWN_GLFW_INIT_RESULT_INIT_FAILED -1
|
||||
#define DAWN_GLFW_INIT_RESULT_WINDOW_CREATE_FAILED -2
|
||||
#define DAWN_GLFW_INIT_RESULT_GAME_LOCK_FAILED -3
|
||||
|
||||
#define DAWN_GLFW_START_RESULT_UPDATE_FAILED -1
|
||||
|
||||
#define DAWN_GLFW_UPDATE_RESULT_GAME_LOCK_FAILED -1
|
||||
|
||||
namespace Dawn {
|
||||
class DawnHostData {
|
||||
public:
|
||||
|
Reference in New Issue
Block a user