aboutsummaryrefslogtreecommitdiff
path: root/09-september/main.c
blob: 0f6ee5861671a9cb97c64252c32fb04206442854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "game.h"

/**
    TODO:   Shadows
            Fix timing
            Scenes
            Materials
            Text
            Fix particle emission rate

            +improve skybox
            |
            +->fog
            +->day/night

            +mouse picking (is it working perfectly?)

            +add cell shading?

            improve math package
            repair gui on renderer.c
            improve shape loading (normal generation) (support other formats)
**/

int main(int args, char *argv[])
{
    SDL_Init(SDL_INIT_EVERYTHING);

    Game game;
    game.gameState = RUNNING;
    game.window = window_new("Test", WINDOW_WIDTH, WINDOW_HEIGHT);

    game.camera = camera_new();
    game.camera->projectionMatrix = mat4_perspective(60.0f, WINDOW_ASPECT_RATIO, 0.1f, 900.0f);

    LoadResources(&game);

    Time_Init();
    SDL_GL_SetSwapInterval(1);
    Time_SetMaxFramesPerSecond(60);
    while(game.gameState != EXIT)
    {
        Time_Begin();
        ProcessInput(&game);
        Player_Update(&game.player, game.terrain);
        Particles_Update(&game.camera->position);
        Draw(&game);

        float FPS = Time_End();

        if( !( Time_GetCountedFrames() % (int)FPS ) )
        {
            fprintf(stderr, "FPS: %.4f\n", FPS);
        }
    }

    window_destroy(game.window);
    CleanUp(&game);
    SDL_Quit();
    return 0;
}