#include <stlplus/portability/file_system.hpp>
#include <stlplus/portability/subprocesses.hpp>
+#include <moof/image.hh>
#include <moof/log.hh>
#include <moof/modal_dialog.hh>
#include <moof/opengl.hh>
#include <moof/string.hh>
#include <moof/video.hh>
-#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",
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
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;
}
void Main::setup_opengl()
{
- //glEnable(GL_TEXTURE_2D);
+ glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
//glEnable(GL_CULL_FACE);
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("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
#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);
+ video.show_fps(true);
- mainView.run();
- return 0;
+ Main app(settings);
+ return app.run();
}
catch (const std::exception& e)
{