Merge branch 'master' of https://github.com/math07/stk-code into working

This commit is contained in:
Mathieu Laprise
2014-12-27 15:14:35 -05:00
83 changed files with 806 additions and 1057 deletions

View File

@@ -58,7 +58,7 @@
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="perPlayerDifficulty"/>
<spacer width="20" height="100%" />
<label height="100%" I18N="In the ui settings" text="Enable handicaped users"/>
<label height="100%" I18N="In the ui settings" text="Enable handicapped users"/>
</div>
</div>

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D Detail;
layout(bindless_sampler) uniform sampler2D SpecMap;
@@ -23,7 +23,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
vec4 color = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D dtex;
layout(bindless_sampler) uniform sampler2D SpecMap;
@@ -17,7 +17,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
vec4 color = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif

View File

@@ -1,3 +1,5 @@
#ifndef HEADER_TXT
#define HEADER_TXT
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
@@ -61,4 +63,5 @@ layout (std140) uniform LightingData
float rL21;
float rL22;
};
#endif
#endif
#endif // HEADER_TXT

View File

@@ -1,10 +1,10 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D Detail;
uniform sampler2D SpecMap;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
flat in sampler2D thirdhandle;
@@ -17,7 +17,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 color = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix

View File

@@ -9,7 +9,7 @@ layout(location = 3) in vec2 Texcoord;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(location = 10) in sampler2D Handle;
layout(location = 11) in sampler2D SecondHandle;
#endif
@@ -27,7 +27,7 @@ in vec3 Scale;
out vec3 nor;
out vec2 uv;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat out sampler2D handle;
flat out sampler2D secondhandle;
#endif
@@ -42,7 +42,7 @@ void main()
gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
uv = Texcoord;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
handle = Handle;
secondhandle = SecondHandle;
#endif

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D dtex;
#else
uniform sampler2D Albedo;
@@ -6,7 +6,7 @@ uniform sampler2D SpecMap;
uniform sampler2D dtex;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
@@ -18,7 +18,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 color = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix

View File

@@ -1,9 +1,9 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D normalMap;
uniform sampler2D glossMap;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D secondhandle;
flat in sampler2D thirdhandle;
#endif
@@ -17,7 +17,7 @@ vec2 EncodeNormal(vec3 n);
void main()
{
// normal in Tangent Space
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec3 TS_normal = 2.0 * texture(thirdhandle, uv).rgb - 1.0;
float gloss = texture(secondhandle, uv).x;
#else

View File

@@ -10,7 +10,7 @@ layout(location = 6) in vec3 Bitangent;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(location = 10) in sampler2D Handle;
layout(location = 11) in sampler2D SecondHandle;
layout(location = 13) in sampler2D ThirdHandle;
@@ -36,7 +36,7 @@ out vec3 bitangent;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat out sampler2D handle;
flat out sampler2D secondhandle;
flat out sampler2D thirdhandle;
@@ -56,7 +56,7 @@ void main(void)
uv = Texcoord;
uv_bis = SecondTexcoord;
color = Color.zyxw;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
handle = Handle;
secondhandle = SecondHandle;
thirdhandle = ThirdHandle;

View File

@@ -1,8 +1,8 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D glosstex;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D secondhandle;
#endif
in vec3 nor;
@@ -13,7 +13,7 @@ vec2 EncodeNormal(vec3 n);
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
float glossmap = texture(secondhandle, uv).x;
#else
float glossmap = texture(glosstex, uv).x;

View File

@@ -1,9 +1,9 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
@@ -15,7 +15,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 col = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
float emitmap = texture(secondhandle, uv).b;

View File

@@ -1,8 +1,8 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
#endif
@@ -12,7 +12,7 @@ out vec4 FragColor;
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 col = texture(handle, uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));

View File

@@ -1,10 +1,10 @@
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
#endif
in vec3 nor;
@@ -21,7 +21,7 @@ void main() {
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
r.y = - r.y;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 detail0 = texture(handle, r.xy / m + .5);
#ifdef SRGBBindlessFix
detail0.xyz = pow(detail0.xyz, vec3(2.2));

View File

@@ -1,9 +1,9 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
uniform sampler2D glosstex;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
@@ -14,7 +14,7 @@ out vec3 EncodedNormal;
vec2 EncodeNormal(vec3 n);
void main() {
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 col = texture(handle, uv);
float glossmap = texture(secondhandle, uv).x;
#else

View File

@@ -1,9 +1,9 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
@@ -15,7 +15,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 col = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix

View File

@@ -1,11 +1,11 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
#endif
in vec2 uv;
in vec3 nor;
in vec4 color;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in uvec2 handle;
#endif
layout (location = 0) out vec3 RSMColor;
@@ -13,7 +13,7 @@ layout (location = 1) out vec3 RSMNormals;
void main()
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 col = texture(sampler2D(handle), uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));

View File

@@ -8,7 +8,7 @@ layout(location = 4) in vec2 SecondTexcoord;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(location = 10) in uvec2 Handle;
#endif
@@ -16,7 +16,7 @@ out vec3 nor;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat out uvec2 handle;
#endif
@@ -33,7 +33,7 @@ void main(void)
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
uv = Texcoord;
color = Color.zyxw;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
}

View File

