1 #define GTEST_HAS_EXCEPTIONS 0
4 #include <SDL2/SDL_error.h>
5 #include <SDL2/SDL_video.h>
7 #include <benchmark/benchmark.h>
12 #include "gtest/gtest.h"
14 int main(int argc, char **argv) {
15 // Set up an OpenGL context using SDL.
16 if (SDL_Init(SDL_INIT_VIDEO) == -1) {
17 fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError());
20 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
21 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
22 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
24 // You can uncomment this if you want to try a core context.
25 // For Mesa, you can get the same effect by doing
27 // export MESA_GL_VERSION_OVERRIDE=3.1FC
29 // before running tests.
30 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
31 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
32 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
34 // See also init.cpp for how to enable debugging.
35 // SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
37 SDL_Window *window = SDL_CreateWindow("OpenGL window for unit test",
38 SDL_WINDOWPOS_UNDEFINED,
39 SDL_WINDOWPOS_UNDEFINED,
42 SDL_GLContext context = SDL_GL_CreateContext(window);
43 assert(context != nullptr);
46 if (argc >= 2 && strcmp(argv[1], "--benchmark") == 0) {
49 ::benchmark::Initialize(&argc, argv + 1);
50 if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1;
51 ::benchmark::RunSpecifiedBenchmarks();
54 fprintf(stderr, "No support for microbenchmarks compiled in.\n");
58 testing::InitGoogleTest(&argc, argv);
59 err = RUN_ALL_TESTS();