]> git.sesse.net Git - movit/blob - gtest_sdl_main.cpp
Allow storing values in intermediate framebuffers as sqrt(x).
[movit] / gtest_sdl_main.cpp
1 #define GTEST_HAS_EXCEPTIONS 0
2
3 #ifdef HAVE_SDL2
4 #include <SDL2/SDL.h>
5 #include <SDL2/SDL_error.h>
6 #include <SDL2/SDL_video.h>
7 #else
8 #include <SDL/SDL.h>
9 #include <SDL/SDL_error.h>
10 #include <SDL/SDL_video.h>
11 #endif
12 #include <stdio.h>
13 #include <stdlib.h>
14
15 #include "gtest/gtest.h"
16
17 int main(int argc, char **argv) {
18         // Set up an OpenGL context using SDL.
19         if (SDL_Init(SDL_INIT_VIDEO) == -1) {
20                 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
21                 exit(1);
22         }
23         SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
24         SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
25         SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
26
27 #ifdef HAVE_SDL2
28         // You can uncomment this if you want to try a core context.
29         // For Mesa, you can get the same effect by doing
30         //
31         //   export MESA_GL_VERSION_OVERRIDE=3.1FC
32         //
33         // before running tests.
34 //      SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
35 //      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
36 //      SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
37
38         // See also init.cpp for how to enable debugging.
39 //      SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
40
41         SDL_Window *window = SDL_CreateWindow("OpenGL window for unit test",
42                 SDL_WINDOWPOS_UNDEFINED,
43                 SDL_WINDOWPOS_UNDEFINED,
44                 32, 32,
45                 SDL_WINDOW_OPENGL);
46         SDL_GLContext context = SDL_GL_CreateContext(window);
47         assert(context != NULL);
48 #else
49         SDL_SetVideoMode(32, 32, 0, SDL_OPENGL);
50         SDL_WM_SetCaption("OpenGL window for unit test", NULL);
51 #endif
52
53         testing::InitGoogleTest(&argc, argv);
54         int err = RUN_ALL_TESTS();
55         SDL_Quit();
56         exit(err);
57 }