1 #define GTEST_HAS_EXCEPTIONS 0
5 #include <SDL2/SDL_error.h>
6 #include <SDL2/SDL_video.h>
9 #include <SDL/SDL_error.h>
10 #include <SDL/SDL_video.h>
13 #include <benchmark/benchmark.h>
18 #include "gtest/gtest.h"
20 int main(int argc, char **argv) {
21 // Set up an OpenGL context using SDL.
22 if (SDL_Init(SDL_INIT_VIDEO) == -1) {
23 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
26 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
27 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
28 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
31 // You can uncomment this if you want to try a core context.
32 // For Mesa, you can get the same effect by doing
34 // export MESA_GL_VERSION_OVERRIDE=3.1FC
36 // before running tests.
37 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
38 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
39 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
41 // See also init.cpp for how to enable debugging.
42 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
44 SDL_Window *window = SDL_CreateWindow("OpenGL window for unit test",
45 SDL_WINDOWPOS_UNDEFINED,
46 SDL_WINDOWPOS_UNDEFINED,
49 SDL_GLContext context = SDL_GL_CreateContext(window);
50 assert(context != nullptr);
52 SDL_SetVideoMode(32, 32, 0, SDL_OPENGL);
53 SDL_WM_SetCaption("OpenGL window for unit test", nullptr);
57 if (argc >= 2 && strcmp(argv[1], "--benchmark") == 0) {
60 ::benchmark::Initialize(&argc, argv + 1);
61 if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1;
62 ::benchmark::RunSpecifiedBenchmarks();
65 fprintf(stderr, "No support for microbenchmarks compiled in.\n");
69 testing::InitGoogleTest(&argc, argv);
70 err = RUN_ALL_TESTS();