X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gtest_sdl_main.cpp;h=cd68777721e19cc92b300920fd094473ef5d5a7d;hp=8a2fa9eafa5eca6ac2fe044932dabc3c74f94602;hb=ab89030be6f55cd1955b9e033c62c2e3c3ba2a2f;hpb=835f017dbbf6bdda89270a461e21e94c3bcb7928 diff --git a/gtest_sdl_main.cpp b/gtest_sdl_main.cpp index 8a2fa9e..cd68777 100644 --- a/gtest_sdl_main.cpp +++ b/gtest_sdl_main.cpp @@ -1,4 +1,17 @@ +#define GTEST_HAS_EXCEPTIONS 0 + +#ifdef HAVE_SDL2 +#include +#include +#include +#else #include +#include +#include +#endif +#include +#include + #include "gtest/gtest.h" int main(int argc, char **argv) { @@ -10,8 +23,28 @@ int main(int argc, char **argv) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + +#ifdef HAVE_SDL2 + // You can uncomment this if you want to try a core context. + // For Mesa, you can get the same effect by doing + // + // export MESA_GL_VERSION_OVERRIDE=3.1FC + // + // before running tests. +// SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); +// SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); +// SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); + SDL_Window *window = SDL_CreateWindow("OpenGL window for unit test", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + 32, 32, + SDL_WINDOW_OPENGL); + SDL_GLContext context = SDL_GL_CreateContext(window); + assert(context != NULL); +#else SDL_SetVideoMode(32, 32, 0, SDL_OPENGL); SDL_WM_SetCaption("OpenGL window for unit test", NULL); +#endif testing::InitGoogleTest(&argc, argv); int err = RUN_ALL_TESTS();