aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Window.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-23 12:23:58 +0800
committerchai <chaifix@163.com>2018-10-23 12:23:58 +0800
commit40fc27154fe754181934dc7ee31375e6bdfb33fc (patch)
tree897ad98d759bc308ef66561181ba88b85f2ccd47 /src/libjin/Graphics/Window.cpp
parent1480c9445100075c9e1a894eb07c0ef727b509a1 (diff)
*merge from minimal
Diffstat (limited to 'src/libjin/Graphics/Window.cpp')
-rw-r--r--src/libjin/Graphics/Window.cpp97
1 files changed, 0 insertions, 97 deletions
diff --git a/src/libjin/Graphics/Window.cpp b/src/libjin/Graphics/Window.cpp
deleted file mode 100644
index 708a30f..0000000
--- a/src/libjin/Graphics/Window.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#include "../modules.h"
-#if JIN_MODULES_RENDER
-
-#include <iostream>
-#include "window.h"
-#include "../3rdparty/GLee/GLee.h"
-#include "canvas.h"
-#include "../utils/utils.h"
-#include "../audio/sdl/SDLAudio.h"
-#include "../utils/log.h"
-
-namespace jin
-{
-namespace graphics
-{
-
- bool Window::initSystem(const SettingBase* s)
- {
-#if JIN_DEBUG
- Loghelper::log(Loglevel::LV_INFO, "Init window system");
-#endif // JIN_DEBUG
-
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
- return false;
-
- const Setting* setting = (Setting*)s;
- width = setting->width;
- height = 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, width, height, 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);
- glClearColor(0.f, 0.f, 0.f, 1.f);
- glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- glColor4f(1, 1, 1, 1);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- Canvas::unbind();
- swapBuffers();
- return true;
- }
-
- void Window::quitSystem()
- {
- SDL_DestroyWindow(wnd);
- SDL_Quit();
- }
-
- inline void Window::swapBuffers()
- {
- if (wnd)
- SDL_GL_SwapWindow(wnd);
- }
-
-} // graphics
-} // jin
-
-#endif // JIN_MODULES_RENDER \ No newline at end of file