diff options
author | chai <chaifix@163.com> | 2019-08-02 20:51:00 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-02 20:51:00 +0800 |
commit | bad78945ceba425f6a80e3b8dca2414d592970eb (patch) | |
tree | 8bf7540766349c534bf9e5746b24fd7507ba034e /source/modules/asura-core/window | |
parent | 99b90496765df21c5f377f42b9ed073ccb34c1fd (diff) |
*修改文件名格式
Diffstat (limited to 'source/modules/asura-core/window')
9 files changed, 14 insertions, 212 deletions
diff --git a/source/modules/asura-core/window/binding/_window.cpp b/source/modules/asura-core/window/binding/_window.cpp index 7119cd2..1e14a3a 100644 --- a/source/modules/asura-core/window/binding/_window.cpp +++ b/source/modules/asura-core/window/binding/_window.cpp @@ -1,6 +1,6 @@ -#include "../../image/image_data.h" +#include "../../Image/ImageData.h" -#include "../window.h" +#include "../Window.h" using namespace std; using namespace AEGraphics; diff --git a/source/modules/asura-core/window/window.cpp b/source/modules/asura-core/window/window.cpp index bbcb949..adba7c9 100644 --- a/source/modules/asura-core/window/window.cpp +++ b/source/modules/asura-core/window/window.cpp @@ -1,10 +1,10 @@ -#include <asura-utils/exceptions/exception.h> +#include <asura-utils/Exceptions/Exception.h> #include "window.h" -#include "window_impl_sdl.h" -#include "window_impl_glew.h" -#include "window_impl_glut.h" +#include "WindowImplSDL.h" +#include "WindowImplGlew.h" +#include "WindowImplGlut.h" namespace_begin(AsuraEngine) namespace_begin(Window) diff --git a/source/modules/asura-core/window/window.h b/source/modules/asura-core/window/window.h index 872c40f..f5498c1 100644 --- a/source/modules/asura-core/window/window.h +++ b/source/modules/asura-core/window/window.h @@ -1,13 +1,13 @@ -#ifndef __ASURA_ENGINE_WINDOW_H__ -#define __ASURA_ENGINE_WINDOW_H__ +#ifndef _ASURA_ENGINE_WINDOW_H_ +#define _ASURA_ENGINE_WINDOW_H_ -#include <asura-utils/scripting/portable.hpp> -#include <asura-utils/math/vector2.hpp> -#include <asura-utils/singleton.hpp> +#include <asura-utils/Scripting/Portable.hpp> +#include <asura-utils/Math/Vector2.hpp> +#include <asura-utils/Singleton.hpp> -#include "../graphics/image.h" -#include "../graphics/render_state.h" -#include "../graphics/render_target.h" +#include "../Graphics/Image.h" +#include "../Graphics/RenderState.h" +#include "../Graphics/RenderTarget.h" namespace_begin(AsuraEngine) namespace_begin(Window) diff --git a/source/modules/asura-core/window/window_impl_glew.cpp b/source/modules/asura-core/window/window_impl_glew.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/window/window_impl_glew.cpp +++ /dev/null diff --git a/source/modules/asura-core/window/window_impl_glew.h b/source/modules/asura-core/window/window_impl_glew.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/window/window_impl_glew.h +++ /dev/null diff --git a/source/modules/asura-core/window/window_impl_glut.cpp b/source/modules/asura-core/window/window_impl_glut.cpp deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/window/window_impl_glut.cpp +++ /dev/null diff --git a/source/modules/asura-core/window/window_impl_glut.h b/source/modules/asura-core/window/window_impl_glut.h deleted file mode 100644 index e69de29..0000000 --- a/source/modules/asura-core/window/window_impl_glut.h +++ /dev/null diff --git a/source/modules/asura-core/window/window_impl_sdl.cpp b/source/modules/asura-core/window/window_impl_sdl.cpp deleted file mode 100644 index 59562a4..0000000 --- a/source/modules/asura-core/window/window_impl_sdl.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "../core_config.h" - -#if ASURA_WINDOW_SDL - -#include <SDL2/SDL.h> - -#include <asura-utils/exceptions/exception.h> - -#include "window_impl_sdl.h" - -using namespace AEGraphics; -using namespace AEImage; - -namespace_begin(AsuraEngine) -namespace_begin(Window) - -#define asura_flag_to_sdl_flag(flag, _flag, _sdl_flag) \ -if ((flag & _flag) != 0) \ - flag |= _sdl_flag - -WindowImplSDL::WindowImplSDL() - : m_Wnd(nullptr) - , m_GLContext(0) -{ -} - -WindowImplSDL::~WindowImplSDL() -{ - SDL_GL_DeleteContext(m_GLContext); - SDL_DestroyWindow(m_Wnd); - SDL_FlushEvent(SDL_WINDOWEVENT); -} - -bool WindowImplSDL::Init(const WindowConfig& config) -{ - if (SDL_Init(SDL_INIT_VIDEO) < 0) - return false; - - int flag = 0; - asura_flag_to_sdl_flag(flag, WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN); - asura_flag_to_sdl_flag(flag, WINDOW_OPENGL, SDL_WINDOW_OPENGL); - asura_flag_to_sdl_flag(flag, WINDOW_SHOWN, SDL_WINDOW_SHOWN); - asura_flag_to_sdl_flag(flag, WINDOW_HIDDEN, SDL_WINDOW_HIDDEN); - asura_flag_to_sdl_flag(flag, WINDOW_BORDERLESS, SDL_WINDOW_BORDERLESS); - asura_flag_to_sdl_flag(flag, WINDOW_RESIZABLE, SDL_WINDOW_RESIZABLE); - asura_flag_to_sdl_flag(flag, WINDOW_MINIMIZED, SDL_WINDOW_MINIMIZED); - asura_flag_to_sdl_flag(flag, WINDOW_MAXIMIZED, SDL_WINDOW_MAXIMIZED); - asura_flag_to_sdl_flag(flag, WINDOW_INPUT_GRABBED, SDL_WINDOW_INPUT_GRABBED); - asura_flag_to_sdl_flag(flag, WINDOW_INPUT_FOCUS, SDL_WINDOW_INPUT_FOCUS); - asura_flag_to_sdl_flag(flag, WINDOW_MOUSE_FOCUS, SDL_WINDOW_MOUSE_FOCUS); - asura_flag_to_sdl_flag(flag, WINDOW_ALLOW_HIGHDPI, SDL_WINDOW_ALLOW_HIGHDPI); - asura_flag_to_sdl_flag(flag, WINDOW_MOUSE_CAPTURE, SDL_WINDOW_MOUSE_CAPTURE); - asura_flag_to_sdl_flag(flag, WINDOW_ALWAYS_ON_TOP, SDL_WINDOW_ALWAYS_ON_TOP); - - // Set GL window / framebuffer attributes. - 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); - - m_Wnd = SDL_CreateWindow(config.title.c_str(), config.x, config.y, config.width, config.height, flag); - - if (!m_Wnd) - return false; - - // ͼ - try - { - if (config.icon) - { - ImageData* img = config.icon; - if (img->format == COLOR_FORMAT_RGBA8) - { - SDL_Surface *surface; - - img->Lock(); - - int w = img->width, h = img->height; - surface = SDL_CreateRGBSurfaceFrom( - img->pixels, - w, h, - 32, - w * 4, - Color32::RMASK, - Color32::GMASK, - Color32::BMASK, - Color32::AMASK - ); - - img->Unlock(); - - SDL_SetWindowIcon(m_Wnd, surface); - SDL_FreeSurface(surface); - } - } - } - catch (...) - { - } - - m_GLContext = SDL_GL_CreateContext(m_Wnd); - - if (!m_GLContext) - { - SDL_DestroyWindow(m_Wnd); - return false; - } - - SDL_GL_MakeCurrent(m_Wnd, m_GLContext); - SDL_GL_SetSwapInterval(config.vsync ? 1 : 0); - - return true; -} - -void WindowImplSDL::SetSize(uint width, uint height) -{ - SDL_SetWindowSize(m_Wnd, width, height); -} - -void WindowImplSDL::SetPosition(int x, int y) -{ - SDL_SetWindowPosition(m_Wnd, x, y); -} - -void WindowImplSDL::SetTitils(const std::string& title) -{ - SDL_SetWindowTitle(m_Wnd, title.c_str()); -} - -void WindowImplSDL::Show() -{ - SDL_ShowWindow(m_Wnd); -} - -void WindowImplSDL::Hide() -{ - SDL_HideWindow(m_Wnd); -} - -void WindowImplSDL::SwapRenderBuffer() -{ - SDL_GL_SwapWindow(m_Wnd); -} - -namespace_end -namespace_end - -#endif // ASURA_WINDOW_SDL
\ No newline at end of file diff --git a/source/modules/asura-core/window/window_impl_sdl.h b/source/modules/asura-core/window/window_impl_sdl.h deleted file mode 100644 index 20f5c95..0000000 --- a/source/modules/asura-core/window/window_impl_sdl.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __ASURA_WINDOW_SDL_H_ -#define __ASURA_WINDOW_SDL_H_ - -#include "../core_config.h" - -#if ASURA_WINDOW_SDL - -#include <SDL2/SDL.h> - -#include "window.h" - -namespace_begin(AsuraEngine) -namespace_begin(Window) - -class WindowImplSDL ASURA_FINAL : public WindowImpl -{ -public: - - WindowImplSDL(); - ~WindowImplSDL(); - - bool Init(const WindowConfig& config); - - void SetSize(uint width, uint height) override; - void SetPosition(int x, int y) override; - void SetTitils(const std::string& title) override; - - void Show() override; - void Hide() override; - - void SwapRenderBuffer() override; - -private: - - SDL_Window* m_Wnd; - SDL_GLContext m_GLContext; - -}; - -namespace_end -namespace_end - -#endif // ASURA_WINDOW_SDL - -#endif
\ No newline at end of file |