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

Last change on this file since 664 was 327, checked in by sam, 10 years ago

Add all the bells and whistles needed for GTK+ compilation on Win32.

  • 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 "glmapview.h"
20#include "debugfps.h"
21
22static gboolean delayed_quit(GtkWidget *w, GdkEvent *e, void *data)
23{
24    (void)w;
25    (void)e;
26    (void)data;
27    gtk_main_quit();
28    return TRUE;
29}
30
31int main(int argc, char **argv)
32{
33    /* Initialize GTK */
34    g_thread_init(NULL);
35    gtk_init(&argc, &argv);
36
37    if (gdk_gl_query() == FALSE)
38    {
39        g_print("OpenGL not supported\n");
40        return EXIT_FAILURE;
41    }
42
43    /* Build the application interface */
44    GtkBuilder *builder = gtk_builder_new();
45#if defined _WIN32
46    _chdir(".."); /* Temporary Win32 hack */
47#endif
48    if (!gtk_builder_add_from_file(builder, "deushax/gtk/editor.xml", NULL))
49    {
50        g_print("Cannot build from XML\n");
51        return EXIT_FAILURE;
52    }
53    gtk_builder_connect_signals(builder, NULL);
54
55    /* Add our custom GL map viewer */
56    GlMapView *glmapview = new GlMapView(builder);
57
58    /* Show window. We're good to go! */
59    GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
60    gtk_widget_show_all(window);
61    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
62                       GTK_SIGNAL_FUNC(delayed_quit), NULL);
63    g_object_unref(G_OBJECT(builder));
64
65    glmapview->LoadMap("maps/testmap.tmx");
66    new DebugFps(10, 10);
67
68    gtk_main();
69
70    delete glmapview;
71
72    return EXIT_SUCCESS;
73}
74
Note: See TracBrowser for help on using the repository browser.