X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMain.cc;h=070912e7ce1a0c7acb8fb7c3e1f75adf6cb151eb;hp=c76a6148bf84abb6a8b48c03f92f1e6de4055185;hb=af88821a172c4dfd138b91b2a5148ae50b502fa2;hpb=1d4aa0d34b0410c7bc60a24bad7abb55eacc850a diff --git a/src/Main.cc b/src/Main.cc index c76a614..070912e 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -26,6 +26,7 @@ inline int isatty(int dummy) { return 0; } #include #include +#include #include #include #include @@ -34,14 +35,12 @@ inline int isatty(int dummy) { return 0; } #include #include -#include "GameLayer.hh" #include "Main.hh" -#include "TitleLayer.hh" #include "version.h" -Main::Main(moof::settings& settings, moof::video& video) : - moof::view(settings, video) +Main::Main(moof::settings& settings) : + moof::application(settings) { moof::dispatcher& dispatcher = moof::dispatcher::global(); video_reloaded_ = dispatcher.add_target("video.newcontext", @@ -58,15 +57,7 @@ Main::Main(moof::settings& settings, moof::video& video) : void Main::update(moof::scalar t, moof::scalar dt) { - if (children().size() == 0) - { - //moof::log_warning("main view has no children"); - //stop(); - //return; - add_child(TitleLayer::alloc()); - } - - moof::view::update(t, dt); + yoink.update(t, dt); } void Main::draw(moof::scalar alpha) const @@ -79,37 +70,41 @@ void Main::draw(moof::scalar alpha) const glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - moof::view::draw(alpha); + yoink.draw(alpha); } -bool Main::handle_event(const moof::event& event) +void Main::handle_event(const moof::event& event) { - if (moof::view::handle_event(event)) return true; + if (yoink.handle_event(event)) return; switch (event.type) { case SDL_KEYUP: + if (event.key.keysym.sym == SDLK_f) { - video().toggle_fullscreen(); + moof::video::current()->toggle_fullscreen(); } else if (event.key.keysym.sym == SDLK_l) { - video().toggle_cursor_captured(); - video().toggle_cursor_visible(); + moof::video::current()->toggle_cursor_captured(); + moof::video::current()->toggle_cursor_visible(); + } + else if (event.key.keysym.sym == SDLK_ESCAPE) + { + stop(); } break; case SDL_VIDEORESIZE: + glViewport(0, 0, event.resize.w, event.resize.h); break; case SDL_QUIT: + stop(); - return true; } - - return false; } @@ -159,7 +154,7 @@ std::string Main::config_paths() void Main::setup_opengl() { - //glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); //glEnable(GL_CULL_FACE); @@ -173,7 +168,7 @@ void Main::setup_opengl() glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.0); - glClearColor(0.0, 0.0, 0.0, 1.0); + glClearColor(1.0, 0.0, 0.0, 1.0); //glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); @@ -269,6 +264,11 @@ void Main::print_info(int argc, char* argv[]) #else print_option("debug", false); #endif +#if ENABLE_DOUBLE_PRECISION + print_option("double", true); +#else + print_option("double", false); +#endif #if WITH_GTK print_option("gtk", true); #else @@ -279,7 +279,7 @@ void Main::print_info(int argc, char* argv[]) #else print_option("hotload", false); #endif -#if PROFILING_ENABLED +#if ENABLE_PROFILING print_option("profile", true); #else print_option("profile", false); @@ -331,7 +331,7 @@ void goodbye() int main(int argc, char* argv[]) { - //moof::backend backend; + moof::backend backend; if (argc > 1) { @@ -361,10 +361,6 @@ int main(int argc, char* argv[]) try { - //std::string iconPath(PACKAGE".png"); - //iconPath = moof::resource::find_file(iconPath); - //moof::image icon(iconPath); - //icon.set_as_icon(); moof::image_handle icon(PACKAGE, "png"); if (icon) icon->set_as_icon(); else moof::log_error("no icon loaded"); @@ -372,10 +368,10 @@ int main(int argc, char* argv[]) class moof::video::attributes attributes(settings); moof::video video(PACKAGE_STRING, attributes); - Main mainView(settings, video); + video.show_fps(true); - mainView.run(); - return 0; + Main app(settings); + return app.run(); } catch (const std::exception& e) {