Merge branch 'improve-xbox-gamepad-support' of github.com:supertuxkart/stk-code into improve-xbox-gamepad-support

This commit is contained in:
hiker 2017-08-09 20:32:13 +10:00
commit 86d5e11c13
358 changed files with 119 additions and 43727 deletions

View File

@ -48,9 +48,8 @@ Android NDK r12b.
You need to create proper "android-sdk" and "android-ndk" symlinks in the
directory with Android project, so that the compilation script will have access
to the SDK and NDK.
These paths can be also set in SDK_PATH and NDK_PATH environmental variables.
to the SDK and NDK. These paths can be also set in SDK_PATH and NDK_PATH
environmental variables.
Before running the compilation, run the generate_assets script, so that
selected assets will be copied to "assets" directory, and then included in the
@ -78,9 +77,10 @@ you have to manually sign the apk with your key and run zipalign.
Additionally you can choose the build tool by setting BUILD_TOOL environment
variable to "gradle" or "ant". Note that ant has been already removed from
Android SDK, so you have to use SDK <= 25.2.5 for building with ant. By default
the BUILD_TOOL is set to "gradle". It has hardcoded version of SDK build-tools
that are set to "25.0.3", so you have to use this particular version (or you can
edit build.gradle file).
the BUILD_TOOL is set to "gradle".
You can override the SDK build-tools version by setting the BUILD_TOOLS_VER
environment variable.
Basically if all dependencies are installed in the system, it should be enough
to just run:

View File

@ -15,8 +15,8 @@ apply plugin: 'com.android.application'
android
{
compileSdkVersion sdkVersion.toInteger()
buildToolsVersion "25.0.3"
compileSdkVersion sdk_version.toInteger()
buildToolsVersion build_tools_ver
sourceSets
{

View File

@ -155,6 +155,24 @@ if [ ! -d "$SDK_PATH" ]; then
exit
fi
# Find newest build-tools version
if [ -z "$BUILD_TOOLS_VER" ]; then
BUILD_TOOLS_DIRS=`ls -1 "$SDK_PATH/build-tools" | sort -V -r`
for DIR in $BUILD_TOOLS_DIRS; do
if [ "$DIR" = `echo $DIR | sed 's/[^0-9,.]//g'` ]; then
BUILD_TOOLS_VER="$DIR"
break
fi
done
fi
if [ -z "$BUILD_TOOLS_VER" ] || [ ! -d "$SDK_PATH/build-tools/$BUILD_TOOLS_VER" ]; then
echo "Error: Couldn't detect build-tools version."
exit
fi
# Standalone toolchain
if [ ! -f "$DIRNAME/obj/make_standalone_toolchain.stamp" ]; then
echo "Creating standalone toolchain"
@ -326,9 +344,13 @@ echo "Building APK"
if [ "$BUILD_TOOL" = "gradle" ]; then
export ANDROID_HOME="$SDK_PATH"
gradle -PsdkVersion=$SDK_VERSION $GRADLE_BUILD_TYPE
gradle -Psdk_version=$SDK_VERSION \
-Pbuild_tools_ver="$BUILD_TOOLS_VER" \
$GRADLE_BUILD_TYPE
elif [ "$BUILD_TOOL" = "ant" ]; then
ant $ANT_BUILD_TYPE -Dsdk.dir="$SDK_PATH" -Dtarget=$NDK_PLATFORM
ant -Dsdk.dir="$SDK_PATH" \
-Dtarget=$NDK_PLATFORM \
$ANT_BUILD_TYPE
fi
check_error

View File

@ -10,6 +10,7 @@ uniform sampler2D SSAO;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue)
{
#if defined(Advanced_Lighting_Enabled)
vec2 tc = gl_FragCoord.xy / screen;
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
@ -17,4 +18,11 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa
vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue;
vec3 emitCol = diffuseMatColor.xyz * diffuseMatColor.xyz * diffuseMatColor.xyz * 15.;
return tmp * ao + (emitMapValue * emitCol);
#else
#if defined(GL_ES)
return diffuseMatColor * 0.73; // 0.5 ^ (1. / 2.2)
#else
return diffuseMatColor * 0.5;
#endif
#endif
}

View File

@ -1,10 +0,0 @@
; part of the Irrlicht Engine Shader example.
; This simple Direct3D9 pixel shader will be loaded by the engine.
; Please note that these example shaders don't do anything really useful.
; They only demonstrate that shaders can be used in Irrlicht.
ps.1.1
tex t0 ; sample color map
mul_x2 t0, t0, v0 ; mulitply with color
add r0, t0, t0 ; make it brighter and store result

View File

@ -1,37 +0,0 @@
; part of the Irrlicht Engine Shader example.
; This Direct3D9 vertex shader will be loaded by the engine.
; Please note that these example shaders don't do anything really useful.
; They only demonstrate that shaders can be used in Irrlicht.
vs.1.1
; transpose and transform position to clip space
mul r0, v0.x, c4
mad r0, v0.y, c5, r0
mad r0, v0.z, c6, r0
add oPos, c7, r0
; transform normal
dp3 r1.x, v1, c0
dp3 r1.y, v1, c1
dp3 r1.z, v1, c2
; renormalize normal
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
; calculate light vector
m4x4 r6, v0, c10 ; vertex into world position
add r2, c8, -r6 ; vtxpos - lightpos
; normalize light vector
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
; calculate light color
dp3 r3, r1, r2 ; dp3 with negative light vector
lit r5, r3 ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y
mul oD0, r5.y, c9 ; ouput diffuse color
mov oT0, v3 ; store texture coordinates

View File

@ -1,84 +0,0 @@
// part of the Irrlicht Engine Shader example.
// These simple Direct3D9 pixel and vertex shaders will be loaded by the shaders
// example. Please note that these example shaders don't do anything really useful.
// They only demonstrate that shaders can be used in Irrlicht.
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
float4x4 mWorldViewProj; // World * View * Projection transformation
float4x4 mInvWorld; // Inverted world matrix
float4x4 mTransWorld; // Transposed world matrix
float3 mLightPos; // Light position
float4 mLightColor; // Light color
// Vertex shader output structure
struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float4 Diffuse : COLOR0; // vertex diffuse color
float2 TexCoord : TEXCOORD0; // tex coords
};
VS_OUTPUT vertexMain(in float4 vPosition : POSITION,
in float3 vNormal : NORMAL,
float2 texCoord : TEXCOORD0 )
{
VS_OUTPUT Output;
// transform position to clip space
Output.Position = mul(vPosition, mWorldViewProj);
// transform normal
float3 normal = mul(float4(vNormal,0.0), mInvWorld);
// renormalize normal
normal = normalize(normal);
// position in world coodinates
float3 worldpos = mul(mTransWorld, vPosition);
// calculate light vector, vtxpos - lightpos
float3 lightVector = worldpos - mLightPos;
// normalize light vector
lightVector = normalize(lightVector);
// calculate light color
float3 tmp = dot(-lightVector, normal);
tmp = lit(tmp.x, tmp.y, 1.0);
tmp = mLightColor * tmp.y;
Output.Diffuse = float4(tmp.x, tmp.y, tmp.z, 0);
Output.TexCoord = texCoord;
return Output;
}
// Pixel shader output structure
struct PS_OUTPUT
{
float4 RGBColor : COLOR0; // Pixel color
};
sampler2D myTexture;
PS_OUTPUT pixelMain(float2 TexCoord : TEXCOORD0,
float4 Position : POSITION,
float4 Diffuse : COLOR0 )
{
PS_OUTPUT Output;
float4 col = tex2D( myTexture, TexCoord ); // sample color map
// multiply with diffuse and do other senseless operations
Output.RGBColor = Diffuse * col;
Output.RGBColor *= 4.0;
return Output;
}

View File

@ -1,11 +0,0 @@
; part of the Irrlicht Engine Shader example.
; This simple Direct3D9 pixel shader will be loaded by the engine.
; Please note that these example shaders don't do anything really useful.
; They only demonstrate that shaders can be used in Irrlicht.
ps.1.1
tex t0 ; sample color map
add r0, v0, v0 ; mulitply with color
mul t0, t0, r0 ; mulitply with color
add r0, t0, t0 ; make it brighter and store result

View File

@ -1,42 +0,0 @@
; part of the Irrlicht Engine Shader example.
; This Direct3D9 vertex shader will be loaded by the engine.
; Please note that these example shaders don't do anything really useful.
; They only demonstrate that shaders can be used in Irrlicht.
vs.1.1
dcl_position v0; ; declare position
dcl_normal v1; ; declare normal
dcl_color v2; ; declare color
dcl_texcoord0 v3; ; declare texture coordinate
; transpose and transform position to clip space
mul r0, v0.x, c4
mad r0, v0.y, c5, r0
mad r0, v0.z, c6, r0
add oPos, c7, r0
; transform normal
dp3 r1.x, v1, c0
dp3 r1.y, v1, c1
dp3 r1.z, v1, c2
; renormalize normal
dp3 r1.w, r1, r1
rsq r1.w, r1.w
mul r1, r1, r1.w
; calculate light vector
m4x4 r6, v0, c10 ; vertex into world position
add r2, c8, -r6 ; vtxpos - lightpos
; normalize light vector
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
; calculate light color
dp3 r3, r1, r2 ; dp3 with negative light vector
lit r5, r3 ; clamp to zero if r3 < 0, r5 has diffuce component in r5.y
mul oD0, r5.y, c9 ; ouput diffuse color
mov oT0, v3 ; store texture coordinates

View File

@ -1,9 +0,0 @@
uniform sampler2D myTexture;
void main (void)
{
vec4 col = texture2D(myTexture, vec2(gl_TexCoord[0]));
col *= gl_Color;
gl_FragColor = col * 4.0;
}

View File

@ -1,22 +0,0 @@
!!ARBfp1.0
# part of the Irrlicht Engine Shader example.
# Please note that these example shaders don't do anything really useful.
# They only demonstrate that shaders can be used in Irrlicht.
#Input
ATTRIB inTexCoord = fragment.texcoord; # texture coordinates
ATTRIB inColor = fragment.color.primary; # interpolated diffuse color
#Output
OUTPUT outColor = result.color;
TEMP texelColor;
TEMP tmp;
TXP texelColor, inTexCoord, texture, 2D;
ADD tmp, inColor, inColor; # mulitply with color
MUL texelColor, texelColor, tmp; # mulitply with color
ADD outColor, texelColor, texelColor; # make it brighter and store result
END

View File

@ -1,27 +0,0 @@
uniform mat4 mWorldViewProj;
uniform mat4 mInvWorld;
uniform mat4 mTransWorld;
uniform vec3 mLightPos;
uniform vec4 mLightColor;
void main(void)
{
gl_Position = mWorldViewProj * gl_Vertex;
vec4 normal = vec4(gl_Normal, 0.0);
normal = mInvWorld * normal;
normal = normalize(normal);
vec4 worldpos = gl_Vertex * mTransWorld;
vec4 lightVector = worldpos - vec4(mLightPos,1.0);
lightVector = normalize(lightVector);
float tmp2 = dot(-lightVector, normal);
vec4 tmp = mLightColor * tmp2;
gl_FrontColor = gl_BackColor = vec4(tmp.x, tmp.y, tmp.z, 0.0);
gl_TexCoord[0] = gl_MultiTexCoord0;
}

View File

