mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Emscripten fixes.
--HG-- branch : dev
This commit is contained in:
@@ -441,7 +441,7 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
add_cross_config_links()
|
||||
|
||||
configuration "emscripten"
|
||||
linkoptions{ "-O1 -s TOTAL_MEMORY=67108864 -s ASM_JS=1 -s VERBOSE=1 -s DISABLE_EXCEPTION_CATCHING=0" }
|
||||
linkoptions{ "-O1 -s TOTAL_MEMORY=67108864 -s ASM_JS=1 -s VERBOSE=1 -s DISABLE_EXCEPTION_CATCHING=0 -s USE_SDL=2" }
|
||||
buildoptions { "-fno-strict-aliasing -O2 -ffast-math" }
|
||||
|
||||
if _OPTIONS["with-gles1"] and ( not _OPTIONS["with-gles2"] or _OPTIONS["force-gles1"] ) then
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
cd $(dirname "$0")
|
||||
premake4 --file=../../premake4.lua --with-gles1 --with-gles2 --with-static-eepp --with-static-freetype --platform=emscripten --with-backend=SDL gmake
|
||||
premake4 --file=../../premake4.lua --with-gles1 --with-gles2 --with-static-eepp --with-static-freetype --platform=emscripten --with-backend=SDL2 gmake
|
||||
cd ../../make/emscripten/
|
||||
ln -sf ../../bin/assets/ ./
|
||||
sed -i 's/-rcs/rcs/g' *.make
|
||||
emmake make $@
|
||||
emmake make -j`nproc` $@
|
||||
|
||||
@@ -165,7 +165,7 @@ bool OpenSSLSocket::init() {
|
||||
BIO_free(mem);
|
||||
}
|
||||
|
||||
eePRINTL( "Loaded certs from '%s': %d", SSLSocket::CertificatesPath.c_str(), (int)sCerts.size() );
|
||||
//eePRINTL( "Loaded certs from '%s': %d", SSLSocket::CertificatesPath.c_str(), (int)sCerts.size() );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#ifdef EE_BACKEND_SDL2
|
||||
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID && EE_PLATFORM != EE_PLATFORM_IOS && !defined( EE_COMPILER_MSVC ) && !defined( EE_SDL2_FROM_ROOTPATH )
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID && EE_PLATFORM != EE_PLATFORM_IOS && EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN && !defined( EE_COMPILER_MSVC ) && !defined( EE_SDL2_FROM_ROOTPATH )
|
||||
#include <SDL2/SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define EE_BACKEND_SDL2
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID && EE_PLATFORM != EE_PLATFORM_IOS && !defined( EE_COMPILER_MSVC ) && !defined( EE_SDL2_FROM_ROOTPATH )
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID && EE_PLATFORM != EE_PLATFORM_IOS && EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN && !defined( EE_COMPILER_MSVC ) && !defined( EE_SDL2_FROM_ROOTPATH )
|
||||
#include <SDL2/SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
|
||||
@@ -10,7 +10,9 @@ static SDL_Cursor * SDL_SYS_CURSORS[ SYS_CURSOR_COUNT ] = {0};
|
||||
|
||||
static SDL_Cursor * getLoadCursor( const EE_SYSTEM_CURSOR& cursor ) {
|
||||
if ( 0 == SDL_SYS_CURSORS[ cursor ] ) {
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
SDL_SYS_CURSORS[ cursor ] = SDL_CreateSystemCursor( (SDL_SystemCursor)cursor );
|
||||
#endif
|
||||
}
|
||||
|
||||
return SDL_SYS_CURSORS[ cursor ];
|
||||
|
||||
@@ -98,7 +98,11 @@ void InputSDL::update() {
|
||||
String txt = String::fromUtf8( SDLEvent.text.text );
|
||||
|
||||
EEEvent.Type = InputEvent::TextInput;
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
EEEvent.text.timestamp = SDLEvent.text.timestamp;
|
||||
#else
|
||||
EEEvent.text.timestamp = Sys::getTicks();
|
||||
#endif
|
||||
EEEvent.text.text = txt[0];
|
||||
|
||||
processEvent( &EEEvent );
|
||||
@@ -322,18 +326,20 @@ void InputSDL::injectMousePos( const Uint16& x, const Uint16& y ) {
|
||||
}
|
||||
|
||||
void InputSDL::init() {
|
||||
#if SDL_VERSION_ATLEAST(2,0,1)
|
||||
int realX, realY;
|
||||
int scaledX, scaledY;
|
||||
SDL_Window * sdlw = reinterpret_cast<WindowSDL*>( mWindow )->GetSDLWindow();
|
||||
SDL_GL_GetDrawableSize(sdlw, &realX, &realY);
|
||||
SDL_GetWindowSize(sdlw, &scaledX, &scaledY);
|
||||
mDPIScale = (Float)realX / (Float)scaledX;
|
||||
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,4)
|
||||
Vector2i mTempMouse;
|
||||
Vector2i mTempWinPos;
|
||||
Rect mBordersSize;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,4)
|
||||
SDL_GetGlobalMouseState( &mTempMouse.x, &mTempMouse.y );
|
||||
SDL_GetWindowPosition( sdlw, &mTempWinPos.x, &mTempWinPos.y );
|
||||
SDL_GetWindowBordersSize( sdlw, &mBordersSize.Top, &mBordersSize.Left, &mBordersSize.Bottom, &mBordersSize.Right );
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#ifdef EE_BACKEND_SDL2
|
||||
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID && EE_PLATFORM != EE_PLATFORM_IOS && !defined( EE_COMPILER_MSVC ) && !defined( EE_SDL2_FROM_ROOTPATH )
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID && EE_PLATFORM != EE_PLATFORM_IOS && EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN && !defined( EE_COMPILER_MSVC ) && !defined( EE_SDL2_FROM_ROOTPATH )
|
||||
#include <SDL2/SDL_revision.h>
|
||||
#else
|
||||
#include <SDL_revision.h>
|
||||
|
||||
@@ -128,7 +128,11 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
mWindow.WindowConfig.Height = mWindow.DesktopResolution.getHeight();
|
||||
}
|
||||
|
||||
mWindow.Flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
mWindow.Flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,1)
|
||||
mWindow.Flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||
#endif
|
||||
|
||||
if ( mWindow.WindowConfig.Style & WindowStyle::Resize ) {
|
||||
mWindow.Flags |= SDL_WINDOW_RESIZABLE;
|
||||
@@ -138,7 +142,7 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
mWindow.Flags |= SDL_WINDOW_BORDERLESS;
|
||||
}
|
||||
|
||||
SetGLConfig();
|
||||
setGLConfig();
|
||||
|
||||
Uint32 mTmpFlags = mWindow.Flags;
|
||||
|
||||
@@ -162,12 +166,14 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
}
|
||||
|
||||
/// In some platforms it will not create the desired window size, so we query the real window size created
|
||||
#if SDL_VERSION_ATLEAST(2,0,1)
|
||||
int w, h;
|
||||
SDL_GL_GetDrawableSize( mSDLWindow, &w, &h );
|
||||
|
||||
mWindow.WindowConfig.Width = w;
|
||||
mWindow.WindowConfig.Height = h;
|
||||
mWindow.WindowSize = Sizei( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height );
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS
|
||||
eePRINTL( "Choosing GL Version from: %d", Context.Version );
|
||||
@@ -201,11 +207,13 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
if ( GLv_3CP == Context.Version ) {
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SDL2_THREADED_GLCONTEXT
|
||||
@@ -323,7 +331,7 @@ void WindowSDL::createPlatform() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowSDL::SetGLConfig() {
|
||||
void WindowSDL::setGLConfig() {
|
||||
if ( mWindow.ContextConfig.DepthBufferSize ) SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE , mWindow.ContextConfig.DepthBufferSize ); // Depth
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, ( mWindow.ContextConfig.DoubleBuffering ? 1 : 0 ) ); // Double Buffering
|
||||
if ( mWindow.ContextConfig.StencilBufferSize ) SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, mWindow.ContextConfig.StencilBufferSize );
|
||||
@@ -405,7 +413,9 @@ void WindowSDL::setSize( Uint32 Width, Uint32 Height, bool Windowed ) {
|
||||
if ( this->isWindowed() && !Windowed ) {
|
||||
mWinPos = getPosition();
|
||||
} else {
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
SDL_SetWindowFullscreen( mSDLWindow, Windowed ? 0 : SDL_WINDOW_FULLSCREEN );
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_SetWindowSize( mSDLWindow, Width, Height );
|
||||
@@ -413,9 +423,11 @@ void WindowSDL::setSize( Uint32 Width, Uint32 Height, bool Windowed ) {
|
||||
if ( this->isWindowed() && !Windowed ) {
|
||||
mWinPos = getPosition();
|
||||
|
||||
SetGLConfig();
|
||||
setGLConfig();
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
SDL_SetWindowFullscreen( mSDLWindow, Windowed ? 0 : SDL_WINDOW_FULLSCREEN );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( !this->isWindowed() && Windowed ) {
|
||||
@@ -586,15 +598,17 @@ Vector2i WindowSDL::getPosition() {
|
||||
return p;
|
||||
}
|
||||
|
||||
void WindowSDL::UpdateDesktopResolution() {
|
||||
void WindowSDL::updateDesktopResolution() {
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
SDL_DisplayMode dpm;
|
||||
SDL_GetDesktopDisplayMode( SDL_GetWindowDisplayIndex( mSDLWindow ), &dpm );
|
||||
|
||||
mWindow.DesktopResolution = Sizei( dpm.w, dpm.h );
|
||||
#endif
|
||||
}
|
||||
|
||||
const Sizei& WindowSDL::getDesktopResolution() {
|
||||
UpdateDesktopResolution();
|
||||
updateDesktopResolution();
|
||||
return Window::getDesktopResolution();
|
||||
}
|
||||
|
||||
@@ -607,7 +621,11 @@ void WindowSDL::startTextInput() {
|
||||
}
|
||||
|
||||
bool WindowSDL::isTextInputActive() {
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
return SDL_TRUE == SDL_IsTextInputActive();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowSDL::stopTextInput() {
|
||||
@@ -631,11 +649,19 @@ void WindowSDL::setTextInputRect( Rect& rect ) {
|
||||
}
|
||||
|
||||
bool WindowSDL::hasScreenKeyboardSupport() {
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
return SDL_TRUE == SDL_HasScreenKeyboardSupport();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WindowSDL::isScreenKeyboardShown() {
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
return SDL_TRUE == SDL_IsScreenKeyboardShown( mSDLWindow );
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_ANDROID
|
||||
|
||||
@@ -113,11 +113,11 @@ class EE_API WindowSDL : public Window {
|
||||
|
||||
void swapBuffers();
|
||||
|
||||
void SetGLConfig();
|
||||
void setGLConfig();
|
||||
|
||||
std::string getVersion();
|
||||
|
||||
void UpdateDesktopResolution();
|
||||
void updateDesktopResolution();
|
||||
};
|
||||
|
||||
}}}}
|
||||
|
||||
Reference in New Issue
Block a user