diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-06-21 13:15:59 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-06-21 13:15:59 +0100 |
commit | 4e8c07d3fd949287fc2361284a5a7704e642396e (patch) | |
tree | 18d7e5c2d41cedb00a29ac303637102c7d4b157d /src/window.cpp | |
parent | f3e75c7f821675740736b46094382d55c7e6ee5c (diff) | |
download | YAGE-4e8c07d3fd949287fc2361284a5a7704e642396e.tar.gz YAGE-4e8c07d3fd949287fc2361284a5a7704e642396e.zip |
Correcting indentation and removed vector2d.cpp
Diffstat (limited to 'src/window.cpp')
-rw-r--r-- | src/window.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/src/window.cpp b/src/window.cpp index dc2a743a..37c3b16d 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -13,69 +13,69 @@ Window::Window() Window::~Window() { - SDL_DestroyWindow(window_); + SDL_DestroyWindow(window_); } void Window::create(const std::string &window_name, int width, int height, unsigned flags) { - Uint32 gl_window_states=0; + Uint32 gl_window_states=0; - // set the correct input flags - if(flags & WindowFlags::SHOWN) - gl_window_states|=SDL_WINDOW_OPENGL; - if(flags & WindowFlags::HIDDEN) - gl_window_states|=SDL_WINDOW_HIDDEN; - if(flags & WindowFlags::FULLSCREEN) - gl_window_states|=SDL_WINDOW_FULLSCREEN; - if(flags & WindowFlags::BORDERLESS) - gl_window_states|=SDL_WINDOW_BORDERLESS; + // set the correct input flags + if(flags & WindowFlags::SHOWN) + gl_window_states|=SDL_WINDOW_OPENGL; + if(flags & WindowFlags::HIDDEN) + gl_window_states|=SDL_WINDOW_HIDDEN; + if(flags & WindowFlags::FULLSCREEN) + gl_window_states|=SDL_WINDOW_FULLSCREEN; + if(flags & WindowFlags::BORDERLESS) + gl_window_states|=SDL_WINDOW_BORDERLESS; - // SDL_GL options + // SDL_GL options - // SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 4); - // SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 5); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + // SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 4); + // SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 5); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - // create the SDL window - window_ = SDL_CreateWindow(window_name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - width, height, gl_window_states); - if(window_ == nullptr) - throw std::runtime_error("SDL_CreateWindow failed"); + // create the SDL window + window_ = SDL_CreateWindow(window_name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + width, height, gl_window_states); + if(window_ == nullptr) + throw std::runtime_error("SDL_CreateWindow failed"); - // initialize the GL context in the window - SDL_GLContext gl_context = SDL_GL_CreateContext(window_); - if(gl_context == nullptr) - throw std::runtime_error("SDL_GL_CreateContext failed"); + // initialize the GL context in the window + SDL_GLContext gl_context = SDL_GL_CreateContext(window_); + if(gl_context == nullptr) + throw std::runtime_error("SDL_GL_CreateContext failed"); - // initialize glew - GLenum error = glewInit(); - if(error != GLEW_OK) - throw std::runtime_error("glewInit failed"); + // initialize glew + GLenum error = glewInit(); + if(error != GLEW_OK) + throw std::runtime_error("glewInit failed"); - // print out the current OpenGL version to debug - std::cout<<"*** OpenGL version: "<<glGetString(GL_VERSION)<<" ***\n"; + // print out the current OpenGL version to debug + std::cout<<"*** OpenGL version: "<<glGetString(GL_VERSION)<<" ***\n"; - // set vsync on instead of custom fps limiting - SDL_GL_SetSwapInterval(1); - // set the clear color to black - glClearColor(0.f, 0.5f, 0.f, 1.f); - // set alpha blending - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // set vsync on instead of custom fps limiting + SDL_GL_SetSwapInterval(1); + // set the clear color to black + glClearColor(0.f, 0.5f, 0.f, 1.f); + // set alpha blending + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } void Window::swapBuffer() { - // swap the window buffer - SDL_GL_SwapWindow(window_); + // swap the window buffer + SDL_GL_SwapWindow(window_); } void Window::clearBuffer() { - // set the clear depth - glClearDepth(1.f); - // clears buffer with clear color - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + // set the clear depth + glClearDepth(1.f); + // clears buffer with clear color + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } } // yage |