source: trunk/src/editor.cpp @ 96

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

Implement lazy initialisation of TileSet objects.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#include <SDL.h>
2
3#include <stdio.h>
4#include <math.h>
5
6#include "gtkvideo.h"
7#include "ticker.h"
8#include "game.h"
9
10#include <math.h>
11#include <gtk/gtk.h>
12#include <gtkgl/gtkglarea.h>
13#include <GL/gl.h>
14
15volatile int quit = 0;
16
17static gint main_quit(GtkWidget *widget, GdkEventExpose *event)
18{
19    quit = 1;
20    return FALSE;
21}
22
23int main(int argc, char **argv)
24{
25    GtkWidget *window, *glarea;
26
27    /* initialize gtk */
28    gtk_init(&argc, &argv);
29
30    /* Create new top level window. */
31    window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
32    gtk_window_set_title(GTK_WINDOW(window), "Simple");
33    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
34
35    /* Quit form main if got delete event */
36    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
37                       GTK_SIGNAL_FUNC(main_quit), NULL);
38
39
40    /* You should always delete gtk_gl_area widgets before exit or else
41       GLX contexts are left undeleted, this may cause problems (=core dump)
42       in some systems.
43       Destroy method of objects is not automatically called on exit.
44       You need to manually enable this feature. Do gtk_quit_add_destroy()
45       for all your top level windows unless you are certain that they get
46       destroy signal by other means.
47    */
48    gtk_quit_add_destroy(1, GTK_OBJECT(window));
49
50
51    /* Create new OpenGL widget. */
52    GtkVideo *video = new GtkVideo("LOL", 640, 480);
53    glarea = GTK_WIDGET(video->GetWidget());
54
55    /* put glarea into window and show it all */
56    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(glarea));
57    gtk_widget_show(GTK_WIDGET(glarea));
58    gtk_widget_show(GTK_WIDGET(window));
59
60    Game *game = new Game("maps/testmap.tmx");
61
62    for (;;)
63    {
64        // Do GTK stuff until the user wants to quit
65        while (g_main_context_iteration(NULL, FALSE));
66
67        if (quit)
68            break;
69
70        game->SetMouse(0, 0);
71        Ticker::TickGame(33.33333f);
72
73        video->PreRender();
74        Ticker::TickRender(33.33333f);
75
76        game->Render();
77        video->PostRender(33.33333f);
78    }
79
80    delete game;
81    delete video;
82
83    return 0;
84}
Note: See TracBrowser for help on using the repository browser.