source: trunk/deushax/gtk/editor.cpp @ 755

Last change on this file since 755 was 696, checked in by sam, 10 years ago

Merge all debug entity includes in <loldebug.h>.

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdlib>
11#if defined _WIN32
12#   include <direct.h>
13#endif
14
15#include <gtk/gtk.h>
16#include <gtkgl/gtkglarea.h>
17
18#include "core.h"
19#include "loldebug.h"
20
21using namespace lol;
22
23#include "glmapview.h"
24
25static gboolean delayed_quit(GtkWidget *w, GdkEvent *e, void *data)
26{
27    (void)w;
28    (void)e;
29    (void)data;
30    gtk_main_quit();
31    return TRUE;
32}
33
34int main(int argc, char **argv)
35{
36    /* Initialize GTK */
37    g_thread_init(NULL);
38    gtk_init(&argc, &argv);
39
40    if (gdk_gl_query() == FALSE)
41    {
42        g_print("OpenGL not supported\n");
43        return EXIT_FAILURE;
44    }
45
46    /* Build the application interface */
47    GtkBuilder *builder = gtk_builder_new();
48#if defined _WIN32
49    _chdir(".."); /* Temporary Win32 hack */
50#endif
51    if (!gtk_builder_add_from_file(builder, "deushax/gtk/editor.xml", NULL))
52    {
53        g_print("Cannot build from XML\n");
54        return EXIT_FAILURE;
55    }
56    gtk_builder_connect_signals(builder, NULL);
57
58    /* Add our custom GL map viewer */
59    GlMapView *glmapview = new GlMapView(builder);
60
61    /* Show window. We're good to go! */
62    GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
63    gtk_widget_show_all(window);
64    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
65                       GTK_SIGNAL_FUNC(delayed_quit), NULL);
66    g_object_unref(G_OBJECT(builder));
67
68    glmapview->LoadMap("maps/testmap.tmx");
69    new DebugFps(10, 10);
70
71    gtk_main();
72
73    delete glmapview;
74
75    return EXIT_SUCCESS;
76}
77
Note: See TracBrowser for help on using the repository browser.