-
-
+
+
-
-
+
-
-
diff --git a/data/shaders/detailledobject_pass2.frag b/data/shaders/detailledobject_pass2.frag
index a426b6935..5b19966cc 100644
--- a/data/shaders/detailledobject_pass2.frag
+++ b/data/shaders/detailledobject_pass2.frag
@@ -1,9 +1,11 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D Detail;
+layout(bindless_sampler) uniform sampler2D SpecMap;
#else
uniform sampler2D Albedo;
uniform sampler2D Detail;
+uniform sampler2D SpecMap;
#endif
#if __VERSION__ >= 130
@@ -16,7 +18,7 @@ varying vec2 uv_bis;
#define FragColor gl_FragColor
#endif
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
@@ -28,6 +30,6 @@ void main(void)
#endif
vec4 detail = texture(Detail, uv_bis);
color *= detail;
- vec3 LightFactor = getLightFactor(1. - color.a);
- FragColor = vec4(color.xyz * LightFactor, 1.);
+ float specmap = texture(SpecMap, uv).g;
+ FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.);
}
diff --git a/data/shaders/diffuseenvmap.frag b/data/shaders/diffuseenvmap.frag
index c88478b23..2ded6b2b0 100644
--- a/data/shaders/diffuseenvmap.frag
+++ b/data/shaders/diffuseenvmap.frag
@@ -2,11 +2,15 @@ uniform float blueLmn[9];
uniform float greenLmn[9];
uniform float redLmn[9];
uniform sampler2D ntex;
+uniform sampler2D dtex;
+uniform samplerCube tex;
uniform mat4 TransposeViewMatrix;
out vec4 Diff;
+out vec4 Spec;
vec3 DecodeNormal(vec2 n);
+vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
mat4 getMatrix(float L[9])
{
@@ -24,8 +28,9 @@ void main(void)
{
vec2 uv = gl_FragCoord.xy / screen;
vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
+
// Convert normal in world space (where SH coordinates were computed)
- vec4 extendednormal = TransposeViewMatrix * vec4(normal, 1.);
+ vec4 extendednormal = TransposeViewMatrix * vec4(normal, 0.);
extendednormal.w = 1.;
mat4 rmat = getMatrix(redLmn);
mat4 gmat = getMatrix(greenLmn);
@@ -36,4 +41,16 @@ void main(void)
float b = dot(extendednormal, bmat * extendednormal);
Diff = max(0.25 * vec4(r, g, b, .1), vec4(0.));
+
+ float z = texture(dtex, uv).x;
+
+ vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
+ vec3 eyedir = -normalize(xpos.xyz);
+ vec3 sampleDirection = reflect(-eyedir, normal);
+ sampleDirection = (InverseViewMatrix * vec4(sampleDirection, 0.)).xyz;
+
+ float specval = texture(ntex, uv).z;
+ float lodval = 16 * (1. - ((log2(specval) - 1.) / 10.));
+ vec4 specular = textureLod(tex, sampleDirection, lodval);
+ Spec = max(specular, vec4(0.));
}
diff --git a/data/shaders/grass_pass2.frag b/data/shaders/grass_pass2.frag
index 408e78365..6b677ceea 100644
--- a/data/shaders/grass_pass2.frag
+++ b/data/shaders/grass_pass2.frag
@@ -1,9 +1,11 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D dtex;
+layout(bindless_sampler) uniform sampler2D SpecMap;
#else
uniform sampler2D Albedo;
uniform sampler2D dtex;
+uniform sampler2D SpecMap;
#endif
uniform vec3 SunDir;
@@ -12,10 +14,18 @@ in vec3 nor;
in vec2 uv;
out vec4 FragColor;
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
+ vec4 color = texture(Albedo, uv);
+#ifdef GL_ARB_bindless_texture
+#ifdef SRGBBindlessFix
+ color.xyz = pow(color.xyz, vec3(2.2));
+#endif
+#endif
+ if (color.a < 0.5) discard;
+
vec2 texc = gl_FragCoord.xy / screen;
float z = texture(dtex, texc).x;
@@ -30,14 +40,8 @@ void main(void)
float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4);
float scattering = mix(fPowEdotL, fLdotNBack, .5);
+ float specmap = texture(SpecMap, uv).g;
- vec4 color = texture(Albedo, uv);
-#ifdef GL_ARB_bindless_texture
-#ifdef SRGBBindlessFix
- color.xyz = pow(color.xyz, vec3(2.2));
-#endif
-#endif
- if (color.a < 0.5) discard;
- vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
+ vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap);
FragColor = vec4(color.xyz * LightFactor, 1.);
}
diff --git a/data/shaders/instanced_detailledobject_pass2.frag b/data/shaders/instanced_detailledobject_pass2.frag
index c631fe3ef..927a6a845 100644
--- a/data/shaders/instanced_detailledobject_pass2.frag
+++ b/data/shaders/instanced_detailledobject_pass2.frag
@@ -1,22 +1,25 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D Albedo;
uniform sampler2D Detail;
+uniform sampler2D SpecMap;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
+flat in sampler2D secondhandle;
flat in sampler2D thirdhandle;
#endif
in vec2 uv;
in vec2 uv_bis;
out vec4 FragColor;
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 color = texture(handle, uv);
+ float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
@@ -24,8 +27,8 @@ void main(void)
#else
vec4 color = texture(Albedo, uv);
vec4 detail = texture(Detail, uv_bis);
+ float specmap = texture(SpecMap, uv).g;
#endif
color *= detail;
- vec3 LightFactor = getLightFactor(1. - color.a);
- FragColor = vec4(color.xyz * LightFactor, 1.);
+ FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.);
}
diff --git a/data/shaders/instanced_grass_pass2.frag b/data/shaders/instanced_grass_pass2.frag
index b297a4c88..0bd7f0dbe 100644
--- a/data/shaders/instanced_grass_pass2.frag
+++ b/data/shaders/instanced_grass_pass2.frag
@@ -2,6 +2,7 @@
layout(bindless_sampler) uniform sampler2D dtex;
#else
uniform sampler2D Albedo;
+uniform sampler2D SpecMap;
uniform sampler2D dtex;
#endif
@@ -9,15 +10,28 @@ uniform vec3 SunDir;
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
+flat in sampler2D secondhandle;
#endif
in vec3 nor;
in vec2 uv;
out vec4 FragColor;
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
+#ifdef GL_ARB_bindless_texture
+ vec4 color = texture(handle, uv);
+ float specmap = texture(secondhandle, uv).g;
+#ifdef SRGBBindlessFix
+ color.xyz = pow(color.xyz, vec3(2.2));
+#endif
+#else
+ vec4 color = texture(Albedo, uv);
+ float specmap = texture(SpecMap, uv).g;
+#endif
+ if (color.a < 0.5) discard;
+
vec2 texc = gl_FragCoord.xy / screen;
float z = texture(dtex, texc).x;
@@ -33,15 +47,7 @@ void main(void)
float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4);
float scattering = mix(fPowEdotL, fLdotNBack, .5);
-#ifdef GL_ARB_bindless_texture
- vec4 color = texture(handle, uv);
-#ifdef SRGBBindlessFix
- color.xyz = pow(color.xyz, vec3(2.2));
-#endif
-#else
- vec4 color = texture(Albedo, uv);
-#endif
- if (color.a < 0.5) discard;
- vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
- FragColor = vec4(color.xyz * LightFactor, 1.);
+
+ vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap);
+ FragColor = vec4(LightFactor, 1.);
}
diff --git a/data/shaders/instanced_object_pass2.frag b/data/shaders/instanced_object_pass2.frag
index 76176ba37..c260d7aab 100644
--- a/data/shaders/instanced_object_pass2.frag
+++ b/data/shaders/instanced_object_pass2.frag
@@ -1,27 +1,30 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D Albedo;
+uniform sampler2D SpecMap;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
+flat in sampler2D secondhandle;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
+ float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
+ float specmap = texture(SpecMap, uv).g;
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
- vec3 LightFactor = getLightFactor(1.);
- FragColor = vec4(col.xyz * LightFactor, 1.);
+ FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
}
diff --git a/data/shaders/instanced_objectpass_spheremap.frag b/data/shaders/instanced_objectpass_spheremap.frag
index 5365dd7ef..21414ee31 100644
--- a/data/shaders/instanced_objectpass_spheremap.frag
+++ b/data/shaders/instanced_objectpass_spheremap.frag
@@ -12,7 +12,7 @@ out vec4 FragColor;
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main() {
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
@@ -29,7 +29,6 @@ void main() {
#else
vec4 detail0 = texture(tex, r.xy / m + .5);
#endif
- vec3 LightFactor = getLightFactor(1.);
- FragColor = vec4(detail0.xyz * LightFactor, 1.);
+ FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.);
}
diff --git a/data/shaders/instanced_objectref_pass2.frag b/data/shaders/instanced_objectref_pass2.frag
index 201f610a1..41f3dc34f 100644
--- a/data/shaders/instanced_objectref_pass2.frag
+++ b/data/shaders/instanced_objectref_pass2.frag
@@ -1,28 +1,31 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D Albedo;
+uniform sampler2D SpecMap;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
+flat in sampler2D secondhandle;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
+ float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
+ float specmap = texture(SpecMap, uv).g;
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
- vec3 LightFactor = getLightFactor(1.);
- FragColor = vec4(col.xyz * LightFactor, 1.);
+ FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
}
diff --git a/data/shaders/object_pass2.frag b/data/shaders/object_pass2.frag
index 047f0a192..ba984f87d 100644
--- a/data/shaders/object_pass2.frag
+++ b/data/shaders/object_pass2.frag
@@ -1,14 +1,16 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
+layout(bindless_sampler) uniform sampler2D SpecMap;
#else
uniform sampler2D Albedo;
+uniform sampler2D SpecMap;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
@@ -21,6 +23,6 @@ void main(void)
vec4 col = texture(Albedo, uv);
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
- vec3 LightFactor = getLightFactor(1.);
- FragColor = vec4(col.xyz * LightFactor, 1.);
+ float specmap = texture(SpecMap, uv).g;
+ FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
}
diff --git a/data/shaders/objectpass_spheremap.frag b/data/shaders/objectpass_spheremap.frag
index 8e4e0f4fc..e5ed033d1 100644
--- a/data/shaders/objectpass_spheremap.frag
+++ b/data/shaders/objectpass_spheremap.frag
@@ -15,7 +15,7 @@ varying vec3 nor;
#endif
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main() {
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
@@ -30,7 +30,6 @@ void main() {
detail0.xyz = pow(detail0.xyz, vec3(2.2));
#endif
#endif
- vec3 LightFactor = getLightFactor(1.);
- FragColor = vec4(detail0.xyz * LightFactor, 1.);
+ FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.);
}
diff --git a/data/shaders/objectref_pass2.frag b/data/shaders/objectref_pass2.frag
index 13ff676f8..a7fd08dca 100644
--- a/data/shaders/objectref_pass2.frag
+++ b/data/shaders/objectref_pass2.frag
@@ -1,14 +1,16 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
+layout(bindless_sampler) uniform sampler2D SpecMap;
#else
uniform sampler2D Albedo;
+uniform sampler2D SpecMap;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main(void)
{
@@ -20,6 +22,6 @@ void main(void)
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
- vec3 LightFactor = getLightFactor(1.);
- FragColor = vec4(col.xyz * LightFactor, 1.);
+ float specmap = texture(SpecMap, uv).g;
+ FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
}
diff --git a/data/shaders/splatting.frag b/data/shaders/splatting.frag
index d302908d2..acc6fabc3 100644
--- a/data/shaders/splatting.frag
+++ b/data/shaders/splatting.frag
@@ -22,7 +22,7 @@ varying vec2 uv_bis;
#define FragColor gl_FragColor
#endif
-vec3 getLightFactor(float specMapValue);
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
void main() {
// Splatting part
@@ -46,6 +46,5 @@ void main() {
splatting.b * detail2 +
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
- vec3 LightFactor = getLightFactor(1.);
- FragColor = vec4(splatted.xyz * LightFactor, 1.);
+ FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0.), 1.);
}
diff --git a/data/shaders/utils/getLightFactor.frag b/data/shaders/utils/getLightFactor.frag
index 9bf4cdf58..7d974d56d 100644
--- a/data/shaders/utils/getLightFactor.frag
+++ b/data/shaders/utils/getLightFactor.frag
@@ -8,12 +8,12 @@ uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
#endif
-vec3 getLightFactor(float specMapValue)
+vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue)
{
vec2 tc = gl_FragCoord.xy / screen;
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
float ao = texture(SSAO, tc).x;
- vec3 tmp = DiffuseComponent + SpecularComponent * specMapValue;
+ vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue;
return tmp * ao;
}
\ No newline at end of file
diff --git a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp
index d4e6d9a91..74c335a35 100644
--- a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp
+++ b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp
@@ -277,7 +277,7 @@ void CGUIButton::draw()
pos.X += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X);
pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y);
}
- driver->draw2DImage(PressedImage,
+ skin->draw2DImage(PressedImage,
ScaleImage? AbsoluteRect :
core::recti(pos, PressedImageRect.getSize()),
PressedImageRect, &AbsoluteClippingRect,
diff --git a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp
index 17d30e0ec..184a6e5cc 100644
--- a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp
+++ b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp
@@ -78,20 +78,20 @@ void CGUIImage::draw()
if (Texture)
{
- if (ScaleImage)
- {
+ //if (ScaleImage)
+ //{
const video::SColor Colors[] = {Color,Color,Color,Color};
- driver->draw2DImage(Texture, AbsoluteRect,
+ skin->draw2DImage(Texture, AbsoluteRect,
core::rect
(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())),
&AbsoluteClippingRect, Colors, UseAlphaChannel);
- }
- else
- {
- driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner,
- core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())),
- &AbsoluteClippingRect, Color, UseAlphaChannel);
- }
+ //}
+ //else
+ //{
+ // driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner,
+ // core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())),
+ // &AbsoluteClippingRect, Color, UseAlphaChannel);
+ //}
}
else
{
diff --git a/src/config/hardware_stats.cpp b/src/config/hardware_stats.cpp
index 0770c2fe2..dd784e10c 100644
--- a/src/config/hardware_stats.cpp
+++ b/src/config/hardware_stats.cpp
@@ -23,15 +23,26 @@
#include "graphics/irr_driver.hpp"
#include "online/http_request.hpp"
#include "utils/random_generator.hpp"
-#include "utils/string_utils.hpp"
#ifdef __APPLE__
# include
#endif
+#include
+#include
+#include
+#include
+
+
namespace HardwareStats
{
+ namespace Private
+ {
+ /** Stores the OS version, e.g. "Windows 7", or "Fedora 21". */
+ static std::string m_os_version;
+ } // namespace Private
+ using namespace Private;
// ----------------------------------------------------------------------------
/** Returns the amount of RAM in MB.
@@ -102,6 +113,105 @@ int getNumProcessors()
return 0;
} // getNumProcessors
+// ----------------------------------------------------------------------------
+/** Tries opening and parsing the specified release file in /etc to find
+ * information about the distro used.
+ * \param filename Full path of the file to open.
+ * \return True if file could be read and valid information was paresed,
+ * false otherwise.
+ */
+bool readEtcReleaseFile(const std::string &filename)
+{
+ std::ifstream in(filename);
+ std::string s, distro, version;
+ int bits = 0;
+ while( (distro.empty() || version.empty()) &&
+ std::getline(in, s) )
+ {
+ std::vector l = StringUtils::split(s, '=');
+ if(l.size()==0) continue;
+ if (l[0]=="NAME" ) distro = l[1];
+ else if(l[0]=="VERSION_ID") version = l[1];
+ }
+ if(!distro.empty() && !version.empty())
+ {
+ m_os_version = distro + " " + version;
+ return true;
+ }
+ return false;
+} // readEtcReleaseFile
+
+// ----------------------------------------------------------------------------
+/** Identify more details about the OS, e.g. on linux which distro
+ * and which verison; on windows the version number.
+ * \param json Json data structure to store the os info in.
+ */
+void determineOSVersion()
+{
+ std::string version, distro;
+
+#ifdef __linux__
+ // First try the standard /etc/os-release. Then check for older versions
+ // e.g. /etc/fedora-release, /etc/SuSE-release, /etc/redhat-release
+ if(readEtcReleaseFile("/etc/os-release")) return;
+
+ std::set file_list;
+ file_manager->listFiles(file_list, "./", true);
+ for(std::set::iterator i = file_list.begin();
+ i != file_list.end(); i++)
+ {
+ // Only try reading /etc/*-release files
+ if(StringUtils::hasSuffix(*i, "-release"))
+ if (readEtcReleaseFile(*i)) return;
+ }
+#endif
+#ifdef WIN32
+ // (C) 2014 by Wildfire Games (0 A.D.), ported by Joerg Henrichs.
+
+ HKEY hKey;
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0,
+ KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
+ {
+ m_os_version = "windows-unknown";
+ return;
+ }
+ char windows_version_string[20];
+ DWORD size = sizeof(windows_version_string);
+ RegQueryValueEx(hKey, "CurrentVersion", 0, 0, (LPBYTE)windows_version_string, &size);
+ unsigned major = 0, minor = 0;
+ const int ret = sscanf_s(windows_version_string, "%u.%u", &major, &minor);
+ int windows_version = (major << 8) | minor;
+ RegCloseKey(hKey);
+
+ switch(windows_version)
+ {
+ case 0x0500: m_os_version="Windows 2000"; break;
+ case 0x0501: m_os_version="Windows XP"; break;
+ case 0x0502: m_os_version="Windows XP64"; break;
+ case 0x0600: m_os_version="Windows Vista"; break;
+ case 0x0601: m_os_version="Windows 7"; break;
+ case 0x0602: m_os_version="Windows 8"; break;
+ default: {
+ m_os_version = StringUtils::insertValues("Windows %d",
+ windows_version);
+ break;
+ }
+ } // switch
+
+#endif
+} // determineOSVersion
+
+// ----------------------------------------------------------------------------
+/** Returns the OS version, e.g.: "Windows 7", or "Fedora 21".
+ */
+const std::string& getOSVersion()
+{
+ if(m_os_version.empty())
+ determineOSVersion();
+ return m_os_version;
+} // getOSVersion
+
// ----------------------------------------------------------------------------
/** If the configuration of this installation has not been reported for the
* current version, collect the hardware statistics and send it to STK's
@@ -144,6 +254,8 @@ void reportHardwareStats()
json.add("build_debug", 1);
#endif
+ json.add("os_version", getOSVersion());
+
unsigned int ogl_version = irr_driver->getGLSLVersion();
unsigned int major = ogl_version/100;
unsigned int minor = ogl_version - 100*major;
@@ -195,7 +307,7 @@ void reportHardwareStats()
int m_version;
public:
HWReportRequest(int version) : Online::HTTPRequest(/*manage memory*/true, 1)
- ,m_version(version)
+ , m_version(version)
{}
// --------------------------------------------------------------------
/** Callback after the request has been executed.
diff --git a/src/config/hardware_stats.hpp b/src/config/hardware_stats.hpp
index f49f73ce5..4c5ef321f 100644
--- a/src/config/hardware_stats.hpp
+++ b/src/config/hardware_stats.hpp
@@ -25,11 +25,14 @@
#include "utils/no_copy.hpp"
#include "utils/string_utils.hpp"
+
namespace HardwareStats
{
+ /** A class to manage json data. */
class Json : public NoCopy
{
private:
+ /** The accumulated json data. */
std::string m_data;
public:
/** Constructor. */
@@ -78,6 +81,7 @@ namespace HardwareStats
// ========================================================================
void reportHardwareStats();
+ const std::string& getOSVersion();
}; // HardwareStats
#endif
diff --git a/src/graphics/lod_node.cpp b/src/graphics/lod_node.cpp
index 1fea813a6..31ab6d731 100644
--- a/src/graphics/lod_node.cpp
+++ b/src/graphics/lod_node.cpp
@@ -80,7 +80,11 @@ int LODNode::getLevel()
if (camera == NULL)
return (int)m_detail.size() - 1;
AbstractKart* kart = camera->getKart();
- const Vec3 &pos = kart->getFrontXYZ();
+ // use kart position and not camera position when a kart is available,
+ // because for some effects the camera will be moved to various locations
+ // (for instance shadows), so using camera position for LOD may result
+ // in objects being culled when they shouldn't
+ const Vec3 &pos = (kart != NULL ? kart->getFrontXYZ() : camera->getCameraSceneNode()->getAbsolutePosition());
const int dist =
(int)((m_nodes[0]->getAbsolutePosition()).getDistanceFromSQ(pos.toIrrVector() ));
diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp
index d633a8a3c..b9244c1a6 100644
--- a/src/graphics/material.cpp
+++ b/src/graphics/material.cpp
@@ -57,8 +57,7 @@ Material::Material(const XMLNode *node, bool deprecated)
m_shader_type = SHADERTYPE_SOLID;
m_deprecated = deprecated;
- node->get("name", &m_texname);
-
+ node->get("name", &m_texname);
if (m_texname=="")
{
throw std::runtime_error("[Material] No texture name specified "
@@ -66,6 +65,7 @@ Material::Material(const XMLNode *node, bool deprecated)
}
init();
+ node->get("lazy-load", &m_lazy_load);
bool b = false;
node->get("clampu", &b); if (b) m_clamp_tex |= UCLAMP; //blender 2.4 style
@@ -412,10 +412,10 @@ Material::Material(const std::string& fname, bool is_full_path,
*/
void Material::init()
{
+ m_lazy_load = false;
+ m_texture = NULL;
m_clamp_tex = 0;
m_shader_type = SHADERTYPE_SOLID;
- //m_lightmap = false;
- //m_adjust_image = ADJ_NONE;
m_backface_culling = true;
m_high_tire_adhesion = false;
m_below_surface = false;
@@ -455,6 +455,9 @@ void Material::init()
//-----------------------------------------------------------------------------
void Material::install(bool is_full_path, bool complain_if_not_found)
{
+ // Don't load a texture that is lazily loaded.
+ if(m_lazy_load) return;
+
const std::string &full_path = is_full_path
? m_texname
: file_manager->searchTexture(m_texname);
diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp
index 4e95e648b..934c3c433 100644
--- a/src/graphics/material.hpp
+++ b/src/graphics/material.hpp
@@ -22,13 +22,11 @@
#include "utils/no_copy.hpp"
+#include
#include