#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",
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
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;
}
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);
#else
print_option("hotload", false);
#endif
-#if PROFILING_ENABLED
+#if ENABLE_PROFILING
print_option("profile", true);
#else
print_option("profile", false);
int main(int argc, char* argv[])
{
- //moof::backend backend;
+ moof::backend backend;
if (argc > 1)
{
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");
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)
{