Euphoria
sdllibrary.cc
Go to the documentation of this file.
1 #include "window/sdllibrary.h"
2 
3 #include "log/log.h"
4 
5 #include "SDL.h"
6 
7 namespace eu::window
8 {
9  void
11  {
12  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 4);
13  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 4);
14  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 4);
15  SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 4);
16  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
17  SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 0);
18  // for 2d we have keept this at 0
19  // todo(Gustav): fix 2d rendering to we can keep this at != 0
20  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
21  SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
22  SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 0);
23  SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 0);
24  SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 0);
25  SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0);
26  SDL_GL_SetAttribute(SDL_GL_STEREO, 0);
27  SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
28  SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);
29  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
30  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
31  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
32  SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
33  }
34 
36  : ok(false)
37  {
38  if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
39  {
40  LOG_ERROR("Failed to init SDL: {0}", SDL_GetError());
41  return;
42  }
43 
45  ok = true;
46  }
47 
49  {
50  SDL_Quit();
51  }
52 }
#define LOG_ERROR(...)
Definition: log.h:9
constexpr ParseResult ok
all ok
Definition: argparse.h:76
void setup_sdl_open_gl_attributes()
Definition: sdllibrary.cc:10