@ -1,60 +0,0 @@
!!ARBvp1.0
# part of the Irrlicht Engine Shader example.
# Please note that these example shaders don't do anything really useful.
# They only demonstrate that shaders can be used in Irrlicht.
#input
ATTRIB InPos = vertex.position;
ATTRIB InColor = vertex.color;
ATTRIB InNormal = vertex.normal;
ATTRIB InTexCoord = vertex.texcoord;
#output
OUTPUT OutPos = result.position;
OUTPUT OutColor = result.color;
OUTPUT OutTexCoord = result.texcoord;
PARAM MVP[4] = { state.matrix.mvp }; # modelViewProjection matrix.
TEMP Temp;
TEMP TempColor;
TEMP TempNormal;
TEMP TempPos;
#transform position to clip space
DP4 Temp.x, MVP[0], InPos;
DP4 Temp.y, MVP[1], InPos;
DP4 Temp.z, MVP[2], InPos;
DP4 Temp.w, MVP[3], InPos;
#transform normal
DP3 TempNormal.x, InNormal.x, program.local[0];
DP3 TempNormal.y, InNormal.y, program.local[1];
DP3 TempNormal.z, InNormal.z, program.local[2];
#renormalize normal
DP3 TempNormal.w, TempNormal, TempNormal;
RSQ TempNormal.w, TempNormal.w;
MUL TempNormal, TempNormal, TempNormal.w;
# calculate light vector
DP4 TempPos.x, InPos, program.local[10]; # vertex into world position
DP4 TempPos.y, InPos, program.local[11];
DP4 TempPos.z, InPos, program.local[12];
DP4 TempPos.w, InPos, program.local[13];
ADD TempPos, program.local[8], -TempPos; # vtxpos - lightpos
# normalize light vector
DP3 TempPos.w, TempPos, TempPos;
RSQ TempPos.w, TempPos.w;
MUL TempPos, TempPos, TempPos.w;
# calculate light color
DP3 TempColor, TempNormal, TempPos; # dp3 with negative light vector
LIT OutColor, TempColor; # clamp to zero if r3 < 0, r5 has diffuce component in r5.y
MUL OutColor, TempColor.y, program.local[9]; # ouput diffuse color
MOV OutColor.w, 1.0; # we want alpha to be always 1
MOV OutTexCoord, InTexCoord; # store texture coordinate
MOV OutPos, Temp;
END

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht10.0.vcxproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release - Fast FPU|Win32 = Release - Fast FPU|Win32
Release - Fast FPU|x64 = Release - Fast FPU|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Static lib - Debug|Win32 = Static lib - Debug|Win32
Static lib - Debug|x64 = Static lib - Debug|x64
Static lib - Release - Fast FPU|Win32 = Static lib - Release - Fast FPU|Win32
Static lib - Release - Fast FPU|x64 = Static lib - Release - Fast FPU|x64
Static lib - Release|Win32 = Static lib - Release|Win32
Static lib - Release|x64 = Static lib - Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|x64.ActiveCfg = Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|x64.Build.0 = Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.ActiveCfg = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.Build.0 = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|x64.ActiveCfg = Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|x64.Build.0 = Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|x64.ActiveCfg = Release|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|x64.Build.0 = Release|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.ActiveCfg = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.Build.0 = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|x64.ActiveCfg = Static lib - Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|x64.Build.0 = Static lib - Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.ActiveCfg = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.Build.0 = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|x64.ActiveCfg = Static lib - Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|x64.Build.0 = Static lib - Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.ActiveCfg = Static lib - Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.Build.0 = Static lib - Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|x64.ActiveCfg = Static lib - Release|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|x64.Build.0 = Static lib - Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht11.0.vcxproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release - Fast FPU|Win32 = Release - Fast FPU|Win32
Release - Fast FPU|x64 = Release - Fast FPU|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Static lib - Debug|Win32 = Static lib - Debug|Win32
Static lib - Debug|x64 = Static lib - Debug|x64
Static lib - Release - Fast FPU|Win32 = Static lib - Release - Fast FPU|Win32
Static lib - Release - Fast FPU|x64 = Static lib - Release - Fast FPU|x64
Static lib - Release|Win32 = Static lib - Release|Win32
Static lib - Release|x64 = Static lib - Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|x64.ActiveCfg = Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|x64.Build.0 = Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.ActiveCfg = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.Build.0 = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|x64.ActiveCfg = Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|x64.Build.0 = Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|x64.ActiveCfg = Release|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|x64.Build.0 = Release|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.ActiveCfg = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.Build.0 = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|x64.ActiveCfg = Static lib - Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|x64.Build.0 = Static lib - Debug|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.ActiveCfg = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.Build.0 = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|x64.ActiveCfg = Static lib - Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|x64.Build.0 = Static lib - Release - Fast FPU|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.ActiveCfg = Static lib - Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.Build.0 = Static lib - Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|x64.ActiveCfg = Static lib - Release|x64
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|x64.Build.0 = Static lib - Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
Static lib - Debug|Win32 = Static lib - Debug|Win32
Static lib - Release - Fast FPU|Win32 = Static lib - Release - Fast FPU|Win32
Static lib - Release|Win32 = Static lib - Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.ActiveCfg = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.Build.0 = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.ActiveCfg = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.Build.0 = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.ActiveCfg = Static lib - Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.Build.0 = Static lib - Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht9.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release - Fast FPU|Win32 = Release - Fast FPU|Win32
Release|Win32 = Release|Win32
Static lib - Debug|Win32 = Static lib - Debug|Win32
Static lib - Release - Fast FPU|Win32 = Static lib - Release - Fast FPU|Win32
Static lib - Release|Win32 = Static lib - Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.ActiveCfg = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU|Win32.Build.0 = Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.ActiveCfg = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Debug|Win32.Build.0 = Static lib - Debug|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.ActiveCfg = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release - Fast FPU|Win32.Build.0 = Static lib - Release - Fast FPU|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.ActiveCfg = Static lib - Release|Win32
{E08E042A-6C45-411B-92BE-3CC31331019F}.Static lib - Release|Win32.Build.0 = Static lib - Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "Irrlicht_mobile6.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Windows Mobile 6 Professional SDK (ARMV4I) = Debug|Windows Mobile 6 Professional SDK (ARMV4I)
Release|Windows Mobile 6 Professional SDK (ARMV4I) = Release|Windows Mobile 6 Professional SDK (ARMV4I)
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I)
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I)
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I)
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I)
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I)
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I)
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht_xbox", "Irrlicht_xbox.vcproj", "{2440E601-7438-4C6B-B4AF-BBFE9735875E}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Profile = Profile
Profile_FastCap = Profile_FastCap
Release = Release
Release_LTCG = Release_LTCG
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Debug.ActiveCfg = Debug|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Debug.Build.0 = Debug|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile.ActiveCfg = Profile|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile.Build.0 = Profile|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release.ActiveCfg = Release|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release.Build.0 = Release|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release_LTCG.Build.0 = Release_LTCG|Xbox
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -1,196 +0,0 @@
VERSION_MAJOR = 1
VERSION_MINOR = 8
VERSION_RELEASE = 0
# Irrlicht Engine 1.8.0
# Makefile for Linux
#
# To use, just run:
#
# make
#
# This will compile Irrlicht, create a static lib (libIrrlicht.a), and copy it
# into the subdirectory lib/Linux. That's all.
#
# If you want Irrlicht to be compiled as shared lib (libIrrlicht.so.versionnumber), then run:
#
# make sharedlib
# make install
#
# If you want to compile in release mode run:
#
# make NDEBUG=1
#
# For cross-compilation for Win32 under Linux, just use the win32 targets. You have to set
# at least CXX, CC, and AR to the proper binaries.
#
# For compiling on MinGW you can run it with:
#
# make win32
#
#List of object files, separated based on engine architecture
IRRMESHLOADER = CBSPMeshFileLoader.o CMD2MeshFileLoader.o CMD3MeshFileLoader.o CMS3DMeshFileLoader.o CB3DMeshFileLoader.o C3DSMeshFileLoader.o COgreMeshFileLoader.o COBJMeshFileLoader.o CColladaFileLoader.o CCSMLoader.o CDMFLoader.o CLMTSMeshFileLoader.o CMY3DMeshFileLoader.o COCTLoader.o CXMeshFileLoader.o CIrrMeshFileLoader.o CSTLMeshFileLoader.o CLWOMeshFileLoader.o CPLYMeshFileLoader.o CSMFMeshFileLoader.o
IRRMESHWRITER = CColladaMeshWriter.o CIrrMeshWriter.o CSTLMeshWriter.o COBJMeshWriter.o CPLYMeshWriter.o
IRRMESHOBJ = $(IRRMESHLOADER) $(IRRMESHWRITER) \
CSkinnedMesh.o CBoneSceneNode.o CMeshSceneNode.o \
CAnimatedMeshSceneNode.o CAnimatedMeshMD2.o CAnimatedMeshMD3.o \
CQ3LevelMesh.o CQuake3ShaderSceneNode.o CAnimatedMeshHalfLife.o
IRROBJ = CBillboardSceneNode.o CCameraSceneNode.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CMeshManipulator.o CMetaTriangleSelector.o COctreeSceneNode.o COctreeTriangleSelector.o CSceneCollisionManager.o CSceneManager.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CVolumeLightSceneNode.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CSceneLoaderIrr.o
IRRPARTICLEOBJ = CParticleAnimatedMeshSceneNodeEmitter.o CParticleBoxEmitter.o CParticleCylinderEmitter.o CParticleMeshEmitter.o CParticlePointEmitter.o CParticleRingEmitter.o CParticleSphereEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticleSystemSceneNode.o CParticleScaleAffector.o
IRRANIMOBJ = CSceneNodeAnimatorCameraFPS.o CSceneNodeAnimatorCameraMaya.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o
IRRDRVROBJ = CNullDriver.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLTexture.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D8Driver.o CD3D8NormalMapRenderer.o CD3D8ParallaxMapRenderer.o CD3D8ShaderMaterialRenderer.o CD3D8Texture.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o
IRRIMAGEOBJ = CColorConverter.o CImage.o CImageLoaderBMP.o CImageLoaderDDS.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderTGA.o CImageLoaderPPM.o CImageLoaderWAL.o CImageLoaderRGB.o \
CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o
IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRNormalMap.o CTRStencilShadow.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o CBurningShader_Raster_Reference.o
IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CWADReader.o CZipReader.o CPakReader.o CNPKReader.o CTarReader.o CMountPointReader.o irrXML.o CAttributes.o lzma/LzmaDec.o
IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceLinux.o CIrrDeviceConsole.o CIrrDeviceStub.o CIrrDeviceWin32.o CIrrDeviceFB.o CLogger.o COSOperator.o Irrlicht.o os.o
IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUITable.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o CGUIImageList.o CGUITreeView.o
ZLIBOBJ = zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o
JPEGLIBOBJ = jpeglib/jcapimin.o jpeglib/jcapistd.o jpeglib/jccoefct.o jpeglib/jccolor.o jpeglib/jcdctmgr.o jpeglib/jchuff.o jpeglib/jcinit.o jpeglib/jcmainct.o jpeglib/jcmarker.o jpeglib/jcmaster.o jpeglib/jcomapi.o jpeglib/jcparam.o jpeglib/jcprepct.o jpeglib/jcsample.o jpeglib/jctrans.o jpeglib/jdapimin.o jpeglib/jdapistd.o jpeglib/jdatadst.o jpeglib/jdatasrc.o jpeglib/jdcoefct.o jpeglib/jdcolor.o jpeglib/jddctmgr.o jpeglib/jdhuff.o jpeglib/jdinput.o jpeglib/jdmainct.o jpeglib/jdmarker.o jpeglib/jdmaster.o jpeglib/jdmerge.o jpeglib/jdpostct.o jpeglib/jdsample.o jpeglib/jdtrans.o jpeglib/jerror.o jpeglib/jfdctflt.o jpeglib/jfdctfst.o jpeglib/jfdctint.o jpeglib/jidctflt.o jpeglib/jidctfst.o jpeglib/jidctint.o jpeglib/jmemmgr.o jpeglib/jmemnobs.o jpeglib/jquant1.o jpeglib/jquant2.o jpeglib/jutils.o jpeglib/jcarith.o jpeglib/jdarith.o jpeglib/jaricom.o
LIBPNGOBJ = libpng/png.o libpng/pngerror.o libpng/pngget.o libpng/pngmem.o libpng/pngpread.o libpng/pngread.o libpng/pngrio.o libpng/pngrtran.o libpng/pngrutil.o libpng/pngset.o libpng/pngtrans.o libpng/pngwio.o libpng/pngwrite.o libpng/pngwtran.o libpng/pngwutil.o
LIBAESGM = aesGladman/aescrypt.o aesGladman/aeskey.o aesGladman/aestab.o aesGladman/fileenc.o aesGladman/hmac.o aesGladman/prng.o aesGladman/pwd2key.o aesGladman/sha1.o aesGladman/sha2.o
BZIP2OBJ = bzip2/blocksort.o bzip2/huffman.o bzip2/crctable.o bzip2/randtable.o bzip2/bzcompress.o bzip2/decompress.o bzip2/bzlib.o
# Next variable is for additional scene nodes etc. of customized Irrlicht versions
EXTRAOBJ =
LINKOBJ = $(IRRMESHOBJ) $(IRROBJ) $(IRRPARTICLEOBJ) $(IRRANIMOBJ) \
$(IRRVIDEOOBJ) $(IRRSWRENDEROBJ) $(IRRIOOBJ) $(IRROTHEROBJ) \
$(IRRGUIOBJ) $(ZLIBOBJ) $(JPEGLIBOBJ) $(LIBPNGOBJ) $(LIBAESGM) \
$(BZIP2OBJ) $(EXTRAOBJ)
###############
#Compiler flags
CXXINCS = -I../../include -Izlib -Ijpeglib -Ilibpng
CPPFLAGS += $(CXXINCS) -DIRRLICHT_EXPORTS=1
CXXFLAGS += -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing
ifndef NDEBUG
CXXFLAGS += -g -D_DEBUG
else
CXXFLAGS += -fexpensive-optimizations -O3
endif
ifdef PROFILE
CXXFLAGS += -pg
endif
CFLAGS := -O3 -fexpensive-optimizations -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES
sharedlib sharedlib_osx: CXXFLAGS += -fPIC
sharedlib sharedlib_osx: CFLAGS += -fPIC
#multilib handling
ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64
endif
#Linux specific options
staticlib sharedlib install: SYSTEM = Linux
STATIC_LIB = libIrrlicht.a
LIB_PATH = ../../lib/$(SYSTEM)
INSTALL_DIR = /usr/local/lib
sharedlib install: SHARED_LIB = libIrrlicht.so
sharedlib: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm
staticlib sharedlib: CXXINCS += -I/usr/X11R6/include
#OSX specific options
staticlib_osx sharedlib_osx install_osx: SYSTEM = MacOSX
staticlib_osx sharedlib_osx: IRROTHEROBJ += MacOSX/CIrrDeviceMacOSX.o MacOSX/OSXClipboard.o MacOSX/AppDelegate.o
staticlib_osx sharedlib_osx: CXXINCS += -IMacOSX -I/usr/X11R6/include
sharedlib_osx install_osx: SHARED_LIB = libIrrlicht.dylib
staticlib_osx sharedlib_osx: LDFLAGS += --no-export-all-symbols --add-stdcall-alias
sharedlib_osx: LDFLAGS += -L/usr/X11R6/lib$(LIBSELECT) -lGL -lXxf86vm
# for non-X11 app
#sharedlib_osx: LDFLAGS += -framework cocoa -framework carbon -framework opengl -framework IOKit
#Windows specific options
IRRLICHT_DLL := ../../bin/Win32-gcc/Irrlicht.dll
sharedlib_win32 staticlib_win32: SYSTEM = Win32-gcc
sharedlib_win32: LDFLAGS += -lgdi32 -lopengl32 -ld3dx9d -lwinmm -Wl,--add-stdcall-alias
#choose either -DIRR_COMPILE_WITH_DX9_DEV_PACK or -DNO_IRR_COMPILE_WITH_DIRECT3D_9_ depending if you need dx9
#sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK
sharedlib_win32 staticlib_win32: CPPFLAGS += -DNO_IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ -DNO_IRR_COMPILE_WITH_DIRECT3D_9_
sharedlib_win32 staticlib_win32: CPPFLAGS += -DIRR_COMPILE_WITH_DX9_DEV_PACK -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_MBCS -D_USRDLL
staticlib_win32: CPPFLAGS += -D_IRR_STATIC_LIB_
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
SHARED_FULLNAME = $(SHARED_LIB).$(VERSION)
SONAME = $(SHARED_LIB).$(VERSION_MAJOR).$(VERSION_MINOR)
####################
# All target, builds Irrlicht as static lib (libIrrlicht.a) and copies it into lib/Linux
all linux: staticlib
# Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into lib/Linux
sharedlib: $(LINKOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -Wl,-soname,$(SONAME) -o $(SHARED_FULLNAME) $^ $(LDFLAGS)
mkdir -p $(LIB_PATH)
cp $(SHARED_FULLNAME) $(LIB_PATH)
# Builds Irrlicht as static lib (libIrrlicht.a)
$(STATIC_LIB): $(LINKOBJ)
$(AR) rs $@ $^
# Copies static lib into lib/Linux
staticlib staticlib_osx: $(STATIC_LIB)
mkdir -p $(LIB_PATH)
cp $^ $(LIB_PATH)
# Builds Irrlicht as dll (Irrlicht.dll) into ../../bin/Win32-gcc
all_win32 win32: sharedlib_win32
sharedlib_win32: $(IRRLICHT_DLL)
../../bin/Win32-gcc/Irrlicht.dll: $(LINKOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -o $@ $^ $(LDFLAGS) -Wl,--out-implib,../../lib/Win32-gcc/$(STATIC_LIB)
# Copies static lib into /lib/Win32-gcc
staticlib_win32: $(STATIC_LIB)
cp $^ $(LIB_PATH)
# Builds Irrlicht as shared lib (libIrrlicht.so.versionNumber) and copies it into /lib/MacOSX
sharedlib_osx: $(LINKOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -dynamiclib -Wl,-install_name,$(SONAME) -o $(SHARED_FULLNAME) $^ $(LDFLAGS)
cp $(SHARED_FULLNAME) $(LIB_PATH)
# Installs Irrlicht if it was created as shared lib
install install_osx:
$(RM) -r $(INSTALL_DIR)/../include/irrlicht
mkdir -p $(INSTALL_DIR)/../include/irrlicht
cp ../../include/*.h $(INSTALL_DIR)/../include/irrlicht/
cp $(LIB_PATH)/$(SHARED_FULLNAME) $(INSTALL_DIR)
cd $(INSTALL_DIR) && ln -s -f $(SHARED_FULLNAME) $(SONAME)
cd $(INSTALL_DIR) && ln -s -f $(SONAME) $(SHARED_LIB)
# ldconfig -n $(INSTALL_DIR)
TAGS:
ctags *.cpp ../../include/*.h *.h
# Create dependency files for automatic recompilation
%.d:%.cpp
$(CXX) $(CPPFLAGS) -MM -MF $@ $<
# Create dependency files for automatic recompilation
%.d:%.c
$(CC) $(CPPFLAGS) -MM -MF $@ $<
# Create object files from objective-c code
%.o:%.mm
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
ifneq ($(MAKECMDGOALS),clean)
-include $(LINKOBJ:.o=.d)
endif
help:
@echo "Available targets for Irrlicht"
@echo " sharedlib: Build shared library Irrlicht.so for Linux"
@echo " staticlib: Build static library Irrlicht.a for Linux"
@echo " install: Copy shared library to /usr/local/lib"
@echo ""
@echo " sharedlib_win32: Build shared library Irrlicht.dll for Windows"
@echo " staticlib_win32: Build static library Irrlicht.a for Windows"
@echo ""
@echo " clean: Clean up directory"
# Cleans all temporary files and compilation results.
clean:
$(RM) $(LINKOBJ) $(SHARED_FULLNAME) $(STATIC_LIB) $(LINKOBJ:.o=.d)
.PHONY: all sharedlib staticlib sharedlib_win32 staticlib_win32 help install clean

View File

@ -1,102 +0,0 @@
import os
import sys
USE_GCC = 1;
NDEBUG = 1;
PROFILE = 0;
APPLICATION_NAME = 'Irrlicht';
LIBRARIES = ['gdi32', 'opengl32', 'd3dx9d', 'winmm'];
if USE_GCC==1 and PROFILE==1:
LIBRARIES += ['gmon'];
CXXINCS = ['../../include/', 'zlib/', 'jpeglib/', 'libpng/'];
if USE_GCC==0:
env = Environment(ENV = {
'PATH': os.environ['PATH']
}, CPPPATH=CXXINCS);
else:
env = Environment(ENV = {
'PATH': os.environ['PATH']
}, tools = ['mingw'], CPPPATH=CXXINCS);
IRRMESHLOADER = ['CBSPMeshFileLoader.cpp', 'CMD2MeshFileLoader.cpp', 'CMD3MeshFileLoader.cpp', 'CMS3DMeshFileLoader.cpp', 'CB3DMeshFileLoader.cpp', 'C3DSMeshFileLoader.cpp', 'COgreMeshFileLoader.cpp', 'COBJMeshFileLoader.cpp', 'CColladaFileLoader.cpp', 'CCSMLoader.cpp', 'CDMFLoader.cpp', 'CLMTSMeshFileLoader.cpp', 'CMY3DMeshFileLoader.cpp', 'COCTLoader.cpp', 'CXMeshFileLoader.cpp', 'CIrrMeshFileLoader.cpp', 'CSTLMeshFileLoader.cpp', 'CLWOMeshFileLoader.cpp'];
IRRMESHWRITER = ['CColladaMeshWriter.cpp', 'CIrrMeshWriter.cpp', 'COBJMeshWriter.cpp', 'CSTLMeshWriter.cpp'];
IRRMESHOBJ = IRRMESHLOADER + IRRMESHWRITER + ['CSkinnedMesh.cpp', 'CBoneSceneNode.cpp', 'CMeshSceneNode.cpp', 'CAnimatedMeshSceneNode.cpp', 'CAnimatedMeshMD2.cpp', 'CAnimatedMeshMD3.cpp', 'CQ3LevelMesh.cpp', 'CQuake3ShaderSceneNode.cpp'];
IRROBJ = ['CBillboardSceneNode.cpp', 'CCameraSceneNode.cpp', 'CDummyTransformationSceneNode.cpp', 'CEmptySceneNode.cpp', 'CGeometryCreator.cpp', 'CLightSceneNode.cpp', 'CMeshManipulator.cpp', 'CMetaTriangleSelector.cpp', 'COctreeSceneNode.cpp', 'COctreeTriangleSelector.cpp', 'CSceneCollisionManager.cpp', 'CSceneManager.cpp', 'CShadowVolumeSceneNode.cpp', 'CSkyBoxSceneNode.cpp', 'CSkyDomeSceneNode.cpp', 'CTerrainSceneNode.cpp', 'CTerrainTriangleSelector.cpp', 'CVolumeLightSceneNode.cpp', 'CCubeSceneNode.cpp', 'CSphereSceneNode.cpp', 'CTextSceneNode.cpp', 'CTriangleBBSelector.cpp', 'CTriangleSelector.cpp', 'CWaterSurfaceSceneNode.cpp', 'CMeshCache.cpp', 'CDefaultSceneNodeAnimatorFactory.cpp', 'CDefaultSceneNodeFactory.cpp'];
IRRPARTICLEOBJ = ['CParticleAnimatedMeshSceneNodeEmitter.cpp', 'CParticleBoxEmitter.cpp', 'CParticleCylinderEmitter.cpp', 'CParticleMeshEmitter.cpp', 'CParticlePointEmitter.cpp', 'CParticleRingEmitter.cpp', 'CParticleSphereEmitter.cpp', 'CParticleAttractionAffector.cpp', 'CParticleFadeOutAffector.cpp', 'CParticleGravityAffector.cpp', 'CParticleRotationAffector.cpp', 'CParticleSystemSceneNode.cpp', 'CParticleScaleAffector.cpp'];
IRRANIMOBJ = ['CSceneNodeAnimatorCameraFPS.cpp', 'CSceneNodeAnimatorCameraMaya.cpp', 'CSceneNodeAnimatorCollisionResponse.cpp', 'CSceneNodeAnimatorDelete.cpp', 'CSceneNodeAnimatorFlyCircle.cpp', 'CSceneNodeAnimatorFlyStraight.cpp', 'CSceneNodeAnimatorFollowSpline.cpp', 'CSceneNodeAnimatorRotation.cpp', 'CSceneNodeAnimatorTexture.cpp'];
IRRDRVROBJ = ['CNullDriver.cpp', 'COpenGLDriver.cpp', 'COpenGLNormalMapRenderer.cpp', 'COpenGLParallaxMapRenderer.cpp', 'COpenGLShaderMaterialRenderer.cpp', 'COpenGLTexture.cpp', 'COpenGLSLMaterialRenderer.cpp', 'COpenGLExtensionHandler.cpp', 'CD3D8Driver.cpp', 'CD3D8NormalMapRenderer.cpp', 'CD3D8ParallaxMapRenderer.cpp', 'CD3D8ShaderMaterialRenderer.cpp', 'CD3D8Texture.cpp', 'CD3D9Driver.cpp', 'CD3D9HLSLMaterialRenderer.cpp', 'CD3D9NormalMapRenderer.cpp', 'CD3D9ParallaxMapRenderer.cpp', 'CD3D9ShaderMaterialRenderer.cpp', 'CD3D9Texture.cpp'];
IRRIMAGEOBJ = ['CColorConverter.cpp', 'CImage.cpp', 'CImageLoaderBMP.cpp', 'CImageLoaderJPG.cpp', 'CImageLoaderPCX.cpp', 'CImageLoaderPNG.cpp', 'CImageLoaderPSD.cpp', 'CImageLoaderTGA.cpp', 'CImageLoaderPPM.cpp', 'CImageLoaderWAL.cpp', 'CImageWriterBMP.cpp', 'CImageWriterJPG.cpp', 'CImageWriterPCX.cpp', 'CImageWriterPNG.cpp', 'CImageWriterPPM.cpp', 'CImageWriterPSD.cpp', 'CImageWriterTGA.cpp'];
IRRVIDEOOBJ = ['CVideoModeList.cpp', 'CFPSCounter.cpp'] + IRRDRVROBJ + IRRIMAGEOBJ;
IRRSWRENDEROBJ = ['CSoftwareDriver.cpp', 'CSoftwareTexture.cpp', 'CTRFlat.cpp', 'CTRFlatWire.cpp', 'CTRGouraud.cpp', 'CTRGouraudWire.cpp', 'CTRTextureFlat.cpp', 'CTRTextureFlatWire.cpp', 'CTRTextureGouraud.cpp', 'CTRTextureGouraudAdd.cpp', 'CTRTextureGouraudNoZ.cpp', 'CTRTextureGouraudWire.cpp', 'CZBuffer.cpp', 'CTRTextureGouraudVertexAlpha2.cpp', 'CTRTextureGouraudNoZ2.cpp', 'CTRTextureLightMap2_M2.cpp', 'CTRTextureLightMap2_M4.cpp', 'CTRTextureLightMap2_M1.cpp', 'CSoftwareDriver2.cpp', 'CSoftwareTexture2.cpp', 'CTRTextureGouraud2.cpp', 'CTRGouraud2.cpp', 'CTRGouraudAlpha2.cpp', 'CTRGouraudAlphaNoZ2.cpp', 'CTRTextureDetailMap2.cpp', 'CTRTextureGouraudAdd2.cpp', 'CTRTextureGouraudAddNoZ2.cpp', 'CTRTextureWire2.cpp', 'CTRTextureLightMap2_Add.cpp', 'CTRTextureLightMapGouraud2_M4.cpp', 'IBurningShader.cpp', 'CTRTextureBlend.cpp', 'CTRTextureGouraudAlpha.cpp', 'CTRTextureGouraudAlphaNoZ.cpp', 'CDepthBuffer.cpp', 'CBurningShader_Raster_Reference.cpp'];
IRRIOOBJ = ['CFileList.cpp', 'CFileSystem.cpp', 'CLimitReadFile.cpp', 'CMemoryReadFile.cpp', 'CReadFile.cpp', 'CWriteFile.cpp', 'CXMLReader.cpp', 'CXMLWriter.cpp', 'CZipReader.cpp', 'CPakReader.cpp', 'CNPKReader.cpp', 'irrXML.cpp', 'CAttributes.cpp', 'lzma/LzmaDec.c'];
IRROTHEROBJ = ['CIrrDeviceSDL.cpp', 'CIrrDeviceLinux.cpp', 'CIrrDeviceStub.cpp', 'CIrrDeviceWin32.cpp', 'CLogger.cpp', 'COSOperator.cpp', 'Irrlicht.cpp', 'os.cpp'];
IRRGUIOBJ = ['CGUIButton.cpp', 'CGUICheckBox.cpp', 'CGUIComboBox.cpp', 'CGUIContextMenu.cpp', 'CGUIEditBox.cpp', 'CGUIEnvironment.cpp', 'CGUIFileOpenDialog.cpp', 'CGUIFont.cpp', 'CGUIImage.cpp', 'CGUIInOutFader.cpp', 'CGUIListBox.cpp', 'CGUIMenu.cpp', 'CGUIMeshViewer.cpp', 'CGUIMessageBox.cpp', 'CGUIModalScreen.cpp', 'CGUIScrollBar.cpp', 'CGUISpinBox.cpp', 'CGUISkin.cpp', 'CGUIStaticText.cpp', 'CGUITabControl.cpp', 'CGUITable.cpp', 'CGUIToolBar.cpp', 'CGUIWindow.cpp', 'CGUIColorSelectDialog.cpp', 'CDefaultGUIElementFactory.cpp', 'CGUISpriteBank.cpp'];
ZLIB_PREFIX = 'zlib/';
ZLIBNAMES = ['adler32.c', 'compress.c', 'crc32.c', 'deflate.c', 'inffast.c', 'inflate.c', 'inftrees.c', 'trees.c', 'uncompr.c', 'zutil.c'];
ZLIBOBJ = [];
for fileName in ZLIBNAMES:
ZLIBOBJ += [ZLIB_PREFIX + fileName];
JPEGLIB_PREFIX = 'jpeglib/';
JPEGLIBNAMES = ['jaricom.c', 'jcapimin.c', 'jcapistd.c', 'jcarith.c', 'jccoefct.c', 'jccolor.c', 'jcdctmgr.c', 'jchuff.c', 'jcinit.c', 'jcmainct.c', 'jcmarker.c', 'jcmaster.c', 'jcomapi.c', 'jcparam.c', 'jcprepct.c', 'jcsample.c', 'jctrans.c', 'jdapimin.c', 'jdapistd.c', 'jdarith.c', 'jdatadst.c', 'jdatasrc.c', 'jdcoefct.c', 'jdcolor.c', 'jddctmgr.c', 'jdhuff.c', 'jdinput.c', 'jdmainct.c', 'jdmarker.c', 'jdmaster.c', 'jdmerge.c', 'jdpostct.c', 'jdsample.c', 'jdtrans.c', 'jerror.c', 'jfdctflt.c', 'jfdctfst.c', 'jfdctint.c', 'jidctflt.c', 'jidctfst.c', 'jidctint.c', 'jmemmgr.c', 'jmemnobs.c', 'jquant1.c', 'jquant2.c', 'jutils.c'];
JPEGLIBOBJ = [];
for fileName in JPEGLIBNAMES:
JPEGLIBOBJ += [JPEGLIB_PREFIX + fileName];
LIBPNG_PREFIX = 'libpng/';
LIBPNGNAMES = ['png.c', 'pngerror.c', 'pngget.c', 'pngmem.c', 'pngpread.c', 'pngread.c', 'pngrio.c', 'pngrtran.c', 'pngrutil.c', 'pngset.c', 'pngtrans.c', 'pngwio.c', 'pngwrite.c', 'pngwtran.c', 'pngwutil.c'];
LIBPNGOBJ = [];
for fileName in LIBPNGNAMES:
LIBPNGOBJ += [LIBPNG_PREFIX + fileName];
AESGLADMAN_PREFIX = 'aesGladman/';
AESGLADMANNAMES = ['aescrypt.cpp', 'aeskey.cpp', 'aestab.cpp', 'fileenc.cpp', 'hmac.cpp', 'prng.cpp', 'pwd2key.cpp', 'sha1.cpp', 'sha2.cpp'];
AESGLADMANOBJ = [];
for fileName in AESGLADMANNAMES:
AESGLADMANOBJ += [AESGLADMAN_PREFIX + fileName];
BZIP2_PREFIX = 'bzip2/';
BZIP2NAMES = ['blocksort.c', 'bzcompress.c', 'bzlib.c', 'crctable.c', 'decompress.c', 'huffman.c', 'randtable.c'];
BZIP2OBJ = [];
for fileName in BZIP2NAMES:
BZIP2OBJ += [BZIP2_PREFIX + fileName];
# Next variable is for additional scene nodes etc. of customized Irrlicht versions
EXTRAOBJ = [];
LINKOBJ = IRRMESHOBJ + IRROBJ + IRRPARTICLEOBJ + IRRANIMOBJ + IRRVIDEOOBJ + IRRSWRENDEROBJ + IRRIOOBJ + IRROTHEROBJ + IRRGUIOBJ + ZLIBOBJ + JPEGLIBOBJ + LIBPNGOBJ + AESGLADMANOBJ + EXTRAOBJ;
env.Append(LIBS = LIBRARIES, LIBPATH = CXXINCS);
CXXFLAGS = ['-Wall'];
if NDEBUG:
CXXFLAGS += ['-fexpensive-optimizations', '-O3'];
else:
CXXFLAGS += ['-g', '-D_DEBUG'];
if PROFILE:
CXXFLAGS += ['-pg'];
CXXFLAGS += ['-DPNG_NO_MMX_CODE', '-DPNG_NO_MNG_FEATURES', '-DIRRLICHT_EXPORTS=1', '-D_IRR_STATIC_LIB_'];
if USE_GCC:
CXXFLAGS += ['-D__GNUWIN32__=1'];
env.Append(CCFLAGS = CXXFLAGS);
IrrlichtLibrary = env.SharedLibrary("Irrlicht.dll", LINKOBJ);

View File

@ -1,40 +0,0 @@
Source code of the Irrlicht Engine
The complete source of the Irrlicht Engine can be found when decompressing
the .zip file included in this directory.
Please note that YOU DO NOT NEED THIS SOURCE to develop 3d applications with
the Irrlicht Engine. Instead, please use the .dll in the \bin directory, the
.lib in the \lib directory and the header files in the \include directory.
You will find a good tutorial how to set up your development environment and to
use the engine in the \examples directory. (Try 1.helloworld)
The source of the engine is only included because of the following reasons:
- To let developers be able to debug the engine.
- To let developers be able to make changes to the engine.
- To let developers be able to compile their own versions of the engine.
HOW TO COMPILE THE ENGINE WITH LINUX
If you wish to compile the engine in linux yourself, unzip the source source.zip
file in the \source directory. Run a 'make' in the now existing new subfolder 'Irrlicht'.
After this, you should be able to make all example applications in \examples.
Then just start an X Server and run them, from the directory where they are.
If you get a compiling/linking problem like
undefined reference to `glXGetProcAddress'
Then there are several solutions:
A) This disables the use of OpenGL extensions:
Open the file IrrCompileConfig.h, comment out _IRR_OPENGL_USE_EXTPOINTER_,
and recompile Irrlicht using
make clean
make
B) Replace all occurrences of 'glXGetProcAddress' with 'glXGetProcAddressARB' and run a
make
This will solve the issue but keep the OpenGL extension enabled.

View File

@ -1,910 +0,0 @@
#include "testUtils.h"
#include <map>
using namespace irr;
namespace
{
// don't use this code! It lacks many checks and is for testing
// purposes only!!!
// based on code and media from SuperTuxKart
class ScalableFont : public gui::IGUIFontBitmap
{
float m_scale;
struct TextureInfo
{
irr::core::stringc m_file_name;
bool m_has_alpha;
float m_scale;
TextureInfo()
{
m_has_alpha = false;
m_scale = 1.0f;
}
};
std::map<int /* texture file ID */, TextureInfo> m_texture_files;
void lazyLoadTexture(int texID)
{
const bool mipmap = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
// load texture
SpriteBank->setTexture(texID, Driver->getTexture( m_texture_files[texID].m_file_name ));
// set previous mip-map+filter state
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap);
// couldn't load texture, abort.
if (!SpriteBank->getTexture(texID))
{
return;
}
else
{
// colorkey texture rather than alpha channel?
if (! m_texture_files[texID].m_has_alpha)
{
Driver->makeColorKeyTexture(SpriteBank->getTexture(texID), core::position2di(0,0));
}
}
}
void doReadXmlFile(io::IXMLReader* xml)
{
while (xml->read())
{
if (io::EXN_ELEMENT == xml->getNodeType())
{
if (core::stringw(L"include") == xml->getNodeName())
{
core::stringc filename = xml->getAttributeValue(L"file");
io::IXMLReader* included = Environment->getFileSystem()->createXMLReader(filename.c_str());
if (included != NULL)
{
doReadXmlFile(included);
included->drop();
}
}
else if (core::stringw(L"Texture") == xml->getNodeName())
{
// add a texture
core::stringc filename = xml->getAttributeValue(L"filename");
core::stringc fn = filename;
u32 i = (u32)xml->getAttributeValueAsInt(L"index");
float scale=1.0f;
if (xml->getAttributeValue(L"scale"))
scale = xml->getAttributeValueAsFloat(L"scale");
//std::cout << "scale = " << scale << std::endl;
core::stringw alpha = xml->getAttributeValue(L"hasAlpha");
//std::cout << "---- Adding font texture " << fn.c_str() << "; alpha=" << alpha.c_str() << std::endl;
// make sure the sprite bank has enough textures in it
while (i+1 > SpriteBank->getTextureCount())
{
SpriteBank->addTexture(NULL);
}
TextureInfo info;
info.m_file_name = fn;
info.m_has_alpha = (alpha == core::stringw("true"));
info.m_scale = scale;
m_texture_files[i] = info;
}
else if (core::stringw(L"c") == xml->getNodeName())
{
// adding a character to this font
SFontArea a;
gui::SGUISpriteFrame f;
gui::SGUISprite s;
core::rect<s32> rectangle;
a.underhang = xml->getAttributeValueAsInt(L"u");
a.overhang = xml->getAttributeValueAsInt(L"o");
a.spriteno = SpriteBank->getSprites().size();
s32 texno = xml->getAttributeValueAsInt(L"i");
// parse rectangle
core::stringc rectstr = xml->getAttributeValue(L"r");
wchar_t ch = xml->getAttributeValue(L"c")[0];
const c8 *c = rectstr.c_str();
s32 val;
val = 0;
while (*c >= '0' && *c <= '9')
{
val *= 10;
val += *c - '0';
c++;
}
rectangle.UpperLeftCorner.X = val;
while (*c == L' ' || *c == L',') c++;
val = 0;
while (*c >= '0' && *c <= '9')
{
val *= 10;
val += *c - '0';
c++;
}
rectangle.UpperLeftCorner.Y = val;
while (*c == L' ' || *c == L',') c++;
val = 0;
while (*c >= '0' && *c <= '9')
{
val *= 10;
val += *c - '0';
c++;
}
rectangle.LowerRightCorner.X = val;
while (*c == L' ' || *c == L',') c++;
val = 0;
while (*c >= '0' && *c <= '9')
{
val *= 10;
val += *c - '0';
c++;
}
rectangle.LowerRightCorner.Y = val;
CharacterMap[ch] = Areas.size();
// make frame
f.rectNumber = SpriteBank->getPositions().size();
f.textureNumber = texno;
// add frame to sprite
s.Frames.push_back(f);
s.frameTime = 0;
// add rectangle to sprite bank
SpriteBank->getPositions().push_back(rectangle);
a.width = rectangle.getWidth();
// add sprite to sprite bank
SpriteBank->getSprites().push_back(s);
// add character to font
Areas.push_back(a);
}
}
}
}
public:
bool m_black_border;
ScalableFont* m_fallback_font;
float m_fallback_font_scale;
int m_fallback_kerning_width;
//! constructor
ScalableFont(gui::IGUIEnvironment *env, const io::path& filename)
: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0),
MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0)
{
#ifdef _DEBUG
setDebugName("ScalableFont");
#endif
m_fallback_font = NULL;
m_fallback_kerning_width = 0;
m_fallback_font_scale = 1.0f;
m_scale = 0.37f;
m_black_border = false;
if (Environment)
{
// don't grab environment, to avoid circular references
Driver = Environment->getVideoDriver();
SpriteBank = Environment->addEmptySpriteBank(filename);
if (SpriteBank)
SpriteBank->grab();
}
if (Driver)
Driver->grab();
setInvisibleCharacters ( L" " );
io::IXMLReader* reader = env->getFileSystem()->createXMLReader(filename.c_str());
if (reader)
{
load( reader );
reader->drop();
}
assert_log(Areas.size() > 0);
}
//! destructor
virtual ~ScalableFont()
{
if (Driver)
Driver->drop();
if (SpriteBank)
SpriteBank->drop();
}
//! loads a font from an XML file
bool load(io::IXMLReader* xml)
{
if (!SpriteBank)
return false;
doReadXmlFile(xml);
// set bad character
WrongCharacter = getAreaIDFromCharacter(L' ', NULL);
setMaxHeight();
for(wchar_t c='0'; c<='9'; c++)
{
SFontArea a = getAreaFromCharacter(c, NULL);
if (a.overhang > m_max_digit_area.overhang ) m_max_digit_area.overhang = a.overhang;
if (a.underhang > m_max_digit_area.underhang) m_max_digit_area.underhang = a.underhang;
if (a.width > m_max_digit_area.width) m_max_digit_area.width = a.width;
}
m_max_digit_area.overhang = 0;
m_max_digit_area.underhang=0;
return true;
}
//! draws an text and clips it to the specified rectangle if wanted
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
video::SColor color, bool hcenter=false,
bool vcenter=false, const core::rect<s32>* clip=0)
{
if (!Driver) return;
core::position2d<s32> offset = position.UpperLeftCorner;
core::dimension2d<s32> text_dimension;
// When we use the "tab" hack, disable right-alignment, it messes up everything
// bool has_tab = (text.findFirst(L'\t') != -1);
// ---- collect character locations
const unsigned int text_size = text.size();
core::array<s32> indices(text_size);
core::array<core::position2di> offsets(text_size);
core::array<bool> fallback;
fallback.set_used(text_size);
for (u32 i = 0; i<text_size; i++)
{
wchar_t c = text[i];
//hack: one tab character is supported, it moves the cursor to the middle of the area
if (c == L'\t')
{
offset.X = position.UpperLeftCorner.X + position.getWidth()/2;
continue;
}
if (c == L'\r' || // Windows breaks
c == L'\n') // Unix breaks
{
if (c==L'\r' && text[i+1]==L'\n')
c = text[++i];
offset.Y += (int)(MaxHeight*m_scale);
offset.X = position.UpperLeftCorner.X;
if (hcenter)
offset.X += (position.getWidth() - text_dimension.Width) >> 1;
continue;
} // if lineBreak
bool use_fallback_font = false;
const SFontArea &area = getAreaFromCharacter(c, &use_fallback_font);
fallback[i] = use_fallback_font;
offset.X += area.underhang;
offsets.push_back(offset);
// Invisible character. add something to the array anyway so that
// indices from the various arrays remain in sync
indices.push_back((Invisible.findFirst(c) < 0) ? (int)area.spriteno
: -1);
offset.X += getCharWidth(area, fallback[i]);
} // for i<text_size
// ---- do the actual rendering
const int indiceAmount = indices.size();
core::array< gui::SGUISprite >& sprites = SpriteBank->getSprites();
core::array< core::rect<s32> >& positions = SpriteBank->getPositions();
core::array< gui::SGUISprite >* fallback_sprites;
core::array< core::rect<s32> >* fallback_positions;
if (m_fallback_font!=NULL)
{
fallback_sprites = &m_fallback_font->SpriteBank->getSprites();
fallback_positions = &m_fallback_font->SpriteBank->getPositions();
}
else
{
fallback_sprites = NULL;
fallback_positions = NULL;
}
video::IVideoDriver* driver = Environment->getVideoDriver();
const int spriteAmount = sprites.size();
for (int n=0; n<indiceAmount; n++)
{
const int spriteID = indices[n];
if (!fallback[n] && (spriteID < 0 || spriteID >= spriteAmount))
continue;
if (indices[n] == -1)
continue;
//assert_log(sprites[spriteID].Frames.size() > 0);
const int texID = (fallback[n] ?
(*fallback_sprites)[spriteID].Frames[0].textureNumber :
sprites[spriteID].Frames[0].textureNumber);
core::rect<s32> source = (fallback[n] ?
(*fallback_positions)[(*fallback_sprites)[spriteID].Frames[0].rectNumber] :
positions[sprites[spriteID].Frames[0].rectNumber]);
const TextureInfo& info = (fallback[n] ?
(*(m_fallback_font->m_texture_files.find(texID))).second :
(*(m_texture_files.find(texID))).second);
float char_scale = info.m_scale;
core::dimension2d<s32> size = source.getSize();
float scale = (fallback[n] ? m_scale*m_fallback_font_scale : m_scale);
size.Width = (int)(size.Width * scale * char_scale);
size.Height = (int)(size.Height * scale * char_scale);
// align vertically if character is smaller
int y_shift = (size.Height < MaxHeight*m_scale ? (int)((MaxHeight*m_scale - size.Height)/2.0f) : 0);
core::rect<s32> dest(offsets[n] + core::position2di(0, y_shift), size);
video::SColor colors[] = {color, color, color, color};
video::ITexture* texture = (fallback[n] ?
m_fallback_font->SpriteBank->getTexture(texID) :
SpriteBank->getTexture(texID) );
if (texture == NULL)
{
// perform lazy loading
if (fallback[n])
{
m_fallback_font->lazyLoadTexture(texID);
texture = m_fallback_font->SpriteBank->getTexture(texID);
}
else
{
lazyLoadTexture(texID);
texture = SpriteBank->getTexture(texID);
}
if (texture == NULL)
{
continue; // no such character
}
}
if (m_black_border)
{
// draw black border
video::SColor black(color.getAlpha(),0,0,0);
video::SColor black_colors[] = {black, black, black, black};
for (int x_delta=-2; x_delta<=2; x_delta++)
{
for (int y_delta=-2; y_delta<=2; y_delta++)
{
if (x_delta == 0 || y_delta == 0) continue;
driver->draw2DImage(texture,
dest + core::position2d<s32>(x_delta, y_delta),
source,
clip,
black_colors, true);
}
}
}
if (fallback[n])
{
// draw text over
static video::SColor orange(color.getAlpha(), 255, 100, 0);
static video::SColor yellow(color.getAlpha(), 255, 220, 15);
video::SColor title_colors[] = {yellow, orange, orange, yellow};
driver->draw2DImage(texture,
dest,
source,
clip,
title_colors, true);
}
else
{
driver->draw2DImage(texture,
dest,
source,
clip,
colors, true);
}
}
}
//! returns the dimension of a text
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const
{
assert_log(Areas.size() > 0);
core::dimension2d<u32> dim(0, 0);
core::dimension2d<u32> thisLine(0, (int)(MaxHeight*m_scale));
for (const wchar_t* p = text; *p; ++p)
{
if (*p == L'\r' || // Windows breaks
*p == L'\n') // Unix breaks
{
if (*p==L'\r' && p[1] == L'\n') // Windows breaks
++p;
dim.Height += thisLine.Height;
if (dim.Width < thisLine.Width)
dim.Width = thisLine.Width;
thisLine.Width = 0;
continue;
}
bool fallback = false;
const SFontArea &area = getAreaFromCharacter(*p, &fallback);
thisLine.Width += area.underhang;
thisLine.Width += getCharWidth(area, fallback);
}
dim.Height += thisLine.Height;
if (dim.Width < thisLine.Width) dim.Width = thisLine.Width;
// std::cout << "ScalableFont::getDimension returns : " << dim.Width << ", " << dim.Height << " --> ";
dim.Width = (int)(dim.Width + 0.9f); // round up
dim.Height = (int)(dim.Height + 0.9f);
//std::cout << dim.Width << ", " << dim.Height << std::endl;
return dim;
}
//! Calculates the index of the character in the text which is on a specific position.
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const
{
s32 x = 0;
s32 idx = 0;
while (text[idx])
{
const SFontArea& a = Areas[getAreaIDFromCharacter(text[idx], NULL)];
x += a.width + a.overhang + a.underhang + GlobalKerningWidth;
if (x >= pixel_x)
return idx;
++idx;
}
return -1;
}
//! Returns the type of this font
virtual gui::EGUI_FONT_TYPE getType() const { return gui::EGFT_BITMAP; }
//! set an Pixel Offset on Drawing ( scale position on width )
virtual void setKerningWidth (s32 kerning)
{
GlobalKerningWidth = kerning;
}
virtual void setKerningHeight (s32 kerning)
{
GlobalKerningHeight = kerning;
}
//! set an Pixel Offset on Drawing ( scale position on width )
virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const
{
s32 ret = GlobalKerningWidth;
if (thisLetter)
{
ret += Areas[getAreaIDFromCharacter(*thisLetter, NULL)].overhang;
if (previousLetter)
{
ret += Areas[getAreaIDFromCharacter(*previousLetter, NULL)].underhang;
}
}
return ret;
}
virtual s32 getKerningHeight() const
{
return GlobalKerningHeight;
}
//! gets the sprite bank
virtual gui::IGUISpriteBank* getSpriteBank() const
{
return SpriteBank;
}
//! returns the sprite number from a given character
virtual u32 getSpriteNoFromChar(const wchar_t *c) const
{
return Areas[getAreaIDFromCharacter(*c, NULL)].spriteno;
}
virtual void setInvisibleCharacters( const wchar_t *s )
{
Invisible = s;
}
private:
struct SFontArea
{
SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}
s32 underhang;
s32 overhang;
s32 width;
u32 spriteno;
};
int getCharWidth(const SFontArea& area, const bool fallback) const
{
core::array< gui::SGUISprite >& sprites = SpriteBank->getSprites();
core::array< gui::SGUISprite >* fallback_sprites = (m_fallback_font != NULL ?
&m_fallback_font->SpriteBank->getSprites() :
NULL);
const int texID = (fallback ?
(*fallback_sprites)[area.spriteno].Frames[0].textureNumber :
sprites[area.spriteno].Frames[0].textureNumber);
const TextureInfo& info = (fallback ?
(*(m_fallback_font->m_texture_files.find(texID))).second :
(*(m_texture_files.find(texID))).second);
const float char_scale = info.m_scale;
//std::cout << "area.spriteno=" << area.spriteno << ", char_scale=" << char_scale << std::endl;
if (fallback)
return (int)(((area.width + area.overhang)*m_fallback_font_scale + m_fallback_kerning_width) * m_scale * char_scale);
else
return (int)((area.width + area.overhang + GlobalKerningWidth) * m_scale * char_scale);
}
s32 getAreaIDFromCharacter(const wchar_t c, bool* fallback_font) const
{
std::map<wchar_t, s32>::const_iterator n = CharacterMap.find(c);
if (n != CharacterMap.end())
{
if (fallback_font != NULL)
*fallback_font = false;
return (*n).second;
}
else if (m_fallback_font != NULL && fallback_font != NULL)
{
*fallback_font = true;
return m_fallback_font->getAreaIDFromCharacter(c, NULL);
}
else
{
// std::cout << "The font does not have this character : <" << (int)c << ">" << std::endl;
if (fallback_font != NULL)
*fallback_font = false;
return WrongCharacter;
}
}
const SFontArea &getAreaFromCharacter(const wchar_t c, bool* fallback_font) const
{
const int area_id = getAreaIDFromCharacter(c, fallback_font);
const bool use_fallback_font = (fallback_font && *fallback_font);
// Note: fallback_font can be NULL
return ( use_fallback_font ? m_fallback_font->Areas[area_id] : Areas[area_id]);
} // getAreaFromCharacter
void setMaxHeight()
{
// FIXME: should consider per-texture scaling
MaxHeight = 0;
s32 t;
core::array< core::rect<s32> >& p = SpriteBank->getPositions();
for (u32 i=0; i<p.size(); ++i)
{
t = p[i].getHeight();
if (t>MaxHeight)
MaxHeight = t;
}
}
core::array<SFontArea> Areas;
/** The maximum values of all digits, used in monospace_digits. */
mutable SFontArea m_max_digit_area;
std::map<wchar_t, s32> CharacterMap;
video::IVideoDriver* Driver;
gui::IGUISpriteBank* SpriteBank;
gui::IGUIEnvironment* Environment;
u32 WrongCharacter;
s32 MaxHeight;
s32 GlobalKerningWidth, GlobalKerningHeight;
core::stringw Invisible;
};
}
// The actual bug that was behind this issue was the combination of
// 2d rendering and mipmaps. The issue was reproduced using the special
// draw2dimage version, hence the name.
static bool draw2DImage4c(video::E_DRIVER_TYPE type)
{
IrrlichtDevice *device = createDevice(type, core::dimension2d<u32>(240, 120));
if (!device)
return true; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
if (!driver->queryFeature(video::EVDF_BILINEAR_FILTER))
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS,true);
driver->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY,true);
video::ITexture* images = driver->getTexture("../media/2ddemo.png");
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
core::rect<s32> imp1(349,15,385,78);
core::rect<s32> imp2(387,15,423,78);
// font cannot handle loading from sub-dirs
io::path cwd = device->getFileSystem()->getWorkingDirectory();
device->getFileSystem()->changeWorkingDirectoryTo("media");
ScalableFont* font = new ScalableFont(device->getGUIEnvironment(), "title_font.xml");
font->m_fallback_font_scale = 4.0f;
font->m_fallback_kerning_width = 15;
font->setKerningWidth(-18);
font->m_black_border = true;
/*
Prepare a nicely filtering 2d render mode for special cases.
*/
driver->getMaterial2D().UseMipMaps = true;
driver->getMaterial2D().TextureLayer[0].BilinearFilter = true;
{
driver->beginScene(true, true, video::SColor(255,120,102,136));
driver->enableMaterial2D();
// draw fire & dragons background world
driver->draw2DImage(images, core::position2di(),
core::rect<s32>(0,0,342,224), 0,
video::SColor(255,255,255,255), true);
// draw flying imp
driver->draw2DImage(images, core::position2d<s32>(114,75),
imp1, 0, video::SColor(255,255,255,255), true);
// draw second flying imp
driver->draw2DImage(images, core::position2d<s32>(220,55),
imp2, 0, video::SColor(255,255,255,255), true);
driver->draw2DImage(images, core::rect<s32>(10,10,108,48),
core::rect<s32>(354,87,442,118));
video::SColor colors[] = {0xff00ffff, 0xff00ffff, 0xffffff00, 0xffffff00};
driver->draw2DImage(images, core::recti(10,50,108,88),
core::recti(354,87,442,118), 0, colors, true);
font->draw( L"WXYZsSdDrRjJbB", core::rect<s32>(30,20,300,300),
video::SColor(255,255,255,255) );
driver->enableMaterial2D(false);
driver->draw2DImage(images, core::recti(10,90,108,128),
core::recti(354,87,442,118), 0, colors, true);
font->draw( L"WXYZsSdDrRjJbB", core::rect<s32>(30,60,300,400),
video::SColor(255,255,255,255) );
driver->endScene();
}
font->drop();
device->getFileSystem()->changeWorkingDirectoryTo(cwd);
// don't go under 99% as the difference is not very large
bool result = takeScreenshotAndCompareAgainstReference(driver, "-draw2DImage4cFilter.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
// This test renders a 3d scene and a gui on top of it. The GUI is
// filtered via 2dmaterial (blurred).
// TODO: Works only for OpenGL right now
static bool addBlend2d(video::E_DRIVER_TYPE type)
{
SIrrlichtCreationParameters params;
params.AntiAlias = 0;
params.Bits = 32;
params.WindowSize = core::dimension2d<u32>(160, 120);
params.DriverType = type;
IrrlichtDevice *device = createDeviceEx(params);
if (!device)
return true; // in case the driver type does not exist
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
if (!driver->queryFeature(video::EVDF_BILINEAR_FILTER))
{
device->closeDevice();
device->run();
device->drop();
return true;
}
logTestString("Testing driver %ls\n", driver->getName());
scene::IAnimatedMesh* mesh = smgr->getMesh("../media/sydney.md2");
if (!mesh)
{
device->closeDevice();
device->run();
device->drop();
return false;
}
stabilizeScreenBackground(driver);
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../media/sydney.bmp") );
}
smgr->addCameraSceneNode(0, core::vector3df(0,30,-40), core::vector3df(0,5,0));
gui::IGUIEnvironment* env = device->getGUIEnvironment();
{
// create the toolbox window
gui::IGUIWindow* wnd = env->addWindow(core::rect<s32>(0,0,800,480),
false, L"Toolset", 0, 100);
// create tab control and tabs
gui::IGUITabControl* tab = env->addTabControl(
core::rect<s32>(2,20,800-602,480-7), wnd, true, true);
gui::IGUITab* t1 = tab->addTab(L"Config");
// add some edit boxes and a button to tab one
env->addImage(driver->getTexture("../media/tools.png"), core::vector2d<s32>(10,20), true, t1);
env->addStaticText(L"X:", core::rect<s32>(22,48,40,66), false, false, t1);
env->addEditBox(L"1.0", core::rect<s32>(40,46,130,66), true, t1, 201);
// quick scale buttons
env->addButton(core::rect<s32>(65,20,95,40), t1, 102, L"* 10");
env->addButton(core::rect<s32>(100,20,130,40), t1, 103, L"* 0.1");
}
video::SMaterial& material2D = driver->getMaterial2D();
for (unsigned int n=0; n<video::MATERIAL_MAX_TEXTURES; n++)
{
material2D.TextureLayer[n].BilinearFilter = true;
material2D.TextureLayer[n].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
material2D.TextureLayer[n].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
}
material2D.AntiAliasing=video::EAAM_FULL_BASIC;
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
driver->enableMaterial2D();
env->drawAll();
driver->enableMaterial2D(false);
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-addBlend2D.png", 98.2f);
device->closeDevice();
device->run();
device->drop();
return result;
}
// This test renders 4 times the same image. Two via IGUIImage, two via draw2DImage
// 3 of the 4 images are filtered via 2dmaterial and bilinear filter, only the one
// at the bottom left is not.
static bool moreFilterTests(video::E_DRIVER_TYPE type)
{
IrrlichtDevice* device = irr::createDevice(type, core::dimension2du(160,120));
if (!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
if (!driver->queryFeature(video::EVDF_BILINEAR_FILTER))
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
video::ITexture* tex = driver->getTexture("../media/irrlichtlogo.jpg");
gui::IGUIImage* image = gui->addImage(core::recti(0,0,64,64));
image->setScaleImage(true);
image->setImage(tex);
image->setUseAlphaChannel(true);
driver->getMaterial2D().TextureLayer[0].BilinearFilter=true;
driver->getMaterial2D().TextureLayer[0].TrilinearFilter=true;
{
driver->beginScene(true, true, irr::video::SColor(255,255,255,255));
// all three logos should be with filtering
driver->enableMaterial2D();
driver->getMaterial2D().setTexture(0, 0);
driver->draw2DImage(tex, irr::core::rect<irr::s32>(64, 64, 128, 128), irr::core::rect<irr::s32>(0, 0, 88, 31));
driver->getMaterial2D().setTexture(0, tex);
driver->draw2DImage(tex, irr::core::rect<irr::s32>(64, 0, 128, 64), irr::core::rect<irr::s32>(0, 0, 88, 31));
gui->drawAll();
// the next gui image should be without filter
driver->enableMaterial2D(false);
image->setRelativePosition(core::recti(0,64,64,128));
gui->drawAll();
driver->endScene();
}
bool result = takeScreenshotAndCompareAgainstReference(driver, "-2dmatFilter.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
bool twodmaterial()
{
bool result = true;
TestWithAllDrivers(addBlend2d);
TestWithAllDrivers(moreFilterTests);
TestWithAllDrivers(draw2DImage4c);
return result;
}

View File

@ -1,49 +0,0 @@
# Irrlicht Engine Regression Tests Makefile
Target = tests
Sources = $(wildcard *.cpp)
CPPFLAGS = -I../include -I/usr/X11R6/include -pipe
# CXXFLAGS += -O3
CXXFLAGS += -Wall -ansi -pedantic -O0 -g -D_DEBUG -fno-exceptions
ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64
endif
all: all_linux
# target specific settings
all_linux: SYSTEM=Linux
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../lib/$(SYSTEM) -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -lXcursor
all_win32 clean_win32: SYSTEM=Win32-gcc
all_win32: LDFLAGS = -L../lib/$(SYSTEM) -lIrrlicht -lopengl32 -lm
all_win32 clean_win32: SUF=.exe
# name of the binary - only valid for targets which set SYSTEM
DESTPATH = ../bin/$(SYSTEM)/$(Target)$(SUF)
OBJ = $(Sources:.cpp=.o)
all_linux all_win32: $(OBJ)
$(warning Building...)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $(DESTPATH) $(LDFLAGS)
@$(RM) tests # otherwise it's easy to forget to copy it and run the old binary
clean: clean_linux clean_win32
$(warning Cleaning...)
@$(RM) $(OBJ)
clean_linux clean_win32:
@$(RM) $(DESTPATH)
.PHONY: all all_win32 clean clean_linux clean_win32
# Create dependency files for automatic recompilation
%.d:%.cpp
$(CXX) $(CPPFLAGS) -MM -MF $@ $<
ifneq ($(MAKECMDGOALS),clean)
-include $(OBJ:.o=.d)
endif

View File

@ -1,74 +0,0 @@
#include "testUtils.h"
using namespace irr;
static bool testLineRendering(video::E_DRIVER_TYPE type)
{
SIrrlichtCreationParameters params;
params.AntiAlias = 2;
params.Bits = 16;
params.WindowSize = core::dimension2d<u32>(160, 120);
params.DriverType = type;
IrrlichtDevice *device = createDeviceEx(params);
if (!device)
return true; // in case the driver type does not exist
video::IVideoDriver* driver = device->getVideoDriver();
// if no AntiAliasing supported, skip this test
if (driver->getDriverAttributes().getAttributeAsInt("AntiAlias")<2)
{
device->closeDevice();
device->run();
device->drop();
return true;
}
logTestString("Testing driver %ls\n", driver->getName());
scene::ISceneManager* smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = smgr->getMesh("./media/sydney.md2");
if (!mesh)
{
device->closeDevice();
device->run();
device->drop();
return false;
}
stabilizeScreenBackground(driver);
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("./media/sydney.bmp") );
}
smgr->addCameraSceneNode(0, core::vector3df(0,30,-40), core::vector3df(0,5,0));
device->getTimer()->setTime(0); // scene has animations and current scene seems to be saved at that time
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
driver->draw3DBox(node->getBoundingBox(), video::SColor(0,255,0,0));
driver->draw2DLine(core::position2di(10,10), core::position2di(100,100), video::SColor(255,0,0,0));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-lineAntiAliasing.png", 99.4f );
device->closeDevice();
device->run();
device->drop();
return result;
}
bool antiAliasing()
{
bool result = true;
TestWithAllHWDrivers(testLineRendering);
return result;
}

View File

@ -1,469 +0,0 @@
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace io;
namespace
{
bool testArchive(IFileSystem* fs, const io::path& archiveName)
{
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
{
logTestString("Already mounted archives found\n");
return false;
}
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting archive failed\n");
return false;
}
// make sure there is an archive mounted
if ( !fs->getFileArchiveCount() )
{
logTestString("Mounted archive not in list\n");
return false;
}
// mount again
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting a second time failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
// make sure there is exactly one archive mounted
if ( fs->getFileArchiveCount() != 1 )
{
logTestString("Duplicate mount not recognized\n");
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (fs->getFileArchive(0)->getType()==io::EFAT_FOLDER)
{
// mount again with different path end symbol (either with slash or without)
core::stringc newArchiveName=archiveName;
if (archiveName.lastChar()=='/')
newArchiveName.erase(newArchiveName.size()-1);
else
newArchiveName.append('/');
if ( !fs->addFileArchive(newArchiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting a second time with different name failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
// make sure there is exactly one archive mounted
if ( fs->getFileArchiveCount() != 1 )
{
logTestString("Duplicate mount with different filename not recognized\n");
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
}
#if 0
// log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
const io::IFileList* fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f)
{
logTestString("File name: %s\n", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
logTestString("ID: %d\n", fileList->getID(f));
}
#endif
io::path filename("mypath/mypath/myfile.txt");
if (!fs->existFile(filename))
{
logTestString("existFile with deep path failed\n");
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
const char* names[] = {"test/test.txt", "mypath/myfile.txt", "mypath/mypath/myfile.txt"};
const char* basenames[] = {"test.txt", "myfile.txt", "myfile.txt"};
const char* content[] = {"Hello world!", "1est\n", "2est"};
for (u32 i=0; i<3; ++i)
{
if (!fs->existFile(names[i]))
{
logTestString("existFile failed\n");
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
IReadFile* readFile = fs->createAndOpenFile(names[i]);
if (!readFile)
{
logTestString("createAndOpenFile failed\n");
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (fs->getFileBasename(readFile->getFileName()) != basenames[i])
{
logTestString("Wrong filename, file list seems to be corrupt\n");
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
readFile->drop();
return false;
}
char tmp[13] = {'\0'};
readFile->read(tmp, 12);
if (strcmp(tmp, content[i]))
{
logTestString("Read bad data from archive: %s\n", tmp);
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
readFile->drop();
return false;
}
readFile->drop();
}
if (!fs->removeFileArchive(fs->getFileArchiveCount()-1))
{
logTestString("Couldn't remove archive.\n");
return false;
}
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
return false;
return true;
}
bool testEncryptedZip(IFileSystem* fs)
{
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
{
logTestString("Already mounted archives found\n");
return false;
}
const char* archiveName = "media/enc.zip";
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting archive failed\n");
return false;
}
// make sure there is an archive mounted
if ( !fs->getFileArchiveCount() )
{
logTestString("Mounted archive not in list\n");
return false;
}
// mount again
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting a second time failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
// make sure there is exactly one archive mounted
if ( fs->getFileArchiveCount() != 1 )
{
logTestString("Duplicate mount not recognized\n");
while (fs->getFileArchiveCount())
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
// log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
io::path filename("doc");
const io::IFileList* fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f)
{
logTestString("%s name: %s\n", fileList->isDirectory(f)?"Directory":"File", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
}
if (fileList->findFile(filename) != -1)
{
logTestString("findFile wrongly succeeded on directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (fileList->findFile(filename, true)==-1)
{
logTestString("findFile failed on directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
filename="doc/readme.txt";
if (fileList->findFile(filename)==-1)
{
logTestString("findFile failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (fileList->findFile(filename, true) != -1)
{
logTestString("findFile wrongly succeeded on non-directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
if (!fs->existFile(filename))
{
logTestString("existFile failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
filename="doc";
if (fs->existFile(filename))
{
logTestString("existFile succeeded wrongly on directory\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
filename="doc/readme.txt";
IReadFile* readFile = fs->createAndOpenFile(filename);
if ( readFile )
{
logTestString("createAndOpenFile succeeded, even though no password was set.\n");
readFile->drop();
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
archive->Password="33445";
readFile = fs->createAndOpenFile(filename);
#ifdef _IRR_COMPILE_WITH_ZIP_ENCRYPTION_
if ( !readFile )
{
logTestString("createAndOpenFile failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
char tmp[13] = {'\0'};
readFile->read(tmp, 12);
readFile->drop();
if (strncmp(tmp, "Linux Users:", 12))
{
logTestString("Read bad data from archive: %s\n", tmp);
return false;
}
#endif
if (!fs->removeFileArchive(fs->getFileArchiveCount()-1))
{
logTestString("Couldn't remove archive.\n");
return false;
}
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
return false;
return true;
}
bool testSpecialZip(IFileSystem* fs, const char* archiveName, const char* filename, const void* content)
{
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
{
logTestString("Already mounted archives found\n");
return false;
}
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting archive failed\n");
return false;
}
// make sure there is an archive mounted
if ( !fs->getFileArchiveCount() )
{
logTestString("Mounted archive not in list\n");
return false;
}
// log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
const io::IFileList* fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f)
{
logTestString("%s name: %s\n", fileList->isDirectory(f)?"Directory":"File", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
}
if (!fs->existFile(filename))
{
logTestString("existFile failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
IReadFile* readFile = fs->createAndOpenFile(filename);
if ( !readFile )
{
logTestString("createAndOpenFile failed\n");
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
char tmp[6] = {'\0'};
readFile->read(tmp, 5);
if (memcmp(tmp, content, 5))
{
logTestString("Read bad data from archive: %s\n", tmp);
readFile->drop();
fs->removeFileArchive(fs->getFileArchiveCount()-1);
return false;
}
readFile->drop();
if (!fs->removeFileArchive(fs->getFileArchiveCount()-1))
{
logTestString("Couldn't remove archive.\n");
return false;
}
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
return false;
return true;
}
static bool testMountFile(IFileSystem* fs)
{
bool result = true;
#if 1
fs->changeWorkingDirectoryTo("empty");
// log what we got
const io::IFileList* fileList = fs->createFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f)
{
logTestString("File name: %s\n", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
logTestString("ID: %d\n", fileList->getID(f));
}
fileList->drop();
fs->changeWorkingDirectoryTo("..");
#endif
if (!fs->addFileArchive("empty"), false)
result = false;
const IFileList* list = fs->getFileArchive(0)->getFileList();
#if 1
// log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f)
{
logTestString("File name: %s\n", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
logTestString("ID: %d\n", fileList->getID(f));
}
#endif
if (list->getFileName(0) != "burnings video 0.39b.png")
result = false;
return result;
}
bool testAddRemove(IFileSystem* fs, const io::path& archiveName)
{
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
{
logTestString("Already mounted archives found\n");
return false;
}
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting archive failed\n");
return false;
}
// make sure there is an archive mounted
if ( !fs->getFileArchiveCount() )
{
logTestString("Mounted archive not in list\n");
return false;
}
if (!fs->removeFileArchive(archiveName))
{
logTestString("Couldn't remove archive.\n");
return false;
}
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
return false;
return true;
}
}
bool archiveReader()
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert_log(device);
if(!device)
return false;
io::IFileSystem * fs = device->getFileSystem ();
if ( !fs )
return false;
bool ret = true;
logTestString("Testing mount file.\n");
ret &= testArchive(fs, "media/file_with_path");
logTestString("Testing mount file.\n");
ret &= testArchive(fs, "media/file_with_path/");
logTestString("Testing zip files.\n");
ret &= testArchive(fs, "media/file_with_path.zip");
logTestString("Testing pak files.\n");
ret &= testArchive(fs, "media/sample_pakfile.pak");
logTestString("Testing npk files.\n");
ret &= testArchive(fs, "media/file_with_path.npk");
logTestString("Testing encrypted zip files.\n");
ret &= testEncryptedZip(fs);
logTestString("Testing special zip files.\n");
ret &= testSpecialZip(fs, "media/Monty.zip", "monty/license.txt", "Monty");
logTestString("Testing special zip files lzma.\n");
const u8 buf[] = {0xff, 0xfe, 0x3c, 0x00, 0x3f};
ret &= testSpecialZip(fs, "media/lzmadata.zip", "tahoma10_.xml", buf);
// logTestString("Testing complex mount file.\n");
// ret &= testMountFile(fs);
logTestString("Testing add/remove with filenames.\n");
ret &= testAddRemove(fs, "media/file_with_path.zip");
device->closeDevice();
device->run();
device->drop();
return ret;
}

View File

@ -1,87 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
// Tests B3D animations.
bool b3dAnimation(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
assert_log(device);
if (!device)
return false;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
scene::ISkinnedMesh* mesh = (scene::ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d");
assert_log(mesh);
bool result = false;
if (!mesh)
return false;
scene::IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh);
assert_log(node1);
/** Verify that two skinned animated mesh scene nodes can use different frames of the skinned mesh */
if(node1)
{
node1->setPosition(core::vector3df(-3, -3, 10));
node1->setMaterialFlag(video::EMF_LIGHTING, false);
node1->setAnimationSpeed(0.f);
node1->setCurrentFrame(10.f);
node1->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS);
}
scene::IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh);
assert_log(node2);
if(node2)
{
node2->setPosition(core::vector3df(3, -3, 10));
node2->setMaterialFlag(video::EMF_LIGHTING, false);
node2->setAnimationSpeed(0.f);
node2->setCurrentFrame(62.f);
node2->setDebugDataVisible(scene::EDS_BBOX_BUFFERS);
}
(void)smgr->addCameraSceneNode();
// Just jump to the last frame since that's all we're interested in.
device->run();
driver->beginScene(true, true, video::SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-b3dAnimation.png");
if (node2)
node2->remove();
/** Now test if bones are correctly positioned. */
node1->setDebugDataVisible(scene::EDS_SKELETON);
node1->setPosition(core::vector3df(1,-5,8));
node1->setRotation(core::vector3df(0,180,0));
node1->updateAbsolutePosition();
for (u32 i=0; i<node1->getJointCount(); ++i)
{
smgr->addCubeSceneNode(1.f,0,-1,node1->getJointNode(i)->getAbsolutePosition());
// smgr->addCubeSceneNode(1.f,node1->getJointNode(i));
}
// Simple render call
device->run();
driver->beginScene(true, true, video::SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result &= takeScreenshotAndCompareAgainstReference(driver, "-b3dJointPosition.png");
device->closeDevice();
device->run();
device->drop();
return result;
}

View File

@ -1,156 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
namespace
{
// Test billboard sizing
bool billboardSize(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
assert_log(device);
if (!device)
return false;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
smgr->addCameraSceneNode();
scene::IBillboardSceneNode* bill = smgr->addBillboardSceneNode();
bill->setPosition(core::vector3df(0,0,50));
bill = smgr->addBillboardSceneNode();
bill->setPosition(core::vector3df(-30,0,50));
bill->getMaterial(0).Lighting=false;
bill = smgr->addBillboardSceneNode();
bill->setPosition(core::vector3df(30,0,50));
bill->getMaterial(0).Lighting=false;
bill->getMaterial(0).Wireframe=true;
bill = smgr->addBillboardSceneNode();
bill->setPosition(core::vector3df(30,0,50));
bill->setSize(2,2,2);
bill = smgr->addBillboardSceneNode();
bill->setSize(10,20,2);
bill->setPosition(core::vector3df(0,30,50));
bill = smgr->addBillboardSceneNode();
bill->setSize(10,2,20);
bill->setPosition(core::vector3df(-30,30,50));
bill->getMaterial(0).Lighting=false;
bill = smgr->addBillboardSceneNode();
bill->setSize(10,2,20);
bill->setPosition(core::vector3df(30,30,50));
bill->getMaterial(0).Lighting=false;
bill->getMaterial(0).Wireframe=true;
bill = smgr->addBillboardSceneNode();
bill->setPosition(core::vector3df(30,30,50));
bill->setSize(2,2,2);
video::ITexture* tex = driver->getTexture("../media/fireball.bmp");
bill = smgr->addBillboardSceneNode();
bill->getMaterial(0).Lighting=false;
bill->getMaterial(0).TextureLayer[0].AnisotropicFilter=true;
bill->getMaterial(0).setTexture(0, tex);
bill->setSize(10,20,2);
bill->setPosition(core::vector3df(0,-30,50));
bill = smgr->addBillboardSceneNode();
bill->setSize(10,2,20);
bill->setPosition(core::vector3df(-30,-30,50));
bill->getMaterial(0).TextureLayer[0].AnisotropicFilter=true;
bill->getMaterial(0).setTexture(0, tex);
bill->getMaterial(0).Lighting=false;
bill = smgr->addBillboardSceneNode();
bill->setSize(10,2,20);
bill->setPosition(core::vector3df(30,-30,50));
bill->getMaterial(0).TextureLayer[0].AnisotropicFilter=true;
bill->getMaterial(0).setTexture(0, tex);
bill->getMaterial(0).Lighting=false;
bill->getMaterial(0).Wireframe=true;
bill = smgr->addBillboardSceneNode();
bill->setPosition(core::vector3df(30,-30,50));
bill->setSize(2,2,2);
bill = smgr->addBillboardSceneNode();
bill->getMaterial(0).Lighting=false;
bill->getMaterial(0).setTexture(0, tex);
bill->setSize(10,20,14);
bill->setPosition(core::vector3df(0,-15,50));
bill = smgr->addBillboardSceneNode();
bill->setSize(10,14,20);
bill->setPosition(core::vector3df(-30,-15,50));
bill->getMaterial(0).setTexture(0, tex);
bill->getMaterial(0).Lighting=false;
bill = smgr->addBillboardSceneNode();
bill->setSize(10,14,20);
bill->setPosition(core::vector3df(30,-15,50));
bill->getMaterial(0).setTexture(0, tex);
bill->getMaterial(0).Lighting=false;
bill->getMaterial(0).Wireframe=true;
bill = smgr->addBillboardSceneNode();
bill->setPosition(core::vector3df(30,-15,50));
bill->setSize(2,2,2);
bool result = false;
device->run();
driver->beginScene(true, true, video::SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-billboard.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
// Test billboard orientation
// Should generate a properly readable (i.e. not mirrored or flipped)
// font file display.
bool billboardOrientation(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
assert_log(device);
if (!device)
return false;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
smgr->addCameraSceneNode();
scene::IBillboardSceneNode* bill = smgr->addBillboardSceneNode(0, core::dimension2df(40,40));
bill->setPosition(core::vector3df(0,-15,10));
bill->getMaterial(0).Lighting=false;
bill->getMaterial(0).setTexture(0, driver->getTexture("../media/fontcourier.bmp"));
bool result = false;
device->run();
driver->beginScene(true, true, video::SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-billboardOrientation.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
} // end anonymous namespace
// Test billboards
bool billboards(void)
{
bool result = billboardSize();
result &= billboardOrientation();
return result;
}

View File

@ -1,40 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace scene;
using namespace video;
/** Tests the Burning Video driver */
bool burningsVideo(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
smgr->addCubeSceneNode(10.f, 0, -1, core::vector3df(0.f, 0.f, 20.f));
smgr->addCameraSceneNode();
// Test that ambient lighting works when there are no other lights in the scene
smgr->setAmbientLight(video::SColorf(.7f, .1f, .1f, 1.f));
bool result = false;
device->run();
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-ambient-lighting.png", 100);
}
device->closeDevice();
device->run();
device->drop();
return result;
}

View File

@ -1,198 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
static bool expectedCollisionCallbackPositions = true;
class CMyCollisionCallback : public ICollisionCallback
{
public:
bool onCollision(const ISceneNodeAnimatorCollisionResponse& animator)
{
const vector3df & collisionPoint = animator.getCollisionPoint();
logTestString("Collision callback at %f %f %f\n",
collisionPoint.X, collisionPoint.Y, collisionPoint.Z);
if(collisionPoint != ExpectedCollisionPoint)
{
logTestString("*** Error: collision point, expected %f %f %f\n",
ExpectedCollisionPoint.X, ExpectedCollisionPoint.Y, ExpectedCollisionPoint.Z);
expectedCollisionCallbackPositions = false;
assert_log(false);
}
const vector3df & nodePosition = animator.getCollisionResultPosition();
if(nodePosition != ExpectedNodePosition)
{
logTestString("*** Error: result position, expected %f %f %f\n",
ExpectedNodePosition.X, ExpectedNodePosition.Y, ExpectedNodePosition.Z);
expectedCollisionCallbackPositions = false;
assert_log(false);
}
if(animator.getTargetNode() != ExpectedTarget)
{
logTestString("*** Error: wrong node\n");
expectedCollisionCallbackPositions = false;
assert_log(false);
}
return ConsumeNextCollision;
}
void setNextExpectedCollision(ISceneNode* target,
const vector3df& expectedPoint,
const vector3df& expectedPosition,
bool consume)
{
ExpectedTarget = target;
ExpectedCollisionPoint = expectedPoint;
ExpectedNodePosition = expectedPosition;
ConsumeNextCollision = consume;
}
private:
ISceneNode * ExpectedTarget;
vector3df ExpectedCollisionPoint;
vector3df ExpectedNodePosition;
bool ConsumeNextCollision;
};
/** Test that collision response animator will reset itself when removed from a
scene node, so that the scene node can then be moved without the animator
jumping it back again. */
bool collisionResponseAnimator(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL);
assert_log(device);
if(!device)
return false;
ISceneManager * smgr = device->getSceneManager();
// Create 2 nodes to the left of a "wall"
ISceneNode * testNode1 = smgr->addEmptySceneNode();
ISceneNode * testNode2 = smgr->addEmptySceneNode();
testNode1->setPosition(vector3df(-50, 0,0));
testNode2->setPosition(vector3df(-50, 0,0));
// Create a "wall" node, and collision response animators for each test node.
IMeshSceneNode * wallNode = smgr->addCubeSceneNode(10.f);
ITriangleSelector * wallSelector = smgr->createTriangleSelectorFromBoundingBox(wallNode);
ISceneNodeAnimatorCollisionResponse * collisionAnimator1 =
smgr->createCollisionResponseAnimator(wallSelector,
testNode1,
vector3df(10,10,10),
vector3df(0, 0, 0));
testNode1->addAnimator(collisionAnimator1);
CMyCollisionCallback collisionCallback;
collisionAnimator1->setCollisionCallback(&collisionCallback);
collisionAnimator1->drop();
collisionAnimator1 = 0;
ISceneNodeAnimatorCollisionResponse * collisionAnimator2 =
smgr->createCollisionResponseAnimator(wallSelector,
testNode2,
vector3df(10,10,10),
vector3df(0, 0, 0));
testNode2->addAnimator(collisionAnimator2);
collisionAnimator2->setCollisionCallback(&collisionCallback);
wallSelector->drop();
// Don't drop() collisionAnimator2 since we're going to use it.
// Get the system in a good state
device->run();
smgr->drawAll();
// Try to move both nodes to the right of the wall.
// This one should be stopped by its animator.
testNode1->setPosition(vector3df(50, 0,0));
collisionCallback.setNextExpectedCollision(testNode1,
vector3df(-5.005f, 0, 0),
vector3df(-15.005f, 0, 0),
false);
// Whereas this one, by forcing the animator to update its target node, should be
// able to pass through the wall. (In <=1.6 it was stopped by the wall even if
// the animator was removed and later re-added);
testNode2->setPosition(vector3df(50, 0,0));
collisionAnimator2->setTargetNode(testNode2);
collisionAnimator2->drop(); // We're done using this now.
device->run();
smgr->drawAll();
bool result = true;
if(testNode1->getAbsolutePosition().X > -15.f)
{
logTestString("collisionResponseAnimator test node 1 wasn't stopped from moving.\n");
assert_log(false);
result = false;
}
if(testNode2->getAbsolutePosition().X < 50.f)
{
logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n");
assert_log(false);
result = false;
}
// Now try to move the second node back through the wall again. Now it should be
// stopped by the wall.
testNode2->setPosition(vector3df(-50, 0, 0));
// We'll consume this collision, so the node will actually move all the way through.
collisionCallback.setNextExpectedCollision(testNode2,
vector3df(5.005f, 0, 0),
vector3df(15.005f, 0, 0),
true);
device->run();
smgr->drawAll();
if(testNode2->getAbsolutePosition().X != -50.f)
{
logTestString("collisionResponseAnimator test node 2 was stopped from moving.\n");
assert_log(false);
result = false;
}
// Now we'll try to move it back to the right and allow it to be stopped.
collisionCallback.setNextExpectedCollision(testNode2,
vector3df(-5.005f, 0, 0),
vector3df(-15.005f, 0, 0),
false);
testNode2->setPosition(vector3df(50, 0, 0));
device->run();
smgr->drawAll();
if(testNode2->getAbsolutePosition().X > -15.f)
{
logTestString("collisionResponseAnimator test node 2 moved too far.\n");
assert_log(false);
result = false;
}
device->closeDevice();
device->run();
device->drop();
result &= expectedCollisionCallbackPositions;
return result;
}

View File

@ -1,21 +0,0 @@
#include "testUtils.h"
using namespace irr;
using namespace video;
bool rounding()
{
SColorf colf(0.003922f, 0.007843f, 0.011765f); // test-values by virion which once failed
SColor col = colf.toSColor();
return col.getRed() == 1 && col.getGreen() == 2 && col.getBlue() == 3;
}
//! Test SColor and SColorf
bool color(void)
{
bool ok = true;
ok &= rounding();
return ok;
}

View File

@ -1,75 +0,0 @@
#include "testUtils.h"
using namespace irr;
namespace
{
bool testImageCreation()
{
// create device
IrrlichtDevice *device = createDevice(video::EDT_SOFTWARE, core::dimension2d<u32>(160,120));
if (device == 0)
return true; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
video::ITexture* tex=driver->getTexture("../media/water.jpg");
video::IImage* img1=driver->createImage(tex, core::vector2di(0,0), core::dimension2du(32,32));
video::ITexture* tex1=driver->addTexture("new1", img1);
img1->drop();
img1=0;
video::IImage* img2=driver->createImage(tex, core::vector2di(0,0), tex->getSize());
video::ITexture* tex2=driver->addTexture("new2", img2);
img2->drop();
img2 = 0;
driver->beginScene(true, true, video::SColor(255,255,0,255));//Backbuffer background is pink
driver->draw2DImage(tex, core::position2d<s32>(0,0), core::recti(0,0,32,32));
driver->draw2DImage(tex1, core::position2d<s32>(32,0));
driver->draw2DImage(tex2, core::position2d<s32>(64,0), core::recti(0,0,32,32));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-createImage.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
bool testImageFormats()
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(256,128));
if (device == 0)
return true; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
video::ITexture* tex=driver->getTexture("../media/water.jpg");
video::ITexture* tex1=driver->getTexture("media/grey.tga");
driver->beginScene(true, true);
driver->draw2DImage(tex, core::position2d<s32>(0,0), core::recti(0,0,64,64));
driver->draw2DImage(tex1, core::position2d<s32>(0,64), core::recti(0,0,64,64));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-testImageFormats.png", 99.5f);
device->closeDevice();
device->run();
device->drop();
return result;
}
}
bool createImage()
{
bool result = testImageCreation();
result &= testImageFormats();
return result;
}

View File

@ -1,70 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
struct TrapMouseMoves : IEventReceiver
{
int MouseMovesReceived;
TrapMouseMoves() : MouseMovesReceived(0) { }
virtual bool OnEvent(const SEvent & event)
{
if(event.EventType == EET_MOUSE_INPUT_EVENT
&& event.MouseInput.Event == EMIE_MOUSE_MOVED)
MouseMovesReceived++;
return false;
}
};
/** This test verifies that setting the cursor visibility
only generates a mouse message when it actually changes */
bool cursorSetVisible(void)
{
IrrlichtDevice * device = createDevice(video::EDT_SOFTWARE, dimension2d<u32>(1, 1));
TrapMouseMoves moveTrapper;
device->setEventReceiver(&moveTrapper);
device->run();
gui::ICursorControl * cursor = device->getCursorControl();
// Move the cursor inside the Irrlicht window so that we get messages for it.
cursor->setPosition(0, 0);
device->run(); // Receive any messages
cursor->setVisible(false); // Should generate a mouse move
device->run(); // Receive any messages
cursor->setVisible(false); // Should not generate a mouse move
device->run(); // Receive any messages
cursor->setVisible(true); // Should generate a mouse move
device->run(); // Receive any messages
cursor->setVisible(true); // Should not generate a mouse move
device->run(); // Receive any messages
// We should get at most 3 messages: one for the setPosition(), and one for
// each actual change of visibility.
bool result = (moveTrapper.MouseMovesReceived <= 3);
device->closeDevice();
device->run();
device->drop();
if(!result)
{
logTestString("ERROR: cursorSetVisible received %d events.\n", moveTrapper.MouseMovesReceived);
assert_log(false);
}
return result;
}

View File

@ -1,84 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
/** This tests verifies that textures opened from different places in the filesystem
can be distinguished, even if they have the same filename. */
bool disambiguateTextures(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_NULL, dimension2d<u32>(640, 480));
if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
// Expects an empty tmp/tmp directory under this app's wd and
// a media directory under this apps' directory with tools.png in it.
stringc wd = device->getFileSystem()->getWorkingDirectory();
if(-1 == wd.find("/tests") && -1 == wd.find("\\tests"))
{
logTestString("The tests must be run from the /tests directory, regardless of where\n"\
"the test executable was built.\n");
device->drop();
return false;
}
IVideoDriver * driver = device->getVideoDriver();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert_log(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex2 = driver->getTexture("../media/tools.png");
assert_log(tex2);
if(!tex2)
logTestString("Unable to open ../media/tools.png\n");
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert_log(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
ITexture * tex3 = driver->getTexture(readFile);
assert_log(tex3);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
readFile->drop();
// All 3 of the above textures should be identical.
assert_log(tex1 == tex2);
assert_log(tex1 == tex3);
stringc newWd = wd + "/empty/empty";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd.c_str());
assert_log(changed);
ITexture * tex4 = driver->getTexture("../../media/tools.png");
assert_log(tex4);
if(!tex4)
logTestString("Unable to open ../../media/tools.png\n");
assert_log(tex1 != tex4);
// The working directory must be restored for the other tests to work.
changed &= device->getFileSystem()->changeWorkingDirectoryTo(wd.c_str());
device->closeDevice();
device->run();
device->drop();
return (changed && tex1 == tex2 && tex1 == tex3 && tex1 != tex4) ? true : false;
}

View File

@ -1,185 +0,0 @@
#include "testUtils.h"
using namespace irr;
namespace
{
bool testWithRenderTarget(video::E_DRIVER_TYPE driverType)
{
// create device
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(160,120));
if (device == 0)
return true; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
if (!driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
video::ITexture* RenderTarget=driver->addRenderTargetTexture(core::dimension2d<u32>(64,64), "BASEMAP");
video::ITexture *tex=driver->getTexture("../media/water.jpg");
driver->beginScene(true, true, video::SColor(255,255,0,255));//Backbuffer background is pink
//draw the 256x256 water image on the rendertarget:
driver->setRenderTarget(RenderTarget,true,true,video::SColor(255,0,0,255));//Rendertarget background is blue
driver->draw2DImage(tex, core::position2d<s32>(0,0), core::recti(0,0,32,32));
driver->setRenderTarget(0, false);
//draw the rendertarget on screen:
//this should normally draw a 64x64 image containing a 32x32 image in the top left corner
driver->draw2DImage(RenderTarget, core::position2d<s32>(0,0));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-draw2DImageRTT.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
// Test various special destination rectangles
bool testRectangles(video::E_DRIVER_TYPE driverType)
{
// create device
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(160,120));
if (device == 0)
return true; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
video::ITexture *tex=driver->getTexture("../media/fireball.bmp");
driver->beginScene(true, true, video::SColor(255,255,0,255));//Backbuffer background is pink
// draw normal, will be overdrwan in error case
driver->draw2DImage(tex, core::recti(68,32,132,96), core::recti(0,0,64,64));
//draw the image larger
driver->draw2DImage(tex, core::recti(0,0,64,64), core::recti(0,0,32,32));
//draw the image flipped horizontally
driver->draw2DImage(tex, core::recti(132,0,68,64), core::recti(0,0,64,64));
//draw the image smaller
driver->draw2DImage(tex, core::recti(0,64,32,96), core::recti(0,0,64,64));
//draw the image much smaller
driver->draw2DImage(tex, core::recti(36,64,44,72), core::recti(0,0,64,64));
//draw the image flipped horizontally
driver->draw2DImage(tex, core::recti(68,64,132,0), core::recti(0,0,64,64));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-draw2DImageRect.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
// draws a complex (interlaced, paletted, alpha) png image
bool testWithPNG(video::E_DRIVER_TYPE driverType)
{
// create device
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(160,120));
if (device == 0)
return true; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
video::ITexture *tex=driver->getTexture("media/RedbrushAlpha-0.25.png");
driver->beginScene(true, true, video::SColor(255,40,40,255));//Backbuffer background is blue
driver->draw2DImage(tex, core::recti(0,0,160,120), core::recti(0,0,256,256), 0, 0, true);
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-draw2DImagePNG.png", 98.f);
device->closeDevice();
device->run();
device->drop();
return result;
}
// draws an image and checks if the written example equals the original image
bool testExactPlacement(video::E_DRIVER_TYPE driverType)
{
// create device
IrrlichtDevice *device = createDevice(driverType, core::dimension2d<u32>(160,120), 32);
if (device == 0)
return true; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
if (driver->getColorFormat() != video::ECF_A8R8G8B8 || !driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
video::ITexture* rt=driver->addRenderTargetTexture(core::dimension2d<u32>(32,32), "rt1");
video::ITexture *tex=driver->getTexture("../media/fireball.bmp");
driver->beginScene(true, true, video::SColor(255,40,40,255));//Backbuffer background is blue
driver->setRenderTarget(rt);
driver->draw2DImage(tex, core::recti(0,0,32,32), core::recti(0,0,64,64));
driver->setRenderTarget(0);
driver->endScene();
video::IImage* img = driver->createImage(rt, core::vector2di(), rt->getSize());
driver->writeImageToFile(img, "results/fireball.png");
img->drop();
bool result = fuzzyCompareImages(driver, "media/fireball.png", "results/fireball.png")>98.25f;
device->closeDevice();
device->run();
device->drop();
return result;
}
}
bool draw2DImage()
{
bool result = true;
TestWithAllDrivers(testWithRenderTarget);
TestWithAllHWDrivers(testWithPNG);
// TODO D3D driver moves image 1 pixel top-left in case of down scaling
TestWithAllDrivers(testExactPlacement);
TestWithAllDrivers(testRectangles);
return result;
}

View File

@ -1,191 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//! Tests IVideoDriver::drawPixel().
/** Expect to see two diagonal lines overlaying a wall texture cube.
One line should run from green at the top left to red at the bottom right.
The other should run from cyan 100% transparent at the bottom left to
cyan 100% opaque at the top right. */
static bool lineRender(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
// Draw a cube background so that we can check that the pixels' alpha is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false);
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
// Test for benign handling of offscreen pixel values as well as onscreen ones.
for(s32 x = -10; x < 170; ++x)
{
s32 y = 120 * x / 160;
driver->drawPixel((u32)x, (u32)y, SColor(255, 255 * x / 640, 255 * (640 - x) / 640, 0));
y = 120 - y;
driver->drawPixel((u32)x, (u32)y, SColor(255 * x / 640, 0, 255, 255));
}
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawPixel.png", 98.81f);
device->closeDevice();
device->run();
device->drop();
return result;
}
// this test draws alternating white and black borders with
// increasing thickness. Intended use of this test is to ensure
// the corect pixel alignment within the render window.
static bool pixelAccuracy(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
device->getSceneManager()->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
u32 start=0;
for (u32 count=1; count<10; ++count)
{
for (u32 j=0; j<count; ++j)
{
for (u32 x=0; x<100-start; ++x)
{
driver->drawPixel(start+x, start, (count%2==1)?0xffffffff:0xff000000);
}
++start;
}
}
start=0;
for (u32 count=1; count<10; ++count)
{
for (u32 j=0; j<count; ++j)
{
for (u32 x=0; x<100-start; ++x)
{
driver->drawPixel(start, start+x, (count%2==1)?0xffffffff:0xff000000);
}
++start;
}
}
for (u32 x=0; x<100; ++x)
{
driver->drawPixel(x, x, 0xffff0000);
}
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-pixelAccuracy.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
// this test draws lines of different lengths and compares
// them with pixel placement
// grey pixels denote start and end of the white drawn lines
// black pixels only make those grey points better visible
// yellow and magenta lines should start and end next toa black pixel,
// yellow one right to the last black pixel down, magenta below the last
// black pixel to the right
// white lines are always double drawn, lines back and forth.
static bool drawLine(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
device->getSceneManager()->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
// horizontal lines
for (u32 i=0; i<20; ++i)
{
driver->draw2DLine(core::vector2di(10,10+3*i), core::vector2di(10+2*i,10+3*i));
// mark start point
driver->drawPixel(9,10+3*i+1, video::SColor(0xff000000));
driver->drawPixel(10,10+3*i+1, video::SColor(0xff888888));
driver->drawPixel(11,10+3*i+1, video::SColor(0xff000000));
// mark end point
driver->drawPixel(9+2*i,10+3*i+1, video::SColor(0xff000000));
driver->drawPixel(10+2*i,10+3*i+1, video::SColor(0xff888888));
driver->drawPixel(11+2*i,10+3*i+1, video::SColor(0xff000000));
driver->draw2DLine(core::vector2di(10+2*i,10+3*i+2), core::vector2di(10,10+3*i+2));
}
// vertical lines
for (u32 i=0; i<20; ++i)
{
driver->draw2DLine(core::vector2di(11+3*i,10), core::vector2di(11+3*i,10+2*i));
// mark start point
driver->drawPixel(11+3*i+1,9, video::SColor(0xff000000));
driver->drawPixel(11+3*i+1,10, video::SColor(0xff888888));
driver->drawPixel(11+3*i+1,11, video::SColor(0xff000000));
// mark end point
driver->drawPixel(11+3*i+1,9+2*i, video::SColor(0xff000000));
driver->drawPixel(11+3*i+1,10+2*i, video::SColor(0xff888888));
driver->drawPixel(11+3*i+1,11+2*i, video::SColor(0xff000000));
driver->draw2DLine(core::vector2di(11+3*i+2,10+2*i), core::vector2di(11+3*i+2, 10));
}
// diagonal lines
driver->draw2DLine(core::vector2di(14,14),core::vector2di(50,68), video::SColor(0xffffff00));
driver->draw2DLine(core::vector2di(15,14),core::vector2di(69,50), video::SColor(0xffff00ff));
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawLine.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
bool drawPixel(void)
{
bool result = true;
TestWithAllDrivers(lineRender);
TestWithAllDrivers(pixelAccuracy);
TestWithAllDrivers(drawLine);
return result;
}

View File

@ -1,54 +0,0 @@
#include "testUtils.h"
using namespace irr;
namespace
{
bool testWithDriver(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device =
createDevice(driverType, core::dimension2du(160, 120));
if (!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
driver->beginScene(true, true, video::SColor(255,100,101,140));
core::recti r;
r.UpperLeftCorner = core::position2di(1,1);
r.LowerRightCorner = core::position2di(100,100);
driver->draw2DRectangleOutline( r );
r += core::position2di( 10 , 10 );
driver->draw2DRectangleOutline( r , video::SColor(128, 255, 128, 128) );
driver->getMaterial2D().Thickness=12.f;
driver->enableMaterial2D();
r += core::position2di( 10 , 10 );
driver->draw2DRectangleOutline( r , video::SColor(128, 255, 128, 128) );
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-drawRectOutline.png", 98.5f );
device->closeDevice();
device->run();
device->drop();
return result ;
}
}
bool drawRectOutline(void)
{
// TODO: Only OpenGL supports thick lines
bool result = true;
TestWithAllDrivers(testWithDriver);
return result;
}

View File

@ -1,104 +0,0 @@
#include "testUtils.h"
using namespace irr;
namespace
{
// this test renders random point clouds using different primitives on top
// tests the primitives type support in general and can hint to differences
// between the drivers
bool testWithDriver(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device =
createDevice(driverType, core::dimension2du(160, 120));
if (!device)
return true;
scene::ISceneManager* smgr = device->getSceneManager();
video::IVideoDriver* driver = device->getVideoDriver();
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
smgr->addCameraSceneNode(0, core::vector3df(128,128,-100), core::vector3df(128,128,128));
scene::SMeshBuffer Buffer;
Buffer.Material.Wireframe = false;
Buffer.Material.Lighting = false;
Buffer.Material.FogEnable = false;
Buffer.Material.BackfaceCulling = false;
Buffer.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
device->getRandomizer()->reset();
const u32 points=256;
Buffer.Vertices.reallocate(points);
for (u32 i=0; i<points; ++i)
{
f32 x = (f32)(1+device->getRandomizer()->rand()%points);
f32 y = (f32)(1+device->getRandomizer()->rand()%points);
f32 z = (f32)(1+device->getRandomizer()->rand()%points);
video::SColor color(255, device->getRandomizer()->rand()%255, device->getRandomizer()->rand()%255, device->getRandomizer()->rand()%255);
Buffer.Vertices.push_back( video::S3DVertex(x,y,z,0,1,0,color,0,0) );
}
Buffer.recalculateBoundingBox();
for (u32 i=0; i<Buffer.Vertices.size(); ++i)
{
Buffer.Indices.push_back(i);
}
bool result = true;
for (u32 Type=scene::EPT_POINTS; Type <= scene::EPT_POINT_SPRITES; ++Type)
{
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
u32 primCount = 0;
switch (Type)
{
case scene::EPT_POINTS: primCount = Buffer.Indices.size(); break;
case scene::EPT_LINE_STRIP: primCount = Buffer.Indices.size()-1; break;
case scene::EPT_LINE_LOOP: primCount = Buffer.Indices.size()-1; break;
case scene::EPT_LINES: primCount = Buffer.Indices.size()/2; break;
case scene::EPT_TRIANGLE_STRIP: primCount = Buffer.Indices.size()-2; break;
case scene::EPT_TRIANGLE_FAN: primCount = Buffer.Indices.size()-2; break;
case scene::EPT_TRIANGLES: primCount = Buffer.Indices.size()/3; break;
case scene::EPT_QUAD_STRIP: primCount = (Buffer.Indices.size()-2)/4; break;
case scene::EPT_QUADS: primCount = Buffer.Indices.size()/4; break;
case scene::EPT_POLYGON: primCount = Buffer.Indices.size()-1; break;
case scene::EPT_POINT_SPRITES: primCount = Buffer.Indices.size(); break;
default: break;
}
// TODO: mode is buggy, but required for skybox. So driver supports it, but would core dump here.
if (driverType==video::EDT_BURNINGSVIDEO && Type==scene::EPT_TRIANGLE_FAN)
continue;
driver->setMaterial(Buffer.Material);
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
driver->drawVertexPrimitiveList(Buffer.getVertices(),
Buffer.getVertexCount(), Buffer.getIndices(), primCount,
video::EVT_STANDARD, (scene::E_PRIMITIVE_TYPE)Type,
video::EIT_16BIT);
driver->endScene();
core::stringc name = "-drawVPL_";
// we use character enumeration as we have more than 9 types
name.append(Type-scene::EPT_POINTS+'a');
name.append(".png");
result &= takeScreenshotAndCompareAgainstReference(driver, name.c_str());
}
device->closeDevice();
device->run();
device->drop();
return result ;
}
}
bool drawVertexPrimitive(void)
{
bool result = true;
TestWithAllDrivers(testWithDriver);
return result;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@ -1,133 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace scene;
using namespace video;
bool enumerateImageManipulators(void)
{
IrrlichtDevice *device = createDevice(video::EDT_NULL);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
const char* filenames[] =
{
"foo.bmp",
"foo.jpg",
"foo.pcx",
"foo.png",
"foo.ppm",
"foo.psd",
"foo.tga",
// the following have no writers
"foo.wal",
"foo.pgm",
"foo.pbm",
"foo.rgb",
"foo.rgba",
"foo.sgi",
"foo.int",
"foo.inta",
"foo.bw"
};
// how many formats have loaders?
const u32 writersUntil = 7;
const u32 numberOfFilenames = sizeof(filenames) / sizeof(filenames[0]);
bool loaderForFilename[numberOfFilenames] = { false }; // and the rest get 0 == false
bool writerForFilename[numberOfFilenames] = { false }; // and the rest get 0 == false
bool result = true;
u32 i;
const u32 loaders = driver->getImageLoaderCount();
for (i = 0; i < loaders; ++i)
{
IImageLoader * loader = driver->getImageLoader(i);
if(!loader)
{
logTestString("Failed to get image loader %d\n", i);
assert_log(false);
result = false;
}
for(u32 filename = 0; filename < numberOfFilenames; ++filename)
{
if(loader->isALoadableFileExtension(filenames[filename]))
{
loaderForFilename[filename] = true;
}
}
}
IImageLoader * loader = driver->getImageLoader(i);
assert_log(loader == 0);
if(loader)
{
logTestString("Got a loader when none was expected (%d)\n", i);
result = false;
}
for(u32 filename = 0; filename < numberOfFilenames; ++filename)
{
if(!loaderForFilename[filename])
{
logTestString("File type '%s' doesn't have a loader\n", filenames[filename]);
assert_log(false);
result = false;
}
}
const u32 writers = driver->getImageWriterCount();
for (i = 0; i < writers; ++i)
{
IImageWriter * writer = driver->getImageWriter(i);
if(!writer)
{
logTestString("Failed to get image writer %d\n", i);
assert_log(false);
result = false;
}
for(u32 filename = 0; filename < numberOfFilenames; ++filename)
{
if(writer->isAWriteableFileExtension(filenames[filename]))
{
writerForFilename[filename] = true;
break;
}
}
}
IImageWriter * writer = driver->getImageWriter(i);
assert_log(writer == 0);
if(writer)
{
logTestString("Got a writer when none was expected (%d)\n", i);
result = false;
}
for(u32 filename = 0; filename < numberOfFilenames; ++filename)
{
// There's no writer for the .WAL file type.
if(!writerForFilename[filename] && (filename<writersUntil))
{
logTestString("File type '%s' doesn't have a writer\n", filenames[filename]);
assert_log(false);
result = false;
}
}
device->closeDevice();
device->run();
device->drop();
return result;
}

View File

@ -1,17 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
//! Tests that symbols exported from Irrlicht can be used by the user app.
bool exports(void)
{
logTestString("Checking whether IdentityMatrix is exported.\n");
irr::core::matrix4 identity = irr::core::IdentityMatrix;
(void)identity; // Satisfy the compiler that it's used.
irr::video::SMaterial id = irr::video::IdentityMaterial;
(void)id; // Satisfy the compiler that it's used.
// If it built, we're done.
return true;
}

View File

@ -1,288 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
//! This was an older Irrlicht implementation, tested against for reference.
static inline u32 old_strtol10(const char* in, const char** out=0)
{
u32 value = 0;
while ( ( *in >= '0') && ( *in <= '9' ))
{
value = ( value * 10 ) + ( *in - '0' );
++in;
}
if (out)
*out = in;
return value;
}
//! This was an older Irrlicht implementation, tested against for reference.
static inline const char* old_fast_atof_move( const char* c, float& out)
{
bool inv = false;
const char *t;
float f;
if (*c=='-')
{
++c;
inv = true;
}
//f = (float)strtol(c, &t, 10);
f = (float) old_strtol10 ( c, &c );
if (*c == '.')
{
++c;
//float pl = (float)strtol(c, &t, 10);
float pl = (float) old_strtol10 ( c, &t );
pl *= fast_atof_table[t-c];
f += pl;
c = t;
if (*c == 'e')
{
++c;
//float exp = (float)strtol(c, &t, 10);
bool einv = (*c=='-');
if (einv)
++c;
float exp = (float)old_strtol10(c, &c);
if (einv)
exp *= -1.0f;
f *= (float)pow(10.0f, exp);
}
}
if (inv)
f *= -1.0f;
out = f;
return c;
}
//! This was an older Irrlicht implementation, tested against for reference.
static inline float old_fast_atof(const char* c)
{
float ret;
old_fast_atof_move(c, ret);
return ret;
}
static bool testCalculation_atof(const char * valueString)
{
const f32 newFastValue = fast_atof(valueString);
const f32 oldFastValue = old_fast_atof(valueString);
const f32 atofValue = (f32)atof(valueString);
logTestString("\n String '%s'\n New fast %.40f\n Old fast %.40f\n atof %.40f\n",
valueString, newFastValue, oldFastValue, atofValue);
const f32 diffNew = fabs(newFastValue - atofValue) ;
const f32 diffOld = fabs(newFastValue - atofValue) ;
bool accurate = diffNew <= diffOld || equalsByUlp(diffNew, diffOld, 1);
if(!accurate)
logTestString("*** ERROR - less accurate than old method ***\n\n");
return accurate;
}
static bool testCalculation_strtol(const char * valueString)
{
const s32 newFastValue = strtol10(valueString);
const s32 oldFastValue = old_strtol10(valueString);
const s32 strtolValue = (s32)clamp(strtol(valueString, 0, 10), (long int)INT_MIN, (long int)INT_MAX);
logTestString("\n String '%s'\n New fast %d\n Old fast %d\n strtol %d\n",
valueString, newFastValue, oldFastValue, strtolValue);
bool accurate = (newFastValue == strtolValue) || (oldFastValue != strtolValue);
if (!accurate)
logTestString("*** ERROR - wrong calculation in new method ***\n\n");
return accurate;
}
//! Test both the accuracy and speed of Irrlicht's fast_atof() implementation.
bool test_fast_atof(void)
{
bool accurate = true;
accurate &= testCalculation_atof("340282346638528859811704183484516925440.000000");
accurate &= testCalculation_atof("3.402823466e+38F");
accurate &= testCalculation_atof("3402823466e+29F");
accurate &= testCalculation_atof("-340282346638528859811704183484516925440.000000");
accurate &= testCalculation_atof("-3.402823466e+38F");
accurate &= testCalculation_atof("-3402823466e+29F");
accurate &= testCalculation_atof("34028234663852885981170418348451692544.000000");
accurate &= testCalculation_atof("3.402823466e+37F");
accurate &= testCalculation_atof("3402823466e+28F");
accurate &= testCalculation_atof("-34028234663852885981170418348451692544.000000");
accurate &= testCalculation_atof("-3.402823466e+37F");
accurate &= testCalculation_atof("-3402823466e+28F");
accurate &= testCalculation_atof(".00234567");
accurate &= testCalculation_atof("-.00234567");
accurate &= testCalculation_atof("0.00234567");
accurate &= testCalculation_atof("-0.00234567");
accurate &= testCalculation_atof("1.175494351e-38F");
accurate &= testCalculation_atof("1175494351e-47F");
accurate &= testCalculation_atof("1.175494351e-37F");
accurate &= testCalculation_atof("1.175494351e-36F");
accurate &= testCalculation_atof("-1.175494351e-36F");
accurate &= testCalculation_atof("123456.789");
accurate &= testCalculation_atof("-123456.789");
accurate &= testCalculation_atof("0000123456.789");
accurate &= testCalculation_atof("-0000123456.789");
accurate &= testCalculation_atof("-0.0690462109446526");
if (!accurate)
{
logTestString("Calculation is not accurate, so the speed is irrelevant\n");
return false;
}
#ifndef _DEBUG // it's only faster in release
IrrlichtDevice* device = createDevice(video::EDT_NULL);
if (!device)
return false;
ITimer* timer = device->getTimer();
const int ITERATIONS = 100000;
int i;
f32 value;
u32 then = timer->getRealTime();
for(i = 0; i < ITERATIONS; ++i)
value = (f32)atof("-340282346638528859811704183484516925440.000000");
const u32 atofTime = timer->getRealTime() - then;
then += atofTime;
for(i = 0; i < ITERATIONS; ++i)
value = fast_atof("-340282346638528859811704183484516925440.000000");
const u32 fastAtofTime = timer->getRealTime() - then;
then += fastAtofTime;
for(i = 0; i < ITERATIONS; ++i)
value = old_fast_atof("-340282346638528859811704183484516925440.000000");
const u32 oldFastAtofTime = timer->getRealTime() - then;
logTestString("Speed test\n atof time = %d\n fast_atof Time = %d\nold fast_atof time = %d\n",
atofTime, fastAtofTime, oldFastAtofTime);
device->closeDevice();
device->run();
device->drop();
if(fastAtofTime > (1.2f*atofTime))
{
logTestString("The fast method is slower than atof()\n");
return false;
}
#endif // #ifndef _DEBUG
return true;
}
//! Test both the accuracy and speed of Irrlicht's strtol10() implementation.
bool test_strtol(void)
{
bool accurate = true;
accurate &= testCalculation_strtol("340282346638528859811704183484516925440");
accurate &= testCalculation_strtol("3402823466");
accurate &= testCalculation_strtol("3402823466e+29F");
accurate &= testCalculation_strtol("-340282346638528859811704183484516925440");
accurate &= testCalculation_strtol("-3402823466");
accurate &= testCalculation_strtol("-3402823466e+29F");
accurate &= testCalculation_strtol("402823466385288598117");
accurate &= testCalculation_strtol("402823466");
accurate &= testCalculation_strtol("402823466e+28F");
accurate &= testCalculation_strtol("402823466385288598117");
accurate &= testCalculation_strtol("-402823466");
accurate &= testCalculation_strtol("-402823466e+28F");
accurate &= testCalculation_strtol(".00234567");
accurate &= testCalculation_strtol("-234567");
accurate &= testCalculation_strtol("234567");
accurate &= testCalculation_strtol("-234567");
accurate &= testCalculation_strtol("1175494351");
accurate &= testCalculation_strtol("11754943512");
accurate &= testCalculation_strtol("11754943513");
accurate &= testCalculation_strtol("11754943514");
accurate &= testCalculation_strtol("-1175494351");
accurate &= testCalculation_strtol("123456789");
accurate &= testCalculation_strtol("-123456789");
accurate &= testCalculation_strtol("123456.789");
accurate &= testCalculation_strtol("-123456.789");
accurate &= testCalculation_strtol("-109446526");
if(!accurate)
{
logTestString("Calculation is not accurate, so the speed is irrelevant\n");
return false;
}
#ifndef _DEBUG // it's only faster in release
IrrlichtDevice* device = createDevice(video::EDT_NULL);
if (!device)
return false;
ITimer* timer = device->getTimer();
const int ITERATIONS = 1000000;
int i;
s32 value;
u32 then = timer->getRealTime();
for(i = 0; i < ITERATIONS; ++i)
value = strtol("-3402823466", 0, 10);
const u32 strtolTime = timer->getRealTime() - then;
then += strtolTime;
for(i = 0; i < ITERATIONS; ++i)
value = strtol10("-3402823466");
const u32 strtol10Time = timer->getRealTime() - then;
then += strtol10Time;
for(i = 0; i < ITERATIONS; ++i)
value = old_strtol10("-3402823466");
const u32 oldstrtol10Time = timer->getRealTime() - then;
logTestString("Speed test\n strtol time = %d\n strtol10 time = %d\nold strtol10 time = %d\n",
strtolTime, strtol10Time, oldstrtol10Time);
device->closeDevice();
device->run();
device->drop();
if (strtol10Time > (1.2f*strtolTime))
{
logTestString("The fast method is slower than strtol()\n");
return false;
}
#endif // #ifndef _DEBUG
return true;
}
bool fast_atof(void)
{
bool ok = true;
ok &= test_fast_atof() ;
ok &= test_strtol();
return ok;
}

View File

@ -1,183 +0,0 @@
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace io;
static bool testgetAbsoluteFilename(io::IFileSystem* fs)
{
bool result=true;
io::path apath = fs->getAbsolutePath("media");
io::path cwd = fs->getWorkingDirectory();
if (apath!=(cwd+"/media"))
{
logTestString("getAbsolutePath failed on existing dir %s\n", apath.c_str());
result = false;
}
apath = fs->getAbsolutePath("../media/");
core::deletePathFromPath(cwd, 1);
if (apath!=(cwd+"media/"))
{
logTestString("getAbsolutePath failed on dir with postfix / %s\n", apath.c_str());
result = false;
}
apath = fs->getAbsolutePath ("../nothere.txt"); // file does not exist
if (apath!=(cwd+"nothere.txt"))
{
logTestString("getAbsolutePath failed on non-existing file %s\n", apath.c_str());
result = false;
}
return result;
}
static bool testFlattenFilename(io::IFileSystem* fs)
{
bool result=true;
io::path tmpString="../tmp";
io::path refString="../tmp/";
fs->flattenFilename(tmpString);
if (tmpString != refString)
{
logTestString("flattening destroys path.\n%s!=%s\n", tmpString.c_str(),refString.c_str());
result = false;
}
tmpString="tmp/tmp/../";
refString="tmp/";
fs->flattenFilename(tmpString);
if (tmpString != refString)
{
logTestString("flattening destroys path.\n%s!=%s\n", tmpString.c_str(),refString.c_str());
result = false;
}
tmpString="tmp/tmp/..";
fs->flattenFilename(tmpString);
if (tmpString != refString)
{
logTestString("flattening destroys path.\n%s!=%s\n", tmpString.c_str(),refString.c_str());
result = false;
}
tmpString="tmp/next/../third";
refString="tmp/third/";
fs->flattenFilename(tmpString);
if (tmpString != refString)
{
logTestString("flattening destroys path.\n%s!=%s\n", tmpString.c_str(),refString.c_str());
result = false;
}
tmpString="this/tmp/next/../../my/fourth";
refString="this/my/fourth/";
fs->flattenFilename(tmpString);
if (tmpString != refString)
{
logTestString("flattening destroys path.\n%s!=%s\n", tmpString.c_str(),refString.c_str());
result = false;
}
tmpString="this/is/../../../a/fifth/test/";
refString="../a/fifth/test/";
fs->flattenFilename(tmpString);
if (tmpString != refString)
{
logTestString("flattening destroys path.\n%s!=%s\n", tmpString.c_str(),refString.c_str());
result = false;
}
tmpString="this/../is/../../a/sixth/test/";
refString="../a/sixth/test/";
fs->flattenFilename(tmpString);
if (tmpString != refString)
{
logTestString("flattening destroys path.\n%s!=%s\n", tmpString.c_str(),refString.c_str());
result = false;
}
return result;
}
static bool testgetRelativeFilename(io::IFileSystem* fs)
{
bool result=true;
io::path apath = fs->getAbsolutePath("media");
io::path cwd = fs->getWorkingDirectory();
if (fs->getRelativeFilename(apath, cwd) != "media")
{
logTestString("getRelativePath failed on %s\n", apath.c_str());
result = false;
}
apath = fs->getAbsolutePath("../media/");
if (fs->getRelativeFilename(apath, cwd) != "../media/")
{
logTestString("getRelativePath failed on %s\n", apath.c_str());
result = false;
}
return result;
}
bool filesystem(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
assert_log(device);
if(!device)
return false;
io::IFileSystem * fs = device->getFileSystem ();
if ( !fs )
return false;
bool result = true;
io::path workingDir = device->getFileSystem()->getWorkingDirectory();
io::path empty;
if ( fs->existFile(empty) )
{
logTestString("Empty filename should not exist.\n");
result = false;
}
io::path newWd = workingDir + "/media";
bool changed = device->getFileSystem()->changeWorkingDirectoryTo(newWd);
assert_log(changed);
if ( fs->existFile(empty) )
{
logTestString("Empty filename should not exist even in another workingdirectory.\n");
result = false;
}
// The working directory must be restored for the other tests to work.
changed = device->getFileSystem()->changeWorkingDirectoryTo(workingDir.c_str());
assert_log(changed);
// adding a folder archive which just should not really change anything
device->getFileSystem()->addFileArchive( "./" );
if ( fs->existFile(empty) )
{
logTestString("Empty filename should not exist in folder file archive.\n");
result = false;
}
// remove it again to not affect other tests
device->getFileSystem()->removeFileArchive( device->getFileSystem()->getFileArchiveCount() );
result &= testFlattenFilename(fs);
result &= testgetAbsoluteFilename(fs);
result &= testgetRelativeFilename(fs);
device->closeDevice();
device->run();
device->drop();
return result;
}

View File

@ -1,60 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
/** Tests the offset capability of the fly circle animator */
bool flyCircleAnimator(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
const f32 offsetDegrees[] = { 0.f, 45.f, 135.f, 270.f };
for(u32 i = 0; i < sizeof(offsetDegrees) / sizeof(offsetDegrees[0]); ++i)
{
IBillboardSceneNode * node = smgr->addBillboardSceneNode();
// Have the animator rotate around the Z axis plane, rather than the default Y axis
ISceneNodeAnimator * animator = smgr->createFlyCircleAnimator(
vector3df(0, 0, 0), 30.f, 0.001f,
vector3df(0, 0, 1), (offsetDegrees[i] / 360.f));
if(!node || !animator)
return false;
node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
node->setMaterialTexture(0, driver->getTexture("../media/particle.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->addAnimator(animator);
animator->drop();
}
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50), vector3df(0, 0, 0));
bool result = false;
// Don't do device->run() since I need the time to remain at 0.
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png", 100);
}
device->closeDevice();
device->run();
device->drop();
return result;
}

View File

@ -1,58 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace gui;
// Tests that disabled GUI menu items don't cause their submenu to appear when hovered over.
/**
http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=178436#178436
*/
bool guiDisabledMenu(void)
{
IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO,
dimension2d<u32>(160, 40), 32);
assert_log(device);
if (!device)
return false;
video::IVideoDriver* driver = device->getVideoDriver();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
gui::IGUIContextMenu* menu = env->addMenu();
menu->addItem(L"Menu", -1, true, true);
gui::IGUIContextMenu* subMenu = menu->getSubMenu(0);
subMenu->addItem(L"Submenu 1", -1, false, true);
gui::IGUIContextMenu* subSubMenu = subMenu->getSubMenu(0);
subSubMenu->addItem(L"Final item");
SEvent event;
event.EventType = EET_MOUSE_INPUT_EVENT;
event.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
event.MouseInput.X = menu->getAbsolutePosition().UpperLeftCorner.X + 1;
event.MouseInput.Y = menu->getAbsolutePosition().UpperLeftCorner.Y + 1;
(void)menu->OnEvent(event);
// Hovering over the disabled submenu shouldn't cause the "Final item" to appear.
event.MouseInput.Event = EMIE_MOUSE_MOVED;
event.MouseInput.X = subMenu->getAbsolutePosition().UpperLeftCorner.X + 40;
event.MouseInput.Y = subMenu->getAbsolutePosition().UpperLeftCorner.Y + 10;
(void)menu->OnEvent(event);
device->run();
driver->beginScene(true, true, video::SColor(150,50,50,50));
env->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-guiDisabledMenu.png", 98.77f);
device->closeDevice();
device->run();
device->drop();
return result;
}

View File

@ -1,132 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
// Tests save scene.
static bool saveScene(void)
{
IrrlichtDevice *device = createDevice( EDT_NULL, dimension2d<u32>(160, 120), 32);
assert_log(device);
if (!device)
return false;
ISceneManager * smgr = device->getSceneManager();
ISkinnedMesh* mesh = (ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d");
if (!mesh)
return false;
IAnimatedMeshSceneNode* node1 = smgr->addAnimatedMeshSceneNode(mesh);
if (node1)
{
node1->setPosition(vector3df(-3, -3, 10));
node1->setMaterialFlag(EMF_LIGHTING, false);
node1->setAnimationSpeed(0.f);
node1->setCurrentFrame(10.f);
node1->setDebugDataVisible(irr::scene::EDS_BBOX_BUFFERS);
}
ISkinnedMesh* mesh2 = (ISkinnedMesh*)smgr->getMesh(device->getFileSystem()->getAbsolutePath("../media/dwarf.x"));
if (!mesh2)
return false;
IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode(mesh2);
if (node2)
{
node2->setPosition(vector3df(33, -93, 120));
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setAnimationSpeed(10.f);
node2->setCurrentFrame(2.f);
}
IAnimatedMeshSceneNode* node3 = smgr->addAnimatedMeshSceneNode(mesh2, node2);
if (node3)
{
node3->setPosition(vector3df(-88, -300, 150));
node3->setMaterialFlag(EMF_LIGHTING, false);
node3->setAnimationSpeed(0.f);
node3->setCurrentFrame(12.f);
}
smgr->addCameraSceneNode();
logTestString("Test scene.irr");
smgr->saveScene("results/scene.irr");
bool result = xmlCompareFiles(device->getFileSystem(), "results/scene.irr", "media/scene.irr");
logTestString("Test scene2.irr");
smgr->saveScene("results/scene2.irr", 0, node3);
result &= xmlCompareFiles(device->getFileSystem(), "results/scene2.irr", "media/scene2.irr");
device->closeDevice();
device->run();
device->drop();
return result;
}
static bool loadScene(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
// load scene from example, with correct relative path
device->getFileSystem()->changeWorkingDirectoryTo("results");
smgr->loadScene("../../media/example.irr");
smgr->addCameraSceneNode(0, core::vector3df(0,0,-50));
device->getFileSystem()->changeWorkingDirectoryTo("..");
bool result = false;
device->run();
device->getTimer()->setTime(666); // scene has animations and current scene seems to be saved at that time ... really - best result with just that number :-)
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
// we need to be very sloppy, because the animators will produce a different
// start depending on the actual loading time. 97% seems to be safe, as removing
// an object produces values around 95%
result = takeScreenshotAndCompareAgainstReference(driver, "-loadScene.png", 97.4f);
if (!result)
logTestString("Rendering the loaded scene failed.\n");
}
ISceneNode* node = smgr->getSceneNodeFromId(128);
if (!node)
result=false;
else if (result) // only check if scene was correctly loaded
{
result &= (node->getChildren().size()==0);
if (!result)
logTestString("Node has an illegal child node.\n");
device->getSceneManager()->loadScene("results/scene2.irr", 0, node);
result &= (node->getChildren().size()!=0);
if (!result)
logTestString("Loading second scene as child failed.\n");
}
device->closeDevice();
device->run();
device->drop();
return result;
}
bool ioScene(void)
{
bool result = saveScene();
result &= loadScene();
return result;
}

View File

@ -1,133 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include <irrlicht.h>
using namespace irr;
using namespace core;
core::map<int, int> countReferences;
struct SDummy
{
SDummy(int a) : x(a)
{
countReferences.insert(x,1);
}
SDummy() : x(0)
{
countReferences.insert(x,1);
}
SDummy(const SDummy& other)
{
x = other.x;
countReferences[x] = countReferences[x] + 1;
}
~SDummy()
{
countReferences[x] = countReferences[x] - 1;
}
int x;
};
static bool testErase()
{
{
core::array<SDummy> aaa;
aaa.push_back(SDummy(0));
aaa.push_back(SDummy(1));
aaa.push_back(SDummy(2));
aaa.push_back(SDummy(3));
aaa.push_back(SDummy(4));
aaa.push_back(SDummy(5));
aaa.erase(0,2);
}
for ( core::map<int,int>::Iterator it = countReferences.getIterator(); !it.atEnd(); it++ )
{
if ( it->getValue() != 0 )
{
logTestString("testErase: wrong count for %d, it's: %d\n", it->getKey(), it->getValue());
return false;
}
}
return true;
}
struct VarArray
{
core::array < int, core::irrAllocatorFast<int> > MyArray;
};
static bool testSelfAssignment()
{
core::array<int> myArray;
myArray.push_back(1);
myArray = myArray;
return myArray.size() == 1;
}
// this will (did once) crash when wrong due to deallocating memory twice, so no return value
static void crashTestFastAlloc()
{
core::array < VarArray, core::irrAllocatorFast<VarArray> > ArrayArray;
ArrayArray.setAllocStrategy(core::ALLOC_STRATEGY_SAFE); // force more re-allocations
VarArray var;
var.MyArray.setAllocStrategy(core::ALLOC_STRATEGY_SAFE); // force more re-allocations
var.MyArray.push_back( 0 );
for ( int i=0; i< 100; ++i )
{
ArrayArray.push_back(var);
ArrayArray.push_back(var);
}
}
static bool testSwap()
{
bool result = true;
core::array<int> array1, array2, copy1, copy2;
for ( int i=0; i<99; ++i )
{
array1.push_back(i);
if ( i < 10 ) // we want also different container sizes
array2.push_back(99-i);
}
copy1 = array1;
copy2 = array2;
array1.swap(array2);
result &= (array1 == copy2);
result &= (array2 == copy1);
assert_log( result );
return result;
}
// Test the functionality of core::array
bool testIrrArray(void)
{
bool allExpected = true;
logTestString("crashTestFastAlloc\n");
crashTestFastAlloc();
allExpected &= testSelfAssignment();
allExpected &= testSwap();
allExpected &= testErase();
if(allExpected)
logTestString("\nAll tests passed\n");
else
logTestString("\nFAIL!\n");
return allExpected;
}

View File

@ -1,132 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald and Christian Stehno
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
bool irrCoreEquals(void)
{
// float tests
if(!irr::core::equals(99.f, 99.f))
{
logTestString("irr::core::equals(f32, f32 (, default)) failed.\n");
return false;
}
if(!irr::core::equals(99.f, 98.f, 1.f))
{
logTestString("irr::core::equals(f32, f32, f32) failed.\n");
return false;
}
// double tests
if(!irr::core::equals(99.0, 99.0))
{
logTestString("irr::core::equals(f64, f64 (,default)) failed.\n");
return false;
}
if(!irr::core::equals(99.0, 98.0, 1.0))
{
logTestString("irr::core::equals(f64, f64, f64) failed.\n");
return false;
}
// int tests
if(!irr::core::equals(99, 99))
{
logTestString("irr::core::equals(s32, s32 (,default)) failed.\n");
return false;
}
if(!irr::core::equals(99, 98, 1))
{
logTestString("irr::core::equals(s32, s32, s32) failed.\n");
return false;
}
if(irr::core::equals(99, 98, 0))
{
logTestString("irr::core::equals(s32, s32, 0) failed.\n");
return false;
}
if(!irr::core::equals(-99, -99))
{
logTestString("irr::core::equals(s32, s32 (,default)) failed.\n");
return false;
}
if(!irr::core::equals(-99, -98, 1))
{
logTestString("irr::core::equals(s32, s32, s32) failed.\n");
return false;
}
if(irr::core::equals(-99, -98, 0))
{
logTestString("irr::core::equals(s32, s32, 0) failed.\n");
return false;
}
// iszero is a specialized equals method
// float tests
if(!irr::core::iszero(.0f))
{
logTestString("irr::core::iszero(f32 (,default)) failed.\n");
return false;
}
if(irr::core::iszero(-1.0f))
{
logTestString("irr::core::iszero(f32 (,default)) failed.\n");
return false;
}
if(!irr::core::iszero(1.0f, 1.0f))
{
logTestString("irr::core::iszero(f32, f32) failed.\n");
return false;
}
// double tests
if(!irr::core::iszero(0.0))
{
logTestString("irr::core::iszero(f64 (,default)) failed.\n");
return false;
}
if(irr::core::iszero(-1.0))
{
logTestString("irr::core::iszero(f64 (,default)) failed.\n");
return false;
}
if(!irr::core::iszero(-2.0, 2.0))
{
logTestString("irr::core::iszero(f64, f64) failed.\n");
return false;
}
// int tests
if(!irr::core::iszero(0))
{
logTestString("irr::core::iszero(s32 (,default)) failed.\n");
return false;
}
if(irr::core::iszero(-1))
{
logTestString("irr::core::iszero(s32 (,default)) failed.\n");
return false;
}
if(!irr::core::iszero(1, 1))
{
logTestString("irr::core::iszero(s32, s32) failed.\n");
return false;
}
return true;
}

View File

@ -1,76 +0,0 @@
#include "testUtils.h"
#include <irrlicht.h>
using namespace irr;
using namespace core;
// list has no operator== currently so we have to check manually
// TODO: Add an operator== to core::list and the kick this function out
template <typename T>
static bool compareLists(const core::list<T> & a, const core::list<T> & b)
{
if ( a.size() != b.size() )
return false;
// can't test allocator because we have no access to it here
typename core::list<T>::ConstIterator iterA = a.begin();
typename core::list<T>::ConstIterator iterB = b.begin();
for ( ; iterA != a.end(); ++iterA, ++iterB )
{
if ( (*iterA) != (*iterB) )
return false;
}
return true;
}
// Make sure that we can get a const iterator from a non-const list
template <typename T>
static void constIteratorCompileTest(core::list<T> & a)
{
typename core::list<T>::ConstIterator iterA = a.begin();
while (iterA != a.end() )
{
++iterA;
}
}
static bool testSwap()
{
bool result = true;
core::list<int> list1, list2, copy1, copy2;
for ( int i=0; i<99; ++i )
{
list1.push_back(i);
if ( i < 10 ) // we want also different container sizes i < 50 )
list2.push_back(99-i);
}
copy1 = list1;
copy2 = list2;
list1.swap(list2);
result &= compareLists<int>(list1, copy2);
result &= compareLists<int>(list2, copy1);
assert_log( result );
return result;
}
// Test the functionality of core::list
bool testIrrList(void)
{
bool success = true;
core::list<int> compileThisList;
constIteratorCompileTest(compileThisList);
success &= testSwap();
if(success)
logTestString("\nAll tests passed\n");
else
logTestString("\nFAIL!\n");
return success;
}

View File

@ -1,64 +0,0 @@
#include "testUtils.h"
#include <irrlicht.h>
using namespace irr;
using namespace core;
// map has no operator== currently so we have to check manually
// TODO: Add an operator== to core::map and the kick this function out
template <class KeyType, class ValueType>
static bool compareMaps(core::map<KeyType,ValueType> & a, core::map<KeyType,ValueType> & b)
{
if ( a.size() != b.size() )
return false;
// can't test allocator because we have no access to it here
typename core::map<KeyType, ValueType>::Iterator iterA = a.getIterator();
typename core::map<KeyType, ValueType>::Iterator iterB = b.getIterator();
for ( ; !iterA.atEnd(); iterA++, iterB++ ) // TODO: only iter++, no ++iter in irr::map
{
if ( iterA->getValue() != iterB->getValue() )
return false;
}
return true;
}
static bool testSwap()
{
bool result = true;
core::map<int, int> map1, map2, copy1, copy2;
for ( int i=0; i<99; ++i )
{
map1[i] = i;
copy1[i] = i; // TODO: whatever the reason - irr::map does not want operator= so we have to assign to identical values
if ( i < 10 ) // we want also different container sizes
{
map2[i] = 99-i;
copy2[i] = 99-i; // TODO: whatever the reason - irr::map does not want operator= so we have to assign to identical values
}
}
map1.swap(map2);
result &= compareMaps(map1, copy2);
result &= compareMaps(map2, copy1);
assert_log( result );
return result;
}
// Test the functionality of core::list
bool testIrrMap(void)
{
bool success = true;
success &= testSwap();
if(success)
logTestString("\nAll tests passed\n");
else
logTestString("\nFAIL!\n");
return success;
}

View File

@ -1,356 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include <irrlicht.h>
using namespace irr;
using namespace core;
static bool testSelfAssignment()
{
core::stringw myString(L"foo");
myString = myString;
return myString == core::stringw(L"foo");
}
static bool testSplit()
{
logTestString("Test stringw::split()\n");
core::stringw teststring(L"[b]this [/b] is a [color=0xff000000]test[/color].");
core::list<core::stringw> parts1;
teststring.split<core::list<core::stringw> >(parts1, L"[");
core::list<core::stringw> parts2;
teststring.split<core::list<core::stringw> >(parts2, L"[", 1, false, true);
return (parts1.getSize()==4) && (parts2.getSize()==5);
}
static bool testFastAlloc()
{
core::string<wchar_t, core::irrAllocatorFast<wchar_t> > FastString(L"abc");
core::string<wchar_t, core::irrAllocatorFast<wchar_t> > FastStringLong(L"longer");
FastString = L"test";
// cause a reallocation
FastString = FastStringLong;
// this test should either not compile or crash when the allocaters are messed up
return true;
}
static bool testReplace()
{
// test string getting longer
core::stringw str = L"no";
str.replace(L"no", L"yes");
if ( str != L"yes" )
return false;
str = L"nonono";
str.replace(L"no", L"yes");
if ( str != L"yesyesyes" )
return false;
str = L"nomaybenomaybeno";
str.replace(L"no", L"yes");
if ( str != L"yesmaybeyesmaybeyes" )
return false;
// test string staying same length
str = L"one";
str.replace(L"one", L"two");
if ( str != L"two" )
return false;
str = L"oneone";
str.replace(L"one", L"two");
if ( str != L"twotwo" )
return false;
// test string getting shorter
str = L"yes";
str.replace(L"yes", L"no");
if ( str != L"no" )
return false;
str = L"yesyes";
str.replace(L"yes", L"no");
if ( str != L"nono" )
return false;
// remove string-parts completely
str = L"killme";
str.replace(L"killme", L"");
if ( str != L"" )
return false;
str = L"killmenow";
str.replace(L"killme", L"");
if ( str != L"now" )
return false;
str = L"nowkillme";
str.replace(L"killme", L"");
if ( str != L"now" )
return false;
// remove nothing
str = L"keepme";
str.replace(L"", L"whatever");
if ( str != L"keepme" )
return false;
str = L"keepme";
str.replace(L"", L"");
if ( str != L"keepme" )
return false;
return true;
}
bool testAppendStringc()
{
core::stringc str;
// Test with character
if (str != "")
return false;
str += 'W';
if (str != "W")
return false;
str += 'i';
if (str != "Wi")
return false;
str="";
if (str != "")
return false;
// Test with C-style string
str += "Another Test";
if (str != "Another Test")
return false;
str="";
str += 'A';
str += "nother Test";
if (str != "Another Test")
return false;
str="";
// Test with int
str += 10;
if (str != "10")
return false;
str += 0;
if (str != "100")
return false;
str="";
str += "-32";
if (str != "-32")
return false;
str="";
// Test with unsigned int
str += 21u;
if (str != "21")
return false;
str += 0u;
if (str != "210")
return false;
str="";
// Test with long int
str += 456l;
if (str != "456")
return false;
str += 0l;
if (str != "4560")
return false;
str="";
str += -456l;
if (str != "-456")
return false;
str="";
// Test with unsigned long
str += 994ul;
if (str != "994")
return false;
str += 0ul;
if (str != "9940")
return false;
str="";
return true;
}
bool testLowerUpper()
{
irr::core::array <irr::core::stringc> stringsOrig, targetLower, targetUpper;
stringsOrig.push_back("abc");
targetLower.push_back("abc");
targetUpper.push_back("ABC");
stringsOrig.push_back("ABC");
targetLower.push_back("abc");
targetUpper.push_back("ABC");
stringsOrig.push_back("Abc");
targetLower.push_back("abc");
targetUpper.push_back("ABC");
stringsOrig.push_back("aBBc");
targetLower.push_back("abbc");
targetUpper.push_back("ABBC");
stringsOrig.push_back("abC");
targetLower.push_back("abc");
targetUpper.push_back("ABC");
stringsOrig.push_back("");
targetLower.push_back("");
targetUpper.push_back("");
/* TODO: those are not supported so far
stringsOrig.push_back("ßäöü");
targetLower.push_back("ßäöü");
targetUpper.push_back("ßÄÖÜ");
stringsOrig.push_back("ßÄÖÜ");
targetLower.push_back("ßäöü");
targetUpper.push_back("ßÄÖÜ");
*/
for ( irr::u32 i=0; i<stringsOrig.size(); ++i )
{
irr::core::stringc c = stringsOrig[i];
c.make_lower();
if ( c != targetLower[i] )
{
logTestString("make_lower for stringc failed in test %d %s\n", i, stringsOrig[i].c_str());
return false;
}
c = stringsOrig[i];
c.make_upper();
if ( c != targetUpper[i] )
{
logTestString("make_upper for stringc failed in test %d %s %s\n", i, stringsOrig[i].c_str(), c.c_str());
return false;
}
irr::core::stringw w = irr::core::stringw(stringsOrig[i]);
c.make_lower();
if ( c != irr::core::stringw(targetLower[i]) )
{
logTestString("make_lower for stringw failed in test %d %s\n", i, stringsOrig[i].c_str());
return false;
}
c = irr::core::stringw(stringsOrig[i]);
c.make_upper();
if ( c != irr::core::stringw(targetUpper[i]) )
{
logTestString("make_upper for stringw failed in test %d %s\n", i, stringsOrig[i].c_str());
return false;
}
}
return true;
}
bool testFindFunctions()
{
irr::core::stringc dot(".");
irr::s32 p = dot.findFirst(0);
if ( p >= 0 )
return false;
irr::core::stringc empty("");
p = empty.findLastCharNotInList("x",1);
if ( p >= 0 )
return false;
p = empty.findLast('x');
if ( p >= 0 )
return false;
p = dot.findLast('.');
if ( p != 0 )
return false;
p = empty.findLastChar("ab", 2);
if ( p >= 0 )
return false;
p = dot.findLastChar("-.", 2);
if ( p != 0 )
return false;
return true;
}
// Test the functionality of irrString
/** Validation is done with assert_log() against expected results. */
bool testIrrString(void)
{
bool allExpected = true;
logTestString("Test stringc\n");
{
// Check empty string
core::stringc empty;
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(empty.c_str()!=0);
assert_log(*(empty.c_str())==0);
// Assign content
empty = "Test";
assert_log(empty.size()==4);
assert_log(empty[0]=='T');
assert_log(empty[3]=='t');
assert_log(*(empty.c_str())=='T');
//Assign empty string, should be same as in the beginning
empty = "";
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(*(empty.c_str())==0);
}
logTestString("Test stringw\n");
{
core::stringw empty;
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(empty.c_str()!=0);
assert_log(*(empty.c_str())==0);
empty = L"Test";
assert_log(empty.size()==4);
assert_log(empty[0]==L'T');
assert_log(empty[3]=='t');
assert_log(*(empty.c_str())==L'T');
empty = L"";
assert_log(empty.size()==0);
assert_log(empty[0]==0);
assert_log(*(empty.c_str())==0);
assert_log(allExpected &= testSplit());
}
allExpected &= testAppendStringc();
logTestString("Test io::path\n");
{
// Only test that this type exists, it's one from above
io::path myPath;
myPath = "Some text"; // Only to avoid wrong optimizations
}
logTestString("Test self assignment\n");
allExpected &= testSelfAssignment();
logTestString("test fast alloc\n");
allExpected &= testFastAlloc();
logTestString("test replace\n");
allExpected &= testReplace();
logTestString("test make_lower and make_uppers\n");
allExpected &= testLowerUpper();
logTestString("test find functions\n");
allExpected &= testFindFunctions();
if(allExpected)
logTestString("\nAll tests passed\n");
else
logTestString("\nFAIL!\n");
return allExpected;
}

View File

@ -1,73 +0,0 @@
// Copyright (C) 2008-2012 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
//! Tests lightmaps under all drivers that support them
static bool runTestWithDriver(E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
if (!device)
return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
logTestString("Testing driver %ls\n", driver->getName());
if (driver->getDriverAttributes().getAttributeAsInt("MaxTextures")<2)
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
bool result = true;
bool added = device->getFileSystem()->addFileArchive("../media/map-20kdm2.pk3");
assert_log(added);
if(added)
{
ISceneNode * node = smgr->addOctreeSceneNode(smgr->getMesh("20kdm2.bsp")->getMesh(0), 0, -1, 1024);
assert_log(node);
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setPosition(core::vector3df(-1300,-820,-1249));
node->setScale(core::vector3df(1, 5, 1));
(void)smgr->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(40,100,30));
driver->beginScene(true, true, video::SColor(255,255,255,0));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-lightmaps.png", 96);
}
}
device->closeDevice();
device->run();
device->drop();
return result;
}
bool lightMaps(void)
{
bool result = true;
TestWithAllDrivers(runTestWithDriver);
return result;
}

View File

@ -1,70 +0,0 @@
// Copyright (C) 2008-2012 Christian Stehno, Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
static bool testLightTypes(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device = createDevice (driverType, core::dimension2d<u32>(128,128));
if (!device)
return true; // No error if device does not exist
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
if (!driver->getDriverAttributes().getAttributeAsInt("MaxLights"))
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
logTestString("Testing driver %ls\n", driver->getName());
// smgr->setAmbientLight(video::SColorf(0.3f,0.3f,0.3f));
scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
cam->setPosition(core::vector3df(0,200,0));
cam->setTarget(core::vector3df());
smgr->addAnimatedMeshSceneNode(device->getSceneManager()->addHillPlaneMesh("plane", core::dimension2df(4,4), core::dimension2du(128,128)));
scene::ILightSceneNode* light1 = smgr->addLightSceneNode(0, core::vector3df(-100,30,-100));
light1->setLightType(video::ELT_POINT);
light1->setRadius(100.f);
light1->getLightData().DiffuseColor.set(0,1,1);
// smgr->addCubeSceneNode(10, light1)->setMaterialFlag(video::EMF_LIGHTING, false);
scene::ILightSceneNode* light2 = smgr->addLightSceneNode(0, core::vector3df(100,30,100));
light2->setRotation(core::vector3df(90,0,0));
light2->setLightType(video::ELT_SPOT);
light2->setRadius(100.f);
light2->getLightData().DiffuseColor.set(1,0,0);
light2->getLightData().InnerCone=10.f;
light2->getLightData().OuterCone=30.f;
// smgr->addCubeSceneNode(10, light2)->setMaterialFlag(video::EMF_LIGHTING, false);
scene::ILightSceneNode* light3 = smgr->addLightSceneNode();
light3->setRotation(core::vector3df(15,0,0));
light3->setLightType(video::ELT_DIRECTIONAL);
light1->getLightData().DiffuseColor.set(0,1,0);
driver->beginScene (true, true, 0);
smgr->drawAll();
driver->endScene();
const bool result = takeScreenshotAndCompareAgainstReference(driver, "-lightType.png", 99.91f);
device->closeDevice();
device->run();
device->drop();
return result;
}
bool lights(void)
{
bool result = true;
// no lights in sw renderer
TestWithAllDrivers(testLightTypes);
return result;
}

View File

@ -1,97 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
/** This tests verifies that textures opened from different places in the
filesystem don't create duplicated textures. */
bool loadFromFileFolder(void)
{
IrrlichtDevice *device =
createDevice( video::EDT_NULL, dimension2du(160, 120));
if (!device)
{
logTestString("Unable to create EDT_NULL device\n");
return false;
}
IVideoDriver * driver = device->getVideoDriver();
u32 numTexs = driver->getTextureCount();
ITexture * tex1 = driver->getTexture("../media/tools.png");
assert_log(tex1);
if(!tex1)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("No additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
IReadFile * readFile = device->getFileSystem()->createAndOpenFile("../media/tools.png");
assert_log(readFile);
if(!readFile)
logTestString("Unable to open ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
ITexture * tex2 = driver->getTexture(readFile);
assert_log(tex2);
if(!readFile)
logTestString("Unable to create texture from ../media/tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
readFile->drop();
// adding a folder archive
device->getFileSystem()->addFileArchive( "../media/" );
ITexture * tex3 = driver->getTexture("tools.png");
assert_log(tex3);
if(!tex3)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
ITexture * tex4 = driver->getTexture("tools.png");
assert_log(tex4);
if(!tex4)
logTestString("Unable to open tools.png\n");
if (driver->getTextureCount()!=numTexs+1)
{
logTestString("Additional texture in the texture cache %s:%d\n", __FILE__, __LINE__);
return false;
}
device->closeDevice();
device->run();
device->drop();
return ((tex1 == tex2) && (tex1 == tex3) && (tex1 == tex4));
}
bool loadTextures()
{
bool result = true;
result &= loadFromFileFolder();
return result;
}

View File

@ -1,256 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald and Christian Stehno
// No rights reserved: this software is in the public domain.
// This is the entry point for the Irrlicht test suite.
// This is an MSVC pragma to link against the Irrlicht library.
// Other builds must link against it in the project files.
#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")
#define _CRT_SECURE_NO_WARNINGS 1
#endif // _MSC_VER
#include "testUtils.h"
#include <stdio.h>
#include <time.h>
#include <vector>
struct STestDefinition
{
//! The test entry point function
bool(*testSignature)(void);
//! A descriptive name for the test
const char * testName;
};
//! This is the main entry point for the Irrlicht test suite.
/** \return The number of test that failed, i.e. 0 is success. */
int main(int argumentCount, char * arguments[])
{
if(argumentCount > 3)
{
logTestString("\nUsage: %s [testNumber] [testCount]\n");
return 9999;
}
#define TEST(x)\
{\
extern bool x(void);\
STestDefinition newTest;\
newTest.testSignature = x;\
newTest.testName = #x;\
tests.push_back(newTest);\
}
// Use an STL vector so that we don't rely on Irrlicht.
std::vector<STestDefinition> tests;
// Note that to interactively debug a test, you will generally want to move it
// (temporarily) to the beginning of the list, since each test runs in its own
// process.
TEST(disambiguateTextures); // Normally you should run this first, since it validates the working directory.
// Now the simple tests without device
TEST(testIrrArray);
TEST(testIrrMap);
TEST(testIrrList);
TEST(exports);
TEST(irrCoreEquals);
TEST(testIrrString);
TEST(testLine2d);
TEST(matrixOps);
TEST(testDimension2d);
TEST(testVector2d);
TEST(testVector3d);
TEST(testQuaternion);
TEST(testS3DVertex);
TEST(testaabbox3d);
TEST(color);
TEST(testTriangle3d);
TEST(vectorPositionDimension2d);
// file system checks (with null driver)
TEST(filesystem);
TEST(archiveReader);
TEST(testXML);
TEST(serializeAttributes);
// null driver
TEST(fast_atof);
TEST(loadTextures);
TEST(collisionResponseAnimator);
TEST(enumerateImageManipulators);
TEST(removeCustomAnimator);
TEST(sceneCollisionManager);
TEST(sceneNodeAnimator);
TEST(meshLoaders);
TEST(testTimer);
// software drivers only
TEST(softwareDevice);
TEST(b3dAnimation);
TEST(burningsVideo);
TEST(billboards);
TEST(createImage);
TEST(cursorSetVisible);
TEST(flyCircleAnimator);
TEST(guiDisabledMenu);
TEST(makeColorKeyTexture);
TEST(md2Animation);
TEST(meshTransform);
TEST(skinnedMesh);
TEST(testGeometryCreator);
TEST(writeImageToFile);
TEST(ioScene);
// all driver checks
TEST(videoDriver);
TEST(screenshot);
TEST(drawPixel);
TEST(drawRectOutline);
TEST(drawVertexPrimitive);
TEST(material);
TEST(renderTargetTexture);
TEST(textureFeatures);
TEST(textureRenderStates);
TEST(transparentMaterials);
TEST(userclipplane);
TEST(antiAliasing);
TEST(draw2DImage);
TEST(lights);
TEST(twodmaterial);
TEST(viewPort);
TEST(mrt);
TEST(projectionMatrix);
// large scenes/long rendering
// shadows are slow
// TEST(orthoCam);
// TEST(stencilShadow);
// q3 maps are slow
TEST(planeMatrix);
TEST(terrainSceneNode);
TEST(lightMaps);
TEST(triangleSelector);
unsigned int numberOfTests = tests.size();
unsigned int testToRun = 0;
unsigned int fails = 0;
bool firstRun=true;
const bool spawn=false;
// args: [testNumber] [testCount]
if(argumentCount > 1)
{
if (!strcmp(arguments[1],"--list"))
{
for (unsigned int i=0; i<tests.size(); ++i)
{
logTestString("%3d: %s\n", i, tests[i].testName);
}
logTestString("\n");
return 0;
}
int tmp = atoi(arguments[1]);
firstRun = (tmp>=0);
testToRun=abs(tmp);
if (!firstRun)
testToRun -= 1;
if(argumentCount > 2)
{
numberOfTests = testToRun + abs(atoi(arguments[2]));
if (numberOfTests>=tests.size())
numberOfTests=tests.size();
}
}
if(testToRun >= numberOfTests)
{
logTestString("\nError: invalid test %d (maximum %d)\n",
testToRun, numberOfTests-testToRun);
return 9999;
}
const unsigned int testCount = numberOfTests-testToRun;
const bool logFileOpened = openTestLog(firstRun);
assert(logFileOpened);
if (firstRun)
{
if (numberOfTests)
{
for (unsigned int i=testToRun; i<numberOfTests; ++i)
{
logTestString("\nStarting test %d, '%s'\n",
i, tests[i].testName);
if (spawn)
{
closeTestLog();
char runNextTest[256];
(void)sprintf(runNextTest, "\"%s\" -%d 1", arguments[0], i+1);
// Spawn the next test in a new process.
if (system(runNextTest))
{
(void)openTestLog(false);
logTestString("\n******** Test failure ********\n"\
"Test %d '%s' failed\n"\
"******** Test failure ********\n",
i, tests[i].testName);
++fails;
}
else
(void)openTestLog(false);
}
else
{
if (!tests[i].testSignature())
{
logTestString("\n******** Test failure ********\n"\
"Test %d '%s' failed\n"\
"******** Test failure ********\n",
i, tests[i].testName);
++fails;
}
}
}
}
const int passed = testCount - fails;
logTestString("\nTests finished. %d test%s of %d passed.\n\n",
passed, 1 == passed ? "" : "s", testCount);
if(0 == fails && testCount==tests.size())
{
time_t rawtime;
struct tm * timeinfo;
(void)time(&rawtime);
timeinfo = gmtime(&rawtime);
(void)printf("\nTest suite pass at GMT %s\n", asctime(timeinfo));
FILE * testsLastPassedAtFile = fopen("tests-last-passed-at.txt", "w");
if(testsLastPassedAtFile)
{
(void)fprintf(testsLastPassedAtFile, "Tests finished. %d test%s of %d passed.\n",
passed, 1 == passed ? "" : "s", numberOfTests);
#ifdef _DEBUG
(void)fprintf(testsLastPassedAtFile, "Compiled as DEBUG\n");
#else
(void)fprintf(testsLastPassedAtFile, "Compiled as RELEASE\n");
#endif
(void)fprintf(testsLastPassedAtFile, "Test suite pass at GMT %s\n", asctime(timeinfo));
(void)fclose(testsLastPassedAtFile);
}
}
closeTestLog();
#ifdef _IRR_WINDOWS_
(void)system("tests.log");
#else
(void)system("$PAGER tests.log");
#endif
return fails;
}
else
{
const bool res = tests[testToRun].testSignature();
closeTestLog();
return res?0:1;
}
}

View File

@ -1,74 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
/** Test the behaviour of makeColorKeyTexture() using both 16 bit (software)
and 32 bit (Burning) textures, with the new behaviour and the legacy
behaviour. */
static bool doTestWith(E_DRIVER_TYPE driverType,
bool zeroTexels)
{
IrrlichtDevice *device = createDevice( driverType,
dimension2d<u32>(160, 120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
// Draw a cube background so that we can check that the keying is working.
ISceneNode * cube = smgr->addCubeSceneNode(50.f, 0, -1, vector3df(0, 0, 60));
cube->setMaterialTexture(0, driver->getTexture("../media/wall.bmp"));
cube->setMaterialFlag(video::EMF_LIGHTING, false);
ITexture * Texture = device->getVideoDriver()->getTexture("../media/portal2.bmp");
device->getVideoDriver()->makeColorKeyTexture(Texture,
position2d<s32>(64,64),
zeroTexels);
device->getVideoDriver()->makeColorKeyTexture(Texture,
position2d<s32>(64,64),
zeroTexels);
(void)smgr->addCameraSceneNode();
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
driver->draw2DImage(Texture,
position2di(40, 40),
rect<s32>(0, 0, Texture->getSize().Width, Texture->getSize().Height),
0,
SColor(255,255,255,255),
true);
driver->endScene();
char screenshotName[256];
(void)snprintf(screenshotName, 256, "-makeColorKeyTexture-%s.png",
zeroTexels? "old" : "new");
bool result = takeScreenshotAndCompareAgainstReference(driver, screenshotName);
device->closeDevice();
device->run();
device->drop();
return result;
}
bool makeColorKeyTexture(void)
{
bool result = true;
result &= doTestWith(EDT_BURNINGSVIDEO, false);
result &= doTestWith(EDT_SOFTWARE, false);
result &= doTestWith(EDT_BURNINGSVIDEO, true);
result &= doTestWith(EDT_SOFTWARE, true);
return result;
}

View File

@ -1,75 +0,0 @@
#include "testUtils.h"
using namespace irr;
static bool polygonOffset(video::E_DRIVER_TYPE type)
{
IrrlichtDevice* device = createDevice(type, core::dimension2d<u32>(160, 120));
if (device == 0)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
if (!driver->queryFeature(video::EVDF_POLYGON_OFFSET))
{
device->closeDevice();
device->run();
device->drop();
return true;
}
stabilizeScreenBackground(driver);
scene::ISceneManager* smgr = device->getSceneManager();
// create first plane
scene::ISceneNode* plane = smgr->addMeshSceneNode(smgr->addHillPlaneMesh(
"plane", core::dimension2df(10,10), core::dimension2du(2,2)), 0, -1,
core::vector3df(0,0,20), core::vector3df(270,0,0));
if (plane)
{
plane->setMaterialTexture(0, driver->getTexture("../media/t351sml.jpg"));
plane->setMaterialFlag(video::EMF_LIGHTING, false);
plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true);
}
// create second plane exactly on top of the first one
scene::ISceneNode* plane2 = smgr->addMeshSceneNode(smgr->addHillPlaneMesh(
"plane2", core::dimension2df(5,5), core::dimension2du(2,2)), 0, -1,
core::vector3df(0,0,20), core::vector3df(270,0,0));
plane2->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
smgr->addCameraSceneNode();
// test back plane to back
plane->getMaterial(0).PolygonOffsetDirection=video::EPO_BACK;
plane->getMaterial(0).PolygonOffsetFactor=7;
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
bool result = takeScreenshotAndCompareAgainstReference(driver, "-polygonBack.png");
//reset back plane
plane->getMaterial(0).PolygonOffsetFactor=0;
// test front plane to front
plane2->getMaterial(0).PolygonOffsetDirection=video::EPO_FRONT;
plane2->getMaterial(0).PolygonOffsetFactor=7;
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
result &= takeScreenshotAndCompareAgainstReference(driver, "-polygonFront.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
bool material()
{
bool result = true;
TestWithAllDrivers(polygonOffset);
return result;
}

View File

@ -1,465 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
namespace
{
// Basic tests for identity matrix
bool identity(void)
{
bool result = true;
matrix4 m;
// Check default init
result &= (m==core::IdentityMatrix);
result &= (core::IdentityMatrix==m);
assert_log(result);
// Since the last test can be made with isDefinitelyIdentityMatrix we set it to false here
m.setDefinitelyIdentityMatrix(false);
result &= (m==core::IdentityMatrix);
result &= (core::IdentityMatrix==m);
assert_log(result);
// also equals should see this
result &= m.equals(core::IdentityMatrix);
result &= core::IdentityMatrix.equals(m);
assert_log(result);
// Check inequality
m[12]=5.f;
result &= (m!=core::IdentityMatrix);
result &= (core::IdentityMatrix!=m);
result &= !m.equals(core::IdentityMatrix);
result &= !core::IdentityMatrix.equals(m);
assert_log(result);
// Test multiplication
result &= (m==(core::IdentityMatrix*m));
result &= m.equals(core::IdentityMatrix*m);
result &= (m==(m*core::IdentityMatrix));
result &= m.equals(m*core::IdentityMatrix);
assert_log(result);
return result;
}
// Test rotations
bool transformations(void)
{
bool result = true;
matrix4 m, s;
m.setRotationDegrees(core::vector3df(30,40,50));
s.setScale(core::vector3df(2,3,4));
m *= s;
m.setTranslation(core::vector3df(5,6,7));
result &= (core::vector3df(5,6,7).equals(m.getTranslation()));
assert_log(result);
result &= (core::vector3df(2,3,4).equals(m.getScale()));
assert_log(result);
core::vector3df newRotation = m.getRotationDegrees();
result &= (core::vector3df(30,40,50).equals(newRotation, 0.000004f));
assert_log(result);
m.setRotationDegrees(vector3df(90.0001f, 270.85f, 180.0f));
s.setRotationDegrees(vector3df(0,0, 0.860866f));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,270,270).equals(newRotation, 0.0001f));
assert_log(result);
m.setRotationDegrees(vector3df(270.0f, 89.8264f, 0.000100879f));
s.setRotationDegrees(vector3df(0,0, 0.189398f));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,90).equals(newRotation, 0.0001f));
assert_log(result);
m.setRotationDegrees(vector3df(270.0f, 89.0602f, 359.999f));
s.setRotationDegrees(vector3df(0,0, 0.949104f));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,89.999f).equals(newRotation));
assert_log(result);
return result;
}
// Test rotations
bool rotations(void)
{
bool result = true;
matrix4 rot1,rot2,rot3,rot4,rot5;
core::vector3df vec1(1,2,3),vec12(1,2,3);
core::vector3df vec2(-5,0,0),vec22(-5,0,0);
core::vector3df vec3(20,0,-20), vec32(20,0,-20);
// Make sure the matrix multiplication and rotation application give same results
rot1.setRotationDegrees(core::vector3df(90,0,0));
rot2.setRotationDegrees(core::vector3df(0,90,0));
rot3.setRotationDegrees(core::vector3df(0,0,90));
rot4.setRotationDegrees(core::vector3df(90,90,90));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
result &= (vec1.equals(vec12));
result &= (vec2.equals(vec22));
result &= (vec3.equals(vec32));
assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0);
vec3.set(20,0,-20);vec32.set(20,0,-20);
rot1.setRotationDegrees(core::vector3df(45,0,0));
rot2.setRotationDegrees(core::vector3df(0,45,0));
rot3.setRotationDegrees(core::vector3df(0,0,45));
rot4.setRotationDegrees(core::vector3df(45,45,45));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
result &= (vec1.equals(vec12));
result &= (vec2.equals(vec22));
result &= (vec3.equals(vec32, 2*ROUNDING_ERROR_f32));
assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0);
vec3.set(20,0,-20);vec32.set(20,0,-20);
rot1.setRotationDegrees(core::vector3df(-60,0,0));
rot2.setRotationDegrees(core::vector3df(0,-60,0));
rot3.setRotationDegrees(core::vector3df(0,0,-60));
rot4.setRotationDegrees(core::vector3df(-60,-60,-60));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
result &= (vec1.equals(vec12));
result &= (vec2.equals(vec22));
// this one needs higher tolerance due to rounding issues
result &= (vec3.equals(vec32, 0.000002f));
assert_log(result);
vec1.set(1,2,3);vec12.set(1,2,3);
vec2.set(-5,0,0);vec22.set(-5,0,0);
vec3.set(20,0,-20);vec32.set(20,0,-20);
rot1.setRotationDegrees(core::vector3df(113,0,0));
rot2.setRotationDegrees(core::vector3df(0,-27,0));
rot3.setRotationDegrees(core::vector3df(0,0,193));
rot4.setRotationDegrees(core::vector3df(113,-27,193));
rot5 = rot3*rot2*rot1;
result &= (rot4.equals(rot5, ROUNDING_ERROR_f32));
assert_log(result);
rot4.transformVect(vec1);rot5.transformVect(vec12);
rot4.transformVect(vec2);rot5.transformVect(vec22);
rot4.transformVect(vec3);rot5.transformVect(vec32);
// these ones need higher tolerance due to rounding issues
result &= (vec1.equals(vec12, 0.000002f));
assert_log(result);
result &= (vec2.equals(vec22));
assert_log(result);
result &= (vec3.equals(vec32, 0.000002f));
assert_log(result);
rot1.setRotationDegrees(core::vector3df(0,0,34));
rot2.setRotationDegrees(core::vector3df(0,43,0));
vec1=(rot2*rot1).getRotationDegrees();
result &= (vec1.equals(core::vector3df(27.5400505f, 34.4302292f, 42.6845398f), 0.000002f));
assert_log(result);
// corner cases
rot1.setRotationDegrees(irr::core::vector3df(180.0f, 0.f, 0.f));
vec1=rot1.getRotationDegrees();
result &= (vec1.equals(core::vector3df(180.0f, 0.f, 0.f), 0.000002f));
assert_log(result);
rot1.setRotationDegrees(irr::core::vector3df(0.f, 180.0f, 0.f));
vec1=rot1.getRotationDegrees();
result &= (vec1.equals(core::vector3df(180.0f, 360, 180.0f), 0.000002f));
assert_log(result);
rot1.setRotationDegrees(irr::core::vector3df(0.f, 0.f, 180.0f));
vec1=rot1.getRotationDegrees();
result &= (vec1.equals(core::vector3df(0.f, 0.f, 180.0f), 0.000002f));
assert_log(result);
rot1.makeIdentity();
rot1.setRotationDegrees(core::vector3df(270.f,0,0));
rot2.makeIdentity();
rot2.setRotationDegrees(core::vector3df(-90.f,0,0));
vec1=(rot1*rot2).getRotationDegrees();
result &= (vec1.equals(core::vector3df(180.f, 0.f, 0.0f)));
assert_log(result);
return result;
}
// Test isOrthogonal
bool isOrthogonal(void)
{
matrix4 rotationMatrix;
if (!rotationMatrix.isOrthogonal())
{
logTestString("irr::core::matrix4::isOrthogonal() failed with Identity.\n");
return false;
}
rotationMatrix.setRotationDegrees(vector3df(90, 0, 0));
if (!rotationMatrix.isOrthogonal())
{
logTestString("irr::core::matrix4::isOrthogonal() failed with rotation.\n");
return false;
}
matrix4 translationMatrix;
translationMatrix.setTranslation(vector3df(0, 3, 0));
if (translationMatrix.isOrthogonal())
{
logTestString("irr::core::matrix4::isOrthogonal() failed with translation.\n");
return false;
}
matrix4 scaleMatrix;
scaleMatrix.setScale(vector3df(1, 2, 3));
if (!scaleMatrix.isOrthogonal())
{
logTestString("irr::core::matrix4::isOrthogonal() failed with scale.\n");
return false;
}
return true;
}
bool checkMatrixRotation(irr::core::matrix4& m, const vector3df& vector, const vector3df& expectedResult)
{
vector3df v(vector);
m.rotateVect(v);
if ( expectedResult.equals(v) )
return true;
logTestString("checkMatrixRotation failed for vector %f %f %f. Expected %f %f %f, got %f %f %f \n"
, vector.X, vector.Y, vector.Z, expectedResult.X, expectedResult.Y, expectedResult.Z, v.X, v.Y, v.Z);
logTestString("matrix: ");
for ( int i=0; i<16; ++i )
logTestString("%.2f ", m[i]);
logTestString("\n");
return false;
}
bool setRotationAxis()
{
matrix4 m;
vector3df v;
// y up, x right, z depth (as usual)
// y rotated around x-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(1,0,0)), vector3df(0,1,0), vector3df(0, 0, 1)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
if ( !checkMatrixRotation( m.setRotationAxisRadians(180.f*DEGTORAD, vector3df(1,0,0)), vector3df(0,1,0), vector3df(0, -1, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// y rotated around negative x-axis
m.makeIdentity();
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(-1,0,0)), vector3df(0,1,0), vector3df(0, 0, -1)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// x rotated around x-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(1,0,0)), vector3df(1,0,0), vector3df(1, 0, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// x rotated around y-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(0,1,0)), vector3df(1,0,0), vector3df(0, 0, -1)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
if ( !checkMatrixRotation( m.setRotationAxisRadians(180.f*DEGTORAD, vector3df(0,1,0)), vector3df(1,0,0), vector3df(-1, 0, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// x rotated around negative y-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(0,-1,0)), vector3df(1,0,0), vector3df(0, 0, 1)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// y rotated around y-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(0,1,0)), vector3df(0,1,0), vector3df(0, 1, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// x rotated around z-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(0,0,1)), vector3df(1,0,0), vector3df(0, 1, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
if ( !checkMatrixRotation( m.setRotationAxisRadians(180.f*DEGTORAD, vector3df(0,0,1)), vector3df(1,0,0), vector3df(-1, 0, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// x rotated around negative z-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(0,0,-1)), vector3df(1,0,0), vector3df(0, -1, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// y rotated around z-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(0,0,1)), vector3df(0,1,0), vector3df(-1, 0, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
if ( !checkMatrixRotation( m.setRotationAxisRadians(180.f*DEGTORAD, vector3df(0,0,1)), vector3df(0,1,0), vector3df(0, -1, 0)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
// z rotated around z-axis
if ( !checkMatrixRotation( m.setRotationAxisRadians(90.f*DEGTORAD, vector3df(0,0,1)), vector3df(0,0,1), vector3df(0, 0, 1)) )
{
logTestString("%s:%d", __FILE__, __LINE__);
return false;
}
return true;
}
// just calling each function once to find compile problems
void calltest()
{
matrix4 mat;
matrix4 mat2(mat);
f32& f1 = mat(0,0);
const f32& f2 = mat(0,0);
f32& f3 = mat[0];
const f32& f4 = mat[0];
mat = mat;
mat = 1.f;
const f32 * pf1 = mat.pointer();
f32 * pf2 = mat.pointer();
bool b = mat == mat2;
b = mat != mat2;
mat = mat + mat2;
mat += mat2;
mat = mat - mat2;
mat -= mat2;
mat.setbyproduct(mat, mat2);
mat.setbyproduct_nocheck(mat, mat2);
mat = mat * mat2;
mat *= mat2;
mat = mat * 10.f;
mat *= 10.f;
mat.makeIdentity();
b = mat.isIdentity();
b = mat.isOrthogonal();
b = mat.isIdentity_integer_base ();
mat.setTranslation(vector3df(1.f, 1.f, 1.f) );
vector3df v1 = mat.getTranslation();
mat.setInverseTranslation(vector3df(1.f, 1.f, 1.f) );
mat.setRotationRadians(vector3df(1.f, 1.f, 1.f) );
mat.setRotationDegrees(vector3df(1.f, 1.f, 1.f) );
vector3df v2 = mat.getRotationDegrees();
mat.setInverseRotationRadians(vector3df(1.f, 1.f, 1.f) );
mat.setInverseRotationDegrees(vector3df(1.f, 1.f, 1.f) );
mat.setRotationAxisRadians(1.f, vector3df(1.f, 1.f, 1.f) );
mat.setScale(vector3df(1.f, 1.f, 1.f) );
mat.setScale(1.f);
vector3df v3 = mat.getScale();
mat.inverseTranslateVect(v1);
mat.inverseRotateVect(v1);
mat.rotateVect(v1);
mat.rotateVect(v1, v2);
f32 fv3[3];
mat.rotateVect(fv3, v1);
mat.transformVect(v1);
mat.transformVect(v1, v1);
f32 fv4[4];
mat.transformVect(fv4, v1);
mat.transformVec3(fv3, fv3);
mat.translateVect(v1);
plane3df p1;
mat.transformPlane(p1);
mat.transformPlane(p1, p1);
aabbox3df bb1;
mat.transformBox(bb1);
mat.transformBoxEx(bb1);
mat.multiplyWith1x4Matrix(fv4);
mat.makeInverse();
b = mat.getInversePrimitive(mat2);
b = mat.getInverse(mat2);
mat.buildProjectionMatrixPerspectiveFovRH(1.f, 1.f, 1.f, 1000.f);
mat.buildProjectionMatrixPerspectiveFovLH(1.f, 1.f, 1.f, 1000.f);
mat.buildProjectionMatrixPerspectiveFovInfinityLH(1.f, 1.f, 1.f);
mat.buildProjectionMatrixPerspectiveRH(100.f, 100.f, 1.f, 1000.f);
mat.buildProjectionMatrixPerspectiveLH(10000.f, 10000.f, 1.f, 1000.f);
mat.buildProjectionMatrixOrthoLH(10000.f, 10000.f, 1.f, 1000.f);
mat.buildProjectionMatrixOrthoRH(10000.f, 10000.f, 1.f, 1000.f);
mat.buildCameraLookAtMatrixLH(vector3df(1.f, 1.f, 1.f), vector3df(0.f, 0.f, 0.f), vector3df(0.f, 1.f, 0.f) );
mat.buildCameraLookAtMatrixRH(vector3df(1.f, 1.f, 1.f), vector3df(0.f, 0.f, 0.f), vector3df(0.f, 1.f, 0.f) );
mat.buildShadowMatrix(vector3df(1.f, 1.f, 1.f), p1);
core::rect<s32> a1(0,0,100,100);
mat.buildNDCToDCMatrix(a1, 1.f);
mat.interpolate(mat2, 1.f);
mat = mat.getTransposed();
mat.getTransposed(mat2);
mat.buildRotateFromTo(vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f));
mat.setRotationCenter(vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f));
mat.buildAxisAlignedBillboard(vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f), vector3df(1.f, 1.f, 1.f));
mat.buildTextureTransform( 1.f,vector2df(1.f, 1.f), vector2df(1.f, 1.f), vector2df(1.f, 1.f));
mat.setTextureRotationCenter( 1.f );
mat.setTextureTranslate( 1.f, 1.f );
mat.setTextureTranslateTransposed(1.f, 1.f);
mat.setTextureScale( 1.f, 1.f );
mat.setTextureScaleCenter( 1.f, 1.f );
f32 fv16[16];
mat.setM(fv16);
mat.setDefinitelyIdentityMatrix(false);
b = mat.getDefinitelyIdentityMatrix();
b = mat.equals(mat2);
f1 = f1+f2+f3+f4+*pf1+*pf2; // getting rid of unused variable warnings.
}
}
bool matrixOps(void)
{
bool result = true;
calltest();
result &= identity();
result &= rotations();
result &= isOrthogonal();
result &= transformations();
result &= setRotationAxis();
return result;
}

View File

@ -1,128 +0,0 @@
// Copyright (C) 2008-2012 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
namespace
{
// Tests MD2 animations.
/** At the moment, this just verifies that the last frame of the animation produces the expected bitmap. */
bool testLastFrame()
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
if (!device)
return false;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = smgr->getMesh("./media/sydney.md2");
bool result = (mesh != 0);
if (mesh)
{
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
if (node)
{
node->setPosition(vector3df(20, 0, 30));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, driver->getTexture("./media/sydney.bmp"));
node->setLoopMode(false);
(void)smgr->addCameraSceneNode();
// Just jump to the last frame since that's all we're interested in.
node->setMD2Animation(scene::EMAT_DEATH_FALLBACK);
node->setCurrentFrame((f32)(node->getEndFrame()));
node->setAnimationSpeed(0);
device->run();
driver->beginScene(true, true, video::SColor(255, 255, 255, 0));
smgr->drawAll();
driver->endScene();
if (mesh->getBoundingBox() != mesh->getMesh(node->getEndFrame())->getBoundingBox())
{
logTestString("bbox of md2 mesh not updated.\n");
result = false;
}
//TODO: Does not yet work, not sure if this is correct or not
#if 0
if (node->getBoundingBox() != mesh->getMesh(node->getFrameNr())->getBoundingBox())
{
logTestString("bbox of md2 scene node not updated.\n");
result = false;
}
#endif
if (node->getTransformedBoundingBox() == core::aabbox3df())
{
logTestString("md2 node returns empty bbox.\n");
result = false;
}
}
}
result &= takeScreenshotAndCompareAgainstReference(driver, "-md2Animation.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
// Tests MD2 normals.
bool testNormals()
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
if (!device)
return false;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager * smgr = device->getSceneManager();
scene::IAnimatedMesh* mesh = smgr->getMesh("./media/sydney.md2");
bool result = (mesh != 0);
if (mesh)
{
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
if (node)
{
node->setPosition(vector3df(20, 0, 30));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setDebugDataVisible(scene::EDS_NORMALS);
node->setMaterialTexture(0, driver->getTexture("./media/sydney.bmp"));
node->setLoopMode(false);
(void)smgr->addCameraSceneNode();
node->setMD2Animation(scene::EMAT_STAND);
node->setAnimationSpeed(0);
device->run();
driver->beginScene(true, true, video::SColor(255, 255, 255, 0));
smgr->drawAll();
driver->endScene();
}
}
result &= takeScreenshotAndCompareAgainstReference(driver, "-md2Normals.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
}
// test md2 features
bool md2Animation(void)
{
bool result = testLastFrame();
result &= testNormals();
return result;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 740 B

Some files were not shown because too many files have changed in this diff Show More