diff options
author | George Marques <george@gmarqu.es> | 2016-09-03 19:36:44 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2016-09-03 19:36:44 -0300 |
commit | c9b82498b4b8de7b5f4c19873421d32ca1749ed2 (patch) | |
tree | 0eb93a7f5534ae6ca54b7d31a274653bce806f71 | |
parent | 2eaad1cfd1c96538d7aaf8bbd46535f8a143d2ad (diff) |
Fix drivers coding for WinRT
- Add a proper function to retrieve IP addresses.
- Solve issues with Windows FileAccess and DirAccess to use the same code
for WinRT.
- Add patches to the GLES2 rasterizer to workaround ANGLE issues.
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 10 | ||||
-rw-r--r-- | drivers/gles2/shaders/material.glsl | 4 | ||||
-rw-r--r-- | drivers/unix/ip_unix.cpp | 15 | ||||
-rw-r--r-- | drivers/windows/dir_access_windows.cpp | 25 | ||||
-rw-r--r-- | drivers/windows/file_access_windows.cpp | 10 | ||||
-rw-r--r-- | drivers/windows/semaphore_windows.cpp | 2 |
6 files changed, 37 insertions, 29 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index ba93a26a2d..5adc8b8ce5 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -5210,7 +5210,6 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material material_shader.set_conditional(MaterialShaderGLES2::USE_FOG,current_env && current_env->fx_enabled[VS::ENV_FX_FOG]); //glDepthMask( true ); - } @@ -10833,6 +10832,11 @@ void RasterizerGLES2::init() { copy_shader.set_conditional(CopyShaderGLES2::USE_GLES_OVER_GL,true); #endif +#ifdef ANGLE_ENABLED + // Fix for ANGLE + material_shader.set_conditional(MaterialShaderGLES2::DISABLE_FRONT_FACING, true); +#endif + shadow=NULL; shadow_pass=0; @@ -10920,7 +10924,11 @@ void RasterizerGLES2::init() { srgb_supported=extensions.has("GL_EXT_sRGB"); +#ifndef ANGLE_ENABLED s3tc_srgb_supported = s3tc_supported && extensions.has("GL_EXT_texture_compression_s3tc"); +#else + s3tc_srgb_supported = s3tc_supported; +#endif latc_supported = extensions.has("GL_EXT_texture_compression_latc"); anisotropic_level=1.0; use_anisotropic_filter=extensions.has("GL_EXT_texture_filter_anisotropic"); diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl index e68949b056..fd778f3442 100644 --- a/drivers/gles2/shaders/material.glsl +++ b/drivers/gles2/shaders/material.glsl @@ -811,7 +811,11 @@ void main() { float specular_exp=1.0; float glow=0.0; float shade_param=0.0; +#ifdef DISABLE_FRONT_FACING + float side=float(1)*2.0-1.0; +#else float side=float(gl_FrontFacing)*2.0-1.0; +#endif #if defined(ENABLE_TANGENT_INTERP) vec3 binormal = normalize(binormal_interp)*side; vec3 tangent = normalize(tangent_interp)*side; diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 535a425302..08a8c19583 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "ip_unix.h" -#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED) && !defined(WINRT_ENABLED) +#if defined(UNIX_ENABLED) || defined(WINDOWS_ENABLED) #ifdef WINDOWS_ENABLED @@ -83,6 +83,19 @@ IP_Address IP_Unix::_resolve_hostname(const String& p_hostname) { void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { + using namespace Windows::Networking; + using namespace Windows::Networking::Connectivity; + + auto hostnames = NetworkInformation::GetHostNames(); + + for (int i = 0; i < hostnames->Size; i++) { + + if (hostnames->GetAt(i)->Type == HostNameType::Ipv4 && hostnames->GetAt(i)->IPInformation != nullptr) { + + r_addresses->push_back(IP_Address(String(hostnames->GetAt(i)->CanonicalName->Data()))); + + } + } }; #else diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 90e43d2518..ad4e8f301c 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -37,12 +37,6 @@ #include <stdio.h> #include "print_string.h" -#ifdef WINRT_ENABLED -#include <Synchapi.h> -#include <collection.h> -#include <ppltasks.h> -#endif - /* [03:57] <reduz> yessopie, so i dont havemak to rely on unicows @@ -135,14 +129,6 @@ Error DirAccessWindows::change_dir(String p_dir) { GLOBAL_LOCK_FUNCTION -#ifdef WINRT_ENABLED - - p_dir = fix_path(p_dir); - current_dir = normalize_path(p_dir); - - return OK; -#else - p_dir=fix_path(p_dir); @@ -178,19 +164,12 @@ Error DirAccessWindows::change_dir(String p_dir) { //} return worked?OK:ERR_INVALID_PARAMETER; -#endif } Error DirAccessWindows::make_dir(String p_dir) { GLOBAL_LOCK_FUNCTION -#ifdef WINRT_ENABLED - - return ERR_CANT_CREATE; - -#else - if (p_dir.is_rel_path()) p_dir=get_current_dir().plus_file(p_dir); @@ -215,8 +194,6 @@ Error DirAccessWindows::make_dir(String p_dir) { }; return ERR_CANT_CREATE; - -#endif } @@ -259,7 +236,6 @@ bool DirAccessWindows::file_exists(String p_file) { return false; return !(fileAttr&FILE_ATTRIBUTE_DIRECTORY); - } bool DirAccessWindows::dir_exists(String p_dir) { @@ -282,7 +258,6 @@ bool DirAccessWindows::dir_exists(String p_dir) { if (INVALID_FILE_ATTRIBUTES == fileAttr) return false; return (fileAttr&FILE_ATTRIBUTE_DIRECTORY); - } Error DirAccessWindows::rename(String p_path,String p_new_path) { diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 3f27068fb2..36dcab1d67 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -124,7 +124,16 @@ void FileAccessWindows::close() { bool rename_error; + +#ifdef WINRT_ENABLED + // WinRT has no PathFileExists, so we check attributes instead + DWORD fileAttr; + + fileAttr = GetFileAttributesW(save_path.c_str()); + if (INVALID_FILE_ATTRIBUTES == fileAttr) { +#else if (!PathFileExistsW(save_path.c_str())) { +#endif //creating new file rename_error = _wrename((save_path+".tmp").c_str(),save_path.c_str())!=0; } else { @@ -139,7 +148,6 @@ void FileAccessWindows::close() { ERR_FAIL_COND( rename_error ); } - } bool FileAccessWindows::is_open() const { diff --git a/drivers/windows/semaphore_windows.cpp b/drivers/windows/semaphore_windows.cpp index 74094f482a..8d11d1b1c1 100644 --- a/drivers/windows/semaphore_windows.cpp +++ b/drivers/windows/semaphore_windows.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "semaphore_windows.h" -#if defined(WINDOWS_ENABLED) && !defined(WINRT_ENABLED) +#if defined(WINDOWS_ENABLED) #include "os/memory.h" |