aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Window.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-16 23:09:18 +0800
committerchai <chaifix@163.com>2018-10-16 23:09:18 +0800
commit5534828032730762f8c1e4daf924b466fffb8be0 (patch)
tree1ae83fc877e4a2d136f6dd120260edd147b13e95 /src/libjin/Graphics/Window.cpp
parent0fc4b3ad5f2ac8d5c0588f61c0cbed4349ee1430 (diff)
*格式化代码
Diffstat (limited to 'src/libjin/Graphics/Window.cpp')
-rw-r--r--src/libjin/Graphics/Window.cpp182
1 files changed, 91 insertions, 91 deletions
diff --git a/src/libjin/Graphics/Window.cpp b/src/libjin/Graphics/Window.cpp
index 6ebc9f9..140ef36 100644
--- a/src/libjin/Graphics/Window.cpp
+++ b/src/libjin/Graphics/Window.cpp
@@ -12,98 +12,98 @@
namespace jin
{
-namespace graphics
-{
-
- bool Window::initSystem(const SettingBase* s)
- {
-#if LIBJIN_DEBUG
- Loghelper::log(Loglevel::LV_INFO, "Init window system");
-#endif
-
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
- return false;
-
- const Setting* setting = (Setting*)s;
- size.w = setting->width;
- size.h = setting->height;
- fps = setting->fps;
- bool vsync = setting->vsync;
- const char* title = setting->title;
-
- if (wnd)
- {
- SDL_DestroyWindow(wnd);
- SDL_FlushEvent(SDL_WINDOWEVENT);
- }
-
- SDL_GLContext ctx = NULL;
-
- if (ctx)
- {
- SDL_GL_DeleteContext(ctx);
- }
-
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- int wx = SDL_WINDOWPOS_UNDEFINED,
- wy = SDL_WINDOWPOS_UNDEFINED;
+ namespace graphics
+ {
+
+ bool Window::initSystem(const SettingBase* s)
+ {
+ #if LIBJIN_DEBUG
+ Loghelper::log(Loglevel::LV_INFO, "Init window system");
+ #endif
+
+ if (SDL_Init(SDL_INIT_VIDEO) < 0)
+ return false;
+
+ const Setting* setting = (Setting*)s;
+ size.w = setting->width;
+ size.h = setting->height;
+ fps = setting->fps;
+ bool vsync = setting->vsync;
+ const char* title = setting->title;
+
+ if (wnd)
+ {
+ SDL_DestroyWindow(wnd);
+ SDL_FlushEvent(SDL_WINDOWEVENT);
+ }
+
+ SDL_GLContext ctx = NULL;
+
+ if (ctx)
+ {
+ SDL_GL_DeleteContext(ctx);
+ }
+
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
+ int wx = SDL_WINDOWPOS_UNDEFINED,
+ wy = SDL_WINDOWPOS_UNDEFINED;
- int flag = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
- if (setting->fullscreen) flag |= SDL_WINDOW_FULLSCREEN;
- if (setting->resizable) flag |= SDL_WINDOW_RESIZABLE;
-
- wnd = SDL_CreateWindow(title, wx, wy, size.w, size.h, flag);
- if (wnd == NULL)
- return false;
- ctx = SDL_GL_CreateContext(wnd);
- if (ctx == NULL)
- return false;
- SDL_GL_SetSwapInterval(vsync ? 1 : 0);
- SDL_GL_MakeCurrent(wnd, ctx);
- /* default configuration */
- gl.setClearColor(0, 0, 0, 0xff);
- gl.pushColor(0xff, 0xff, 0xff, 0xff);
- gl.enable(GL_BLEND);
- gl.enable(GL_TEXTURE_2D);
- gl.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- /* avoid white screen blink on windows */
- swapBuffers();
- /* bind to default canvas */
- Canvas::unbind();
- Shader::unuse();
- return true;
- }
-
- void Window::quitSystem()
- {
- /* disable opengl */
- gl.disable(GL_BLEND);
- gl.disable(GL_TEXTURE_2D);
- /* close window */
- SDL_DestroyWindow(wnd);
- SDL_Quit();
- }
-
- void Window::swapBuffers()
- {
- if (wnd)
- SDL_GL_SwapWindow(wnd);
- }
-
- void Window::setTitle(const char* title)
- {
- SDL_SetWindowTitle(wnd, title);
- };
-
-} // graphics
+ int flag = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
+ if (setting->fullscreen) flag |= SDL_WINDOW_FULLSCREEN;
+ if (setting->resizable) flag |= SDL_WINDOW_RESIZABLE;
+
+ wnd = SDL_CreateWindow(title, wx, wy, size.w, size.h, flag);
+ if (wnd == NULL)
+ return false;
+ ctx = SDL_GL_CreateContext(wnd);
+ if (ctx == NULL)
+ return false;
+ SDL_GL_SetSwapInterval(vsync ? 1 : 0);
+ SDL_GL_MakeCurrent(wnd, ctx);
+ /* default configuration */
+ gl.setClearColor(0, 0, 0, 0xff);
+ gl.pushColor(0xff, 0xff, 0xff, 0xff);
+ gl.enable(GL_BLEND);
+ gl.enable(GL_TEXTURE_2D);
+ gl.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ /* avoid white screen blink on windows */
+ swapBuffers();
+ /* bind to default canvas */
+ Canvas::unbind();
+ Shader::unuse();
+ return true;
+ }
+
+ void Window::quitSystem()
+ {
+ /* disable opengl */
+ gl.disable(GL_BLEND);
+ gl.disable(GL_TEXTURE_2D);
+ /* close window */
+ SDL_DestroyWindow(wnd);
+ SDL_Quit();
+ }
+
+ void Window::swapBuffers()
+ {
+ if (wnd)
+ SDL_GL_SwapWindow(wnd);
+ }
+
+ void Window::setTitle(const char* title)
+ {
+ SDL_SetWindowTitle(wnd, title);
+ };
+
+ } // graphics
} // jin
#endif // LIBJIN_MODULES_RENDER \ No newline at end of file