X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Finit.cpp;h=73a73094749ec1e6d6712f5dc2a7296816ee6f96;hb=4485397da18a25dfd1a51e864814887b66ba0f2e;hp=9e73c2890226e11cd20a271cefae00c79c4f3e7c;hpb=482114e156e91729f2529ea6bb1fe98dacdee97f;p=blank.git diff --git a/src/init.cpp b/src/init.cpp index 9e73c28..73a7309 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -46,7 +46,7 @@ InitIMG::~InitIMG() { } -InitGL::InitGL() { +InitGL::InitGL(bool double_buffer, int sample_size) { if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0) { sdl_error("SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3)"); } @@ -57,13 +57,20 @@ InitGL::InitGL() { sdl_error("SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE)"); } - if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) != 0) { - sdl_error("SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)"); + if (double_buffer) { + if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) != 0) { + sdl_error("SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)"); + } } -} - -InitGL::~InitGL() { + if (sample_size > 1) { + if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) != 0) { + sdl_error("SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS)"); + } + if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, sample_size) != 0) { + sdl_error("SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES)"); + } + } } @@ -155,6 +162,10 @@ void GLContext::Clear() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } +void GLContext::ClearDepthBuffer() { + glClear(GL_DEPTH_BUFFER_BIT); +} + InitGLEW::InitGLEW() { glewExperimental = GL_TRUE; @@ -171,8 +182,4 @@ InitGLEW::InitGLEW() { } } -InitGLEW::~InitGLEW() { - -} - }