diff --git a/compile_linux.sh b/compile_linux.sh index 51a1e44..cb1fef4 100755 --- a/compile_linux.sh +++ b/compile_linux.sh @@ -44,7 +44,7 @@ g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c sfw/application/scene.cpp - g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c sfw/application/window.cpp -o sfw/application/window.o -#g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c game_scene.cpp -o game_scene.o +g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c game_scene.cpp -o game_scene.o g++ -Wall -D_REENTRANT -g -Isfw -Isfw/application -c main.cpp -o main.o diff --git a/game_scene.cpp b/game_scene.cpp index 72d7053..92e4e25 100644 --- a/game_scene.cpp +++ b/game_scene.cpp @@ -2,6 +2,11 @@ #include "application.h" +#include "3rd_glad.h" + +//#include "camera.h" +//#include "sprite.h" + void GameScene::event() { /* switch (ev.type) { @@ -92,16 +97,14 @@ void GameScene::update(float delta) { } void GameScene::render() { - /* - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClearColor(1.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); - camera->bind(); + //camera->bind(); - tile_map->render(); + //tile_map->render(); - sprite->render(); - */ + //sprite->render(); } GameScene::GameScene() { diff --git a/main.cpp b/main.cpp index 1c28865..1b23964 100644 --- a/main.cpp +++ b/main.cpp @@ -3,30 +3,43 @@ #endif // __EMSCRIPTEN__ #include "application.h" +#include "window.h" #include "game_application.h" Application *application = NULL; void handle_frame() { - application->main_loop(); + application->main_loop(); } -int main(int argc, char** argv) -{ - application = new GameApplication(); +int main(int argc, char **argv) { + application = new GameApplication(); - #ifdef __EMSCRIPTEN__ - emscripten_set_main_loop(handle_frame, 0, 1); - #else +#ifdef __EMSCRIPTEN__ + emscripten_set_main_loop(handle_frame, 0, 1); +#else - while (application->running) { - application->main_loop(); - } + //while (application->running) { + // application->main_loop(); + //} - delete application; + AppWindow *w = AppWindow::get_singleton(); - #endif // __EMSCRIPTEN__ + while (application->running) { + if (w->frame_begin()) { + //w->resize(); + //w->render_callback(loopArg); + w->frame_end(); + w->frame_swap(); + } else { + w->shutdown(); + } + } - return 0; + delete application; + +#endif // __EMSCRIPTEN__ + + return 0; } diff --git a/sfw/application/application.h b/sfw/application/application.h index 8c3cb8c..6f1d379 100644 --- a/sfw/application/application.h +++ b/sfw/application/application.h @@ -5,7 +5,7 @@ #include "scene.h" -class Window; +class AppWindow; class Application { public: @@ -23,7 +23,7 @@ public: Scene *scene; - Window *window; + AppWindow *window; static Application *get_singleton(); diff --git a/sfw/application/window.cpp b/sfw/application/window.cpp index eedb925..0d59440 100644 --- a/sfw/application/window.cpp +++ b/sfw/application/window.cpp @@ -27,6 +27,7 @@ #include "stime.h" #include "ustring.h" #include "vector4.h" +#include "application.h" /* static volatile float framerate = 0; @@ -464,6 +465,8 @@ int AppWindow::frame_begin() { //input_update(); + Application::get_singleton()->render(); + return 1; } diff --git a/sfw/application/window.h b/sfw/application/window.h index 5154ec7..827e5ba 100644 --- a/sfw/application/window.h +++ b/sfw/application/window.h @@ -89,6 +89,8 @@ public: void fps_lock(float fps); void fps_unlock(); + void shutdown(); + Vector2 dpi(); enum CURSOR_SHAPES { @@ -119,7 +121,6 @@ protected: static void drop_callback(GLFWwindow *window, int count, const char **paths); static void window_hints(unsigned flags); GLFWmonitor *find_monitor(int wx, int wy); - void shutdown(); void resize(); static void loop_wrapper(void *loopArg); void glNewFrame();