From 8b00d67febf133e89f6a0bfabc41feed555dc4a9 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 12 Jan 2019 21:48:33 +0800 Subject: =?UTF-8?q?*=E5=8E=BB=E6=8E=89=E6=96=87=E4=BB=B6=E5=89=8D=E7=BC=80?= =?UTF-8?q?je=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/graphics/je_window.cpp | 122 -------------------------------------- 1 file changed, 122 deletions(-) delete mode 100644 src/libjin/graphics/je_window.cpp (limited to 'src/libjin/graphics/je_window.cpp') diff --git a/src/libjin/graphics/je_window.cpp b/src/libjin/graphics/je_window.cpp deleted file mode 100644 index fcca1b7..0000000 --- a/src/libjin/graphics/je_window.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "../core/je_configuration.h" -#if defined(jin_graphics) - -#include - -#include "../common/je_exception.h" -#include "../utils/je_utils.h" -#include "../audio/sdl/je_sdl_audio.h" -#include "../utils/je_log.h" - -#include "shaders/je_shader.h" -#include "je_window.h" -#include "je_gl.h" -#include "je_canvas.h" - -using namespace JinEngine::Graphics::Shaders; - -namespace JinEngine -{ - namespace Graphics - { - - bool Window::startSystem(const SettingBase* s) - { - jin_log_info("Initialize window system."); - - if (SDL_Init(SDL_INIT_VIDEO) < 0) - return false; - - const Setting* setting = (Setting*)s; - mSize.w() = setting->width; - mSize.h() = setting->height; - mFps = setting->fps; - bool vsync = setting->vsync; - const char* title = setting->title; - const char* icon = setting->icon; - - if (mWnd) - { - SDL_DestroyWindow(mWnd); - 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); - SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0); - - int wx = SDL_WINDOWPOS_UNDEFINED, - wy = SDL_WINDOWPOS_UNDEFINED; - - int flag = SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL; - if (setting->fullscreen) flag |= SDL_WINDOW_FULLSCREEN; - if (setting->resizable) flag |= SDL_WINDOW_RESIZABLE; - - mWnd = SDL_CreateWindow(title, wx, wy, mSize.w(), mSize.h(), flag); - if (mWnd == NULL) - return false; - - // Set window icon. - //try - //{ - // Bitmap* bitmap = new Bitmap(icon); - // SDL_Surface *surface; - // Color* pixels = const_cast(bitmap->getPixels()); - // uint w = bitmap->getWidth(), h = bitmap->getHeight(); - // surface = SDL_CreateRGBSurfaceFrom( - // pixels, w, h, 32, w * 4, Color::RMASK, Color::GMASK, Color::BMASK, Color::AMASK); - // SDL_SetWindowIcon(mWnd, surface); - // SDL_FreeSurface(surface); - //} catch (...) {} - - ctx = SDL_GL_CreateContext(mWnd); - if (ctx == NULL) - return false; - - gl.initContext(); - - SDL_GL_SetSwapInterval(vsync ? 1 : 0); - SDL_GL_MakeCurrent(mWnd, ctx); - - // Default configuration. - gl.init(); - - return true; - } - - void Window::quitSystem() - { - jin_log_info("Quit window system."); - - SDL_DestroyWindow(mWnd); - } - - void Window::present() - { - if (mWnd) - SDL_GL_SwapWindow(mWnd); - gl.resetStats(); - } - - void Window::setTitle(const char* title) - { - SDL_SetWindowTitle(mWnd, title); - }; - - } // namespace Graphics -} // namespace JinEngine - -#endif // defined(jin_graphics) \ No newline at end of file -- cgit v1.1-26-g67d0