summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp66
1 files changed, 30 insertions, 36 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 900bb11..3876db0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -14,26 +14,26 @@
* limitations under the License.
*/
-#include "candy_gear.h"
-#include "color.h"
-#include "core.h"
-#include "font.h"
-#include "graphic.h"
-#include "key.h"
-#include "log.h"
-#include "palette.h"
-#include "point.h"
-#include "rect.h"
-#include "sound.h"
-#include "sprite.h"
-#include "texture.h"
+#ifdef DEBUG
+#include <iostream>
+#endif
+
+#include "camera.hpp"
+#include "candy_gear.hpp"
+#include "core.hpp"
+#include "key.hpp"
+#include "log.hpp"
+#include "model.hpp"
+#include "model/instance.hpp"
+#include "sound.hpp"
+#include "texture.hpp"
cg_sCore cg_core;
static void handle_error(mrb_state *mrb)
{
mrb_print_error(mrb);
- cg_core.quit_game = SDL_TRUE;
+ cg_core.quit_game = true;
}
int main(int argc, char *argv[])
@@ -41,31 +41,34 @@ int main(int argc, char *argv[])
SDL_Event event;
Uint32 frame_start;
+ // Random numbers
+ random_number_generator.seed(random_seed());
+
mrb_state *mrb = mrb_open();
mrb_value main_obj;
mrb_sym sym_init, sym_key_down, sym_key_up, sym_quit, sym_tick;
FILE *fp;
- LoaderStack core_loader;
-
cg_core.config_file = argv[1];
- cg_Core_init(&core_loader);
- if(!cg_Core_load(&core_loader)) return 1;
+ try{ cg_sCore::loader.execute(nullptr); }
+ catch(const CommandError &error)
+ {
+#ifdef DEBUG
+ std::cout << error.what() << std::endl;
+#endif
+ return 1;
+ }
if (!mrb) { /* handle error */ }
mrb_define_module(mrb, "CandyGear");
+ cg_camera_init(mrb);
cg_candy_gear_init(mrb);
- cg_color_init(mrb);
- cg_font_init(mrb);
- cg_graphic_init(mrb);
cg_key_init(mrb);
cg_log_init(mrb);
- cg_palette_init(mrb);
- cg_point_init(mrb);
- cg_rect_init(mrb);
+ cg_model_init(mrb);
+ cg_model_instance_init(mrb);
cg_sound_init(mrb);
- cg_sprite_init(mrb);
cg_texture_init(mrb);
main_obj = mrb_obj_iv_inspect(mrb, mrb->top_self);
@@ -118,19 +121,10 @@ int main(int argc, char *argv[])
}
}
- // Clear buffer.
- SDL_SetRenderDrawColor(cg_core.renderer, 0x00, 0x00, 0x00, 0xff);
- SDL_RenderClear(cg_core.renderer);
-
mrb_funcall_id(mrb, main_obj, sym_tick, 0);
if (mrb->exc) handle_error(mrb);
- // Copy buffer to the screen and display it.
- SDL_SetRenderTarget(cg_core.renderer, NULL);
- SDL_RenderCopy(
- cg_core.renderer, cg_core.pre_screen_buffer, NULL, &cg_core.screen_rect);
- SDL_RenderPresent(cg_core.renderer);
- SDL_SetRenderTarget(cg_core.renderer, cg_core.pre_screen_buffer);
+ cg_core.vk_graphics_pipeline->draw();
// Timer
{
@@ -148,7 +142,7 @@ int main(int argc, char *argv[])
}
mrb_close(mrb);
- cg_Core_unload(&core_loader);
+ cg_sCore::loader.revert(nullptr);
return 0;
}