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.
This commit is contained in:
George Marques 2016-09-03 19:36:44 -03:00
parent 2eaad1cfd1
commit c9b82498b4
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
6 changed files with 37 additions and 29 deletions

View file

@ -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");

View file

@ -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;

View file

@ -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

View file

@ -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) {

View file

@ -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 {

View file

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