Pārlūkot izejas kodu

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.
George Marques 9 gadi atpakaļ
vecāks
revīzija
c51f54749f

+ 9 - 1
drivers/gles2/rasterizer_gles2.cpp

@@ -10193,6 +10193,11 @@ void RasterizerGLES2::init() {
 	shadow = NULL;
 	shadow_pass = 0;
 
+#ifdef ANGLE_ENABLED
+	// Fix for ANGLE
+	material_shader.set_conditional(MaterialShaderGLES2::DISABLE_FRONT_FACING, true);
+#endif
+
 	framebuffer.fbo = 0;
 	framebuffer.width = 0;
 	framebuffer.height = 0;
@@ -10271,9 +10276,12 @@ void RasterizerGLES2::init() {
 	s3tc_supported = extensions.has("GL_EXT_texture_compression_dxt1") || extensions.has("GL_EXT_texture_compression_s3tc") || extensions.has("WEBGL_compressed_texture_s3tc");
 	use_half_float = extensions.has("GL_OES_vertex_half_float");
 	atitc_supported = extensions.has("GL_AMD_compressed_ATC_texture");
-
 	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");

+ 4 - 0
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;

+ 10 - 4
drivers/unix/ip_unix.cpp

@@ -127,6 +127,15 @@ 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())));
+		}
+	}
 
 	auto hostnames = NetworkInformation::GetHostNames();
 
@@ -148,10 +157,7 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const {
 	while (true) {
 
 		addrs = (IP_ADAPTER_ADDRESSES *)memalloc(buf_size);
-		int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST |
-														  GAA_FLAG_SKIP_MULTICAST |
-														  GAA_FLAG_SKIP_DNS_SERVER |
-														  GAA_FLAG_SKIP_FRIENDLY_NAME,
+		int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME,
 				NULL, addrs, &buf_size);
 		if (err == NO_ERROR) {
 			break;

+ 0 - 23
drivers/windows/dir_access_windows.cpp

@@ -38,12 +38,6 @@
 #include <wchar.h>
 #include <windows.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
@@ -130,14 +124,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);
 
 	wchar_t real_current_dir_name[2048];
@@ -170,19 +156,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);
 
@@ -207,8 +186,6 @@ Error DirAccessWindows::make_dir(String p_dir) {
 	};
 
 	return ERR_CANT_CREATE;
-
-#endif
 }
 
 String DirAccessWindows::get_current_dir() {

+ 10 - 0
drivers/windows/file_access_windows.cpp

@@ -115,7 +115,16 @@ void FileAccessWindows::close() {
 		//int rename_error = _wrename((save_path+".tmp").c_str(),save_path.c_str());
 
 		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 {
@@ -130,6 +139,7 @@ void FileAccessWindows::close() {
 		ERR_FAIL_COND(rename_error);
 	}
 }
+
 bool FileAccessWindows::is_open() const {
 
 	return (f != NULL);

+ 1 - 1
drivers/windows/semaphore_windows.cpp

@@ -29,7 +29,7 @@
 /*************************************************************************/
 #include "semaphore_windows.h"
 
-#if defined(WINDOWS_ENABLED) && !defined(WINRT_ENABLED)
+#if defined(WINDOWS_ENABLED)
 
 #include "os/memory.h"