Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/main.c
author Bob Pendleton <bob@pendleton.com>
Wed, 25 Jul 2007 21:23:28 +0000
changeset 2215 23a2cb765052
parent 2213 59a667370c57
child 2220 4d2d0548f5b2
permissions -rw-r--r--
make indent
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
/* Simple program:  Create a blank window, wait for keypress, quit.
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
   Please see the SDL documentation for details on using the SDL API:
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
   /Developer/Documentation/SDL/docs.html
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
*/
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
     7
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
#include <stdio.h>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
#include <stdlib.h>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
#include <string.h>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
#include <math.h>
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
#include "SDL.h"
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    15
extern void Atlantis_Init();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    16
extern void Atlantis_Reshape(int w, int h);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    17
extern void Atlantis_Animate();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    18
extern void Atlantis_Display();
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
static SDL_Surface *gScreen;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    22
static void
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    23
initAttributes()
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
{
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
    // Setup attributes we want for the OpenGL context
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    26
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
    int value;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    28
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
    // Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
    //    Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
    //    5-5-5 RGB for 16-bit screens
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    32
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
    // Request a 16-bit depth buffer (without this, there is no depth buffer)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
    value = 16;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    35
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, value);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    36
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    37
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
    // Request double-buffered OpenGL
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
    //     The fact that windows are double-buffered on Mac OS X has no effect
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
    //     on OpenGL double buffering.
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
    value = 1;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    42
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, value);
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
}
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    45
static void
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    46
printAttributes()
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
{
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
    // Print out attributes of the context we created
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
    int nAttr;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
    int i;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    51
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    52
    int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    53
        SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    54
    };
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    55
2215
23a2cb765052 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
    56
    char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n",
23a2cb765052 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2213
diff changeset
    57
        "Green size: %d bits\n",
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    58
        "Alpha size: %d bits\n", "Color buffer size: %d bits\n",
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    59
        "Depth bufer size: %d bits\n"
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    60
    };
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
    nAttr = sizeof(attr) / sizeof(int);
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    63
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    for (i = 0; i < nAttr; i++) {
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    65
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
        int value;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    67
        SDL_GL_GetAttribute(attr[i], &value);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    68
        printf(desc[i], value);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    69
    }
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
}
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    72
static void
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    73
createSurface(int fullscreen)
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
{
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    Uint32 flags = 0;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    76
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
    flags = SDL_OPENGL;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    if (fullscreen)
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
        flags |= SDL_FULLSCREEN;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    80
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    // Create window
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    82
    gScreen = SDL_SetVideoMode(640, 480, 0, flags);
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
    if (gScreen == NULL) {
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    84
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    85
        fprintf(stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    86
                SDL_GetError());
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    87
        SDL_Quit();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    88
        exit(2);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    89
    }
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
}
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    92
static void
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    93
initGL()
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
{
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    95
    Atlantis_Init();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    96
    Atlantis_Reshape(gScreen->w, gScreen->h);
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
}
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
    99
static void
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   100
drawGL()
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
{
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   102
    Atlantis_Animate();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   103
    Atlantis_Display();
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
}
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   106
static void
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   107
mainLoop()
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
{
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
    SDL_Event event;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
    int done = 0;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
    int fps = 24;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   112
    int delay = 1000 / fps;
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
    int thenTicks = -1;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
    int nowTicks;
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   115
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   116
    while (!done) {
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   118
        /* Check for events */
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   119
        while (SDL_PollEvent(&event)) {
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   120
            switch (event.type) {
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   122
            case SDL_MOUSEMOTION:
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   123
                break;
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   124
            case SDL_MOUSEBUTTONDOWN:
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   125
                break;
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   126
            case SDL_KEYDOWN:
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   127
                /* Any keypress quits the app... */
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   128
            case SDL_QUIT:
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   129
                done = 1;
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   130
                break;
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   131
            default:
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   132
                break;
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   133
            }
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   134
        }
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   135
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
        // Draw at 24 hz
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
        //     This approach is not normally recommended - it is better to
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
        //     use time-based animation and run as fast as possible
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   139
        drawGL();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   140
        SDL_GL_SwapBuffers();
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
        // Time how long each draw-swap-delay cycle takes
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
        // and adjust delay to get closer to target framerate
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
        if (thenTicks > 0) {
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   145
            nowTicks = SDL_GetTicks();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   146
            delay += (1000 / fps - (nowTicks - thenTicks));
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
            thenTicks = nowTicks;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
            if (delay < 0)
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   149
                delay = 1000 / fps;
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   150
        } else {
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   151
            thenTicks = SDL_GetTicks();
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
        }
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   154
        SDL_Delay(delay);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   155
    }
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
}
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   158
int
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   159
main(int argc, char *argv[])
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
{
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   161
    // Init SDL video subsystem
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   162
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   164
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   165
        exit(1);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   166
    }
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
    // Set GL context attributes
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   168
    initAttributes();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   169
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
    // Create GL context
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   171
    createSurface(0);
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   172
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
    // Get GL context attributes
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   174
    printAttributes();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   175
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
    // Init GL state
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   177
    initGL();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   178
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
    // Draw, get events...
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   180
    mainLoop();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   181
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
    // Cleanup
2213
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   183
    SDL_Quit();
59a667370c57 make indent
Bob Pendleton <bob@pendleton.com>
parents: 2207
diff changeset
   184
2207
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
    return 0;
d63e9f5944ae Unpacked project archives to get individual file history in subversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
}