source: trunk/src/test-map.cpp @ 208

Last change on this file since 208 was 208, checked in by sam, 11 years ago

Add a debugging sphere object to test transparency.

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
11#include <cmath>
12
13#include <SDL.h>
14
15#include "core.h"
16#include "sdlinput.h"
17#include "debugfps.h"
18#include "debugsprite.h"
19#include "debugsphere.h"
20#include "debugrecord.h"
21#include "debugstats.h"
22
23static float const FPS = 30.0f;
24
25int main(int argc, char **argv)
26{
27    /* Initialise SDL */
28    if (SDL_Init(SDL_INIT_VIDEO) < 0)
29    {
30        fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError());
31        return EXIT_FAILURE;
32    }
33
34    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
35    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
36    SDL_Surface *video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
37    if (!video)
38    {
39        fprintf(stderr, "Cannot create OpenGL screen: %s\n", SDL_GetError());
40        SDL_Quit();
41        return EXIT_FAILURE;
42    }
43
44    SDL_WM_SetCaption("Map Test (SDL)", NULL);
45    SDL_ShowCursor(0);
46    //SDL_WM_GrabInput(SDL_GRAB_ON);
47
48    /* Initialise OpenGL */
49    Video::Setup(video->w, video->h);
50
51    /* Create a game */
52    Game *game = new Game("maps/testmap.tmx");
53
54    /* Register an input driver and some debug stuff */
55    new SdlInput();
56    new DebugFps();
57    new DebugSprite(game);
58    new DebugSphere();
59    //new DebugRecord("lolengine.ogg");
60    new DebugStats("stats.txt");
61
62    while (!Ticker::Finished())
63    {
64        /* Tick the game */
65        Ticker::TickGame();
66
67        /* Clear the screen, tick the renderer, show the frame and
68         * clamp to desired framerate. */
69        Video::Clear();
70        Ticker::TickDraw();
71        SDL_GL_SwapBuffers();
72        Ticker::ClampFps(1000.0f / FPS);
73    }
74
75    SDL_Quit();
76
77    return EXIT_SUCCESS;
78}
79
Note: See TracBrowser for help on using the repository browser.