@@ -1,21 +1,21 @@
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in uvec2 hdle[3];
#endif
in vec2 tc[3];
in int layerId[3];
out vec2 uv;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
out flat uvec2 handle;
#endif
void main(void)
{
gl_Layer = layerId[0];
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
handle = hdle[0];
#endif
for(int i=0; i<3; i++)

View File

@@ -1,8 +1,8 @@
#ifndef GL_ARB_bindless_texture
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat in uvec2 handle;
#endif
in vec2 uv;
@@ -11,7 +11,7 @@ out vec4 FragColor;
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 col = texture(sampler2D(handle), uv);
#else
vec4 col = texture(tex, uv);

View File

@@ -9,7 +9,7 @@ layout(location = 3) in vec2 Texcoord;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(location = 10) in uvec2 Handle;
#endif
@@ -25,13 +25,13 @@ in vec3 Scale;
#ifdef VSLayer
out vec2 uv;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat out uvec2 handle;
#endif
#else
out vec2 tc;
out int layerId;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat out uvec2 hdle;
#endif
#endif
@@ -46,14 +46,14 @@ void main(void)
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
uv = Texcoord;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
#else
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
tc = Texcoord;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
hdle = Handle;
#endif
#endif

View File

@@ -7,7 +7,7 @@ layout(location = 3) in vec2 Texcoord;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(location = 10) in uvec2 Handle;
#endif
@@ -22,13 +22,13 @@ in vec3 Scale;
#ifdef VSLayer
out vec2 uv;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat out uvec2 handle;
#endif
#else
out vec2 tc;
out int layerId;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
flat out uvec2 hdle;
#endif
#endif
@@ -43,14 +43,14 @@ void main(void)
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
uv = Texcoord;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
#else
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
tc = Texcoord;
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
hdle = Handle;
#endif
#endif

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D normalMap;
layout(bindless_sampler) uniform sampler2D DiffuseForAlpha;
#else

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D SpecMap;
#else
@@ -14,7 +14,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
vec4 col = texture(Albedo, uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
@@ -24,5 +24,6 @@ void main(void)
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
float specmap = texture(SpecMap, uv).g;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, 0.), 1.);
float emitmap = texture(SpecMap, uv).b;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);
}

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
@@ -11,7 +11,7 @@ out vec4 FragColor;
void main(void)
{
vec4 col = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif

View File

@@ -1,6 +1,6 @@
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
@@ -25,7 +25,7 @@ void main() {
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
r.y = - r.y;
vec4 detail0 = texture(tex, r.xy / m + .5);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
detail0.xyz = pow(detail0.xyz, vec3(2.2));
#endif

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
layout(bindless_sampler) uniform sampler2D glosstex;
#else

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D SpecMap;
#else
@@ -15,7 +15,7 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
void main(void)
{
vec4 col = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex_layout;
layout(bindless_sampler) uniform sampler2D tex_detail0;
layout(bindless_sampler) uniform sampler2D tex_detail1;
@@ -32,7 +32,7 @@ void main() {
vec4 detail2 = texture(tex_detail2, uv);
vec4 detail3 = texture(tex_detail3, uv);
vec4 detail4 = vec4(0.0);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
detail0.xyz = pow(detail0.xyz, vec3(2.2));
detail1.xyz = pow(detail1.xyz, vec3(2.2));

View File

@@ -8,16 +8,7 @@ vec3 DecodeNormal(vec2 n);
vec3 SpecularBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
vec3 DiffuseBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
vec3 getMostRepresentativePoint(vec3 direction, vec3 R, float angularRadius)
{
vec3 D = direction;
float d = cos(angularRadius);
float r = sin(angularRadius);
float DdotR = dot(D, R);
vec3 S = R - DdotR * D;
return (DdotR < d) ? normalize(d * D + normalize (S) * r) : R;
}
vec3 SunMRP(vec3 normal, vec3 eyedir);
void main() {
vec2 uv = gl_FragCoord.xy / screen;
@@ -28,12 +19,8 @@ void main() {
float roughness = texture(ntex, uv).z;
vec3 eyedir = -normalize(xpos.xyz);
vec3 L = normalize((transpose(InverseViewMatrix) * vec4(sun_direction, 0.)).xyz);
float NdotL = clamp(dot(norm, L), 0., 1.);
float angle = 3.14 * sun_angle / 180.;
vec3 R = reflect(-eyedir, norm);
vec3 Lightdir = getMostRepresentativePoint(L, R, angle);
vec3 Lightdir = SunMRP(norm, eyedir);
float NdotL = clamp(dot(norm, Lightdir), 0., 1.);
vec3 Specular = SpecularBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
vec3 Diffuse = DiffuseBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);

View File

@@ -15,16 +15,7 @@ vec3 DecodeNormal(vec2 n);
vec3 SpecularBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
vec3 DiffuseBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
vec3 getMostRepresentativePoint(vec3 direction, vec3 R, float angularRadius)
{
vec3 D = direction;
float d = cos(angularRadius);
float r = sin(angularRadius);
float DdotR = dot(D, R);
vec3 S = R - DdotR * D;
return (DdotR < d) ? normalize(d * D + normalize (S) * r) : R;
}
vec3 SunMRP(vec3 normal, vec3 eyedir);
float getShadowFactor(vec3 pos, int index)
{
@@ -46,12 +37,8 @@ void main() {
float roughness =texture(ntex, uv).z;
vec3 eyedir = -normalize(xpos.xyz);
vec3 L = normalize((transpose(InverseViewMatrix) * vec4(sun_direction, 0.)).xyz);
float NdotL = clamp(dot(norm, L), 0., 1.);
float angle = 3.14 * sun_angle / 180.;
vec3 R = reflect(-eyedir, norm);
vec3 Lightdir = getMostRepresentativePoint(L, R, angle);
vec3 Lightdir = SunMRP(norm, eyedir);
float NdotL = clamp(dot(norm, Lightdir), 0., 1.);
vec3 Specular = SpecularBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
vec3 Diffuse = DiffuseBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
@@ -12,7 +12,7 @@ out vec4 FragColor;
void main()
{
vec4 Color = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
Color.xyz = pow(Color.xyz, vec3(2.2));
#endif
Color.xyz *= pow(color.xyz, vec3(2.2));

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
@@ -20,7 +20,7 @@ out vec4 FragColor;
void main()
{
vec4 diffusecolor = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
diffusecolor.xyz = pow(diffusecolor.xyz, vec3(2.2));
#endif
diffusecolor.xyz *= pow(color.xyz, vec3(2.2));

View File

@@ -0,0 +1,14 @@
// Sun Most Representative Point (used for MRP area lighting method)
// From "Frostbite going PBR" paper
vec3 SunMRP(vec3 normal, vec3 eyedir)
{
vec3 local_sundir = normalize((transpose(InverseViewMatrix) * vec4(sun_direction, 0.)).xyz);
vec3 R = reflect(-eyedir, normal);
float angularRadius = 3.14 * sun_angle / 180.;
vec3 D = local_sundir;
float d = cos(angularRadius);
float r = sin(angularRadius);
float DdotR = dot(D, R);
vec3 S = R - DdotR * D;
return (DdotR < d) ? normalize(d * D + normalize (S) * r) : R;
}

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D DiffuseMap;
layout(bindless_sampler) uniform sampler2D SpecularMap;
layout(bindless_sampler) uniform sampler2D SSAO;

View File

@@ -1,4 +1,4 @@
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
@@ -20,7 +20,7 @@ out vec4 FragColor;
void main()
{
vec4 diffusecolor = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
#ifdef Use_Bindless_Texture
diffusecolor.xyz = pow(diffusecolor.xyz, vec3(2.2));
#endif
diffusecolor.xyz *= pow(color.xyz, vec3(2.2));

View File

@@ -46,8 +46,6 @@ AchievementsManager::AchievementsManager()
for (unsigned int i = 0; i < num_nodes; i++)
{
const XMLNode *node = root->getNode(i);
std::string type("");
node->get("type", &type);
AchievementInfo * achievement_info = new AchievementInfo(node);
m_achievements_info[achievement_info->getID()] = achievement_info;
}

View File

@@ -24,6 +24,7 @@
#include "config/hardware_stats.hpp"
#include "config/user_config.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
#include "online/http_request.hpp"
@@ -303,7 +304,7 @@ void reportHardwareStats()
json.add("os_version", getOSVersion());
unsigned int ogl_version = irr_driver->getGLSLVersion();
unsigned int ogl_version = CVS->getGLSLVersion();
unsigned int major = ogl_version/100;
unsigned int minor = ogl_version - 100*major;
std::string version =

View File

@@ -1,4 +1,5 @@
#include "2dutils.hpp"
#include "central_settings.hpp"
#include "glwrap.hpp"
#include "utils/cpp2011.hpp"
@@ -104,7 +105,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
const video::SColor &colors, bool useAlphaChannelOfTexture)
{
if (!irr_driver->isGLSL()) {
if (!CVS->isGLSL()) {
video::SColor duplicatedArray[4] = {
colors, colors, colors, colors
};
@@ -195,7 +196,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
const video::SColor* const colors, bool useAlphaChannelOfTexture)
{
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
{
irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture);
return;
@@ -246,7 +247,7 @@ void draw2DVertexPrimitiveList(video::ITexture *tex, const void* vertices,
u32 vertexCount, const void* indexList, u32 primitiveCount,
video::E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, video::E_INDEX_TYPE iType)
{
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
{
irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType, iType);
return;
@@ -281,7 +282,7 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
const core::rect<s32>* clip)
{
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
{
irr_driver->getVideoDriver()->draw2DRectangle(color, position, clip);
return;

View File

@@ -0,0 +1,312 @@
#include "central_settings.hpp"
#include "modes/profile_world.hpp"
#include "gl_headers.hpp"
#include "glwrap.hpp"
#include "graphics_restrictions.hpp"
CentralVideoSettings *CVS = new CentralVideoSettings();
void CentralVideoSettings::init()
{
m_gl_major_version = 2;
m_gl_minor_version = 1;
// Parse extensions
hasVSLayer = false;
hasBaseInstance = false;
hasBuffserStorage = false;
hasDrawIndirect = false;
hasComputeShaders = false;
hasTextureStorage = false;
hasTextureView = false;
hasBindlessTexture = false;
hasAtomics = false;
hasSSBO = false;
hasImageLoadStore = false;
hasMultiDrawIndirect = false;
hasTextureCompression = false;
hasUBO = false;
hasGS = false;
m_need_rh_workaround = false;
m_need_srgb_workaround = false;
// Call to glGetIntegerv should not be made if --no-graphics is used
if (!ProfileWorld::isNoGraphics())
{
}
if (!ProfileWorld::isNoGraphics())
{
glGetIntegerv(GL_MAJOR_VERSION, &m_gl_major_version);
glGetIntegerv(GL_MINOR_VERSION, &m_gl_minor_version);
Log::info("IrrDriver", "OpenGL version: %d.%d", m_gl_major_version, m_gl_minor_version);
Log::info("IrrDriver", "OpenGL vendor: %s", glGetString(GL_VENDOR));
Log::info("IrrDriver", "OpenGL renderer: %s", glGetString(GL_RENDERER));
Log::info("IrrDriver", "OpenGL version string: %s", glGetString(GL_VERSION));
}
m_glsl = (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version >= 1));
if (!ProfileWorld::isNoGraphics())
initGL();
#if !defined(__APPLE__)
if (!ProfileWorld::isNoGraphics())
{
std::string driver((char*)(glGetString(GL_VERSION)));
std::string card((char*)(glGetString(GL_RENDERER)));
std::vector<std::string> restrictions =
GraphicsRestrictions::getRestrictions(driver, card);
if (hasGLExtension("GL_AMD_vertex_shader_layer")) {
hasVSLayer = true;
Log::info("GLDriver", "AMD Vertex Shader Layer Present");
}
if (hasGLExtension("GL_ARB_buffer_storage")) {
hasBuffserStorage = true;
Log::info("GLDriver", "ARB Buffer Storage Present");
}
if (hasGLExtension("GL_ARB_base_instance")) {
hasBaseInstance = true;
Log::info("GLDriver", "ARB Base Instance Present");
}
if (hasGLExtension("GL_ARB_draw_indirect")) {
hasDrawIndirect = true;
Log::info("GLDriver", "ARB Draw Indirect Present");
}
if (hasGLExtension("GL_ARB_compute_shader")) {
hasComputeShaders = true;
Log::info("GLDriver", "ARB Compute Shader Present");
}
if (hasGLExtension("GL_ARB_texture_storage")) {
hasTextureStorage = true;
Log::info("GLDriver", "ARB Texture Storage Present");
}
if (hasGLExtension("GL_ARB_texture_view")) {
hasTextureView = true;
Log::info("GLDriver", "ARB Texture View Present");
}
if (hasGLExtension("GL_ARB_bindless_texture")) {
hasBindlessTexture = true;
Log::info("GLDriver", "ARB Bindless Texture Present");
}
if (hasGLExtension("GL_ARB_shader_image_load_store")) {
hasImageLoadStore = true;
Log::info("GLDriver", "ARB Image Load Store Present");
}
if (hasGLExtension("GL_ARB_shader_atomic_counters")) {
hasAtomics = true;
Log::info("GLDriver", "ARB Shader Atomic Counters Present");
}
if (hasGLExtension("GL_ARB_shader_storage_buffer_object")) {
hasSSBO = true;
Log::info("GLDriver", "ARB Shader Storage Buffer Object Present");
}
if (hasGLExtension("GL_ARB_multi_draw_indirect")) {
hasMultiDrawIndirect = true;
Log::info("GLDriver", "ARB Multi Draw Indirect Present");
}
if (hasGLExtension("GL_EXT_texture_compression_s3tc")) {
hasTextureCompression = true;
Log::info("GLDriver", "EXT Texture Compression S3TC Present");
}
if (hasGLExtension("GL_ARB_uniform_buffer_object")) {
hasUBO = true;
Log::info("GLDriver", "ARB Uniform Buffer Object Present");
}
if (hasGLExtension("GL_ARB_geometry_shader4")) {
hasGS = true;
Log::info("GLDriver", "ARB Geometry Shader 4 Present");
}
// Specific disablement
// (should use graphic restriction system)
if (strstr((const char *)glGetString(GL_VENDOR), "Intel") != NULL)
{
// Intel doesnt support sRGB compressed textures on some chip/OS
// TODO: Have a more precise list
// Sandy Bridge on Windows
hasTextureCompression = false;
#ifdef WIN32
// Fix for Intel Sandy Bridge on Windows which supports GL up to 3.1 only
// Works with Haswell and latest drivers
// Status unknown on Ivy Bridge
// Status unknown on older driver for Haswell
if (m_gl_major_version == 3 && m_gl_minor_version == 1)
hasUBO = false;
#endif
}
if (strstr((const char *)glGetString(GL_VENDOR), "NVIDIA") != NULL)
{
// Fix for Nvidia and instanced RH
// Compiler crashes with a big loop in RH or GI shaders
m_need_rh_workaround = true;
// Atomic counters make the driver crash on windows and linux
hasAtomics = false;
}
if (strstr((const char *)glGetString(GL_VENDOR), "ATI") != NULL)
{
// Bindless textures are all treated RGB even sRGB one
m_need_srgb_workaround = true;
}
// Mesa
if (strstr((const char *)glGetString(GL_VENDOR), "Intel Open Source Technology Center") != NULL ||
strstr((const char *)glGetString(GL_VENDOR), "Gallium") != NULL)
{
// Needs a patched Mesa (current 10.4) to use array texture fbo
// Technically GS works but array texture fbo interacts with GS.
hasGS = false;
}
}
#endif
}
unsigned CentralVideoSettings::getGLSLVersion() const
{
if (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version == 3))
return m_gl_major_version * 100 + m_gl_minor_version * 10;
else if (m_gl_major_version == 3)
return 100 + (m_gl_minor_version + 3) * 10;
else
return 120;
}
bool CentralVideoSettings::isGLSL() const
{
return m_glsl;
}
bool CentralVideoSettings::needRHWorkaround() const
{
return m_need_rh_workaround;
}
bool CentralVideoSettings::needsRGBBindlessWorkaround() const
{
return m_need_srgb_workaround;
}
bool CentralVideoSettings::isARBGeometryShader4Usable() const
{
return hasGS;
}
bool CentralVideoSettings::isARBUniformBufferObjectUsable() const
{
return hasUBO;
}
bool CentralVideoSettings::isEXTTextureCompressionS3TCUsable() const
{
return hasTextureCompression;
}
bool CentralVideoSettings::isARBBaseInstanceUsable() const
{
return hasBaseInstance;
}
bool CentralVideoSettings::isARBDrawIndirectUsable() const
{
return hasDrawIndirect;
}
bool CentralVideoSettings::isAMDVertexShaderLayerUsable() const
{
return hasVSLayer;
}
bool CentralVideoSettings::isARBBufferStorageUsable() const
{
return hasBuffserStorage;
}
bool CentralVideoSettings::isARBComputeShaderUsable() const
{
return hasComputeShaders;
}
bool CentralVideoSettings::isARBTextureStorageUsable() const
{
return hasTextureStorage;
}
bool CentralVideoSettings::isARBTextureViewUsable() const
{
return hasTextureView;
}
bool CentralVideoSettings::isARBBindlessTextureUsable() const
{
return hasBindlessTexture;
}
bool CentralVideoSettings::isARBShaderAtomicCountersUsable() const
{
return hasAtomics;
}
bool CentralVideoSettings::isARBShaderStorageBufferObjectUsable() const
{
return hasSSBO;
}
bool CentralVideoSettings::isARBImageLoadStoreUsable() const
{
return hasComputeShaders;
}
bool CentralVideoSettings::isARBMultiDrawIndirectUsable() const
{
return hasMultiDrawIndirect;
}
bool CentralVideoSettings::supportsShadows() const
{
return isARBGeometryShader4Usable() && isARBUniformBufferObjectUsable();
}
bool CentralVideoSettings::supportsGlobalIllumination() const
{
return isARBGeometryShader4Usable() && isARBUniformBufferObjectUsable();
}
bool CentralVideoSettings::supportsIndirectInstancingRendering() const
{
return isARBBaseInstanceUsable() && isARBDrawIndirectUsable();
}
bool CentralVideoSettings::supportsComputeShadersFiltering() const
{
return isARBBufferStorageUsable() && isARBImageLoadStoreUsable();
}
bool CentralVideoSettings::isShadowEnabled() const
{
return supportsShadows() && UserConfigParams::m_shadows;
}
bool CentralVideoSettings::isGlobalIlluminationEnabled() const
{
return supportsGlobalIllumination() && UserConfigParams::m_gi;
}
bool CentralVideoSettings::isTextureCompressionEnabled() const
{
return isEXTTextureCompressionS3TCUsable() && UserConfigParams::m_texture_compression;
}
// See http://visual-computing.intel-research.net/art/publications/sdsm/
bool CentralVideoSettings::isSDSMEnabled() const
{
return isShadowEnabled() && isARBShaderAtomicCountersUsable() && isARBShaderStorageBufferObjectUsable() && isARBComputeShaderUsable() && isARBImageLoadStoreUsable() && UserConfigParams::m_sdsm;
}
// See http://fr.slideshare.net/CassEveritt/approaching-zero-driver-overhead
bool CentralVideoSettings::isAZDOEnabled() const
{
return supportsIndirectInstancingRendering() && isARBBindlessTextureUsable() && isARBMultiDrawIndirectUsable() && UserConfigParams::m_azdo;
}

View File

@@ -0,0 +1,72 @@
#ifndef CENTRAL_SETTINGS_HPP
#define CENTRAL_SETTINGS_HPP
class CentralVideoSettings
{
private:
/** Supports GLSL */
bool m_glsl;
int m_gl_major_version, m_gl_minor_version;
bool hasVSLayer;
bool hasBaseInstance;
bool hasDrawIndirect;
bool hasBuffserStorage;
bool hasComputeShaders;
bool hasTextureStorage;
bool hasTextureView;
bool hasBindlessTexture;
bool hasUBO;
bool hasGS;
bool hasTextureCompression;
bool hasAtomics;
bool hasSSBO;
bool hasImageLoadStore;
bool hasMultiDrawIndirect;
bool m_need_rh_workaround;
bool m_need_srgb_workaround;
public:
void init();
bool isGLSL() const;
unsigned getGLSLVersion() const;
// Needs special handle ?
bool needRHWorkaround() const;
bool needsRGBBindlessWorkaround() const;
// Extension is available and safe to use
bool isARBUniformBufferObjectUsable() const;
bool isEXTTextureCompressionS3TCUsable() const;
bool isARBTextureViewUsable() const;
bool isARBGeometryShader4Usable() const;
bool isARBTextureStorageUsable() const;
bool isAMDVertexShaderLayerUsable() const;
bool isARBComputeShaderUsable() const;
bool isARBBindlessTextureUsable() const;
bool isARBBufferStorageUsable() const;
bool isARBBaseInstanceUsable() const;
bool isARBDrawIndirectUsable() const;
bool isARBShaderAtomicCountersUsable() const;
bool isARBShaderStorageBufferObjectUsable() const;
bool isARBImageLoadStoreUsable() const;
bool isARBMultiDrawIndirectUsable() const;
// Are all required extensions available for feature support
bool supportsShadows() const;
bool supportsGlobalIllumination() const;
bool supportsIndirectInstancingRendering() const;
bool supportsComputeShadersFiltering() const;
// "Macro" around feature support and user config
bool isShadowEnabled() const;
bool isGlobalIlluminationEnabled() const;
bool isTextureCompressionEnabled() const;
bool isSDSMEnabled() const;
bool isAZDOEnabled() const;
};
extern CentralVideoSettings* CVS;
#endif

View File

@@ -1,3 +1,4 @@
#include "graphics/central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "config/user_config.hpp"
@@ -265,7 +266,7 @@ void FrameBuffer::BlitToDefault(size_t x0, size_t y0, size_t x1, size_t y1)
void draw3DLine(const core::vector3df& start,
const core::vector3df& end, irr::video::SColor color)
{
if (!irr_driver->isGLSL()) {
if (!CVS->isGLSL()) {
irr_driver->getVideoDriver()->draw3DLine(start, end, color);
return;
}

View File

@@ -60,6 +60,8 @@ public:
size_t getHeight() const { return height; }
static void Blit(const FrameBuffer &Src, FrameBuffer &Dst, GLbitfield mask = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST);
void BlitToDefault(size_t, size_t, size_t, size_t);
LEAK_CHECK();
};
class VertexUtils

View File

@@ -85,6 +85,19 @@ public:
{
m_version.clear();
// Mesa needs to be tested first, otherwise (if testing for card name
// further down) it would be detected as a non-mesa driver.
if (driver_version.find("Mesa") != std::string::npos)
{
std::vector<std::string> l = StringUtils::split(driver_version, ' ');
if (l.size() > 0)
{
convertVersionString(l.back());
return;
}
}
// Intel card: driver version = "3.1.0 - Build 9.17.10.3517"
// ---------------------------------------------------------
if (StringUtils::startsWith(card_name, "Intel"))

View File

@@ -21,11 +21,11 @@
#include "config/user_config.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/camera.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/2dutils.hpp"
#include "graphics/graphics_restrictions.hpp"
#include "graphics/hardware_skinning.hpp"
#include "graphics/lens_flare.hpp"
#include "graphics/light.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/particle_kind_manager.hpp"
@@ -158,7 +158,7 @@ IrrDriver::~IrrDriver()
*/
void IrrDriver::reset()
{
if (m_glsl) m_post_processing->reset();
if (CVS->isGLSL()) m_post_processing->reset();
} // reset
void IrrDriver::setPhase(STKRenderingPass p)
@@ -474,122 +474,8 @@ void IrrDriver::initDevice()
m_scene_manager = m_device->getSceneManager();
m_gui_env = m_device->getGUIEnvironment();
m_video_driver = m_device->getVideoDriver();
m_gl_major_version = 2;
m_gl_minor_version = 1;
// Call to glGetIntegerv should not be made if --no-graphics is used
if(!ProfileWorld::isNoGraphics())
{
}
if(!ProfileWorld::isNoGraphics())
{
glGetIntegerv(GL_MAJOR_VERSION, &m_gl_major_version);
glGetIntegerv(GL_MINOR_VERSION, &m_gl_minor_version);
Log::info("IrrDriver", "OpenGL version: %d.%d", m_gl_major_version, m_gl_minor_version);
Log::info("IrrDriver", "OpenGL vendor: %s", glGetString(GL_VENDOR));
Log::info("IrrDriver", "OpenGL renderer: %s", glGetString(GL_RENDERER));
Log::info("IrrDriver", "OpenGL version string: %s", glGetString(GL_VERSION));
m_need_ubo_workaround = false;
m_need_rh_workaround = false;
m_need_srgb_workaround = false;
m_support_sdsm = true;
m_support_texture_compression = true;
#ifdef WIN32
if (strstr((const char *)glGetString(GL_VENDOR), "Intel") != NULL)
{
// Intel on windows doesnt support srgb compressed textures properly
m_support_texture_compression = false;
// Fix for Intel Sandy Bridge on Windows which supports GL up to 3.1 only
if (m_gl_major_version == 3 && m_gl_minor_version == 1)
m_need_ubo_workaround = true;
}
#endif
// Fix for Nvidia and instanced RH
if (strstr((const char *)glGetString(GL_VENDOR), "NVIDIA") != NULL)
{
m_need_rh_workaround = true;
m_support_sdsm = false;
}
// Fix for AMD and bindless sRGB textures
if (strstr((const char *)glGetString(GL_VENDOR), "ATI") != NULL)
m_need_srgb_workaround = true;
}
#ifdef WIN32
m_glsl = (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version >= 1));
#else
m_glsl = (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version >= 1));
#endif
if (!ProfileWorld::isNoGraphics())
initGL();
m_sync = 0;
// Parse extensions
hasVSLayer = false;
hasBaseInstance = false;
hasBuffserStorage = false;
hasDrawIndirect = false;
hasComputeShaders = false;
hasTextureStorage = false;
hasTextureView = false;
hasBindlessTexture = false;
// Default false value for hasVSLayer if --no-graphics argument is used
#if !defined(__APPLE__)
if (!ProfileWorld::isNoGraphics())
{
if (hasGLExtension("GL_AMD_vertex_shader_layer")) {
hasVSLayer = true;
Log::info("GLDriver", "AMD Vertex Shader Layer enabled");
}
if (hasGLExtension("GL_ARB_buffer_storage")) {
hasBuffserStorage = true;
Log::info("GLDriver", "ARB Buffer Storage enabled");
}
if (hasGLExtension("GL_ARB_base_instance")) {
hasBaseInstance = true;
Log::info("GLDriver", "ARB Base Instance enabled");
}
if (hasGLExtension("GL_ARB_draw_indirect")) {
hasDrawIndirect = true;
Log::info("GLDriver", "ARB Draw Indirect enabled");
}
if (hasGLExtension("GL_ARB_compute_shader")) {
hasComputeShaders = true;
Log::info("GLDriver", "ARB Compute Shader enabled");
}
if (hasGLExtension("GL_ARB_texture_storage")) {
hasTextureStorage = true;
Log::info("GLDriver", "ARB Texture Storage enabled");
}
if (hasGLExtension("GL_ARB_texture_view")) {
hasTextureView = true;
Log::info("GLDriver", "ARB Texture View enabled");
}
if (hasGLExtension("GL_ARB_bindless_texture")) {
hasBindlessTexture = true;
Log::info("GLDriver", "ARB Bindless Texture enabled");
}
m_support_sdsm = m_support_sdsm && hasComputeShaders && hasBuffserStorage;
std::string driver((char*)(glGetString(GL_VERSION)));
std::string card((char*)(glGetString(GL_RENDERER)));
std::vector<std::string> restrictions =
GraphicsRestrictions::getRestrictions(driver, card);
for (const std::string &restriction : restrictions)
{
if (!restriction.compare("BufferStorage"))
{
hasBuffserStorage = false;
Log::info("Graphics restrictions", "Buffer Storage disabled");
}
}
}
#else
m_support_sdsm = false;
#endif
CVS->init();
// This remaps the window, so it has to be done before the clear to avoid flicker
@@ -603,20 +489,20 @@ void IrrDriver::initDevice()
file_manager->reInit();
if (m_glsl)
if (CVS->isGLSL())
{
Log::info("irr_driver", "GLSL supported.");
}
if (!supportGeometryShader())
/* if (!supportGeometryShader())
{
// these options require geometry shaders
UserConfigParams::m_shadows = 0;
UserConfigParams::m_gi = false;
}
}*/
// m_glsl might be reset in rtt if an error occurs.
if(m_glsl)
if (CVS->isGLSL())
{
m_shaders = new Shaders();
@@ -1154,7 +1040,7 @@ scene::IMeshSceneNode *IrrDriver::addMesh(scene::IMesh *mesh,
const std::string& debug_name,
scene::ISceneNode *parent)
{
if (!isGLSL())
if (!CVS->isGLSL())
return m_scene_manager->addMeshSceneNode(mesh, parent);
if (!parent)
@@ -1186,7 +1072,7 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size,
scene::ISceneNode* parent, bool alphaTesting)
{
scene::IBillboardSceneNode* node;
if (isGLSL())
if (CVS->isGLSL())
{
if (!parent)
parent = m_scene_manager->getRootSceneNode();
@@ -1342,7 +1228,7 @@ void IrrDriver::removeTexture(video::ITexture *t)
scene::IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *mesh,
const std::string& debug_name, scene::ISceneNode* parent)
{
if (!isGLSL())
if (!CVS->isGLSL())
{
return m_scene_manager->addAnimatedMeshSceneNode(mesh, parent, -1,
core::vector3df(0, 0, 0),
@@ -1777,7 +1663,7 @@ void IrrDriver::setRTT(RTT* rtt)
// ----------------------------------------------------------------------------
void IrrDriver::onLoadWorld()
{
if (m_glsl)
if (CVS->isGLSL())
{
const core::recti &viewport = Camera::getCamera(0)->getViewport();
size_t width = viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X, height = viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y;
@@ -2172,7 +2058,7 @@ void IrrDriver::update(float dt)
// video::SColor(0,0,0,255));
//m_scene_manager->drawAll();
if (m_glsl)
if (CVS->isGLSL())
renderGLSL(dt);
else
renderFixed(dt);
@@ -2192,7 +2078,7 @@ void IrrDriver::update(float dt)
return;
}
if (m_glsl)
if (CVS->isGLSL())
renderGLSL(dt);
else
renderFixed(dt);
@@ -2258,7 +2144,7 @@ bool IrrDriver::OnEvent(const irr::SEvent &event)
bool IrrDriver::supportsSplatting()
{
return m_glsl;
return CVS->isGLSL();
}
// ----------------------------------------------------------------------------
@@ -2401,7 +2287,7 @@ void IrrDriver::RTTProvider::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
m_camera = irr_driver->getSceneManager()->addCameraSceneNode();
m_camera->setPosition( core::vector3df(0.0, 20.0f, 70.0f) );
if (irr_driver->isGLSL())
if (CVS->isGLSL())
m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) );
else
m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) );
@@ -2478,7 +2364,7 @@ video::ITexture* IrrDriver::RTTProvider::renderToTexture(float angle,
void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimlit)
{
if (!m_glsl)
if (!CVS->isGLSL())
return;
// Don't override sky
@@ -2546,7 +2432,7 @@ void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimli
void IrrDriver::applyObjectPassShader()
{
if (!m_glsl)
if (!CVS->isGLSL())
return;
applyObjectPassShader(m_scene_manager->getRootSceneNode());
@@ -2557,7 +2443,7 @@ void IrrDriver::applyObjectPassShader()
scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy, float radius,
float r, float g, float b, bool sun, scene::ISceneNode* parent)
{
if (m_glsl)
if (CVS->isGLSL())
{
if (parent == NULL) parent = m_scene_manager->getRootSceneNode();
LightNode *light = NULL;

View File

@@ -183,20 +183,6 @@ enum TypeRTT
class IrrDriver : public IEventReceiver, public NoCopy
{
private:
int m_gl_major_version, m_gl_minor_version;
bool hasVSLayer;
bool hasBaseInstance;
bool hasDrawIndirect;
bool hasBuffserStorage;
bool hasComputeShaders;
bool hasTextureStorage;
bool hasTextureView;
bool hasBindlessTexture;
bool m_support_sdsm;
bool m_support_texture_compression;
bool m_need_ubo_workaround;
bool m_need_rh_workaround;
bool m_need_srgb_workaround;
GLsync m_sync;
/** The irrlicht device. */
IrrlichtDevice *m_device;
@@ -275,106 +261,6 @@ public:
float power;
};
unsigned getGLSLVersion() const
{
if (m_gl_major_version > 3 || (m_gl_major_version == 3 && m_gl_minor_version == 3))
return m_gl_major_version * 100 + m_gl_minor_version * 10;
else if (m_gl_major_version == 3)
return 100 + (m_gl_minor_version + 3) * 10;
else
return 120;
}
bool supportsSDSM() const
{
return m_support_sdsm && UserConfigParams::m_sdsm;
}
bool supportTextureCompression() const
{
return m_support_texture_compression;
}
bool supportGeometryShader() const
{
return getGLSLVersion() >= 330;
}
bool usesShadows() const
{
return supportGeometryShader() && UserConfigParams::m_shadows && !needUBOWorkaround();
}
bool usesGI() const
{
return supportGeometryShader() && UserConfigParams::m_gi && !needUBOWorkaround();
}
bool usesTextureCompression() const
{
return UserConfigParams::m_texture_compression && m_support_texture_compression;
}
bool useAZDO() const
{
return hasBindlessTexture && UserConfigParams::m_azdo;
}
bool needUBOWorkaround() const
{
return m_need_ubo_workaround;
}
bool needRHWorkaround() const
{
return m_need_rh_workaround;
}
bool needsRGBBindlessWorkaround() const
{
return m_need_srgb_workaround;
}
bool hasARB_base_instance() const
{
return hasBaseInstance;
}
bool hasARB_draw_indirect() const
{
return hasDrawIndirect;
}
bool hasVSLayerExtension() const
{
return hasVSLayer;
}
bool hasBufferStorageExtension() const
{
return hasBuffserStorage;
}
bool hasARBComputeShaders() const
{
return hasComputeShaders;
}
bool hasARBTextureStorage() const
{
return hasTextureStorage;
}
bool hasARBTextureView() const
{
return hasTextureView;
}
bool hasARBBindlessTexture() const
{
return hasBindlessTexture;
}
video::SColorf getAmbientLight() const;
struct GlowData {
@@ -390,9 +276,6 @@ private:
/** Whether the mouse cursor is currently shown */
bool m_pointer_shown;
/** Supports GLSL */
bool m_glsl;
/** Internal method that applies the resolution in user settings. */
void applyResolutionSettings();
void createListOfVideoModes();
@@ -686,12 +569,6 @@ public:
FrameBuffer& getFBO(TypeFBO which);
GLuint getDepthStencilTexture();
// ------------------------------------------------------------------------
inline bool isGLSL() const { return m_glsl; }
// ------------------------------------------------------------------------
/** Called when the driver pretends to support it, but fails at some
* operations. */
void disableGLSL() { m_glsl = false; }
// ------------------------------------------------------------------------
void resetDebugModes()
{
m_wireframe = false;

View File

@@ -1,264 +0,0 @@
/* TODO: copyright */
#include "graphics/lens_flare.hpp"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "ISceneCollisionManager.h"
namespace irr
{
namespace scene
{
CLensFlareSceneNode::CLensFlareSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id) :
scene::ISceneNode(parent, mgr, id)
{
#ifdef _DEBUG
setDebugName("CLensFlareSceneNode");
#endif
// set the bounding box
BBox.MaxEdge.set(0,0,0);
BBox.MinEdge.set(0,0,0);
// set the initial Strength
Strength = 1.0f;
// setup the vertices
Vertices[0] = video::S3DVertex(-1.f, -1.f, 0.f, 0.f, 0.f, 1.f, 0xffffffff, 0.f, 1.f);
Vertices[1] = video::S3DVertex(-1.f, 1.f, 0.f, 0.f, 0.f, 1.f, 0xffffffff, 0.f, 0.f);
Vertices[2] = video::S3DVertex( 1.f, 1.f, 0.f, 0.f, 0.f, 1.f, 0xffffffff, 1.f, 0.f);
Vertices[3] = video::S3DVertex( 1.f, -1.f, 0.f, 0.f, 0.f, 1.f, 0xffffffff, 1.f, 1.f);
// setup the indices
Indices[0] = 0;
Indices[1] = 1;
Indices[2] = 2;
Indices[3] = 2;
Indices[4] = 3;
Indices[5] = 0;
// set the default material properties
Material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
Material.Lighting = false;
Material.ZBuffer = video::ECFN_NEVER;
FlareData.reallocate(30);
// prepare the flare data array
// circles, halos and ring behind the sun
FlareData.push_back(SFlareData(EFT_CIRCLE, 0.5f, 0.12f, video::SColor(120, 60, 180, 35)));
FlareData.push_back(SFlareData(EFT_HALO, 0.45f, 0.4f, video::SColor(200, 100, 200, 60)));
FlareData.push_back(SFlareData(EFT_CIRCLE, 0.4f, 0.17f, video::SColor(240, 120, 220, 40)));
FlareData.push_back(SFlareData(EFT_CIRCLE, 0.2f, 0.35f, video::SColor(175, 175, 255, 20)));
FlareData.push_back(SFlareData(EFT_RING, 0.15f, 0.2f, video::SColor(120, 60, 255, 100)));
// sun and glow effect at sun position
FlareData.push_back(SFlareData(EFT_SUN, 0.0f, 0.75f, video::SColor(255, 255, 255, 255)));
// FlareData.push_back(SFlareData(EFT_STREAKS, 0.0f, 2.9f, video::SColor(255, 255, 255, 255)));
FlareData.push_back(SFlareData(EFT_GLOW, 0.0f, 3.5f, video::SColor(255, 255, 255, 255)));
// FlareData.push_back(SFlareData(EFT_RING, 0.0f, 1.5f, video::SColor(120, 120, 120, 150)));
// some lenses, halos and circles
FlareData.push_back(SFlareData(EFT_LENS, -0.15f, 0.15f, video::SColor(255, 60, 60, 90)));
FlareData.push_back(SFlareData(EFT_HALO, -0.3f, 0.3f, video::SColor(120, 60, 255, 180)));
FlareData.push_back(SFlareData(EFT_HALO, -0.4f, 0.2f, video::SColor(220, 80, 80, 98)));
FlareData.push_back(SFlareData(EFT_CIRCLE, -0.45f, 0.1f, video::SColor(220, 80, 80, 85)));
FlareData.push_back(SFlareData(EFT_RING, -0.42f, 0.3f, video::SColor(180, 60, 255, 110)));
// some small lenses, halos and rings
FlareData.push_back(SFlareData(EFT_LENS, -0.55f, 0.2f, video::SColor(255, 60, 60, 130)));
FlareData.push_back(SFlareData(EFT_HALO, -0.6f, 0.3f, video::SColor(120, 60, 255, 80)));
FlareData.push_back(SFlareData(EFT_LENS, -0.7f, 0.2f, video::SColor(200, 60, 60, 130)));
FlareData.push_back(SFlareData(EFT_LENS, -0.71f, 0.2f, video::SColor(200, 60, 130, 60)));
FlareData.push_back(SFlareData(EFT_LENS, -0.72f, 0.2f, video::SColor(200, 130, 130, 60)));
FlareData.push_back(SFlareData(EFT_LENS, -0.74f, 0.2f, video::SColor(200, 130, 60, 60)));
// some polyons, lenses and circle
FlareData.push_back(SFlareData(scene::EFT_POLY, -0.79f, 0.2f, video::SColor(200, 60, 130, 60)));
FlareData.push_back(SFlareData(scene::EFT_POLY, -0.86f, 0.3f, video::SColor(200, 130, 130, 60)));
FlareData.push_back(SFlareData(scene::EFT_LENS, -0.87f, 0.3f, video::SColor(180,255,192,178)));
FlareData.push_back(SFlareData(scene::EFT_CIRCLE, -0.9f, 0.1f, video::SColor(200, 60, 60, 130)));
FlareData.push_back(SFlareData(scene::EFT_POLY, -0.93f, 0.4f, video::SColor(200, 130, 60, 60)));
// finally som polygons
FlareData.push_back(SFlareData(EFT_POLY, -0.95f, 0.6f, video::SColor(120, 60, 255, 120)));
FlareData.push_back(SFlareData(EFT_POLY, -1.0f, 0.15f, video::SColor(120, 20, 255, 85)));
}
CLensFlareSceneNode::~CLensFlareSceneNode()
{
}
u32 CLensFlareSceneNode::getMaterialCount() const
{
// return the material count (always one in our case)
return 1;
}
video::SMaterial& CLensFlareSceneNode::getMaterial(u32 i)
{
// return the material
return Material;
}
core::array<SFlareData>& CLensFlareSceneNode::getFlareData()
{
// return the flare data array
return FlareData;
}
void CLensFlareSceneNode::OnRegisterSceneNode()
{
// if node is visible and Strength is greater than 0 register it for the ESNRP_TRANSPARENT_EFFECT pass
if(IsVisible && Strength > 0.0f)
{
SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT_EFFECT);
}
// call base OnRegisterSceneNode
ISceneNode::OnRegisterSceneNode();
}
void CLensFlareSceneNode::render()
{
// get the videodriver and the active camera
video::IVideoDriver* driver = SceneManager->getVideoDriver();
ICameraSceneNode* camera = SceneManager->getActiveCamera();
// return if we don't have a valid driver or a valid camera
// or if we have no texture attached to the material
if (!camera || !driver || !Material.getTexture(0))
return;
// get screencenter
const core::vector2d<s32> screenCenter = core::vector2d<s32>(
SceneManager->getVideoDriver()->getScreenSize().Width,
SceneManager->getVideoDriver()->getScreenSize().Height)/2;
// get screencoordinates of the node
const core::vector2d<s32> lightPos = SceneManager->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(
getAbsolutePosition(),
camera);
// store old projection matrix
core::matrix4 oldProjMat = driver->getTransform(video::ETS_PROJECTION);
// store old view matrix
core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW);
// clear the projection matrix
driver->setTransform(video::ETS_PROJECTION, core::IdentityMatrix);
// clear the view matrix
driver->setTransform(video::ETS_VIEW, core::IdentityMatrix);
// set the transform
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
// set the material
driver->setMaterial(Material);
// calculate some handy constants
const f32 texPos = 1.0f/EFT_COUNT;
const s32 texHeight = s32(Material.getTexture(0)->getSize().Height*0.5f);
const f32 screenWidth = f32(driver->getScreenSize().Width);
const f32 screenHeight = f32(driver->getScreenSize().Height);
// render the flares
for (u32 i=0; i<FlareData.size(); ++i)
{
// get the flare element
SFlareData& flare = FlareData[i];
// calculate center of the flare
core::vector2d<s32>flarePos = screenCenter.getInterpolated(lightPos, -2.0*flare.Position);
// calculate flareposition in vertex coordinates using the scalefactor of the flare
s32 flareScale = s32((texHeight*flare.Scale));
core::rect<f32> flareRect = core::rect<f32>(
-1.f + 2.f * f32(flarePos.X-flareScale) / screenWidth,
-1.f + 2.f * f32(screenHeight-flarePos.Y-flareScale) / screenHeight,
-1.f + 2.f * f32(flarePos.X+flareScale) / screenWidth,
-1.f + 2.f * f32(screenHeight-flarePos.Y+flareScale) / screenHeight);
// calculate flarecolor in dependence of occlusion
f32 flareAlpha = f32(flare.Color.getAlpha()) / 255.f;
video::SColor flareColor(255,
(u32)(Strength * flareAlpha * flare.Color.getRed()),
(u32)(Strength * flareAlpha * flare.Color.getGreen()),
(u32)(Strength * flareAlpha * flare.Color.getBlue()));
// set vertex colors
Vertices[0].Color = flareColor;
Vertices[1].Color = flareColor;
Vertices[2].Color = flareColor;
Vertices[3].Color = flareColor;
// set texture coordinates
Vertices[0].TCoords.set( flare.Type * texPos, 1.0f);
Vertices[1].TCoords.set( flare.Type * texPos, 0.0f);
Vertices[2].TCoords.set((flare.Type+1) * texPos, 0.0f);
Vertices[3].TCoords.set((flare.Type+1) * texPos, 1.0f);
// set vertex positions
Vertices[0].Pos.set(flareRect.UpperLeftCorner.X, flareRect.UpperLeftCorner.Y, 0);
Vertices[1].Pos.set(flareRect.UpperLeftCorner.X, flareRect.LowerRightCorner .Y, 0);
Vertices[2].Pos.set(flareRect.LowerRightCorner.X, flareRect.LowerRightCorner.Y, 0);
Vertices[3].Pos.set(flareRect.LowerRightCorner.X, flareRect.UpperLeftCorner.Y, 0);
//draw the mesh
driver->drawIndexedTriangleList(Vertices, 4, Indices, 2);
}
// restore view matrix
driver->setTransform(video::ETS_VIEW, oldViewMat);
// restore projection matrix
driver->setTransform(video::ETS_PROJECTION, oldProjMat);
}
const core::aabbox3df& CLensFlareSceneNode::getBoundingBox() const
{
// return the bounding box
return BBox;
}
ESCENE_NODE_TYPE CLensFlareSceneNode::getType() const
{
// return type of the scene node
// (important when using with a custom scene node factory)
return scene::ESNT_UNKNOWN; //(ESCENE_NODE_TYPE) ECSNT_LENSFLARE;
}
void CLensFlareSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
{
// write attributes of the scene node.
ISceneNode::serializeAttributes(out, options);
}
void CLensFlareSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
{
// read attributes of the scene node.
ISceneNode::deserializeAttributes(in, options);
}
ISceneNode* CLensFlareSceneNode::clone(ISceneNode* newParent, ISceneManager* newManager)
{
if (!newParent)
newParent = Parent;
if (!newManager)
newManager = SceneManager;
CLensFlareSceneNode* nb = new CLensFlareSceneNode(newParent, newManager, ID);
nb->cloneMembers(this, newManager);
nb->Material = Material;
nb->drop();
return nb;
}
}// end irr namespace
}// end scene namespace

View File

@@ -1,117 +0,0 @@
#ifndef _CLENSFLARESCENENODE_H
#define _CLENSFLARESCENENODE_H
#include <ISceneNode.h>
#include <S3DVertex.h>
namespace irr
{
namespace scene
{
// enum with different flare types (used by SFlareData)
enum E_FLARE_TYPE
{
EFT_SUN = 0,
EFT_GLOW,
EFT_LENS,
EFT_STREAKS,
EFT_RING,
EFT_HALO,
EFT_CIRCLE,
EFT_POLY,
EFT_COUNT
};
// struct holding the flare specification
struct SFlareData
{
public:
// constructor
SFlareData(const E_FLARE_TYPE type, const float position,
const float scale, const video::SColor &color)
{
Type = type;
Position = position;
Scale = scale;
Color = color;
}
// flare type
E_FLARE_TYPE Type;
// position
f32 Position;
// flare scale
f32 Scale;
// flare color
video::SColor Color;
};
class CLensFlareSceneNode : public ISceneNode
{
public:
// constructor
CLensFlareSceneNode(ISceneNode* parent, scene::ISceneManager* mgr, s32 id = -1);
// destructor
virtual ~CLensFlareSceneNode();
protected:
// material of the node
video::SMaterial Material;
// Bounding box
core::aabbox3d<f32> BBox;
// vertices and indices of a flare element
video::S3DVertex Vertices[4];
u16 Indices[6];
// flare data array
core::array<SFlareData> FlareData;
// Strength of the flare effect (between 0 and 1)
f32 Strength;
public:
// typical OnRegisterSceneNode function
virtual void OnRegisterSceneNode();
// renders the node
virtual void render();
// returns the bounding box
virtual const core::aabbox3d<f32>& getBoundingBox() const;
// returns the node type
virtual ESCENE_NODE_TYPE getType() const;
// returns the material count
virtual u32 getMaterialCount() const;
// returns the material
virtual video::SMaterial& getMaterial(u32 i);
// writes attributes of the scene node.
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options = 0) const;
// reads attributes of the scene node.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options = 0);
// clones the node
virtual ISceneNode* clone(ISceneNode* newParent = 0, ISceneManager* newManager = 0);
// returns the flare data array
core::array<SFlareData>& getFlareData();
// returns the strength (visibility) of the flares
f32 getStrength() { return Strength; }
// sets the strength (visibility) of the flares
void setStrength(f32 strength) { Strength = core::clamp(strength, 0.0f, 0.7f); }
};
} // end namespace scene
} // end namespace irr
#endif

View File

@@ -28,6 +28,7 @@
#include "config/stk_config.hpp"
#include "guiengine/engine.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/particle_kind_manager.hpp"
@@ -586,7 +587,7 @@ void Material::initParticlesEffect(const XMLNode *node)
ParticleKind* particles = NULL;
try
{
particles = pkm->getParticles(base.c_str());
particles = pkm->getParticles(base);
if (particles == NULL)
{
@@ -689,7 +690,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m_texname.c_str());
}
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
ITexture *tex;
ITexture *glossytex;
@@ -952,7 +953,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
bool use_fog) const
{
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
// to disable fog in the new pipeline, we slightly abuse the steps :
// moving an object into the transparent pass will make it rendered
@@ -982,7 +983,7 @@ void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
/** Callback from LOD nodes to create some effects */
void Material::onMadeVisible(scene::IMeshBuffer* who)
{
if (!irr_driver->isGLSL()) return;
if (!CVS->isGLSL()) return;
}
//-----------------------------------------------------------------------------
@@ -990,14 +991,14 @@ void Material::onMadeVisible(scene::IMeshBuffer* who)
/** Callback from LOD nodes to create some effects */
void Material::onHidden(scene::IMeshBuffer* who)
{
if (!irr_driver->isGLSL()) return;
if (!CVS->isGLSL()) return;
}
//-----------------------------------------------------------------------------
void Material::isInitiallyHidden(scene::IMeshBuffer* who)
{
if (!irr_driver->isGLSL()) return;
if (!CVS->isGLSL()) return;
}
//-----------------------------------------------------------------------------

View File

@@ -17,6 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/mesh_tools.hpp"
#include "graphics/central_settings.hpp"
#include <irrlicht.h>
#include <IMesh.h>
#include <IMeshBuffer.h>
@@ -325,7 +326,7 @@ void recalculateTangents(scene::IMesh* mesh, bool recalculateNormals, bool smoot
bool MeshTools::isNormalMap(scene::IMeshBuffer* mb)
{
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
return false;
return (mb->getMaterial().MaterialType == irr_driver->getShader(ES_NORMAL_MAP) &&
mb->getVertexType() != video::EVT_TANGENTS);

View File

@@ -17,7 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/particle_emitter.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/particle_kind.hpp"
@@ -298,7 +298,7 @@ ParticleEmitter::ParticleEmitter(const ParticleKind* type,
m_particle_type = NULL;
m_parent = parent;
m_emission_decay_rate = 0;
m_is_glsl = irr_driver->isGLSL();
m_is_glsl = CVS->isGLSL();
m_randomize_initial_y = randomize_initial_y;

View File

@@ -76,7 +76,6 @@ void ParticleKindManager::cleanUpTrackSpecificGfx()
ParticleKind* ParticleKindManager::getParticles(const std::string &name)
{
Track* t = track_manager->getTrack(race_manager->getTrackName());
std::map<std::string, ParticleKind*>::iterator i;
i = m_per_track_kinds.find(name);
if (i != m_per_track_kinds.end())
@@ -87,9 +86,13 @@ ParticleKind* ParticleKindManager::getParticles(const std::string &name)
{
try
{
ParticleKind* newkind = new ParticleKind(t->getTrackFile(name));
m_per_track_kinds[name] = newkind;
return newkind;
Track* t = track_manager->getTrack(race_manager->getTrackName());
if (t)
{
ParticleKind* newkind = new ParticleKind(t->getTrackFile(name));
m_per_track_kinds[name] = newkind;
return newkind;
}
}
catch (std::runtime_error& e)
{

View File

@@ -19,6 +19,7 @@
#include "config/user_config.hpp"
#include "graphics/callbacks.hpp"
#include "central_settings.hpp"
#include "graphics/camera.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
@@ -169,7 +170,7 @@ void PostProcessing::begin()
/** Set the boost amount according to the speed of the camera */
void PostProcessing::giveBoost(unsigned int camera_index)
{
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
m_boost_time[camera_index] = 0.75f;
@@ -185,7 +186,7 @@ void PostProcessing::giveBoost(unsigned int camera_index)
*/
void PostProcessing::update(float dt)
{
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
return;
MotionBlurProvider* const cb =
@@ -283,6 +284,27 @@ void PostProcessing::renderShadowedSunlight(const core::vector3df &direction, co
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShader>(shadowSplit[1], shadowSplit[2], shadowSplit[3], shadowSplit[4], direction, col);
}
static
std::vector<float> getGaussianWeight(float sigma, size_t count)
{
float g0, g1, g2, total;
std::vector<float> weights;
g0 = 1.f / (sqrtf(2.f * 3.14f) * sigma);
g1 = exp(-.5f / (sigma * sigma));
g2 = g1 * g1;
total = g0;
for (unsigned i = 0; i < count; i++)
{
weights.push_back(g0);
g0 *= g1;
g1 *= g2;
total += 2 * g0;
}
for (float &weight : weights)
weight /= total;
return weights;
}
void PostProcessing::renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxiliary)
{
@@ -307,7 +329,7 @@ void PostProcessing::renderGaussian6BlurLayer(FrameBuffer &in_fbo, size_t layer,
GLuint LayerTex;
glGenTextures(1, &LayerTex);
glTextureView(LayerTex, GL_TEXTURE_2D, in_fbo.getRTT()[0], GL_R32F, 0, 1, layer, 1);
if (!irr_driver->hasARBComputeShaders())
if (!CVS->supportsComputeShadersFiltering())
{
// Used as temp
irr_driver->getFBO(FBO_SCALAR_1024).Bind();
@@ -319,18 +341,7 @@ void PostProcessing::renderGaussian6BlurLayer(FrameBuffer &in_fbo, size_t layer,
}
else
{
float g0, g1, g2;
std::vector<float> weightsV;
g0 = 1.f / (sqrtf(2.f * 3.14f) * sigmaV);
g1 = exp(-.5f / (sigmaV * sigmaV));
g2 = g1 * g1;
for (unsigned i = 0; i < 7; i++)
{
weightsV.push_back(g0);
g0 *= g1;
g1 *= g2;
}
const std::vector<float> &weightsV = getGaussianWeight(sigmaV, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
glUseProgram(FullScreenShader::ComputeShadowBlurVShader::getInstance()->Program);
FullScreenShader::ComputeShadowBlurVShader::getInstance()->SetTextureUnits(LayerTex);
@@ -339,17 +350,7 @@ void PostProcessing::renderGaussian6BlurLayer(FrameBuffer &in_fbo, size_t layer,
FullScreenShader::ComputeShadowBlurVShader::getInstance()->setUniforms(core::vector2df(1.f / 1024.f, 1.f / 1024.f), weightsV);
glDispatchCompute((int)1024 / 8 + 1, (int)1024 / 8 + 1, 1);
std::vector<float> weightsH;
g0 = 1.f / (sqrtf(2.f * 3.14f) * sigmaH);
g1 = exp(-.5f / (sigmaH * sigmaH));
g2 = g1 * g1;
for (unsigned i = 0; i < 7; i++)
{
weightsH.push_back(g0);
g0 *= g1;
g1 *= g2;
}
const std::vector<float> &weightsH = getGaussianWeight(sigmaH, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
glUseProgram(FullScreenShader::ComputeShadowBlurHShader::getInstance()->Program);
FullScreenShader::ComputeShadowBlurHShader::getInstance()->SetTextureUnits(irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0]);
@@ -367,7 +368,7 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
assert(in_fbo.getWidth() == auxiliary.getWidth() && in_fbo.getHeight() == auxiliary.getHeight());
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
if (!irr_driver->hasARBComputeShaders())
if (!CVS->supportsComputeShadersFiltering())
{
auxiliary.Bind();
@@ -381,19 +382,7 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
}
else
{
float g0, g1, g2;
std::vector<float> weightsV;
g0 = 1.f / (sqrtf(2.f * 3.14f) * sigmaV);
g1 = exp(-.5f / (sigmaV * sigmaV));
g2 = g1 * g1;
for (unsigned i = 0; i < 7; i++)
{
weightsV.push_back(g0);
g0 *= g1;
g1 *= g2;
}
const std::vector<float> &weightsV = getGaussianWeight(sigmaV, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
glUseProgram(FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->Program);
FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0]);
@@ -402,17 +391,7 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
FullScreenShader::ComputeGaussian6VBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height), weightsV);
glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1);
std::vector<float> weightsH;
g0 = 1.f / (sqrtf(2.f * 3.14f) * sigmaH);
g1 = exp(-.5f / (sigmaH * sigmaH));
g2 = g1 * g1;
for (unsigned i = 0; i < 7; i++)
{
weightsH.push_back(g0);
g0 *= g1;
g1 *= g2;
}
const std::vector<float> &weightsH = getGaussianWeight(sigmaH, 7);
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
glUseProgram(FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->Program);
FullScreenShader::ComputeGaussian6HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
@@ -447,11 +426,11 @@ void PostProcessing::renderHorizontalBlur(FrameBuffer &in_fbo, FrameBuffer &auxi
void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &auxiliary)
{
assert(in_fbo.getWidth() == auxiliary.getWidth() && in_fbo.getHeight() == auxiliary.getHeight());
if (irr_driver->hasARBComputeShaders())
if (CVS->supportsComputeShadersFiltering())
glMemoryBarrier(GL_FRAMEBUFFER_BARRIER_BIT);
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
{
if (!irr_driver->hasARBComputeShaders())
if (!CVS->supportsComputeShadersFiltering())
{
auxiliary.Bind();
FullScreenShader::Gaussian17TapHShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0], irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0]);
@@ -467,10 +446,10 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1);
}
}
if (irr_driver->hasARBComputeShaders())
if (CVS->supportsComputeShadersFiltering())
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
{
if (!irr_driver->hasARBComputeShaders())
if (!CVS->supportsComputeShadersFiltering())
{
in_fbo.Bind();
@@ -487,7 +466,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glDispatchCompute((int)in_fbo.getWidth() / 8 + 1, (int)in_fbo.getHeight() / 8 + 1, 1);
}
}
if (irr_driver->hasARBComputeShaders())
if (CVS->supportsComputeShadersFiltering())
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
}
@@ -843,7 +822,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
}
// Workaround a bug with srgb fbo on sandy bridge windows
if (irr_driver->needUBOWorkaround())
if (!CVS->isARBUniformBufferObjectUsable())
return in_fbo;
glEnable(GL_FRAMEBUFFER_SRGB);

View File

@@ -17,7 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/referee.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/light.hpp"
#include "graphics/mesh_tools.hpp"
@@ -150,7 +150,7 @@ Referee::Referee()
irr_driver->applyObjectPassShader(m_scene_node);
if (irr_driver->isGLSL() && UserConfigParams::m_dynamic_lights)
if (CVS->isGLSL() && UserConfigParams::m_dynamic_lights)
{
m_light = irr_driver->addLight(core::vector3df(0.0f, 0.0f, 0.6f), 0.7f, 2.0f,
0.7f /* r */, 0.0 /* g */, 0.0f /* b */, false /* sun */, m_scene_node);

View File

@@ -20,8 +20,8 @@
#include "config/user_config.hpp"
#include "graphics/callbacks.hpp"
#include "central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/lens_flare.hpp"
#include "graphics/lod_node.hpp"
#include "graphics/post_processing.hpp"
#include "graphics/referee.hpp"
@@ -353,12 +353,12 @@ void IrrDriver::renderScene(scene::ICameraSceneNode * const camnode, unsigned po
// To avoid wrong culling, use the largest view possible
m_scene_manager->setActiveCamera(m_suncam);
if (UserConfigParams::m_dynamic_lights &&
UserConfigParams::m_shadows && irr_driver->usesShadows() && hasShadow)
UserConfigParams::m_shadows && CVS->isShadowEnabled() && hasShadow)
{
PROFILER_PUSH_CPU_MARKER("- Shadow", 0x30, 0x6F, 0x90);
renderShadows();
PROFILER_POP_CPU_MARKER();
if (irr_driver->usesGI())
if (CVS->isGlobalIlluminationEnabled())
{
PROFILER_PUSH_CPU_MARKER("- RSM", 0xFF, 0x0, 0xFF);
renderRSM();
@@ -783,7 +783,7 @@ void IrrDriver::UpdateSplitAndLightcoordRangeFromComputeShaders(size_t width, si
void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height)
{
if (irr_driver->supportsSDSM())
if (CVS->isSDSMEnabled())
UpdateSplitAndLightcoordRangeFromComputeShaders(width, height);
static_cast<scene::CSceneManager *>(m_scene_manager)->OnAnimate(os::Timer::getTime());
camnode->render();
@@ -841,7 +841,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
// Build the 3 ortho projection (for the 3 shadow resolution levels)
for (unsigned i = 0; i < 4; i++)
{
if (!irr_driver->supportsSDSM())
if (!CVS->isSDSMEnabled())
{
camnode->setFarValue(FarValues[i]);
camnode->setNearValue(NearValues[i]);
@@ -896,7 +896,7 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
core::matrix4 tmp_matrix;
if (irr_driver->supportsSDSM()){
if (CVS->isSDSMEnabled()){
float left = float(CBB[currentCBB][i].xmin / 4 - 2);
float right = float(CBB[currentCBB][i].xmax / 4 + 2);
float up = float(CBB[currentCBB][i].ymin / 4 - 2);
@@ -1032,7 +1032,7 @@ void IrrDriver::renderGlow(std::vector<GlowData>& glows)
glDepthMask(GL_FALSE);
glDisable(GL_BLEND);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(EVT_STANDARD));
for (u32 i = 0; i < glowcount; i++)
{
@@ -1041,17 +1041,17 @@ void IrrDriver::renderGlow(std::vector<GlowData>& glows)
STKMeshSceneNode *node = static_cast<STKMeshSceneNode *>(cur);
node->setGlowColors(SColor(0, (unsigned) (dat.b * 255.f), (unsigned)(dat.g * 255.f), (unsigned)(dat.r * 255.f)));
if (!irr_driver->hasARB_draw_indirect())
if (!CVS->supportsIndirectInstancingRendering())
node->render();
}
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
{
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, GlowPassCmd::getInstance()->drawindirectcmd);
glUseProgram(MeshShader::InstancedColorizeShader::getInstance()->Program);
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(video::EVT_STANDARD, InstanceTypeGlow));
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
if (GlowPassCmd::getInstance()->Size)
{

View File

@@ -1,5 +1,5 @@
#include "graphics/irr_driver.hpp"
#include "central_settings.hpp"
#include "config/user_config.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/glwrap.hpp"
@@ -410,14 +410,14 @@ void renderMeshes1stPass()
{
auto &meshes = T::List::getInstance()->SolidPass;
glUseProgram(T::FirstPassShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType));
for (unsigned i = 0; i < meshes.size(); i++)
{
std::vector<GLuint> Textures;
std::vector<uint64_t> Handles;
GLMesh &mesh = *(STK::tuple_get<0>(meshes.at(i)));
if (!irr_driver->hasARB_base_instance())
if (!CVS->isARBBaseInstanceUsable())
glBindVertexArray(mesh.vao);
if (mesh.VAOType != T::VertexType)
{
@@ -427,7 +427,7 @@ void renderMeshes1stPass()
continue;
}
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
HandleExpander<typename T::FirstPassShader>::template Expand(mesh.TextureHandles, T::FirstPassTextures);
else
TexExpander<typename T::FirstPassShader>::template ExpandTex(mesh, T::FirstPassTextures);
@@ -481,7 +481,7 @@ void IrrDriver::renderSolidFirstPass()
{
windDir = getWindDir();
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, SolidPassCmd::getInstance()->drawindirectcmd);
{
@@ -500,7 +500,7 @@ void IrrDriver::renderSolidFirstPass()
renderMeshes1stPass<SphereMap, 2, 1>();
renderMeshes1stPass<DetailMat, 2, 1>();
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
multidraw1stPass<DefaultMaterial>();
multidraw1stPass<AlphaRef>();
@@ -511,7 +511,7 @@ void IrrDriver::renderSolidFirstPass()
multidraw1stPass<NormalMat>();
multidraw1stPass<DetailMat>();
}
else if (irr_driver->hasARB_draw_indirect())
else if (CVS->supportsIndirectInstancingRendering())
{
renderInstancedMeshes1stPass<DefaultMaterial>();
renderInstancedMeshes1stPass<AlphaRef>();
@@ -530,12 +530,12 @@ void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
{
auto &meshes = T::List::getInstance()->SolidPass;
glUseProgram(T::SecondPassShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType));
for (unsigned i = 0; i < meshes.size(); i++)
{
GLMesh &mesh = *(STK::tuple_get<0>(meshes.at(i)));
if (!irr_driver->hasARB_base_instance())
if (!CVS->isARBBaseInstanceUsable())
glBindVertexArray(mesh.vao);
if (mesh.VAOType != T::VertexType)
@@ -546,7 +546,7 @@ void renderMeshes2ndPass( const std::vector<uint64_t> &Prefilled_Handle,
continue;
}
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
HandleExpander<typename T::SecondPassShader>::template Expand(mesh.TextureHandles, T::SecondPassTextures, Prefilled_Handle[0], Prefilled_Handle[1], Prefilled_Handle[2]);
else
TexExpander<typename T::SecondPassShader>::template ExpandTex(mesh, T::SecondPassTextures, Prefilled_Tex[0], Prefilled_Tex[1], Prefilled_Tex[2]);
@@ -595,7 +595,7 @@ void IrrDriver::renderSolidSecondPass()
uint64_t DiffuseHandle = 0, SpecularHandle = 0, SSAOHandle = 0, DepthHandle = 0;
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
DiffuseHandle = glGetTextureSamplerHandleARB(m_rtts->getRenderTarget(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle))
@@ -633,7 +633,7 @@ void IrrDriver::renderSolidSecondPass()
renderMeshes2ndPass<GrassMat, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
renderMeshes2ndPass<NormalMat, 3, 1>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle), DiffSpecSSAOTex);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
multidraw2ndPass<DefaultMaterial>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
multidraw2ndPass<AlphaRef>(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0));
@@ -658,7 +658,7 @@ void IrrDriver::renderSolidSecondPass()
}
}
}
else if (irr_driver->hasARB_draw_indirect())
else if (CVS->supportsIndirectInstancingRendering())
{
renderInstancedMeshes2ndPass<DefaultMaterial>(DiffSpecSSAOTex);
renderInstancedMeshes2ndPass<AlphaRef>(DiffSpecSSAOTex);
@@ -714,7 +714,7 @@ static void renderMultiMeshNormals()
void IrrDriver::renderNormalsVisualisation()
{
if (irr_driver->useAZDO()) {
if (CVS->isAZDOEnabled()) {
renderMultiMeshNormals<DefaultMaterial>();
renderMultiMeshNormals<AlphaRef>();
renderMultiMeshNormals<UnlitMat>();
@@ -722,7 +722,7 @@ void IrrDriver::renderNormalsVisualisation()
renderMultiMeshNormals<DetailMat>();
renderMultiMeshNormals<NormalMat>();
}
else if (irr_driver->hasARB_draw_indirect())
else if (CVS->supportsIndirectInstancingRendering())
{
renderInstancedMeshNormals<DefaultMaterial>();
renderInstancedMeshNormals<AlphaRef>();
@@ -737,12 +737,12 @@ template<typename Shader, enum video::E_VERTEX_TYPE VertexType, int...List, type
void renderTransparenPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > *meshes)
{
glUseProgram(Shader::getInstance()->Program);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(VertexType));
for (unsigned i = 0; i < meshes->size(); i++)
{
GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i)));
if (!irr_driver->hasARB_base_instance())
if (!CVS->isARBBaseInstanceUsable())
glBindVertexArray(mesh.vao);
if (mesh.VAOType != VertexType)
{
@@ -752,7 +752,7 @@ void renderTransparenPass(const std::vector<TexUnit> &TexUnits, std::vector<STK:
continue;
}
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]);
else
Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0]));
@@ -775,7 +775,7 @@ void IrrDriver::renderTransparent()
for (unsigned i = 0; i < ImmediateDrawList::getInstance()->size(); i++)
ImmediateDrawList::getInstance()->at(i)->render();
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(video::EVT_STANDARD));
if (World::getWorld() && World::getWorld()->isFogEnabled())
@@ -820,7 +820,7 @@ void IrrDriver::renderTransparent()
glStencilFunc(GL_ALWAYS, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(video::EVT_2TCOORDS));
// Generate displace mask
// Use RTT_TMP4 as displace mask
@@ -828,7 +828,7 @@ void IrrDriver::renderTransparent()
for (unsigned i = 0; i < ListDisplacement::getInstance()->size(); i++)
{
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::getInstance()->at(i)));
if (!irr_driver->hasARB_base_instance())
if (!CVS->isARBBaseInstanceUsable())
glBindVertexArray(mesh.vao);
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::getInstance()->at(i));
if (mesh.VAOType != video::EVT_2TCOORDS)
@@ -855,7 +855,7 @@ void IrrDriver::renderTransparent()
for (unsigned i = 0; i < ListDisplacement::getInstance()->size(); i++)
{
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::getInstance()->at(i)));
if (!irr_driver->hasARB_base_instance())
if (!CVS->isARBBaseInstanceUsable())
glBindVertexArray(mesh.vao);
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::getInstance()->at(i));
if (mesh.VAOType != video::EVT_2TCOORDS)
@@ -925,14 +925,14 @@ void renderShadow(unsigned cascade)
{
auto &t = T::List::getInstance()->Shadows[cascade];
glUseProgram(T::ShadowPassShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType));
for (unsigned i = 0; i < t.size(); i++)
{
GLMesh *mesh = STK::tuple_get<0>(t.at(i));
if (!irr_driver->hasARB_base_instance())
if (!CVS->isARBBaseInstanceUsable())
glBindVertexArray(mesh->vao);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
HandleExpander<typename T::ShadowPassShader>::template Expand(mesh->TextureHandles, T::ShadowTextures);
else
TexExpander<typename T::ShadowPassShader>::template ExpandTex(*mesh, T::ShadowTextures);
@@ -1001,10 +1001,10 @@ void IrrDriver::renderShadows()
renderShadow<UnlitMat, 1>(cascade);
renderShadow<GrassMat, 3, 1>(cascade);
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, ShadowPassCmd::getInstance()->drawindirectcmd);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
multidrawShadow<DefaultMaterial>(cascade);
multidrawShadow<DetailMat>(cascade);
@@ -1013,7 +1013,7 @@ void IrrDriver::renderShadows()
multidrawShadow<UnlitMat>(cascade);
multidrawShadow<GrassMat>(cascade, windDir);
}
else if (irr_driver->hasARB_draw_indirect())
else if (CVS->supportsIndirectInstancingRendering())
{
renderInstancedShadow<DefaultMaterial>(cascade);
renderInstancedShadow<DetailMat>(cascade);
@@ -1029,7 +1029,7 @@ void IrrDriver::renderShadows()
{
ScopedGPUTimer Timer(getGPUTimer(Q_SHADOW_POSTPROCESS));
if (irr_driver->hasARBTextureView())
if (CVS->isARBTextureViewUsable())
{
for (unsigned i = 0; i < 2; i++)
{
@@ -1072,16 +1072,16 @@ template<typename T, int... Selector>
void drawRSM(const core::matrix4 & rsm_matrix)
{
glUseProgram(T::RSMShader::getInstance()->Program);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(T::VertexType));
auto t = T::List::getInstance()->RSM;
for (unsigned i = 0; i < t.size(); i++)
{
std::vector<GLuint> Textures;
GLMesh *mesh = STK::tuple_get<0>(t.at(i));
if (!irr_driver->hasARB_base_instance())
if (!CVS->isARBBaseInstanceUsable())
glBindVertexArray(mesh->vao);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
HandleExpander<typename T::RSMShader>::template Expand(mesh->TextureHandles, T::RSMTextures);
else
TexExpander<typename T::RSMShader>::template ExpandTex(*mesh, T::RSMTextures);
@@ -1135,10 +1135,10 @@ void IrrDriver::renderRSM()
drawRSM<DetailMat, 3, 1>(rsm_matrix);
drawRSM<SplattingMat, 1>(rsm_matrix);
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, RSMPassCmd::getInstance()->drawindirectcmd);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
multidrawRSM<DefaultMaterial>(rsm_matrix);
multidrawRSM<NormalMat>(rsm_matrix);
@@ -1146,7 +1146,7 @@ void IrrDriver::renderRSM()
multidrawRSM<UnlitMat>(rsm_matrix);
multidrawRSM<DetailMat>(rsm_matrix);
}
else if (irr_driver->hasARB_draw_indirect())
else if (CVS->supportsIndirectInstancingRendering())
{
renderRSMShadow<DefaultMaterial>(rsm_matrix);
renderRSMShadow<AlphaRef>(rsm_matrix);

View File

@@ -1,5 +1,5 @@
#include "graphics/irr_driver.hpp"
#include "central_settings.hpp"
#include "config/user_config.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/light.hpp"
@@ -115,7 +115,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
glDisable(GL_BLEND);
m_rtts->getRH().Bind();
glBindVertexArray(SharedObject::FullScreenQuadVAO);
if (irr_driver->needRHWorkaround())
if (CVS->needRHWorkaround())
{
glUseProgram(FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->Program);
FullScreenShader::NVWorkaroundRadianceHintsConstructionShader::getInstance()->SetTextureUnits(
@@ -145,7 +145,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
glClear(GL_COLOR_BUFFER_BIT);
m_rtts->getFBO(FBO_DIFFUSE).Bind();
if (irr_driver->usesGI() && hasShadow)
if (CVS->isGlobalIlluminationEnabled() && hasShadow)
{
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_GI));
m_post_processing->renderGI(rh_matrix, rh_extend, m_rtts->getRH().getRTT()[0], m_rtts->getRH().getRTT()[1], m_rtts->getRH().getRTT()[2]);
@@ -162,7 +162,7 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow)
if (!World::getWorld() || World::getWorld()->getTrack()->hasShadows())
{
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_SUN));
if (World::getWorld() && irr_driver->usesShadows() && hasShadow)
if (World::getWorld() && CVS->isShadowEnabled() && hasShadow)
m_post_processing->renderShadowedSunlight(irr_driver->getSunDirection(), irr_driver->getSunColor(), sun_ortho_matrix, m_rtts->getShadowFBO().getRTT()[0]);
else
m_post_processing->renderSunlight(irr_driver->getSunDirection(), irr_driver->getSunColor());

View File

@@ -1,3 +1,4 @@
#include "central_settings.hpp"
#include "graphics/IBL.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/shaders.hpp"
@@ -263,7 +264,7 @@ GLuint generateCubeMapFromTextures(const std::vector<video::ITexture *> &texture
}
glBindTexture(GL_TEXTURE_CUBE_MAP, result);
if (irr_driver->usesTextureCompression())
if (CVS->isTextureCompressionEnabled())
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_COMPRESSED_SRGB_ALPHA, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);
else
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_SRGB_ALPHA, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)rgba[i]);

View File

@@ -16,7 +16,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/rtts.hpp"
#include "central_settings.hpp"
#include "config/user_config.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
@@ -29,7 +29,7 @@ static GLuint generateRTT3D(GLenum target, size_t w, size_t h, size_t d, GLint i
GLuint result;
glGenTextures(1, &result);
glBindTexture(target, result);
if (irr_driver->hasARBTextureStorage())
if (CVS->isARBTextureStorageUsable())
glTexStorage3D(target, mipmaplevel, internalFormat, w, h, d);
else
glTexImage3D(target, 0, internalFormat, w, h, d, 0, format, type, 0);
@@ -41,7 +41,7 @@ static GLuint generateRTT(const core::dimension2du &res, GLint internalFormat, G
GLuint result;
glGenTextures(1, &result);
glBindTexture(GL_TEXTURE_2D, result);
if (irr_driver->hasARBTextureStorage())
if (CVS->isARBTextureStorageUsable())
glTexStorage2D(GL_TEXTURE_2D, mipmaplevel, internalFormat, res.Width, res.Height);
else
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, res.Width, res.Height, 0, format, type, 0);
@@ -243,7 +243,7 @@ RTT::RTT(size_t width, size_t height)
somevector.push_back(RenderTargetTextures[RTT_LENS_128]);
FrameBuffers.push_back(new FrameBuffer(somevector, 128, 128));
if (UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround())
if (CVS->isShadowEnabled())
{
shadowColorTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_R32F, GL_RED, GL_FLOAT, 10);
shadowDepthTex = generateRTT3D(GL_TEXTURE_2D_ARRAY, 1024, 1024, 4, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 1);
@@ -253,7 +253,7 @@ RTT::RTT(size_t width, size_t height)
m_shadow_FBO = new FrameBuffer(somevector, shadowDepthTex, 1024, 1024, true);
}
if (UserConfigParams::m_gi)
if (CVS->isGlobalIlluminationEnabled())
{
//Todo : use "normal" shadowtex
RSM_Color = generateRTT(shadowsize0, GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE);
@@ -291,13 +291,13 @@ RTT::~RTT()
{
glDeleteTextures(RTT_COUNT, RenderTargetTextures);
glDeleteTextures(1, &DepthStencilTexture);
if (UserConfigParams::m_shadows && !irr_driver->needUBOWorkaround())
if (CVS->isShadowEnabled())
{
delete m_shadow_FBO;
glDeleteTextures(1, &shadowColorTex);
glDeleteTextures(1, &shadowDepthTex);
}
if (UserConfigParams::m_gi)
if (CVS->isGlobalIlluminationEnabled())
{
delete m_RH_FBO;
delete m_RSM;

View File

@@ -92,6 +92,7 @@
#define SHADER_NAMES
#include "graphics/callbacks.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/gpuparticles.hpp"
#include "graphics/shaders.hpp"
@@ -145,22 +146,22 @@ GLuint LoadShader(const char * file, unsigned type)
{
GLuint Id = glCreateShader(type);
char versionString[20];
sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion());
sprintf(versionString, "#version %d\n", CVS->getGLSLVersion());
std::string Code = versionString;
if (irr_driver->useAZDO())
Code += "#extension GL_ARB_bindless_texture : enable\n";
else if (irr_driver->hasARBBindlessTexture())
if (CVS->isAMDVertexShaderLayerUsable())
Code += "#extension GL_AMD_vertex_shader_layer : enable\n";
if (CVS->isAZDOEnabled())
{
Code += "#extension GL_ARB_bindless_texture : disable\n";
Code += "#undef GL_ARB_bindless_texture\n";
Code += "#extension GL_ARB_bindless_texture : enable\n";
Code += "#define Use_Bindless_Texture\n";
}
std::ifstream Stream(file, std::ios::in);
Code += "//" + std::string(file) + "\n";
if (irr_driver->needUBOWorkaround())
if (!CVS->isARBUniformBufferObjectUsable())
Code += "#define UBO_DISABLED\n";
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
Code += "#define VSLayer\n";
if (irr_driver->needsRGBBindlessWorkaround())
if (CVS->needsRGBBindlessWorkaround())
Code += "#define SRGBBindlessFix\n";
Code += LoadHeader();
if (Stream.is_open())
@@ -237,7 +238,7 @@ GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsi
{
GLuint Program = glCreateProgram();
loadAndAttach(Program, GL_VERTEX_SHADER, vertex_file_path);
if (irr_driver->getGLSLVersion() < 330)
if (CVS->getGLSLVersion() < 330)
setAttribute(PARTICLES_SIM, Program);
glTransformFeedbackVaryings(Program, varyingscount, varyings, GL_INTERLEAVED_ATTRIBS);
glLinkProgram(Program);
@@ -695,7 +696,7 @@ using namespace UtilShader;
bool needsUBO()
{
return irr_driver->needUBOWorkaround();
return !CVS->isARBUniformBufferObjectUsable();
}
void setTextureSampler(GLenum tp, GLuint texunit, GLuint tid, GLuint sid)
@@ -895,7 +896,7 @@ void BindTextureVolume(GLuint TU, GLuint tex)
unsigned getGLSLVersion()
{
return irr_driver->getGLSLVersion();
return CVS->getGLSLVersion();
}
namespace UtilShader
@@ -1195,9 +1196,9 @@ namespace MeshShader
ShadowShader::ShadowShader()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
if (CVS->getGLSLVersion() < 150)
return;
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/shadow.vert").c_str(),
@@ -1247,9 +1248,9 @@ namespace MeshShader
InstancedShadowShader::InstancedShadowShader()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
if (CVS->getGLSLVersion() < 150)
return;
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/utils/getworldmatrix.vert").c_str(),
@@ -1270,9 +1271,9 @@ namespace MeshShader
RefShadowShader::RefShadowShader()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
if (CVS->getGLSLVersion() < 150)
return;
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/shadow.vert").c_str(),
@@ -1292,9 +1293,9 @@ namespace MeshShader
InstancedRefShadowShader::InstancedRefShadowShader()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
if (CVS->getGLSLVersion() < 150)
return;
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/utils/getworldmatrix.vert").c_str(),
@@ -1316,9 +1317,9 @@ namespace MeshShader
GrassShadowShader::GrassShadowShader()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
if (CVS->getGLSLVersion() < 150)
return;
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/shadow_grass.vert").c_str(),
@@ -1338,9 +1339,9 @@ namespace MeshShader
InstancedGrassShadowShader::InstancedGrassShadowShader()
{
// Geometry shader needed
if (irr_driver->getGLSLVersion() < 150)
if (CVS->getGLSLVersion() < 150)
return;
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/utils/getworldmatrix.vert").c_str(),
@@ -1638,6 +1639,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/SpecularBRDF.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/DiffuseBRDF.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/SunMRP.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlight.frag").c_str());
AssignSamplerNames(Program, 0, "ntex", 1, "dtex");
@@ -1665,6 +1667,7 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/SpecularBRDF.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/DiffuseBRDF.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/SunMRP.frag").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/sunlightshadow.frag").c_str());
// Use 8 to circumvent a catalyst bug when binding sampler
@@ -1674,7 +1677,7 @@ namespace FullScreenShader
RadianceHintsConstructionShader::RadianceHintsConstructionShader()
{
if (irr_driver->hasVSLayerExtension())
if (CVS->isAMDVertexShaderLayerUsable())
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/slicedscreenquad.vert").c_str(),

View File

@@ -17,7 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/slip_stream.hpp"
#include "graphics/central_settings.hpp"
#include "config/user_config.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
@@ -235,7 +235,7 @@ void SlipStream::createMesh(Material* material)
} // for j<num_circles-1
material->setMaterialProperties(&buffer->getMaterial(), buffer);
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
{
buffer->Material.setFlag(video::EMF_BACK_FACE_CULLING, false);
buffer->Material.setFlag(video::EMF_COLOR_MATERIAL, true);

View File

@@ -1,3 +1,4 @@
#include "central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/stkanimatedmesh.hpp"
#include <ISceneManager.h>
@@ -155,7 +156,7 @@ void STKAnimatedMesh::updateGL()
else
InitTexturesTransparent(mesh);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
{
std::pair<unsigned, unsigned> p = VAOManager::getInstance()->getBase(mb);
mesh.vaoBaseVertex = p.first;
@@ -180,7 +181,7 @@ void STKAnimatedMesh::updateGL()
size_t size = mb->getVertexCount() * GLmeshes[i].Stride, offset = GLmeshes[i].vaoBaseVertex * GLmeshes[i].Stride;
void *buf;
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
buf = VAOManager::getInstance()->getVBOPtr(mb->getVertexType());
buf = (char *)buf + offset;
@@ -188,7 +189,7 @@ void STKAnimatedMesh::updateGL()
else
{
glBindVertexArray(0);
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindBuffer(GL_ARRAY_BUFFER, VAOManager::getInstance()->getVBO(mb->getVertexType()));
else
glBindBuffer(GL_ARRAY_BUFFER, GLmeshes[i].vertex_buffer);
@@ -196,7 +197,7 @@ void STKAnimatedMesh::updateGL()
buf = glMapBufferRange(GL_ARRAY_BUFFER, offset, size, bitfield);
}
memcpy(buf, mb->getVertices(), size);
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);

View File

@@ -1,3 +1,4 @@
#include "central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/stkmesh.hpp"
@@ -286,7 +287,7 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb, const std::string &matname)
return;
}
compressTexture(mesh.textures[i], isSrgb);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[i])
mesh.TextureHandles[i] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[i]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);
@@ -359,7 +360,7 @@ void InitTexturesTransparent(GLMesh &mesh)
return;
}
compressTexture(mesh.textures[0], true);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);

View File

@@ -1,3 +1,4 @@
#include "central_settings.hpp"
#include "stkmeshscenenode.hpp"
#include "stkmesh.hpp"
#include "graphics/irr_driver.hpp"
@@ -197,7 +198,7 @@ void STKMeshSceneNode::updateGL()
else if (!immediate_draw)
InitTexturesTransparent(mesh);
if (!immediate_draw && irr_driver->hasARB_base_instance())
if (!immediate_draw && CVS->isARBBaseInstanceUsable())
{
std::pair<unsigned, unsigned> p = VAOManager::getInstance()->getBase(mb);
mesh.vaoBaseVertex = p.first;
@@ -269,7 +270,7 @@ void STKMeshSceneNode::render()
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]);
@@ -307,7 +308,7 @@ void STKMeshSceneNode::render()
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
GLuint64 DiffuseHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle))
@@ -356,7 +357,7 @@ void STKMeshSceneNode::render()
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
if (!mb)
continue;
if (irr_driver->hasARB_base_instance())
if (CVS->isARBBaseInstanceUsable())
glBindVertexArray(VAOManager::getInstance()->getVAO(video::EVT_STANDARD));
else
glBindVertexArray(GLmeshes[i].vao);
@@ -403,7 +404,7 @@ void STKMeshSceneNode::render()
tmpcol.getBlue() / 255.0f);
compressTexture(mesh.textures[0], true);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
@@ -433,7 +434,7 @@ void STKMeshSceneNode::render()
size_t count = mesh.IndexCount;
compressTexture(mesh.textures[0], true);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
{
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::TransparentShader::getInstance()->SamplersId[0]);

View File

@@ -2,6 +2,7 @@
#include "graphics/stkscenemanager.hpp"
#include "graphics/stkmesh.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/central_settings.hpp"
#include "stkanimatedmesh.hpp"
#include "stkmeshscenenode.hpp"
#include "utils/ptr_vector.hpp"
@@ -143,7 +144,7 @@ void FillInstances(const std::unordered_map<scene::IMeshBuffer *, std::vector<st
for (; It != E; ++It)
{
FillInstances_impl<T>(It->second, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, Polycount);
if (!irr_driver->useAZDO())
if (!CVS->isAZDOEnabled())
InstancedList.push_back(It->second.front().first);
}
}
@@ -292,7 +293,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
{
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
{
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
{
for_in(mesh, node->MeshSolidMaterial[Mat])
{
@@ -369,7 +370,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
continue;
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
{
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
{
for_in(mesh, node->MeshSolidMaterial[Mat])
{
@@ -426,7 +427,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
{
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
{
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
{
if (Mat == Material::SHADERTYPE_SPLATTING)
for_in(mesh, node->MeshSolidMaterial[Mat])
@@ -524,10 +525,10 @@ template<Material::ShaderType Mat, typename T> static void
GenDrawCalls(unsigned cascade, std::vector<GLMesh *> &InstancedList,
T *InstanceBuffer, DrawElementsIndirectCommand *CommandBuffer, size_t &InstanceBufferOffset, size_t &CommandBufferOffset, size_t &PolyCount)
{
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
ShadowPassCmd::getInstance()->Offset[cascade][Mat] = CommandBufferOffset; // Store command buffer offset
FillInstances<T>(MeshForShadowPass[Mat][cascade], InstancedList, InstanceBuffer, CommandBuffer, InstanceBufferOffset, CommandBufferOffset, PolyCount);
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
ShadowPassCmd::getInstance()->Size[cascade][Mat] = CommandBufferOffset - ShadowPassCmd::getInstance()->Offset[cascade][Mat];
}
@@ -613,7 +614,7 @@ PROFILER_POP_CPU_MARKER();
DeferredUpdate[i]->updateGL();
PROFILER_POP_CPU_MARKER();
if (!irr_driver->hasARB_draw_indirect())
if (!CVS->supportsIndirectInstancingRendering())
return;
InstanceDataDualTex *InstanceBufferDualTex;
@@ -626,7 +627,7 @@ PROFILER_POP_CPU_MARKER();
DrawElementsIndirectCommand *RSMCmdBuffer;
DrawElementsIndirectCommand *GlowCmdBuffer;
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
InstanceBufferDualTex = (InstanceDataDualTex*)VAOManager::getInstance()->getInstanceBufferPtr(InstanceTypeDualTex);
InstanceBufferThreeTex = (InstanceDataThreeTex*)VAOManager::getInstance()->getInstanceBufferPtr(InstanceTypeThreeTex);
@@ -659,7 +660,7 @@ PROFILER_POP_CPU_MARKER();
#pragma omp section
{
size_t offset = 0, current_cmd = 0;
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glBindBuffer(GL_ARRAY_BUFFER, VAOManager::getInstance()->getInstanceBuffer(InstanceTypeDualTex));
InstanceBufferDualTex = (InstanceDataDualTex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, 10000 * sizeof(InstanceDataDualTex), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
@@ -689,7 +690,7 @@ PROFILER_POP_CPU_MARKER();
FillInstances(MeshForSolidPass[Material::SHADERTYPE_VEGETATION], ListInstancedMatGrass::getInstance()->SolidPass, InstanceBufferDualTex, CmdBuffer, offset, current_cmd, SolidPoly);
SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_VEGETATION] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_VEGETATION];
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, VAOManager::getInstance()->getInstanceBuffer(InstanceTypeThreeTex));
@@ -707,7 +708,7 @@ PROFILER_POP_CPU_MARKER();
SolidPassCmd::getInstance()->Size[Material::SHADERTYPE_NORMAL_MAP] = current_cmd - SolidPassCmd::getInstance()->Offset[Material::SHADERTYPE_NORMAL_MAP];
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glUnmapBuffer(GL_ARRAY_BUFFER);
glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
@@ -717,7 +718,7 @@ PROFILER_POP_CPU_MARKER();
{
size_t offset = 0, current_cmd = 0;
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glBindBuffer(GL_ARRAY_BUFFER, VAOManager::getInstance()->getInstanceBuffer(InstanceTypeGlow));
GlowInstanceBuffer = (GlowInstanceData*)glMapBufferRange(GL_ARRAY_BUFFER, 0, 10000 * sizeof(InstanceDataDualTex), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
@@ -726,7 +727,7 @@ PROFILER_POP_CPU_MARKER();
}
// Glow
if (irr_driver->hasARB_draw_indirect())
if (CVS->supportsIndirectInstancingRendering())
GlowPassCmd::getInstance()->Offset = offset; // Store command buffer offset
auto It = MeshForGlowPass.begin(), E = MeshForGlowPass.end();
@@ -734,14 +735,14 @@ PROFILER_POP_CPU_MARKER();
{
size_t Polycnt = 0;
FillInstances_impl<GlowInstanceData>(It->second, GlowInstanceBuffer, GlowCmdBuffer, offset, current_cmd, Polycnt);
if (!irr_driver->useAZDO())
if (!CVS->isAZDOEnabled())
ListInstancedGlow::getInstance()->push_back(It->second.front().first);
}
if (irr_driver->useAZDO())
if (CVS->isAZDOEnabled())
GlowPassCmd::getInstance()->Size = current_cmd - GlowPassCmd::getInstance()->Offset;
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glUnmapBuffer(GL_ARRAY_BUFFER);
glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
@@ -752,7 +753,7 @@ PROFILER_POP_CPU_MARKER();
irr_driver->setPhase(SHADOW_PASS);
size_t offset = 0, current_cmd = 0;
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glBindBuffer(GL_ARRAY_BUFFER, VAOManager::getInstance()->getInstanceBuffer(InstanceTypeShadow));
ShadowInstanceBuffer = (InstanceDataSingleTex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, 10000 * sizeof(InstanceDataDualTex), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
@@ -777,7 +778,7 @@ PROFILER_POP_CPU_MARKER();
// Mat Grass
GenDrawCalls<Material::SHADERTYPE_VEGETATION>(i, ListInstancedMatGrass::getInstance()->Shadows[i], ShadowInstanceBuffer, ShadowCmdBuffer, offset, current_cmd, ShadowPoly);
}
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glUnmapBuffer(GL_ARRAY_BUFFER);
glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
@@ -787,7 +788,7 @@ PROFILER_POP_CPU_MARKER();
if (!m_rsm_map_available)
{
size_t offset = 0, current_cmd = 0;
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glBindBuffer(GL_ARRAY_BUFFER, VAOManager::getInstance()->getInstanceBuffer(InstanceTypeRSM));
RSMInstanceBuffer = (InstanceDataSingleTex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, 10000 * sizeof(InstanceDataDualTex), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
@@ -816,7 +817,7 @@ PROFILER_POP_CPU_MARKER();
FillInstances(MeshForRSM[Material::SHADERTYPE_NORMAL_MAP], ListInstancedMatNormalMap::getInstance()->RSM, RSMInstanceBuffer, RSMCmdBuffer, offset, current_cmd, MiscPoly);
RSMPassCmd::getInstance()->Size[Material::SHADERTYPE_NORMAL_MAP] = current_cmd - RSMPassCmd::getInstance()->Offset[Material::SHADERTYPE_NORMAL_MAP];
if (!irr_driver->hasBufferStorageExtension())
if (!CVS->isARBBufferStorageUsable())
{
glUnmapBuffer(GL_ARRAY_BUFFER);
glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
@@ -827,6 +828,6 @@ PROFILER_POP_CPU_MARKER();
poly_count[SOLID_NORMAL_AND_DEPTH_PASS] += SolidPoly;
poly_count[SHADOW_PASS] += ShadowPoly;
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT);
}

View File

@@ -5,6 +5,7 @@
#define HEADER_STKSCENEMANAGER_HPP
#include "utils/singleton.hpp"
#include "central_settings.hpp"
#include "gl_headers.hpp"
#include "stkmesh.hpp"
#include "gpuparticles.hpp"
@@ -20,7 +21,7 @@ public:
{
glGenBuffers(1, &drawindirectcmd);
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, drawindirectcmd);
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
glBufferStorage(GL_DRAW_INDIRECT_BUFFER, 10000 * sizeof(DrawElementsIndirectCommand), 0, GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT);
Ptr = (DrawElementsIndirectCommand *)glMapBufferRange(GL_DRAW_INDIRECT_BUFFER, 0, 10000 * sizeof(DrawElementsIndirectCommand), GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT);

View File

@@ -1,3 +1,4 @@
#include "central_settings.hpp"
#include "texturemanager.hpp"
#include <fstream>
#include <sstream>
@@ -34,7 +35,7 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha)
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
std::string cached_file;
if (irr_driver->usesTextureCompression())
if (CVS->isTextureCompressionEnabled())
{
// Try to retrieve the compressed texture in cache
std::string tex_name = irr_driver->getTextureName(tex);
@@ -70,7 +71,7 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha)
}
}
if (!irr_driver->usesTextureCompression())
if (!CVS->isTextureCompressionEnabled())
{
if (srgb)
internalFormat = (tex->hasAlpha()) ? GL_SRGB_ALPHA : GL_SRGB;
@@ -88,7 +89,7 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha)
glGenerateMipmap(GL_TEXTURE_2D);
delete[] data;
if (irr_driver->usesTextureCompression() && !cached_file.empty())
if (CVS->isTextureCompressionEnabled() && !cached_file.empty())
{
// Save the compressed texture in the cache for later use.
saveCompressedTexture(cached_file);

View File

@@ -2,6 +2,7 @@
#include "irr_driver.hpp"
#include "stkmesh.hpp"
#include "glwrap.hpp"
#include "central_settings.hpp"
VAOManager::VAOManager()
{
@@ -17,7 +18,7 @@ VAOManager::VAOManager()
{
glGenBuffers(1, &instance_vbo[i]);
glBindBuffer(GL_ARRAY_BUFFER, instance_vbo[i]);
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
glBufferStorage(GL_ARRAY_BUFFER, 10000 * sizeof(InstanceDataDualTex), 0, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
Ptr[i] = glMapBufferRange(GL_ARRAY_BUFFER, 0, 10000 * sizeof(InstanceDataDualTex), GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
@@ -67,7 +68,7 @@ void VAOManager::regenerateBuffer(enum VTXTYPE tp, size_t newlastvertex, size_t
GLuint newVBO;
glGenBuffers(1, &newVBO);
glBindBuffer(GL_ARRAY_BUFFER, newVBO);
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
glBufferStorage(GL_ARRAY_BUFFER, RealVBOSize[tp] * getVertexPitch(tp), 0, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
VBOPtr[tp] = glMapBufferRange(GL_ARRAY_BUFFER, 0, RealVBOSize[tp] * getVertexPitch(tp), GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
@@ -94,7 +95,7 @@ void VAOManager::regenerateBuffer(enum VTXTYPE tp, size_t newlastvertex, size_t
GLuint newIBO;
glGenBuffers(1, &newIBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, newIBO);
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, RealIBOSize[tp] * sizeof(u16), 0, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
IBOPtr[tp] = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, RealIBOSize[tp] * sizeof(u16), GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT);
@@ -287,7 +288,7 @@ void VAOManager::append(scene::IMeshBuffer *mb, VTXTYPE tp)
size_t old_idx_cnt = last_index[tp];
regenerateBuffer(tp, old_vtx_cnt + mb->getVertexCount(), old_idx_cnt + mb->getIndexCount());
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
void *tmp = (char*)VBOPtr[tp] + old_vtx_cnt * getVertexPitch(tp);
memcpy(tmp, mb->getVertices(), mb->getVertexCount() * getVertexPitch(tp));
@@ -297,7 +298,7 @@ void VAOManager::append(scene::IMeshBuffer *mb, VTXTYPE tp)
glBindBuffer(GL_ARRAY_BUFFER, vbo[tp]);
glBufferSubData(GL_ARRAY_BUFFER, old_vtx_cnt * getVertexPitch(tp), mb->getVertexCount() * getVertexPitch(tp), mb->getVertices());
}
if (irr_driver->hasBufferStorageExtension())
if (CVS->isARBBufferStorageUsable())
{
void *tmp = (char*)IBOPtr[tp] + old_idx_cnt * sizeof(u16);
memcpy(tmp, mb->getIndices(), mb->getIndexCount() * sizeof(u16));

View File

@@ -134,6 +134,7 @@ void Widget::elementRemoved()
assert(m_magic_number == 0xCAFEC001);
m_element = NULL;
m_is_visible = true;
// If any player focused this widget, unset that focus
for (unsigned int n=0; n<MAX_PLAYER_COUNT; n++)

View File

@@ -82,15 +82,15 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
}
m_skills[SKILL_MASS]->setValue((int)(props->getMass()/5));
m_skills[SKILL_MASS]->setLabel("WEIGHT");
m_skills[SKILL_MASS]->setLabel(_("WEIGHT"));
m_skills[SKILL_MASS]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_mass", m_player_id);
m_skills[SKILL_SPEED]->setValue((int)((props->getAbsMaxSpeed()-20)*9));
m_skills[SKILL_SPEED]->setLabel("SPEED");
m_skills[SKILL_SPEED]->setLabel(_("SPEED"));
m_skills[SKILL_SPEED]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_speed", m_player_id);
m_skills[SKILL_POWER]->setValue((int)(props->getAvgPower()));
m_skills[SKILL_POWER]->setLabel("POWER");
m_skills[SKILL_POWER]->setLabel(_("POWER"));
m_skills[SKILL_POWER]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_power", m_player_id);
move(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,

View File

@@ -16,6 +16,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "config/user_config.hpp"
#include "graphics/central_settings.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/model_view_widget.hpp"
#include "graphics/irr_driver.hpp"
@@ -155,7 +156,7 @@ void ModelViewWidget::update(float delta)
if (fabsf(angle - m_rotation_target) < 2.0f) m_rotation_mode = ROTATE_OFF;
}
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
return;
if (m_rtt_provider == NULL)

View File

@@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "karts/kart.hpp"
#include "graphics/central_settings.hpp"
#include "audio/music_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "audio/sfx_base.hpp"
@@ -2163,7 +2163,7 @@ void Kart::updateEngineSFX()
if(isOnGround())
{
float max_speed = m_max_speed->getCurrentMaxSpeed();
assert(max_speed>0);
// Engine noise is based half in total speed, half in fake gears:
// With a sawtooth graph like /|/|/| we get 3 even spaced gears,
// ignoring the gear settings from stk_config, but providing a
@@ -2705,7 +2705,7 @@ void Kart::setOnScreenText(const wchar_t *text)
// is started without splash screen (since "Loading" is shown even in this
// case). A smaller font would be better
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
gui::ScalableFont* font = GUIEngine::getFont() ? GUIEngine::getFont() : GUIEngine::getTitleFont();
new STKTextBillboard(text, font,

View File

@@ -23,6 +23,7 @@
#include "config/stk_config.hpp"
#include "config/user_config.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/lod_node.hpp"
#include "graphics/mesh_tools.hpp"
@@ -343,7 +344,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
node = irr_driver->addAnimatedMesh(m_mesh, "kartmesh");
// as animated mesh are not cheap to render use frustum box culling
if (irr_driver->isGLSL())
if (CVS->isGLSL())
node->setAutomaticCulling(scene::EAC_OFF);
else
node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);

View File

@@ -51,6 +51,8 @@ MaxSpeed::MaxSpeed(AbstractKart *kart)
// Initialise m_add_engine_force since it might be queried before
// update() is called.
m_add_engine_force = 0;
// This can be used if command line option -N is used
m_current_max_speed = 0;
} // MaxSpeed
// ----------------------------------------------------------------------------

View File

@@ -730,41 +730,26 @@ int handleCmdLine()
if(CommandLine::has("--kart", &s))
{
const PlayerProfile *player = PlayerManager::getCurrentPlayer();
if(player && !player->isLocked(s))
const KartProperties *prop = kart_properties_manager->getKart(s);
if (prop)
{
const KartProperties *prop =
kart_properties_manager->getKart(s);
if(prop)
{
UserConfigParams::m_default_kart = s;
UserConfigParams::m_default_kart = s;
// if a player was added with -N, change its kart.
// Otherwise, nothing to do, kart choice will be picked
// up upon player creation.
if (StateManager::get()->activePlayerCount() > 0)
{
race_manager->setLocalKartInfo(0, s);
}
Log::verbose("main", "You chose to use kart '%s'.",
s.c_str() ) ;
}
else
// if a player was added with -N, change its kart.
// Otherwise, nothing to do, kart choice will be picked
// up upon player creation.
if (StateManager::get()->activePlayerCount() > 0)
{
Log::warn("main", "Kart '%s' not found, ignored.",
s.c_str());
race_manager->setLocalKartInfo(0, s);
}
Log::verbose("main", "You chose to use kart '%s'.",
s.c_str());
}
else // kart locked
else
{
if (player)
Log::warn("main", "Kart '%s' has not been unlocked yet.",
s.c_str());
else
Log::warn("main",
"A default player must exist in order to use --kart.");
} // if kart locked
Log::warn("main", "Kart '%s' not found, ignored.",
s.c_str());
}
} // if --kart
if(CommandLine::has("--ai", &s))
@@ -802,49 +787,35 @@ int handleCmdLine()
if(CommandLine::has("--track", &s) || CommandLine::has("-t", &s))
{
const PlayerProfile *player = PlayerManager::getCurrentPlayer();
if (player && !player->isLocked(s))
{
race_manager->setTrack(s);
Log::verbose("main", "You choose to start in track '%s'.",
s.c_str());
race_manager->setTrack(s);
Log::verbose("main", "You choose to start in track '%s'.",
s.c_str());
Track* t = track_manager->getTrack(s);
if (!t)
{
Log::warn("main", "Can't find track named '%s'.", s.c_str());
}
else if (t->isArena())
{
//if it's arena, don't create ai karts
const std::vector<std::string> l;
race_manager->setDefaultAIKartList(l);
// Add 1 for the player kart
race_manager->setNumKarts(1);
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
}
else if(t->isSoccer())
{
//if it's soccer, don't create ai karts
const std::vector<std::string> l;
race_manager->setDefaultAIKartList(l);
// Add 1 for the player kart
race_manager->setNumKarts(1);
race_manager->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
}
}
else
Track* t = track_manager->getTrack(s);
if (!t)
{
if (player)
Log::warn("main", "Track '%s' has not been unlocked yet.",
s.c_str());
else
Log::warn("main",
"A default player must exist in order to use --track.");
Log::warn("main", "Can't find track named '%s'.", s.c_str());
}
else if (t->isArena())
{
//if it's arena, don't create ai karts
const std::vector<std::string> l;
race_manager->setDefaultAIKartList(l);
// Add 1 for the player kart
race_manager->setNumKarts(1);
race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES);
}
else if (t->isSoccer())
{
//if it's soccer, don't create ai karts
const std::vector<std::string> l;
race_manager->setDefaultAIKartList(l);
// Add 1 for the player kart
race_manager->setNumKarts(1);
race_manager->setMinorMode(RaceManager::MINOR_MODE_SOCCER);
}
} // --track
if(CommandLine::has("--gp", &s))
{
race_manager->setMajorMode(RaceManager::MAJOR_MODE_GRAND_PRIX);
@@ -1160,8 +1131,8 @@ void askForInternetPermission()
"anonymous hardware statistics to help with the development of STK. "
"Would you like this feature to be enabled? (To change this setting "
"at a later time, go to options, select tab "
"'User Interface', and edit \"Allow STK to connect to the "
"Internet\" and \"Allow STK to send anonymous HW statistics\")."),
"'User Interface', and edit \"Connect to the "
"Internet\" and \"Send anonymous HW statistics\")."),
MessageDialog::MESSAGE_DIALOG_YESNO,
new ConfirmServer(), true);
}

View File

@@ -22,6 +22,7 @@
#include "guiengine/widgets/spinner_widget.hpp"
#include "states_screens/options_screen_video.hpp"
#include "utils/translation.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include <IGUIEnvironment.h>
@@ -84,7 +85,7 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
shadows->addLabel(_("Disabled")); // 0
shadows->addLabel(_("low")); // 1
shadows->addLabel(_("high")); // 2
if (!irr_driver->needUBOWorkaround())
if (CVS->supportsShadows())
shadows->setValue(UserConfigParams::m_shadows);
else
shadows->setValue(0);
@@ -96,7 +97,7 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
getWidget<CheckBoxWidget>("glow")->setState(UserConfigParams::m_glow);
getWidget<CheckBoxWidget>("ssao")->setState(UserConfigParams::m_ssao);
getWidget<CheckBoxWidget>("bloom")->setState(UserConfigParams::m_bloom);
if (irr_driver->supportTextureCompression())
if (CVS->isEXTTextureCompressionS3TCUsable())
{
getWidget<CheckBoxWidget>("texture_compression")->setState(UserConfigParams::m_texture_compression);
}
@@ -107,7 +108,7 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
cb_tex_cmp->setDeactivated();
}
if (!irr_driver->supportGeometryShader())
if (!CVS->supportsGlobalIllumination())
{
shadows->setDeactivated();
getWidget<CheckBoxWidget>("global_illumination")->setDeactivated();
@@ -129,7 +130,7 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
UserConfigParams::m_motionblur =
advanced_pipeline && getWidget<CheckBoxWidget>("motionblur")->getState();
if (advanced_pipeline && irr_driver->supportGeometryShader())
if (advanced_pipeline && CVS->supportsShadows())
{
UserConfigParams::m_shadows =
getWidget<SpinnerWidget>("shadows")->getValue();
@@ -149,7 +150,7 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
advanced_pipeline && getWidget<CheckBoxWidget>("lightshaft")->getState();
UserConfigParams::m_gi =
advanced_pipeline && irr_driver->supportGeometryShader() &&
advanced_pipeline && CVS->supportsGlobalIllumination() &&
getWidget<CheckBoxWidget>("global_illumination")->getState();
UserConfigParams::m_glow =
@@ -244,7 +245,7 @@ void CustomVideoSettingsDialog::updateActivation()
getWidget<CheckBoxWidget>("bloom")->setDeactivated();
}
if (!irr_driver->supportGeometryShader())
if (!CVS->supportsShadows() && !CVS->supportsGlobalIllumination())
{
getWidget<SpinnerWidget>("shadows")->setDeactivated();
getWidget<CheckBoxWidget>("global_illumination")->setDeactivated();

View File

@@ -53,7 +53,7 @@ void UserInfoDialog::load()
m_name_widget->setText(m_online_profile->getUserName(),false);
m_info_widget->setText(m_info, false);
if(m_remove_widget->isVisible() && !m_online_profile->isFriend())
m_remove_widget->setLabel("Cancel Request");
m_remove_widget->setLabel(_("Cancel Request"));
} // load
// ----------------------------------------------------------------------------

View File

@@ -488,7 +488,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
new MessageDialog(_("You can not play online without internet access. "
"If you want to play online, go to options, select "
" tab 'User Interface', and edit "
"\"Allow STK to connect to the Internet\"."));
"\"Connect to the Internet\"."));
return;
}
if (PlayerManager::getCurrentOnlineId())
@@ -513,7 +513,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
new MessageDialog(_("You can not download addons without internet access. "
"If you want to download addons, go to options, select "
" tab 'User Interface', and edit "
"\"Allow STK to connect to the Internet\"."));
"\"Connect to the Internet\"."));
return;
}
AddonsScreen::getInstance()->push();

View File

@@ -22,7 +22,7 @@
#include <IMesh.h>
#include <ICameraSceneNode.h>
#include "graphics/central_settings.hpp"
#include "config/user_config.hpp"
#include "graphics/callbacks.hpp"
#include "graphics/irr_driver.hpp"
@@ -55,6 +55,7 @@ QuadGraph::QuadGraph(const std::string &quad_file_name,
m_mesh = NULL;
m_mesh_buffer = NULL;
m_lap_length = 0;
m_new_rtt = NULL;
QuadSet::create();
QuadSet::get()->init(quad_file_name);
m_quad_filename = quad_file_name;
@@ -72,6 +73,8 @@ QuadGraph::~QuadGraph()
}
if(UserConfigParams::m_track_debug)
cleanupDebugMesh();
if (m_new_rtt != NULL)
delete m_new_rtt;
} // ~QuadGraph
// -----------------------------------------------------------------------------
@@ -989,9 +992,9 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension,
RTT* newRttProvider = NULL;
IrrDriver::RTTProvider* oldRttProvider = NULL;
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
newRttProvider = new RTT(dimension.Width, dimension.Height);
m_new_rtt = newRttProvider = new RTT(dimension.Width, dimension.Height);
}
else
{
@@ -1076,12 +1079,9 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension,
video::ITexture* texture = NULL;
FrameBuffer* frame_buffer = NULL;
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
frame_buffer = newRttProvider->render(camera, GUIEngine::getLatestDt());
// TODO: leak
//delete newRttProvider;
}
else
{

View File

@@ -37,6 +37,7 @@ namespace irr
using namespace irr;
class CheckLine;
class RTT;
class FrameBuffer;
/**
@@ -55,6 +56,8 @@ class QuadGraph : public NoCopy
private:
static QuadGraph *m_quad_graph;
RTT* m_new_rtt;
/** The actual graph data structure. */
std::vector<GraphNode*> m_all_nodes;
/** For debug mode only: the node of the debug mesh. */

View File

@@ -28,6 +28,7 @@
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/CBatchingMesh.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/lod_node.hpp"
@@ -352,8 +353,7 @@ void Track::cleanup()
}
if (m_new_rtt_mini_map)
{
delete m_new_rtt_mini_map;
m_new_rtt_mini_map = NULL;
m_new_rtt_mini_map = NULL; // already deleted by QuadGraph::~QuadGraph
}
for(unsigned int i=0; i<m_sky_textures.size(); i++)
@@ -1130,7 +1130,7 @@ bool Track::loadMainTrack(const XMLNode &root)
assert(GUIEngine::getHighresDigitFont() != NULL);
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
STKTextBillboard* tb = new STKTextBillboard(msg.c_str(), font,
@@ -1766,7 +1766,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
// It's important to execute this BEFORE the code that creates the skycube,
// otherwise the skycube node could be modified to have fog enabled, which
// we don't want
if (m_use_fog && !UserConfigParams::m_camera_debug && !irr_driver->isGLSL())
if (m_use_fog && !UserConfigParams::m_camera_debug && !CVS->isGLSL())
{
/* NOTE: if LINEAR type, density does not matter, if EXP or EXP2, start
and end do not matter */
@@ -1840,7 +1840,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
const video::SColorf tmpf(m_sun_diffuse_color);
m_sun = irr_driver->addLight(m_sun_position, 0., 0., tmpf.r, tmpf.g, tmpf.b, true);
if (!irr_driver->isGLSL())
if (!CVS->isGLSL())
{
scene::ILightSceneNode *sun = (scene::ILightSceneNode *) m_sun;

View File

@@ -17,7 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "tracks/track_object_presentation.hpp"
#include "graphics/central_settings.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_buffer.hpp"
#include "challenges/unlock_manager.hpp"
@@ -777,7 +777,7 @@ TrackObjectPresentationLight::TrackObjectPresentationLight(const XMLNode& xml_no
m_distance = 20.f * m_energy;
xml_node.get("distance", &m_distance);
if (irr_driver->isGLSL())
if (CVS->isGLSL())
{
m_node = irr_driver->addLight(m_init_xyz, m_energy, m_distance, colorf.r, colorf.g, colorf.b, false, parent);
}