diff --git a/ee.kdevelop b/ee.kdevelop deleted file mode 100644 index 676f94ffa..000000000 --- a/ee.kdevelop +++ /dev/null @@ -1,222 +0,0 @@ - - - - Martín Lucas Golini - spartanj@gmail.com - 1 - KDevCustomProject - C++ - - ee - . - false - - - - - - - executable - eetest - - - ./ - false - false - true - false - false - - - - *.java - *.h - *.H - *.hh - *.hxx - *.hpp - *.c - *.C - *.cc - *.cpp - *.c++ - *.cxx - Makefile - CMakeLists.txt - - - - make - - - - 0 - - - - default - - - - - - false - 4 - 0 - false - - - test - default - - - - - - - - - - - - - true - false - false - false - - - false - true - 10 - - - - - ada - ada_bugs_gcc - bash - bash_bugs - clanlib - fortran_bugs_gcc - gnome1 - gnustep - gtk - gtk_bugs - haskell - haskell_bugs_ghc - java_bugs_gcc - java_bugs_sun - kde2book - opengl - pascal_bugs_fp - php - php_bugs - perl - perl_bugs - python - python_bugs - qt-kdev3 - ruby - ruby_bugs - sdl - sw - w3c-dom-level2-html - w3c-svg - w3c-uaag10 - wxwidgets_bugs - - - Guide to the Qt Translation Tools - Qt Assistant Manual - Qt Designer Manual - Qt Reference Documentation - qmake User Guide - - - KDE Libraries (Doxygen) - - - - - - - - - - - - - false - 3 - 3 - /usr/lib/qt3 - EmbeddedKDevDesigner - /usr/lib/qt3/bin/qmake - /usr/lib/qt3/bin/designer - - - - true - true - true - 0 - 200 - 250 - false - 0 - true - true - false - std=_GLIBCXX_STD;__gnu_cxx=std - false - false - true - true - false - true - true - false - .; - - - - set - m_,_ - theValue - true - true - - - false - true - Vertical - - - automatic_%2Fhome%2Fprogramming%2Fprojects%2FEE - - - - - .h - .cpp - - - - - - - - - - - - false - false - - - *.o,*.lo,CVS - false - - - diff --git a/ee.win.cbp b/ee.win.cbp index de72339c0..8fe967d46 100644 --- a/ee.win.cbp +++ b/ee.win.cbp @@ -33,7 +33,7 @@ - + @@ -46,6 +46,7 @@ + @@ -802,6 +803,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -816,6 +839,8 @@ + + @@ -825,6 +850,15 @@ + + + + + + + + + diff --git a/src/ee.h b/src/ee.h index 0d8f320dd..e6b51d58c 100755 --- a/src/ee.h +++ b/src/ee.h @@ -22,10 +22,13 @@ **/ /** - @TODO Add some Surface Grid class, to create special effects ( waved texture, and stuff like that ). + @TODO Support GLES1 ( GLES1 is just a fixed pipeline renderer, so it should be the same renderer that GLv_2 ). + @TODO Remove std::wstring dependency ( wchar_t ), and create an eeString class to manage strings without wchar_t platform restrictions ( Android only support wchar_t in 2.3 ). + @TODO Check for endianness problems, and make EEPP endianness agnostic. + @TODO Add backend for SDL 1.3 ( support for Android ). And may be SFML backend ( just for fun ). + @TODO Support for Android and iOS. @TODO Add Scripting support ( lua or squirrel ). - @TODO Support color cursors ( not only black and white cursors, that really sucks ) - Imposible with SDL 1.2 - @TODO Support for Android and iPhone + @TODO Support color cursors ( not only black and white cursors, that really sucks ) - Imposible with SDL 1.2. Allegro 5 have this implemented ( could implement this for the Allegro backend at least ). */ // General includes and declarations diff --git a/src/gaming/cisomap.cpp b/src/gaming/cisomap.cpp index c0dcbcc3c..ef637d3fb 100755 --- a/src/gaming/cisomap.cpp +++ b/src/gaming/cisomap.cpp @@ -57,7 +57,7 @@ void cIsoMap::CreateBaseVertexBuffer() { T->Q = TileQBaseCoords( x, y ); T->Box = Quad2toAABB( T->Q ); - T->TilePosStr = stringTowstring( intToStr( x ) + "-" + intToStr( y ) ); + T->TilePosStr = toStr( x) + " - " + toStr( y ); for ( i = 0; i < 4; i++ ) T->Color[i] = mMapAmbientColor; diff --git a/src/gaming/cisomap.hpp b/src/gaming/cisomap.hpp index fbea6bae7..cc4715006 100755 --- a/src/gaming/cisomap.hpp +++ b/src/gaming/cisomap.hpp @@ -25,7 +25,7 @@ class EE_API cIsoTile { eeColor Color[4]; //! Color of every vertex stored eeQuad2f Q; //! Vertex Buffer Data std::vector Layers; - std::wstring TilePosStr; + std::string TilePosStr; eeAABB Box; }; diff --git a/src/graphics/cbatchrenderer.hpp b/src/graphics/cbatchrenderer.hpp index 8c4a65369..1b99219ea 100755 --- a/src/graphics/cbatchrenderer.hpp +++ b/src/graphics/cbatchrenderer.hpp @@ -7,16 +7,16 @@ namespace EE { namespace Graphics { -typedef struct eeTexCoordS { +struct eeTexCoord { eeFloat u; eeFloat v; -} eeTexCoord; +}; -typedef struct eeVertexS { +struct eeVertex { eeVector2f pos; eeTexCoord tex; eeColorA color; -} eeVertex; +}; /** @brief A batch rendering class. */ class EE_API cBatchRenderer { diff --git a/src/graphics/cfontmanager.cpp b/src/graphics/cfontmanager.cpp index 28cdb06d6..66dbda06b 100644 --- a/src/graphics/cfontmanager.cpp +++ b/src/graphics/cfontmanager.cpp @@ -10,8 +10,6 @@ cFontManager::~cFontManager() { cFont * cFontManager::Add( cFont * Font ) { eeASSERT( NULL != Font ); - //eePRINT( "Added font: %s\n", Font->Name().c_str() ); - return tResourceManager::Add( Font ); } diff --git a/src/graphics/fonthelper.hpp b/src/graphics/fonthelper.hpp index d09a1458b..bc28fe1e9 100644 --- a/src/graphics/fonthelper.hpp +++ b/src/graphics/fonthelper.hpp @@ -29,20 +29,20 @@ inline Uint32 FontVAlignGet( Uint32 Flags ) { #define FONT_DRAW_ALIGN_MASK ( FONT_DRAW_VALIGN_MASK | FONT_DRAW_HALIGN_MASK ) /** Basic Glyph structure used by the engine */ -typedef struct eeGlyphS { +struct eeGlyph { Int32 MinX, MaxX, MinY, MaxY, Advance; Uint16 CurX, CurY, CurW, CurH, GlyphH; -} eeGlyph; +}; -typedef struct eeVertexCoordsS { +struct eeVertexCoords { eeFloat TexCoords[2]; eeFloat Vertex[2]; -} eeVertexCoords; +}; -typedef struct eeTexCoordsS { +struct eeTexCoords { eeFloat TexCoords[8]; eeFloat Vertex[8]; -} eeTexCoords; +}; }} diff --git a/src/window/backend/SDL/cwindowsdl.cpp b/src/window/backend/SDL/cwindowsdl.cpp index 0e91ed01b..feb3d5510 100644 --- a/src/window/backend/SDL/cwindowsdl.cpp +++ b/src/window/backend/SDL/cwindowsdl.cpp @@ -9,6 +9,7 @@ #include "../../../graphics/cvertexbuffermanager.hpp" #include "../../../graphics/cframebuffermanager.hpp" #include "../../../graphics/ctexturefactory.hpp" +#include "../../platform/platformimpl.hpp" namespace EE { namespace Window { namespace Backend { namespace SDL { @@ -81,9 +82,6 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { return false; } - SDL_VERSION( &mWMinfo.version ); - SDL_GetWMInfo ( &mWMinfo ); - if ( mWindow.WindowConfig.BitsPerPixel == 16 ) { SDL_GL_SetAttribute( SDL_GL_RED_SIZE , 4 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE , 4 ); @@ -96,15 +94,17 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE , 8 ); } - Caption( mWindow.WindowConfig.Caption ); - if ( NULL == cGL::ExistsSingleton() ) { cGL::CreateSingleton( mWindow.ContextConfig.Version ); cGL::instance()->Init(); } + CreatePlatform(); + GetMainContext(); + Caption( mWindow.WindowConfig.Caption ); + CreateView(); Setup2D(); @@ -126,6 +126,23 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { } } +void cWindowSDL::CreatePlatform() { + eeSAFE_DELETE( mPlatform ); + + SDL_VERSION( &mWMinfo.version ); + SDL_GetWMInfo ( &mWMinfo ); + +#if EE_PLATFORM == EE_PLATFORM_LINUX + mPlatform = eeNew( Platform::cX11Impl, ( this, mWMinfo.info.x11.display, mWMinfo.info.x11.wmwindow, mWMinfo.info.x11.lock_func, mWMinfo.info.x11.unlock_func ) ); +#elif EE_PLATFORM == EE_PLATFORM_WIN + mPlatform = eeNew( Platform::cWinImpl, ( this, GetWindowHandler() ) ); +#elif EE_PLATFORM == EE_PLATFORM_MACOSX + mPlatform = eeNew( Platform::cOSXImpl, ( this ) ); +#else + cWindow::CreatePlatform(); +#endif +} + void cWindowSDL::SetGLConfig() { SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE , mWindow.ContextConfig.DepthBufferSize ); // Depth SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, ( mWindow.ContextConfig.DoubleBuffering ? 1 : 0 ) ); // Double Buffering @@ -224,95 +241,6 @@ bool cWindowSDL::Icon( const std::string& Path ) { return false; } -void cWindowSDL::Minimize() { - SDL_WM_IconifyWindow(); -} - -void cWindowSDL::Maximize() { - #if EE_PLATFORM == EE_PLATFORM_WIN - WIN_ShowWindow(mWMinfo.window, SW_MAXIMIZE); - #elif EE_PLATFORM == EE_PLATFORM_LINUX - // coded by Rafał Maj, idea from Måns Rullgård http://tinyurl.com/68mvk3 - mWMinfo.info.x11.lock_func(); - - XEvent xev; - Atom wm_state = XInternAtom( mWMinfo.info.x11.display, "_NET_WM_STATE", False); - Atom maximizeV = XInternAtom( mWMinfo.info.x11.display, "_NET_WM_STATE_MAXIMIZED_VERT", False); - Atom maximizeH = XInternAtom( mWMinfo.info.x11.display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); - - memset( &xev, 0, sizeof(xev) ); - xev.type = ClientMessage; - xev.xclient.window = mWMinfo.info.x11.wmwindow; - xev.xclient.message_type = wm_state; - xev.xclient.format = 32; - xev.xclient.data.l[0] = 1; - xev.xclient.data.l[1] = maximizeV; - xev.xclient.data.l[2] = maximizeH; - xev.xclient.data.l[3] = 0; - XSendEvent( mWMinfo.info.x11.display, DefaultRootWindow(mWMinfo.info.x11.display), 0, SubstructureNotifyMask|SubstructureRedirectMask, &xev); - - XFlush(mWMinfo.info.x11.display); - - mWMinfo.info.x11.unlock_func(); - #else - #warning cWindowSDL::MaximizeWindow() not implemented on this platform. - #endif -} - -void cWindowSDL::Hide() { -#if EE_PLATFORM == EE_PLATFORM_LINUX - mWMinfo.info.x11.lock_func(); - XUnmapWindow( mWMinfo.info.x11.display, mWMinfo.info.x11.wmwindow ); - mWMinfo.info.x11.unlock_func(); -#elif EE_PLATFORM == EE_PLATFORM_WIN - WIN_ShowWindow( mWMinfo.window, SW_HIDE ); -#else - #warning cWindowSDL::HideWindow() not implemented on this platform. -#endif -} - -void cWindowSDL::Raise() { -#if EE_PLATFORM == EE_PLATFORM_LINUX - mWMinfo.info.x11.lock_func(); - XRaiseWindow( mWMinfo.info.x11.display, mWMinfo.info.x11.wmwindow ); - mWMinfo.info.x11.unlock_func(); -#elif EE_PLATFORM == EE_PLATFORM_WIN - HWND top; - - if ( !Windowed() ) - top = HWND_TOPMOST; - else - top = HWND_NOTOPMOST; - - SetWindowPos( mWMinfo.window, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE) ); -#else - #warning cWindowSDL::RaiseWindow() not implemented on this platform. -#endif -} - -void cWindowSDL::Show() { -#if EE_PLATFORM == EE_PLATFORM_LINUX - mWMinfo.info.x11.lock_func(); - XMapRaised( mWMinfo.info.x11.display, mWMinfo.info.x11.wmwindow ); - mWMinfo.info.x11.unlock_func(); -#elif EE_PLATFORM == EE_PLATFORM_WIN - WIN_ShowWindow( mWMinfo.window, SW_SHOW ); -#else - #warning cWindowSDL::RaiseWindow() not implemented on this platform. -#endif -} - -void cWindowSDL::Position( Int16 Left, Int16 Top ) { -#if EE_PLATFORM == EE_PLATFORM_LINUX - XMoveWindow( mWMinfo.info.x11.display, mWMinfo.info.x11.wmwindow, Left, Top); - XFlush( mWMinfo.info.x11.display ); -#elif EE_PLATFORM == EE_PLATFORM_WIN - SetWindowPos( mWMinfo.window, NULL, Left, Top, 0, 0, SWP_NOSIZE | SWP_NOZORDER ); -#else - #warning cWindowSDL::SetWindowPosition() not implemented on this platform. -#endif -} - bool cWindowSDL::Active() { return 0 != ( SDL_GetAppState() & SDL_APPINPUTFOCUS ); } @@ -321,22 +249,6 @@ bool cWindowSDL::Visible() { return 0 != ( SDL_GetAppState() & SDL_APPACTIVE ); } -eeVector2i cWindowSDL::Position() { -#if EE_PLATFORM == EE_PLATFORM_LINUX - XWindowAttributes Attrs; - XGetWindowAttributes( mWMinfo.info.x11.display, mWMinfo.info.x11.wmwindow, &Attrs ); - - return eeVector2i( Attrs.x, Attrs.y ); -#elif EE_PLATFORM == EE_PLATFORM_WIN - RECT r; - GetWindowRect( mWMinfo.window, &r ); - return eeVector2i( r.left, r.top ); -#else - #warning cWindowSDL::GetWindowPos() not implemented on this platform. - return eeVector2i( 0, 0 ); -#endif -} - void cWindowSDL::Size( const Uint32& Width, const Uint32& Height ) { if ( Windowed() ) { Size( Width, Height, true ); @@ -392,6 +304,7 @@ void cWindowSDL::Size( const Uint16& Width, const Uint16& Height, const bool& Wi Graphics::Private::cFrameBufferManager::instance()->Reload(); // Reload all frame buffers Graphics::Private::cVertexBufferManager::instance()->Reload(); // Reload all vertex buffers GetMainContext(); // Recover the context + CreatePlatform(); } #endif @@ -450,26 +363,6 @@ eeWindowHandler cWindowSDL::GetWindowHandler() { #endif } -void cWindowSDL::SetCurrentContext( eeWindowContex Context ) { - if ( mWindow.Created ) { - #ifdef EE_GLEW_AVAILABLE - - #if EE_PLATFORM == EE_PLATFORM_WIN - wglMakeCurrent( GetDC( mWMinfo.window ), Context ); - #elif EE_PLATFORM == EE_PLATFORM_LINUX - mWMinfo.info.x11.lock_func(); - glXMakeCurrent( mWMinfo.info.x11.display, mWMinfo.info.x11.window, Context ); - mWMinfo.info.x11.unlock_func(); - #elif EE_PLATFORM == EE_PLATFORM_MACOSX - aglSetCurrentContext( Context ); - #else - #warning No context supported on this platform - #endif - - #endif - } -} - }}}} #endif diff --git a/src/window/backend/SDL/cwindowsdl.hpp b/src/window/backend/SDL/cwindowsdl.hpp index 12444d831..ed233f9ea 100644 --- a/src/window/backend/SDL/cwindowsdl.hpp +++ b/src/window/backend/SDL/cwindowsdl.hpp @@ -25,24 +25,10 @@ class EE_API cWindowSDL : public cWindow { bool Icon( const std::string& Path ); - void Minimize(); - - void Maximize(); - - void Hide(); - - void Raise(); - - void Show(); - - void Position( Int16 Left, Int16 Top ); - bool Active(); bool Visible(); - eeVector2i Position(); - void Size( const Uint32& Width, const Uint32& Height ); void Size( const Uint16& Width, const Uint16& Height, const bool& Windowed ); @@ -53,8 +39,6 @@ class EE_API cWindowSDL : public cWindow { void SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ); - void SetCurrentContext( eeWindowContex Context ); - eeWindowHandler GetWindowHandler(); protected: friend class cClipboardSDL; @@ -62,6 +46,8 @@ class EE_API cWindowSDL : public cWindow { SDL_Surface * mSurface; SDL_SysWMinfo mWMinfo; + void CreatePlatform(); + void SwapBuffers(); void SetGLConfig(); diff --git a/src/window/backend/allegro5/cwindowal.cpp b/src/window/backend/allegro5/cwindowal.cpp index ad0b8aaba..8ddde3e5e 100644 --- a/src/window/backend/allegro5/cwindowal.cpp +++ b/src/window/backend/allegro5/cwindowal.cpp @@ -9,12 +9,99 @@ #include "../../../graphics/cvertexbuffermanager.hpp" #include "../../../graphics/cframebuffermanager.hpp" #include "../../../graphics/ctexturefactory.hpp" - -#include + +#include "../../platform/platformimpl.hpp" #if EE_PLATFORM == EE_PLATFORM_WIN -#include +#include +#define WGL_NV_video_out +#elif EE_PLATFORM == EE_PLATFORM_LINUX + +#include +#include + +struct ALLEGRO_SYSTEM_XGLX +{ + ALLEGRO_SYSTEM system; + Display *x11display; + Display *gfxdisplay; + Atom AllegroAtom; + #ifdef ALLEGRO_XWINDOWS_WITH_XF86VIDMODE + int xfvm_available; + int xfvm_screen_count; + struct { + int mode_count; + void **modes; + void *original_mode; + } *xfvm_screen; + #endif + _AL_THREAD thread; + _AL_MUTEX lock; + _AL_COND resized; + ALLEGRO_DISPLAY *mouse_grab_display; + int toggle_mouse_grab_keycode; + unsigned int toggle_mouse_grab_modifiers; + bool inhibit_screensaver; + + bool mmon_interface_inited; +#ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA + int xinerama_available; + int xinerama_screen_count; + void *xinerama_screen_info; #endif +#ifdef ALLEGRO_XWINDOWS_WITH_XRANDR + int xrandr_available; + int xrandr_event_base; + + _AL_VECTOR xrandr_screens; + _AL_VECTOR xrandr_adaptermap; +#endif + uint32_t adapter_use_count; + int adapter_map[32]; +}; + +struct ALLEGRO_DISPLAY_XGLX +{ + ALLEGRO_DISPLAY display; + Window window; + int xscreen; + int adapter; + GLXWindow glxwindow; + GLXContext context; + Atom wm_delete_window_atom; + XVisualInfo *xvinfo; + GLXFBConfig *fbc; + int glx_version; + _AL_COND mapped; + bool is_mapped; + int resize_count; + bool programmatic_resize; + Cursor invisible_cursor; + Cursor current_cursor; + bool cursor_hidden; + Pixmap icon, icon_mask; + int x, y; + bool mouse_warp; +}; +static _AL_MUTEX * al_display_mutex = NULL; + +static void al_display_lock() { + if ( NULL != al_display_mutex ) { + _al_mutex_lock( al_display_mutex ); + } +} + +static void al_display_unlock() { + if ( NULL != al_display_mutex ) { + _al_mutex_unlock( al_display_mutex ); + } +} + +#endif + +#include +#include +#include namespace EE { namespace Window { namespace Backend { namespace Al { @@ -99,6 +186,8 @@ bool cWindowAl::Create( WindowSettings Settings, ContextSettings Context ) { cGL::instance()->Init(); + CreatePlatform(); + GetMainContext(); CreateView(); @@ -117,12 +206,33 @@ bool cWindowAl::Create( WindowSettings Settings, ContextSettings Context ) { return true; } - + LogFailureInit( "cWindowAl", "Allegro 5" ); return false; } +void cWindowAl::SetCurrent() { +#if EE_PLATFORM == EE_PLATFORM_LINUX + al_display_mutex = &((ALLEGRO_SYSTEM_XGLX *)al_get_system_driver())->lock; +#endif +} + +void cWindowAl::CreatePlatform() { + eeSAFE_DELETE( mPlatform ); + +#if EE_PLATFORM == EE_PLATFORM_LINUX + SetCurrent(); + mPlatform = eeNew( Platform::cX11Impl, ( this, GetWindowHandler(), ((ALLEGRO_DISPLAY_XGLX *)mDisplay)->window, al_display_lock, al_display_unlock ) ); +#elif EE_PLATFORM == EE_PLATFORM_WIN + mPlatform = eeNew( Platform::cWinImpl, ( this, GetWindowHandler() ) ); +#elif EE_PLATFORM == EE_PLATFORM_MACOSX + mPlatform = eeNew( Platform::cOSXImpl, ( this ) ); +#else + cWindow::CreatePlatform(); +#endif +} + void cWindowAl::ToggleFullscreen() { bool WasMaximized = mWindow.Maximized; @@ -147,25 +257,6 @@ bool cWindowAl::Icon( const std::string& Path ) { return false; } -void cWindowAl::Minimize() { -} - -void cWindowAl::Maximize() { -} - -void cWindowAl::Hide() { -} - -void cWindowAl::Raise() { -} - -void cWindowAl::Show() { -} - -void cWindowAl::Position( Int16 Left, Int16 Top ) { - al_set_window_position( mDisplay, Left, Top ); -} - bool cWindowAl::Active() { return mActive; } @@ -176,9 +267,7 @@ bool cWindowAl::Visible() { eeVector2i cWindowAl::Position() { eeVector2i Pos; - al_get_window_position( mDisplay, &Pos.x, &Pos.y ); - return Pos; } @@ -298,12 +387,12 @@ std::vector< std::pair > cWindowAl::GetPossibleResol void cWindowAl::SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ) { } -void cWindowAl::SetCurrentContext( eeWindowContex Context ) { -} - eeWindowHandler cWindowAl::GetWindowHandler() { #if EE_PLATFORM == EE_PLATFORM_WIN - al_get_win_window_handle( mDisplay ); + return al_get_win_window_handle( mDisplay ); + #elif EE_PLATFORM == EE_PLATFORM_LINUX + ALLEGRO_SYSTEM_XGLX * glx = (ALLEGRO_SYSTEM_XGLX *)al_get_system_driver(); + return glx->x11display; #else return 0; #endif diff --git a/src/window/backend/allegro5/cwindowal.hpp b/src/window/backend/allegro5/cwindowal.hpp index e7ae686af..484054bc0 100644 --- a/src/window/backend/allegro5/cwindowal.hpp +++ b/src/window/backend/allegro5/cwindowal.hpp @@ -4,8 +4,10 @@ #include "../../cbackend.hpp" #ifdef EE_BACKEND_ALLEGRO_ACTIVE - -#include + +#define ALLEGRO_LIB_BUILD +#include +#include #include "../../cwindow.hpp" namespace EE { namespace Window { namespace Backend { namespace Al { @@ -13,29 +15,17 @@ namespace EE { namespace Window { namespace Backend { namespace Al { class EE_API cWindowAl : public cWindow { public: cWindowAl( WindowSettings Settings, ContextSettings Context ); - + virtual ~cWindowAl(); - + bool Create( WindowSettings Settings, ContextSettings Context ); - + void ToggleFullscreen(); - + void Caption( const std::string& Caption ); bool Icon( const std::string& Path ); - void Minimize(); - - void Maximize(); - - void Hide(); - - void Raise(); - - void Show(); - - void Position( Int16 Left, Int16 Top ); - bool Active(); bool Visible(); @@ -45,15 +35,13 @@ class EE_API cWindowAl : public cWindow { void Size( const Uint32& Width, const Uint32& Height ); void Size( const Uint16& Width, const Uint16& Height, const bool& Windowed ); - + void ShowCursor( const bool& showcursor ); std::vector< std::pair > GetPossibleResolutions() const; void SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ); - void SetCurrentContext( eeWindowContex Context ); - eeWindowHandler GetWindowHandler(); void SetDefaultContext(); @@ -62,10 +50,14 @@ class EE_API cWindowAl : public cWindow { protected: friend class cClipboardAl; friend class cInputAl; - + ALLEGRO_DISPLAY * mDisplay; bool mActive; - + + void CreatePlatform(); + + void SetCurrent(); + void SwapBuffers(); void DestroyDisplay(); diff --git a/src/window/base.hpp b/src/window/base.hpp index 003923c06..3bd0f2641 100644 --- a/src/window/base.hpp +++ b/src/window/base.hpp @@ -36,6 +36,7 @@ using namespace EE::Graphics; typedef Window X11Window; typedef Display * eeWindowHandler; #undef Window + #undef Display #elif EE_PLATFORM == EE_PLATFORM_MACOSX typedef Uint32 eeScrapType; typedef void * eeWindowHandler; // NSWindow * diff --git a/src/window/cengine.cpp b/src/window/cengine.cpp index f6c43d864..1f8b6beb8 100755 --- a/src/window/cengine.cpp +++ b/src/window/cengine.cpp @@ -43,7 +43,7 @@ cEngine::cEngine() : #endif } -cEngine::~cEngine() { +cEngine::~cEngine() { Physics::cPhysicsManager::DestroySingleton(); Graphics::Private::cFrameBufferManager::DestroySingleton(); @@ -97,13 +97,13 @@ cWindow * cEngine::CreateWindow( WindowSettings Settings, ContextSettings Contex } mWindows.push_back( mWindow ); - + return window; } void cEngine::DestroyWindow( cWindow * window ) { mWindows.remove( window ); - + if ( window == mWindow ) { if ( mWindows.size() > 0 ) { mWindow = mWindows.back(); @@ -111,7 +111,7 @@ void cEngine::DestroyWindow( cWindow * window ) { mWindow = NULL; } } - + eeSAFE_DELETE( window ); } @@ -133,8 +133,8 @@ cWindow * cEngine::GetCurrentWindow() const { void cEngine::SetCurrentWindow( cWindow * window ) { if ( NULL != window ) { mWindow = window; - - mWindow->SetDefaultContext(); + + mWindow->SetCurrent(); } } @@ -148,19 +148,19 @@ bool cEngine::Running() const { eeFloat cEngine::Elapsed() const { eeASSERT( Running() ); - + return mWindow->Elapsed(); } const Uint32& cEngine::GetWidth() const { eeASSERT( Running() ); - + return mWindow->GetWidth(); } const Uint32& cEngine::GetHeight() const { eeASSERT( Running() ); - + return mWindow->GetHeight(); } diff --git a/src/window/cplatformimpl.cpp b/src/window/cplatformimpl.cpp new file mode 100644 index 000000000..f19d0f655 --- /dev/null +++ b/src/window/cplatformimpl.cpp @@ -0,0 +1,14 @@ +#include "cplatformimpl.hpp" +#include "cwindow.hpp" + +namespace EE { namespace Window { namespace Platform { + +cPlatformImpl::cPlatformImpl( cWindow * window ) : + mWindow( window ) +{ +} + +cPlatformImpl::~cPlatformImpl() { +} + +}}} diff --git a/src/window/cplatformimpl.hpp b/src/window/cplatformimpl.hpp new file mode 100644 index 000000000..ab81b7b11 --- /dev/null +++ b/src/window/cplatformimpl.hpp @@ -0,0 +1,41 @@ +#ifndef EE_WINDOWCPLATFORMIMPL_HPP +#define EE_WINDOWCPLATFORMIMPL_HPP + +#include "base.hpp" + +namespace EE { namespace Window { +class cWindow; +}} + +namespace EE { namespace Window { namespace Platform { + +using namespace EE::Window; + +class cPlatformImpl { + public: + cPlatformImpl( cWindow * window ); + + virtual ~cPlatformImpl(); + + virtual void MinimizeWindow() = 0; + + virtual void MaximizeWindow() = 0; + + virtual void HideWindow() = 0; + + virtual void RaiseWindow() = 0; + + virtual void ShowWindow() = 0; + + virtual void MoveWindow( int left, int top ) = 0; + + virtual void SetContext( eeWindowContex Context ) = 0; + + virtual eeVector2i Position() = 0; + protected: + cWindow * mWindow; +}; + +}}} + +#endif diff --git a/src/window/cwindow.cpp b/src/window/cwindow.cpp index 38eb8113f..6120ea910 100644 --- a/src/window/cwindow.cpp +++ b/src/window/cwindow.cpp @@ -2,12 +2,14 @@ #include "cclipboard.hpp" #include "cinput.hpp" #include "../graphics/ctexturefactory.hpp" +#include "platform/null/cnullimpl.hpp" namespace EE { namespace Window { cWindow::cWindow( WindowSettings Settings, ContextSettings Context, cClipboard * Clipboard, cInput * Input ) : mClipboard( Clipboard ), mInput( Input ), + mPlatform( NULL ), mNumCallBacks( 0 ) { mWindow.WindowConfig = Settings; @@ -17,6 +19,7 @@ cWindow::cWindow( WindowSettings Settings, ContextSettings Context, cClipboard * cWindow::~cWindow() { eeSAFE_DELETE( mClipboard ); eeSAFE_DELETE( mInput ); + eeSAFE_DELETE( mPlatform ); } eeSize cWindow::Size() { @@ -337,4 +340,54 @@ void cWindow::SetDefaultContext() { #endif } +void cWindow::Minimize() { + if ( NULL != mPlatform ) + mPlatform->MinimizeWindow(); +} + +void cWindow::Maximize() { + if ( NULL != mPlatform ) + mPlatform->MaximizeWindow(); +} + +void cWindow::Hide() { + if ( NULL != mPlatform ) + mPlatform->HideWindow(); +} + +void cWindow::Raise() { + if ( NULL != mPlatform ) + mPlatform->RaiseWindow(); +} + +void cWindow::Show() { + if ( NULL != mPlatform ) + mPlatform->ShowWindow(); +} + +void cWindow::Position( Int16 Left, Int16 Top ) { + if ( NULL != mPlatform ) + mPlatform->MoveWindow( Left, Top ); +} + +eeVector2i cWindow::Position() { + if ( NULL != mPlatform ) + return mPlatform->Position(); + + return eeVector2i(); +} + +void cWindow::SetCurrentContext( eeWindowContex Context ) { + if ( NULL != mPlatform ) + mPlatform->SetContext( Context ); +} + +void cWindow::CreatePlatform() { + eeSAFE_DELETE( mPlatform ); + mPlatform = eeNew( Platform::cNullImpl, ( this ) ); +} + +void cWindow::SetCurrent() { +} + }} diff --git a/src/window/cwindow.hpp b/src/window/cwindow.hpp index 35d826717..b5d99acb1 100644 --- a/src/window/cwindow.hpp +++ b/src/window/cwindow.hpp @@ -3,6 +3,7 @@ #include "base.hpp" #include "cview.hpp" +#include "cplatformimpl.hpp" namespace EE { namespace Window { @@ -118,22 +119,28 @@ class EE_API cWindow { virtual bool Icon( const std::string& Path ) = 0; /** This will attempt to iconify/minimize the window. */ - virtual void Minimize() = 0; + virtual void Minimize(); /** Maximize the Window */ - virtual void Maximize() = 0; + virtual void Maximize(); /** This will attempt to hide the window */ - virtual void Hide() = 0; + virtual void Hide(); /** This will attempt to raise the window */ - virtual void Raise() = 0; + virtual void Raise(); /** This will attempt to show the window */ - virtual void Show() = 0; + virtual void Show(); /** This will attemp to move the window over the desktop to the position */ - virtual void Position( Int16 Left, Int16 Top ) = 0; + virtual void Position( Int16 Left, Int16 Top ); + + /** @return The Current Window Position */ + virtual eeVector2i Position(); + + /** Set as current context the default context ( the context used for the window creation ) */ + virtual void SetDefaultContext(); /** @return If the current window is active */ virtual bool Active() = 0; @@ -141,9 +148,6 @@ class EE_API cWindow { /** @return If the current window is visible */ virtual bool Visible() = 0; - /** @return The Current Window Position */ - virtual eeVector2i Position() = 0; - /** Set to show or not the curson on the main screen */ virtual void ShowCursor( const bool& showcursor ) = 0; @@ -167,7 +171,7 @@ class EE_API cWindow { virtual void SetGamma( eeFloat Red, eeFloat Green, eeFloat Blue ) = 0; /** The the OpenGL context as the current context */ - virtual void SetCurrentContext( eeWindowContex Context ) = 0; + virtual void SetCurrentContext( eeWindowContex Context ); /** @return The current OpenGL context */ virtual eeWindowContex GetContext() const; @@ -175,9 +179,6 @@ class EE_API cWindow { /** @return The window handler */ virtual eeWindowHandler GetWindowHandler() = 0; - /** Set as current context the default context ( the context used for the window creation ) */ - virtual void SetDefaultContext(); - /** Render the Scene to Screen */ virtual void Display(); @@ -280,12 +281,15 @@ class EE_API cWindow { /** Pop the callback id indicated. */ void PopResizeCallback( const Uint32& CallbackId ); protected: - WindowInfo mWindow; - cClipboard * mClipboard; - cInput * mInput; - cView mDefaultView; - const cView * mCurrentView; - Uint32 mNumCallBacks; + friend class cEngine; + + WindowInfo mWindow; + cClipboard * mClipboard; + cInput * mInput; + Platform::cPlatformImpl * mPlatform; + cView mDefaultView; + const cView * mCurrentView; + Uint32 mNumCallBacks; std::map mCallbacks; struct _FrameData { @@ -301,12 +305,17 @@ class EE_API cWindow { eeFloat ElapsedTime; } mFrameData; + /** Set the flag state to be the current window */ + virtual void SetCurrent(); + /** Swap Buffers call */ virtual void SwapBuffers() = 0; /** Obtain the Main Context, this is called after the OpenGL context creation. */ virtual void GetMainContext(); + virtual void CreatePlatform(); + void SendVideoResizeCb(); void CreateView(); diff --git a/src/window/platform/null/cnullimpl.cpp b/src/window/platform/null/cnullimpl.cpp new file mode 100644 index 000000000..a31337e63 --- /dev/null +++ b/src/window/platform/null/cnullimpl.cpp @@ -0,0 +1,38 @@ +#include "cnullimpl.hpp" + +namespace EE { namespace Window { namespace Platform { + +cNullImpl::cNullImpl( cWindow * window ) : + cPlatformImpl( window ) +{ +} + +cNullImpl::~cNullImpl() { +} + +void cNullImpl::MinimizeWindow() { +} + +void cNullImpl::MaximizeWindow() { +} + +void cNullImpl::HideWindow() { +} + +void cNullImpl::RaiseWindow() { +} + +void cNullImpl::ShowWindow() { +} + +void cNullImpl::MoveWindow( int left, int top ) { +} + +void cNullImpl::SetContext( eeWindowContex Context ) { +} + +eeVector2i cNullImpl::Position() { + return eeVector2i(0,0); +} + +}}} diff --git a/src/window/platform/null/cnullimpl.hpp b/src/window/platform/null/cnullimpl.hpp new file mode 100644 index 000000000..d7288daf3 --- /dev/null +++ b/src/window/platform/null/cnullimpl.hpp @@ -0,0 +1,37 @@ +#ifndef EE_WINDOWcNullImpl_HPP +#define EE_WINDOWcNullImpl_HPP + +#include "../../base.hpp" +#include "../../cplatformimpl.hpp" + +namespace EE { namespace Window { namespace Platform { + +using namespace EE::Window; + +class cNullImpl : public cPlatformImpl { + public: + cNullImpl( cWindow * window ); + + ~cNullImpl(); + + void MinimizeWindow(); + + void MaximizeWindow(); + + void HideWindow(); + + void RaiseWindow(); + + void ShowWindow(); + + void MoveWindow( int left, int top ); + + void SetContext( eeWindowContex Context ); + + eeVector2i Position(); + protected: +}; + +}}} + +#endif diff --git a/src/window/platform/osx/cosximpl.cpp b/src/window/platform/osx/cosximpl.cpp new file mode 100644 index 000000000..e0af15c99 --- /dev/null +++ b/src/window/platform/osx/cosximpl.cpp @@ -0,0 +1,43 @@ +#include "cosximpl.hpp" + +#if EE_PLATFORM == EE_PLATFORM_MACOSX + +namespace EE { namespace Window { namespace Platform { + +cOSXImpl::cOSXImpl( cWindow * window ) : + cPlatformImpl( window ) +{ +} + +cOSXImpl::~cOSXImpl() { +} + +void cOSXImpl::MinimizeWindow() { +} + +void cOSXImpl::MaximizeWindow() { +} + +void cOSXImpl::HideWindow() { +} + +void cOSXImpl::RaiseWindow() { +} + +void cOSXImpl::ShowWindow() { +} + +void cOSXImpl::MoveWindow( int left, int top ) { +} + +void cOSXImpl::SetContext( eeWindowContex Context ) { + aglSetCurrentContext( Context ); +} + +eeVector2i cOSXImpl::Position() { + return eeVector2i(0,0); +} + +}}} + +#endif diff --git a/src/window/platform/osx/cosximpl.hpp b/src/window/platform/osx/cosximpl.hpp new file mode 100644 index 000000000..099977fdc --- /dev/null +++ b/src/window/platform/osx/cosximpl.hpp @@ -0,0 +1,41 @@ +#ifndef EE_WINDOWCOSXIMPL_HPP +#define EE_WINDOWCOSXIMPL_HPP + +#include "../../base.hpp" +#include "../../cplatformimpl.hpp" + +#if EE_PLATFORM == EE_PLATFORM_MACOSX + +namespace EE { namespace Window { namespace Platform { + +using namespace EE::Window; + +class cOSXImpl : public cPlatformImpl { + public: + cOSXImpl( cWindow * window ); + + ~cOSXImpl(); + + void MinimizeWindow(); + + void MaximizeWindow(); + + void HideWindow(); + + void RaiseWindow(); + + void ShowWindow(); + + void MoveWindow( int left, int top ); + + void SetContext( eeWindowContex Context ); + + eeVector2i Position(); + protected: +}; + +}}} + +#endif + +#endif diff --git a/src/window/platform/platformimpl.hpp b/src/window/platform/platformimpl.hpp new file mode 100644 index 000000000..83b3341d7 --- /dev/null +++ b/src/window/platform/platformimpl.hpp @@ -0,0 +1,16 @@ +#ifndef EE_WINDOWPLATFORMIMPL_HPP +#define EE_WINDOWPLATFORMIMPL_HPP + +#include "../../base.hpp" + +#if EE_PLATFORM == EE_PLATFORM_LINUX +#include "../platform/x11/cx11impl.hpp" +#elif EE_PLATFORM == EE_PLATFORM_WIN +#include "../platform/win/cwinimpl.hpp" +#elif EE_PLATFORM == EE_PLATFORM_MACOSX +#include "../platform/osx/cosximpl.hpp" +#else +#include "../platform/null/cnullimpl.hpp" +#endif + +#endif diff --git a/src/window/platform/win/cwinimpl.cpp b/src/window/platform/win/cwinimpl.cpp new file mode 100644 index 000000000..85f1849a8 --- /dev/null +++ b/src/window/platform/win/cwinimpl.cpp @@ -0,0 +1,61 @@ +#include "cwinimpl.hpp" + +#if EE_PLATFORM == EE_PLATFORM_WIN + +#include "../../cwindow.hpp" + +namespace EE { namespace Window { namespace Platform { + +cWinImpl::cWinImpl( cWindow * window, eeWindowHandler handler ) : + cPlatformImpl( window ), + mHandler( handler ) +{ +} + +cWinImpl::~cWinImpl() { +} + +void cWinImpl::MinimizeWindow() { + WIN_ShowWindow( mHandler, SW_MINIMIZE ); +} + +void cWinImpl::MaximizeWindow() { + WIN_ShowWindow( mHandler, SW_MAXIMIZE ); +} + +void cWinImpl::HideWindow() { + WIN_ShowWindow( mHandler, SW_HIDE ); +} + +void cWinImpl::RaiseWindow() { + HWND top; + + if ( !mWindow->Windowed() ) + top = HWND_TOPMOST; + else + top = HWND_NOTOPMOST; + + SetWindowPos( mHandler, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE) ); +} + +void cWinImpl::ShowWindow() { + WIN_ShowWindow( mHandler, SW_SHOW ); +} + +void cWinImpl::MoveWindow( int left, int top ) { + SetWindowPos( mHandler, NULL, left, top, 0, 0, SWP_NOSIZE | SWP_NOZORDER ); +} + +void cWinImpl::SetContext( eeWindowContex Context ) { + wglMakeCurrent( GetDC( mHandler ), Context ); +} + +eeVector2i cWinImpl::Position() { + RECT r; + GetWindowRect( mHandler, &r ); + return eeVector2i( r.left, r.top ); +} + +}}} + +#endif diff --git a/src/window/platform/win/cwinimpl.hpp b/src/window/platform/win/cwinimpl.hpp new file mode 100644 index 000000000..1ed291345 --- /dev/null +++ b/src/window/platform/win/cwinimpl.hpp @@ -0,0 +1,42 @@ +#ifndef EE_WINDOWCWINIMPL_HPP +#define EE_WINDOWCWINIMPL_HPP + +#include "../../base.hpp" +#include "../../cplatformimpl.hpp" + +#if EE_PLATFORM == EE_PLATFORM_WIN + +namespace EE { namespace Window { namespace Platform { + +using namespace EE::Window; + +class cWinImpl : public cPlatformImpl { + public: + cWinImpl( cWindow * window, eeWindowHandler handler ); + + ~cWinImpl(); + + void MinimizeWindow(); + + void MaximizeWindow(); + + void HideWindow(); + + void RaiseWindow(); + + void ShowWindow(); + + void MoveWindow( int left, int top ); + + void SetContext( eeWindowContex Context ); + + eeVector2i Position(); + protected: + eeWindowHandler mHandler; +}; + +}}} + +#endif + +#endif diff --git a/src/window/platform/x11/cx11impl.cpp b/src/window/platform/x11/cx11impl.cpp new file mode 100644 index 000000000..5d4ff49c6 --- /dev/null +++ b/src/window/platform/x11/cx11impl.cpp @@ -0,0 +1,91 @@ +#include "cx11impl.hpp" + +#if EE_PLATFORM == EE_PLATFORM_LINUX + +namespace EE { namespace Window { namespace Platform { + +cX11Impl::cX11Impl( cWindow * window, eeWindowHandler display, X11Window xwindow, LockFunc lock, UnlockFunc unlock ) : + cPlatformImpl( window ), + mDisplay( display ), + mWindow( xwindow ), + mLock( lock ), + mUnlock( unlock ) +{ +} + +cX11Impl::~cX11Impl() { +} + +void cX11Impl::MinimizeWindow() { + mLock(); + XIconifyWindow( mDisplay, DefaultRootWindow( mDisplay ), 0 ); + XFlush(mDisplay); + mUnlock(); +} + +void cX11Impl::MaximizeWindow() { + // coded by Rafał Maj, idea from Måns Rullgård http://tinyurl.com/68mvk3 + mLock(); + + XEvent xev; + Atom wm_state = XInternAtom( mDisplay, "_NET_WM_STATE", False); + Atom maximizeV = XInternAtom( mDisplay, "_NET_WM_STATE_MAXIMIZED_VERT", False); + Atom maximizeH = XInternAtom( mDisplay, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + + memset( &xev, 0, sizeof(xev) ); + xev.type = ClientMessage; + xev.xclient.window = mWindow; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 1; + xev.xclient.data.l[1] = maximizeV; + xev.xclient.data.l[2] = maximizeH; + xev.xclient.data.l[3] = 0; + XSendEvent( mDisplay, DefaultRootWindow(mDisplay), 0, SubstructureNotifyMask|SubstructureRedirectMask, &xev); + + XFlush(mDisplay); + + mUnlock(); +} + +void cX11Impl::HideWindow() { + mLock(); + XUnmapWindow( mDisplay, mWindow ); + mUnlock(); +} + +void cX11Impl::RaiseWindow() { + mLock(); + XRaiseWindow( mDisplay, mWindow ); + mUnlock(); +} + +void cX11Impl::ShowWindow() { + mLock(); + XMapRaised( mDisplay, mWindow ); + mUnlock(); +} + +void cX11Impl::MoveWindow( int left, int top ) { + mLock(); + XMoveWindow( mDisplay, mWindow, left, top ); + XFlush( mDisplay ); + mUnlock(); +} + +void cX11Impl::SetContext( eeWindowContex Context ) { + /// FIXME: This is wrong + /*mLock(); + glXMakeCurrent( mDisplay, mWindow, Context ); + mUnlock();*/ +} + +eeVector2i cX11Impl::Position() { + XWindowAttributes Attrs; + XGetWindowAttributes( mDisplay, mWindow, &Attrs ); + return eeVector2i( Attrs.x, Attrs.y ); +} + +}}} + +#endif diff --git a/src/window/platform/x11/cx11impl.hpp b/src/window/platform/x11/cx11impl.hpp new file mode 100644 index 000000000..cce4b34ef --- /dev/null +++ b/src/window/platform/x11/cx11impl.hpp @@ -0,0 +1,48 @@ +#ifndef EE_WINDOWCX11IMPL_HPP +#define EE_WINDOWCX11IMPL_HPP + +#include "../../base.hpp" +#include "../../cplatformimpl.hpp" + +#if EE_PLATFORM == EE_PLATFORM_LINUX + +namespace EE { namespace Window { namespace Platform { + +using namespace EE::Window; + +class cX11Impl : public cPlatformImpl { + public: + typedef void (*LockFunc)(void); + typedef void (*UnlockFunc)(void); + + cX11Impl( cWindow * window, eeWindowHandler display, X11Window xwindow, LockFunc lock, UnlockFunc unlock ); + + ~cX11Impl(); + + void MinimizeWindow(); + + void MaximizeWindow(); + + void HideWindow(); + + void RaiseWindow(); + + void ShowWindow(); + + void MoveWindow( int left, int top ); + + void SetContext( eeWindowContex Context ); + + eeVector2i Position(); + protected: + eeWindowHandler mDisplay; + X11Window mWindow; + LockFunc mLock; + UnlockFunc mUnlock; +}; + +}}} + +#endif + +#endif