X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMain.cc;h=e16803739ae6e809d5bf049040debbb3b75e93fd;hp=13681ee0625fa74d578fd1dcdb24f49db5e5129e;hb=d6990468d297a6cbee98e4d0d33ab37e1b2352c9;hpb=6f1b787a10d8ab1a3117a4b8c004dd2d90599608 diff --git a/src/Main.cc b/src/Main.cc index 13681ee..e168037 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -20,7 +20,7 @@ #if !defined(__WIN32) #include #else -int isatty(int dummy) { return 0; } +inline int isatty(int dummy) { return 0; } #endif #include @@ -40,15 +40,15 @@ int isatty(int dummy) { return 0; } #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", boost::bind(&Main::setup_opengl)); setup_opengl(); -#if USE_HOTLOADING +#if ENABLE_HOTLOADING hotload_timer_.init(boost::bind(&moof::resource::reload_as_needed), SCALAR(0.25), moof::timer::repeat); @@ -58,15 +58,6 @@ 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); } void Main::draw(moof::scalar alpha) const @@ -78,38 +69,38 @@ void Main::draw(moof::scalar alpha) const glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - - moof::view::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; - 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,13 +150,13 @@ 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); - //glEnable(GL_POINT_SMOOTH); - //glEnable(GL_LINE_SMOOTH); - //glEnable(GL_POLYGON_SMOOTH); + glEnable(GL_POINT_SMOOTH); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POLYGON_SMOOTH); glShadeModel(GL_SMOOTH); //glEnable(GL_BLEND); @@ -173,7 +164,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); @@ -259,7 +250,7 @@ void Main::print_info(int argc, char* argv[]) << " Assets: " << assets << std::endl << "Build options: "; -#if USE_CLOCK_GETTIME +#if ENABLE_CLOCK_GETTIME print_option("clock_gettime", true); #else print_option("clock_gettime", false); @@ -269,27 +260,27 @@ void Main::print_info(int argc, char* argv[]) #else print_option("debug", false); #endif -#if USE_GTK +#if WITH_GTK print_option("gtk", true); #else print_option("gtk", false); #endif -#if USE_HOTLOADING +#if ENABLE_HOTLOADING print_option("hotload", true); #else print_option("hotload", false); #endif -#if PROFILING_ENABLED +#if ENABLE_PROFILING print_option("profile", true); #else print_option("profile", false); #endif -#if USE_QT4 +#if WITH_QT4 print_option("qt4", true); #else print_option("qt4", false); #endif -#if USE_THREADS +#if ENABLE_THREADS print_option("threads", true); #else print_option("threads", false); @@ -361,10 +352,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 +359,9 @@ int main(int argc, char* argv[]) class moof::video::attributes attributes(settings); moof::video video(PACKAGE_STRING, attributes); - Main mainView(settings, video); - mainView.run(); - return 0; + Main app(settings); + return app.run(); } catch (const std::exception& e) {