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

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

Implement video recording using libpipi.

  • Property svn:keywords set to Id
File size: 1.6 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 "sdlinput.h"
16#include "debugfps.h"
17#include "debugsprite.h"
18#include "debugrecord.h"
19#include "game.h"
20#include "ticker.h"
21#include "profiler.h"
22#include "video.h"
23
24static float const FPS = 30.0f;
25
26int main(int argc, char **argv)
27{
28    /* Initialise SDL */
29    if (SDL_Init(SDL_INIT_VIDEO) < 0)
30    {
31        fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError());
32        return EXIT_FAILURE;
33    }
34
35    SDL_Surface *video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
36    if (!video)
37    {
38        fprintf(stderr, "Cannot create OpenGL screen: %s\n", SDL_GetError());
39        SDL_Quit();
40        return EXIT_FAILURE;
41    }
42
43    SDL_WM_SetCaption("Map Test (SDL)", NULL);
44    SDL_ShowCursor(0);
45    SDL_WM_GrabInput(SDL_GRAB_ON);
46
47    /* Initialise OpenGL */
48    Video::Setup(video->w, video->h);
49
50    /* Create a game */
51    Game *game = new Game("maps/testmap.tmx");
52
53    /* Register an input driver and some debug stuff */
54    new SdlInput(game);
55    new DebugFps();
56    new DebugSprite(game);
57    //new DebugRecord("movie.ogg");
58
59    while (!game->Finished())
60    {
61        /* Tick the game */
62        Ticker::TickGame();
63
64        /* Clear the screen, tick the renderer, show the frame and
65         * clamp to desired framerate. */
66        Video::Clear();
67        Ticker::TickRender();
68        SDL_GL_SwapBuffers();
69        Ticker::ClampFps(1.0f / FPS);
70    }
71
72    SDL_Quit();
73
74    return EXIT_SUCCESS;
75}
76
Note: See TracBrowser for help on using the repository browser.