diff --git a/include/eepp/declares.hpp b/include/eepp/declares.hpp index 63ce9e762..8b2cf31b8 100644 --- a/include/eepp/declares.hpp +++ b/include/eepp/declares.hpp @@ -18,6 +18,13 @@ #if ( defined( _MSCVER ) || defined( _MSC_VER ) ) #define EE_COMPILER_MSVC + + #pragma warning(disable : 4251) + #pragma warning(disable : 4244) + #pragma warning(disable : 4996) + #pragma warning(disable : 4311) + #pragma warning(disable : 4312) + #pragma warning(disable : 4068) #endif #ifdef CreateWindow @@ -59,19 +66,13 @@ #endif #endif -#if !defined( EE_GLES1 ) && !defined( EE_GLES2 ) -#define EE_PLATFORM_DESKTOP -#endif - #if defined ( linux ) || defined( __linux__ ) \ || defined( __FreeBSD__ ) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined( __DragonFly__ ) \ || defined( __SVR4 ) || defined( __sun ) -#if !defined( EE_GLES1 ) && !defined( EE_GLES2 ) - -#define EE_X11_PLATFORM - -#endif + #if !defined( EE_GLES1 ) && !defined( EE_GLES2 ) + #define EE_X11_PLATFORM + #endif #endif @@ -80,7 +81,7 @@ #define EE_PLATFORM_POSIX #endif -#if EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_BSD || EE_PLATFORM == EE_PLATFORM_SOLARIS || EE_PLATFORM == EE_PLATFORM_HAIKU +#if EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_BSD || EE_PLATFORM == EE_PLATFORM_SOLARIS || EE_PLATFORM == EE_PLATFORM_HAIKU || EE_PLATFORM == EE_PLATFORM_ANDROID #define EE_HAVE_CLOCK_GETTIME #endif @@ -97,51 +98,22 @@ #define EE_BACKEND_SDL_ACTIVE #endif -#if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS || defined( EE_COMPILER_MSVC ) - #if EE_PLATFORM == EE_PLATFORM_ANDROID - #define EE_NO_WIDECHAR - #endif +#if EE_PLATFORM == EE_PLATFORM_ANDROID + #define EE_NO_WIDECHAR +#endif - #ifdef EE_BACKEND_SDL_ACTIVE +#if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS + #if defined( EE_BACKEND_SDL_ACTIVE ) #define main SDL_main #endif +#endif - #ifdef EE_BACKEND_ALLEGRO_ACTIVE - #if EE_PLATFORM == EE_PLATFORM_IOS - #define ALLEGRO_MAGIC_MAIN - #define main _al_mangled_main - #elif EE_PLATFORM == EE_PLATFORM_ANDROID - #ifdef __cplusplus - extern "C" int main(int argc, char ** argv); - #else - extern int main(int argc, char ** argv); - #endif - #endif - #endif - - #ifndef EE_MAIN_FUNC - #ifdef __cplusplus - #define EE_MAIN_FUNC extern "C" - #else - #define EE_MAIN_FUNC - #endif - #endif -#else - #if defined( EE_BACKEND_SDL_ACTIVE ) && EE_PLATFORM == EE_PLATFORM_WIN - #define main SDL_main - #define EE_MAIN_FUNC extern "C" - extern "C" int SDL_main(int argc, char *argv[]); - #endif - - #ifndef EE_MAIN_FUNC - #define EE_MAIN_FUNC - #endif - +#if EE_PLATFORM != EE_PLATFORM_ANDROID #define EE_SUPPORT_EXCEPTIONS #endif #ifndef EE_DEBUG - #if defined( DEBUG ) || defined( _DEBUG ) || defined( __DEBUG ) || defined( __DEBUG__ ) + #ifndef NDEBUG #define EE_DEBUG #endif #endif @@ -161,23 +133,8 @@ #define EE_ENDIAN EE_BIG_ENDIAN #endif -#ifdef EE_PLATFORM - #define EE_SUPPORTED_PLATFORM -#else - #error Platform not supported -#endif - -#if EE_PLATFORM == EE_PLATFORM_WIN - #ifdef EE_COMPILER_MSVC - #pragma warning(disable : 4251) - #pragma warning(disable : 4244) - #pragma warning(disable : 4996) - #pragma warning(disable : 4311) - #pragma warning(disable : 4312) - #pragma warning(disable : 4068) - #endif - - #ifdef EE_DYNAMIC +#ifndef EE_STATIC + #if EE_PLATFORM == EE_PLATFORM_WIN // Windows platforms #ifdef EE_EXPORTS // From DLL side, we must export @@ -187,20 +144,14 @@ #define EE_API __declspec(dllimport) #endif #else - // No specific directive needed for static build - #ifndef EE_API - #define EE_API + #if ( __GNUC__ >= 4 ) + #define EE_API __attribute__ ((visibility("default"))) #endif #endif -#else - #if ( __GNUC__ >= 4 ) - #define EE_API __attribute__ ((visibility("default"))) - #endif +#endif - // Other platforms don't need to define anything - #ifndef EE_API +#ifndef EE_API #define EE_API - #endif #endif #ifndef EE_USE_DOUBLES @@ -232,7 +183,6 @@ namespace EE { #if 1 == EE_USE_DOUBLES - #define EE_SIZE_OF_FLOAT 8 typedef double eeFloat; #define eesqrt sqrt #define eesin sin @@ -247,7 +197,6 @@ namespace EE { #define eeceil ceil #define eeabs abs #else - #define EE_SIZE_OF_FLOAT 4 typedef float eeFloat; //! The internal floating point used on EE++. \n This can help to improve compatibility with some platforms. \n And helps for an easy change from single precision to double precision. #define eesqrt sqrtf #define eesin sinf diff --git a/premake4.lua b/premake4.lua index 1c8618c29..a9747ef56 100644 --- a/premake4.lua +++ b/premake4.lua @@ -236,12 +236,19 @@ end function build_link_configuration( package_name, use_ee_icon ) includedirs { "include", "src" } + + if package_name == "eepp" then + defines { "EE_EXPORTS" } + elseif package_name == "eepp-static" then + defines { "EE_STATIC" } + end if package_name ~= "eepp" and package_name ~= "eepp-static" then if not _OPTIONS["with-static-eepp"] then links { "eepp-shared" } else links { "eepp-static" } + defines { "EE_STATIC" } add_static_links() links { link_list } end @@ -258,40 +265,18 @@ function build_link_configuration( package_name, use_ee_icon ) links { get_backend_link_name( "sfml-window" ) } end else - if ( os.is_real("macosx") or os.is_real("windows") or os.is_real("mingw32") ) then - if os.is_real("windows") or os.is_real("mingw32") then - links { "mingw32" } - + if os.is_real("macosx") or os.is("windows") then + if os.is("windows") and not is_vs() then if ( true == use_ee_icon ) then linkoptions { "../../assets/icon/ee.res" } end end - - if ( backend_is("SDL") ) then - links { "SDLmain", get_backend_link_name( "SDL" ) } - elseif ( backend_is("SDL2") ) then - links { "SDL2main", get_backend_link_name( "SDL2" ) } - elseif ( backend_is("allegro5") ) then - links { "allegro_main", get_backend_link_name( "allegro" ) } - elseif ( backend_is("SFML") ) then - links { get_backend_link_name( "sfml-system" ) } - links { get_backend_link_name( "sfml-window" ) } - end end end - end - + end + configuration "debug" defines { "DEBUG", "EE_DEBUG", "EE_MEMORY_MANAGER" } - - if package_name == "eepp" then - defines { "EE_DYNAMIC", "EE_EXPORTS" } - else - if package_name ~= "eepp-static" then - defines { "EE_DYNAMIC" } - end - end - flags { "Symbols" } if not is_vs() then @@ -302,15 +287,6 @@ function build_link_configuration( package_name, use_ee_icon ) configuration "release" defines { "NDEBUG" } - - if package_name == "eepp" then - defines { "EE_DYNAMIC", "EE_EXPORTS" } - else - if package_name ~= "eepp-static" then - defines { "EE_DYNAMIC" } - end - end - flags { "Optimize" } if not is_vs() then @@ -484,11 +460,7 @@ end function backend_is( name ) if not _OPTIONS["with-backend"] then - if ( os.is_real("mingw32") ) then - _OPTIONS["with-backend"] = "SDL" - else - _OPTIONS["with-backend"] = "SDL2" - end + _OPTIONS["with-backend"] = "SDL2" end if next(backends) == nil then @@ -706,6 +678,12 @@ solution "eepp" files { "src/eepp/helper/jpeg-compressor/*.cpp" } build_base_cpp_configuration( "jpeg-compressor" ) + project "eepp-main" + kind "StaticLib" + language "C++" + targetdir("libs/" .. os.get_real() .. "/") + files { "src/eepp/main/eepp_main.cpp" } + project "eepp-static" kind "StaticLib" language "C++" @@ -718,13 +696,13 @@ solution "eepp" targetdir("libs/" .. os.get_real() .. "/") build_eepp( "eepp" ) + -- Examples project "eepp-test" kind "WindowedApp" language "C++" files { "src/test/*.cpp" } build_link_configuration( "eetest", true ) - -- Examples project "eepp-es" kind "WindowedApp" language "C++" diff --git a/src/eepp/graphics/renderer/cgl.cpp b/src/eepp/graphics/renderer/cgl.cpp index a0d562472..faa833bbc 100644 --- a/src/eepp/graphics/renderer/cgl.cpp +++ b/src/eepp/graphics/renderer/cgl.cpp @@ -10,7 +10,7 @@ cGL * GLi = NULL; cGL * cGL::ms_singleton = NULL; cGL * cGL::CreateSingleton( EEGL_version ver ) { - #ifdef EE_PLATFORM_DESKTOP + #if !defined( EE_GLES1 ) && !defined( EE_GLES2 ) if ( GLv_default == ver ) ver = GLv_2; #else diff --git a/src/eepp/main/eepp_main.cpp b/src/eepp/main/eepp_main.cpp new file mode 100644 index 000000000..ba08b4db5 --- /dev/null +++ b/src/eepp/main/eepp_main.cpp @@ -0,0 +1,13 @@ + +#if defined(_WIN32) + + #include + + extern int main(int argc, char* argv[]); + + int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT) + { + return main(__argc, __argv); + } + +#endif // _WIN32 diff --git a/src/eepp/ui/cuipopupmenu.cpp b/src/eepp/ui/cuipopupmenu.cpp index f87b6565a..270d885d9 100644 --- a/src/eepp/ui/cuipopupmenu.cpp +++ b/src/eepp/ui/cuipopupmenu.cpp @@ -29,7 +29,7 @@ void cUIPopUpMenu::SetTheme( cUITheme * Theme ) { bool cUIPopUpMenu::Show() { if ( !Visible() || 0.f == mAlpha ) { #ifdef EE_PLATFORM_TOUCH - mTE.Reset(); + mTE.Restart(); #endif Enabled( true ); @@ -86,7 +86,7 @@ Uint32 cUIPopUpMenu::OnMessage( const cUIMessage * Msg ) { case cUIMessage::MsgMouseUp: { #ifdef EE_PLATFORM_TOUCH - if ( mTE.Elapsed() > 250.f ) { + if ( mTE.Elapsed().AsMilliseconds() > 250.f ) { #endif if ( !Msg->Sender()->IsType( UI_TYPE_MENUSUBMENU ) && ( Msg->Flags() & EE_BUTTONS_LRM ) ) { SendCommonEvent( cUIEvent::EventOnHideByClick ); diff --git a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp index c49b7eeed..0560da812 100644 --- a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp @@ -64,6 +64,10 @@ static std::string SDL_AndroidGetApkPath() { } #endif +#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || defined( EE_X11_PLATFORM ) +#define SDL2_THREADED_GLCONTEXT +#endif + namespace EE { namespace Window { namespace Backend { namespace SDL2 { cWindowSDL::cWindowSDL( WindowSettings Settings, ContextSettings Context ) : @@ -205,7 +209,7 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { }*/ #endif - #if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || defined( EE_X11_PLATFORM ) + #ifdef SDL2_THREADED_GLCONTEXT SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1 ); mGLContext = SDL_GL_CreateContext( mSDLWindow ); @@ -215,7 +219,7 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { #endif if ( NULL == mGLContext - #if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || defined( EE_X11_PLATFORM ) + #ifdef SDL2_THREADED_GLCONTEXT || NULL == mGLContextThread #endif ) @@ -279,7 +283,11 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { } bool cWindowSDL::IsThreadedGLContext() { +#ifdef SDL2_THREADED_GLCONTEXT return true; +#else + return false; +#endif } void cWindowSDL::SetGLContextThread() { diff --git a/src/examples/empty_window/empty_window.cpp b/src/examples/empty_window/empty_window.cpp index f8613641c..27fd04785 100644 --- a/src/examples/empty_window/empty_window.cpp +++ b/src/examples/empty_window/empty_window.cpp @@ -1,7 +1,6 @@ #include -// EE_MAIN_FUNC is needed for some platforms to export the main function as C function. -EE_MAIN_FUNC int main (int argc, char * argv []) +int main (int argc, char * argv []) { // Create a new window cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, "eepp - Empty Window" ) ); diff --git a/src/examples/external_shader/external_shader.cpp b/src/examples/external_shader/external_shader.cpp index f5dd230ee..5fe25bbbd 100644 --- a/src/examples/external_shader/external_shader.cpp +++ b/src/examples/external_shader/external_shader.cpp @@ -81,7 +81,7 @@ void videoResize( cWindow * w ) { } using namespace Demo_ExternalShader; -EE_MAIN_FUNC int main (int argc, char * argv []) +int main (int argc, char * argv []) { win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, "eepp - External Shaders" ), ContextSettings( true ) ); diff --git a/src/examples/fonts/fonts.cpp b/src/examples/fonts/fonts.cpp index bf4d5d14e..9d9bec2f8 100644 --- a/src/examples/fonts/fonts.cpp +++ b/src/examples/fonts/fonts.cpp @@ -1,6 +1,6 @@ #include -EE_MAIN_FUNC int main (int argc, char * argv []) +int main (int argc, char * argv []) { // Create a new window cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, "eepp - Fonts" ), ContextSettings( true ) ); diff --git a/src/examples/physics/physics.cpp b/src/examples/physics/physics.cpp index e48f0ca66..d46c3799c 100644 --- a/src/examples/physics/physics.cpp +++ b/src/examples/physics/physics.cpp @@ -608,7 +608,7 @@ void PhysicsDestroy() { mDemo[ mCurDemo ].destroy(); } -EE_MAIN_FUNC int main (int argc, char * argv []) +int main (int argc, char * argv []) { mWindow = cEngine::instance()->CreateWindow( WindowSettings( 1024, 768, "eepp - Physics" ), ContextSettings( true ) ); diff --git a/src/examples/sound/sound.cpp b/src/examples/sound/sound.cpp index 3f10eff84..8836f0782 100644 --- a/src/examples/sound/sound.cpp +++ b/src/examples/sound/sound.cpp @@ -55,7 +55,7 @@ void playMusic() { } /// Entry point of application -EE_MAIN_FUNC int main (int argc, char * argv []) +int main (int argc, char * argv []) { // Play a sound playSound(); diff --git a/src/examples/sprites/sprites.cpp b/src/examples/sprites/sprites.cpp index a989005a2..024ea4c35 100644 --- a/src/examples/sprites/sprites.cpp +++ b/src/examples/sprites/sprites.cpp @@ -26,7 +26,7 @@ void spriteCallback( Uint32 Event, cSprite * Sprite, void * UserData ) { } } -EE_MAIN_FUNC int main (int argc, char * argv []) +int main (int argc, char * argv []) { // Create a new window cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 640, 480, "eepp - Sprites" ), ContextSettings( true ) ); diff --git a/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp b/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp index ecf709765..81fe95b9b 100644 --- a/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp +++ b/src/examples/vbo_fbo_batch/vbo_fbo_batch.cpp @@ -1,7 +1,6 @@ #include -// EE_MAIN_FUNC is needed for some platforms to export the main function as C function. -EE_MAIN_FUNC int main (int argc, char * argv []) +int main (int argc, char * argv []) { // Create a new window cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 1024, 768, "eepp - VBO - FBO and Batch Rendering" ), ContextSettings( true ) ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 29c18e2a3..1e8d51594 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -1945,7 +1945,7 @@ void cEETest::End() { } -EE_MAIN_FUNC int main (int argc, char * argv []) { +int main (int argc, char * argv []) { Demo_Test::cEETest * Test = eeNew( Demo_Test::cEETest, () ); Test->Process();