Browse Source

Replace the usage of Emscripten define and include to follow its norm.
Close #921.
[ci only: Emscripten]

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
e1341f7261

+ 9 - 9
Source/ThirdParty/kNet/src/Clock.cpp

@@ -1,4 +1,4 @@
-/* Copyright 2010 Jukka Jylänki
+/* Copyright 2010 Jukka Jylänki
 
 
    Licensed under the Apache License, Version 2.0 (the "License");
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 // Urho3D: ensure that kNetBuildConfig.h is included for WinXP compatibility
 // Urho3D: ensure that kNetBuildConfig.h is included for WinXP compatibility
 #include "kNetBuildConfig.h"
 #include "kNetBuildConfig.h"
 
 
-#if defined(__unix__) || defined(__native_client__) || defined(EMSCRIPTEN) || defined(ANDROID) || defined(__APPLE__) || defined (__CYGWIN__)
+#if defined(__unix__) || defined(__native_client__) || defined(__EMSCRIPTEN__) || defined(ANDROID) || defined(__APPLE__) || defined (__CYGWIN__)
 #include <time.h>
 #include <time.h>
 #include <errno.h>
 #include <errno.h>
 #include <string.h>
 #include <string.h>
@@ -32,8 +32,8 @@
 #include <windows.h>
 #include <windows.h>
 #endif
 #endif
 
 
-#ifdef EMSCRIPTEN
-#include <emscripten.h>
+#ifdef __EMSCRIPTEN__
+#include <emscripten/emscripten.h>
 #endif
 #endif
 
 
 #include "kNet/Clock.h"
 #include "kNet/Clock.h"
@@ -72,7 +72,7 @@ void Clock::InitClockData()
 		appStartTime = (tick_t)GetTickCount64();
 		appStartTime = (tick_t)GetTickCount64();
 #else
 #else
 		appStartTime = (tick_t)GetTickCount();
 		appStartTime = (tick_t)GetTickCount();
-#endif		
+#endif
 	}
 	}
 
 
 	///\todo Test here that the return values of QueryPerformanceCounter is nondecreasing.
 	///\todo Test here that the return values of QueryPerformanceCounter is nondecreasing.
@@ -90,7 +90,7 @@ void Clock::Sleep(int milliseconds)
 #pragma WARNING(Clock::Sleep has not been implemented!)
 #pragma WARNING(Clock::Sleep has not been implemented!)
 #elif defined(WIN32)
 #elif defined(WIN32)
 	::Sleep(milliseconds);
 	::Sleep(milliseconds);
-#elif !defined(__native_client__) && !defined(EMSCRIPTEN) && !defined(__APPLE__)
+#elif !defined(__native_client__) && !defined(__EMSCRIPTEN__) && !defined(__APPLE__)
 	// http://linux.die.net/man/2/nanosleep
 	// http://linux.die.net/man/2/nanosleep
 	timespec ts;
 	timespec ts;
 	ts.tv_sec = milliseconds / 1000;
 	ts.tv_sec = milliseconds / 1000;
@@ -182,7 +182,7 @@ unsigned long Clock::SystemTime()
 	return (unsigned long)GetTickCount64();
 	return (unsigned long)GetTickCount64();
 #else
 #else
 	return (unsigned long)GetTickCount();
 	return (unsigned long)GetTickCount();
-#endif		
+#endif
 #else
 #else
 	return TickU32();
 	return TickU32();
 #endif
 #endif
@@ -204,7 +204,7 @@ tick_t Clock::Tick()
 	struct timespec res;
 	struct timespec res;
 	clock_gettime(CLOCK_REALTIME, &res);
 	clock_gettime(CLOCK_REALTIME, &res);
 	return 1000000000ULL*res.tv_sec + (tick_t)res.tv_nsec;
 	return 1000000000ULL*res.tv_sec + (tick_t)res.tv_nsec;
-#elif defined(EMSCRIPTEN)
+#elif defined(__EMSCRIPTEN__)
 	// emscripten_get_now() returns a wallclock time as a float in milliseconds (1e-3).
 	// emscripten_get_now() returns a wallclock time as a float in milliseconds (1e-3).
 	// scale it to microseconds (1e-6) and return as a tick.
 	// scale it to microseconds (1e-6) and return as a tick.
 	return (tick_t)(((double)emscripten_get_now()) * 1e3);
 	return (tick_t)(((double)emscripten_get_now()) * 1e3);
@@ -241,7 +241,7 @@ tick_t Clock::TicksPerSec()
 {
 {
 #if defined(ANDROID)
 #if defined(ANDROID)
 	return 1000000000ULL; // 1e9 == nanoseconds.
 	return 1000000000ULL; // 1e9 == nanoseconds.
-#elif defined(EMSCRIPTEN)
+#elif defined(__EMSCRIPTEN__)
 	return 1000000ULL; // 1e6 == microseconds.
 	return 1000000ULL; // 1e6 == microseconds.
 //	return CLOCKS_PER_SEC;
 //	return CLOCKS_PER_SEC;
 #elif defined(WIN32)
 #elif defined(WIN32)

+ 3 - 3
Source/Urho3D/Audio/Audio.cpp

@@ -85,7 +85,7 @@ bool Audio::SetMode(int bufferLengthMSec, int mixRate, bool stereo, bool interpo
     desired.freq = mixRate;
     desired.freq = mixRate;
 
 
 // The concept behind the emscripten audio port is to treat it as 16 bit until the final accumulation form the clip buffer
 // The concept behind the emscripten audio port is to treat it as 16 bit until the final accumulation form the clip buffer
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     desired.format = AUDIO_F32LSB;
     desired.format = AUDIO_F32LSB;
 #else
 #else
     desired.format = AUDIO_S16;
     desired.format = AUDIO_S16;
@@ -107,7 +107,7 @@ bool Audio::SetMode(int bufferLengthMSec, int mixRate, bool stereo, bool interpo
         return false;
         return false;
     }
     }
 
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     if (obtained.format != AUDIO_F32LSB && obtained.format != AUDIO_F32MSB && obtained.format != AUDIO_F32SYS)
     if (obtained.format != AUDIO_F32LSB && obtained.format != AUDIO_F32MSB && obtained.format != AUDIO_F32SYS)
     {
     {
         LOGERROR("Could not initialize audio output, 32-bit float buffer format not supported");
         LOGERROR("Could not initialize audio output, 32-bit float buffer format not supported");
@@ -272,7 +272,7 @@ void Audio::MixOutput(void* dest, unsigned samples)
             (*i)->Mix(clipPtr, workSamples, mixRate_, stereo_, interpolation_);
             (*i)->Mix(clipPtr, workSamples, mixRate_, stereo_, interpolation_);
 
 
         // Copy output from clip buffer to destination
         // Copy output from clip buffer to destination
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
         float* destPtr = (float*)dest;
         float* destPtr = (float*)dest;
         while (clipSamples--)
         while (clipSamples--)
             *destPtr++ = (float)Clamp(*clipPtr++, -32768, 32767) / 32768.0f;
             *destPtr++ = (float)Clamp(*clipPtr++, -32768, 32767) / 32768.0f;

+ 1 - 1
Source/Urho3D/Audio/Audio.h

@@ -105,7 +105,7 @@ public:
     void MixOutput(void* dest, unsigned samples);
     void MixOutput(void* dest, unsigned samples);
 
 
     /// Final multiplier for for audio byte conversion
     /// Final multiplier for for audio byte conversion
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     static const int SAMPLE_SIZE_MUL = 2;
     static const int SAMPLE_SIZE_MUL = 2;
 #else
 #else
     static const int SAMPLE_SIZE_MUL = 1;
     static const int SAMPLE_SIZE_MUL = 1;

+ 7 - 7
Source/Urho3D/Core/ProcessUtils.cpp

@@ -34,7 +34,7 @@
 #if defined(IOS)
 #if defined(IOS)
 #include "../Math/MathDefs.h"
 #include "../Math/MathDefs.h"
 #include <mach/mach_host.h>
 #include <mach/mach_host.h>
-#elif !defined(ANDROID) && !defined(RPI) && !defined(EMSCRIPTEN)
+#elif !defined(ANDROID) && !defined(RPI) && !defined(__EMSCRIPTEN__)
 #include <LibCpuId/libcpuid.h>
 #include <LibCpuId/libcpuid.h>
 #endif
 #endif
 
 
@@ -47,7 +47,7 @@
 
 
 #if defined(_MSC_VER)
 #if defined(_MSC_VER)
 #include <float.h>
 #include <float.h>
-#elif !defined(ANDROID) && !defined(IOS) && !defined(RPI) && !defined(EMSCRIPTEN)
+#elif !defined(ANDROID) && !defined(IOS) && !defined(RPI) && !defined(__EMSCRIPTEN__)
 // From http://stereopsis.com/FPU.html
 // From http://stereopsis.com/FPU.html
 
 
 #define FPU_CW_PREC_MASK        0x0300
 #define FPU_CW_PREC_MASK        0x0300
@@ -94,7 +94,7 @@ static void GetCPUData(host_basic_info_data_t* data)
     infoCount = HOST_BASIC_INFO_COUNT;
     infoCount = HOST_BASIC_INFO_COUNT;
     host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)data, &infoCount);
     host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)data, &infoCount);
 }
 }
-#elif !defined(ANDROID) && !defined(RPI) && !defined(EMSCRIPTEN)
+#elif !defined(ANDROID) && !defined(RPI) && !defined(__EMSCRIPTEN__)
 
 
 static void GetCPUData(struct cpu_id_t* data)
 static void GetCPUData(struct cpu_id_t* data)
 {
 {
@@ -109,7 +109,7 @@ static void GetCPUData(struct cpu_id_t* data)
 
 
 void InitFPU()
 void InitFPU()
 {
 {
-#if !defined(URHO3D_LUAJIT) && !defined(ANDROID) && !defined(IOS) && !defined(RPI) && !defined(__x86_64__) && !defined(_M_AMD64) && !defined(EMSCRIPTEN)
+#if !defined(URHO3D_LUAJIT) && !defined(ANDROID) && !defined(IOS) && !defined(RPI) && !defined(__x86_64__) && !defined(_M_AMD64) && !defined(__EMSCRIPTEN__)
     // Make sure FPU is in round-to-nearest, single precision mode
     // Make sure FPU is in round-to-nearest, single precision mode
     // This ensures Direct3D and OpenGL behave similarly, and all threads behave similarly
     // This ensures Direct3D and OpenGL behave similarly, and all threads behave similarly
 #ifdef _MSC_VER
 #ifdef _MSC_VER
@@ -358,7 +358,7 @@ String GetPlatform()
     return "Mac OS X";
     return "Mac OS X";
 #elif defined(RPI)
 #elif defined(RPI)
     return "Raspberry Pi";
     return "Raspberry Pi";
-#elif defined(EMSCRIPTEN)
+#elif defined(__EMSCRIPTEN__)
     return "HTML5";
     return "HTML5";
 #elif defined(__linux__)
 #elif defined(__linux__)
     return "Linux";
     return "Linux";
@@ -404,7 +404,7 @@ unsigned GetNumPhysicalCPUs()
 #endif
 #endif
 #elif defined(ANDROID) || defined(RPI)
 #elif defined(ANDROID) || defined(RPI)
     return GetArmCPUCount();
     return GetArmCPUCount();
-#elif !defined(EMSCRIPTEN)
+#elif !defined(__EMSCRIPTEN__)
     struct cpu_id_t data;
     struct cpu_id_t data;
     GetCPUData(&data);
     GetCPUData(&data);
     return (unsigned)data.num_cores;
     return (unsigned)data.num_cores;
@@ -426,7 +426,7 @@ unsigned GetNumLogicalCPUs()
 #endif
 #endif
 #elif defined(ANDROID) || defined (RPI)
 #elif defined(ANDROID) || defined (RPI)
     return GetArmCPUCount();
     return GetArmCPUCount();
-#elif !defined(EMSCRIPTEN)
+#elif !defined(__EMSCRIPTEN__)
     struct cpu_id_t data;
     struct cpu_id_t data;
     GetCPUData(&data);
     GetCPUData(&data);
     return (unsigned)data.num_logical_cpus;
     return (unsigned)data.num_logical_cpus;

+ 4 - 4
Source/Urho3D/Core/Thread.cpp

@@ -50,7 +50,7 @@ void* ThreadFunctionStatic(void* data)
 {
 {
     Thread* thread = static_cast<Thread*>(data);
     Thread* thread = static_cast<Thread*>(data);
     thread->ThreadFunction();
     thread->ThreadFunction();
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     // note: emscripten doesn't have this function but doesn't use threading anyway
     // note: emscripten doesn't have this function but doesn't use threading anyway
     // so #ifdef it out to prevent linker warnings
     // so #ifdef it out to prevent linker warnings
     pthread_exit((void*)0);
     pthread_exit((void*)0);
@@ -82,7 +82,7 @@ bool Thread::Run()
     shouldRun_ = true;
     shouldRun_ = true;
 #ifdef WIN32
 #ifdef WIN32
     handle_ = CreateThread(0, 0, ThreadFunctionStatic, this, 0, 0);
     handle_ = CreateThread(0, 0, ThreadFunctionStatic, this, 0, 0);
-#elif !defined(EMSCRIPTEN)
+#elif !defined(__EMSCRIPTEN__)
     // note: emscripten doesn't have this function but doesn't use
     // note: emscripten doesn't have this function but doesn't use
     // threading anyway so #ifdef it out to prevent linker warnings
     // threading anyway so #ifdef it out to prevent linker warnings
     handle_ = new pthread_t;
     handle_ = new pthread_t;
@@ -104,7 +104,7 @@ void Thread::Stop()
 #ifdef WIN32
 #ifdef WIN32
     WaitForSingleObject((HANDLE)handle_, INFINITE);
     WaitForSingleObject((HANDLE)handle_, INFINITE);
     CloseHandle((HANDLE)handle_);
     CloseHandle((HANDLE)handle_);
-#elif !defined(EMSCRIPTEN)
+#elif !defined(__EMSCRIPTEN__)
     // note: emscripten doesn't have this function but doesn't use
     // note: emscripten doesn't have this function but doesn't use
     // threading anyway so #ifdef it out to prevent linker warnings
     // threading anyway so #ifdef it out to prevent linker warnings
     pthread_t* thread = (pthread_t*)handle_;
     pthread_t* thread = (pthread_t*)handle_;
@@ -121,7 +121,7 @@ void Thread::SetPriority(int priority)
     if (handle_)
     if (handle_)
         SetThreadPriority((HANDLE)handle_, priority);
         SetThreadPriority((HANDLE)handle_, priority);
 #endif
 #endif
-#if defined(__linux__) && !defined(ANDROID) && !defined(EMSCRIPTEN)
+#if defined(__linux__) && !defined(ANDROID) && !defined(__EMSCRIPTEN__)
     pthread_t* thread = (pthread_t*)handle_;
     pthread_t* thread = (pthread_t*)handle_;
     if (thread)
     if (thread)
         pthread_setschedprio(*thread, priority);
         pthread_setschedprio(*thread, priority);

+ 6 - 6
Source/Urho3D/Engine/Application.cpp

@@ -36,10 +36,10 @@
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
-#if defined(IOS) || defined(EMSCRIPTEN)
+#if defined(IOS) || defined(__EMSCRIPTEN__)
 // Code for supporting SDL_iPhoneSetAnimationCallback() and emscripten_set_main_loop_arg()
 // Code for supporting SDL_iPhoneSetAnimationCallback() and emscripten_set_main_loop_arg()
-#if defined(EMSCRIPTEN)
-#include <emscripten.h>
+#if defined(__EMSCRIPTEN__)
+#include <emscripten/emscripten.h>
 #endif
 #endif
 void RunFrame(void* data)
 void RunFrame(void* data)
 {
 {
@@ -81,8 +81,8 @@ int Application::Run()
         if (exitCode_)
         if (exitCode_)
             return exitCode_;
             return exitCode_;
 
 
-        // Platforms other than iOS and EMSCRIPTEN run a blocking main loop
-#if !defined(IOS) && !defined(EMSCRIPTEN)
+        // Platforms other than iOS and Emscripten run a blocking main loop
+#if !defined(IOS) && !defined(__EMSCRIPTEN__)
         while (!engine_->IsExiting())
         while (!engine_->IsExiting())
             engine_->RunFrame();
             engine_->RunFrame();
 
 
@@ -92,7 +92,7 @@ int Application::Run()
 #else
 #else
 #if defined(IOS)
 #if defined(IOS)
         SDL_iPhoneSetAnimationCallback(GetSubsystem<Graphics>()->GetImpl()->GetWindow(), 1, &RunFrame, engine_);
         SDL_iPhoneSetAnimationCallback(GetSubsystem<Graphics>()->GetImpl()->GetWindow(), 1, &RunFrame, engine_);
-#elif defined(EMSCRIPTEN)
+#elif defined(__EMSCRIPTEN__)
         emscripten_set_main_loop_arg(RunFrame, engine_, 0, 1);
         emscripten_set_main_loop_arg(RunFrame, engine_, 0, 1);
 #endif
 #endif
 #endif
 #endif

+ 4 - 4
Source/Urho3D/Engine/Engine.cpp

@@ -58,8 +58,8 @@
 #include "../Urho2D/Urho2D.h"
 #include "../Urho2D/Urho2D.h"
 #endif
 #endif
 
 
-#if defined(EMSCRIPTEN) && defined(URHO3D_TESTING)
-#include <emscripten.h>
+#if defined(__EMSCRIPTEN__) && defined(URHO3D_TESTING)
+#include <emscripten/emscripten.h>
 #endif
 #endif
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
@@ -680,7 +680,7 @@ void Engine::ApplyFrameLimit()
 
 
     long long elapsed = 0;
     long long elapsed = 0;
 
 
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
     // Perform waiting loop if maximum FPS set
     // Perform waiting loop if maximum FPS set
     if (maxFps)
     if (maxFps)
     {
     {
@@ -918,7 +918,7 @@ void Engine::DoExit()
         graphics->Close();
         graphics->Close();
 
 
     exiting_ = true;
     exiting_ = true;
-#if defined(EMSCRIPTEN) && defined(URHO3D_TESTING)
+#if defined(__EMSCRIPTEN__) && defined(URHO3D_TESTING)
     emscripten_force_exit(EXIT_SUCCESS);    // Some how this is required to signal emrun to stop
     emscripten_force_exit(EXIT_SUCCESS);    // Some how this is required to signal emrun to stop
 #endif
 #endif
 }
 }

+ 10 - 10
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -337,7 +337,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
         return true;
         return true;
     }
     }
 
 
-    // If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size. 
+    // If zero dimensions in windowed mode, set windowed mode to maximize and set a predefined default restored window size.
     // If zero in fullscreen, use desktop mode
     // If zero in fullscreen, use desktop mode
     if (!width || !height)
     if (!width || !height)
     {
     {
@@ -457,7 +457,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
                 impl_->window_ = SDL_CreateWindow(windowTitle_.CString(), x, y, width, height, flags);
                 impl_->window_ = SDL_CreateWindow(windowTitle_.CString(), x, y, width, height, flags);
             else
             else
             {
             {
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
                 if (!impl_->window_)
                 if (!impl_->window_)
                     impl_->window_ = SDL_CreateWindowFrom(externalWindow_, SDL_WINDOW_OPENGL);
                     impl_->window_ = SDL_CreateWindowFrom(externalWindow_, SDL_WINDOW_OPENGL);
                 fullscreen = false;
                 fullscreen = false;
@@ -1989,7 +1989,7 @@ unsigned Graphics::GetFormat(CompressedFormat format) const
     case CF_DXT1:
     case CF_DXT1:
         return dxtTextureSupport_ ? GL_COMPRESSED_RGBA_S3TC_DXT1_EXT : 0;
         return dxtTextureSupport_ ? GL_COMPRESSED_RGBA_S3TC_DXT1_EXT : 0;
 
 
-#if !defined(GL_ES_VERSION_2_0) || defined(EMSCRIPTEN)
+#if !defined(GL_ES_VERSION_2_0) || defined(__EMSCRIPTEN__)
     case CF_DXT3:
     case CF_DXT3:
         return dxtTextureSupport_ ? GL_COMPRESSED_RGBA_S3TC_DXT3_EXT : 0;
         return dxtTextureSupport_ ? GL_COMPRESSED_RGBA_S3TC_DXT3_EXT : 0;
 
 
@@ -1999,16 +1999,16 @@ unsigned Graphics::GetFormat(CompressedFormat format) const
 #ifdef GL_ES_VERSION_2_0
 #ifdef GL_ES_VERSION_2_0
     case CF_ETC1:
     case CF_ETC1:
         return etcTextureSupport_ ? GL_ETC1_RGB8_OES : 0;
         return etcTextureSupport_ ? GL_ETC1_RGB8_OES : 0;
-        
+
     case CF_PVRTC_RGB_2BPP:
     case CF_PVRTC_RGB_2BPP:
         return pvrtcTextureSupport_ ? COMPRESSED_RGB_PVRTC_2BPPV1_IMG : 0;
         return pvrtcTextureSupport_ ? COMPRESSED_RGB_PVRTC_2BPPV1_IMG : 0;
-        
+
     case CF_PVRTC_RGB_4BPP:
     case CF_PVRTC_RGB_4BPP:
         return pvrtcTextureSupport_ ? COMPRESSED_RGB_PVRTC_4BPPV1_IMG : 0;
         return pvrtcTextureSupport_ ? COMPRESSED_RGB_PVRTC_4BPPV1_IMG : 0;
-        
+
     case CF_PVRTC_RGBA_2BPP:
     case CF_PVRTC_RGBA_2BPP:
         return pvrtcTextureSupport_ ? COMPRESSED_RGBA_PVRTC_2BPPV1_IMG : 0;
         return pvrtcTextureSupport_ ? COMPRESSED_RGBA_PVRTC_2BPPV1_IMG : 0;
-        
+
     case CF_PVRTC_RGBA_4BPP:
     case CF_PVRTC_RGBA_4BPP:
         return pvrtcTextureSupport_ ? COMPRESSED_RGBA_PVRTC_4BPPV1_IMG : 0;
         return pvrtcTextureSupport_ ? COMPRESSED_RGBA_PVRTC_4BPPV1_IMG : 0;
 #endif
 #endif
@@ -2778,7 +2778,7 @@ void Graphics::CheckFeatureSupport()
 #endif
 #endif
 #else
 #else
     // Check for supported compressed texture formats
     // Check for supported compressed texture formats
-    #ifdef EMSCRIPTEN
+    #ifdef __EMSCRIPTEN__
     dxtTextureSupport_ = CheckExtension("WEBGL_compressed_texture_s3tc"); // https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/
     dxtTextureSupport_ = CheckExtension("WEBGL_compressed_texture_s3tc"); // https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc/
     etcTextureSupport_ = CheckExtension("WEBGL_compressed_texture_etc1"); // https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/
     etcTextureSupport_ = CheckExtension("WEBGL_compressed_texture_etc1"); // https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/
     pvrtcTextureSupport_ = CheckExtension("WEBGL_compressed_texture_pvrtc"); // https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_pvrtc/
     pvrtcTextureSupport_ = CheckExtension("WEBGL_compressed_texture_pvrtc"); // https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_pvrtc/
@@ -2793,7 +2793,7 @@ void Graphics::CheckFeatureSupport()
         glesDepthStencilFormat = GL_DEPTH_COMPONENT24_OES;
         glesDepthStencilFormat = GL_DEPTH_COMPONENT24_OES;
     if (CheckExtension("GL_OES_packed_depth_stencil"))
     if (CheckExtension("GL_OES_packed_depth_stencil"))
         glesDepthStencilFormat = GL_DEPTH24_STENCIL8_OES;
         glesDepthStencilFormat = GL_DEPTH24_STENCIL8_OES;
-    #ifdef EMSCRIPTEN
+    #ifdef __EMSCRIPTEN__
     if (!CheckExtension("WEBGL_depth_texture"))
     if (!CheckExtension("WEBGL_depth_texture"))
 #else
 #else
     if (!CheckExtension("GL_OES_depth_texture"))
     if (!CheckExtension("GL_OES_depth_texture"))
@@ -2813,7 +2813,7 @@ void Graphics::CheckFeatureSupport()
         shadowMapFormat_ = GL_DEPTH_COMPONENT;
         shadowMapFormat_ = GL_DEPTH_COMPONENT;
         hiresShadowMapFormat_ = 0;
         hiresShadowMapFormat_ = 0;
         // WebGL shadow map rendering seems to be extremely slow without an attached dummy color texture
         // WebGL shadow map rendering seems to be extremely slow without an attached dummy color texture
-        #ifdef EMSCRIPTEN
+        #ifdef __EMSCRIPTEN__
         dummyColorFormat_ = GetRGBAFormat();
         dummyColorFormat_ = GetRGBAFormat();
 #endif
 #endif
     }
     }

+ 2 - 2
Source/Urho3D/Graphics/OpenGL/OGLGraphicsImpl.h

@@ -26,7 +26,7 @@
 #include "../../Core/Timer.h"
 #include "../../Core/Timer.h"
 #include "../../Math/Color.h"
 #include "../../Math/Color.h"
 
 
-#if defined(ANDROID) || defined (RPI) || defined (EMSCRIPTEN)
+#if defined(ANDROID) || defined (RPI) || defined (__EMSCRIPTEN__)
 #include <GLES2/gl2.h>
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 #include <GLES2/gl2ext.h>
 #elif defined(IOS)
 #elif defined(IOS)
@@ -42,7 +42,7 @@
 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
 #ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83f2
 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83f2
 #endif
 #endif
-#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 
+#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83f3
 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83f3
 #endif
 #endif
 #ifndef GL_ETC1_RGB8_OES
 #ifndef GL_ETC1_RGB8_OES

+ 1 - 1
Source/Urho3D/Graphics/OpenGL/OGLShaderVariation.cpp

@@ -153,7 +153,7 @@ bool ShaderVariation::Create()
     if (type_ == VS)
     if (type_ == VS)
         shaderCode += "#define RPI\n";
         shaderCode += "#define RPI\n";
 #endif
 #endif
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     shaderCode += "#define WEBGL\n";
     shaderCode += "#define WEBGL\n";
 #endif
 #endif
     if (Graphics::GetGL3Support())
     if (Graphics::GetGL3Support())

+ 27 - 27
Source/Urho3D/Input/Input.cpp

@@ -39,7 +39,7 @@
 #include "../UI/Text.h"
 #include "../UI/Text.h"
 #include "../UI/UI.h"
 #include "../UI/UI.h"
 
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
 #include <emscripten/html5.h>
 #include <emscripten/html5.h>
 #endif
 #endif
 
 
@@ -77,7 +77,7 @@ UIElement* TouchState::GetTouchedElement()
     return touchedElement_.Get();
     return touchedElement_.Get();
 }
 }
 
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
 #define EM_TRUE 1
 #define EM_TRUE 1
 
 
 /// Glue between Urho Input and Emscripten HTML5
 /// Glue between Urho Input and Emscripten HTML5
@@ -212,7 +212,7 @@ Input::Input(Context* context) :
     lastMouseVisible_(false),
     lastMouseVisible_(false),
     mouseGrabbed_(false),
     mouseGrabbed_(false),
     mouseMode_(MM_ABSOLUTE),
     mouseMode_(MM_ABSOLUTE),
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     emscriptenExitingPointerLock_(false),
     emscriptenExitingPointerLock_(false),
     emscriptenEnteredPointerLock_(false),
     emscriptenEnteredPointerLock_(false),
 #endif
 #endif
@@ -230,7 +230,7 @@ Input::Input(Context* context) :
 
 
     SubscribeToEvent(E_SCREENMODE, HANDLER(Input, HandleScreenMode));
     SubscribeToEvent(E_SCREENMODE, HANDLER(Input, HandleScreenMode));
 
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     emscriptenInput_ = new EmscriptenInput(this);
     emscriptenInput_ = new EmscriptenInput(this);
 #endif
 #endif
 
 
@@ -240,7 +240,7 @@ Input::Input(Context* context) :
 
 
 Input::~Input()
 Input::~Input()
 {
 {
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     delete emscriptenInput_;
     delete emscriptenInput_;
     emscriptenInput_ = 0;
     emscriptenInput_ = 0;
 #endif
 #endif
@@ -279,7 +279,7 @@ void Input::Update()
     // Check for focus change this frame
     // Check for focus change this frame
     SDL_Window* window = graphics_->GetImpl()->GetWindow();
     SDL_Window* window = graphics_->GetImpl()->GetWindow();
     unsigned flags = window ? SDL_GetWindowFlags(window) & (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS) : 0;
     unsigned flags = window ? SDL_GetWindowFlags(window) & (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS) : 0;
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
     if (window)
     if (window)
     {
     {
 #ifdef REQUIRE_CLICK_TO_FOCUS
 #ifdef REQUIRE_CLICK_TO_FOCUS
@@ -360,7 +360,7 @@ void Input::Update()
 
 
     // Check for relative mode mouse move
     // Check for relative mode mouse move
     // Note that Emscripten will use SDL mouse move events for relative mode instead
     // Note that Emscripten will use SDL mouse move events for relative mode instead
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
     if (!touchEmulation_ && (graphics_->GetExternalWindow() || ((!mouseVisible_ && mouseMode_ != MM_FREE) && inputFocus_ && (flags & SDL_WINDOW_MOUSE_FOCUS))))
     if (!touchEmulation_ && (graphics_->GetExternalWindow() || ((!mouseVisible_ && mouseMode_ != MM_FREE) && inputFocus_ && (flags & SDL_WINDOW_MOUSE_FOCUS))))
 #else
 #else
     if (!touchEmulation_ && mouseMode_ != MM_RELATIVE && (graphics_->GetExternalWindow() || (!mouseVisible_ && inputFocus_ && (flags & SDL_WINDOW_MOUSE_FOCUS))))
     if (!touchEmulation_ && mouseMode_ != MM_RELATIVE && (graphics_->GetExternalWindow() || (!mouseVisible_ && inputFocus_ && (flags & SDL_WINDOW_MOUSE_FOCUS))))
@@ -368,7 +368,7 @@ void Input::Update()
     {
     {
         IntVector2 mousePosition = GetMousePosition();
         IntVector2 mousePosition = GetMousePosition();
         mouseMove_ = mousePosition - lastMousePosition_;
         mouseMove_ = mousePosition - lastMousePosition_;
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
         if (graphics_->GetExternalWindow())
         if (graphics_->GetExternalWindow())
             lastMousePosition_ = mousePosition;
             lastMousePosition_ = mousePosition;
         else
         else
@@ -443,7 +443,7 @@ void Input::SetMouseVisible(bool enable, bool suppressEvent)
             if (!mouseVisible_ && inputFocus_)
             if (!mouseVisible_ && inputFocus_)
             {
             {
                 SDL_ShowCursor(SDL_FALSE);
                 SDL_ShowCursor(SDL_FALSE);
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
                 if (mouseMode_ != MM_FREE)
                 if (mouseMode_ != MM_FREE)
                 {
                 {
                     // Recenter the mouse cursor manually when hiding it to avoid erratic mouse move for one frame
                     // Recenter the mouse cursor manually when hiding it to avoid erratic mouse move for one frame
@@ -460,7 +460,7 @@ void Input::SetMouseVisible(bool enable, bool suppressEvent)
             else
             else
             {
             {
                 SDL_ShowCursor(SDL_TRUE);
                 SDL_ShowCursor(SDL_TRUE);
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
                 if (lastVisibleMousePosition_.x_ != MOUSE_POSITION_OFFSCREEN.x_ &&
                 if (lastVisibleMousePosition_.x_ != MOUSE_POSITION_OFFSCREEN.x_ &&
                     lastVisibleMousePosition_.y_ != MOUSE_POSITION_OFFSCREEN.y_)
                     lastVisibleMousePosition_.y_ != MOUSE_POSITION_OFFSCREEN.y_)
                     SetMousePosition(lastVisibleMousePosition_);
                     SetMousePosition(lastVisibleMousePosition_);
@@ -487,14 +487,14 @@ void Input::SetMouseVisible(bool enable, bool suppressEvent)
 
 
 void Input::ResetMouseVisible()
 void Input::ResetMouseVisible()
 {
 {
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
     SetMouseVisible(lastMouseVisible_, true);
     SetMouseVisible(lastMouseVisible_, true);
 #else
 #else
     SetMouseVisibleEmscripten(lastMouseVisible_);
     SetMouseVisibleEmscripten(lastMouseVisible_);
 #endif
 #endif
 }
 }
 
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
 void Input::SetMouseVisibleEmscripten(bool enable)
 void Input::SetMouseVisibleEmscripten(bool enable)
 {
 {
     if (enable != mouseVisible_)
     if (enable != mouseVisible_)
@@ -545,7 +545,7 @@ void Input::SetMouseMode(MouseMode mode)
         // Handle changing away from previous mode
         // Handle changing away from previous mode
         if (previousMode == MM_RELATIVE)
         if (previousMode == MM_RELATIVE)
         {
         {
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
             /// \todo Use SDL_SetRelativeMouseMode() for MM_RELATIVE mode
             /// \todo Use SDL_SetRelativeMouseMode() for MM_RELATIVE mode
             ResetMouseVisible();
             ResetMouseVisible();
 #else
 #else
@@ -554,7 +554,7 @@ void Input::SetMouseMode(MouseMode mode)
 
 
             SDL_SetWindowGrab(window, SDL_FALSE);
             SDL_SetWindowGrab(window, SDL_FALSE);
         }
         }
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
         else if (previousMode == MM_WRAP)
         else if (previousMode == MM_WRAP)
             SDL_SetWindowGrab(window, SDL_FALSE);
             SDL_SetWindowGrab(window, SDL_FALSE);
 #endif
 #endif
@@ -562,7 +562,7 @@ void Input::SetMouseMode(MouseMode mode)
         // Handle changing to new mode
         // Handle changing to new mode
         if (mode == MM_ABSOLUTE || mode == MM_FREE)
         if (mode == MM_ABSOLUTE || mode == MM_FREE)
         {
         {
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
             SetMouseGrabbed(false);
             SetMouseGrabbed(false);
             VariantMap& eventData = GetEventDataMap();
             VariantMap& eventData = GetEventDataMap();
             eventData[MouseModeChanged::P_MODE] = mode;
             eventData[MouseModeChanged::P_MODE] = mode;
@@ -578,7 +578,7 @@ void Input::SetMouseMode(MouseMode mode)
             if (mode == MM_RELATIVE)
             if (mode == MM_RELATIVE)
             {
             {
                 SDL_SetWindowGrab(window, SDL_TRUE);
                 SDL_SetWindowGrab(window, SDL_TRUE);
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
                 SetMouseVisible(false, true);
                 SetMouseVisible(false, true);
 
 
                 VariantMap& eventData = GetEventDataMap();
                 VariantMap& eventData = GetEventDataMap();
@@ -591,7 +591,7 @@ void Input::SetMouseMode(MouseMode mode)
 #endif
 #endif
 
 
             }
             }
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
             else if (mode == MM_WRAP)
             else if (mode == MM_WRAP)
             {
             {
                 /// \todo When SDL 2.0.4 is integrated, use SDL_CaptureMouse() and global mouse functions for MM_WRAP mode.
                 /// \todo When SDL 2.0.4 is integrated, use SDL_CaptureMouse() and global mouse functions for MM_WRAP mode.
@@ -935,7 +935,7 @@ unsigned Input::LoadGestures(Deserializer& source)
 
 
 bool Input::RemoveGesture(unsigned gestureID)
 bool Input::RemoveGesture(unsigned gestureID)
 {
 {
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     return false;
     return false;
 #else
 #else
     return SDL_RemoveDollarTemplate(gestureID) != 0;
     return SDL_RemoveDollarTemplate(gestureID) != 0;
@@ -944,7 +944,7 @@ bool Input::RemoveGesture(unsigned gestureID)
 
 
 void Input::RemoveAllGestures()
 void Input::RemoveAllGestures()
 {
 {
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
     SDL_RemoveAllDollarTemplates();
     SDL_RemoveAllDollarTemplates();
 #endif
 #endif
 }
 }
@@ -1169,7 +1169,7 @@ void Input::Initialize()
 
 
     // Set the initial activation
     // Set the initial activation
     initialized_ = true;
     initialized_ = true;
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
     focusedThisFrame_ = true;
     focusedThisFrame_ = true;
 #else
 #else
     // Note: Page visibility and focus are slightly different, however we can't query last focus with Emscripten (1.29.0)
     // Note: Page visibility and focus are slightly different, however we can't query last focus with Emscripten (1.29.0)
@@ -1356,7 +1356,7 @@ void Input::SendInputFocusEvent()
 
 
 void Input::SetMouseButton(int button, bool newState)
 void Input::SetMouseButton(int button, bool newState)
 {
 {
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     if (emscriptenEnteredPointerLock_)
     if (emscriptenEnteredPointerLock_)
     {
     {
         // Suppress mouse jump on initial Pointer Lock
         // Suppress mouse jump on initial Pointer Lock
@@ -1489,7 +1489,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
     {
     {
     case SDL_KEYDOWN:
     case SDL_KEYDOWN:
         // Convert to uppercase to match Win32 virtual key codes
         // Convert to uppercase to match Win32 virtual key codes
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, 0, true);
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, 0, true);
 #else
 #else
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, evt.key.keysym.raw, true);
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, evt.key.keysym.raw, true);
@@ -1497,7 +1497,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
         break;
         break;
 
 
     case SDL_KEYUP:
     case SDL_KEYUP:
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, 0, false);
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, 0, false);
 #else
 #else
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, evt.key.keysym.raw, false);
         SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, evt.key.keysym.raw, false);
@@ -1567,7 +1567,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
     case SDL_MOUSEMOTION:
     case SDL_MOUSEMOTION:
         // Emscripten will use SDL mouse move events for relative mode, as repositioning the mouse and
         // Emscripten will use SDL mouse move events for relative mode, as repositioning the mouse and
         // measuring distance from window center is not supported
         // measuring distance from window center is not supported
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
         if ((mouseVisible_ || mouseMode_ == MM_FREE) && !touchEmulation_)
         if ((mouseVisible_ || mouseMode_ == MM_FREE) && !touchEmulation_)
 #else
 #else
         if ((mouseVisible_ || mouseMode_ == MM_RELATIVE || mouseMode_ == MM_FREE) && !touchEmulation_)
         if ((mouseVisible_ || mouseMode_ == MM_RELATIVE || mouseMode_ == MM_FREE) && !touchEmulation_)
@@ -1620,7 +1620,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
             int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffff);
             int touchID = GetTouchIndexFromID(evt.tfinger.fingerId & 0x7ffffff);
             TouchState& state = touches_[touchID];
             TouchState& state = touches_[touchID];
             state.touchID_ = touchID;
             state.touchID_ = touchID;
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
             state.lastPosition_ = state.position_ = IntVector2((int)(evt.tfinger.x * graphics_->GetWidth()),
             state.lastPosition_ = state.position_ = IntVector2((int)(evt.tfinger.x * graphics_->GetWidth()),
                 (int)(evt.tfinger.y * graphics_->GetHeight()));
                 (int)(evt.tfinger.y * graphics_->GetHeight()));
 #else
 #else
@@ -1676,7 +1676,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
                 break;
                 break;
             TouchState& state = touches_[touchID];
             TouchState& state = touches_[touchID];
             state.touchID_ = touchID;
             state.touchID_ = touchID;
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
             state.position_ = IntVector2((int)(evt.tfinger.x * graphics_->GetWidth()),
             state.position_ = IntVector2((int)(evt.tfinger.x * graphics_->GetWidth()),
                 (int)(evt.tfinger.y * graphics_->GetHeight()));
                 (int)(evt.tfinger.y * graphics_->GetHeight()));
 #else
 #else
@@ -1691,7 +1691,7 @@ void Input::HandleSDLEvent(void* sdlEvent)
             eventData[P_TOUCHID] = touchID;
             eventData[P_TOUCHID] = touchID;
             eventData[P_X] = state.position_.x_;
             eventData[P_X] = state.position_.x_;
             eventData[P_Y] = state.position_.y_;
             eventData[P_Y] = state.position_.y_;
-#ifndef EMSCRIPTEN
+#ifndef __EMSCRIPTEN__
             eventData[P_DX] = (int)(evt.tfinger.dx * graphics_->GetWidth());
             eventData[P_DX] = (int)(evt.tfinger.dx * graphics_->GetWidth());
             eventData[P_DY] = (int)(evt.tfinger.dy * graphics_->GetHeight());
             eventData[P_DY] = (int)(evt.tfinger.dy * graphics_->GetHeight());
 #else
 #else

+ 4 - 4
Source/Urho3D/Input/Input.h

@@ -127,7 +127,7 @@ struct JoystickState
     PODVector<int> hats_;
     PODVector<int> hats_;
 };
 };
 
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
 class EmscriptenInput;
 class EmscriptenInput;
 #endif
 #endif
 
 
@@ -136,7 +136,7 @@ class URHO3D_API Input : public Object
 {
 {
     OBJECT(Input);
     OBJECT(Input);
 
 
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     friend class EmscriptenInput;
     friend class EmscriptenInput;
 #endif
 #endif
 
 
@@ -322,7 +322,7 @@ private:
     void SetMouseButton(int button, bool newState);
     void SetMouseButton(int button, bool newState);
     /// Handle a key change.
     /// Handle a key change.
     void SetKey(int key, int scancode, unsigned raw, bool newState);
     void SetKey(int key, int scancode, unsigned raw, bool newState);
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     /// Set whether the operating system mouse cursor is visible (Emscripten platform only).
     /// Set whether the operating system mouse cursor is visible (Emscripten platform only).
     void SetMouseVisibleEmscripten(bool enable);
     void SetMouseVisibleEmscripten(bool enable);
     /// Set mouse mode (Emscripten platform only).
     /// Set mouse mode (Emscripten platform only).
@@ -401,7 +401,7 @@ private:
     bool screenModeChanged_;
     bool screenModeChanged_;
     /// Initialized flag.
     /// Initialized flag.
     bool initialized_;
     bool initialized_;
-#ifdef EMSCRIPTEN
+#ifdef __EMSCRIPTEN__
     /// Emscripten Input glue instance.
     /// Emscripten Input glue instance.
     EmscriptenInput* emscriptenInput_;
     EmscriptenInput* emscriptenInput_;
     /// Flag used to detect mouse jump when exiting pointer lock.
     /// Flag used to detect mouse jump when exiting pointer lock.