diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Basic2D/Basic2D.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Basic2D/Basic2D.vcxproj index 7f1133e..9b8d980 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Basic2D/Basic2D.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Basic2D/Basic2D.vcxproj @@ -37,56 +37,56 @@ {6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495} Basic2D - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_Includepath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\VuzixSDK\inc;$(SolutionDir)SDK\DirectXTex\DirectXTex;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -194,7 +194,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\VuzixSDK\Lib;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bitmap/Bitmap.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bitmap/Bitmap.vcxproj index e8e13e3..655461a 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bitmap/Bitmap.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bitmap/Bitmap.vcxproj @@ -36,56 +36,56 @@ {D7763803-1667-4016-ACA2-F595DD7581ED} - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -175,7 +175,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -185,7 +185,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bullet/Bullet.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bullet/Bullet.vcxproj index 159dd70..8558bed 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bullet/Bullet.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Bullet/Bullet.vcxproj @@ -37,56 +37,56 @@ {4A04C2F5-7052-47E2-AC88-2BA8AE2DD9F3} ODE - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,8 +184,8 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\BULLET\bullet-2.81-rev2613\lib\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\BULLET\bullet-2.81-rev2613\lib\;$(LibraryPath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\BULLET\bullet-2.81-rev2613\lib\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Camera/Camera.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Camera/Camera.vcxproj index 43ff439..5168f37 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Camera/Camera.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Camera/Camera.vcxproj @@ -37,56 +37,56 @@ {1311DBF5-D188-4034-B25D-AE7A36878C01} Camera - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -194,7 +194,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/ConvX/ConvX.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/ConvX/ConvX.vcxproj index a1fd658..ff3dc1d 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/ConvX/ConvX.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/ConvX/ConvX.vcxproj @@ -37,56 +37,56 @@ {06E6A302-6658-4E0E-A894-577D5BD556D7} ConvX - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -176,7 +176,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\DirectX 2007 Extras\lib\;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -186,7 +186,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\DirectX 2007 Extras\lib\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\DirectX 2007 Extras\lib\;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\DirectX 2007 Extras\lib\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Core/DBDLLCore.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Core/DBDLLCore.vcxproj index 1e4daef..571ad89 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Core/DBDLLCore.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Core/DBDLLCore.vcxproj @@ -37,56 +37,56 @@ {B81553CC-39BB-4542-A379-F49D2F3A73A3} DBDLLCore - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -176,7 +176,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\VuzixSDK\inc\;$(SolutionDir)SDK\DirectXTex\DirectXTex\Bin\Desktop_2022\x64\Release;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -186,7 +186,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Lib\x64;$(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\Release;$(SolutionDir)SDK\DirectXTex\DirectXTex\Bin\Desktop_2022\x64\Release;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\VuzixSDK\lib;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/FTP/FTP.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/FTP/FTP.vcxproj index 492b9f2..5f16459 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/FTP/FTP.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/FTP/FTP.vcxproj @@ -37,56 +37,56 @@ {C0A62805-4411-4176-A24A-91CE14219778} FTP - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -194,7 +194,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/File/File.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/File/File.vcxproj index 7e39118..11f986c 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/File/File.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/File/File.vcxproj @@ -37,56 +37,56 @@ {19D06E7C-892B-4461-87C6-166634AB6513} File - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -176,7 +176,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -186,7 +186,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Image/Image.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Image/Image.vcxproj index f94c817..b0badb3 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Image/Image.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Image/Image.vcxproj @@ -37,56 +37,56 @@ {8BA32D12-D5B1-412B-967A-C329376CBEC6} Image - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\DirectXTex\DirectXTex\;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader\;$(SolutionDir)SDK\DirectXTex\DirectXTex\ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\DirectXTex\DirectXTex\;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader\;$(SolutionDir)SDK\DirectXTex\DirectXTex\ - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\DirectXTex\DirectXTex\;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader\;$(SolutionDir)SDK\DirectXTex\DirectXTex\;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\DirectXTex\DirectXTex\;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\DirectXTex\DirectXTex\;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader\;$(SolutionDir)SDK\DirectXTex\DirectXTex\ @@ -194,7 +194,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Input/Input.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Input/Input.vcxproj index 86c2925..59c0f71 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Input/Input.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Input/Input.vcxproj @@ -37,56 +37,56 @@ {3B7BC9B2-3FDB-4129-A700-59F05B480293} Input - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -194,7 +194,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Light/Light.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Light/Light.vcxproj index cd623a8..633e0c5 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Light/Light.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Light/Light.vcxproj @@ -36,56 +36,56 @@ {8563B5F0-10AC-494E-B27B-0A7AFD0BD0E1} - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -183,7 +183,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -193,7 +193,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Memblocks/Memblocks.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Memblocks/Memblocks.vcxproj index f834bf5..5725974 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Memblocks/Memblocks.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Memblocks/Memblocks.vcxproj @@ -37,56 +37,56 @@ {FDB42674-ABA0-41AC-9552-C5B6A6DECDDB} Memblocks - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -176,7 +176,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -186,7 +186,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Objects/Objects.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Objects/Objects.vcxproj index 16fa61e..46455a6 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Objects/Objects.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Objects/Objects.vcxproj @@ -37,56 +37,56 @@ {5EC29E1C-8C20-4C9C-9C2D-71493CE16D73} Objects - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath);D:\Apps\Microsoft DirectX SDK (August 2007)\Lib\x86 C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI Basic3D Basic3D @@ -202,7 +202,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath);D:\Apps\Microsoft DirectX SDK (August 2007)\Lib\x86 - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath);D:\Apps\Microsoft DirectX SDK (August 2007)\Lib\x86 + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Setup/Setup.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Setup/Setup.vcxproj index df031e2..c2fd610 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Setup/Setup.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Setup/Setup.vcxproj @@ -37,56 +37,56 @@ {C22CB11E-0592-4DDD-B8D8-296FCA25F07C} Setup - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\DirectX\Effect11\Bin;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\VuzixSDK\lib;$(LibraryPath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\VuzixSDK\inc C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\VuzixSDK\inc - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\VuzixSDK\inc;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\VuzixSDK\inc;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\VuzixSDK\inc @@ -194,7 +194,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\DirectX\Effect11\Bin;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\VuzixSDK\lib;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\DirectX\Effect11\Bin;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\VuzixSDK\lib;$(LibraryPath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(SolutionDir)SDK\VuzixSDK\lib;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Sprites/Sprites.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Sprites/Sprites.vcxproj index 12b6c8e..2d8eaf0 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Sprites/Sprites.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Sprites/Sprites.vcxproj @@ -36,56 +36,56 @@ {368D8DDB-C349-4FF1-A848-1D14C0944500} - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -183,7 +183,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -193,7 +193,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/System/System.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/System/System.vcxproj index 75471f3..8d4efdf 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/System/System.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/System/System.vcxproj @@ -37,56 +37,56 @@ {35D0D628-907B-4378-95E1-EEF2B5E891BF} System - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -180,7 +180,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -190,7 +190,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Text/Text.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Text/Text.vcxproj index 3c264a8..41a764f 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Text/Text.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Text/Text.vcxproj @@ -37,56 +37,56 @@ {73383739-8763-47B9-8A3F-6727B491191D} Text - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -184,7 +184,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -194,7 +194,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Vectors/Vectors.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Vectors/Vectors.vcxproj index 438f77d..e88c58c 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Vectors/Vectors.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDK/Vectors/Vectors.vcxproj @@ -37,56 +37,56 @@ {E72F0AB4-B8E1-4424-96DC-4C23F167FCA6} Vectors - 10.0.17763.0 + 10.0 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 StaticLibrary false MultiByte - v141 + v143 @@ -176,7 +176,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI @@ -186,7 +186,7 @@ C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath); + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj deleted file mode 100644 index 06e76dd..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj +++ /dev/null @@ -1,317 +0,0 @@ - - - - - Debug GAME - Win32 - - - Debug GAME - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {DC3D254B-0B9C-4272-B2DC-D0B06835D3A0} - BlitzTerrain - Win32Proj - 10.0.17763.0 - - - - StaticLibrary - false - MultiByte - false - true - v141 - - - StaticLibrary - MultiByte - false - v141 - - - StaticLibrary - MultiByte - false - v141 - - - DynamicLibrary - false - MultiByte - false - false - v141 - - - DynamicLibrary - MultiByte - false - v141 - - - DynamicLibrary - MultiByte - false - v141 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(ProjectDir)..\..\..\Lib\ - $(ProjectDir)..\..\..\Lib\ - $(Configuration)\ - $(Configuration)\ - true - true - $(ProjectDir)..\..\..\Lib64\ - $(ProjectDir)..\..\..\Lib64\ - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - true - $(ProjectDir)..\..\..\Lib\ - $(Configuration)\ - $(ProjectDir)..\..\..\Lib64\ - $(Platform)\$(Configuration)\ - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI; - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI; - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - - - - Disabled - false - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - true - Fast - - - Level3 - EditAndContinue - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - 4005 - - - F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\BlitzTerrain.dll - true - Windows - - - MachineX86 - - - MachineX86 - - - - - Disabled - false - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - true - Fast - - - Level3 - EditAndContinue - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - 4005 - - - F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\BlitzTerrain.dll - true - Windows - - - MachineX86 - - - MachineX86 - - - - - X64 - - - Disabled - false - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - C:\DBPro\Compiler\plugins-user\BlitzTerrain.dll - true - Windows - - - MachineX64 - - - - - X64 - - - Disabled - false - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - C:\DBPro\Compiler\plugins-user\BlitzTerrain.dll - true - Windows - - - MachineX64 - - - - - MaxSpeed - AnySuitable - true - Speed - false - WIN32;NDEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_EXPORTS;%(PreprocessorDefinitions) - MultiThreaded - true - Fast - /J - - - AssemblyAndMachineCode - Level3 - - - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - 4005;4995;4723 - - - $(TargetPath) - false - true - UseLinkTimeCodeGeneration - MachineX86 - - - MachineX86 - - - - - X64 - - - Full - Default - true - Speed - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_EXPORTS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Fast - /J - - - AssemblyAndMachineCode - Level3 - - - - - C:\DBPro\Compiler\plugins-user\BlitzTerrain.dll - true - UseLinkTimeCodeGeneration - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj.filters b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj.filters deleted file mode 100644 index 001f722..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj.filters +++ /dev/null @@ -1,71 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj.user b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj.user deleted file mode 100644 index be25078..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/BlitzTerrain.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/CreateObject.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/CreateObject.cpp deleted file mode 100644 index 139ed1c..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/CreateObject.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "CreateObject.h" -#include "CObjectsC.h" - -void BT_Intern_Error(int); - -// This is the function that creates everything. -sObject* BT_Intern_CreateBlankObject(DWORD ObjectId, DWORD FrameCount) -{ - CreateNewObject(ObjectId,"BlitzTerrain", FrameCount); - sObject* Object = GetObjectData(ObjectId); - return Object; -} - -void BT_Intern_SetupMesh(sMesh* Mesh, DWORD VertexCount, DWORD IndexCount, DWORD Fvf) -{ - SetupMeshFVFData( Mesh, Fvf, VertexCount, IndexCount, false ); - Mesh->iPrimitiveType = GGPT_TRIANGLELIST; - Mesh->iDrawVertexCount = VertexCount; - Mesh->iDrawPrimitives = (IndexCount ? IndexCount : VertexCount) / 3; - return; -} - -void BT_Intern_FinnishObject(unsigned long ObjectID) -{ - SetNewObjectFinalProperties(ObjectID, 0.0f); - TextureObject(ObjectID,0); - return; -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/CreateObject.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/CreateObject.h deleted file mode 100644 index 347673e..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/CreateObject.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _CREATEOBJECT_H -#define _CREATEOBJECT_H - -#define WIN32_LEAN_AND_MEAN -#include - -#include "globstruct.h" -#include ".\..\..\Shared\DBOFormat\DBOData.h" - -sObject* BT_Intern_CreateBlankObject(DWORD ObjectId, DWORD FrameCount); -void BT_Intern_SetupMesh(sMesh* Mesh, DWORD VertexCount, DWORD IndexCount, DWORD Fvf); -void BT_Intern_FinnishObject(unsigned long ObjectID); - -void CO_ReceiveCoreDataPtr(LPVOID CorePtr); - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/EnvironmentMapping.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/EnvironmentMapping.cpp deleted file mode 100644 index aa3ef7d..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/EnvironmentMapping.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "EnvironmentMapping.h" -#include "main.h" -#include -#include - -unsigned short BT_Intern_AddEnvironment(BT_EnvironmentMap* EnvironmentMap,unsigned long Colour) -{ -//Check that this environment map is not made - if(EnvironmentMap->Made==false) - { - //Increase buffer size - EnvironmentMap->EnvironmentCount++; - EnvironmentMap->EnvironmentBuffer=(unsigned long*)realloc(EnvironmentMap->EnvironmentBuffer,(EnvironmentMap->EnvironmentCount+1)*sizeof(unsigned long)); - if(EnvironmentMap->EnvironmentBuffer==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - //EnvironmentMap->EnvironmentDetailMap=(unsigned long*)realloc(EnvironmentMap->EnvironmentBuffer,(EnvironmentMap->EnvironmentCount+1)*sizeof(unsigned long)); - - //Set last value - EnvironmentMap->EnvironmentBuffer[EnvironmentMap->EnvironmentCount]=Colour; - //EnvironmentMap->EnvironmentDetailMap[EnvironmentMap->EnvironmentCount]=0; - - //Return count - return EnvironmentMap->EnvironmentCount; - } - -//Return nothing - return 0; -} - -void BT_Intern_CreateEnvironmentMap(BT_EnvironmentMap* EnvironmentMap,unsigned long Width,unsigned long Height,unsigned long* Buffer) -{ -//Allocate buffer - EnvironmentMap->Buffer=(unsigned short*)malloc(Width*Height*sizeof(unsigned short)); - if(EnvironmentMap->Buffer==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(EnvironmentMap->Buffer,0,Width*Height*sizeof(unsigned short)); - -//Set width and height - EnvironmentMap->Width=Width; - EnvironmentMap->Height=Height; - -//Loop through points and add to the environment map - for(unsigned long x=0;xEnvironmentCount+1;CurrentEnvironment++) - { - if(EnvironmentMap->EnvironmentBuffer[CurrentEnvironment]==Buffer[x+y*Width]) - EnvironmentMap->Buffer[x+y*Width]=CurrentEnvironment; - } - } - } - -//Cleanup - free(EnvironmentMap->EnvironmentBuffer); - EnvironmentMap->EnvironmentBuffer=0; - -//Say that its made - EnvironmentMap->Made=true; -} - -void BT_Intern_CleanupEnvironmentMap(BT_EnvironmentMap* EnvironmentMap) -{ - free(EnvironmentMap->EnvironmentBuffer); - EnvironmentMap->EnvironmentBuffer=0; -} - -void BT_Intern_DeleteEnvironmentMap(BT_EnvironmentMap* EnvironmentMap) -{ -//Delete Environment info - if(EnvironmentMap->EnvironmentBuffer!=0) - free(EnvironmentMap->EnvironmentBuffer); - -//Delete buffer - if(EnvironmentMap->Buffer!=0) - free(EnvironmentMap->Buffer); - -//Clean up - memset(EnvironmentMap,0,sizeof(BT_EnvironmentMap)); -} - -unsigned short BT_Intern_GetPointEnvironment(BT_EnvironmentMap* EnvironmentMap,unsigned long x,unsigned long y) -{ - return EnvironmentMap->Buffer[x+y*EnvironmentMap->Width]; -} - -void BT_Intern_SetEnvironmentDetailmap(BT_EnvironmentMap* EnvironmentMap,unsigned short EnvironmentMapID,unsigned long DetailMapID) -{ - EnvironmentMap->EnvironmentDetailMap[EnvironmentMapID]=DetailMapID; -} - -unsigned long BT_Intern_GetEnvironmentDetailmap(BT_EnvironmentMap* EnvironmentMap,unsigned short EnvironmentMapID) -{ - return EnvironmentMap->EnvironmentDetailMap[EnvironmentMapID]; -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/EnvironmentMapping.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/EnvironmentMapping.h deleted file mode 100644 index e3fd9be..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/EnvironmentMapping.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _ENVIRONMENTMAPPING_H -#define _ENVIRONMENTMAPPING_H - -struct BT_EnvironmentMap -{ - bool Made; - unsigned long Width; - unsigned long Height; - unsigned short* Buffer; - - unsigned short EnvironmentCount; - unsigned long* EnvironmentBuffer; - unsigned long* EnvironmentDetailMap; -}; - - -unsigned short BT_Intern_AddEnvironment(BT_EnvironmentMap* EnvironmentMap,unsigned long Colour); -void BT_Intern_CreateEnvironmentMap(BT_EnvironmentMap* EnvironmentMap,unsigned long Width,unsigned long Height,unsigned long* Buffer); -void BT_Intern_DeleteEnvironmentMap(BT_EnvironmentMap* EnvironmentMap); -unsigned short BT_Intern_GetPointEnvironment(BT_EnvironmentMap* EnvironmentMap,unsigned long x,unsigned long y); -void BT_Intern_SetEnvironmentDetailmap(BT_EnvironmentMap* EnvironmentMap,unsigned short EnvironmentMapID,unsigned long DetailMapID); -unsigned long BT_Intern_GetEnvironmentDetailmap(BT_EnvironmentMap* EnvironmentMap,unsigned short EnvironmentMapID); - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO.cpp deleted file mode 100644 index 2363798..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include "FileIO.h" -#include "CreateObject.h" -#include - -extern s_BT_main BT_Main; - - -#ifndef COMPILE_GDK - extern t_dbGetDirect3DDevice dbGetDirect3DDevice; -#endif - -EXPORT unsigned long BT_LoadTerrain(char* FileName,unsigned long ObjectID) -{ - return BT_LoadTerrain(FileName,ObjectID,false); -} - -EXPORT unsigned long BT_LoadTerrain(char* FileName,unsigned long ObjectID,bool GenerateTerrain) -{ -//Set current function - BT_Main.CurrentFunction=C_BT_FUNCTION_LOADTERRAIN; - -//Variables - ifstream File; - s_BT_terrain* TerrainPtr; - unsigned short TempShort; - unsigned long TerrainID; - -//Open the file - File.open(FileName,ios::in | ios::app | ios::binary); - -//Check the magic number - File.read((char*)&TempShort,sizeof(unsigned short)); - if(TempShort!=21570) - { - BT_Intern_Error(C_BT_ERROR_INVALIDFILE); - return 0; - } - -//Check the file version - File.read((char*)&TempShort,sizeof(unsigned short)); - if(TempShort!=1 && TempShort!=101) - { - BT_Intern_Error(C_BT_ERROR_VERSIONCANNOTREADFILE); - return 0; - } - unsigned short Version=TempShort; - File.read((char*)&TempShort,sizeof(unsigned short)); - if(TempShort>C_BT_VERSION) - { - BT_Intern_Error(C_BT_ERROR_VERSIONCANNOTREADFILE); - return 0; - } - -//Load the map - TerrainID=0; - if(Version==1) - TerrainID=LoadTerrain100(&File,ObjectID,GenerateTerrain); - - if(Version==101) - TerrainID=LoadTerrain101(&File,ObjectID,GenerateTerrain); - - if(TerrainID==NULL) - return 0; - TerrainPtr=&BT_Main.Terrains[TerrainID]; - File.close(); - -//Allocate quadtree - TerrainPtr->QuadTree=BT_Intern_AllocateQuadTree(TerrainPtr); - -//Create LOD Map - TerrainPtr->LODMap=(s_BT_LODMap**)malloc(TerrainPtr->LODLevel[0].Split*sizeof(s_BT_LODMap*)); - if(TerrainPtr->LODMap==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - for(unsigned long i=0;iLODLevel[0].Split;i++) - { - TerrainPtr->LODMap[i]=(s_BT_LODMap*)malloc(TerrainPtr->LODLevel[0].Split*sizeof(s_BT_LODMap)); - if(TerrainPtr->LODMap[i]==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(TerrainPtr->LODMap[i],0,TerrainPtr->LODLevel[0].Split*sizeof(s_BT_LODMap)); - } - -//Vertex Declaration - IDirect3DDevice9* D3DDevice=dbGetDirect3DDevice(); - //VD Array - const D3DVERTEXELEMENT9 VD[5] = - { - {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION,0}, - {0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, - {0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,0}, - {0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,1}, - D3DDECL_END() - }; - //Make Vertex Declaration - D3DDevice->CreateVertexDeclaration(VD,&TerrainPtr->VertexDeclaration); - -//Initialise build - BT_Main.Building=1; - BT_Main.BuildType=0; - BT_Main.CurrentBuildTerrain=TerrainPtr; - BT_Main.CurrentBuildSector=0; - BT_Main.CurrentBuildRow=0; - BT_Main.CurrentBuildColumn=0; - BT_Main.CurrentBuildTerrainSector=0; - TerrainPtr->Built=1; - -//Build - if(GenerateTerrain==true) - { - unsigned long tempbuildstep=BT_Main.buildstep; - BT_Main.buildstep=0; - int null=BT_ContinueBuild(); - BT_Main.buildstep=tempbuildstep; - } - -//Add RTTMS update handler - BT_RTTMS_AddUpdateHandler(TerrainID,BT_Intern_RTTMSUpdateHandler); - - return TerrainID; -} - -EXPORT void BT_SaveTerrain(unsigned long TerrainID,char* FileName) -{ -//Set current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SAVETERRAIN; - -//Variables - ofstream File; - s_BT_terrain* TerrainPtr; - unsigned short TempShort; - s_BT_FileTerrainHeader101* TerrainHeader; - -//Check that the terrain exists and it is built - if(BT_Intern_TerrainExist(TerrainID)==true) - { - TerrainPtr=&BT_Main.Terrains[TerrainID]; - if(TerrainPtr->Built==true) - { - //Open the file - File.open(FileName,ios::out | ios::app | ios::binary); - - //Write the magic number - TempShort=21570; //This magically turns into "BT" - File.write((char*)&TempShort,sizeof(unsigned short)); - - //Write the filesystem version - TempShort=101; - File.write((char*)&TempShort,sizeof(unsigned short)); - - //Write the minimum version of blitzterrain to read the file - TempShort=C_FILE_MINBTREADVERSION; - File.write((char*)&TempShort,sizeof(unsigned short)); - - //Write the header size - TempShort=sizeof(s_BT_FileTerrainHeader101); - File.write((char*)&TempShort,sizeof(unsigned short)); - - //Make the terrain header - TerrainHeader=BT_Intern_MakeDefaultTerrainHeader101(); - BT_Intern_FillTerrainHeader101(TerrainHeader,TerrainPtr); - - //Write the terrain header - File.write((char*)TerrainHeader,sizeof(s_BT_FileTerrainHeader101)); - - //Free the terrain header - free(TerrainHeader); - - //Make the LODLevel and Sector header - s_BT_FileLODLevelHeader101* LODLevelHeader=BT_Intern_MakeDefaultLODLevelHeader101(); - s_BT_FileSectorHeader101* SectorHeader=BT_Intern_MakeDefaultSectorHeader101(); - - //Loop through LODLevels - for(unsigned long LODLevel=0;LODLevelLODLevels;LODLevel++) - { - //Get the LODLevel pointer and fill the LODLevel Header - s_BT_LODLevel* LODLevelPtr=&TerrainPtr->LODLevel[LODLevel]; - BT_Intern_FillLODLevelHeader101(LODLevelHeader,LODLevelPtr); - - //Write the header size - TempShort=sizeof(s_BT_FileLODLevelHeader101); - File.write((char*)&TempShort,sizeof(unsigned short)); - - //Write the header - File.write((char*)LODLevelHeader,sizeof(s_BT_FileLODLevelHeader101)); - - //Loop through Sectors - for(unsigned long Sector=0;SectorSectors;Sector++) - { - //Get the Sector pointer and fill the Sector Header - s_BT_Sector* SectorPtr=&LODLevelPtr->Sector[Sector]; - BT_Intern_FillSectorHeader101(SectorHeader,SectorPtr); - - //Write the header size - TempShort=sizeof(s_BT_FileSectorHeader101); - File.write((char*)&TempShort,sizeof(unsigned short)); - - //Write the header - File.write((char*)SectorHeader,sizeof(s_BT_FileSectorHeader101)); - - //Make the quadmap - //char* QuadMapBuffer; - //unsigned long QuadMapBufferSize; - //SectorPtr->QuadMap->MakeBuffer(&QuadMapBuffer,&QuadMapBufferSize); - - //Write the quadmap size - //File.write((char*)&QuadMapBufferSize,sizeof(unsigned long)); - - //Write the quadmap - //File.write(QuadMapBuffer,QuadMapBufferSize); - - //Delete the quadmap - //free((void*)QuadMapBuffer); - } - } - - //Free headers - free(LODLevelHeader); - free(SectorHeader); - - //Close the file - File.close(); - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINNOTBUILT); - return; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO.h deleted file mode 100644 index bd9ef07..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef _FILEIO_H -#define _FILEIO_H - -#include "main.h" - - -#define C_FILE_FILESYSTEMVERSION 1 //Filesystem version -#define C_FILE_MINBTREADVERSION 200 //Minimum version of blitzterrain needed to read the file - -struct s_BT_FileTerrainHeader100 -{ - unsigned long Flags; - unsigned char LODLevels; - float Scale; - float YScale; - float Tile; - unsigned short Sectors; - unsigned short HeightmapSize; - float TerrainSize; - unsigned char ExclusionThreshold; - unsigned long FVF; - unsigned char ATMode; - unsigned char DetailBlendMode; -}; - -struct s_BT_FileLODLevelHeader100 -{ - float SectorSize; - unsigned char SectorDetail; - unsigned short Sectors; - float Distance; - unsigned short Split; - unsigned char TileSpan; -}; - -struct s_BT_FileSectorHeader100 -{ - bool Excluded; - unsigned short Row; - unsigned short Column; - float PosX; - float PosY; - float PosZ; -}; - -struct s_BT_FileTerrainHeader101 -{ - unsigned long Flags; - unsigned char LODLevels; - float Scale; - float YScale; - float Tile; - unsigned short Sectors; - unsigned short HeightmapSize; - float TerrainSize; - unsigned char ExclusionThreshold; - unsigned long FVF; - unsigned char ATMode; - unsigned char DetailBlendMode; -}; - -struct s_BT_FileLODLevelHeader101 -{ - float SectorSize; - unsigned char SectorDetail; - unsigned short Sectors; - float Distance; - unsigned short Split; - unsigned char TileSpan; -}; - -struct s_BT_FileSectorHeader101 -{ - bool Excluded; - unsigned short Row; - unsigned short Column; -}; - -EXPORT unsigned long BT_LoadTerrain(char* FileName,unsigned long ObjectID); -EXPORT unsigned long BT_LoadTerrain(char* FileName,unsigned long ObjectID,bool GenerateTerrain); -EXPORT void BT_SaveTerrain(unsigned long TerrainID,char* FileName); - -unsigned long LoadTerrain100(ifstream *File,unsigned long ObjectID,bool GenerateTerrain); -s_BT_FileTerrainHeader100 *BT_Intern_MakeDefaultTerrainHeader100(); -void BT_Intern_FillTerrainHeader100(s_BT_FileTerrainHeader100* Header,s_BT_terrain* Terrain); -void BT_Intern_FillTerrainHeaderDefault100(s_BT_FileTerrainHeader100* Header); -s_BT_FileLODLevelHeader100 *BT_Intern_MakeDefaultLODLevelHeader100(); -void BT_Intern_FillLODLevelHeader100(s_BT_FileLODLevelHeader100* Header,s_BT_LODLevel* LODLevel); -void BT_Intern_FillLODLevelHeaderDefault100(s_BT_FileLODLevelHeader100* Header); -s_BT_FileSectorHeader100 *BT_Intern_MakeDefaultSectorHeader100(); -void BT_Intern_FillSectorHeader100(s_BT_FileSectorHeader100* Header,s_BT_Sector* Sector); -void BT_Intern_FillSectorHeaderDefault100(s_BT_FileSectorHeader100* Header); - -unsigned long LoadTerrain101(ifstream *File,unsigned long ObjectID,bool GenerateTerrain); -s_BT_FileTerrainHeader101 *BT_Intern_MakeDefaultTerrainHeader101(); -void BT_Intern_FillTerrainHeader101(s_BT_FileTerrainHeader101* Header,s_BT_terrain* Terrain); -void BT_Intern_FillTerrainHeaderDefault101(s_BT_FileTerrainHeader101* Header); -s_BT_FileLODLevelHeader101 *BT_Intern_MakeDefaultLODLevelHeader101(); -void BT_Intern_FillLODLevelHeader101(s_BT_FileLODLevelHeader101* Header,s_BT_LODLevel* LODLevel); -void BT_Intern_FillLODLevelHeaderDefault101(s_BT_FileLODLevelHeader101* Header); -s_BT_FileSectorHeader101 *BT_Intern_MakeDefaultSectorHeader101(); -void BT_Intern_FillSectorHeader101(s_BT_FileSectorHeader101* Header,s_BT_Sector* Sector); -void BT_Intern_FillSectorHeaderDefault101(s_BT_FileSectorHeader101* Header); - - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO100.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO100.cpp deleted file mode 100644 index 3e1af26..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO100.cpp +++ /dev/null @@ -1,363 +0,0 @@ -#include "FileIO.h" -#include "CreateObject.h" -#include - -extern s_BT_main BT_Main; - - -#ifndef COMPILE_GDK - extern t_dbGetDirect3DDevice dbGetDirect3DDevice; -#endif - -unsigned long LoadTerrain100(ifstream *File,unsigned long ObjectID,bool GenerateTerrain) -{ -//Set current function - BT_Main.CurrentFunction=C_BT_FUNCTION_LOADTERRAIN; - -//Variables - s_BT_terrain* TerrainPtr; - unsigned short TempShort; - s_BT_FileTerrainHeader100* TerrainHeader; - unsigned long TerrainID; - -//Make a new terrain - TerrainID=BT_MakeTerrain(); - TerrainPtr=&BT_Main.Terrains[TerrainID]; - -//Make a terrain header - TerrainHeader=BT_Intern_MakeDefaultTerrainHeader100(); - -//Load header from file - File->read((char*)&TempShort,sizeof(unsigned short)); - File->read((char*)TerrainHeader,TempShort); - -//Check that no full version features are used -#ifndef C_BT_FULLVERSION - if((TerrainHeader->Flags>>3)&0x1 || (TerrainHeader->Flags>>1)&0x1 || - TerrainHeader->HeightmapSize>C_BT_MAXTERRAINSIZE || TerrainHeader->LODLevels>C_BT_MAXLODLEVELS) - BT_Intern_Error(C_BT_ERROR_USESFULLVERSION); -#endif - -//Check heightmap size - if(TerrainHeader->HeightmapSize>C_BT_MAXTERRAINSIZE) - { - BT_Intern_Error(C_BT_ERROR_HEIGHTMAPSIZEINVALID); - return NULL; - } - -//Insert terrain header into terrain - TerrainPtr->Built=true; - TerrainPtr->Smoothing=(TerrainHeader->Flags>>2)&0x1; - TerrainPtr->QuadReduction=(TerrainHeader->Flags>>3)&0x1; - TerrainPtr->QuadRotation=(TerrainHeader->Flags>>4)&0x1; - TerrainPtr->LODLevels=TerrainHeader->LODLevels; - TerrainPtr->Scale=TerrainHeader->Scale; - TerrainPtr->YScale=TerrainHeader->YScale; - TerrainPtr->Tile=TerrainHeader->Tile; - TerrainPtr->MeshOptimisation=(TerrainHeader->Flags>>5)&0x1; - TerrainPtr->Sectors=TerrainHeader->Sectors; - TerrainPtr->Heightmapsize=TerrainHeader->HeightmapSize; - TerrainPtr->TerrainSize=TerrainHeader->TerrainSize; - TerrainPtr->ExclusionThreshold=TerrainHeader->ExclusionThreshold; - TerrainPtr->ATMode=TerrainHeader->ATMode; - TerrainPtr->DetailBlendMode=TerrainHeader->DetailBlendMode; - free(TerrainHeader); - -//Terrain info - BT_TerrainInfo* TerrainInfo=(BT_TerrainInfo*)malloc(sizeof(BT_TerrainInfo)); - if(TerrainInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(TerrainInfo,0,sizeof(BT_TerrainInfo)); - TerrainPtr->Info=(void*)TerrainInfo; - TerrainInfo->Built=true; - TerrainInfo->Generated=GenerateTerrain; - TerrainInfo->Smoothing=(TerrainPtr->Smoothing>0); - TerrainInfo->QuadReduction=TerrainPtr->QuadReduction; - TerrainInfo->QuadRotation=TerrainPtr->QuadRotation; - TerrainInfo->LODLevels=TerrainPtr->LODLevels; - TerrainInfo->Scale=TerrainPtr->Scale; - TerrainInfo->YScale=TerrainPtr->YScale; - TerrainInfo->Tile=TerrainPtr->Tile; - TerrainInfo->MeshOptimisation=TerrainPtr->MeshOptimisation; - TerrainInfo->Sectors=TerrainPtr->Sectors; - TerrainInfo->Heightmapsize=TerrainPtr->Heightmapsize; - TerrainInfo->TerrainSize=TerrainPtr->TerrainSize; - TerrainInfo->ExclusionThreshold=TerrainPtr->ExclusionThreshold; - TerrainInfo->ATMode=TerrainPtr->ATMode; - TerrainInfo->DetailBlendMode=TerrainPtr->DetailBlendMode; - -//Make terrain object - TerrainPtr->ObjectID=ObjectID; - TerrainPtr->Object=BT_Intern_CreateBlankObject(ObjectID,1); - BT_Intern_SetupMesh(TerrainPtr->Object->pFrame->pMesh,3,0,D3DFVF_DIFFUSE); - BT_Intern_FinnishObject(ObjectID); - - //TerrainPtr->Object->pDelete=new sObjectDelete::sDelete; - //TerrainPtr->Object->pDelete->onDelete=&BT_Intern_DeleteCallback; - //TerrainPtr->Object->pDelete->userData=TerrainID; - //TerrainPtr->Object->iDeleteCount=0; - //TerrainPtr->Object->iDeleteID=1; - -//Make the LODLevel and Sector header - s_BT_FileLODLevelHeader100* LODLevelHeader=BT_Intern_MakeDefaultLODLevelHeader100(); - s_BT_FileSectorHeader100* SectorHeader=BT_Intern_MakeDefaultSectorHeader100(); - -//Allocate LODLevels - TerrainPtr->LODLevel=(s_BT_LODLevel*)malloc(TerrainPtr->LODLevels*sizeof(s_BT_LODLevel)); - if(TerrainPtr->LODLevel==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Loop through LODLevels - for(unsigned char LODLevel=0;LODLevelLODLevels;LODLevel++) - { - //Find LODLevel Ptr - s_BT_LODLevel* LODLevelPtr=&TerrainPtr->LODLevel[LODLevel]; - - //Read header - File->read((char*)&TempShort,sizeof(unsigned short)); - File->read((char*)LODLevelHeader,TempShort); - - //Insert LODLevel header into LODLevel - LODLevelPtr->SectorSize=LODLevelHeader->SectorSize; - LODLevelPtr->SectorDetail=LODLevelHeader->SectorDetail; - LODLevelPtr->Sectors=LODLevelHeader->Sectors; - LODLevelPtr->Distance=LODLevelHeader->Distance; - LODLevelPtr->Split=LODLevelHeader->Split; - LODLevelPtr->TileSpan=LODLevelHeader->TileSpan; - LODLevelPtr->Terrain=TerrainPtr; - LODLevelPtr->ID=LODLevel; - - //Allocate segment data - if(LODLevel==0) - BT_Intern_AllocateSegmentData(TerrainPtr); - - //LODLevel info - BT_LODLevelInfo* LODLevelInfo=(BT_LODLevelInfo*)malloc(sizeof(BT_LODLevelInfo)); - if(LODLevelInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(LODLevelInfo,0,sizeof(BT_LODLevelInfo)); - LODLevelPtr->Info=(void*)LODLevelInfo; - LODLevelInfo->SectorSize=LODLevelPtr->SectorSize; - LODLevelInfo->SectorDetail=LODLevelPtr->SectorDetail; - LODLevelInfo->Sectors=LODLevelPtr->Sectors; - LODLevelInfo->Distance=LODLevelPtr->Distance; - LODLevelInfo->Split=LODLevelPtr->Split; - LODLevelInfo->TileSpan=LODLevelPtr->TileSpan; - - //Allocate sectors - LODLevelPtr->Sector=(s_BT_Sector*)malloc(LODLevelPtr->Sectors*sizeof(s_BT_Sector)); - if(LODLevelPtr->Sector==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - - //Loop through sectors - for(unsigned short Sector=0;SectorSectors;Sector++) - { - //Find Sector Ptr - s_BT_Sector* SectorPtr=&LODLevelPtr->Sector[Sector]; - - //Read header - File->read((char*)&TempShort,sizeof(unsigned short)); - File->read((char*)SectorHeader,TempShort); - - //Insert Sector header into Sector - SectorPtr->Excluded=SectorHeader->Excluded; - SectorPtr->Row=SectorHeader->Row; - SectorPtr->Column=SectorHeader->Column; - SectorPtr->Pos_x=SectorHeader->PosX; - SectorPtr->Pos_y=SectorHeader->PosY; - SectorPtr->Pos_z=SectorHeader->PosZ; - SectorPtr->LODLevel=LODLevelPtr; - SectorPtr->Terrain=TerrainPtr; - /* OLD SYSTEM - SectorPtr->TopSideNeedsUpdate=false; - SectorPtr->LeftSideNeedsUpdate=false; - SectorPtr->RightSideNeedsUpdate=false; - SectorPtr->BottomSideNeedsUpdate=false; - SectorPtr->TopSideLODLevel=LODLevel; - SectorPtr->LeftSideLODLevel=LODLevel; - SectorPtr->RightSideLODLevel=LODLevel; - SectorPtr->BottomSideLODLevel=LODLevel; - */ - SectorPtr->UpdateMesh=false; - SectorPtr->ID=Sector; - - //Allocate segment info - SectorPtr->SegmentsPerSide=unsigned char((float)pow(2.0f,(float)LODLevelPtr->ID)); - SectorPtr->SegmentLODLevel=(unsigned char*)malloc(4*SectorPtr->SegmentsPerSide*sizeof(unsigned char)); - if(SectorPtr->SegmentLODLevel==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorPtr->SegmentLODLevel,0,4*SectorPtr->SegmentsPerSide*sizeof(unsigned char)); - SectorPtr->SegmentNeedsUpdate=(bool*)malloc(4*SectorPtr->SegmentsPerSide*sizeof(bool)); - if(SectorPtr->SegmentNeedsUpdate==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorPtr->SegmentNeedsUpdate,0,4*SectorPtr->SegmentsPerSide*sizeof(bool)); - - //Sector info - BT_SectorInfo* SectorInfo=(BT_SectorInfo*)malloc(sizeof(BT_SectorInfo)); - if(SectorInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorInfo,0,sizeof(BT_SectorInfo)); - SectorPtr->Info=(void*)SectorInfo; - SectorInfo->Excluded=SectorPtr->Excluded; - SectorInfo->Row=SectorPtr->Row; - SectorInfo->Column=SectorPtr->Column; - SectorInfo->Pos_x=SectorPtr->Pos_x; - SectorInfo->Pos_y=SectorPtr->Pos_y; - SectorInfo->Pos_z=SectorPtr->Pos_z; - SectorInfo->WorldMatrix=&SectorPtr->WorldMatrix; - - //Create QuadMap - if(SectorPtr->Excluded==false) - { - //Read QuadMap - unsigned long QuadMapBufferSize; - char* QuadMapBuffer; - File->read((char*)&QuadMapBufferSize,sizeof(unsigned long)); - QuadMapBuffer=(char*)malloc(QuadMapBufferSize*sizeof(char)); - if(QuadMapBuffer==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - File->read(QuadMapBuffer,QuadMapBufferSize); - - //RTTMS - TerrainPtr->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS=(BT_RTTMS_STRUCT*)malloc(sizeof(BT_RTTMS_STRUCT)); - if(TerrainPtr->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - BT_RTTMS_STRUCTINTERNALS* RTTMSStructInternals=(BT_RTTMS_STRUCTINTERNALS*)malloc(sizeof(BT_RTTMS_STRUCTINTERNALS)); - if(RTTMSStructInternals==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - RTTMSStructInternals->TerrainID=TerrainID; - RTTMSStructInternals->LODLevelID=LODLevel; - RTTMSStructInternals->SectorID=Sector; - RTTMSStructInternals->SectorPtr=&TerrainPtr->LODLevel[LODLevel].Sector[Sector]; - TerrainPtr->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS->Internals=(void*)RTTMSStructInternals; - - //Create quadmap - SectorPtr->QuadMap=(BT_QuadMap*)malloc(sizeof(BT_QuadMap)); - if(SectorPtr->QuadMap==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorPtr->QuadMap,0,sizeof(BT_QuadMap)); - SectorPtr->QuadMap->GenerateFromBuffer100(QuadMapBuffer,QuadMapBufferSize,SectorPtr); - free(QuadMapBuffer); - } - - //Clear Sector Header - BT_Intern_FillSectorHeaderDefault100(SectorHeader); - } - - //Clear LODLevel Header - BT_Intern_FillLODLevelHeaderDefault100(LODLevelHeader); - } - -//Cleanup - free(LODLevelHeader); - free(SectorHeader); - -//Return pointer - return TerrainID; -} - - - -s_BT_FileTerrainHeader100 *BT_Intern_MakeDefaultTerrainHeader100() -{ -//Make Header - s_BT_FileTerrainHeader100* Header=(s_BT_FileTerrainHeader100*)malloc(sizeof(s_BT_FileTerrainHeader100)); - if(Header==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Set default values - BT_Intern_FillTerrainHeaderDefault100(Header); - -//Return header - return Header; -} - -void BT_Intern_FillTerrainHeader100(s_BT_FileTerrainHeader100* Header,s_BT_terrain* Terrain) -{ -//Fill the header - Header->Flags=(Terrain->Environmentmap!=NULL); - Header->Flags|=(Terrain->Exclusionmap!=NULL)<<1; - Header->Flags|=(Terrain->Smoothing>0)<<2; - Header->Flags|=(Terrain->QuadReduction)<<3; - Header->Flags|=(Terrain->QuadRotation)<<4; - Header->Flags|=(Terrain->MeshOptimisation)<<5; - Header->LODLevels=Terrain->LODLevels; - Header->Scale=Terrain->Scale; - Header->YScale=Terrain->YScale; - Header->Tile=Terrain->Tile; - Header->Sectors=Terrain->Sectors; - Header->HeightmapSize=Terrain->Heightmapsize; - Header->TerrainSize=Terrain->TerrainSize; - Header->ExclusionThreshold=Terrain->ExclusionThreshold; - Header->FVF=0; - Header->ATMode=Terrain->ATMode; - Header->DetailBlendMode=Terrain->DetailBlendMode; -} - - -void BT_Intern_FillTerrainHeaderDefault100(s_BT_FileTerrainHeader100* Header) -{ - -} - - -s_BT_FileLODLevelHeader100 *BT_Intern_MakeDefaultLODLevelHeader100() -{ -//Make Header - s_BT_FileLODLevelHeader100* Header=(s_BT_FileLODLevelHeader100*)malloc(sizeof(s_BT_FileLODLevelHeader100)); - if(Header==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Set default values - BT_Intern_FillLODLevelHeaderDefault100(Header); - -//Return header - return Header; -} - -void BT_Intern_FillLODLevelHeader100(s_BT_FileLODLevelHeader100* Header,s_BT_LODLevel* LODLevel) -{ -//Fill the header - Header->SectorSize=LODLevel->SectorSize; - Header->SectorDetail=LODLevel->SectorDetail; - Header->Sectors=LODLevel->Sectors; - Header->Distance=LODLevel->Distance; - Header->Split=LODLevel->Split; - Header->TileSpan=LODLevel->TileSpan; -} - -void BT_Intern_FillLODLevelHeaderDefault100(s_BT_FileLODLevelHeader100* Header) -{ - -} - - -s_BT_FileSectorHeader100 *BT_Intern_MakeDefaultSectorHeader100() -{ -//Make Header - s_BT_FileSectorHeader100* Header=(s_BT_FileSectorHeader100*)malloc(sizeof(s_BT_FileSectorHeader100)); - if(Header==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Set default values - BT_Intern_FillSectorHeaderDefault100(Header); - -//Return header - return Header; -} - -void BT_Intern_FillSectorHeader100(s_BT_FileSectorHeader100* Header,s_BT_Sector* Sector) -{ -//Fill the header - Header->Excluded=Sector->Excluded; - Header->Row=Sector->Row; - Header->Column=Sector->Column; - Header->PosX=Sector->Pos_x; - Header->PosY=Sector->Pos_y; - Header->PosZ=Sector->Pos_z; -} - -void BT_Intern_FillSectorHeaderDefault100(s_BT_FileSectorHeader100* Header) -{ - -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO101.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO101.cpp deleted file mode 100644 index d5c8af4..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/FileIO101.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#include "FileIO.h" -#include "CreateObject.h" -#include - -extern s_BT_main BT_Main; - - -#ifndef COMPILE_GDK - extern t_dbGetDirect3DDevice dbGetDirect3DDevice; -#endif - -unsigned long LoadTerrain101(ifstream *File,unsigned long ObjectID,bool GenerateTerrain) -{ -//Set current function - BT_Main.CurrentFunction=C_BT_FUNCTION_LOADTERRAIN; - -//Variables - s_BT_terrain* TerrainPtr; - unsigned short TempShort; - s_BT_FileTerrainHeader101* TerrainHeader; - unsigned long TerrainID; - -//Make a new terrain - TerrainID=BT_MakeTerrain(); - TerrainPtr=&BT_Main.Terrains[TerrainID]; - -//Make a terrain header - TerrainHeader=BT_Intern_MakeDefaultTerrainHeader101(); - -//Load header from file - File->read((char*)&TempShort,sizeof(unsigned short)); - File->read((char*)TerrainHeader,TempShort); - -//Check that no full version features are used -#ifndef C_BT_FULLVERSION - if((TerrainHeader->Flags>>3)&0x1 || (TerrainHeader->Flags>>1)&0x1 || - TerrainHeader->HeightmapSize>C_BT_MAXTERRAINSIZE || TerrainHeader->LODLevels>C_BT_MAXLODLEVELS) - BT_Intern_Error(C_BT_ERROR_USESFULLVERSION); -#endif - -//Check heightmap size - if(TerrainHeader->HeightmapSize>C_BT_MAXTERRAINSIZE) - { - BT_Intern_Error(C_BT_ERROR_HEIGHTMAPSIZEINVALID); - return NULL; - } - -//Insert terrain header into terrain - TerrainPtr->Built=true; - TerrainPtr->Smoothing=(TerrainHeader->Flags>>2)&0x1; - TerrainPtr->QuadReduction=(TerrainHeader->Flags>>3)&0x1; - TerrainPtr->QuadRotation=(TerrainHeader->Flags>>4)&0x1; - TerrainPtr->LODLevels=TerrainHeader->LODLevels; - TerrainPtr->Scale=TerrainHeader->Scale; - TerrainPtr->YScale=TerrainHeader->YScale; - TerrainPtr->Tile=TerrainHeader->Tile; - TerrainPtr->MeshOptimisation=(TerrainHeader->Flags>>5)&0x1; - TerrainPtr->Sectors=TerrainHeader->Sectors; - TerrainPtr->Heightmapsize=TerrainHeader->HeightmapSize; - TerrainPtr->TerrainSize=TerrainHeader->TerrainSize; - TerrainPtr->ExclusionThreshold=TerrainHeader->ExclusionThreshold; - TerrainPtr->ATMode=TerrainHeader->ATMode; - TerrainPtr->DetailBlendMode=TerrainHeader->DetailBlendMode; - free(TerrainHeader); - -//Terrain info - BT_TerrainInfo* TerrainInfo=(BT_TerrainInfo*)malloc(sizeof(BT_TerrainInfo)); - if(TerrainInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(TerrainInfo,0,sizeof(BT_TerrainInfo)); - TerrainPtr->Info=(void*)TerrainInfo; - TerrainInfo->Built=true; - TerrainInfo->Generated=GenerateTerrain; - TerrainInfo->Smoothing=(TerrainPtr->Smoothing>0); - TerrainInfo->QuadReduction=TerrainPtr->QuadReduction; - TerrainInfo->QuadRotation=TerrainPtr->QuadRotation; - TerrainInfo->LODLevels=TerrainPtr->LODLevels; - TerrainInfo->Scale=TerrainPtr->Scale; - TerrainInfo->YScale=TerrainPtr->YScale; - TerrainInfo->Tile=TerrainPtr->Tile; - TerrainInfo->MeshOptimisation=TerrainPtr->MeshOptimisation; - TerrainInfo->Sectors=TerrainPtr->Sectors; - TerrainInfo->Heightmapsize=TerrainPtr->Heightmapsize; - TerrainInfo->TerrainSize=TerrainPtr->TerrainSize; - TerrainInfo->ExclusionThreshold=TerrainPtr->ExclusionThreshold; - TerrainInfo->ATMode=TerrainPtr->ATMode; - TerrainInfo->DetailBlendMode=TerrainPtr->DetailBlendMode; - -//Make terrain object - TerrainPtr->ObjectID=ObjectID; - TerrainPtr->Object=BT_Intern_CreateBlankObject(ObjectID,1); - BT_Intern_SetupMesh(TerrainPtr->Object->pFrame->pMesh,3,0,D3DFVF_DIFFUSE); - BT_Intern_FinnishObject(ObjectID); - - //TerrainPtr->Object->pDelete=new sObjectDelete::sDelete; - //TerrainPtr->Object->pDelete->onDelete=&BT_Intern_DeleteCallback; - //TerrainPtr->Object->pDelete->userData=TerrainID; - //TerrainPtr->Object->iDeleteCount=0; - //TerrainPtr->Object->iDeleteID=1; - -//Make the LODLevel and Sector header - s_BT_FileLODLevelHeader101* LODLevelHeader=BT_Intern_MakeDefaultLODLevelHeader101(); - s_BT_FileSectorHeader101* SectorHeader=BT_Intern_MakeDefaultSectorHeader101(); - -//Allocate LODLevels - TerrainPtr->LODLevel=(s_BT_LODLevel*)malloc(TerrainPtr->LODLevels*sizeof(s_BT_LODLevel)); - if(TerrainPtr->LODLevel==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Loop through LODLevels - for(unsigned char LODLevel=0;LODLevelLODLevels;LODLevel++) - { - //Find LODLevel Ptr - s_BT_LODLevel* LODLevelPtr=&TerrainPtr->LODLevel[LODLevel]; - - //Read header - File->read((char*)&TempShort,sizeof(unsigned short)); - File->read((char*)LODLevelHeader,TempShort); - - //Insert LODLevel header into LODLevel - LODLevelPtr->SectorSize=LODLevelHeader->SectorSize; - LODLevelPtr->SectorDetail=LODLevelHeader->SectorDetail; - LODLevelPtr->Sectors=LODLevelHeader->Sectors; - LODLevelPtr->Distance=LODLevelHeader->Distance; - LODLevelPtr->Split=LODLevelHeader->Split; - LODLevelPtr->TileSpan=LODLevelHeader->TileSpan; - LODLevelPtr->Terrain=TerrainPtr; - LODLevelPtr->ID=LODLevel; - - //Allocate segment data - if(LODLevel==0) - BT_Intern_AllocateSegmentData(TerrainPtr); - - //LODLevel info - BT_LODLevelInfo* LODLevelInfo=(BT_LODLevelInfo*)malloc(sizeof(BT_LODLevelInfo)); - if(LODLevelInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(LODLevelInfo,0,sizeof(BT_LODLevelInfo)); - LODLevelPtr->Info=(void*)LODLevelInfo; - LODLevelInfo->SectorSize=LODLevelPtr->SectorSize; - LODLevelInfo->SectorDetail=LODLevelPtr->SectorDetail; - LODLevelInfo->Sectors=LODLevelPtr->Sectors; - LODLevelInfo->Distance=LODLevelPtr->Distance; - LODLevelInfo->Split=LODLevelPtr->Split; - LODLevelInfo->TileSpan=LODLevelPtr->TileSpan; - - //Allocate sectors - LODLevelPtr->Sector=(s_BT_Sector*)malloc(LODLevelPtr->Sectors*sizeof(s_BT_Sector)); - if(LODLevelPtr->Sector==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - - //Loop through sectors - for(unsigned short Sector=0;SectorSectors;Sector++) - { - //Find Sector Ptr - s_BT_Sector* SectorPtr=&LODLevelPtr->Sector[Sector]; - - //Read header - File->read((char*)&TempShort,sizeof(unsigned short)); - File->read((char*)SectorHeader,TempShort); - - //Insert Sector header into Sector - SectorPtr->Excluded=SectorHeader->Excluded; - SectorPtr->Row=SectorHeader->Row; - SectorPtr->Column=SectorHeader->Column; - SectorPtr->Pos_x=float(SectorPtr->Column*LODLevelPtr->SectorSize+0.5*LODLevelPtr->SectorSize); - SectorPtr->Pos_y=0.0f; - SectorPtr->Pos_z=float(SectorPtr->Row*LODLevelPtr->SectorSize+0.5*LODLevelPtr->SectorSize); - SectorPtr->LODLevel=LODLevelPtr; - SectorPtr->Terrain=TerrainPtr; - /* OLD SYSTEM - SectorPtr->TopSideNeedsUpdate=false; - SectorPtr->LeftSideNeedsUpdate=false; - SectorPtr->RightSideNeedsUpdate=false; - SectorPtr->BottomSideNeedsUpdate=false; - SectorPtr->TopSideLODLevel=LODLevel; - SectorPtr->LeftSideLODLevel=LODLevel; - SectorPtr->RightSideLODLevel=LODLevel; - SectorPtr->BottomSideLODLevel=LODLevel; - */ - SectorPtr->UpdateMesh=false; - SectorPtr->ID=Sector; - - //Allocate segment info - SectorPtr->SegmentsPerSide=unsigned char((float)pow(2.0f,(float)LODLevelPtr->ID)); - SectorPtr->SegmentLODLevel=(unsigned char*)malloc(4*SectorPtr->SegmentsPerSide*sizeof(unsigned char)); - if(SectorPtr->SegmentLODLevel==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorPtr->SegmentLODLevel,0,4*SectorPtr->SegmentsPerSide*sizeof(unsigned char)); - SectorPtr->SegmentNeedsUpdate=(bool*)malloc(4*SectorPtr->SegmentsPerSide*sizeof(bool)); - if(SectorPtr->SegmentNeedsUpdate==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorPtr->SegmentNeedsUpdate,0,4*SectorPtr->SegmentsPerSide*sizeof(bool)); - - //Sector info - BT_SectorInfo* SectorInfo=(BT_SectorInfo*)malloc(sizeof(BT_SectorInfo)); - if(SectorInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorInfo,0,sizeof(BT_SectorInfo)); - SectorPtr->Info=(void*)SectorInfo; - SectorInfo->Excluded=SectorPtr->Excluded; - SectorInfo->Row=SectorPtr->Row; - SectorInfo->Column=SectorPtr->Column; - SectorInfo->Pos_x=SectorPtr->Pos_x; - SectorInfo->Pos_y=SectorPtr->Pos_y; - SectorInfo->Pos_z=SectorPtr->Pos_z; - SectorInfo->WorldMatrix=&SectorPtr->WorldMatrix; - - //Create QuadMap - if(SectorPtr->Excluded==false) - { - //Read QuadMap - unsigned long QuadMapBufferSize; - char* QuadMapBuffer; - File->read((char*)&QuadMapBufferSize,sizeof(unsigned long)); - QuadMapBuffer=(char*)malloc(QuadMapBufferSize*sizeof(char)); - if(QuadMapBuffer==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - File->read(QuadMapBuffer,QuadMapBufferSize); - - //RTTMS - TerrainPtr->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS=(BT_RTTMS_STRUCT*)malloc(sizeof(BT_RTTMS_STRUCT)); - if(TerrainPtr->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - BT_RTTMS_STRUCTINTERNALS* RTTMSStructInternals=(BT_RTTMS_STRUCTINTERNALS*)malloc(sizeof(BT_RTTMS_STRUCTINTERNALS)); - if(RTTMSStructInternals==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - RTTMSStructInternals->TerrainID=TerrainID; - RTTMSStructInternals->LODLevelID=LODLevel; - RTTMSStructInternals->SectorID=Sector; - RTTMSStructInternals->SectorPtr=&TerrainPtr->LODLevel[LODLevel].Sector[Sector]; - TerrainPtr->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS->Internals=(void*)RTTMSStructInternals; - - //Create quadmap - SectorPtr->QuadMap=(BT_QuadMap*)malloc(sizeof(BT_QuadMap)); - if(SectorPtr->QuadMap==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorPtr->QuadMap,0,sizeof(BT_QuadMap)); - SectorPtr->QuadMap->GenerateFromBuffer101(QuadMapBuffer,QuadMapBufferSize,SectorPtr); - free(QuadMapBuffer); - } - - //Clear Sector Header - BT_Intern_FillSectorHeaderDefault101(SectorHeader); - } - - //Clear LODLevel Header - BT_Intern_FillLODLevelHeaderDefault101(LODLevelHeader); - } - -//Cleanup - free(LODLevelHeader); - free(SectorHeader); - -//Return pointer - return TerrainID; -} - - - -s_BT_FileTerrainHeader101 *BT_Intern_MakeDefaultTerrainHeader101() -{ -//Make Header - s_BT_FileTerrainHeader101* Header=(s_BT_FileTerrainHeader101*)malloc(sizeof(s_BT_FileTerrainHeader101)); - if(Header==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Set default values - BT_Intern_FillTerrainHeaderDefault101(Header); - -//Return header - return Header; -} - -void BT_Intern_FillTerrainHeader101(s_BT_FileTerrainHeader101* Header,s_BT_terrain* Terrain) -{ -//Fill the header - Header->Flags=(Terrain->Environmentmap!=NULL); - Header->Flags|=(Terrain->Exclusionmap!=NULL)<<1; - Header->Flags|=(Terrain->Smoothing>0)<<2; - Header->Flags|=(Terrain->QuadReduction)<<3; - Header->Flags|=(Terrain->QuadRotation)<<4; - Header->Flags|=(Terrain->MeshOptimisation)<<5; - Header->LODLevels=Terrain->LODLevels; - Header->Scale=Terrain->Scale; - Header->YScale=Terrain->YScale; - Header->Tile=Terrain->Tile; - Header->Sectors=Terrain->Sectors; - Header->HeightmapSize=Terrain->Heightmapsize; - Header->TerrainSize=Terrain->TerrainSize; - Header->ExclusionThreshold=Terrain->ExclusionThreshold; - Header->FVF=0; - Header->ATMode=Terrain->ATMode; - Header->DetailBlendMode=Terrain->DetailBlendMode; -} - - -void BT_Intern_FillTerrainHeaderDefault101(s_BT_FileTerrainHeader101* Header) -{ - -} - - -s_BT_FileLODLevelHeader101 *BT_Intern_MakeDefaultLODLevelHeader101() -{ -//Make Header - s_BT_FileLODLevelHeader101* Header=(s_BT_FileLODLevelHeader101*)malloc(sizeof(s_BT_FileLODLevelHeader101)); - if(Header==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Set default values - BT_Intern_FillLODLevelHeaderDefault101(Header); - -//Return header - return Header; -} - -void BT_Intern_FillLODLevelHeader101(s_BT_FileLODLevelHeader101* Header,s_BT_LODLevel* LODLevel) -{ -//Fill the header - Header->SectorSize=LODLevel->SectorSize; - Header->SectorDetail=LODLevel->SectorDetail; - Header->Sectors=LODLevel->Sectors; - Header->Distance=LODLevel->Distance; - Header->Split=LODLevel->Split; - Header->TileSpan=LODLevel->TileSpan; -} - -void BT_Intern_FillLODLevelHeaderDefault101(s_BT_FileLODLevelHeader101* Header) -{ - -} - - -s_BT_FileSectorHeader101 *BT_Intern_MakeDefaultSectorHeader101() -{ -//Make Header - s_BT_FileSectorHeader101* Header=(s_BT_FileSectorHeader101*)malloc(sizeof(s_BT_FileSectorHeader101)); - if(Header==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Set default values - BT_Intern_FillSectorHeaderDefault101(Header); - -//Return header - return Header; -} - -void BT_Intern_FillSectorHeader101(s_BT_FileSectorHeader101* Header,s_BT_Sector* Sector) -{ -//Fill the header - Header->Excluded=Sector->Excluded; - Header->Row=Sector->Row; - Header->Column=Sector->Column; -} - -void BT_Intern_FillSectorHeaderDefault101(s_BT_FileSectorHeader101* Header) -{ - -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/Resource.rc b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/Resource.rc deleted file mode 100644 index 1ecc7b4..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/Resource.rc +++ /dev/null @@ -1,170 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -//#define _USING_V110_SDK71_ -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United Kingdom) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,2,2 - PRODUCTVERSION 2,0,2,2 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904b0" - BEGIN - VALUE "CompanyName", "Blitzwerks" - VALUE "FileDescription", "Blitzwerks Terrain" - VALUE "FileVersion", "2.0.2.2" - VALUE "InternalName", "BlitzTerrain" - VALUE "LegalCopyright", "Copyright (C) Blitzwerks 2009 - 2011" - VALUE "ProductName", "Blitzwerks Terrain" - VALUE "ProductVersion", "2.0.2.2" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_STRING101 "BT MAKETERRAIN[%D%?BT_MakeTerrain@@YAKXZ%*No Parameters*" - IDS_STRING102 "BT GETSTATISTIC[%DD%?BT_GetStatistic@@YAKK@Z%int Code" - IDS_STRING103 "BT SETTERRAINHEIGHTMAP%DD%?BT_SetTerrainHeightmap@@YAXKK@Z%int TerrainID, int ImageID" - IDS_STRING104 "BT RENDERTERRAIN%D%?BT_RenderTerrain@@YAXK@Z%int TerrainID" - IDS_STRING105 "BT GETGROUNDHEIGHT[%FDFFD%?BT_GetGroundHeight@@YAKKMM_N@Z%int TerrainID, float X, float Z, bool Round" - IDS_STRING106 "BT INTERN RENDER%0%?BT_Intern_Render@@YAXXZ%*No parameters*" - IDS_STRING107 "BT GETGROUNDHEIGHT[%FDFF%?BT_GetGroundHeight@@YAKKMM@Z%int TerrainID, float X, float Z" - IDS_STRING108 "BT GETPOINTEXCLUDED[%DDFF%?BT_GetPointExcluded@@YAKKMM@Z%int TerrainID, float PointX, float PointZ" - IDS_STRING109 "BT SETTERRAINEXCLUSION%DD%?BT_SetTerrainExclusion@@YAXKK@Z%int TerrainID, int ImageID" - IDS_STRING110 "BT GETTERRAINOBJECTID[%DD%?BT_GetTerrainObjectID@@YAKK@Z%int TerrainID" - IDS_STRING111 "BT SETTERRAINDETAIL%DD%?BT_SetTerrainDetail@@YAXKK@Z%int TerrainID, int ImageID" -END - -STRINGTABLE -BEGIN - IDS_STRING112 "BT MAKETERRAINOBJECT%DDD%?BT_MakeTerrainObject@@YAXKKK@Z%int TerrainID, int LODLevel, int ObjectID" - IDS_STRING113 "BT SETTERRAINLOD%DD%?BT_SetTerrainLOD@@YAXKE@Z%int TerrainID, int LODLevels" - IDS_STRING114 "BT MAKESECTOROBJECT%DDDD%?BT_MakeSectorObject@@YAXKKKK@Z%int TerrainID, int LODLevel, int SectorID, int ObjectID" - IDS_STRING115 "BT GETSECTORCOUNT[%DDD%?BT_GetSectorCount@@YAKKK@Z%int TerrainID, int LODLevel" - IDS_STRING116 "BT GETSECTORPOSITIONX[%FDDD%?BT_GetSectorPositionX@@YAKKKK@Z%int TerrainID, int LODLevel, int SectorID" - IDS_STRING117 "BT SETTERRAINSPLIT%DD%?BT_SetTerrainSplit@@YAXKK@Z%int TerrainID, int Split" - IDS_STRING118 "BT GETSECTORPOSITIONY[%FDDD%?BT_GetSectorPositionY@@YAKKKK@Z%int TerrainID, int LODLevel, int SectorID" - IDS_STRING119 "BT SETTERRAINDETAILTILE%DF%?BT_SetTerrainDetailTile@@YAXKM@Z%int TerrainID, float Tile" - IDS_STRING120 "BT GETSECTORPOSITIONZ[%FDDD%?BT_GetSectorPositionZ@@YAKKKK@Z%int TerrainID, int LODLevel, int SectorID" - IDS_STRING121 "BT UPDATETERRAINCULL%D%?BT_UpdateTerrainCull@@YAXK@Z%int TerrainID" - IDS_STRING122 "BT UPDATETERRAINLOD%D%?BT_UpdateTerrainLOD@@YAXK@Z%int TerrainID" - IDS_STRING123 "BT FORCETECHNIQUEMODE%D%?BT_ForceTerrainTechnique@@YAXK@Z%int TechniqueMode" - IDS_STRING124 "BT SETCURRENTCAMERA%D%?BT_SetCurrentCamera@@YAXK@Z%int CameraID" - IDS_STRING125 "BT SETTERRAINQUADROTATION%DD%?BT_SetTerrainQuadRotation@@YAXK_N@Z%int TerrainID, bool Enabled" - IDS_STRING126 "BT SETTERRAINRENDERLEVEL%L%?SetTerrainRenderLevel@@YAXH@Z%int Level (0-100)" - IDS_STRING127 "BT SETTERRAINSMOOTHING%DD%?BT_SetTerrainSmoothing@@YAXKK@Z%int TerrainID, bool Enabled" -END - -STRINGTABLE -BEGIN - IDS_STRING128 "BT SETTERRAINEXCLUSIONTHRESHOLD%DD%?BT_SetTerrainExclusionThreshold@@YAXKK@Z%int TerrainID, int Threshold" - IDS_STRING129 "BT SETTERRAINSCALE%DF%?BT_SetTerrainScale@@YAXKM@Z%int TerrainID, float Scale" - IDS_STRING131 "BT SETTERRAINYSCALE%DF%?BT_SetTerrainYScale@@YAXKM@Z%int TerrainID, float YScale" - IDS_STRING133 "BT SETTERRAINLODDISTANCE%DDF%?BT_SetTerrainLODDistance@@YAXKEM@Z%int TerrainID, int LODLevel, float Value" - IDS_STRING134 "BT GETSECTOREXCLUDED[%DDDD%?BT_GetSectorExcluded@@YAKKKK@Z%int TerrainID, int LODLevelID, int SectorID" - IDS_STRING135 "BT BUILDTERRAIN%DD%?BT_BuildTerrain@@YAXKK@Z%int TerrainID, int ObjectID" - IDS_STRING136 "BT SETATMODE%D%?BT_SetATMode@@YAX_N@Z%bool Enabled" - IDS_STRING137 "BT CONTINUEBUILD[%L%?BT_ContinueBuild@@YAHXZ%*No Parameters*" - IDS_STRING138 "BT SETTERRAINDETAILBLENDMODE%DD%?BT_SetTerrainDetailBlendMode@@YAXKE@Z%int TerrainID, int Mode" - IDS_STRING139 "BT SETTERRAINENVIRONMENT%DD%?BT_SetTerrainEnvironment@@YAXKK@Z%int TerrainID, int ImageID" - IDS_STRING140 "BT BUILDTERRAIN%DDD%?BT_BuildTerrain@@YAXKK_N@Z%int TerrainID, int ObjectID, bool Build Fully" - IDS_STRING142 "BT ADDTERRAINENVIRONMENT[%DDD%?BT_AddTerrainEnvironment@@YAKKK@Z%int TerrainID, dword Colour" - IDS_STRING143 "BT TERRAINEXIST[%DD%?BT_TerrainExist@@YAKK@Z%int TerrainID" -END - -STRINGTABLE -BEGIN - IDS_STRING144 "BT GETVERSION[%S%?BT_GetVersion@@YAKXZ%*No Parameters*" - IDS_STRING145 "BT GETPOINTENVIRONMENT[%DDFF%?BT_GetPointEnvironment@@YAKKMM@Z%int TerrainID, float X, float Z" - IDS_STRING146 "BT SETTERRAINTEXTURE%DD%?BT_SetTerrainTexture@@YAXKK@Z%int TerrainID, int ImageID" - IDS_STRING147 "BT DELETETERRAIN%D%?BT_DeleteTerrain@@YAXK@Z%int TerrainID" - IDS_STRING153 "BT SETBUILDSTEP%D%?BT_SetBuildStep@@YAXK@Z%int Step" - IDS_STRING149 "BT GETTERRAINSIZE[%FD%?BT_GetTerrainSize@@YAKK@Z%int TerrainID" - IDS_STRING150 "BT UPDATETERRAINOBJECTS%D%?BT_UpdateTerrainObjects@@YAXK@Z%int TerrainID" - IDS_STRING151 "BT ENABLEAUTORENDER%D%?BT_EnableAutoRender@@YAX_N@Z%bool Enabled" -END - -#endif // English (United Kingdom) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/code-from-dbp.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/code-from-dbp.cpp deleted file mode 100644 index 8e98923..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/code-from-dbp.cpp +++ /dev/null @@ -1,519 +0,0 @@ -//THIS CODE WAS BORROWED FROM DBPRO 7.5 AND MODIFIED TO WORK WITH BLITZTERRAIN - -#include ".\..\..\Shared\DBOFormat\DBOData.h" -#include "globstruct.h" -#include "main.h" - -extern GlobStruct* g_pGlob; -extern IGGDevice* m_pD3D; - -bool DBPRO_SetMeshRenderStates( sMesh* pMesh ) -{ - #ifdef DX11 - - // terrain render states - - #else - -//Get D3D Device - IGGDevice* D3DDevice = m_pD3D; - -//Wireframe - if ( pMesh->bWireframe ) - D3DDevice->SetRenderState ( D3DRS_FILLMODE, D3DFILL_WIREFRAME ); - else - D3DDevice->SetRenderState ( D3DRS_FILLMODE, D3DFILL_SOLID ); - -//Lighting - if ( pMesh->bLight ) - D3DDevice->SetRenderState ( D3DRS_LIGHTING, TRUE ); - else - D3DDevice->SetRenderState ( D3DRS_LIGHTING, FALSE ); - -//Culling - if ( pMesh->bCull ) - D3DDevice->SetRenderState ( D3DRS_CULLMODE, GGCULL_CCW ); - else - D3DDevice->SetRenderState ( D3DRS_CULLMODE, D3DCULL_NONE ); - -//Fog - if(g_pGlob) - { - if(g_pGlob->iFogState==1) - { - if ( pMesh->bFog ) - D3DDevice->SetRenderState ( D3DRS_FOGENABLE, TRUE ); - else - D3DDevice->SetRenderState ( D3DRS_FOGENABLE, FALSE ); - - // ghosts in fog must override fog color part (fog override) - if ( pMesh->bFog && pMesh->bGhost ) - D3DDevice->SetRenderState ( D3DRS_FOGCOLOR, GGCOLOR_RGBA ( 0, 0, 0, 0 ) ); - } - } - - // leefix - 070204 - introduced for better Zwrite control - bool bCorrectZWriteState = pMesh->bZWrite; - -//Transparency - bool bDoGhostAgain = false; - if ( pMesh->bTransparency==true ) - { - if ( pMesh->bTransparency ) - { - D3DDevice->SetRenderState ( D3DRS_ALPHABLENDENABLE, true ); - D3DDevice->SetRenderState ( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); - D3DDevice->SetRenderState ( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); - D3DDevice->SetRenderState ( D3DRS_ALPHATESTENABLE, true ); - - // mike - 020904 - use this for alpha testing - do not get edges anymore - // lee - 240903 - need full range of alpha rendered, not just the upper band - DWORD dwuseAlphaTestValue = pMesh->dwAlphaTestValue; - - if ( dwuseAlphaTestValue==0 ) - { - D3DDevice->SetRenderState ( D3DRS_ALPHAFUNC, D3DCMP_GREATER ); - D3DDevice->SetRenderState ( D3DRS_ALPHAREF, (DWORD)0x00000000 ); - } - else - { - // leeadd - 131205 - let SetAlphaMappingOn command scale the alpha-test to let semi-transparent pixel through - if ( pMesh->bAlphaOverride==true ) - { - // alpha mapping percentage vased alpha test - DWORD dwPercAlpha = ( (pMesh->dwAlphaOverride & 0xFF000000) >> 24 ) ; - float perc = (float)dwPercAlpha / 255.0f; - // leefix - 071208 - alpha test transition not perfect as go from override to 0xCF based alpha, so cap it - // DWORD dwAlphaLevelToDraw = (DWORD)(128.0f * perc); - DWORD dwAlphaLevelToDraw = (DWORD)(255 * perc); - dwuseAlphaTestValue = dwAlphaLevelToDraw; - if ( dwuseAlphaTestValue > (DWORD)0x000000CF ) dwuseAlphaTestValue=(DWORD)0x000000CF; - D3DDevice->SetRenderState ( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL ); - } - else - { - // regular alpha test - dwuseAlphaTestValue=(DWORD)0x000000CF; - D3DDevice->SetRenderState ( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL ); - } - D3DDevice->SetRenderState ( D3DRS_ALPHAREF, dwuseAlphaTestValue ); - } - } - else - { - D3DDevice->SetRenderState ( D3DRS_ALPHABLENDENABLE, false ); - D3DDevice->SetRenderState ( D3DRS_ALPHATESTENABLE, false ); - D3DDevice->SetRenderState ( D3DRS_ALPHAFUNC, D3DCMP_ALWAYS ); - } - - // now must do ghost again - to combine with blend settings - bDoGhostAgain = true; - } - -//Ghosting - if ( bDoGhostAgain==true ) - { - if ( pMesh->bGhost ) - { - D3DDevice->SetRenderState ( D3DRS_ALPHABLENDENABLE, true ); - switch ( pMesh->iGhostMode ) - { - case 0: - { - D3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ); - D3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR ); - } - break; - - case 1: - { - // lee - 220306 - u6b4 - direct from best of DBC (darkghostmode7) - DWORD dwDarkAlphaSourceBlend = D3DBLEND_ZERO; - DWORD dwDarkAlphaDestinationBlend = D3DBLEND_SRCCOLOR; - D3DDevice->SetRenderState( D3DRS_SRCBLEND, dwDarkAlphaSourceBlend ); - D3DDevice->SetRenderState( D3DRS_DESTBLEND, dwDarkAlphaDestinationBlend ); - } - break; - - case 2: - { - D3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR ); - D3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); - } - break; - - case 3: - { - D3DDevice->SetRenderState ( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); - D3DDevice->SetRenderState ( D3DRS_DESTBLEND, D3DBLEND_SRCALPHA ); - } - break; - - case 4: - { - D3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR ); - D3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR ); - } - break; - - case 5: - { - // leeadd - 210806 - replace OLD-MODE-1 (used in FPSC) for Scorch Texture Multiply - D3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR ); - D3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR ); - } - break; - } - bCorrectZWriteState = false; - } - else - { - // no ghost and no transparency, end alpha blend effect - if ( pMesh->bTransparency==false) - { - D3DDevice->SetRenderState ( D3DRS_ALPHABLENDENABLE, FALSE ); - } - } - - } - -//Z Write - if ( pMesh->bZWrite ) - D3DDevice->SetRenderState ( D3DRS_ZWRITEENABLE, TRUE ); - else - D3DDevice->SetRenderState ( D3DRS_ZWRITEENABLE, FALSE ); - -//Z Bias - if ( pMesh->bZBiasActive ) - { - D3DDevice->SetRenderState ( D3DRS_DEPTHBIAS, *(DWORD*)&pMesh->fZBiasDepth ); - D3DDevice->SetRenderState ( D3DRS_SLOPESCALEDEPTHBIAS, *(DWORD*)&pMesh->fZBiasSlopeScale ); - } - else - { - D3DDevice->SetRenderState ( D3DRS_DEPTHBIAS, 0 ); - D3DDevice->SetRenderState ( D3DRS_SLOPESCALEDEPTHBIAS, 0 ); - } - -//Z Read - if ( pMesh->bZRead ) - D3DDevice->SetRenderState ( D3DRS_ZENABLE, TRUE ); - else - D3DDevice->SetRenderState ( D3DRS_ZENABLE, FALSE ); - -//Material - if ( pMesh->bUsesMaterial ) - { - // use diffuse from material (if present) - D3DDevice->SetRenderState ( D3DRS_COLORVERTEX, FALSE ); - D3DDevice->SetRenderState ( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL ); - - // set the material from the mesh - if ( FAILED ( D3DDevice->SetMaterial ( &pMesh->mMaterial ) ) ) - return false; - } - - // mike - 230505 - need to be able to set mip map LOD bias on a per mesh basis - D3DDevice->SetSamplerState ( 0, D3DSAMP_MIPMAPLODBIAS, *( ( LPDWORD ) ( &pMesh->fMipMapLODBias ) ) ); - - #endif - - // success - return true; -} - -void DBPRO_ApplyEffect ( sMesh* pMesh, tagCameraData* m_Camera_Ptr ) -{ - #ifdef DX11 - // no need, should be using shadereffect START function to call this! - #else - // This MAY be redundant IF we can somehow set all terrain shader constants - // at the start of the pass and not make any more effect commits - -//Get D3D Device - IGGDevice* D3DDevice = m_pD3D; - -//Get effect - cSpecialEffect* Effect=pMesh->pVertexShaderEffect; - - // Gather and calculate required constants data - GGMATRIX matWorld,matView,matProj; - D3DDevice->GetTransform( GGTS_WORLD, &matWorld ); - D3DDevice->GetTransform( GGTS_VIEW, &matView ); - D3DDevice->GetTransform( GGTS_PROJECTION, &matProj ); - - GGMATRIX matWorldView,matViewProj,matWorldViewProj; - matWorldView = matWorld * matView; - matViewProj = matView * matProj; - matWorldViewProj = matWorld * matView * matProj; - - // Calculate inverse matrices - GGMATRIX matWorldInv,matViewInv,matWorldViewInv; - GGMatrixInverse( &matWorldInv, NULL, &matWorld ); - GGMatrixInverse( &matViewInv, NULL, &matView ); - GGMatrixInverse( &matWorldViewInv, NULL, &matWorldView ); - - // Get raw light data - D3DLIGHT9 d3dLight; - D3DDevice->GetLight(0,&d3dLight); - GGVECTOR4 vecLightDir,vecLightPos,vecLightDirInv; - - if ( d3dLight.Type==GGLIGHT_DIRECTIONAL ) - { - // get direction directly from structure - vecLightDir = GGVECTOR4( d3dLight.Direction.x, d3dLight.Direction.y, d3dLight.Direction.z, 0.0f ); - vecLightPos = GGVECTOR4( d3dLight.Direction.x*-1000.0f, d3dLight.Direction.y*-1000.0f, d3dLight.Direction.z*-1000.0f, 1.0f ); - } - else - { - // calculate direction from world position - vecLightDir.x = matWorld._41-d3dLight.Position.x; - vecLightDir.y = matWorld._42-d3dLight.Position.y; - vecLightDir.z = matWorld._43-d3dLight.Position.z; - vecLightDir.w = 1.0f; - - // calculate light position (in object space) - vecLightPos.x = d3dLight.Position.x; - vecLightPos.y = d3dLight.Position.y; - vecLightPos.z = d3dLight.Position.z; - vecLightPos.w = 1.0f; - } - - // Calculate light and object-space light(inv) - GGVec4Transform ( &vecLightDirInv, &vecLightDir, &matWorldInv ); - D3DXVec4Normalize ( &vecLightDirInv, &vecLightDirInv ); - D3DXVec4Normalize ( &vecLightDir, &vecLightDir ); - - // Get camera psition - GGVECTOR4 vecCameraPosition; - vecCameraPosition = GGVECTOR4( matViewInv._41, matViewInv._42, matViewInv._43, 1.0f ); - - // Alpha override component - if ( Effect->m_AlphaOverrideHandle ) - { - if ( pMesh->bAlphaOverride==true ) - { - float fPercentage = (float)(pMesh->dwAlphaOverride>>24)/255.0f; - Effect->GGSetEffectFloat( Effect->m_AlphaOverrideHandle, fPercentage ); - } - } - - // prepare tranposed matrices for column major matrices - if ( Effect->m_bTranposeToggle ) - { - GGMatrixTranspose( &matWorld, &matWorld ); - GGMatrixTranspose( &matView, &matView ); - GGMatrixTranspose( &matProj, &matProj ); - GGMatrixTranspose( &matWorldView, &matWorldView ); - GGMatrixTranspose( &matViewProj, &matViewProj ); - GGMatrixTranspose( &matWorldViewProj, &matWorldViewProj ); - GGMatrixTranspose( &matWorldInv, &matWorldInv ); - GGMatrixTranspose( &matViewInv, &matViewInv ); - GGMatrixTranspose( &matWorldViewInv, &matWorldViewInv ); - } - - // leeadd - 290104 - addition of tranposed matrices for effects that use them - GGMATRIX matWorldT,matViewT,matProjT,matWorldViewT,matViewProjT,matWorldViewProjT, - matWorldInvT,matViewInvT,matWorldViewInvT; - GGMatrixTranspose( &matWorldT, &matWorld ); - GGMatrixTranspose( &matViewT, &matView ); - GGMatrixTranspose( &matProjT, &matProj ); - GGMatrixTranspose( &matWorldViewT, &matWorldView ); - GGMatrixTranspose( &matViewProjT, &matViewProj ); - GGMatrixTranspose( &matWorldViewProjT, &matWorldViewProj ); - GGMatrixTranspose( &matWorldInvT, &matWorldInv ); - GGMatrixTranspose( &matViewInvT, &matViewInv ); - GGMatrixTranspose( &matWorldViewInvT, &matWorldViewInv ); - - // apply latest data to effect - if( Effect->m_pEffect != NULL ) - { - // main matrices (row major) - if( Effect->m_MatWorldEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldEffectHandle, &matWorld ); - } - if( Effect->m_MatViewEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatViewEffectHandle, &matView ); - } - if( Effect->m_MatProjEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatProjEffectHandle, &matProj ); - } - if( Effect->m_MatWorldViewEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldViewEffectHandle, &matWorldView ); - } - if( Effect->m_MatViewProjEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatViewProjEffectHandle, &matViewProj ); - } - if( Effect->m_MatWorldViewProjEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldViewProjEffectHandle, &matWorldViewProj ); - } - if( Effect->m_MatWorldInverseEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldInverseEffectHandle, &matWorldInv ); - } - if( Effect->m_MatViewInverseEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatViewInverseEffectHandle, &matViewInv ); - } - if( Effect->m_MatProjectionInverseEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatProjectionInverseEffectHandle, &matProjInv ); - } - if( Effect->m_MatWorldViewInverseEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldViewInverseEffectHandle, &matWorldViewInv ); - } - - // tranposed matrices (column major) - if( Effect->m_MatWorldTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldTEffectHandle, &matWorldT ); - } - if( Effect->m_MatViewTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatViewTEffectHandle, &matViewT ); - } - if( Effect->m_MatProjTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatProjTEffectHandle, &matProjT ); - } - if( Effect->m_MatWorldViewTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldViewTEffectHandle, &matWorldViewT ); - } - if( Effect->m_MatViewProjTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatViewProjTEffectHandle, &matViewProjT ); - } - if( Effect->m_MatWorldViewProjTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldViewProjTEffectHandle, &matWorldViewProjT ); - } - if( Effect->m_MatWorldInverseTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldInverseTEffectHandle, &matWorldInvT ); - } - if( Effect->m_MatViewInverseTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatViewInverseTEffectHandle, &matViewInvT ); - } - if( Effect->m_MatWorldViewInverseTEffectHandle != NULL ) - { - Effect->GGSetEffectMatrix( Effect->m_MatWorldViewInverseTEffectHandle, &matWorldViewInvT ); - } - - // main vectors - if ( Effect->m_LightDirHandle != NULL ) - { - Effect->GGSetEffectVector( Effect->m_LightDirHandle, &vecLightDir ); - } - if ( Effect->m_LightDirInvHandle != NULL ) - { - Effect->GGSetEffectVector( Effect->m_LightDirInvHandle, &vecLightDirInv ); - } - if ( Effect->m_LightPosHandle != NULL ) - { - Effect->GGSetEffectVector( Effect->m_LightPosHandle, &vecLightPos ); - } - if( Effect->m_VecCameraPosEffectHandle != NULL ) - { - Effect->GGSetEffectVector( Effect->m_VecCameraPosEffectHandle, &vecCameraPosition ); - } - if ( Effect->m_VecEyePosEffectHandle != NULL ) - { - Effect->GGSetEffectVector( Effect->m_VecEyePosEffectHandle, &vecCameraPosition ); - } - - // misclanious values - if( Effect->m_TimeEffectHandle != NULL ) - { - // TIME DATA IN SECONDS - float fTime =0.0f; -// float fTime = (float)(timeGetTime() / 1000.0); - Effect->GGSetEffectFloat( Effect->m_TimeEffectHandle, fTime ); - } - if( Effect->m_SinTimeEffectHandle != NULL ) - { - // TIME DATA IN SECONDS - float fSinTime =0.0f; -// float fSinTime = (float)sin((timeGetTime() / 1000.0)); - Effect->GGSetEffectFloat( Effect->m_SinTimeEffectHandle, fSinTime ); - } - - // leelee - 290713 - need to adjust clipping plane if shader used (clip space not world space plane) - GGPLANE planeUse = m_Camera_Ptr->planeClip; - // called before camera (m_Camera_Ptr) renders - if ( m_Camera_Ptr->iClipPlaneOn!=0 ) - { - // they should be in clip space, not world space - bool bClipSpaceRequired = false; - int iActualClipPlaneOn = m_Camera_Ptr->iClipPlaneOn; - if ( m_Camera_Ptr->iClipPlaneOn==3 ) { bClipSpaceRequired=true; iActualClipPlaneOn=1; } - if ( m_Camera_Ptr->iClipPlaneOn==4 ) { bClipSpaceRequired=true; iActualClipPlaneOn=2; } - - // transform world to clip space - if ( bClipSpaceRequired ) - { - // temp planes for conversion - GGPLANE tempPlane = planeUse; - GGPLANE viewSpacePlane; - - // normalize the plane which is required for the transforms - GGPlaneNormalize(&tempPlane, &tempPlane); - - // transform the plane into view space - GGMATRIX tempMatrix = m_Camera_Ptr->matView; - GGMatrixInverse(&tempMatrix, NULL, &tempMatrix); - GGMatrixTranspose(&tempMatrix, &tempMatrix); - GGPlaneTransform(&viewSpacePlane, &tempPlane, &tempMatrix); - - // transform the plane into clip space, or post projection space - tempMatrix = m_Camera_Ptr->matProjection; - GGMatrixInverse(&tempMatrix, NULL, &tempMatrix); - GGMatrixTranspose(&tempMatrix, &tempMatrix); - - // place resulting clip space plane ready for setclipplane - GGPlaneTransform(&planeUse, &viewSpacePlane, &tempMatrix); - } - - // clipping plane enabled - D3DDevice->SetClipPlane ( 0, (float*)planeUse ); - D3DDevice->SetRenderState ( D3DRS_CLIPPLANEENABLE, D3DCLIPPLANE0 ); - } - else - { - D3DDevice->SetRenderState ( D3DRS_CLIPPLANEENABLE, 0x00 ); - } - - // leelee - 290713 - pass clipping data to shader (automatic) - if ( Effect->m_VecClipPlaneEffectHandle ) - { - if ( m_Camera_Ptr->iClipPlaneOn>0 ) - { - // special mode which creates plane but does not use RenderState to set clip - // as you cannot mix FF clip and HLSL clip in same scene (artefacts) - GGVECTOR4 vec = (GGVECTOR4)m_Camera_Ptr->planeClip; - Effect->GGSetEffectVector( Effect->m_VecClipPlaneEffectHandle, &vec ); - } - else - { - // ensure shader stops using clip plane when not being clipped! - GGVECTOR4 vec = GGVECTOR4( 0.0f, 1.0f, 0.0f, 99999.0f ); - Effect->GGSetEffectVector( Effect->m_VecClipPlaneEffectHandle, &vec ); - } - } - - - //Commit changes - D3DDevice->SetRenderState ( D3DRS_CLIPPLANEENABLE, 0x00 ); - Effect->m_pEffect->CommitChanges(); - - } - #endif -} diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/code-from-dbp.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/code-from-dbp.h deleted file mode 100644 index 3e0b13f..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/code-from-dbp.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _CFDBP_H -#define _CFDBP_H - -#include "windows.h" -#include "directx-macros.h" -#include "globstruct.h" -#include ".\..\..\Shared\camera\ccameradatac.h" -#include ".\..\..\Shared\DBOFormat\DBOData.h" -#include ".\..\..\Shared\error\cerror.h" - -bool DBPRO_SetMeshRenderStates( sMesh* pMesh ); -void DBPRO_ApplyEffect ( sMesh* pMesh, tagCameraData* m_Camera_Ptr ); - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/main.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/main.cpp deleted file mode 100644 index d310d45..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/main.cpp +++ /dev/null @@ -1,4804 +0,0 @@ -#include "main.h" -#include "createobject.h" -#include "rttms.h" -#include "code-from-dbp.h" -#include "CObjectsC.h" -#include "CMemblocks.h" -#include "CGfxC.h" -#include ".\..\..\Shared\Objects\ShadowMapping\cShadowMaps.h" - -bool update_mesh_light(sMesh* pMesh, sObject* pObject, sFrame* pFrame); - -s_BT_main BT_Main; - -// shadow mapping -extern CascadedShadowsManager g_CascadedShadow; - -extern GlobStruct* g_pGlob; -extern void AddToRenderList(LPVOID pFunction, int iPriority); - -int g_LevelToRender = 5; -int g_iQualityTechniqueMode = 0; -int g_iTerrainIDForShadowMap = 0; -bool g_bRenderTerrainForShadowMap = false; - -// New DX11 Constant buffer structure -#ifdef DX11 -struct CBChangePerTerrsainChunk -{ - KMaths::Matrix mWorld; - KMaths::Matrix mView; - KMaths::Matrix mProjection; -}; -struct CBChangePerTerrsainChunkPS -{ - GGCOLOR vMaterialEmissive; - float fAlphaOverride; - float fRes1; - float fRes2; - float fRes3; - KMaths::Matrix mViewInv; - KMaths::Matrix mViewProj; - KMaths::Matrix mPrevViewProj; -}; -ID3D11Buffer* m_pCBChangePerTerrsainChunk = NULL; -ID3D11Buffer* m_pCBChangePerTerrsainChunkPS = NULL; -#else -#endif - -void SetTerrainRenderLevel( int size ) -{ - float s = (float)size; - if ( s < 1 ) s = 1; - if ( s > 100 ) s = 100; - - // 1-5 - g_LevelToRender = (int)(ceil(s /= 20.0f)); -} - -#ifndef COMPILE_GDK - - void BTConstructor() - { - BT_Main.buildstep=1; - - // from passcore - //CO_ReceiveCoreDataPtr(NULL); - AddToRenderList(&BT_Intern_Render,7500); - memset(&BT_Main,0,sizeof(s_BT_main)); - BT_Main.InstructionQueueSize=1000; - BT_Main.InstructionQueueUsed=0; - BT_Main.InstructionQueue=new char[BT_Main.InstructionQueueSize]; - BT_Main.InstructionQueue[0]=NULL; - BT_Main.Initialised=true; - BT_Main.buildstep=1; - } - - void BTReceiveCoreDataPtr(LPVOID CorePtr) - { - } - - void BTDestructor() - { - } - -#endif - -//======================== -// === BT MAKE TERRAIN === -//======================== -unsigned long BT_MakeTerrain() -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_MAKETERRAIN; - -//Variables - unsigned long TerrainNum; - bool FoundID=0; - -//Check that BT is initialised - if(BT_Main.Initialised) - { - //Find a free terrain ID - TerrainNum=1; - while(FoundID==0) - { - //Check if we have gone over terrain limit and call an error - if(TerrainNum>C_BT_MAXTERRAINS+1) - { - BT_Intern_Error(C_BT_ERROR_MAXTERRAINSEXCEDED); - return 0; - } - - if(BT_Main.Terrains[TerrainNum].Exists) - { - TerrainNum++; - }else{ - FoundID=1; - } - } - - //Set default values - memset(&BT_Main.Terrains[TerrainNum],0,sizeof(s_BT_terrain)); - BT_Main.Terrains[TerrainNum].Exists=1; - BT_Main.Terrains[TerrainNum].ID=TerrainNum; - BT_Main.Terrains[TerrainNum].Scale=1.0f; - BT_Main.Terrains[TerrainNum].YScale=1.0f; - BT_Main.Terrains[TerrainNum].Tile=1.0f; - BT_Main.Terrains[TerrainNum].LODLevels=1; - BT_Main.Terrains[TerrainNum].LODLevel=(s_BT_LODLevel*)malloc(sizeof(s_BT_LODLevel)*C_BT_MAXLODLEVELS); - if(BT_Main.Terrains[TerrainNum].LODLevel==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset ( BT_Main.Terrains[TerrainNum].LODLevel, 0, sizeof(s_BT_LODLevel)*C_BT_MAXLODLEVELS ); - BT_Main.Terrains[TerrainNum].Built=0; - BT_Main.Terrains[TerrainNum].Generated=0; - BT_Main.Terrains[TerrainNum].MeshOptimisation=true; - BT_Main.Terrains[TerrainNum].ExclusionThreshold=128; - BT_Main.Terrains[TerrainNum].DetailBlendMode=8; - - //Setup Environment map - BT_Main.Terrains[TerrainNum].EnvironmentMap=(BT_EnvironmentMap*)malloc(sizeof(BT_EnvironmentMap)); - if(BT_Main.Terrains[TerrainNum].EnvironmentMap==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(BT_Main.Terrains[TerrainNum].EnvironmentMap,0,sizeof(BT_EnvironmentMap)); - BT_Main.Terrains[TerrainNum].EnvironmentMap->EnvironmentBuffer=(unsigned long*)malloc(4); - if(BT_Main.Terrains[TerrainNum].EnvironmentMap->EnvironmentBuffer==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - - //Setup TerrainInfo - BT_TerrainInfo* TerrainInfo=(BT_TerrainInfo*)malloc(sizeof(BT_TerrainInfo)); - if(TerrainInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(TerrainInfo,0,sizeof(BT_TerrainInfo)); - TerrainInfo->Scale=1.0f; - TerrainInfo->YScale=1.0f; - TerrainInfo->Tile=1.0f; - TerrainInfo->LODLevels=1; - TerrainInfo->MeshOptimisation=true; - TerrainInfo->ExclusionThreshold=128; - TerrainInfo->DetailBlendMode=8; - BT_Main.Terrains[TerrainNum].Info=(void*)TerrainInfo; - - //Return the terrain id - return TerrainNum; - - } - return NULL; -} -// === END FUNCTION === - - - -//================================= -// === BT SET TERRAIN HEIGHTMAP === -//================================= -void BT_SetTerrainHeightmap(unsigned long terrainid,unsigned long image) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINHEIGHTMAP; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built==false) - { - //Set the values - BT_Main.Terrains[terrainid].Heightmap=image; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINALREADYBUILT); - return; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} - -// ============================== -// === BT SET TERRAIN TEXTURE === -// ============================== -void BT_SetTerrainTexture(unsigned long terrainid,unsigned long image) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINTEXTURE; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built) - { - //Set the texture - BT_Main.Terrains[terrainid].Texture=image; - SetObjectBlendMap(BT_Main.Terrains[terrainid].ObjectID,0,image,10,4); - }else{ - //Set the texture - BT_Main.Terrains[terrainid].Texture=image; - } - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->Texture=image; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ================================ -// === BT SET TERRAIN EXCLUSION === -// ================================ -void BT_SetTerrainExclusion(unsigned long terrainid,unsigned long image) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINEXCLUSION; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built==false) - { - //Set the exclusionmap -#ifdef C_BT_FULLVERSION - BT_Main.Terrains[terrainid].Exclusionmap=image; - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->Exclusion=true; -#endif - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINALREADYBUILT); - return; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - -// ========================================== -// === BT SET TERRAIN EXCLUSION THRESHOLD === -// ========================================== -void BT_SetTerrainExclusionThreshold(unsigned long terrainid,unsigned long threshold) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINEXCLUSIONTHRESHOLD; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built==false) - { - //Set the exclusion threshold -#ifdef C_BT_FULLVERSION - BT_Main.Terrains[terrainid].ExclusionThreshold=unsigned char(threshold); - - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->ExclusionThreshold=unsigned char(threshold); -#endif - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINALREADYBUILT); - return; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ============================= -// === BT SET TERRAIN DETAIL === -// ============================= -void BT_SetTerrainDetail(unsigned long terrainid,unsigned long image) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINDETAIL; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built) - { - //Set the detailmap - BT_Main.Terrains[terrainid].Detailmap=image; - SetObjectBlendMap(BT_Main.Terrains[terrainid].ObjectID,1,image,11,BT_Main.Terrains[terrainid].DetailBlendMode); - }else{ - BT_Main.Terrains[terrainid].Detailmap=image; - } - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->Detailmap=image; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ======================================= -// === BT SET TERRAIN DETAIL BLENDMODE === -// ======================================= -void BT_SetTerrainDetailBlendMode(unsigned long terrainid,unsigned char mode) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINDETAILBLENDMODE; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built==true) - { - //Set the detail blendmode - BT_Main.Terrains[terrainid].DetailBlendMode=mode; - if(BT_Main.Terrains[terrainid].Detailmap) - SetObjectBlendMap(BT_Main.Terrains[terrainid].ObjectID,1,BT_Main.Terrains[terrainid].Detailmap,11,mode); - }else{ - //Set the detail blendmode - BT_Main.Terrains[terrainid].DetailBlendMode=mode; - } - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->DetailBlendMode=mode; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ================================== -// === BT SET TERRAIN ENVIRONMENT === -// ================================== -void BT_SetTerrainEnvironment(unsigned long terrainid,unsigned long image) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINENVIRONMENT; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Set the environmentmap - BT_Main.Terrains[terrainid].Environmentmap=image; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ================================== -// === BT ADD TERRAIN ENVIRONMENT === -// ================================== -unsigned long BT_AddTerrainEnvironment(unsigned long terrainid,unsigned long Colour) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_ADDTERRAINENVIRONMENT; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built==true) - { - BT_Intern_Error(C_BT_ERROR_CANNOTUSEFUNCTIONONBUILTTERRAIN); - return 0; - }else{ - //Add the environment - return BT_Intern_AddEnvironment(BT_Main.Terrains[terrainid].EnvironmentMap,Colour); - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return 0; - } -} -// === END FUNCTION === - - - -// ========================== -// === BT SET TERRAIN LOD === -// ========================== -void BT_SetTerrainLOD(unsigned long terrainid,unsigned char LODLevels) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINLOD; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check the LOD Levels - if(LODLevels>0 && LODLevels<=C_BT_MAXLODLEVELS) - { - //Set the LODLevels - BT_Main.Terrains[terrainid].LODLevels=LODLevels; - - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->LODLevels=LODLevels; - - }else{ - BT_Intern_Error(C_BT_ERROR_INVALIDLODLEVELS); - return; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ============================ -// === BT SET TERRAIN SPLIT === -// ============================ -void BT_SetTerrainSplit(unsigned long terrainid,unsigned long Split) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINSPLIT; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Set the Collision LODLevel - BT_Main.Terrains[terrainid].LODLevel[0].Split=unsigned short(Split); - - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ================================== -// === BT SET TERRAIN DETAIL TILE === -// ================================== -void BT_SetTerrainDetailTile(unsigned long terrainid,float Tile) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINDETAILTILE; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Set the Collision LODLevel - BT_Main.Terrains[terrainid].Tile=Tile; - - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->Tile=Tile; - - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ===================================== -// === BT SET TERRAIN QUAD REDUCTION === -// ===================================== -void BT_SetTerrainQuadReduction(unsigned long terrainID, bool enabled) -{ - // Set Current function - BT_Main.CurrentFunction = C_BT_FUNCTION_SETTERRAINQUADREDUCTION; - - // Check that the terrain exists - if (!BT_Intern_TerrainExist(terrainID)) - return; - - // Check that this is the full version - #ifndef C_BT_FULLVERSION - return; - #endif - - // Set quad reduction - BT_Main.Terrains[terrainID].QuadReduction=enabled; - ((BT_TerrainInfo*)BT_Main.Terrains[terrainID].Info)->QuadReduction=enabled; -} -// === END FUNCTION === - - - -// ==================================== -// === BT SET TERRAIN QUAD ROTATION === -// ==================================== -void BT_SetTerrainQuadRotation(unsigned long terrainid,bool Enabled) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINQUADROTATION; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Set Quad rotation -#ifdef C_BT_FULLVERSION - BT_Main.Terrains[terrainid].QuadRotation=Enabled; -#endif - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->QuadRotation=Enabled; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ================================ -// === BT SET TERRAIN SMOOTHING === -// ================================ -void BT_SetTerrainSmoothing(unsigned long terrainid,unsigned long Amount) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINSMOOTHING; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Limit amount - if(Amount>100) - Amount=100; - - //Set the Collision LODLevel - BT_Main.Terrains[terrainid].Smoothing=Amount; - - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->Smoothing=(Amount>0); - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->SmoothAmount=Amount; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ============================ -// === BT SET TERRAIN SCALE === -// ============================ -void BT_SetTerrainScale(unsigned long terrainid,float Scale) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINSCALE; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Set the Scale - BT_Main.Terrains[terrainid].Scale=Scale; - - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->Scale=Scale; - - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ============================= -// === BT SET TERRAIN YSCALE === -// ============================= -void BT_SetTerrainYScale(unsigned long terrainid,float YScale) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINYSCALE; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Set the Collision LODLevel - BT_Main.Terrains[terrainid].YScale=YScale; - - //Update in terrain info - ((BT_TerrainInfo*)BT_Main.Terrains[terrainid].Info)->YScale=YScale; - - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// =================================== -// === BT SET TERRAIN LOD DISTANCE === -// =================================== -void BT_SetTerrainLODDistance(unsigned long terrainid,unsigned char LODLevel,float value) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETTERRAINLODDISTANCES; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - if(LODLevelDistance=value; - BT_Main.Terrains[terrainid].LODLevel[LODLevel].Distance=value/BT_Main.Terrains[terrainid].Scale*C_BT_INTERNALSCALE; - }else{ - BT_Main.Terrains[terrainid].LODLevel[LODLevel].Distance=value; - } - - }else{ - - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return; - } - - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ======================== -// === BT BUILD TERRAIN === -// ======================== -void BT_BuildTerrain(unsigned long terrainid,unsigned long ObjectID) -{ - BT_BuildTerrain(terrainid,ObjectID,false); -} - -void BT_BuildTerrain(unsigned long terrainid,unsigned long ObjectID,bool GenerateTerrain) -{ - -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_BUILDTERRAIN; - -//Variables - unsigned long HeightmapImg; - int size; - unsigned long Heightmapmemblock; - unsigned short x; - unsigned short y; - unsigned short lx; - unsigned short ly; - unsigned long currentvertex; - unsigned short Sectors; - unsigned short Sector; - unsigned short Column; - unsigned short Row; - unsigned char LODLevel; - unsigned long MaxLODLevels; - BT_Quadmap_Generator Generator; - unsigned long Excludememblock; - s_BT_terrain* Terrain; - -//Check that the system isnt building - if(BT_Main.Building) - BT_Intern_Error(C_BT_ERROR_ALREADYBUILDING); - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Get the terrain pointer - Terrain=&BT_Main.Terrains[terrainid]; - - //Check that the terrain isnt built - if(Terrain->Built==true) - BT_Intern_Error(C_BT_ERROR_TERRAINALREADYBUILT); - - //Find the heightmap image - HeightmapImg=Terrain->Heightmap; - - //Check all the images - - //Heightmap - if(BT_Intern_ImageExist(HeightmapImg)==false) - { - BT_Intern_Error(C_BT_ERROR_HEIGHTMAPDOESNTEXIST); - return; - } - - //Texture - if(BT_Intern_ImageExist(Terrain->Texture)==false) - Terrain->Texture=0; - - //Detailmap - if(BT_Intern_ImageExist(Terrain->Detailmap)==false) - Terrain->Detailmap=0; - - //Environmentmap - if(BT_Intern_ImageExist(Terrain->Environmentmap)==false) - Terrain->Environmentmap=0; - - //Exclusionmap - if(BT_Intern_ImageExist(Terrain->Exclusionmap)==false) - Terrain->Exclusionmap=0; - - - //Open heightmap - //Find free memblock - Heightmapmemblock=0; - do { - Heightmapmemblock++; - } while ( !( MemblockExist(Heightmapmemblock) == 0 ) ); - - //Make memblock from heightmap - CreateMemblockFromImage(Heightmapmemblock,HeightmapImg); - unsigned long* HeightmapMemblockPtr=(unsigned long*)GetMemblockPtr(Heightmapmemblock); - - - //Check heightmap size - //Width and height must be equal - if(HeightmapMemblockPtr[0]!=HeightmapMemblockPtr[1]) - BT_Intern_Error(C_BT_ERROR_HEIGHTMAPSIZEINVALID); - - //Dimensions must be power of 2 numbers - size=HeightmapMemblockPtr[0]; - if((size & -size) != size) - BT_Intern_Error(C_BT_ERROR_HEIGHTMAPSIZEINVALID); - - //Size must be equal to or greater than 64 - if(size<128) - BT_Intern_Error(C_BT_ERROR_HEIGHTMAPSIZEINVALID); - - //Size must be less or equal to C_BT_MAXTERRAINSIZE - if(size>C_BT_MAXTERRAINSIZE) - BT_Intern_Error(C_BT_ERROR_HEIGHTMAPSIZEINVALID); - - //Set heightmap size - Terrain->Heightmapsize=unsigned short(HeightmapMemblockPtr[0]); - ((BT_TerrainInfo*)Terrain->Info)->Heightmapsize=Terrain->Heightmapsize; - - //Exclusionmap must be same size as heightmap - if(Terrain->Exclusionmap>0) - { - size=ImageWidth(Terrain->Exclusionmap); - if(size=!ImageWidth(HeightmapImg)) - BT_Intern_Error(C_BT_ERROR_EXCLUSIONMAPSIZEINVALID); - } - - //Give split an autovalue if not set - if(Terrain->LODLevel[0].Split==0) - Terrain->LODLevel[0].Split=Terrain->Heightmapsize/32; - - //Check that split isnt too small - if(Terrain->Heightmapsize/Terrain->LODLevel[0].Split>64) - BT_Intern_Error(C_BT_ERROR_SECTORTOOBIG); - - //Work out some variables - //Terrain size - Terrain->TerrainSize=(Terrain->Heightmapsize-1)*C_BT_INTERNALSCALE; - unsigned short Split=Terrain->LODLevel[0].Split; - for(LODLevel=0;LODLevelLODLevels;LODLevel++) - { - //Split - Terrain->LODLevel[LODLevel].Split=Split; - Split=Split/2; - - //Sector size* - Terrain->LODLevel[LODLevel].SectorSize=(Terrain->TerrainSize+C_BT_INTERNALSCALE)/Terrain->LODLevel[LODLevel].Split; - - //Sector detail - Terrain->LODLevel[LODLevel].SectorDetail=Terrain->Heightmapsize/Terrain->LODLevel[0].Split; - } - - //Check the LOD levels - MaxLODLevels=int(log10((float)Terrain->LODLevel[0].Split)/log10((float)2))+1; - if(Terrain->LODLevels>(char)MaxLODLevels) - { - Terrain->LODLevels=(char)MaxLODLevels; - Terrain->LODLevel=(s_BT_LODLevel*)realloc(Terrain->LODLevel,MaxLODLevels*sizeof(s_BT_LODLevel)); - if(Terrain->LODLevel==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - } - - //Load Heightmap - - //Allocate points - Terrain->HeightPoint=(float*)malloc(Terrain->Heightmapsize*Terrain->Heightmapsize*sizeof(float)); - if(Terrain->HeightPoint==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - - //Fill the points with data - currentvertex=0; - Terrain->ATMode=BT_Main.ATMode; - for(ly=0;lyHeightmapsize;ly++) - { - for(lx=0;lxHeightmapsize;lx++) - { - if(Terrain->ATMode) - { - x=lx; - y=Terrain->Heightmapsize-ly-1; - }else{ - x=lx; - y=ly; - } - Terrain->HeightPoint[currentvertex]=BT_Intern_GetHeightFromColor(HeightmapMemblockPtr[3+x+y*Terrain->Heightmapsize])*Terrain->YScale; - currentvertex++; - } - } - - //Delete memblock - DeleteMemblock(Heightmapmemblock); - - //Smooth terrain - // LEENOTE - 070314 - Dave, why did you comment this out on 070314? - BT_Intern_SmoothTerrain(Terrain); - - //Make exclusion memblock - if(Terrain->Exclusionmap>0) - { - Excludememblock=Heightmapmemblock; - CreateMemblockFromImage(Excludememblock,Terrain->Exclusionmap); - }else{ - Excludememblock=0; - } - - //Make object - Terrain->ObjectID=ObjectID; - Terrain->Object=BT_Intern_CreateBlankObject(ObjectID,1); - BT_Intern_SetupMesh(Terrain->Object->pFrame->pMesh,3,0,GGFVF_DIFFUSE); - BT_Intern_FinnishObject(ObjectID); - if(Terrain->Texture!=NULL) - SetObjectBlendMap(ObjectID,0,Terrain->Texture,10,4); - if(Terrain->Detailmap!=NULL) - SetObjectBlendMap(ObjectID,1,Terrain->Detailmap,11,Terrain->DetailBlendMode); - - //Make sectors - Terrain->Sectors=0; - Generator.Size=Terrain->LODLevel[0].SectorDetail; - if(Excludememblock>0) - { - Generator.exclusion=(bool*)malloc((Generator.Size+1)*(Generator.Size+1)*sizeof(bool)); - if(Generator.exclusion==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - }else{ - Generator.exclusion=NULL; - } - Generator.heights=(float*)malloc((Generator.Size+1)*(Generator.Size+1)*sizeof(float)); - if(Generator.heights==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - BT_Intern_StartQuadMapGeneration(Generator); - - for(LODLevel=0;LODLevelLODLevels;LODLevel++) - { - s_BT_LODLevel* LODLevelPtr=&Terrain->LODLevel[LODLevel]; - - //Scale distance - LODLevelPtr->Distance=LODLevelPtr->Distance/Terrain->Scale*C_BT_INTERNALSCALE; - - //Allocate sectors - Sectors=LODLevelPtr->Split*LODLevelPtr->Split; - Terrain->Sectors+=Sectors; - LODLevelPtr->Sectors=Sectors; - LODLevelPtr->Sector=(s_BT_Sector*)malloc(Sectors*sizeof(s_BT_Sector)); - if(LODLevelPtr->Sector==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(LODLevelPtr->Sector, 0, Sectors*sizeof(s_BT_Sector)); - LODLevelPtr->Terrain=Terrain; - LODLevelPtr->ID=LODLevel; - - //Initialise QuadMap Generator - Generator.QuadRotation=Terrain->QuadRotation; - Generator.QuadReduction=Terrain->QuadReduction; - LODLevelPtr->TileSpan=Terrain->LODLevel[0].Split/LODLevelPtr->Split; - Generator.TileSize=C_BT_INTERNALSCALE*LODLevelPtr->TileSpan; - Generator.Optimise=Terrain->MeshOptimisation; - Generator.LODLevel=LODLevel; - Generator.TileSpan=1; - - //LODLevel Info - BT_LODLevelInfo* LODLevelInfo=(BT_LODLevelInfo*)malloc(sizeof(BT_LODLevelInfo)); - if(LODLevelInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset ( LODLevelInfo, 0, sizeof(BT_LODLevelInfo) ); - LODLevelInfo->Distance=Terrain->LODLevel[LODLevel].Distance; - LODLevelInfo->SectorDetail=Terrain->LODLevel[LODLevel].SectorDetail; - LODLevelInfo->Sectors=Terrain->LODLevel[LODLevel].Sectors; - LODLevelInfo->SectorSize=Terrain->LODLevel[LODLevel].SectorSize; - LODLevelInfo->Split=Terrain->LODLevel[LODLevel].Split; - LODLevelInfo->TileSpan=Terrain->LODLevel[LODLevel].TileSpan; - LODLevelInfo->InternalData=(void*)LODLevelPtr; - LODLevelPtr->Info=(void*)LODLevelInfo; - LODLevelPtr->DBPObject = 0; - - Row=0; - Column=0; - for(Sector=0;SectorSplit) - { - Column++; - Row=0; - } - - //Get sector pointer - s_BT_Sector* SectorPtr=&LODLevelPtr->Sector[Sector]; - - //Fill Sector structure - SectorPtr->ID=Sector; - SectorPtr->Column=Column; - SectorPtr->Row=Row; - SectorPtr->Pos_x=float(Column*Terrain->LODLevel[LODLevel].SectorSize+0.5*Terrain->LODLevel[LODLevel].SectorSize); - SectorPtr->Pos_y=0.0f; - SectorPtr->Pos_z=float(Row*Terrain->LODLevel[LODLevel].SectorSize+0.5*Terrain->LODLevel[LODLevel].SectorSize); - Generator.Sector=SectorPtr; - SectorPtr->LODLevel=&Terrain->LODLevel[LODLevel]; - SectorPtr->Terrain=Terrain; - SectorPtr->DBPObject = 0; - Generator.RemoveFarX=false; - if(Row==LODLevelPtr->Split-1) - Generator.RemoveFarX=true; - Generator.RemoveFarZ=false; - if(Column==LODLevelPtr->Split-1) - Generator.RemoveFarZ=true; - - //Get heights for this sector - BT_Intern_GetSectorHeights(Terrain,LODLevel,Row,Column,Generator.heights); - - Terrain->LODLevel[LODLevel].Sector[Sector].Excluded=false; - if(Excludememblock>0) - { - if(BT_Intern_GetSectorExclusion(Terrain,LODLevel,Excludememblock,Row,Column,Generator.exclusion)==true) - SectorPtr->Excluded=true; - } - - if(Terrain->LODLevel[LODLevel].Sector[Sector].Excluded==false) - { - //RTTMS - Terrain->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS=(BT_RTTMS_STRUCT*)malloc(sizeof(BT_RTTMS_STRUCT)); - if(Terrain->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset ( Terrain->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS, 0, sizeof(BT_RTTMS_STRUCT) ); - BT_RTTMS_STRUCTINTERNALS* RTTMSStructInternals=(BT_RTTMS_STRUCTINTERNALS*)malloc(sizeof(BT_RTTMS_STRUCTINTERNALS)); - if(RTTMSStructInternals==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - RTTMSStructInternals->TerrainID=terrainid; - RTTMSStructInternals->LODLevelID=LODLevel; - RTTMSStructInternals->SectorID=Sector; - RTTMSStructInternals->SectorPtr=SectorPtr; - SectorPtr->VertexDataRTTMS->Internals=(void*)RTTMSStructInternals; - - SectorPtr->QuadMap=(BT_QuadMap*)malloc(sizeof(BT_QuadMap)); - if(SectorPtr->QuadMap==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(SectorPtr->QuadMap,0,sizeof(BT_QuadMap)); - SectorPtr->QuadMap->Generate(Generator); - } - - //Sector Info - BT_SectorInfo* SectorInfo=(BT_SectorInfo*)malloc(sizeof(BT_SectorInfo)); - if(SectorInfo==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset ( SectorInfo, 0, sizeof(BT_SectorInfo) ); - SectorInfo->Column=Column; - SectorInfo->Row=Row; - SectorInfo->Excluded=SectorPtr->Excluded; - SectorInfo->Pos_x=SectorPtr->Pos_x; - SectorInfo->Pos_y=0.0f; - SectorInfo->Pos_z=SectorPtr->Pos_z; - SectorInfo->WorldMatrix=&SectorPtr->WorldMatrix; - SectorInfo->InternalData=(void*)SectorPtr; - SectorPtr->Info=(void*)SectorInfo; - - Row++; - } - } - - //Post process quadmap - for(LODLevel=0;LODLevelLODLevels;LODLevel++) - { - Generator.TileSize=C_BT_INTERNALSCALE*Terrain->LODLevel[LODLevel].TileSpan; - Generator.LODLevel=LODLevel; - for(Sector=0;SectorLODLevel[LODLevel].Sectors;Sector++) - { - s_BT_Sector* SectorPtr=&Terrain->LODLevel[LODLevel].Sector[Sector]; - if(SectorPtr->Excluded==false) - { - SectorPtr->QuadMap->Above=SectorPtr->QuadMap->Below=SectorPtr->QuadMap->Left=SectorPtr->QuadMap->Right=0; - if(SectorPtr->Column!=0) - { - s_BT_Sector* OtherSectorPtr=&Terrain->LODLevel[LODLevel].Sector[Sector-Terrain->LODLevel[LODLevel].Split]; - if(OtherSectorPtr->Excluded==false) - SectorPtr->QuadMap->Above=OtherSectorPtr->QuadMap; - } - if(SectorPtr->Row!=Terrain->LODLevel[LODLevel].Split-1) - { - s_BT_Sector* OtherSectorPtr=&Terrain->LODLevel[LODLevel].Sector[Sector+1]; - if(OtherSectorPtr->Excluded==false) - SectorPtr->QuadMap->Right=OtherSectorPtr->QuadMap; - } - if(SectorPtr->Row!=0) - { - s_BT_Sector* OtherSectorPtr=&Terrain->LODLevel[LODLevel].Sector[Sector-1]; - if(OtherSectorPtr->Excluded==false) - SectorPtr->QuadMap->Left=OtherSectorPtr->QuadMap; - } - if(SectorPtr->Column!=Terrain->LODLevel[LODLevel].Split-1) - { - s_BT_Sector* OtherSectorPtr=&Terrain->LODLevel[LODLevel].Sector[Sector+Terrain->LODLevel[LODLevel].Split]; - if(OtherSectorPtr->Excluded==false) - SectorPtr->QuadMap->Below=OtherSectorPtr->QuadMap; - } - - SectorPtr->QuadMap->CalculateNormals(); - } - } - } - - //Delete exclusion - if(Excludememblock>0) - DeleteMemblock(Excludememblock); - if(Generator.exclusion!=NULL) - free(Generator.exclusion); - - //Load Environment map - if(Terrain->Environmentmap>0) - { - //Convert Image into Memblock (recycle heightmap memblock) - CreateMemblockFromImage(Heightmapmemblock,Terrain->Environmentmap); - - //Create the environment map - BT_Intern_CreateEnvironmentMap(Terrain->EnvironmentMap,ImageWidth(Terrain->Environmentmap),ImageHeight(Terrain->Environmentmap),(unsigned long*)(GetMemblockPtr(Heightmapmemblock)+4)); - - //Delete the Memblock - DeleteMemblock(Heightmapmemblock); - } - - //Allocate quadtree - Terrain->QuadTree=BT_Intern_AllocateQuadTree(Terrain); - - //Create LOD Map - Terrain->LODMap=(s_BT_LODMap**)malloc(Terrain->LODLevel[0].Split*sizeof(s_BT_LODMap*)); - if(Terrain->LODMap==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset ( Terrain->LODMap, 0, Terrain->LODLevel[0].Split*sizeof(s_BT_LODMap*) ); - for(unsigned long i=0;iLODLevel[0].Split;i++) - { - Terrain->LODMap[i]=(s_BT_LODMap*)malloc(Terrain->LODLevel[0].Split*sizeof(s_BT_LODMap)); - if(Terrain->LODMap[i]==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(Terrain->LODMap[i],0,Terrain->LODLevel[0].Split*sizeof(s_BT_LODMap)); - } - - //Vertex Declaration - #ifdef DX11 - - // VD Array (critical that shaders are loaded prior to this step, unlike DX9) - int iLayoutSize = 4; - D3D11_INPUT_ELEMENT_DESC* pLayout = new D3D11_INPUT_ELEMENT_DESC [ iLayoutSize ]; - D3D11_INPUT_ELEMENT_DESC layout [ ] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 1, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - std::memcpy ( pLayout, layout, sizeof ( layout ) ); - - // Get FIRST vertex shader input layout found in shader - ID3DBlob* pBlob = g_sShaders[SHADERSTERRAINBASIC].pBlob; - DWORD tIndex = 0; - ID3DX11EffectTechnique* tech = NULL; - while((tech = g_sShaders[SHADERSTERRAINBASIC].pEffect->GetTechniqueByIndex(tIndex++))->IsValid()) - { - DWORD pIndex = 0; - ID3DX11EffectPass* pass = NULL; - while((pass = tech->GetPassByIndex(pIndex++))->IsValid()) - { - D3DX11_PASS_SHADER_DESC vs_desc; - pass->GetVertexShaderDesc(&vs_desc); - D3DX11_EFFECT_SHADER_DESC s_desc; - vs_desc.pShaderVariable->GetShaderDesc(0, &s_desc); - HRESULT hr = m_pD3D->CreateInputLayout ( pLayout, iLayoutSize, s_desc.pBytecode, s_desc.BytecodeLength, &Terrain->VertexDeclaration ); - break; - } - if ( Terrain->VertexDeclaration != NULL ) break; - } - SAFE_DELETE_ARRAY(pLayout); - - #else - //VD Array - IGGDevice* D3DDevice=m_pD3D; - const GGVERTEXELEMENT VD[5] = - { - {0, 0, GGDECLTYPE_FLOAT3, GGDECLMETHOD_DEFAULT, GGDECLUSAGE_POSITION,0}, - {0, 12, GGDECLTYPE_FLOAT3, GGDECLMETHOD_DEFAULT, GGDECLUSAGE_NORMAL, 0}, - {0, 24, GGDECLTYPE_FLOAT2, GGDECLMETHOD_DEFAULT, GGDECLUSAGE_TEXCOORD,0}, - {0, 32, GGDECLTYPE_FLOAT2, GGDECLMETHOD_DEFAULT, GGDECLUSAGE_TEXCOORD,1}, - GDECL_END() - }; - //Make Vertex Declaration - D3DDevice->CreateVertexDeclaration(VD,&Terrain->VertexDeclaration); - #endif - - //Cleanup - BT_Intern_EndQuadMapGeneration(); - free(Generator.heights); - free(Terrain->HeightPoint); - - //Terrain Info - ((BT_TerrainInfo*)Terrain->Info)->Built=true; - ((BT_TerrainInfo*)Terrain->Info)->Generated=GenerateTerrain; - ((BT_TerrainInfo*)Terrain->Info)->ATMode=Terrain->ATMode; - ((BT_TerrainInfo*)Terrain->Info)->Sectors=Terrain->Sectors; - ((BT_TerrainInfo*)Terrain->Info)->TerrainSize=Terrain->TerrainSize/C_BT_INTERNALSCALE*Terrain->Scale; - ((BT_TerrainInfo*)Terrain->Info)->InternalData=(void*)Terrain; - ((BT_TerrainInfo*)Terrain->Info)->DBPObjectPtr=(void*)Terrain->Object; - - //Initialise build - BT_Main.Building=1; - BT_Main.BuildType=0; - BT_Main.CurrentBuildTerrain=Terrain; - BT_Main.CurrentBuildSector=0; - BT_Main.CurrentBuildRow=0; - BT_Main.CurrentBuildColumn=0; - BT_Main.CurrentBuildTerrainSector=0; - Terrain->Built=1; - - //Build - if(GenerateTerrain==true) - { - unsigned long tempbuildstep=BT_Main.buildstep; - BT_Main.buildstep=0; - int null=BT_ContinueBuild(); - BT_Main.buildstep=tempbuildstep; - } - - //Add RTTMS update handler - BT_RTTMS_AddUpdateHandler(terrainid,BT_Intern_RTTMSUpdateHandler); - - //Fix LOD seams - BT_Intern_FixLODSeams(Terrain); - - //Set autocam - // TODO: Stick some proper values here - SetAutoCam(0.0,0.0,0.0,0.0); - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - - - -// ========================= -// === BT CONTINUE BUILD === -// ========================= -int BT_ContinueBuild() -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_CONTINUEBUILD; - -//Variables - int Progress=0; - int numsectorstomake; - int I; - float Progress_flt; - -//Check that its building - if(BT_Main.Building==true) - { - if(BT_Main.buildstep>BT_Main.CurrentBuildTerrain->Sectors) - BT_Main.buildstep=0; - - //Work out the amount of sectors which need to be made - if(BT_Main.buildstep==0) - { - numsectorstomake=BT_Main.CurrentBuildTerrain->Sectors-BT_Main.CurrentBuildTerrainSector; - }else{ - numsectorstomake=BT_Main.buildstep; - } - if(BT_Main.CurrentBuildTerrainSector+numsectorstomake>BT_Main.CurrentBuildTerrain->Sectors) - numsectorstomake=BT_Main.CurrentBuildTerrain->Sectors-BT_Main.CurrentBuildTerrainSector; - - //Loop - for(I=0;ISectors) - { - Progress=-1; - BT_Main.Building=0; - BT_Main.CurrentBuildTerrain->Generated=true; - ((BT_TerrainInfo*)BT_Main.CurrentBuildTerrain->Info)->Generated=true; - BT_Main.CurrentBuildTerrain=NULL; - BT_Main.CurrentBuildLODLevel=0; - BT_Main.CurrentBuildSector=0; - BT_Main.CurrentBuildRow=0; - BT_Main.CurrentBuildColumn=0; - return -1; - } - - //Get the progress - Progress_flt=float((float(BT_Main.CurrentBuildTerrainSector)/float(BT_Main.CurrentBuildTerrain->Sectors))*100.0); - Progress=int(Progress_flt); - } - return Progress; -} -// === END FUNCTION === - - - -// ======================== -// === BT TERRAIN EXIST === -// ======================== -unsigned long BT_TerrainExist(unsigned long TerrainID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_TERRAINEXIST; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - return 1; - } - -//Return false - return 0; -} -// === END FUNCTION === - - - -// ========================= -// === BT DELETE TERRAIN === -// ========================= -void BT_DeleteTerrain(unsigned long TerrainID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_DELETETERRAIN; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - //Delete the terrain - BT_Intern_DeleteTerrain(TerrainID,true); - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } - -} -// === END FUNCTION === - -void BT_ForceTerrainTechnique(unsigned long QualityTechniqueMode) -{ - g_iQualityTechniqueMode = QualityTechniqueMode; -} - -// =========================== -// === BT GET GROUND HEIGHT == -// =========================== -float BT_GetGroundHeight(unsigned long terrainid,float x,float z,bool Round) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETGROUNDHEIGHT; - -//Variables - float Height=0.0; - -//Check that the terrain exists and has been built - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built) - { - //Get the height - Height=BT_Intern_GetPointHeight(&BT_Main.Terrains[terrainid],x/BT_Main.Terrains[terrainid].Scale*C_BT_INTERNALSCALE,z/BT_Main.Terrains[terrainid].Scale*C_BT_INTERNALSCALE,0,Round); - return Height; - } - } - return Height; -} - -float BT_GetGroundHeight(unsigned long terrainid,float x,float z) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETGROUNDHEIGHT; - -//Variables - float Height=0.0; - -//Check that the terrain exists and has been built - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built) - { - //Get the height - Height=BT_Intern_GetPointHeight(&BT_Main.Terrains[terrainid],x/BT_Main.Terrains[terrainid].Scale*C_BT_INTERNALSCALE,z/BT_Main.Terrains[terrainid].Scale*C_BT_INTERNALSCALE,0,0); - return Height; - } - } - return Height; -} - -// =========================== -// === BT GET TERRAIN SIZE === -// =========================== -float BT_GetTerrainSize(unsigned long terrainid) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETTERRAINSIZE; - -//Variables - float Size=0.0; - -//Check that the terrain exists and has been built - if(BT_Intern_TerrainExist(terrainid)) - { - if(BT_Main.Terrains[terrainid].Built) - { - //Get the size - Size=BT_Main.Terrains[terrainid].TerrainSize/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - return Size; - } - } - return Size; -} - - - -// ============================= -// === BT GET POINT EXCLUDED === -// ============================= -unsigned long BT_GetPointExcluded(unsigned long terrainid,float x,float z) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETPOINTEXCLUDED; - -//Variables - float Height=0.0; - -//Check that the terrain exists and has been built - if(BT_Intern_TerrainExist(terrainid)==true) - { - if(BT_Main.Terrains[terrainid].Built==true) - { - //Return if it is excluded - return BT_Intern_GetPointExcluded(&BT_Main.Terrains[terrainid],x/BT_Main.Terrains[terrainid].Scale*C_BT_INTERNALSCALE,z/BT_Main.Terrains[terrainid].Scale*C_BT_INTERNALSCALE); - } - } - return false; -} -// === END FUNCTION === - - - -// ================================ -// === BT GET POINT ENVIRONMENT === -// ================================ -unsigned long BT_GetPointEnvironment(unsigned long terrainid,float x,float z) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETPOINTENVIRONMENT; - -//Variables - float Height=0.0; - -//Check that the terrain exists and has been built - if(BT_Intern_TerrainExist(terrainid)==true) - { - if(BT_Main.Terrains[terrainid].Built==true) - { - //Check the range - if( x>0 && BT_Main.Terrains[terrainid].TerrainSize/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale>x && - z>0 && BT_Main.Terrains[terrainid].TerrainSize/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale>z) - { - //Transform coordinates to fit on environment map - x=(x*BT_Main.Terrains[terrainid].EnvironmentMap->Width)/BT_Main.Terrains[terrainid].Heightmapsize; - z=(z*BT_Main.Terrains[terrainid].EnvironmentMap->Width)/BT_Main.Terrains[terrainid].Heightmapsize; - - //Return the points environment - return BT_Intern_GetPointEnvironment(BT_Main.Terrains[terrainid].EnvironmentMap,unsigned long(x/BT_Main.Terrains[terrainid].Scale),unsigned long(z/BT_Main.Terrains[terrainid].Scale)); - }else{ - return false; - } - } - } - return false; -} -// === END FUNCTION === - - - -// ====================== -// === BT GET VERSION === -// ====================== -DWORD BT_GetVersion() -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETVERSION; - -//Variables - LPSTR Version=BT_VERSION; - - return (DWORD)Version; -} - -// ========================= -// === BT SET BUILD STEP === -// ========================= -void BT_SetBuildStep(unsigned long step) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETBUILDSTEP; - -//Set build step - BT_Main.buildstep=step; -} -// === END FUNCTION === - - - -// ====================== -// === BT SET AT MODE === -// ====================== -void BT_SetATMode(bool ATMode) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETATMODE; - -//Set AT mode - BT_Main.ATMode=ATMode; -} -// === END FUNCTION === - - - -// ============================= -// === BT ENABLE AUTO RENDER === -// ============================= -void BT_EnableAutoRender(bool AutoRender) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_ENABLEAUTORENDER; - -//Set AT mode - BT_Main.AutoRender=AutoRender; -} -// === END FUNCTION === - - - -// ======================== -// === BT GET STATISTIC === -// ======================== -unsigned long BT_GetStatistic(unsigned long code) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSTATISTIC; - -//Find stat code and return it - if(code==1) - return BT_Main.DrawPrimitiveCount; - - if(code==2) - return BT_Main.DrawCalls; - - if(code==3) - return BT_Main.CullChecks; - - return 0; -} -// === END FUNCTION === - - - -// ================================ -// === BT GET TERRAIN OBJECT ID === -// ================================ -unsigned long BT_GetTerrainObjectID(unsigned long terrainid) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETOBJECTID; - -//Check if terrain exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Return objectID - return BT_Main.Terrains[terrainid].ObjectID; - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return 0; - } -} -// === END FUNCTION === - - - -// ============================= -// === BT MAKE SECTOR OBJECT === -// ============================= -void BT_MakeSectorObject(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID,unsigned long ObjectID) -{ - //Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_MAKESECTOROBJECT; - - //Check that the Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check that the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Check that the Sector exists - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors>SectorID) - { - //Check that the sector is not excluded - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Excluded==0) - { - // Add or Wipe - if ( ObjectID==0 ) - { - BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].DBPObject = 0; - BT_Main.Terrains[terrainid].LODLevel[LODLevel].DBPObject=0; - } - else - { - //Generate the object - sObject* Object=BT_Intern_CreateBlankObject(ObjectID,1); - - //Generate the mesh - BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].QuadMap->GenerateDBPMesh(Object->pFrame->pMesh); - - // for now only reference the actual LOD1 sector as we can guarentee this clipping is perfect. - BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].DBPObject = Object; - - //Finnish the object - Object->bExcluded=true; - BT_Intern_FinnishObject(ObjectID); - - //Position and scale object to terrains position and scale - Object->position.vecPosition.x=BT_Main.Terrains[terrainid].Object->position.vecPosition.x+BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_x/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - Object->position.vecPosition.y=BT_Main.Terrains[terrainid].Object->position.vecPosition.y+BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_y/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - Object->position.vecPosition.z=BT_Main.Terrains[terrainid].Object->position.vecPosition.z+BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_z/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - Object->position.vecScale=BT_Main.Terrains[terrainid].Object->position.vecScale; - - //Record object ref (for later collision mesh updating when raise terrain) - BT_Main.Terrains[terrainid].LODLevel[LODLevel].DBPObject=Object; - } - - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORISEXCLUDED); - } - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORDOESNTEXIST); - } - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - } -} -// === END FUNCTION === - - - -// ============================== -// === BT MAKE TERRAIN OBJECT === -// ============================== -void BT_MakeTerrainObject(unsigned long terrainid,unsigned long LODLevel,unsigned long ObjectID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_MAKETERRAINOBJECT; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Variables - unsigned long SectorID=0; - - //Generate the object - sObject* Object=BT_Intern_CreateBlankObject(ObjectID,BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors); - - //Loop through mesh list - sFrame* CurrentFrame=Object->pFrame; - for(SectorID=0;SectorIDGenerateDBPMesh(CurrentFrame->pMesh); - - //Set LODLevelFrame to sector - BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].LODLevelObjectFrame=CurrentFrame; - - //Position mesh - CurrentFrame->vecOffset.x=BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_x/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - CurrentFrame->vecOffset.y=BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_y/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - CurrentFrame->vecOffset.z=BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_z/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - - //Get next frame and link it properly - CurrentFrame->pSibling=CurrentFrame->pChild; - CurrentFrame->pChild=0; - CurrentFrame=CurrentFrame->pSibling; - } - } - - //Position and scale object to terrains position and scale - Object->position.vecPosition=BT_Main.Terrains[terrainid].Object->position.vecPosition; - Object->position.vecScale=BT_Main.Terrains[terrainid].Object->position.vecScale; - BT_Main.Terrains[terrainid].LODLevel[LODLevel].DBPObject=Object; - - //Finnish the object - Object->bExcluded=true; - BT_Intern_FinnishObject(ObjectID); - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - } -} -// === END FUNCTION === - - - -// ================================= -// === BT UPADTE TERRAIN OBJECTS === -// ================================= -void BT_UpdateTerrainObjects(unsigned long terrainid) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_MAKETERRAINOBJECT; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(terrainid)){ - //Check that the terrain is built - if(BT_Main.Terrains[terrainid].Built){ - //Get Terrain ptr - s_BT_terrain* TerrainPtr=&BT_Main.Terrains[terrainid]; - - //Loop through LOD Levels - for(unsigned long LODLevel=0;LODLevelLODLevels;LODLevel++){ - //Get LODLevel ptr - s_BT_LODLevel* LODLevelPtr=&TerrainPtr->LODLevel[LODLevel]; - - //Loop through sectors - for(unsigned long Sector=0;SectorSectors;Sector++){ - //Get Sector ptr - s_BT_Sector* SectorPtr=&LODLevelPtr->Sector[Sector]; - - //Check that the sector has its own object - if(SectorPtr->DBPObject!=0){ - //Update object - SectorPtr->DBPObject->position.vecPosition.x=BT_Main.Terrains[terrainid].Object->position.vecPosition.x+SectorPtr->Pos_x/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - SectorPtr->DBPObject->position.vecPosition.y=BT_Main.Terrains[terrainid].Object->position.vecPosition.y+SectorPtr->Pos_y/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - SectorPtr->DBPObject->position.vecPosition.z=BT_Main.Terrains[terrainid].Object->position.vecPosition.z+SectorPtr->Pos_z/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - SectorPtr->DBPObject->position.vecScale=BT_Main.Terrains[terrainid].Object->position.vecScale; - } - - //Check if the LODLevel has an object - if(LODLevelPtr->DBPObject!=0){ - //Update object - LODLevelPtr->DBPObject->position.vecPosition=BT_Main.Terrains[terrainid].Object->position.vecPosition; - LODLevelPtr->DBPObject->position.vecScale=BT_Main.Terrains[terrainid].Object->position.vecScale; - } - } - } - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - } -} -// === END FUNCTION === - - - -// ================================ -// === BT GET SECTOR POSITION X === -// ================================ -float BT_GetSectorPositionX(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTORPOSITIONX; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Check if the Sector exists - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors>SectorID) - { - //Return X Position - float PosX=BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_x/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - return PosX; - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } -} - -// ================================ -// === BT GET SECTOR POSITION Y === -// ================================ -float BT_GetSectorPositionY(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTORPOSITIONY; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Check if the Sector exists - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors>SectorID) - { - //Return Y Position - float PosY=BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_y/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - return PosY; - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } -} - -// ================================ -// === BT GET SECTOR POSITION Z === -// ================================ -float BT_GetSectorPositionZ(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTORPOSITIONZ; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Check if the Sector exists - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors>SectorID) - { - //Return Z Position - float PosZ=BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Pos_z/C_BT_INTERNALSCALE*BT_Main.Terrains[terrainid].Scale; - return PosZ; - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } -} - -// =========================== -// === BT GET SECTOR COUNT === -// =========================== -unsigned long BT_GetSectorCount(unsigned long TerrainID,unsigned long LODLevel) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTORCOUNT; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(TerrainID)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[TerrainID].LODLevels>LODLevel) - { - return BT_Main.Terrains[TerrainID].LODLevel[LODLevel].Sectors; - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } - return NULL; -} -// === END FUNCTION === - - - -// =========================== -// === BT GET SECTOR SIZE === -// =========================== -unsigned long BT_GetSectorSize(unsigned long TerrainID,unsigned long LODLevel) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTORSIZE; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(TerrainID)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[TerrainID].LODLevels>LODLevel) - { - float Size=BT_Main.Terrains[TerrainID].LODLevel[LODLevel].SectorSize/C_BT_INTERNALSCALE*BT_Main.Terrains[TerrainID].Scale; - return *(DWORD*)&Size; - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } - return NULL; -} - -// ============================== -// === BT GET SECTOR EXCLUDED === -// ============================== -unsigned long BT_GetSectorExcluded(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTOREXCLUDED; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Check if the Sector exists - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors>SectorID) - { - //Return excluded - return BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Excluded; - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } -} -// === END FUNCTION === - - - -// ========================= -// === BT GET SECTOR ROW === -// ========================= -unsigned long BT_GetSectorRow(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTORROW; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Check if the Sector exists - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors>SectorID) - { - //Return row - return BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Row; - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } -} -// === END FUNCTION === - - - -// ============================= -// === BT GET SECTOR COLLUMN === -// ============================= -unsigned long BT_GetSectorCollumn(unsigned long terrainid,unsigned long LODLevel,unsigned long SectorID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_GETSECTORCOLLUMN; - -//Check if Terrain Exists - if(BT_Intern_TerrainExist(terrainid)) - { - //Check if the LOD level exists - if(BT_Main.Terrains[terrainid].LODLevels>LODLevel) - { - //Check if the Sector exists - if(BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sectors>SectorID) - { - //Return row - return BT_Main.Terrains[terrainid].LODLevel[LODLevel].Sector[SectorID].Column; - }else{ - BT_Intern_Error(C_BT_ERROR_SECTORDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_LODLEVELDOESNTEXIST); - return NULL; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return NULL; - } -} -// === END FUNCTION === - - - -// ============================= -// === BT SET CURRENT CAMERA === -// ============================= -void BT_SetCurrentCamera(unsigned long CameraID) -{ -//Set current function - BT_Main.CurrentFunction=C_BT_FUNCTION_SETCURRENTCAMERA; - -//Check if the camera exists - if(GetCameraInternalData(CameraID)!=NULL) - { - //Add to queue - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_SETCURRENTCAMERA,(char)CameraID); - } - -} -// === END FUNCTION === - - - -// ============================= -// === BT UPDATE TERRAIN LOD === -// ============================= -void BT_UpdateTerrainLOD(unsigned long TerrainID) -{ -//Set current function - BT_Main.CurrentFunction=C_BT_FUNCTION_UPDATETERRAINLOD; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - - //Check that the terrain is generated - if(BT_Main.Terrains[TerrainID].Generated==true) - { - //Add to queue - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_UPDATETERRAINLOD,(char)TerrainID); - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINNOTGENERATED); - return; - } - - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } - -} -// === END FUNCTION === - - - -// ============================== -// === BT UPDATE TERRAIN CULL === -// ============================== -void BT_UpdateTerrainCull(unsigned long TerrainID) -{ -//Set current function - BT_Main.CurrentFunction=C_BT_FUNCTION_UPDATETERRAINCULL; - -//Check that the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - - //Check that the terrain is generated - if(BT_Main.Terrains[TerrainID].Generated==true) - { - //Add to queue - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_UPDATETERRAINCULL,(char)TerrainID); - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINNOTGENERATED); - return; - } - - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } - -} -// === END FUNCTION === - - - -// ========================= -// === BT RENDER TERRAIN === -// ========================= -void BT_RenderTerrain(unsigned long TerrainID) -{ -//Set Current function - BT_Main.CurrentFunction=C_BT_FUNCTION_RENDER; - -//Check if the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - //Check that the terrain is generated - if(BT_Main.Terrains[TerrainID].Generated==true) - { - //Add to queue - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_RENDERTERRAIN,(char)TerrainID); - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINNOTGENERATED); - return; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} -// === END FUNCTION === - -void BT_NoRenderTerrain(unsigned long TerrainID) -{ - BT_Main.CurrentFunction=C_BT_FUNCTION_RENDER; - if(BT_Intern_TerrainExist(TerrainID)) - { - if(BT_Main.Terrains[TerrainID].Generated==true) - { - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_NORENDERTERRAIN,(char)TerrainID); - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINNOTGENERATED); - return; - } - }else{ - BT_Intern_Error(C_BT_ERROR_TERRAINDOESNTEXIST); - return; - } -} - - - -// =========================== -// === BT GET TERRAIN INFO === -// =========================== -void* BT_GetTerrainInfo(unsigned long terrainid) -{ - return BT_Main.Terrains[terrainid].Info; -} -// === END FUNCTION === - - - -// ============================ -// === BT GET LODLEVEL INFO === -// ============================ -void* BT_GetLODLevelInfo(unsigned long terrainid,unsigned long LODLevelID) -{ - return BT_Main.Terrains[terrainid].LODLevel[LODLevelID].Info; -} -// === END FUNCTION === - - - -// ========================== -// === BT GET SECTOR INFO === -// ========================== -void* BT_GetSectorInfo(unsigned long terrainid,unsigned long LODLevelID,unsigned long SectorID) -{ - return BT_Main.Terrains[terrainid].LODLevel[LODLevelID].Sector[SectorID].Info; -} -// === END FUNCTION === - -// ======================== -// === BT INTERN RENDER === THIS AUTOMATICALY GETS CALLED BY DBPRO -// ======================== - -bool g_bSkipTerrainRender = false; -unsigned long g_CurrentTerrainCameraID = 0; - -void BT_Intern_Render() -{ - // Dave - added this as going into the importer can crash in this, in debug mode, so may be dodgy - if ( g_bSkipTerrainRender ) - { - BT_Main.InstructionQueue[0]=NULL; - BT_Main.InstructionQueueUsed=0; - g_bSkipTerrainRender = false; - return; - } - - // 100418 - seems when skip terrain render (.superflat), viewport is not set (and needs to be) - // look FURTHER into this to determine if 1920 or 1772 width viewport is correct for terrain - // 160418 - ensure this fix does not interfere with 64x64 viewport setting for bitmap capture - if ( g_pGlob->iCurrentBitmapNumber < 32 ) - { - // but only if not rendering to a shadow map - if (g_bRenderTerrainForShadowMap == false) - { - tagCameraData* Camera = (tagCameraData*)GetCameraInternalData(0); - D3D11_VIEWPORT vp; - GGVIEWPORT* pvp = &Camera->viewPort3D; - vp.TopLeftX = pvp->X; - vp.TopLeftY = pvp->Y; - vp.Width = (FLOAT)pvp->Width; - vp.Height = (FLOAT)pvp->Height; - vp.MinDepth = pvp->MinZ; - vp.MaxDepth = pvp->MaxZ; - SetupSetViewport(g_pGlob->dwRenderCameraID, &vp, NULL); - } - } - - try - { - //Clear statistics - BT_Intern_ClearStatistics(); - - //Check if autorender is enabled - if(BT_Main.AutoRender==true) - { - //Loop through cameras - for(unsigned long CameraID=0;CameraID<32;CameraID++) - { - if(GetCameraInternalData(CameraID)!=0) - { - //Add camera to queue - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_SETCURRENTCAMERA,(char)CameraID); - - //Loop through terrains - for(unsigned long TerrainID=1;TerrainID1) - { - //Add terrain LOD update to queue - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_UPDATETERRAINLOD,(char)TerrainID); - } - - //Add render terrain to queue - BT_Intern_AddToInstructionQueue(C_BT_INSTRUCTION_RENDERTERRAIN,(char)TerrainID); - } - } - } - } - } - - //Read instruction queue - unsigned long CurrentPos=0; - do - { - if(BT_Main.InstructionQueue[CurrentPos]==C_BT_INSTRUCTION_SETCURRENTCAMERA) - { - //Variables - unsigned long CameraID = BT_Main.InstructionQueue[CurrentPos+1]; - g_CurrentTerrainCameraID = CameraID; - - //Set current camera - BT_Main.CurrentUpdateCamera=(tagCameraData*)GetCameraInternalData(CameraID); - BT_Main.FrustumExtracted=false; - - //Increase position - CurrentPos+=2; - } - else if(BT_Main.InstructionQueue[CurrentPos]==C_BT_INSTRUCTION_UPDATETERRAINCULL) - { - //Variables - unsigned long TerrainID=BT_Main.InstructionQueue[CurrentPos+1]; - - //Cull Offset and scale - BT_Main.CullOffset=-BT_Main.Terrains[TerrainID].Object->position.vecPosition; - BT_Main.CullScale=BT_Main.Terrains[TerrainID].Object->position.vecScale; - BT_Main.CullScale.x=BT_Main.CullScale.x*BT_Main.Terrains[TerrainID].Scale/C_BT_INTERNALSCALE; - BT_Main.CullScale.z=BT_Main.CullScale.z*BT_Main.Terrains[TerrainID].Scale/C_BT_INTERNALSCALE; - - //Extract frustum - if(BT_Main.FrustumExtracted==false) - { - BT_Intern_ExtractFrustum(); - BT_Main.FrustumExtracted=true; - } - - //Update Cull - BT_RTTMS_UnlockTerrain(&BT_Main.Terrains[TerrainID]); - BT_Intern_UpdateCullBoxesRec(&BT_Main.Terrains[TerrainID],BT_Main.Terrains[TerrainID].QuadTree,BT_Main.Terrains[TerrainID].QuadTreeLevels); - - // camera 30 (cube rendering) does not cull terrain visibility - bool bIntersectingCull = false; - if ( g_CurrentTerrainCameraID == 30 ) bIntersectingCull = true; - BT_Intern_CalculateCullingRec(&BT_Main.Terrains[TerrainID],BT_Main.Terrains[TerrainID].QuadTree,BT_Main.Terrains[TerrainID].QuadTreeLevels,bIntersectingCull); - - //Increase position - CurrentPos+=2; - } - else if(BT_Main.InstructionQueue[CurrentPos]==C_BT_INSTRUCTION_UPDATETERRAINLOD) - { - //Variables - unsigned long TerrainID=BT_Main.InstructionQueue[CurrentPos+1]; - - // if no camera at this time, leave - if ( BT_Main.CurrentUpdateCamera==NULL ) return; - - //Set main camera - BT_Main.LODCamPosition=BT_Main.CurrentUpdateCamera->vecPosition; - - //Find LODLevels - if(BT_Main.Terrains[TerrainID].LODLevels>1) - BT_Intern_CalculateLODLevelsRec(&BT_Main.Terrains[TerrainID],BT_Main.Terrains[TerrainID].QuadTree,BT_Main.Terrains[TerrainID].QuadTreeLevels,0); - - //Fix LOD seams - BT_Intern_FixLODSeams(&BT_Main.Terrains[TerrainID]); - - //Increase position - CurrentPos+=2; - } - else if(BT_Main.InstructionQueue[CurrentPos]==C_BT_INSTRUCTION_RENDERTERRAIN) - { - // Variables - unsigned long TerrainID=BT_Main.InstructionQueue[CurrentPos+1]; - - // Check if the object is visible (lee - 050115 - if present!) - if ( BT_Main.Terrains[TerrainID].Object->pFrame ) - { - if(BT_Main.Terrains[TerrainID].Object->pFrame->pMesh->bVisible==true) - { - // Set main camera - BT_Main.LODCamPosition=BT_Main.CurrentUpdateCamera->vecPosition; - - // Render terrain - BT_Intern_RenderTerrain(&BT_Main.Terrains[TerrainID]); - } - } - - // Increase position - CurrentPos+=2; - } - else if(BT_Main.InstructionQueue[CurrentPos]==C_BT_INSTRUCTION_NORENDERTERRAIN) - { - // this mimics the above, but calls BT_Intern_NoRenderTerrain - // which renders no terrain but keeps state changes as though it was (fixes VR rendering) - unsigned long TerrainID=BT_Main.InstructionQueue[CurrentPos+1]; - if ( BT_Main.Terrains[TerrainID].Object->pFrame ) - { - if(BT_Main.Terrains[TerrainID].Object->pFrame->pMesh->bVisible==true) - { - BT_Main.LODCamPosition=BT_Main.CurrentUpdateCamera->vecPosition; - BT_Intern_NoRenderTerrain(&BT_Main.Terrains[TerrainID]); - } - } - - // Increase position - CurrentPos+=2; - } - } - while(BT_Main.InstructionQueue[CurrentPos]!=NULL); - - //Clear instruction queue - BT_Main.InstructionQueue[0]=NULL; - BT_Main.InstructionQueueUsed=0; - } - catch (...) - { - //MessageBox ( NULL, "Terrain module error", "Terrain Module", MB_OK ); - } -} -// === END FUNCTION === - - - -// ========================================== -// === BT INTERN ADD TO INSTRUCTION QUEUE === -// ========================================== -static void BT_Intern_AddToInstructionQueue(char Instruction,char Data) -{ -//Check the queue size - if(BT_Main.InstructionQueueUsed+2Object->pFrame->pMesh; - - #ifdef DX11 - // create constant buffer for quick world position changes - if ( m_pCBChangePerTerrsainChunk == NULL ) - { - D3D11_BUFFER_DESC bdChangePerTerrsainChunkBuffer; - std::memset ( &bdChangePerTerrsainChunkBuffer, 0, sizeof ( bdChangePerTerrsainChunkBuffer ) ); - bdChangePerTerrsainChunkBuffer.Usage = D3D11_USAGE_DEFAULT; - bdChangePerTerrsainChunkBuffer.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bdChangePerTerrsainChunkBuffer.CPUAccessFlags = 0; - bdChangePerTerrsainChunkBuffer.ByteWidth = sizeof ( CBChangePerTerrsainChunk ); - if ( FAILED ( m_pD3D->CreateBuffer ( &bdChangePerTerrsainChunkBuffer, NULL, &m_pCBChangePerTerrsainChunk ) ) ) - return; - } - if ( m_pCBChangePerTerrsainChunkPS == NULL ) - { - D3D11_BUFFER_DESC bdChangePerTerrsainChunkBuffer; - std::memset ( &bdChangePerTerrsainChunkBuffer, 0, sizeof ( bdChangePerTerrsainChunkBuffer ) ); - bdChangePerTerrsainChunkBuffer.Usage = D3D11_USAGE_DEFAULT; - bdChangePerTerrsainChunkBuffer.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bdChangePerTerrsainChunkBuffer.CPUAccessFlags = 0; - bdChangePerTerrsainChunkBuffer.ByteWidth = sizeof ( CBChangePerTerrsainChunkPS ); - if ( FAILED ( m_pD3D->CreateBuffer ( &bdChangePerTerrsainChunkBuffer, NULL, &m_pCBChangePerTerrsainChunkPS ) ) ) - return; - } - - // when rendering terrain for shadow mapping, these transforms are already set (for the light camera view) - if (g_bRenderTerrainForShadowMap == false) - { - // Transforms - GGSetTransform(GGTS_PROJECTION, &Camera->matProjection); - GGSetTransform(GGTS_VIEW, &Camera->matView); - } - - // Viewport for terrain rendering - if (g_bRenderTerrainForShadowMap == true) - { - // the call to RSSetViewports already done in ShadowMap code - } - else - { - D3D11_VIEWPORT vp; - GGVIEWPORT* pvp = &Camera->viewPort3D; - vp.TopLeftX = pvp->X; - vp.TopLeftY = pvp->Y; - vp.Width = (FLOAT)pvp->Width; - vp.Height = (FLOAT)pvp->Height; - vp.MinDepth = pvp->MinZ; - vp.MaxDepth = pvp->MaxZ; - SetupSetViewport ( g_pGlob->dwRenderCameraID, &vp, NULL ); - } - - // Set current render terrain - BT_Main.CurrentRenderTerrain=Terrain; - - // Unlock sectors - BT_Intern_UnlockSectorsRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels); - - // Check if theres an effect - if ( Mesh->pVertexShaderEffect != NULL ) - { - // Vertex Declaration - m_pImmediateContext->IASetInputLayout ( Terrain->VertexDeclaration ); - - // Variables - LPGGEFFECT Effect = Mesh->pVertexShaderEffect->m_pEffect; - - // Obtain technique handles - GGTECHNIQUE hNearTechnique = Mesh->pVertexShaderEffect->m_hCurrentTechnique; - GGTECHNIQUE hDistantTechnique = Effect->GetTechniqueByName ( "Distant" ); - - // Can also render terrain into the shadow map, so use super quick render type - int iQualityPassCount = 2; - if (g_bRenderTerrainForShadowMap == true) - { - iQualityPassCount = 1; - hNearTechnique = Effect->GetTechniqueByName ( "DepthMap" ); - hDistantTechnique = Effect->GetTechniqueByName ( "DepthMap" ); - } - // Two passes, one NORMAL technique and one VERY LOW technique (distant terrain) - BT_Main.CurrentEffect=Mesh->pVertexShaderEffect; - for ( int iQualityPass=0; iQualityPassIsValid() ) - { - // Move plenty of effect setup to here (performance) - m_pImmediateContext->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - - if (g_bRenderTerrainForShadowMap == true) - { - m_pImmediateContext->RSSetState(m_pRasterStateTerrainShadow); - m_pImmediateContext->OMSetBlendState(m_pBlendStateNoAlpha, 0, 0xffffffff); - m_pImmediateContext->OMSetDepthStencilState(m_pDepthStencilState, 0); - } - else - { - // state blocks for raster, blend and depthstencil - m_pImmediateContext->RSSetState(m_pRasterState); - m_pImmediateContext->OMSetBlendState(m_pBlendStateNoAlpha, 0, 0xffffffff); - m_pImmediateContext->OMSetDepthStencilState(m_pDepthStencilState, 0); - } - - - // Update shadow textures of terrain shader (added for DX11 - not sure where DX9 did this) - if (iQualityPass == 0 && g_bRenderTerrainForShadowMap == false) - { - DWORD dwEffectIndex = Mesh->pVertexShaderEffect->m_dwEffectIndex; - if (dwEffectIndex < EFFECT_INDEX_SIZE) - { - if (g_CascadedShadow.m_pEffectParam[dwEffectIndex]) - { - GGHANDLE hdepthHandle0 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX1; - GGHANDLE hdepthHandle1 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX2; - GGHANDLE hdepthHandle2 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX3; - GGHANDLE hdepthHandle3 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX4; - GGHANDLE hdepthHandle4 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX5; - GGHANDLE hdepthHandle5 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX6; - GGHANDLE hdepthHandle6 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX7; - GGHANDLE hdepthHandle7 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX8; - if (hdepthHandle0 && g_CascadedShadow.m_depthTexture[0]) hdepthHandle0->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[0]->getTextureResourceView()); - if (hdepthHandle1 && g_CascadedShadow.m_depthTexture[1]) hdepthHandle1->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[1]->getTextureResourceView()); - if (hdepthHandle2 && g_CascadedShadow.m_depthTexture[2]) hdepthHandle2->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[2]->getTextureResourceView()); - if (hdepthHandle3 && g_CascadedShadow.m_depthTexture[3]) hdepthHandle3->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[3]->getTextureResourceView()); - if (hdepthHandle4 && g_CascadedShadow.m_depthTexture[4]) hdepthHandle4->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[4]->getTextureResourceView()); - if (hdepthHandle5 && g_CascadedShadow.m_depthTexture[5]) hdepthHandle5->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[5]->getTextureResourceView()); - if (hdepthHandle6 && g_CascadedShadow.m_depthTexture[6]) hdepthHandle6->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[6]->getTextureResourceView()); - if (hdepthHandle7 && g_CascadedShadow.m_depthTexture[7]) hdepthHandle7->AsShaderResource()->SetResource(g_CascadedShadow.m_depthTexture[7]->getTextureResourceView()); - } - } - } - - // pass clipping data to shader - if ( Mesh->pVertexShaderEffect->m_VecClipPlaneEffectHandle ) - { - GGVECTOR4 vec; - tagCameraData* m_Camera_Ptr = (tagCameraData*)GetCameraInternalData ( g_pGlob->dwRenderCameraID ); - if ( m_Camera_Ptr ) - { - if ( m_Camera_Ptr->iClipPlaneOn==1 ) - { - // special mode which creates plane but does not use RenderState to set clip - // as you cannot mix FF clip and HLSL clip in same scene (artefacts) - vec.x = m_Camera_Ptr->planeClip.a; - vec.y = m_Camera_Ptr->planeClip.b; - vec.z = m_Camera_Ptr->planeClip.c; - vec.w = m_Camera_Ptr->planeClip.d; - } - else - { - // ensure shader stops using clip plane when not being clipped! - vec = GGVECTOR4( 0.0f, 1.0f, 0.0f, 99999.0f ); - } - } - else - { - // ensure shader stops using clip plane when not being clipped! - vec = GGVECTOR4( 0.0f, 1.0f, 0.0f, 99999.0f ); - } - Mesh->pVertexShaderEffect->m_VecClipPlaneEffectHandle->AsVector()->SetFloatVector ( (float*)&vec ); - } - - // Ensure normal invert in effect for terrain (NOTE: not liking duplicated of code) - #ifdef DX11 - //PE: removed , terrain always invert normal. -// GGHANDLE pArtFlags = Mesh->pVertexShaderEffect->m_pEffect->GetVariableByName ( "ArtFlagControl1" ); -// if ( pArtFlags ) -// { -// float fInvertNormal = 0.0f; -// if ( Mesh->dwArtFlags & 0x1 ) fInvertNormal = 1.0f; -// GGVECTOR4 vec4 = GGVECTOR4 ( fInvertNormal, 0.0f, 0.0f, 0.0f ); -// pArtFlags->AsVector()->SetFloatVector ( (float*)&vec4 ); -// } - #endif - - // apply effect ready for rendering - hTechniqueUsed->GetPassByIndex(0)->Apply(0,m_pImmediateContext); - - // Set textures (AFTER Apply which overrides texture view ptrs) - if (g_bRenderTerrainForShadowMap == false) - { - for (unsigned long i = 0; i < Mesh->dwTextureCount; i++) // terrain now has lots of textures - { - if (i != 1 && i != 5 && i != 7) - { - //PE: only for more gpu mem (cache) they are not used. - ID3D11ShaderResourceView* lpTexture = NULL; - if (Mesh->dwTextureCount > i) lpTexture = Mesh->pTextures[i].pTexturesRefView; - m_pImmediateContext->PSSetShaderResources(i, 1, &lpTexture); - } - } - } - - // assign constants - GGMATRIX matWorld; - GGGetTransform ( GGTS_WORLD, &matWorld ); - Mesh->pVertexShaderEffect->Start ( Mesh, matWorld ); - - //PE: Terrain should be split into smaller meshes for better light. - if (g_bRenderTerrainForShadowMap == false) - update_mesh_light(Mesh, NULL,NULL); - - // Render many terrain chunks (only CB changes for world position for faster rendering) - BT_Intern_RenderTerrainRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels,iQualityPass); - - // End effect - BT_Main.CurrentEffect=NULL; - - // Free textures (especially camera image texture which needs to be output bound next cycle) - if (g_bRenderTerrainForShadowMap == false) - { - for (unsigned long i = 0; i < Mesh->dwTextureCount; i++) - { - if (i != 1 && i != 5 && i != 7) - { - //PE: - ID3D11ShaderResourceView* lpTexture = NULL; - m_pImmediateContext->PSSetShaderResources(i, 1, &lpTexture); - } - } - } - } - } - } - else - { - // no rendering if no effect shader - } - - // zero current render terrain - BT_Main.CurrentRenderTerrain=NULL; - - #else - // Set textures - IGGDevice* D3DDevice=m_pD3D; - for(unsigned long i=0;i<8;i++) - { - if(Mesh->dwTextureCount>i) - { - D3DDevice->SetTexture(Mesh->pTextures[i].dwStage,Mesh->pTextures[i].pTexturesRef); - D3DDevice->SetTextureStageState(Mesh->pTextures[i].dwStage,D3DTSS_COLOROP,Mesh->pTextures[i].dwBlendMode); - D3DDevice->SetTextureStageState(Mesh->pTextures[i].dwStage,D3DTSS_COLORARG1,Mesh->pTextures[i].dwBlendArg1); - D3DDevice->SetTextureStageState(Mesh->pTextures[i].dwStage,D3DTSS_COLORARG2,Mesh->pTextures[i].dwBlendArg2); - D3DDevice->SetSamplerState(Mesh->pTextures[i].dwStage,D3DSAMP_MAGFILTER,Mesh->pTextures[i].dwMagState); - D3DDevice->SetSamplerState(Mesh->pTextures[i].dwStage,D3DSAMP_MINFILTER,Mesh->pTextures[i].dwMinState); - D3DDevice->SetSamplerState(Mesh->pTextures[i].dwStage,D3DSAMP_MIPFILTER,Mesh->pTextures[i].dwMipState); - - // Clamp base texture - if(i==0) - { - D3DDevice->SetSamplerState(Mesh->pTextures[i].dwStage,D3DSAMP_ADDRESSU,GGTADDRESS_CLAMP); - D3DDevice->SetSamplerState(Mesh->pTextures[i].dwStage,D3DSAMP_ADDRESSV,GGTADDRESS_CLAMP); - } - } - else - { - D3DDevice->SetTexture(i,NULL); - } - } - - // Set shader - if(Mesh->bOverridePixelShader) - { - D3DDevice->SetPixelShader(Mesh->pPixelShader); - } - else - { - D3DDevice->SetPixelShader(NULL); - } - if(Mesh->bUseVertexShader) - { - D3DDevice->SetVertexShader(Mesh->pVertexShader); - } - else - { - D3DDevice->SetVertexShader(NULL); - } - - // Transforms - D3DDevice->SetTransform(GGTS_PROJECTION,&Camera->matProjection); - D3DDevice->SetTransform(GGTS_VIEW,&Camera->matView); - - // Store old VertDec to restore later - IDirect3DVertexDeclaration9* pDecl = NULL; - D3DDevice->GetVertexDeclaration(&pDecl); - DWORD dwFVF = 0; - D3DDevice->GetFVF(&dwFVF); - - // Vertex Declaration - D3DDevice->SetVertexDeclaration(Terrain->VertexDeclaration); - - // Viewport - D3DDevice->SetViewport((GGVIEWPORT*)&Camera->viewPort3D); - - // DBPRO RENDERING ENGINE - DBPRO_SetMeshRenderStates(Mesh); - - // Set current render terrain - BT_Main.CurrentRenderTerrain=Terrain; - - // Unlock sectors - BT_Intern_UnlockSectorsRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels); - - // Check if theres an effect - if(Mesh->pVertexShaderEffect!=NULL) - { - // Variables - LPGGEFFECT Effect=Mesh->pVertexShaderEffect->m_pEffect; - - // Obtain technique handles - GGHANDLE hNearTechnique = Effect->GetCurrentTechnique(); - GGHANDLE hDistantTechnique = Effect->GetTechniqueByName ( "Distant" ); - - // Two passes, one NORMAL technique and one VERY LOW technique (distant terrain) - BT_Main.CurrentEffect=Mesh->pVertexShaderEffect; - for ( int iQualityPass=0; iQualityPass<2; iQualityPass++ ) - { - // Set correct technique - GGHANDLE hTechniqueUsed = NULL; - if ( g_iQualityTechniqueMode==0 ) - { - if ( iQualityPass==0 ) hTechniqueUsed = hNearTechnique; - if ( iQualityPass==1 ) hTechniqueUsed = hDistantTechnique; - } - else - { - if ( g_iQualityTechniqueMode==1 ) hTechniqueUsed = hNearTechnique; - if ( g_iQualityTechniqueMode==2 ) hTechniqueUsed = hDistantTechnique; - } - Effect->SetTechnique ( hTechniqueUsed ); - - // Begin effect - UINT Passes; - Effect->Begin(&Passes,NULL); - - // store main camera render target and depth stencil buffer - IGGSurface* pCurrentRenderTarget = NULL; - IGGSurface* pCurrentDepthTarget = NULL; - m_pD3D->GetRenderTarget( 0, &pCurrentRenderTarget ); - m_pD3D->GetDepthStencilSurface( &pCurrentDepthTarget ); - - // Begin loop - for(unsigned int Pass=0;PassGetPass( hTechniqueUsed, Pass ); - GGHANDLE hRT = Effect->GetAnnotationByName( hPass, "RenderColorTarget" ); - const char* szRT = 0; - if ( hRT ) Effect->GetString( hRT, &szRT ); - if ( szRT && strnicmp( szRT, "[depthtexture]", strlen("[depthtexture]") )==NULL && g_pGlob->dwRenderCameraID==0 ) - { - // render to depth texture from main basic3D DLL - int iSuccess = SwitchRenderTargetToDepthTexture(0); - } - else - { - // render to original render target - m_pD3D->SetRenderTarget( 0, pCurrentRenderTarget ); - m_pD3D->SetDepthStencilSurface( pCurrentDepthTarget ); - } - - // Begin pass - Effect->BeginPass(Pass); - - // Render - BT_Intern_RenderTerrainRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels,iQualityPass); - - // End pass - Effect->EndPass(); - } - - // End effect - BT_Main.CurrentEffect=NULL; - Effect->End(); - - // restore render target in any event - m_pD3D->SetRenderTarget( 0, pCurrentRenderTarget ); - m_pD3D->SetDepthStencilSurface( pCurrentDepthTarget ); - } - - // Restore terrain shader technique - Effect->SetTechnique ( hNearTechnique ); - } - else - { - // Render - BT_Main.CurrentEffect=NULL; - BT_Intern_RenderTerrainRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels,0); - BT_Intern_RenderTerrainRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels,1); - } - - //Zero current render terrain - BT_Main.CurrentRenderTerrain=NULL; - - // Restore vertex decl - D3DDevice->SetVertexDeclaration(pDecl); - D3DDevice->SetFVF(dwFVF); - #endif -} -// === END FUNCTION === - -static void BT_Intern_NoRenderTerrain(s_BT_terrain* Terrain) -{ - // Variables - tagCameraData* Camera = BT_Main.CurrentUpdateCamera; - GGMATRIX World; - sMesh* Mesh = Terrain->Object->pFrame->pMesh; - - // create constant buffer for quick world position changes - if ( m_pCBChangePerTerrsainChunk == NULL ) - { - D3D11_BUFFER_DESC bdChangePerTerrsainChunkBuffer; - std::memset ( &bdChangePerTerrsainChunkBuffer, 0, sizeof ( bdChangePerTerrsainChunkBuffer ) ); - bdChangePerTerrsainChunkBuffer.Usage = D3D11_USAGE_DEFAULT; - bdChangePerTerrsainChunkBuffer.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bdChangePerTerrsainChunkBuffer.CPUAccessFlags = 0; - bdChangePerTerrsainChunkBuffer.ByteWidth = sizeof ( CBChangePerTerrsainChunk ); - if ( FAILED ( m_pD3D->CreateBuffer ( &bdChangePerTerrsainChunkBuffer, NULL, &m_pCBChangePerTerrsainChunk ) ) ) - return; - } - if ( m_pCBChangePerTerrsainChunkPS == NULL ) - { - D3D11_BUFFER_DESC bdChangePerTerrsainChunkBuffer; - std::memset ( &bdChangePerTerrsainChunkBuffer, 0, sizeof ( bdChangePerTerrsainChunkBuffer ) ); - bdChangePerTerrsainChunkBuffer.Usage = D3D11_USAGE_DEFAULT; - bdChangePerTerrsainChunkBuffer.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bdChangePerTerrsainChunkBuffer.CPUAccessFlags = 0; - bdChangePerTerrsainChunkBuffer.ByteWidth = sizeof ( CBChangePerTerrsainChunkPS ); - if ( FAILED ( m_pD3D->CreateBuffer ( &bdChangePerTerrsainChunkBuffer, NULL, &m_pCBChangePerTerrsainChunkPS ) ) ) - return; - } - - // Transforms - GGSetTransform(GGTS_PROJECTION,&Camera->matProjection); - GGSetTransform(GGTS_VIEW,&Camera->matView); - - // Viewport - D3D11_VIEWPORT vp; - GGVIEWPORT* pvp = &Camera->viewPort3D; - vp.TopLeftX = pvp->X; - vp.TopLeftY = pvp->Y; - vp.Width = (FLOAT)pvp->Width; - vp.Height = (FLOAT)pvp->Height; - vp.MinDepth = pvp->MinZ; - vp.MaxDepth = pvp->MaxZ; - SetupSetViewport ( g_pGlob->dwRenderCameraID, &vp, NULL ); - - /* - // Set current render terrain - BT_Main.CurrentRenderTerrain=Terrain; - - // Unlock sectors - BT_Intern_UnlockSectorsRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels); - - // Check if theres an effect - if ( Mesh->pVertexShaderEffect != NULL ) - { - // Vertex Declaration - m_pImmediateContext->IASetInputLayout ( Terrain->VertexDeclaration ); - - // Variables - LPGGEFFECT Effect = Mesh->pVertexShaderEffect->m_pEffect; - - // Obtain technique handles - GGTECHNIQUE hNearTechnique = Mesh->pVertexShaderEffect->m_hCurrentTechnique; - GGTECHNIQUE hDistantTechnique = Effect->GetTechniqueByName ( "Distant" ); - - // Two passes, one NORMAL technique and one VERY LOW technique (distant terrain) - BT_Main.CurrentEffect=Mesh->pVertexShaderEffect; - for ( int iQualityPass=0; iQualityPass<2; iQualityPass++ ) - { - //PE: Todo fullshadowsoreditor is always 1 , so hDistantTechnique is never used ? - // Set correct technique - GGTECHNIQUE hTechniqueUsed = NULL; - if ( g_iQualityTechniqueMode==0 ) - { - if ( iQualityPass==0 ) hTechniqueUsed = hNearTechnique; - if ( iQualityPass==1 ) hTechniqueUsed = hDistantTechnique; - } - else - { - if ( g_iQualityTechniqueMode==1 ) hTechniqueUsed = hNearTechnique; - if ( g_iQualityTechniqueMode==2 ) hTechniqueUsed = hDistantTechnique; - } - - // only one pass (removed secondary depth pass for DX11) - if ( hTechniqueUsed->IsValid() ) - { - // Move plenty of effect setup to here (performance) - m_pImmediateContext->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - - // state blocks for raster, blend and depthstencil - m_pImmediateContext->RSSetState(m_pRasterState); - m_pImmediateContext->OMSetBlendState(m_pBlendStateNoAlpha, 0, 0xffffffff); - m_pImmediateContext->OMSetDepthStencilState( m_pDepthStencilState, 0 ); - - // Update shadow textures of terrain shader (added for DX11 - not sure where DX9 did this) - DWORD dwEffectIndex = Mesh->pVertexShaderEffect->m_dwEffectIndex; - if ( dwEffectIndex < EFFECT_INDEX_SIZE ) - { - if ( g_CascadedShadow.m_pEffectParam[dwEffectIndex] ) - { - GGHANDLE hdepthHandle0 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX1; - GGHANDLE hdepthHandle1 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX2; - GGHANDLE hdepthHandle2 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX3; - GGHANDLE hdepthHandle3 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX4; - GGHANDLE hdepthHandle4 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX5; - GGHANDLE hdepthHandle5 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX6; - GGHANDLE hdepthHandle6 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX7; - GGHANDLE hdepthHandle7 = g_CascadedShadow.m_pEffectParam[dwEffectIndex]->DepthMapTX8; - if ( hdepthHandle0 && g_CascadedShadow.m_depthTexture[0] ) hdepthHandle0->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[0]->getTextureResourceView() ); - if ( hdepthHandle1 && g_CascadedShadow.m_depthTexture[1] ) hdepthHandle1->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[1]->getTextureResourceView() ); - if ( hdepthHandle2 && g_CascadedShadow.m_depthTexture[2] ) hdepthHandle2->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[2]->getTextureResourceView() ); - if ( hdepthHandle3 && g_CascadedShadow.m_depthTexture[3] ) hdepthHandle3->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[3]->getTextureResourceView() ); - if ( hdepthHandle4 && g_CascadedShadow.m_depthTexture[4] ) hdepthHandle4->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[4]->getTextureResourceView() ); - if ( hdepthHandle5 && g_CascadedShadow.m_depthTexture[5] ) hdepthHandle5->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[5]->getTextureResourceView() ); - if ( hdepthHandle6 && g_CascadedShadow.m_depthTexture[6] ) hdepthHandle6->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[6]->getTextureResourceView() ); - if ( hdepthHandle7 && g_CascadedShadow.m_depthTexture[7] ) hdepthHandle7->AsShaderResource()->SetResource ( g_CascadedShadow.m_depthTexture[7]->getTextureResourceView() ); - } - } - - // pass clipping data to shader - if ( Mesh->pVertexShaderEffect->m_VecClipPlaneEffectHandle ) - { - GGVECTOR4 vec; - tagCameraData* m_Camera_Ptr = (tagCameraData*)GetCameraInternalData ( g_pGlob->dwRenderCameraID ); - if ( m_Camera_Ptr ) - { - if ( m_Camera_Ptr->iClipPlaneOn==1 ) - { - // special mode which creates plane but does not use RenderState to set clip - // as you cannot mix FF clip and HLSL clip in same scene (artefacts) - vec.x = m_Camera_Ptr->planeClip.a; - vec.y = m_Camera_Ptr->planeClip.b; - vec.z = m_Camera_Ptr->planeClip.c; - vec.w = m_Camera_Ptr->planeClip.d; - } - else - { - // ensure shader stops using clip plane when not being clipped! - vec = GGVECTOR4( 0.0f, 1.0f, 0.0f, 99999.0f ); - } - } - else - { - // ensure shader stops using clip plane when not being clipped! - vec = GGVECTOR4( 0.0f, 1.0f, 0.0f, 99999.0f ); - } - Mesh->pVertexShaderEffect->m_VecClipPlaneEffectHandle->AsVector()->SetFloatVector ( (float*)&vec ); - } - - // Ensure normal invert in effect for terrain (NOTE: not liking duplicated of code) - #ifdef DX11 - //PE: removed , terrain always invert normal. -// GGHANDLE pArtFlags = Mesh->pVertexShaderEffect->m_pEffect->GetVariableByName ( "ArtFlagControl1" ); -// if ( pArtFlags ) -// { -// float fInvertNormal = 0.0f; -// if ( Mesh->dwArtFlags & 0x1 ) fInvertNormal = 1.0f; -// GGVECTOR4 vec4 = GGVECTOR4 ( fInvertNormal, 0.0f, 0.0f, 0.0f ); -// pArtFlags->AsVector()->SetFloatVector ( (float*)&vec4 ); -// } - #endif - - // apply effect ready for rendering - hTechniqueUsed->GetPassByIndex(0)->Apply(0,m_pImmediateContext); - - // Set textures (AFTER Apply which overrides texture view ptrs) - for ( unsigned long i = 0; i < Mesh->dwTextureCount; i++ ) // terrain now has lots of textures - { - if (i != 1 && i != 5 && i != 7) - { - //PE: only for more gpu mem (cache) they are not used. - ID3D11ShaderResourceView* lpTexture = NULL; - if ( Mesh->dwTextureCount > i ) lpTexture = Mesh->pTextures[i].pTexturesRefView; - m_pImmediateContext->PSSetShaderResources ( i, 1, &lpTexture ); - } - } - - // assign constants - GGMATRIX matWorld; - GGGetTransform ( GGTS_WORLD, &matWorld ); - Mesh->pVertexShaderEffect->Start ( Mesh, matWorld ); - - //PE: Terrain should be split into smaller meshes for better light. - update_mesh_light(Mesh, NULL,NULL); - - // Render many terrain chunks (only CB changes for world position for faster rendering) - BT_Intern_RenderTerrainRec(Terrain,Terrain->QuadTree,Terrain->QuadTreeLevels,iQualityPass); - - // End effect - BT_Main.CurrentEffect=NULL; - - // Free textures (especially camera image texture which needs to be output bound next cycle) - for ( unsigned long i = 0; i < Mesh->dwTextureCount; i++ ) - { - if (i != 1 && i != 5 && i != 7) - { - //PE: - ID3D11ShaderResourceView* lpTexture = NULL; - m_pImmediateContext->PSSetShaderResources ( i, 1, &lpTexture ); - } - } - } - } - } - else - { - // no rendering if no effect shader - } - */ - - // zero current render terrain - BT_Main.CurrentRenderTerrain=NULL; -} - - -// ====================================== -// === BT INTERN CALCULATE LOD LEVELS === -// ====================================== -static void BT_Intern_CalculateLODLevelsRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level,unsigned char LODLevelToDraw) -{ -//Initialise Drawthis variable - Quadtree->DrawThis=false; - -//Check if we have to draw this LOD level - if(Quadtree->Sector!=NULL && LODLevelToDraw==0) - { - if(BT_Intern_DistanceToLODCamera(Terrain,Quadtree->CullBox)>Terrain->LODLevel[Level].Distance*Terrain->LODLevel[Level].Distance) - { - Quadtree->DrawThis=true; - LODLevelToDraw=unsigned char(Level); - } - } - -//Check if LOD level is greater than 0 - if(Level>0) - { - //Part 1 - if(Quadtree->n1->Culled==false) - BT_Intern_CalculateLODLevelsRec(Terrain,Quadtree->n1,Level-1,LODLevelToDraw); - - //Part 2 - if(Quadtree->n2->Culled==false) - BT_Intern_CalculateLODLevelsRec(Terrain,Quadtree->n2,Level-1,LODLevelToDraw); - - //Part 3 - if(Quadtree->n3->Culled==false) - BT_Intern_CalculateLODLevelsRec(Terrain,Quadtree->n3,Level-1,LODLevelToDraw); - - //Part 4 - if(Quadtree->n4->Culled==false) - BT_Intern_CalculateLODLevelsRec(Terrain,Quadtree->n4,Level-1,LODLevelToDraw); - }else{ - if(Terrain->LODMap[Quadtree->row][Quadtree->collumn].Level!=LODLevelToDraw) - { - Terrain->LODMap[Quadtree->row][Quadtree->collumn].Level=LODLevelToDraw; - } - - } -} -// === END FUNCTION === - - - -// =============================== -// === BT INTERN FIX LOD SEAMS === -// =============================== -static void BT_Intern_FixLODSeams(s_BT_terrain* Terrain) -{ -//Find seams to be fixed - for(unsigned char LODLevel=0;LODLevelLODLevels;LODLevel++) - { - unsigned long Span=0x1<LODLevel[LODLevel].Sectors;Sector++) - { - s_BT_Sector* SectorPtr=&Terrain->LODLevel[LODLevel].Sector[Sector]; - if(SectorPtr->QuadTree!=NULL) - { - if(SectorPtr->QuadTree->Culled==false && SectorPtr->QuadTree->DrawThis==true) - { - //Find row and collumn - s_BT_QuadTree* CurrentQuadTree=SectorPtr->QuadTree; - unsigned long Row=SectorPtr->Row*Span; - unsigned long Collumn=SectorPtr->Column*Span; - - //Left - if(Collumn>0) - { - int LeftSideLODLevel = Terrain->LODMap[Row][Collumn-1].Level - LODLevel; - if (LeftSideLODLevel < 0) - LeftSideLODLevel = 0; - if(SectorPtr->LeftSideLODLevel!=LeftSideLODLevel) - { - SectorPtr->LeftSideLODLevel=LeftSideLODLevel; - SectorPtr->LeftSideNeedsUpdate=true; - } - } - - //Top - if(Row>0) - { - int TopSideLODLevel = Terrain->LODMap[Row-1][Collumn].Level - LODLevel; - if (TopSideLODLevel < 0) - TopSideLODLevel = 0; - if(SectorPtr->TopSideLODLevel!=TopSideLODLevel) - { - SectorPtr->TopSideLODLevel=TopSideLODLevel; - SectorPtr->TopSideNeedsUpdate=true; - } - } - - //Right - if(Collumn+SpanLODLevel[0].Split) - { - int RightSideLODLevel = Terrain->LODMap[Row][Collumn+Span].Level - LODLevel; - if (RightSideLODLevel < 0) - RightSideLODLevel = 0; - if(SectorPtr->RightSideLODLevel!=RightSideLODLevel) - { - SectorPtr->RightSideLODLevel=RightSideLODLevel; - SectorPtr->RightSideNeedsUpdate=true; - } - } - - //Bottom - if(Row+SpanLODLevel[0].Split) - { - int BottomSideLODLevel = Terrain->LODMap[Row+Span][Collumn].Level - LODLevel; - if (BottomSideLODLevel < 0) - BottomSideLODLevel = 0; - if(SectorPtr->BottomSideLODLevel!=BottomSideLODLevel) - { - SectorPtr->BottomSideLODLevel=BottomSideLODLevel; - SectorPtr->BottomSideNeedsUpdate=true; - } - } - } - } - } - } -} -// === END FUNCTION === - - - -// ====================================== -// === BT INTERN FIX SECTOR LOD SEAMS === -// ====================================== -static void BT_Intern_FixSectorLODSeams(s_BT_Sector* SectorPtr) -{ -//Fix the seams - if(SectorPtr->QuadTree!=NULL && SectorPtr->Excluded==false) - { - if(SectorPtr->QuadTree->Culled==false && SectorPtr->QuadTree->DrawThis==true) - { - //Make sure that the sector is unlocked - BT_Intern_UnlockSectorVertexData(SectorPtr); - - //Update sides - // Top - if(SectorPtr->TopSideNeedsUpdate) { - SectorPtr->QuadMap->SetSideLOD(0, SectorPtr->TopSideLODLevel); - SectorPtr->TopSideNeedsUpdate=false; - SectorPtr->UpdateMesh=true; - } - - // Right - if(SectorPtr->RightSideNeedsUpdate) { - SectorPtr->QuadMap->SetSideLOD(1, SectorPtr->RightSideLODLevel); - SectorPtr->RightSideNeedsUpdate=false; - SectorPtr->UpdateMesh=true; - } - - // Bottom - if(SectorPtr->BottomSideNeedsUpdate) { - SectorPtr->QuadMap->SetSideLOD(2, SectorPtr->BottomSideLODLevel); - SectorPtr->BottomSideNeedsUpdate=false; - SectorPtr->UpdateMesh=true; - } - - // Left - if(SectorPtr->LeftSideNeedsUpdate) { - SectorPtr->QuadMap->SetSideLOD(3, SectorPtr->LeftSideLODLevel); - SectorPtr->LeftSideNeedsUpdate=false; - SectorPtr->UpdateMesh=true; - } - } - } -} -// === END FUNCTION === - - - -// ======================================= -// === BT INTERN CALCULATE CULLING REC === -// ======================================= -static void BT_Intern_CalculateCullingRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level,bool IntersectingFrustum){ - - //Initialise Culled variable - if (g_bRenderTerrainForShadowMap == true) - { - // no culling when rendering terrain shadow - Quadtree->Culled = false; - } - else - { - Quadtree->Culled = true; - if (IntersectingFrustum == true) - { - char Culled = BT_Intern_CullBox(Quadtree->CullBox); - if (Culled > 0) - { - Quadtree->Culled = false; - if (Culled == 2) - IntersectingFrustum = false; - } - } - else { - Quadtree->Culled = false; - } - } - -//Check if LOD level is greater than 0 and the sector isnt culled - if(Level>0 && Quadtree->Culled==false) - { - //Part 1 - BT_Intern_CalculateCullingRec(Terrain,Quadtree->n1,Level-1,IntersectingFrustum); //-x,-z - - //Part 2 - BT_Intern_CalculateCullingRec(Terrain,Quadtree->n2,Level-1,IntersectingFrustum); //+x,-z - - //Part 3 - BT_Intern_CalculateCullingRec(Terrain,Quadtree->n3,Level-1,IntersectingFrustum); //-x,+z - - //Part 4 - BT_Intern_CalculateCullingRec(Terrain,Quadtree->n4,Level-1,IntersectingFrustum); //+x,+z - } -} -// === END FUNCTION === - - - -// ======================================= -// === BT INTERN UPDATE CULLBOXES REC === -// ======================================= -static void BT_Intern_UpdateCullBoxesRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level){ -//Check if the cullbox needs updating - if(Quadtree->CullboxChanged && Quadtree->Excluded==false) - { - //Check if LOD level is greater than 0 - if(Level>0) - { - //Part 1 - if(Quadtree->n1->CullboxChanged) - BT_Intern_UpdateCullBoxesRec(Terrain,Quadtree->n1,Level-1); //-x,-z - - //Part 2 - if(Quadtree->n2->CullboxChanged) - BT_Intern_UpdateCullBoxesRec(Terrain,Quadtree->n2,Level-1); //+x,-z - - //Part 3 - if(Quadtree->n3->CullboxChanged) - BT_Intern_UpdateCullBoxesRec(Terrain,Quadtree->n3,Level-1); //-x,+z - - //Part 4 - if(Quadtree->n4->CullboxChanged) - BT_Intern_UpdateCullBoxesRec(Terrain,Quadtree->n4,Level-1); //+x,+z - } - - //Update cullboxes - if(Quadtree->Sector!=NULL) - { - Quadtree->CullBox->Top=Quadtree->Sector->Pos_y+Quadtree->Sector->QuadMap->GetHighestPoint(); - Quadtree->CullBox->Bottom=Quadtree->Sector->Pos_y+Quadtree->Sector->QuadMap->GetLowestPoint(); - }else{ - Quadtree->CullBox->Top=max(max(Quadtree->n1->CullBox->Top,Quadtree->n2->CullBox->Top),max(Quadtree->n3->CullBox->Top,Quadtree->n4->CullBox->Top)); - Quadtree->CullBox->Bottom=min(min(Quadtree->n1->CullBox->Bottom,Quadtree->n2->CullBox->Bottom),min(Quadtree->n3->CullBox->Bottom,Quadtree->n4->CullBox->Bottom)); - } - Quadtree->CullboxChanged=false; - } -} -// === END FUNCTION === - - - -// ==================================== -// === BT INTERN RENDER TERRAIN REC === -// ==================================== -static void BT_Intern_RenderTerrainRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level,int iQualityPass) -{ - // Check if were not at the bottom - if(Level>0) - { - // If we have to draw this LOD level, draw it. If not, continue down the tree - if(Quadtree->DrawThis && Quadtree->Sector!=NULL) // Check if current LOD level is active and sector is near the camera - { - // Only render if iQualityPass is DISTANT - if ( iQualityPass==1 ) - { - // Only render if it is below our required TERRAIN SIZE slider setting - if ( Level < (unsigned long)g_LevelToRender ) BT_Intern_RenderSector(Quadtree->Sector); - } - - }else{ - - if(BT_Main.LODCamPosition.z/Terrain->Scale*C_BT_INTERNALSCALEPosZ) - { - if(BT_Main.LODCamPosition.x/Terrain->Scale*C_BT_INTERNALSCALEPosX) - { - //Part 1 - if(Quadtree->n1->Excluded==false && Quadtree->n1->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n1,Level-1,iQualityPass); //-x,-z - - //Part 2 - if(Quadtree->n2->Excluded==false && Quadtree->n2->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n2,Level-1,iQualityPass); //+x,-z - - //Part 3 - if(Quadtree->n3->Excluded==false && Quadtree->n3->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n3,Level-1,iQualityPass); //-x,+z - - //Part 4 - if(Quadtree->n4->Excluded==false && Quadtree->n4->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n4,Level-1,iQualityPass); //+x,+z - }else{ - //Part 2 - if(Quadtree->n2->Excluded==false && Quadtree->n2->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n2,Level-1,iQualityPass); //+x,-z - - //Part 1 - if(Quadtree->n1->Excluded==false && Quadtree->n1->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n1,Level-1,iQualityPass); //-x,-z - - //Part 4 - if(Quadtree->n4->Excluded==false && Quadtree->n4->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n4,Level-1,iQualityPass); //+x,+z - - //Part 3 - if(Quadtree->n3->Excluded==false && Quadtree->n3->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n3,Level-1,iQualityPass); //-x,+z - } - - }else{ - if(BT_Main.LODCamPosition.x/Terrain->Scale*C_BT_INTERNALSCALEPosX) - { - //Part 3 - if(Quadtree->n3->Excluded==false && Quadtree->n3->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n3,Level-1,iQualityPass); //-x,+z - - //Part 4 - if(Quadtree->n4->Excluded==false && Quadtree->n4->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n4,Level-1,iQualityPass); //+x,+z - - //Part 1 - if(Quadtree->n1->Excluded==false && Quadtree->n1->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n1,Level-1,iQualityPass); //-x,-z - - //Part 2 - if(Quadtree->n2->Excluded==false && Quadtree->n2->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n2,Level-1,iQualityPass); //+x,-z - }else{ - //Part 4 - if(Quadtree->n4->Excluded==false && Quadtree->n4->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n4,Level-1,iQualityPass); //+x,+z - - //Part 3 - if(Quadtree->n3->Excluded==false && Quadtree->n3->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n3,Level-1,iQualityPass); //-x,+z - - //Part 2 - if(Quadtree->n2->Excluded==false && Quadtree->n2->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n2,Level-1,iQualityPass); //+x,-z - - //Part 1 - if(Quadtree->n1->Excluded==false && Quadtree->n1->Culled==false) - BT_Intern_RenderTerrainRec(Terrain,Quadtree->n1,Level-1,iQualityPass); //-x,-z - } - } - } - } - else - { - if(Quadtree->Sector!=NULL) - { - // Only render if iQualityPass is NEAR - if ( iQualityPass==0 ) - { - BT_Intern_RenderSector(Quadtree->Sector); - } - } - } -} -// === END FUNCTION === - - - -// ==================================== -// === BT INTERN UNLOCK SECTORS REC === -// ==================================== -static void BT_Intern_UnlockSectorsRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level) -{ -//Check if were not at the bottom - if(Level>0){ - //If we have to draw this LOD level, draw it. If not, continue down the tree - if(Quadtree->DrawThis && Quadtree->Sector!=NULL)//Check if current LOD level is active and sector is near the camera - { - BT_Intern_UnlockSectorVertexData(Quadtree->Sector); - }else{ - //Part 1 - if(Quadtree->n1->Excluded==false && Quadtree->n1->Culled==false) - BT_Intern_UnlockSectorsRec(Terrain,Quadtree->n1,Level-1); //-x,-z - - //Part 2 - if(Quadtree->n2->Excluded==false && Quadtree->n2->Culled==false) - BT_Intern_UnlockSectorsRec(Terrain,Quadtree->n2,Level-1); //+x,-z - - //Part 3 - if(Quadtree->n3->Excluded==false && Quadtree->n3->Culled==false) - BT_Intern_UnlockSectorsRec(Terrain,Quadtree->n3,Level-1); //-x,+z - - //Part 4 - if(Quadtree->n4->Excluded==false && Quadtree->n4->Culled==false) - BT_Intern_UnlockSectorsRec(Terrain,Quadtree->n4,Level-1); //+x,+z - } - }else{ - if(Quadtree->Sector!=NULL){ - BT_Intern_UnlockSectorVertexData(Quadtree->Sector); - } - } -} - -// === END FUNCTION === - - - -// =============================== -// === BT INTERN RENDER SECTOR === -// =============================== -static void BT_Intern_RenderSector(s_BT_Sector* Sector) -{ - //Render sector - if(Sector->Excluded==false) - { - // if sector DBP object has been made universe invisible, it means the engine has occluded it - //if ( Sector->DBPObject==NULL || (Sector->DBPObject && Sector->DBPObject->bUniverseVisible==true ) ) / 070314 not always work :( - if ( 1 ) - { - //Fix LOD seams - BT_Intern_FixSectorLODSeams(Sector); - - //Check if the sector needs to update its drawbuffer - //Sector->QuadMap->GenerateMeshData(); - if(Sector->UpdateMesh==true) - { - // if often can be locking the index and vertex buffers each time which would be slow - Sector->QuadMap->UpdateMesh(Sector->DrawBuffer,true); - Sector->UpdateMesh=false; - } - - #ifdef DX11 - - // calculate world/v/p position of terrain chunk - - GGMATRIX World = Sector->WorldMatrix*BT_Main.CurrentRenderTerrain->Object->position.matScale*BT_Main.CurrentRenderTerrain->Object->position.matTranslation; - if ( m_pCBChangePerTerrsainChunk ) - { - // as terrain would self-shadow - if (g_bRenderTerrainForShadowMap == true) - { - // sink it a little so not interfere with itself - World._42 -= 10.0f; - } - - CBChangePerTerrsainChunk cb; - cb.mWorld = World; - GGMatrixTranspose(&cb.mWorld,&cb.mWorld); - GGGetTransform(GGTS_VIEW,&cb.mView); - GGGetTransform(GGTS_PROJECTION,&cb.mProjection); - GGMatrixTranspose(&cb.mView,&cb.mView); - GGMatrixTranspose(&cb.mProjection,&cb.mProjection); - m_pImmediateContext->UpdateSubresource( m_pCBChangePerTerrsainChunk, 0, NULL, &cb, 0, 0 ); - m_pImmediateContext->VSSetConstantBuffers ( 0, 1, &m_pCBChangePerTerrsainChunk ); - m_pImmediateContext->PSSetConstantBuffers ( 0, 1, &m_pCBChangePerTerrsainChunk ); - } - if ( 1==1 ) - { - CBChangePerTerrsainChunkPS cbps; - //cbps.vMaterialEmissive = GGCOLOR(pMesh->mMaterial.Emissive.r,pMesh->mMaterial.Emissive.g,pMesh->mMaterial.Emissive.b,pMesh->mMaterial.Emissive.a); - //if ( pMesh->bAlphaOverride == true ) - // cbps.fAlphaOverride = (pMesh->dwAlphaOverride>>24)/255.0f; - //else - // cbps.fAlphaOverride = 1.0f; - cbps.vMaterialEmissive = GGCOLOR(0,0,0,0); - cbps.fAlphaOverride = 1.0f; - - // feed camera zero matrices into pixel shader constant buffer - tagCameraData* m_Camera_Ptr = (tagCameraData*)GetCameraInternalData ( 0 ); - float fDet = 0.0f; - GGMatrixInverse ( &cbps.mViewInv, &fDet, &m_Camera_Ptr->matView ); - GGMatrixTranspose(&cbps.mViewInv,&cbps.mViewInv); - //cbps.mViewProj = g_matThisViewProj; - //GGMatrixTranspose(&cbps.mViewProj,&cbps.mViewProj); - //cbps.mPrevViewProj = g_matPreviousViewProj; - //GGMatrixTranspose(&cbps.mPrevViewProj,&cbps.mPrevViewProj); - m_pImmediateContext->UpdateSubresource( m_pCBChangePerTerrsainChunkPS, 0, NULL, &cbps, 0, 0 ); - m_pImmediateContext->PSSetConstantBuffers ( 1, 1, &m_pCBChangePerTerrsainChunkPS ); - } - - // Index buffers - //This line is ruin cascade 0 ? - m_pImmediateContext->IASetIndexBuffer(Sector->DrawBuffer->IndexBuffer, DXGI_FORMAT_R16_UINT, 0); - - // Vertex buffers - unsigned int stride; - unsigned int offset; - stride = Sector->DrawBuffer->FVF_Size; - offset = 0; - m_pImmediateContext->IASetVertexBuffers ( 0, 1, &Sector->DrawBuffer->VertexBuffer, &stride, &offset); - - //Draw - m_pImmediateContext->DrawIndexed(Sector->DrawBuffer->Indices, 0, 0); - - #else - //World matrix - IGGDevice* D3DDevice=m_pD3D; - GGMATRIX World; - World=Sector->WorldMatrix*BT_Main.CurrentRenderTerrain->Object->position.matScale*BT_Main.CurrentRenderTerrain->Object->position.matTranslation; - D3DDevice->SetTransform(GGTS_WORLD,&World); - - //DBPRO RENDERING ENGINE - //Dave - applying effect could be slow - sMesh* Mesh=Sector->Terrain->Object->pFrame->pMesh; - if(Mesh->pVertexShaderEffect!=NULL) - DBPRO_ApplyEffect(Mesh,BT_Main.CurrentUpdateCamera); - - //Index and vertex buffers - D3DDevice->SetStreamSource(0,Sector->DrawBuffer->VertexBuffer,0,Sector->DrawBuffer->FVF_Size); - D3DDevice->SetIndices(Sector->DrawBuffer->IndexBuffer); - - //Draw - D3DDevice->DrawIndexedPrimitive(GGPT_TRIANGLELIST,0,0,Sector->DrawBuffer->Vertices,0,Sector->DrawBuffer->Primitives); - - //Draw edge - D3DDevice->SetIndices(Sector->DrawBuffer->EdgeLineIndexBuffer); - D3DDevice->DrawIndexedPrimitive(D3DPT_LINELIST,0,0,Sector->LODLevel->SectorDetail*2,0,Sector->DrawBuffer->EdgeIndexCount/2); - #endif - - //Stats - BT_Main.DrawCalls++; - BT_Main.DrawPrimitiveCount+=Sector->DrawBuffer->Primitives; - g_pGlob->dwNumberOfPrimCalls++; - g_pGlob->dwNumberOfPolygonsDrawn+=Sector->DrawBuffer->Primitives; - } - } -} -// === END FUNCTION === - - -//LEFT = x-size -//RIGHT = x+size -//TOP = y+size -//BOTTOM = y-size -//FRONT = z-size -//BACK = z+size - -// ======================================== -// === BT INTERN DISTANCE TO LOD CAMERA === -// ======================================== -static float BT_Intern_DistanceToLODCamera(s_BT_terrain* Terrain,s_BT_CullBox* CullBox) -{ -//Variables - float CamX=(BT_Main.LODCamPosition.x-Terrain->Object->position.vecPosition.x)/Terrain->Scale*C_BT_INTERNALSCALE; - float CamY=(BT_Main.LODCamPosition.y-Terrain->Object->position.vecPosition.y)/Terrain->Scale*C_BT_INTERNALSCALE; - float CamZ=(BT_Main.LODCamPosition.z-Terrain->Object->position.vecPosition.z)/Terrain->Scale*C_BT_INTERNALSCALE; - -//Calculate distances - float XDistA=-CamX+CullBox->Left; - float XDistB=CamX-CullBox->Right; - float YDistA=-CamY+CullBox->Bottom; - float YDistB=CamY-CullBox->Top; - float ZDistA=-CamZ+CullBox->Front; - float ZDistB=CamZ-CullBox->Back; - -//Calculate X Distance - float XDist; - if(XDistA>0.0f){ - XDist=-XDistA; - }else if(XDistB>0.0f){ - XDist=XDistB; - }else{ - XDist=0.0f; - } - -//Calculate Y Distance - float YDist; - if(YDistA>0.0f){ - YDist=-YDistA; - }else if(YDistB>0.0f){ - YDist=YDistB; - }else{ - YDist=0.0f; - } - -//Calculate Z Distance - float ZDist; - if(ZDistA>0.0f){ - ZDist=-ZDistA; - }else if(ZDistB>0.0f){ - ZDist=ZDistB; - }else{ - ZDist=0.0f; - } - -//Return distance - return XDist*XDist+YDist*YDist+ZDist*ZDist; -} -// === END FUNCTION === - - - -// ================================ -// === BT INTERN CONTINUE BUILD === -// ================================ -static void BT_Intern_ContinueBuild() -{ -//Variables - s_BT_Sector* Sector; - -//Get sector - Sector=&BT_Main.CurrentBuildTerrain->LODLevel[BT_Main.CurrentBuildLODLevel].Sector[BT_Main.CurrentBuildSector]; - -//Check that the sector is not excluded - if(Sector->Excluded==false) - { - //Build - if(BT_Main.BuildType==true) - { // Rebuild - BT_Intern_BuildSector(Sector); - }else{ //Firstbuild - BT_Intern_BuildSector(Sector); - } - } - -//Set Current values - BT_Main.CurrentBuildRow=Sector->Row; - BT_Main.CurrentBuildColumn=Sector->Column; - -//Increase sector number - BT_Main.CurrentBuildSector++; - BT_Main.CurrentBuildTerrainSector++; - -//Check if this LOD Level is finnished - if(BT_Main.CurrentBuildSector==BT_Main.CurrentBuildTerrain->LODLevel[BT_Main.CurrentBuildLODLevel].Sectors) - { - BT_Main.CurrentBuildSector=0; - BT_Main.CurrentBuildLODLevel++; - } - - return; -} -// === END FUNCTION === - - - -// =============================== -// === BT INTERN TERRAIN EXIST === -// =============================== -bool BT_Intern_TerrainExist(unsigned long terrainid) -{ -//Check the range of the value - if(terrainid>0 && terrainid<=C_BT_MAXTERRAINS) - { - //Return the exist varaible - return BT_Main.Terrains[terrainid].Exists; - } - return 0; -} -// === END FUNCTION === - - - -// ============================= -// === BT INTERN IMAGE EXIST === -// ============================= -static long BT_Intern_ImageExist(unsigned long imageid) -{ -//Check the range of the value - if(imageid>0) - { - //Check if it exists and return the answer - return GetImageExistEx(imageid); - } - return 0; -} -// === END FUNCTION === - - - -// ======================= -// === BT INTERN ERROR === -// ======================= -void BT_Intern_Error(int number) -{ -//Variables - char Message[100]; - Message[0]=NULL; - -//Create message string - strcat(Message,"BT Error: "); - strcat(Message,BT_Intern_GetErrorString(number)); - strcat(Message,"\nFunction: "); - strcat(Message,BT_Intern_GetFunctionName(BT_Main.CurrentFunction)); - -//Display string and terminate app - // now use DBP error system - RunTimeError ( 0, Message ); - -} -// === END FUNCTION === - - - -// ================================== -// === BT INTERN GET ERROR STRING === -// ================================== -static char* BT_Intern_GetErrorString(int number) -{ -//Set default error message - char* Error="Unknown"; - -//Get error - if(number==C_BT_ERROR_MAXTERRAINSEXCEDED){ - Error="Max terrains Exceded"; - }else if(number==C_BT_ERROR_TERRAINDOESNTEXIST){ - Error="Terrain doesnt exist"; - }else if(number==C_BT_ERROR_INVALIDLODLEVELS){ - Error="Invalid LOD levels"; - }else if(number==C_BT_ERROR_HEIGHTMAPDOESNTEXIST){ - Error="Heightmap doesnt exist"; - }else if(number==C_BT_ERROR_LODLEVELDOESNTEXIST){ - Error="LOD level doesnt exist"; - }else if(number==C_BT_ERROR_HEIGHTMAPSIZEINVALID){ - Error="Heightmap size invalid"; - }else if(number==C_BT_ERROR_EXCLUSIONMAPSIZEINVALID){ - Error="Exclusion map size invalid"; - }else if(number==C_BT_ERROR_ALREADYBUILDING){ - Error="Already building"; - }else if(number==C_BT_ERROR_OBJECTIDILLEGAL){ - Error="Object ID illegal"; - }else if(number==C_BT_ERROR_TERRAINNOTGENERATED){ - Error="Terrain not generated"; - }else if(number==C_BT_ERROR_CANNOTCREATEVB){ - Error="Cannot create Vertex Buffer"; - }else if(number==C_BT_ERROR_CANNOTCREATEIB){ - Error="Cannot Create Index Buffer"; - }else if(number==C_BT_ERROR_SECTORDOESNTEXIST){ - Error="Sector doesnt exist"; - }else if(number==C_BT_ERROR_TERRAINNOTBUILT){ - Error="Terrain not built"; - }else if(number==C_BT_ERROR_INVALIDFILE){ - Error="Invalid file"; - }else if(number==C_BT_ERROR_VERSIONCANNOTREADFILE){ - Error="Cannot read file"; - }else if(number==C_BT_ERROR_TERRAINALREADYBUILT){ - Error="Terrain already built"; - }else if(number==C_BT_ERROR_CANNOTUSEFUNCTIONONBUILTTERRAIN){ - Error="Cannot use function with a built terrain"; - }else if(number==C_BT_ERROR_SECTORALREADYLOCKED){ - Error="Sector already locked"; - }else if(number==C_BT_ERROR_SECTORNOTUNLOCKED){ - Error="Sector not unlocked"; - }else if(number==C_BT_ERROR_USESFULLVERSION){ - Error="Terrain uses full version features. Cannot load."; - }else if(number==C_BT_ERROR_SECTORTOOBIG){ - Error="Sectors too big. Increase split."; - }else if(number==C_BT_ERROR_SPLITTOOHIGH){ - Error="Split too big. (Max: 32)"; - }else if(number==C_BT_ERROR_SECTORALREADYHASOBJECT){ - Error="This sector already has an object"; - }else if(number==C_BT_ERROR_LODLEVELALREADYHASOBJECT){ - Error="This LOD level already has an object"; - }else if(number==C_BT_ERROR_SECTORISEXCLUDED){ - Error="Sector is excluded"; - }else if(number==C_BT_ERROR_MEMORYERROR){ - Error="Memory error"; - } - -//Return the error message - return Error; -} -// === END FUNCTION === - - - -// =================================== -// === BT INTERN GET FUNCTION NAME === -// =================================== -static char* BT_Intern_GetFunctionName(int number) -{ -//Set default name - char* Name="Unknown"; - -//Get name - if(number==C_BT_FUNCTION_MAKETERRAIN){ - Name="BT MakeTerrain"; - }else if(number==C_BT_FUNCTION_SETTERRAINHEIGHTMAP){ - Name="BT SetTerrainHeightmap"; - }else if(number==C_BT_FUNCTION_SETTERRAINTEXTURE){ - Name="BT SetTerrainTexture"; - }else if(number==C_BT_FUNCTION_SETTERRAINEXCLUSION){ - Name="BT SetTerrainExclusion"; - }else if(number==C_BT_FUNCTION_SETTERRAINDETAIL){ - Name="BT SetTerrainDetail"; - }else if(number==C_BT_FUNCTION_SETTERRAINENVIRONMENT){ - Name="BT SetTerrainEnvironment"; - }else if(number==C_BT_FUNCTION_SETTERRAINLOD){ - Name="BT SetTerrainLOD"; - }else if(number==C_BT_FUNCTION_SETTERRAINSPLIT){ - Name="BT SetTerrainSplit"; - }else if(number==C_BT_FUNCTION_SETTERRAINDETAILTILE){ - Name="BT SetTerrainDetailTile"; - }else if(number==C_BT_FUNCTION_SETTERRAINQUADREDUCTION){ - Name="BT SetTerrainQuadReduction"; - }else if(number==C_BT_FUNCTION_SETTERRAINQUADROTATION){ - Name="BT SetTerrainQuadRotation"; - }else if(number==C_BT_FUNCTION_SETTERRAINSMOOTHING){ - Name="BT SetTerrainSmoothing"; - }else if(number==C_BT_FUNCTION_SETTERRAINSCALE){ - Name="BT SetTerrainScale"; - }else if(number==C_BT_FUNCTION_SETTERRAINYSCALE){ - Name="BT SetTerrainYScale"; - }else if(number==C_BT_FUNCTION_SETTERRAINLODDISTANCES){ - Name="BT SetTerrainLODDistances"; - }else if(number==C_BT_FUNCTION_BUILDTERRAIN){ - Name="BT BuildTerrain"; - }else if(number==C_BT_FUNCTION_CONTINUEBUILD){ - Name="BT ContinueBuild"; - }else if(C_BT_FUNCTION_TERRAINEXIST){ - Name="BT TerrainExist"; - }else if(number==C_BT_FUNCTION_DELETETERRAIN){ - Name="BT DeleteTerrain"; - }else if(number==C_BT_FUNCTION_GETGROUNDHEIGHT){ - Name="BT GetGroundHeight"; - }else if(number==C_BT_FUNCTION_GETTERRAINSIZE){ - Name="BT GetTerrainSize"; - }else if(number==C_BT_FUNCTION_GETVERSION){ - Name="BT GetVersion"; - }else if(number==C_BT_FUNCTION_SETBUILDSTEP){ - Name="BT SetBuildStep"; - }else if(number==C_BT_FUNCTION_UPDATETERRAIN){ - Name="BT UpdateTerrain"; - }else if(number==C_BT_FUNCTION_UPDATE){ - Name="BT Update"; - }else if(number==C_BT_FUNCTION_RENDER){ - Name="BT Render"; - }else if(number==C_BT_FUNCTION_ENABLEAUTORECOVERY){ - Name="BT EnableAutoRecovery"; - }else if(number==C_BT_FUNCTION_GETSTATISTIC){ - Name="BT GetStatistic"; - }else if(number==C_BT_FUNCTION_CLEARSTATISTICS){ - Name="BT ClearStatistics"; - }else if(number==C_BT_FUNCTION_GETOBJECTID){ - Name="BT GetObjectID"; - }else if(number==C_BT_FUNCTION_MAKESECTOROBJECT){ - Name="BT MakeSectorObject"; - }else if(number==C_BT_FUNCTION_GETSECTORPOSITIONX){ - Name="BT GetSectorPositionX"; - }else if(number==C_BT_FUNCTION_GETSECTORPOSITIONY){ - Name="BT GetSectorPositionY"; - }else if(number==C_BT_FUNCTION_GETSECTORPOSITIONZ){ - Name="BT GetSectorPositionZ"; - }else if(number==C_BT_FUNCTION_GETSECTORCOUNT){ - Name="BT GetSectorCount"; - }else if(number==C_BT_FUNCTION_GETSECTORSIZE){ - Name="BT GetSectorSize"; - }else if(number==C_BT_FUNCTION_GETSECTOREXCLUDED){ - Name="BT GetSectorExcluded"; - }else if(number==C_BT_FUNCTION_GETSECTORROW){ - Name="BT GetSectorRow"; - }else if(number==C_BT_FUNCTION_GETSECTORCOLLUMN){ - Name="BT GetSectorCollumn"; - }else if(number==C_BT_FUNCTION_SETCURRENTCAMERA){ - Name="BT SetCurrentCamera"; - }else if(number==C_BT_FUNCTION_UPDATETERRAINLOD){ - Name="BT UpdateTerrainLOD"; - }else if(number==C_BT_FUNCTION_UPDATETERRAINCULL){ - Name="BT UpdateTerrainCull"; - }else if(number==C_BT_FUNCTION_SETPOINTHEIGHT){ - Name="BT SetPointHeight"; - }else if(number==C_BT_FUNCTION_SETTERRAINEXCLUSIONTHRESHOLD){ - Name="BT SetTerrainExclusionThreshold"; - }else if(number==C_BT_FUNCTION_LOADTERRAIN){ - Name="BT LoadTerrain"; - }else if(number==C_BT_FUNCTION_SAVETERRAIN){ - Name="BT SaveTerrain"; - }else if(number==C_BT_FUNCTION_GETPOINTEXCLUDED){ - Name="BT GetPointExcluded"; - }else if(number==C_BT_FUNCTION_SETATMODE){ - Name="BT SetATMode"; - }else if(number==C_BT_FUNCTION_SETTERRAINDETAILBLENDMODE){ - Name="BT SetTerrainDetailBlendMode"; - }else if(number==C_BT_FUNCTION_INIT){ - Name="BT Init"; - }else if(number==C_BT_FUNCTION_ADDTERRAINENVIRONMENT){ - Name="BT AddTerrainEnvironment"; - }else if(number==C_BT_FUNCTION_GETPOINTENVIRONMENT){ - Name="BT GetPointEnvironment"; - }else if(number==C_BT_FUNCTION_GETTERRAININFO){ - Name="BT GetTerrainInfo"; - }else if(number==C_BT_FUNCTION_GETLODLEVELINFO){ - Name="BT GetLODLevelInfo"; - }else if(number==C_BT_FUNCTION_GETSECTORINFO){ - Name="BT GetSectorInfo"; - }else if(number==C_BT_FUNCTION_MAKETERRAINOBJECT){ - Name="BT MakeTerrainObject"; - }else if(number==C_BT_FUNCTION_ENABLEAUTORENDER){ - Name="BT EnableAutoRender"; - } - -//Return the name - return Name; -} -// === END FUNCTION === - - - -// ==================================== -// === BT INTERN GET SECTOR HEIGHTS === -// ==================================== -static void BT_Intern_GetSectorHeights(s_BT_terrain* Terrain,unsigned long LODLevel,unsigned long row,unsigned long column,float* buffer) -{ -//Variables - unsigned long StartX; - unsigned long StartY; - unsigned long X; - unsigned long Y; - unsigned long Xb; - unsigned long Yb; - unsigned long BufferPos; - unsigned long HeightPos; - -//Set start positions - StartX=column*Terrain->LODLevel[LODLevel].SectorDetail*Terrain->LODLevel[LODLevel].TileSpan; - StartY=row*Terrain->LODLevel[LODLevel].SectorDetail*Terrain->LODLevel[LODLevel].TileSpan; - -//Loop through points - for(Y=0;Y<=Terrain->LODLevel[LODLevel].SectorDetail;Y++) - { - for(X=0;X<=Terrain->LODLevel[LODLevel].SectorDetail;X++) - { - BufferPos=(X+Y*(Terrain->LODLevel[LODLevel].SectorDetail+1)); - - if(X*Terrain->LODLevel[LODLevel].TileSpan+StartX>unsigned(Terrain->Heightmapsize-1) ) - { - Xb=X*Terrain->LODLevel[LODLevel].TileSpan-1; - }else{ - Xb=X*Terrain->LODLevel[LODLevel].TileSpan; - } - - if(Y*Terrain->LODLevel[LODLevel].TileSpan+StartY>unsigned(Terrain->Heightmapsize-1)) - { - Yb=Y*Terrain->LODLevel[LODLevel].TileSpan-1; - }else{; - Yb=Y*Terrain->LODLevel[LODLevel].TileSpan; - } - - HeightPos=((Xb+StartX)+(Yb+StartY)*Terrain->Heightmapsize); - buffer[BufferPos]=Terrain->HeightPoint[HeightPos]; - } - } -} -// === END FUNCTION === - - - -// ===================================== -// === BT INTERN GET SECTOR EXCLUSION === -// ====================================== -static bool BT_Intern_GetSectorExclusion(s_BT_terrain* Terrain,unsigned long LODLevel,unsigned long excludememblock,unsigned long row,unsigned long column,bool* buffer) -{ -//Variables - bool WholeSectorExcluded=true; - unsigned long X; - unsigned long Y; - unsigned long Xb; - unsigned long Yb; - unsigned long StartX; - unsigned long StartY; - unsigned long BufferPos; - unsigned long ExcludePos; - bool Excluded; - -//Set start positions - StartX=column*Terrain->LODLevel[LODLevel].SectorDetail*Terrain->LODLevel[LODLevel].TileSpan; - StartY=row*Terrain->LODLevel[LODLevel].SectorDetail*Terrain->LODLevel[LODLevel].TileSpan; - -//Loop through points - for(Y=0;Y<=Terrain->LODLevel[LODLevel].SectorDetail;Y++) - { - for(X=0;X<=Terrain->LODLevel[LODLevel].SectorDetail;X++) - { - - BufferPos=(X+Y*(Terrain->LODLevel[LODLevel].SectorDetail+1)); - - if(X*Terrain->LODLevel[LODLevel].TileSpan+StartX>unsigned(Terrain->Heightmapsize-1)) - { - Xb=X*Terrain->LODLevel[LODLevel].TileSpan-1; - }else{ - Xb=X*Terrain->LODLevel[LODLevel].TileSpan; - } - - if(Y*Terrain->LODLevel[LODLevel].TileSpan+StartY>unsigned(Terrain->Heightmapsize-1)) - { - Yb=Y*Terrain->LODLevel[LODLevel].TileSpan-1; - }else{; - Yb=Y*Terrain->LODLevel[LODLevel].TileSpan; - } - ExcludePos=12+((Xb+StartX)+(Yb+StartY)*Terrain->Heightmapsize)*4; - #ifdef DX11 - Excluded=false;// no holes in terrain for DX11 - #else - Excluded=Terrain->ExclusionThreshold>unsigned(GGCOLOR(ReadMemblockDWord(excludememblock,ExcludePos)).r*255); - buffer[BufferPos]=Excluded; - #endif - if(Excluded==false) - WholeSectorExcluded=false; - } - } - -//Return - return WholeSectorExcluded; -} -// === END FUNCTION === - - - -// ============================== -// === BT INTERN BUILD SECTOR === -// ============================== -static void BT_Intern_BuildSector(s_BT_Sector* Sector) -{ -//Generate meshdata - Sector->QuadMap->GenerateMeshData(); - -//Create object - Sector->DrawBuffer=Sector->QuadMap->GeneratePlain(); - -//Make world matrix - GGMatrixTranslation(&Sector->WorldMatrix,Sector->Pos_x*Sector->Terrain->Scale/C_BT_INTERNALSCALE,Sector->Pos_y,Sector->Pos_z*Sector->Terrain->Scale/C_BT_INTERNALSCALE); -} -// === END FUNCTION === - - - -// ================================ -// === BT INTERN DELETE TERRAIN === -// ================================ -static void BT_Intern_DeleteTerrain(unsigned long TerrainID,bool DeleteObjectFlag) -{ -//Check that the terrain is built - if(BT_Main.Terrains[TerrainID].Built==true) - { - //Get terrain pointer - s_BT_terrain* Terrain; - Terrain=&BT_Main.Terrains[TerrainID]; - - //Delete LODMap - for(unsigned long i=0;iLODLevel[0].Split;i++) - free(Terrain->LODMap[i]); - free(Terrain->LODMap); - - //Delete LODLevels - for(unsigned long LODLevel=0;LODLevelLODLevels;LODLevel++) - { - //Delete sectors - unsigned long Sector=0; - for(Sector=0;SectorLODLevel[LODLevel].Sectors;Sector++) - { - //Check if the sector is not excluded - if(Terrain->LODLevel[LODLevel].Sector[Sector].Excluded==false) - { - #ifdef DX11 - // delete draw buffer in DX11 - #else - //Delete drawbuffer - Terrain->LODLevel[LODLevel].Sector[Sector].DrawBuffer->VertexBuffer->Release(); - Terrain->LODLevel[LODLevel].Sector[Sector].DrawBuffer->IndexBuffer->Release(); - Terrain->LODLevel[LODLevel].Sector[Sector].DrawBuffer->EdgeLineIndexBuffer->Release(); - #endif - free(Terrain->LODLevel[LODLevel].Sector[Sector].DrawBuffer); - - //Delete Quadmap - Terrain->LODLevel[LODLevel].Sector[Sector].QuadMap->DeleteInternalData(); - free(Terrain->LODLevel[LODLevel].Sector[Sector].QuadMap); - - //Delete RTTMS - free(Terrain->LODLevel[LODLevel].Sector[Sector].VertexDataRTTMS); - - //Delete Info - free(Terrain->LODLevel[LODLevel].Sector[Sector].Info); - } - } - free(Terrain->LODLevel[LODLevel].Sector); - - //Delete Info - free(Terrain->LODLevel[LODLevel].Info); - } - free(Terrain->LODLevel); - - //Delete Quadtree - BT_Intern_DeAllocateQuadTree(Terrain->QuadTree); - - //Delete Environment map - BT_Intern_DeleteEnvironmentMap(Terrain->EnvironmentMap); - free(Terrain->EnvironmentMap); - - //Delete object - if(DeleteObjectFlag==true) - DeleteObject(Terrain->ObjectID); - - //Delete update handlers - BT_RTTMS_DeleteUpdateHandlers(TerrainID); - - //Delete Info - free(Terrain->Info); - - //Zero terrain array - memset(Terrain,0,sizeof(s_BT_terrain)); - }else{ - //Zero terrain array - memset(&BT_Main.Terrains[TerrainID],0,sizeof(s_BT_terrain)); - } -} -// === END FUNCTION === - -// ================================== -// === BT INTERN GET POINT HEIGHT === -// ================================== -float BT_Intern_GetPointHeight(s_BT_terrain* Terrain,float Px,float Pz,char LODLevel,bool Round) -{ -//Variables - float Height; - unsigned short SRow; - unsigned short SCollumn; - unsigned short SectorID; - s_BT_Sector* Sector; - BT_QuadMap* Quadmap; - -//Clamp values - if(Px>Terrain->TerrainSize) - return 0.0; - - if(Pz>Terrain->TerrainSize) - return 0.0; - - if(Px<0) - return 0.0; - - if(Pz<0) - return 0.0; - -//Find the row and collumn of the sector - SRow=(unsigned short)floor(Px/Terrain->LODLevel[LODLevel].SectorSize); - SCollumn=(unsigned short)floor(Pz/Terrain->LODLevel[LODLevel].SectorSize); - -//As the above clamping sometimes makes mistakes, we will correct them here - if(SRow>unsigned(Terrain->LODLevel[LODLevel].Split-1)) - SRow=Terrain->LODLevel[LODLevel].Split-1; - - if(SCollumn>unsigned(Terrain->LODLevel[LODLevel].Split-1)) - SCollumn=Terrain->LODLevel[LODLevel].Split-1; - - SectorID=SCollumn+SRow*Terrain->LODLevel[LODLevel].Split; - -//Find the sector pointer - Sector=&Terrain->LODLevel[LODLevel].Sector[SectorID]; - -//Get point on sector - Px=Px-Sector->Pos_x; - Pz=Pz-Sector->Pos_z; - -//Find the quadmap pointer - Quadmap=Sector->QuadMap; - -//Check that the sector exists - if(Sector->Excluded==false) - { - //Get the height - Height=Quadmap->GetPointHeight(Px,Pz,Round); - - //Return the height - return Height; - - }else{ - //Return nothing - return 0.0; - } -} -// === END FUNCTION === - - - -// ================================== -// === BT INTERN GET POINT NORMAL === -// ================================== -BTVector3 BT_Intern_GetPointNormal(s_BT_terrain* Terrain,float Px,float Pz) -{ -//Variables - BTVector3 Normal; - float Tilesize; - float Top; - float Left; - float Bottom; - float Right; - float Dx; - float Dy; - float Dz; - -//Work out tilesize (halved to make this code a little faster) - Tilesize=C_BT_INTERNALSCALE/2.0; - -//Find point heights - Top=BT_Intern_GetPointHeight(Terrain,Px,float(Pz+Tilesize),0,0); - Left=BT_Intern_GetPointHeight(Terrain,float(Px-Tilesize),Pz,0,0); - Bottom=BT_Intern_GetPointHeight(Terrain,Px,float(Pz-Tilesize),0,0); - Right=BT_Intern_GetPointHeight(Terrain,float(Px+Tilesize),Pz,0,0); - -//If Top or Right heights are 0 then set height to middle (bug fix) - if(Top==0.0f || Left==0.0f || Bottom==0.0f || Right==0.0f) - { - float Middle=BT_Intern_GetPointHeight(Terrain,Px,Pz,0,0); - if(Top==0.0f) - Top=Middle*2-Bottom; - if(Left==0.0f) - Left=Middle*2-Right; - if(Bottom==0.0f) - Bottom=Middle*2-Top; - if(Right==0.0f) - Right=Middle*2-Left; - } - -//Get distances - Dx=(Bottom-Top)/Tilesize; - Dz=(Right-Left)/Tilesize; - Dx=Dx/Terrain->Scale*C_BT_INTERNALSCALE; - Dz=Dz/Terrain->Scale*C_BT_INTERNALSCALE; - Dy=float(1.0/sqrt(1.0+Dx*Dx+Dz*Dz)); - -//Work out normal - Normal.x=-Dz*Dy; - Normal.y=Dy; - Normal.z=Dx*Dy; - - return Normal; -} -// === END FUNCTION === - - - -// ==================================== -// === BT INTERN GET POINT EXCLUDED === -// ==================================== -static bool BT_Intern_GetPointExcluded(s_BT_terrain* Terrain,float Px,float Pz) -{ -//Variables - unsigned short SRow; - unsigned short SCollumn; - unsigned short SectorID; - s_BT_Sector* Sector; - BT_QuadMap* Quadmap; - -//Clamp values - if(Px>Terrain->TerrainSize-C_BT_INTERNALSCALE) - return true; - - if(Pz>Terrain->TerrainSize-C_BT_INTERNALSCALE) - return true; - - if(Px<0) - return true; - - if(Pz<0) - return true; - -//Find the row and collumn of the sector - SRow=(unsigned short) floor(Px/Terrain->LODLevel[0].SectorSize); - SCollumn=(unsigned short) floor(Pz/Terrain->LODLevel[0].SectorSize); - -//As the above clamping sometimes makes mistakes, we will correct them here - if(SRow>unsigned(Terrain->LODLevel[0].Split-1)) - SRow=Terrain->LODLevel[0].Split-1; - - if(SCollumn>unsigned(Terrain->LODLevel[0].Split-1)) - SCollumn=Terrain->LODLevel[0].Split-1; - - SectorID=SCollumn+SRow*Terrain->LODLevel[0].Split; - -//Find the sector pointer - Sector=&Terrain->LODLevel[0].Sector[SectorID]; - -//Get point on sector - Px=Px-Sector->Pos_x; - Pz=Pz-Sector->Pos_z; - -//Find the quadmap pointer - Quadmap=Sector->QuadMap; - -//Check that the sector exists - if(Sector->Excluded==false) - { - //Get the excluded - return Quadmap->GetPointExcluded(Px,Pz); - }else{ - //Return nothing - return false; - } -} -// === END FUNCTION === - - - -// =================================== -// === BT INTERN ALLOCATE QUADTREE === -// =================================== -s_BT_QuadTree* BT_Intern_AllocateQuadTree(s_BT_terrain* Terrain) -{ -//Variables - s_BT_QuadTree* QuadTree; - unsigned char Levels; - -//Calculate levels - unsigned char i=1; - while(((Terrain->LODLevel[0].Split>>i)&0x1)==NULL) - i++; - - Levels=i; - Terrain->QuadTreeLevels=Levels; - -//Allocate quadtree - QuadTree=BT_Intern_AllocateQuadTreeRec(Terrain,Levels,NULL,0,0); - - return QuadTree; -} -// === END FUNCTION === - - - -// ======================================= -// === BT INTERN ALLOCATE QUADTREE REC === -// ======================================= -static s_BT_QuadTree* BT_Intern_AllocateQuadTreeRec(s_BT_terrain* Terrain,unsigned char Levels,s_BT_QuadTree* Parent,unsigned char row,unsigned char collumn) -{ -//Variables - s_BT_QuadTree* Quadtree; - bool QHasSector=false; - -//Allocate Quadtree - Quadtree=(s_BT_QuadTree*)malloc(sizeof(s_BT_QuadTree)); - if(Quadtree==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset ( Quadtree, 0, sizeof(s_BT_QuadTree) ); - -//Set values - Quadtree->Level=Levels; - Quadtree->row=row; - Quadtree->collumn=collumn; - Quadtree->Parent=Parent; - Quadtree->Excluded=false; - Quadtree->Culled=false; - -//Allocate cullbox - Quadtree->CullBox=(s_BT_CullBox*)malloc(sizeof(s_BT_CullBox)); - if(Quadtree->CullBox==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - -//Check if this LOD level exists - if(LevelsLODLevels) - { - //Find sector ID - Quadtree->Sector=&Terrain->LODLevel[Levels].Sector[row+collumn*Terrain->LODLevel[Levels].Split]; - Quadtree->Sector->QuadTree=Quadtree; - - //Set cullbox values - if(Quadtree->Sector->Excluded==false) - { - Quadtree->CullBox->Left=float(Quadtree->Sector->Pos_x-Terrain->LODLevel[Levels].SectorSize/2.0); - Quadtree->CullBox->Right=float(Quadtree->Sector->Pos_x+Terrain->LODLevel[Levels].SectorSize/2.0); - Quadtree->CullBox->Front=float(Quadtree->Sector->Pos_z-Terrain->LODLevel[Levels].SectorSize/2.0); - Quadtree->CullBox->Back=float(Quadtree->Sector->Pos_z+Terrain->LODLevel[Levels].SectorSize/2.0); - Quadtree->CullBox->Top=Quadtree->Sector->Pos_y+Quadtree->Sector->QuadMap->GetHighestPoint(); - Quadtree->CullBox->Bottom=Quadtree->Sector->Pos_y+Quadtree->Sector->QuadMap->GetLowestPoint(); - } - QHasSector=true; - - Quadtree->Excluded=Quadtree->Sector->Excluded; - }else{ - Quadtree->Sector=NULL; - } - -//Allocate children (if any) - if(Levels>0) - { - Levels--; - Quadtree->n1=BT_Intern_AllocateQuadTreeRec(Terrain,Levels,Quadtree,row*2,collumn*2); - Quadtree->n2=BT_Intern_AllocateQuadTreeRec(Terrain,Levels,Quadtree,row*2,collumn*2+1); - Quadtree->n3=BT_Intern_AllocateQuadTreeRec(Terrain,Levels,Quadtree,row*2+1,collumn*2); - Quadtree->n4=BT_Intern_AllocateQuadTreeRec(Terrain,Levels,Quadtree,row*2+1,collumn*2+1); - - Quadtree->Excluded=Quadtree->n1->Excluded && Quadtree->n2->Excluded && Quadtree->n3->Excluded && Quadtree->n4->Excluded; - - if(QHasSector==false) - { - Quadtree->CullBox->Left=Quadtree->n1->CullBox->Left; - Quadtree->CullBox->Right=Quadtree->n4->CullBox->Right; - Quadtree->CullBox->Front=Quadtree->n1->CullBox->Front; - Quadtree->CullBox->Back=Quadtree->n4->CullBox->Back; - - Quadtree->CullBox->Top=Quadtree->n1->CullBox->Top; - if(Quadtree->n2->CullBox->Top>Quadtree->CullBox->Top) - Quadtree->CullBox->Top=Quadtree->n2->CullBox->Top; - if(Quadtree->n3->CullBox->Top>Quadtree->CullBox->Top) - Quadtree->CullBox->Top=Quadtree->n3->CullBox->Top; - if(Quadtree->n4->CullBox->Top>Quadtree->CullBox->Top) - Quadtree->CullBox->Top=Quadtree->n4->CullBox->Top; - - Quadtree->CullBox->Bottom=Quadtree->n1->CullBox->Bottom; - if(Quadtree->n2->CullBox->BottomCullBox->Bottom) - Quadtree->CullBox->Bottom=Quadtree->n2->CullBox->Bottom; - if(Quadtree->n3->CullBox->BottomCullBox->Bottom) - Quadtree->CullBox->Bottom=Quadtree->n3->CullBox->Bottom; - if(Quadtree->n4->CullBox->BottomCullBox->Bottom) - Quadtree->CullBox->Bottom=Quadtree->n4->CullBox->Bottom; - } - }else{ - Quadtree->n1=NULL; - Quadtree->n2=NULL; - Quadtree->n3=NULL; - Quadtree->n4=NULL; - } - -//Find position - Quadtree->PosX=(Quadtree->CullBox->Left+Quadtree->CullBox->Right)/2.0f; - Quadtree->PosY=(Quadtree->CullBox->Top+Quadtree->CullBox->Bottom)/2.0f; - Quadtree->PosZ=(Quadtree->CullBox->Front+Quadtree->CullBox->Back)/2.0f; - -//Return - return Quadtree; -} -// === END FUNCTION === - -//LEFT = x-size -//RIGHT = x+size -//TOP = y+size -//BOTTOM = y-size -//FRONT = z-size -//BACK = z+size - -// ===================================== -// === BT INTERN DEALLOCATE QUADTREE === -// ===================================== -static void BT_Intern_DeAllocateQuadTree(s_BT_QuadTree* Quadtree) -{ -//DeAllocate quadtree - BT_Intern_DeAllocateQuadTreeRec(Quadtree); - free(Quadtree); -} -// === END FUNCTION === - - - -// ========================================= -// === BT INTERN DEALLOCATE QUADTREE REC === -// ========================================= -static void BT_Intern_DeAllocateQuadTreeRec(s_BT_QuadTree* Quadtree) -{ -//Deallocate children - if(Quadtree->n1!=NULL){ - BT_Intern_DeAllocateQuadTreeRec(Quadtree->n1); - free(Quadtree->n1); - } - - if(Quadtree->n2!=NULL){ - BT_Intern_DeAllocateQuadTreeRec(Quadtree->n2); - free(Quadtree->n2); - } - - if(Quadtree->n3!=NULL){ - BT_Intern_DeAllocateQuadTreeRec(Quadtree->n3); - free(Quadtree->n3); - } - - if(Quadtree->n4!=NULL){ - BT_Intern_DeAllocateQuadTreeRec(Quadtree->n4); -#pragma message("TEMPORARY") - //free(Quadtree->n4); - } - - if(Quadtree->CullBox!=NULL) - free(Quadtree->CullBox); -} -// === END FUNCTION === - - - -void BT_Intern_RefreshVB(s_BT_DrawBuffer* DrawBuffer,unsigned long FirstVertex,unsigned long LastVertex,BT_Meshdata_Vertex* Vertex) -{ -//Variables - - //FVF size - unsigned long FVFSize; - -//Get variables from drawbuffer - FVFSize=DrawBuffer->FVF_Size; - -//Lock vertexdata -#ifdef DX11 - // lock and write to vertex buffer in DX11 - if ( 0 ) - { - // if VB is dynamic - D3D11_MAPPED_SUBRESOURCE resource; - std::memset ( &resource, 0, sizeof ( resource ) ); - if ( FAILED ( m_pImmediateContext->Map ( DrawBuffer->VertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource ) ) ) return; - BT_Meshdata_Vertex* LockedVertex = (BT_Meshdata_Vertex*)resource.pData; - std::memcpy(LockedVertex,Vertex+FirstVertex*FVFSize,(LastVertex-FirstVertex)*FVFSize); - m_pImmediateContext->Unmap ( DrawBuffer->VertexBuffer, 0 ); - } - else - { - // if VB is default (faster) - D3D11_BOX box; - box.left = FirstVertex*FVFSize; - box.right = (FirstVertex*FVFSize) + ( (LastVertex-FirstVertex)*FVFSize ); - box.top = 0; - box.bottom = 1; - box.front = 0; - box.back = 1; - m_pImmediateContext->UpdateSubresource ( DrawBuffer->VertexBuffer, 0, &box, Vertex, 0, 0 ); - } -#else - //Locked vertex list - BT_Meshdata_Vertex* LockedVertex; - DrawBuffer->VertexBuffer->Lock(FirstVertex*FVFSize,(LastVertex-FirstVertex)*FVFSize,(void**)&LockedVertex,NULL); - -//Copy vertexdata - memcpy(LockedVertex,Vertex+FirstVertex*FVFSize,(LastVertex-FirstVertex)*FVFSize); - -//Unlock vertexdata - DrawBuffer->VertexBuffer->Unlock(); -#endif -} - -void BT_Intern_RefreshIB(s_BT_DrawBuffer* DrawBuffer,unsigned long FirstIndex,unsigned long LastIndex,unsigned short* Index) -{ -#ifdef DX11 - // lock index buffer and write to it - if ( 0 ) - { - // if IB is dynamic - D3D11_MAPPED_SUBRESOURCE resource; - std::memset ( &resource, 0, sizeof ( resource ) ); - if ( FAILED ( m_pImmediateContext->Map ( DrawBuffer->IndexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource ) ) ) return; - unsigned short* LockedIndex = (unsigned short*)resource.pData; - std::memcpy(LockedIndex,Index+FirstIndex*sizeof(unsigned short),(LastIndex-FirstIndex)*sizeof(unsigned short)); - m_pImmediateContext->Unmap ( DrawBuffer->IndexBuffer, 0 ); - } - else - { - // if IB is default (faster) - D3D11_BOX box; - box.left = FirstIndex*sizeof(unsigned short); - box.right = (FirstIndex*sizeof(unsigned short)) + ( (LastIndex-FirstIndex)*sizeof(unsigned short) ); - box.top = 0; - box.bottom = 1; - box.front = 0; - box.back = 1; - m_pImmediateContext->UpdateSubresource ( DrawBuffer->IndexBuffer, 0, &box, Index, 0, 0 ); - } -#else - //Locked index list - unsigned short* LockedIndex; -//Lock indexdata - DrawBuffer->IndexBuffer->Lock(FirstIndex*sizeof(unsigned short),(LastIndex-FirstIndex)*sizeof(unsigned short),(void**)&LockedIndex,NULL); - -//Copy indexdata - memcpy(LockedIndex,Index+FirstIndex*sizeof(unsigned short),(LastIndex-FirstIndex)*sizeof(unsigned short)); - -//Unlock indexdata - DrawBuffer->IndexBuffer->Unlock(); -#endif -} - - - -static void BT_Intern_ExtractFrustum() -{ -//Variables - GGMATRIX ClipMatrix; - -//Multiply view and projection matrices together - GGMatrixMultiply(&ClipMatrix,&BT_Main.CurrentUpdateCamera->matView,&BT_Main.CurrentUpdateCamera->matProjection); - -//Get right plane - BT_Main.Frustum[0][0]=ClipMatrix._14-ClipMatrix._11; - BT_Main.Frustum[0][1]=ClipMatrix._24-ClipMatrix._21; - BT_Main.Frustum[0][2]=ClipMatrix._34-ClipMatrix._31; - BT_Main.Frustum[0][3]=ClipMatrix._44-ClipMatrix._41; - -//Get left plane - BT_Main.Frustum[1][0]=ClipMatrix._14+ClipMatrix._11; - BT_Main.Frustum[1][1]=ClipMatrix._24+ClipMatrix._21; - BT_Main.Frustum[1][2]=ClipMatrix._34+ClipMatrix._31; - BT_Main.Frustum[1][3]=ClipMatrix._44+ClipMatrix._41; - -//Get bottom plane - BT_Main.Frustum[2][0]=ClipMatrix._14+ClipMatrix._12; - BT_Main.Frustum[2][1]=ClipMatrix._24+ClipMatrix._22; - BT_Main.Frustum[2][2]=ClipMatrix._34+ClipMatrix._32; - BT_Main.Frustum[2][3]=ClipMatrix._44+ClipMatrix._42; - -//Get top plane - BT_Main.Frustum[3][0]=ClipMatrix._14-ClipMatrix._12; - BT_Main.Frustum[3][1]=ClipMatrix._24-ClipMatrix._22; - BT_Main.Frustum[3][2]=ClipMatrix._34-ClipMatrix._32; - BT_Main.Frustum[3][3]=ClipMatrix._44-ClipMatrix._42; - -//Get far plane - BT_Main.Frustum[4][0]=ClipMatrix._14-ClipMatrix._13; - BT_Main.Frustum[4][1]=ClipMatrix._24-ClipMatrix._23; - BT_Main.Frustum[4][2]=ClipMatrix._34-ClipMatrix._33; - BT_Main.Frustum[4][3]=ClipMatrix._44-ClipMatrix._43; - -} - - -//LEFT = x-size -//RIGHT = x+size -//TOP = y+size -//BOTTOM = y-size -//FRONT = z-size -//BACK = z+size - - -//Returns 0 if box isnt in frustum, 1 if intersecting and 2 if completely in frustum -static int BT_Intern_CullBox(s_BT_CullBox* pCullBox) -{ -//Increase cull checks - BT_Main.CullChecks++; - -//Subtract Cull offset - s_BT_CullBox CullBox; - CullBox.Left=pCullBox->Left*BT_Main.CullScale.x-BT_Main.CullOffset.x; - CullBox.Right=pCullBox->Right*BT_Main.CullScale.x-BT_Main.CullOffset.x; - CullBox.Top=pCullBox->Top*BT_Main.CullScale.y-BT_Main.CullOffset.y; - CullBox.Bottom=pCullBox->Bottom*BT_Main.CullScale.y-BT_Main.CullOffset.y; - CullBox.Front=pCullBox->Front*BT_Main.CullScale.z-BT_Main.CullOffset.z; - CullBox.Back=pCullBox->Back*BT_Main.CullScale.z-BT_Main.CullOffset.z; - -//Variables - int p; - int c; - int c2 = 0; - -//Loop - for( p = 0; p < 5; p++ ) - { - c = 0; - if( BT_Main.Frustum[p][0] * CullBox.Left + BT_Main.Frustum[p][1] * CullBox.Bottom + BT_Main.Frustum[p][2] * CullBox.Front + BT_Main.Frustum[p][3] > 0 ) - c++; - if( BT_Main.Frustum[p][0] * CullBox.Right + BT_Main.Frustum[p][1] * CullBox.Bottom + BT_Main.Frustum[p][2] * CullBox.Front + BT_Main.Frustum[p][3] > 0 ) - c++; - if( BT_Main.Frustum[p][0] * CullBox.Left + BT_Main.Frustum[p][1] * CullBox.Top + BT_Main.Frustum[p][2] * CullBox.Front + BT_Main.Frustum[p][3] > 0 ) - c++; - if( BT_Main.Frustum[p][0] * CullBox.Right + BT_Main.Frustum[p][1] * CullBox.Top + BT_Main.Frustum[p][2] * CullBox.Front + BT_Main.Frustum[p][3] > 0 ) - c++; - if( BT_Main.Frustum[p][0] * CullBox.Left + BT_Main.Frustum[p][1] * CullBox.Bottom + BT_Main.Frustum[p][2] * CullBox.Back + BT_Main.Frustum[p][3] > 0 ) - c++; - if( BT_Main.Frustum[p][0] * CullBox.Right + BT_Main.Frustum[p][1] * CullBox.Bottom + BT_Main.Frustum[p][2] * CullBox.Back + BT_Main.Frustum[p][3] > 0 ) - c++; - if( BT_Main.Frustum[p][0] * CullBox.Left + BT_Main.Frustum[p][1] * CullBox.Top + BT_Main.Frustum[p][2] * CullBox.Back + BT_Main.Frustum[p][3] > 0 ) - c++; - if( BT_Main.Frustum[p][0] * CullBox.Right + BT_Main.Frustum[p][1] * CullBox.Top + BT_Main.Frustum[p][2] * CullBox.Back + BT_Main.Frustum[p][3] > 0 ) - c++; - if( c == 0 ) - return 0; - if( c == 8 ) - c2++; - } - return (c2 == 4) ? 2 : 1; -} - - - -// ========================================= -// === BT INTERN LOCK SECTOR VERTEX DATA === -// ========================================= -static BT_RTTMS_STRUCT* BT_Intern_LockSectorVertexData(s_BT_Sector* Sector) -{ -//Lock sector - return (BT_RTTMS_STRUCT*)BT_RTTMS_LockSectorVertexData(Sector->Terrain->ID,Sector->LODLevel->ID,Sector->ID); -} -// === END FUNCTION === - - - -// =========================================== -// === BT INTERN UNLOCK SECTOR VERTEX DATA === -// =========================================== -static void BT_Intern_UnlockSectorVertexData(s_BT_Sector* Sector) -{ -//Unlock vertexdata - if(Sector->VertexDataLocked==true) - { - BT_RTTMS_UnlockSectorVertexData((void*)Sector->VertexDataRTTMS); - } -} -// === END FUNCTION === - - -// ====================================== -// === BT INTERN RTTMS UPDATE HANDLER === -// ====================================== -void BT_Intern_RTTMSUpdateHandler(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID,unsigned short StartVertex,unsigned short EndVertex,float* VerticesPtr) -{ -#ifdef C_BT_FULLVERSION -//Cast vertices - float* Vertices=(float*)VerticesPtr; - -//Get sector - s_BT_Sector* Sector=&BT_Main.Terrains[TerrainID].LODLevel[LODLevelID].Sector[SectorID]; - -//Change mesh data - if(EndVertex>0) - { - //Update meshdata - Sector->QuadMap->ChangeMeshData(StartVertex,EndVertex,Vertices); - Sector->UpdateMesh=true; - - //Force update of edges - Sector->LeftSideNeedsUpdate=true; - Sector->RightSideNeedsUpdate=true; - Sector->TopSideNeedsUpdate=true; - Sector->BottomSideNeedsUpdate=true; - - //Update collision - if(Sector->DBPObject!=0){ - Sector->QuadMap->UpdateDBPMesh(Sector->DBPObject->pFrame->pMesh); - } - if(Sector->LODLevel->DBPObject!=0){ - //Find the sector - if ( Sector->LODLevelObjectFrame ) - Sector->QuadMap->UpdateDBPMesh(Sector->LODLevelObjectFrame->pMesh); - } - - //Say that the cull box has changed - s_BT_QuadTree* QuadTree=Sector->QuadTree; - do{ - QuadTree->CullboxChanged=true; - QuadTree=QuadTree->Parent; - }while(QuadTree!=NULL); - } -#endif -} -// === END FUNCTION === - - - -// ======================================== -// === BT INTERN GET HEIGHT FROM COLOUR === -// ======================================== -static float BT_Intern_GetHeightFromColor(unsigned long Colour) -{ - GGCOLOR D3DColour = GGCOLOR(Colour); -#ifdef C_BT_FULLVERSION - return D3DColour.r * 256.0f + D3DColour.g + D3DColour.b / 256.0f; -#else - return D3DColour.r * 256.0f; -#endif -} -// === END FUNCTION === - - - -// ========================= -// === BT SMOOTH TERRAIN === -// ========================= -static void BT_Intern_SmoothTerrain(s_BT_terrain* Terrain) -{ -//Loop through smooth levels - for(unsigned char SmoothLevel=0;SmoothLevelSmoothing;SmoothLevel++){ - for(unsigned short y=1;yHeightmapsize-1;y++){ - for(unsigned short x=1;xHeightmapsize-1;x++){ - float CornA=Terrain->HeightPoint[(x-1)+(y-1)*Terrain->Heightmapsize]; - float CornB=Terrain->HeightPoint[(x+1)+(y-1)*Terrain->Heightmapsize]; - float CornC=Terrain->HeightPoint[(x-1)+(y+1)*Terrain->Heightmapsize]; - float CornD=Terrain->HeightPoint[(x+1)+(y+1)*Terrain->Heightmapsize]; - float NexA=Terrain->HeightPoint[(x-1)+y*Terrain->Heightmapsize]; - float NexB=Terrain->HeightPoint[(x+1)+y*Terrain->Heightmapsize]; - float NexC=Terrain->HeightPoint[x+(y-1)*Terrain->Heightmapsize]; - float NexD=Terrain->HeightPoint[x+(y+1)*Terrain->Heightmapsize]; - float Middle=Terrain->HeightPoint[x+y*Terrain->Heightmapsize]; - float CornerAverage=(CornA+CornB+CornC+CornD)/4.0f; - float NeighborAverage=(CornerAverage+NexA+NexB+NexC+NexD)/5.0f; - Terrain->HeightPoint[x+y*Terrain->Heightmapsize]=(Middle+NeighborAverage)/2.0f; - } - } - } -} -// === END FUNCTION === diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/main.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/main.h deleted file mode 100644 index 057bf65..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/main.h +++ /dev/null @@ -1,519 +0,0 @@ -#ifndef _BLITZTERRAINMAIN_H -#define _BLITZTERRAINMAIN_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include ".\..\..\Shared\DBOFormat\DBOData.h" -#include ".\..\..\Shared\camera\ccameradatac.h" -#include "directx-macros.h" -#include "BlitzTerrain.h" -#include "globstruct.h" - -#define C_BT_FULLVERSION -#define C_BT_VERSION 200 -#define C_BT_MAXTERRAINS 255 -#define C_BT_MAXLODLEVELS 16 //PE: org 255 , just waste mem and cpu. -#define C_BT_MAXTERRAINSIZE 4096 -#define BT_VERSION "2.02 R2 FULL" - -using namespace std; - -struct s_BT_Sector; - -#include "quadmapping.h" -#include "EnvironmentMapping.h" - -struct BTVector3 -{ - float x,y,z; -}; - -struct s_BT_DrawBuffer -{ - IGGVertexBuffer* VertexBuffer; - IGGIndexBuffer* IndexBuffer; - IGGIndexBuffer* EdgeLineIndexBuffer; - unsigned short Vertices; - unsigned long Indices; - unsigned short EdgeIndexCount; - unsigned long FVF; - unsigned char FVF_Size; - unsigned short Primitives; -}; - -struct s_BT_LODLevel; -struct s_BT_terrain; -struct s_BT_QuadTree; -class BT_QuadMap; - -struct s_BT_Sector -{ - //Excluded - bool Excluded; - - //ID - unsigned long ID; - - //Positions - unsigned short Row; - unsigned short Column; - float Pos_x; - float Pos_y; - float Pos_z; - - //Quadmap - BT_QuadMap* QuadMap; - - //Drawbuffer - s_BT_DrawBuffer* DrawBuffer; - - //World Matrix - GGMATRIX WorldMatrix; - - //LODLevel and Terrain - s_BT_LODLevel* LODLevel; - s_BT_terrain* Terrain; - - // Edge LOD - bool TopSideNeedsUpdate; - bool LeftSideNeedsUpdate; - bool RightSideNeedsUpdate; - bool BottomSideNeedsUpdate; - int TopSideLODLevel; - int LeftSideLODLevel; - int RightSideLODLevel; - int BottomSideLODLevel; - - //Quadtree - s_BT_QuadTree* QuadTree; - - //Update mesh bool - bool UpdateMesh; - - //RTTMS - bool VertexDataLocked; - BT_RTTMS_STRUCT* VertexDataRTTMS; - - //Object - sObject* DBPObject; - sFrame* LODLevelObjectFrame; - - //Info - void* Info; -}; - -struct BT_SectorInfo -{ - bool Excluded; - unsigned short Row; - unsigned short Column; - float Pos_x; - float Pos_y; - float Pos_z; - void* WorldMatrix; - void* InternalData; -}; - - -struct s_BT_LODLevel -{ - unsigned char ID; - float SectorSize; - unsigned char SectorDetail; - unsigned short Sectors; - float Distance; - s_BT_Sector* Sector; - unsigned short Split; - unsigned char TileSpan; - s_BT_terrain* Terrain; - sObject* DBPObject; - - //Info - void* Info; -}; - -struct BT_LODLevelInfo -{ - float SectorSize; - unsigned char SectorDetail; - unsigned short Sectors; - float Distance; - unsigned short Split; - unsigned char TileSpan; - void* InternalData; -}; - - -struct s_BT_CullBox -{ - float Front,Back, - Left,Right, - Top,Bottom; -}; - -struct s_BT_QuadTree -{ - s_BT_QuadTree* n1; - s_BT_QuadTree* n2; - s_BT_QuadTree* n3; - s_BT_QuadTree* n4; - - s_BT_QuadTree* Parent; - - unsigned char Level; - unsigned char row; - unsigned char collumn; - - s_BT_Sector* Sector; - bool Excluded; - s_BT_CullBox* CullBox; - float PosX,PosY,PosZ; - bool DrawThis; - bool Culled; - bool CullboxChanged; -}; - -struct s_BT_LODMap -{ - int Level; -}; - -struct s_BT_terrain -{ - //Exists - bool Exists; - - //ID - unsigned long ID; - - //Build stuff - bool Built; - bool Generated; - - //Point lists - float* HeightPoint; - - //Object stuff - sObject* Object; - unsigned long ObjectID; - - //Images - unsigned long Heightmap; - unsigned long Texture; - unsigned long Detailmap; - unsigned long Environmentmap; - unsigned long Exclusionmap; - - //Settings - unsigned long Smoothing; - bool QuadRotation; - bool QuadReduction; - unsigned char LODLevels; - float Scale; - float YScale; - float Tile; - bool MeshOptimisation; - unsigned short Sectors; - - //LOD Levels - s_BT_LODLevel* LODLevel; - - //Sizes and details - unsigned short Heightmapsize; - float TerrainSize; - - //Quadtree - s_BT_QuadTree* QuadTree; - unsigned char QuadTreeLevels; - - //Exclusion threshold - unsigned char ExclusionThreshold; - - //LODMap - s_BT_LODMap** LODMap; - - //AT Mode - unsigned char ATMode; - - //Detail BlendMode - unsigned char DetailBlendMode; - - //Vertex declaration - LPGGVERTEXLAYOUT VertexDeclaration; - - //Environment Map - BT_EnvironmentMap* EnvironmentMap; - - //Multidetailmapping - bool MultiDetailmapping; - unsigned long DetailMapCount; - - //Info - void* Info; -}; - -struct BT_TerrainInfo -{ - bool Built; - bool Generated; - unsigned long Texture; - unsigned long Detailmap; - bool Smoothing; - bool QuadReduction; - bool QuadRotation; - unsigned char LODLevels; - float Scale; - float YScale; - float Tile; - bool MeshOptimisation; - unsigned short Sectors; - unsigned short Heightmapsize; - float TerrainSize; - bool MultiDetailmapping; - unsigned long DetailMapCount; - bool Exclusion; - unsigned char ExclusionThreshold; - unsigned char ATMode; - unsigned char DetailBlendMode; - void* InternalData; - //Added in 2.2 - unsigned long SmoothAmount; - void* DBPObjectPtr; -}; - - -struct BT_QuadMap_Main; - -struct s_BT_main -{ - //Terrains - s_BT_terrain Terrains[C_BT_MAXTERRAINS]; - - //Build info - bool Building; - bool BuildType; - s_BT_terrain* CurrentBuildTerrain; - unsigned long CurrentBuildSector; - unsigned long CurrentBuildRow; - unsigned long CurrentBuildColumn; - unsigned long CurrentBuildLODLevel; - unsigned long CurrentBuildTerrainSector; - - //Current function - unsigned long CurrentFunction; - - //BuildStep - unsigned long buildstep; - - //Updating - tagCameraData* CurrentUpdateCamera; - bool FrustumExtracted; - - //Frustum Culling - GGVECTOR3 CullOffset; - GGVECTOR3 CullScale; - float Frustum[5][4]; - - //LOD Cam - GGVECTOR3 LODCamPosition; - - //Statistics - unsigned long DrawPrimitiveCount; - unsigned long DrawCalls; - unsigned long CullChecks; - - //Current render terrain - s_BT_terrain* CurrentRenderTerrain; - - //Quadmap info - BT_QuadMap_Main QuadmapInfo; - - //Instruction queue - char* InstructionQueue; - unsigned long InstructionQueueSize; - unsigned long InstructionQueueUsed; - - //Advanced Terrain mode - bool ATMode; - - //Auto render - bool AutoRender; - - //Effect - cSpecialEffect* CurrentEffect; - - //Initialised boolean (for GDK) - bool Initialised; -}; - -struct BT_SectorMeshData -{ - bool DeleteMeshData; - void* Vertex_Data; - unsigned short Vertex_Count; - unsigned char Vertex_FVFSize; - - unsigned short* Index_Data; - unsigned long Index_Count; - - float Scale; -}; - -void *BT_GetSectorInternalData(unsigned long TerrainID,unsigned long LODLevel,unsigned long SectorID); -void BT_DeleteSectorInternalData(unsigned long TerrainID,unsigned long LODLevel,unsigned long SectorID); - -void BT_Intern_Render(); -static void BT_Intern_AddToInstructionQueue(char Instruction,char Data); -static void BT_Intern_ClearStatistics(); -static void BT_Intern_CalculateLODLevelsRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level,unsigned char LODLevelToDraw); -static void BT_Intern_FixLODSeams(s_BT_terrain* Terrain); -static void BT_Intern_FixSectorLODSeams(s_BT_Sector* SectorPtr); -static void BT_Intern_CalculateCullingRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level,bool IntersectingFrustum); -static void BT_Intern_UpdateCullBoxesRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level); -static void BT_Intern_RenderTerrainRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level,int iQualityPass); -static void BT_Intern_UnlockSectorsRec(s_BT_terrain* Terrain,s_BT_QuadTree* Quadtree,unsigned long Level); -static void BT_Intern_RenderSector(s_BT_Sector* Sector); -static float BT_Intern_DistanceToLODCamera(s_BT_terrain* Terrain,s_BT_CullBox* CullBox); -static void BT_Intern_ContinueBuild(); -static void BT_Intern_RenderTerrain(s_BT_terrain* Terrain); -static void BT_Intern_NoRenderTerrain(s_BT_terrain* Terrain); -bool BT_Intern_TerrainExist(unsigned long terrainid); -static long BT_Intern_ImageExist(unsigned long imageid); -void BT_Intern_Error(int number); -static char* BT_Intern_GetErrorString(int number); -static char* BT_Intern_GetFunctionName(int number); -static void BT_Intern_GetSectorHeights(s_BT_terrain* Terrain,unsigned long LODLevel,unsigned long row,unsigned long column,float* buffer); -static bool BT_Intern_GetSectorExclusion(s_BT_terrain* Terrain,unsigned long LODLevel,unsigned long excludememblock,unsigned long row,unsigned long column,bool* buffer); -static void BT_Intern_BuildSector(s_BT_Sector* Sector); -static void BT_Intern_DeleteTerrain(unsigned long TerrainID,bool DeleteObject); -float BT_Intern_GetPointHeight(s_BT_terrain* Terrain,float Px,float Pz,char LODLevel,bool Round); -BTVector3 BT_Intern_GetPointNormal(s_BT_terrain* Terrain,float Px,float Pz); -static bool BT_Intern_GetPointExcluded(s_BT_terrain* Terrain,float Px,float Pz); -s_BT_QuadTree* BT_Intern_AllocateQuadTree(s_BT_terrain* Terrain); -static s_BT_QuadTree* BT_Intern_AllocateQuadTreeRec(s_BT_terrain* Terrain,unsigned char Levels,s_BT_QuadTree* Parent,unsigned char row,unsigned char collumn); - -static void BT_Intern_DeAllocateQuadTree(s_BT_QuadTree* Quadtree); -static void BT_Intern_DeAllocateQuadTreeRec(s_BT_QuadTree* Quadtree); - -static float BT_Intern_GetHeightFromColor(unsigned long Colour); - -void BT_Intern_RefreshVB(s_BT_DrawBuffer* DrawBuffer,unsigned long FirstVertex,unsigned long LastVertex,BT_Meshdata_Vertex* Vertex); -void BT_Intern_RefreshIB(s_BT_DrawBuffer* DrawBuffer,unsigned long FirstIndex,unsigned long LastIndex,unsigned short* Index); - -static void BT_Intern_ExtractFrustum(); -static int BT_Intern_CullBox(s_BT_CullBox* CullBox); - -static BT_RTTMS_STRUCT* BT_Intern_LockSectorVertexData(s_BT_Sector* Sector); -static void BT_Intern_UnlockSectorVertexData(s_BT_Sector* Sector); - -struct BT_RTTMS_VERTEX; - -void BT_Intern_RTTMSUpdateHandler(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID,unsigned short StartVertex,unsigned short EndVertex,float* VerticesPtr); - -static void BT_Intern_SmoothTerrain(s_BT_terrain* Terrain); - - -#define C_BT_ERROR_MAXTERRAINSEXCEDED 1 -#define C_BT_ERROR_TERRAINDOESNTEXIST 2 -#define C_BT_ERROR_INVALIDLODLEVELS 3 -#define C_BT_ERROR_HEIGHTMAPDOESNTEXIST 4 -#define C_BT_ERROR_LODLEVELDOESNTEXIST 5 -#define C_BT_ERROR_HEIGHTMAPSIZEINVALID 6 -#define C_BT_ERROR_EXCLUSIONMAPSIZEINVALID 7 -#define C_BT_ERROR_ALREADYBUILDING 8 -#define C_BT_ERROR_OBJECTIDILLEGAL 9 -#define C_BT_ERROR_TERRAINNOTGENERATED 10 -#define C_BT_ERROR_CANNOTCREATEVB 11 -#define C_BT_ERROR_CANNOTCREATEIB 12 -#define C_BT_ERROR_SECTORDOESNTEXIST 13 -#define C_BT_ERROR_TERRAINNOTBUILT 14 -#define C_BT_ERROR_INVALIDFILE 15 -#define C_BT_ERROR_VERSIONCANNOTREADFILE 16 -#define C_BT_ERROR_TERRAINALREADYBUILT 17 -#define C_BT_ERROR_CANNOTUSEFUNCTIONONBUILTTERRAIN 18 -#define C_BT_ERROR_SECTORALREADYLOCKED 19 -#define C_BT_ERROR_SECTORNOTUNLOCKED 20 -#define C_BT_ERROR_USESFULLVERSION 21 -#define C_BT_ERROR_SECTORTOOBIG 22 -#define C_BT_ERROR_SPLITTOOHIGH 23 -#define C_BT_ERROR_SECTORALREADYHASOBJECT 24 -#define C_BT_ERROR_LODLEVELALREADYHASOBJECT 25 -#define C_BT_ERROR_SECTORISEXCLUDED 26 -#define C_BT_ERROR_MEMORYERROR 27 - -#define C_BT_FUNCTION_MAKETERRAIN 1 -#define C_BT_FUNCTION_SETTERRAINHEIGHTMAP 2 -#define C_BT_FUNCTION_SETTERRAINTEXTURE 4 -#define C_BT_FUNCTION_SETTERRAINEXCLUSION 5 -#define C_BT_FUNCTION_SETTERRAINDETAIL 6 -#define C_BT_FUNCTION_SETTERRAINENVIRONMENT 7 -#define C_BT_FUNCTION_SETTERRAINLOD 8 -#define C_BT_FUNCTION_SETTERRAINSPLIT 9 -#define C_BT_FUNCTION_SETTERRAINDETAILTILE 10 -#define C_BT_FUNCTION_SETTERRAINQUADREDUCTION 12 -#define C_BT_FUNCTION_SETTERRAINQUADROTATION 13 -#define C_BT_FUNCTION_SETTERRAINSMOOTHING 14 -#define C_BT_FUNCTION_SETTERRAINSCALE 15 -#define C_BT_FUNCTION_SETTERRAINYSCALE 16 -#define C_BT_FUNCTION_SETTERRAINLODDISTANCES 17 -#define C_BT_FUNCTION_BUILDTERRAIN 18 -#define C_BT_FUNCTION_CONTINUEBUILD 19 -#define C_BT_FUNCTION_TERRAINEXIST 20 -#define C_BT_FUNCTION_DELETETERRAIN 21 -#define C_BT_FUNCTION_GETGROUNDHEIGHT 22 -#define C_BT_FUNCTION_GETTERRAINSIZE 23 -#define C_BT_FUNCTION_GETVERSION 25 -#define C_BT_FUNCTION_SETBUILDSTEP 26 -#define C_BT_FUNCTION_UPDATETERRAIN 28 -#define C_BT_FUNCTION_UPDATE 29 -#define C_BT_FUNCTION_RENDER 32 -#define C_BT_FUNCTION_ENABLEAUTORECOVERY 33 -#define C_BT_FUNCTION_GETSTATISTIC 34 -#define C_BT_FUNCTION_CLEARSTATISTICS 35 -#define C_BT_FUNCTION_GETOBJECTID 36 -#define C_BT_FUNCTION_MAKESECTOROBJECT 38 -#define C_BT_FUNCTION_GETSECTORPOSITIONX 39 -#define C_BT_FUNCTION_GETSECTORPOSITIONY 40 -#define C_BT_FUNCTION_GETSECTORPOSITIONZ 41 -#define C_BT_FUNCTION_GETSECTORCOUNT 42 -#define C_BT_FUNCTION_GETSECTORSIZE 43 -#define C_BT_FUNCTION_GETSECTOREXCLUDED 44 -#define C_BT_FUNCTION_GETSECTORROW 45 -#define C_BT_FUNCTION_GETSECTORCOLLUMN 46 -#define C_BT_FUNCTION_SETCURRENTCAMERA 47 -#define C_BT_FUNCTION_UPDATETERRAINLOD 48 -#define C_BT_FUNCTION_UPDATETERRAINCULL 49 -#define C_BT_FUNCTION_SETPOINTHEIGHT 50 -#define C_BT_FUNCTION_SETTERRAINEXCLUSIONTHRESHOLD 51 -#define C_BT_FUNCTION_LOADTERRAIN 52 -#define C_BT_FUNCTION_SAVETERRAIN 53 -#define C_BT_FUNCTION_GETPOINTEXCLUDED 54 -#define C_BT_FUNCTION_SETATMODE 55 -#define C_BT_FUNCTION_SETTERRAINDETAILBLENDMODE 56 -#define C_BT_FUNCTION_INIT 57 -#define C_BT_FUNCTION_ADDTERRAINENVIRONMENT 58 -#define C_BT_FUNCTION_GETPOINTENVIRONMENT 59 -#define C_BT_FUNCTION_GETTERRAININFO 60 -#define C_BT_FUNCTION_GETLODLEVELINFO 61 -#define C_BT_FUNCTION_GETSECTORINFO 62 -#define C_BT_FUNCTION_MAKETERRAINOBJECT 63 -#define C_BT_FUNCTION_ENABLEAUTORENDER 64 - -#define C_BT_INSTRUCTION_SETCURRENTCAMERA 1 -#define C_BT_INSTRUCTION_UPDATETERRAINCULL 3 -#define C_BT_INSTRUCTION_UPDATETERRAINLOD 4 -#define C_BT_INSTRUCTION_RENDERTERRAIN 5 -#define C_BT_INSTRUCTION_NORENDERTERRAIN 6 - - -#define C_BT_INTERNALSCALE 128.0f - -#endif diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/quadmapping.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/quadmapping.cpp deleted file mode 100644 index 432e372..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/quadmapping.cpp +++ /dev/null @@ -1,1116 +0,0 @@ -#include "main.h" -#include "quadmapping.h" -#include "CreateObject.h" - -extern s_BT_main BT_Main; - -extern IGGDevice* m_pD3D; - -void BT_Intern_StartQuadMapGeneration(BT_Quadmap_Generator Generator) -{ - if(BT_Main.QuadmapInfo.Locked==false){ - BT_Main.QuadmapInfo.Locked=true; - BT_Main.QuadmapInfo.TempVertices=(Generator.Size+1)*(Generator.Size+1)+1; - BT_Main.QuadmapInfo.TempQuads=Generator.Size*Generator.Size; - BT_Main.QuadmapInfo.TempVertexdata=(BT_Quadmap_Vertex*)malloc((BT_Main.QuadmapInfo.TempVertices+1)*sizeof(BT_Quadmap_Vertex)); - if(BT_Main.QuadmapInfo.TempVertexdata==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(BT_Main.QuadmapInfo.TempVertexdata,0,(BT_Main.QuadmapInfo.TempVertices+1)*sizeof(BT_Quadmap_Vertex)); - BT_Main.QuadmapInfo.TempQuaddata=(BT_Quadmap_Quad*)malloc(BT_Main.QuadmapInfo.TempQuads*sizeof(BT_Quadmap_Quad)); - if(BT_Main.QuadmapInfo.TempQuaddata==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(BT_Main.QuadmapInfo.TempQuaddata,0,BT_Main.QuadmapInfo.TempQuads*sizeof(BT_Quadmap_Quad)); - BT_Main.QuadmapInfo.TempVertexMap=(BT_Quadmap_Vertex***)malloc((Generator.Size+1)*sizeof(BT_Quadmap_Vertex**)); - if(BT_Main.QuadmapInfo.TempVertexMap==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - memset(BT_Main.QuadmapInfo.TempVertexMap,0,(Generator.Size+1)*sizeof(BT_Quadmap_Vertex**)); - for(unsigned long i=0;iPos_y; - V2h=TempQuad[Quadn].V2->Pos_y; - V3h=TempQuad[Quadn].V3->Pos_y; - V4h=TempQuad[Quadn].V4->Pos_y; - - //Get height differences - HD1=fabs(V4h-V1h); - HD2=fabs(V3h-V2h); - - //Work out rotation - TempQuad[Quadn].Rotation=HD1>HD2; - } - } - } - -//Optimise arrays - if(Generator.Optimise==true){ - //Make new arrays - Vertex=(BT_Quadmap_Vertex*)calloc(IncVertices+1,sizeof(BT_Quadmap_Vertex)); - if(Vertex==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - Quad=(BT_Quadmap_Quad*)calloc(IncQuads,sizeof(BT_Quadmap_Quad)); - if(Quad==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - - //Copy vertices - CurrVertex=0; - for(Vertexn=0;Vertexn<=Vertices;Vertexn++){ - if(TempVertex[Vertexn].Exclude==false){ - //Position - Vertex[CurrVertex].Pos_y=TempVertex[Vertexn].Pos_y; - Vertex[CurrVertex].Vrow=TempVertex[Vertexn].Vrow; - Vertex[CurrVertex].Vcol=TempVertex[Vertexn].Vcol; - - //Normals - Vertex[CurrVertex].Nrm_x=TempVertex[Vertexn].Nrm_x; - Vertex[CurrVertex].Nrm_y=TempVertex[Vertexn].Nrm_y; - Vertex[CurrVertex].Nrm_z=TempVertex[Vertexn].Nrm_z; - - //Index - Vertex[CurrVertex].Index=(unsigned short)CurrVertex; - - //Set newptr in old array so Quads can find this vertex again - TempVertex[Vertexn].NewPtr=&Vertex[CurrVertex]; - - //Increase current vertex - CurrVertex++; - }else{ - IncVertices--; - } - } - - //Copy quads - CurrQuad=0; - for(Quadn=0;QuadnNewPtr; - Quad[CurrQuad].V2=TempQuad[Quadn].V2->NewPtr; - Quad[CurrQuad].V3=TempQuad[Quadn].V3->NewPtr; - Quad[CurrQuad].V4=TempQuad[Quadn].V4->NewPtr; - - //Copy size - Quad[CurrQuad].Size=TempQuad[Quadn].Size; - - //Copy rotation - Quad[CurrQuad].Rotation=TempQuad[Quadn].Rotation; - - //Set Quadmap - //Get quadsize - unsigned long QuadSize=unsigned long(Quad[CurrQuad].Size/Generator.TileSize); - - //Set all the quads to this one - unsigned long Qx, Qy; - for(Qy=0;QyPos_x+float(Vertex[i].Vcol*TileSize-Size/2.0); - float y=Sector->Pos_z+float(Vertex[i].Vrow*TileSize-Size/2.0); - - // Get heights - float topY = BT_Intern_GetPointHeight(Sector->Terrain,x,y-1,Sector->LODLevel->ID,true); - float belowY = BT_Intern_GetPointHeight(Sector->Terrain,x,y+1,Sector->LODLevel->ID,true); - float leftY = BT_Intern_GetPointHeight(Sector->Terrain,x-1,y,Sector->LODLevel->ID,true); - float rightY = BT_Intern_GetPointHeight(Sector->Terrain,x+1,y,Sector->LODLevel->ID,true); - - /* cannot seem to prefer an upward normal when most of the vertex is associated with the ground (not slope) - // if current position has neighbor of same height, it's floor and should reflect in normal - float hereY = BT_Intern_GetPointHeight(Sector->Terrain,x,y,Sector->LODLevel->ID,true); - bool bFlattenAndPointUp = false; - if ( topY < hereY && belowY > hereY ) bFlattenAndPointUp = true; - if ( topY > hereY && belowY < hereY ) bFlattenAndPointUp = true; - if ( leftY < hereY && rightY > hereY ) bFlattenAndPointUp = true; - if ( leftY > hereY && rightY < hereY ) bFlattenAndPointUp = true; - if ( bFlattenAndPointUp==true ) - { - // force upward normal - topY = hereY; - belowY = hereY; - leftY = hereY; - rightY = hereY; - } - */ - - //Work out normal - float Dx=(belowY-topY)/TileSize; - float Dz=(rightY-leftY)/TileSize; - Dx=Dx/Sector->Terrain->Scale*C_BT_INTERNALSCALE; - Dz=Dz/Sector->Terrain->Scale*C_BT_INTERNALSCALE; - float Dy=float(1.0/sqrt(1.0+Dx*Dx+Dz*Dz)); - Vertex[i].Nrm_x=signed char((-Dz*Dy)*127.0); - Vertex[i].Nrm_y=signed char((Dy)*127.0); - Vertex[i].Nrm_z=signed char((-Dx*Dy)*127.0); - } - - /* no creates new seams, worse than the stretchy textures! - // go through each vertex and point upwards if any neighbor is also pointing up :) - int iMaxVertsHere = (QuadsAccross + 1)*(QuadsAccross + 1); - for(unsigned short i=0;i0 && iTop0 && iBottom0 && iLeft0 && iRightHighestPoint){ - HighestPoint=10000; - } - - //Lowest point - if(Vertex[Vertexn].Pos_yCreateBuffer( &bufferDesc, NULL, &DrawBuffer->VertexBuffer ) ) ) - BT_Intern_Error(C_BT_ERROR_CANNOTCREATEVB); - - bufferDesc.ByteWidth = Mesh_Indices*sizeof(unsigned short); - bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; //GGFMT_INDEX16 hmm - if ( FAILED ( m_pD3D->CreateBuffer( &bufferDesc, NULL, &DrawBuffer->IndexBuffer ) ) ) - BT_Intern_Error(C_BT_ERROR_CANNOTCREATEIB); - - bufferDesc.ByteWidth = (QuadsAccross+1)*4*sizeof(unsigned short); - if ( FAILED ( m_pD3D->CreateBuffer( &bufferDesc, NULL, &DrawBuffer->EdgeLineIndexBuffer ) ) ) - BT_Intern_Error(C_BT_ERROR_CANNOTCREATEIB); - #else - - //Generate buffers - if(FAILED(D3DDevice->CreateVertexBuffer(Mesh_Vertices*sizeof(BT_Meshdata_Vertex),D3DUSAGE_WRITEONLY,0,D3DPOOL_DEFAULT,&DrawBuffer->VertexBuffer,NULL))) - BT_Intern_Error(C_BT_ERROR_CANNOTCREATEVB); - - if(FAILED(D3DDevice->CreateIndexBuffer(Mesh_Indices*sizeof(unsigned short),D3DUSAGE_WRITEONLY,GGFMT_INDEX16,D3DPOOL_DEFAULT,&DrawBuffer->IndexBuffer,NULL))) - BT_Intern_Error(C_BT_ERROR_CANNOTCREATEIB); - - if(FAILED(D3DDevice->CreateIndexBuffer((QuadsAccross+1)*4*sizeof(unsigned short),D3DUSAGE_WRITEONLY,GGFMT_INDEX16,D3DPOOL_DEFAULT,&DrawBuffer->EdgeLineIndexBuffer,NULL))) - BT_Intern_Error(C_BT_ERROR_CANNOTCREATEIB); - #endif - - //Set buffer parameters - DrawBuffer->FVF_Size=sizeof(BT_Meshdata_Vertex); - DrawBuffer->Vertices=Mesh_Vertices; - DrawBuffer->Indices=Mesh_Indices; - SetToMesh(DrawBuffer); - - return DrawBuffer; - } - return NULL; -} - -void BT_QuadMap::GenerateDBPMesh(sMesh* Mesh) -{ -//Variables - bool bDeleteMeshData=false; - -//Check that the quadmap is generated - if(Generated==true){ - //Generate mesh data if its not already generated - if(MeshMade==false){ - bDeleteMeshData=true; - GenerateMeshData(); - } - - //Create mesh - BT_Intern_SetupMesh(Mesh,Mesh_Vertices,Mesh_Indices,GGFVF_XYZ|GGFVF_NORMAL|GGFVF_TEX2); - - //Fill mesh vertexdata - if(Mesh->pVertexData==NULL){ - Mesh->pVertexData=(BYTE*)malloc(Mesh_Vertices*sizeof(BT_Meshdata_Vertex)); - if(Mesh->pVertexData==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - Mesh->pIndices=(WORD*)malloc(Mesh_Indices*sizeof(unsigned short)); - if(Mesh->pIndices==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - Mesh->dwVertexCount=Mesh_Vertices; - Mesh->dwIndexCount=Mesh_Indices; - } - - memcpy(Mesh->pVertexData,Mesh_Vertex,Mesh_Vertices*sizeof(BT_Meshdata_Vertex)); - memcpy(Mesh->pIndices,Mesh_Index,Mesh_Indices*sizeof(unsigned short)); - Mesh->bVBRefreshRequired=true; - - //Delete mesh data if created - if(bDeleteMeshData) - DeleteMeshData(); - } -} - -void BT_QuadMap::UpdateDBPMesh(sMesh* Mesh) -{ -//Variables - bool bDeleteMeshData=false; - -//Check that the quadmap is generated - if(Generated==true){ - //Generate mesh data if its not already generated - if(MeshMade==false){ - bDeleteMeshData=true; - GenerateMeshData(); - } - - memcpy(Mesh->pVertexData,Mesh_Vertex,Mesh_Vertices*sizeof(BT_Meshdata_Vertex)); - memcpy(Mesh->pIndices,Mesh_Index,Mesh_Indices*sizeof(unsigned short)); - Mesh->bVBRefreshRequired=true; - - //Delete mesh data if created - if(bDeleteMeshData) - DeleteMeshData(); - } -} - -void BT_QuadMap::SetToMesh(s_BT_DrawBuffer* DrawBuffer) -{ -//Check that the quadmap is generated - if(Generated==true){ - bool DeleteData=false; - if(MeshMade==false){ - DeleteData=true; - GenerateMeshData(); - } - BT_Intern_RefreshVB(DrawBuffer,0,Mesh_Vertices,Mesh_Vertex); - BT_Intern_RefreshIB(DrawBuffer,0,Mesh_Indices,Mesh_Index); - - #ifdef DX11 - // lock and fill in edge index buffer for DX11 - #else - //Update Edges - unsigned short* LockedIndex; - - //Lock indexdata - DrawBuffer->EdgeLineIndexBuffer->Lock(0,(QuadsAccross+1)*4*sizeof(unsigned short),(void**)&LockedIndex,NULL); - - //Fill indexdata - DrawBuffer->EdgeIndexCount=0; - - //Fill top - int i; - for(i=0;iExclude==false){ - LockedIndex[DrawBuffer->EdgeIndexCount]=Quad->V1->Index; - DrawBuffer->EdgeIndexCount++; - LockedIndex[DrawBuffer->EdgeIndexCount]=Quad->V2->Index; - DrawBuffer->EdgeIndexCount++; - } - } - } - //Fill right - for(i=0;iExclude==false){ - LockedIndex[DrawBuffer->EdgeIndexCount]=Quad->V2->Index; - DrawBuffer->EdgeIndexCount++; - LockedIndex[DrawBuffer->EdgeIndexCount]=Quad->V4->Index; - DrawBuffer->EdgeIndexCount++; - } - } - } - - //Unlock indexdata - DrawBuffer->EdgeLineIndexBuffer->Unlock(); - #endif - - DrawBuffer->Primitives=(unsigned short)Mesh_Indices/3; - DrawBuffer->Vertices=Mesh_Vertices; - if(DeleteData==true) - DeleteMeshData(); - } -} - -void BT_QuadMap::UpdateMesh(s_BT_DrawBuffer* DrawBuffer,bool ClearUpdateInfo) -{ -//Check that the quadmap is generated - if(Generated==true){ - if(RefreshNormals) - { - // Recalculate normals - CalculateNormals(); - RefreshNormals = false; - - // Copy new normals data into mesh - for(unsigned int CurrentVertex=0;CurrentVertex<=this->Vertices;CurrentVertex++) - { - Mesh_Vertex[CurrentVertex].Nrm_x=float(Vertex[CurrentVertex].Nrm_x/127.0); - Mesh_Vertex[CurrentVertex].Nrm_y=float(Vertex[CurrentVertex].Nrm_y/127.0); - Mesh_Vertex[CurrentVertex].Nrm_z=float(Vertex[CurrentVertex].Nrm_z/127.0); - } - } - - //Update vertices - if(UpdateVertexBuffer==true){ - //BT_Intern_RefreshVB(DrawBuffer,UpdateFirstVertex,UpdateLastVertex,Mesh_Vertex); - BT_Intern_RefreshVB(DrawBuffer,0,Mesh_Vertices,Mesh_Vertex); - DrawBuffer->Vertices=Mesh_Vertices; - } - - //Update indices - if(UpdateIndexBuffer==true){ - BT_Intern_RefreshIB(DrawBuffer,0,Mesh_Indices,Mesh_Index); - DrawBuffer->Primitives=(unsigned short)Mesh_Indices/3; - } - } - -//Clear update info - if(ClearUpdateInfo==true){ - UpdateVertexBuffer=false; - UpdateIndexBuffer=false; - } -} - - -void BT_QuadMap::GenerateMeshData() -{ -//Variables - unsigned long CurrentVertex; - unsigned long CurrentIndex; - unsigned long CurrentQuad; - -//Check that the quadmap is generated - if(Generated==true){ - //Create mesh if not made - if(MeshMade==false){ - Mesh_Vertex=(BT_Meshdata_Vertex*)malloc((Vertices+1)*sizeof(BT_Meshdata_Vertex)); - if(Mesh_Vertex==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - Mesh_Index=(unsigned short*)malloc(Quads*6*sizeof(unsigned short)); - if(Mesh_Index==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - MeshMade=true; - UpdateVertices=true; - UpdateIndices=true; - } - - //Update Vertices - if(UpdateVertices==true){ - float Scale=Sector->Terrain->Scale/C_BT_INTERNALSCALE; - float TerrainSize=Sector->Terrain->TerrainSize*Scale; - float SectorSize=Sector->LODLevel->SectorSize*Scale; - for(CurrentVertex=0;CurrentVertex<=Vertices;CurrentVertex++) - { - //Position - //lee - 220914 - produced GAPS between vertices!! Lightmapper found them. - Mesh_Vertex[CurrentVertex].Pos_x=float((Vertex[CurrentVertex].Vcol*TileSize-Size/2.0)/C_BT_INTERNALSCALE*Sector->Terrain->Scale); - Mesh_Vertex[CurrentVertex].Pos_y=Vertex[CurrentVertex].Pos_y; - Mesh_Vertex[CurrentVertex].Pos_z=float((Vertex[CurrentVertex].Vrow*TileSize-Size/2.0)/C_BT_INTERNALSCALE*Sector->Terrain->Scale); - - //Normals - Mesh_Vertex[CurrentVertex].Nrm_x=float(Vertex[CurrentVertex].Nrm_x/127.0); - Mesh_Vertex[CurrentVertex].Nrm_y=float(Vertex[CurrentVertex].Nrm_y/127.0); - Mesh_Vertex[CurrentVertex].Nrm_z=float(Vertex[CurrentVertex].Nrm_z/127.0); - - //UVs - if(Sector->Terrain->ATMode){ - Mesh_Vertex[CurrentVertex].U0=(Sector->Pos_x*Scale+Mesh_Vertex[CurrentVertex].Pos_x)/TerrainSize; - Mesh_Vertex[CurrentVertex].V0=1.0f-(Sector->Pos_z*Scale+Mesh_Vertex[CurrentVertex].Pos_z)/TerrainSize; - }else{ - Mesh_Vertex[CurrentVertex].U0=(Sector->Pos_x*Scale+Mesh_Vertex[CurrentVertex].Pos_x)/TerrainSize; - Mesh_Vertex[CurrentVertex].V0=(Sector->Pos_z*Scale+Mesh_Vertex[CurrentVertex].Pos_z)/TerrainSize; - } - Mesh_Vertex[CurrentVertex].U1=Mesh_Vertex[CurrentVertex].U0*Sector->Terrain->LODLevel[0].Split*Sector->Terrain->Tile; - Mesh_Vertex[CurrentVertex].V1=Mesh_Vertex[CurrentVertex].V0*Sector->Terrain->LODLevel[0].Split*Sector->Terrain->Tile; - } - Mesh_Vertices=Vertices; - UpdateVertices=false; - } - - //Update indices - if(UpdateIndices==true){ - CurrentIndex=0; - for(CurrentQuad=0;CurrentQuadIndex; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V3->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V2->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V4->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V2->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V3->Index; - }else{ - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V1->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V3->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V4->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V1->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V4->Index; - Mesh_Index[CurrentIndex++]=Quad[CurrentQuad].V2->Index; - } - } - } - Mesh_Indices=CurrentIndex; - - //Edges - UpdateIndices=false; - } - } -} - -void BT_QuadMap::DeleteMeshData() -{ -//Check that the quadmap is generated - if(Generated==true){ - if(MeshMade==true){ - MeshMade=false; - free(Mesh_Vertex); - free(Mesh_Index); - Mesh_Vertices=0; - Mesh_Indices=0; - } - } -} - - - -bool BT_QuadMap::GetPointExcluded(float x,float z) -{ -//Variables - float U; - float V; - unsigned long Row; - unsigned long Collumn; - BT_Quadmap_Quad* cQuad; - -//Check that the quadmap is generated - if(Generated==true){ - //Find position on quadmap - U=float((x+Size*0.5)/Size); - V=float((z+Size*0.5)/Size); - - //Find row and collumn - Row=unsigned long(floor(V*QuadsAccross)); - Collumn=unsigned long(floor(U*QuadsAccross)); - - //Work out the quad number - cQuad=QuadMap[unsigned long(QuadsAccross*Row+Collumn)]; - - //Check that the quad exists - if(cQuad==NULL) - return true; - - //Return false - return false; - } - return true; -} - - - -float BT_QuadMap::GetPointHeight(float x,float z,bool Round) -{ -//Variables - float U; - float V; - unsigned short Row; - unsigned short Collumn; - float Px; - float Pz; - BT_Quadmap_Quad* cQuad; - bool Tile; - float Dx; - float Dy; - float Dz; - -//Check that the quadmap is generated - if(Generated==true){ - //Find position on quadmap - U=float((x+Size*0.5)/Size); - V=float((z+Size*0.5)/Size); - - //Find row and collumn - Row=unsigned short(floor(V*QuadsAccross)); - Collumn=unsigned short(floor(U*QuadsAccross)); - - if(V==1.00f) - Row--; - if(U==1.00f) - Collumn--; - - //Work out the quad number - cQuad=QuadMap[unsigned long(QuadsAccross*Row+Collumn)]; - - //Check that the quad exists - if(cQuad==NULL) - return 0.0; - - //Scale - float Scale=cQuad->Size/TileSize; - - //Find the position on the quad - Px=((U*QuadsAccross)-cQuad->V1->Vcol)/Scale; - Pz=((V*QuadsAccross)-cQuad->V1->Vrow)/Scale; - - //Work out height - if(Round){ - return cQuad->V1->Pos_y; - }else{ - Tile=0; - if(cQuad->Rotation){ - Tile=!(PxV4->Pos_y-cQuad->V3->Pos_y); - Dz=(cQuad->V2->Pos_y-cQuad->V4->Pos_y); - }else{ - Dx=(cQuad->V2->Pos_y-cQuad->V1->Pos_y); - Dz=(cQuad->V1->Pos_y-cQuad->V3->Pos_y); - } - Pz=1-Pz; - Dy=cQuad->V3->Pos_y; - }else{ - Tile=Px>Pz; - if(Tile==true){ - Dx=(cQuad->V2->Pos_y-cQuad->V1->Pos_y); - Dz=(cQuad->V4->Pos_y-cQuad->V2->Pos_y); - }else{ - Dx=(cQuad->V4->Pos_y-cQuad->V3->Pos_y); - Dz=(cQuad->V3->Pos_y-cQuad->V1->Pos_y); - } - Dy=cQuad->V1->Pos_y; - } - - //Return height - return Dx*Px+Dz*Pz+Dy; - } - } - return 0.0; -} - -void BT_QuadMap::SetSideLOD(unsigned char Side,unsigned long LODLevel) -{ -//Check that the quadmap is generated - if(Generated==true){ - //Find first vertex - unsigned short SideFirstVertex=Side*QuadsAccross; - float InterpMin=0.0f; - float InterpMax=0.0f; - unsigned char LODTileSpan=1<Internals)->DeleteMeshData=false; - Meshdata->VertexCount=0; - Meshdata->Vertices=NULL; - if(MeshMade==false){ - ((BT_RTTMS_STRUCTINTERNALS*)Meshdata->Internals)->DeleteMeshData=true; - GenerateMeshData(); - } - Meshdata->VertexCount=Mesh_Vertices; - Meshdata->Vertices=(float*)malloc(Mesh_Vertices*sizeof(float)); - for(unsigned short Vertexn=0;VertexnVertices[Vertexn]=Vertex[Vertexn].Pos_y; - Meshdata->ChangedAVertex=false; - Meshdata->FirstUpdatedVertex=0; - Meshdata->LastUpdatedVertex=0; - } -} - -void BT_QuadMap::ChangeMeshData(unsigned short VertexStart,unsigned short VertexEnd,float* Vertices) -{ -//Check that the quadmap is generated - if(Generated==true){ - //Update vertex buffer - UpdateVertexBuffer=true; - - //Copy data back into the quadmap structures - for(unsigned short Vertexn=VertexStart;VertexnPos_y; - p12=Quads[QuadTL].V2->Pos_y; - p13=Quads[QuadTR].V2->Pos_y; - p21=Quads[QuadTL].V3->Pos_y; - p22=Quads[QuadTL].V4->Pos_y; - p23=Quads[QuadTR].V3->Pos_y; - p31=Quads[QuadBL].V3->Pos_y; - p32=Quads[QuadBL].V4->Pos_y; - p33=Quads[QuadBR].V4->Pos_y; - - //Check that they are all the same height - if (p11 != p12) - return; - if (p11 != p13) - return; - if (p11 != p21) - return; - if (p11 != p22) - return; - if (p11 != p23) - return; - if (p11 != p31) - return; - if (p11 != p32) - return; - if (p11 != p33) - return; - } - -// Reduce the quad - // Exclude all but top left - Quads[QuadTR].Exclude=true; - Quads[QuadBL].Exclude=true; - Quads[QuadBR].Exclude=true; - - // Stretch top left to cover the full size of the new quad - Quads[QuadTL].V2=Quads[QuadTR].V2; - Quads[QuadTL].V3=Quads[QuadBL].V3; - Quads[QuadTL].V4=Quads[QuadBR].V4; - Quads[QuadTL].Size*=2; -} - -unsigned short BT_QuadMap::FindVertex(unsigned short Vcol,unsigned short Vrow) -{ -//Check that the quadmap is generated - if(Generated==true){ - //Find the vertex - BT_Quadmap_Vertex* Vertex; - if(Vrow==QuadsAccross){ - if(Vcol==QuadsAccross){ - Vertex=QuadMap[unsigned long(QuadsAccross*(Vrow-1)+(Vcol-1))]->V4; - }else{ - Vertex=QuadMap[unsigned long(QuadsAccross*(Vrow-1)+Vcol)]->V3; - } - }else{ - if(Vcol==QuadsAccross){ - Vertex=QuadMap[unsigned long(QuadsAccross*Vrow+(Vcol-1))]->V2; - }else{ - Vertex=QuadMap[unsigned long(QuadsAccross*Vrow+Vcol)]->V1; - } - } - - //Check that the vertex is in the same position - if(Vertex->Vrow==Vrow && Vertex->Vcol==Vcol){ - //Return the index - return Vertex->Index+1; - } - } - -//Return nothing - return 0; -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/quadmapping.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/quadmapping.h deleted file mode 100644 index c7327f1..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/quadmapping.h +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef _QUADMAP_H -#define _QUADMAP_H - -///struct GGVECTOR4; -struct s_BT_Sector; - -struct BT_Quadmap_Generator -{ - bool QuadRotation; - bool QuadReduction; - float TileSize; - unsigned char Size; - float* heights; - bool* exclusion; - unsigned char TileSpan; - bool Optimise; - s_BT_Sector* Sector; - unsigned long LODLevel; - bool RemoveFarX; - bool RemoveFarZ; -}; - -struct BT_Quadmap_Vertex -{ - //Exclude - bool Exclude; - - //Position - float Pos_y; - unsigned char Vrow,Vcol; - - //Normals - signed char Nrm_x, Nrm_y, Nrm_z; - - //Index - unsigned short Index; - BT_Quadmap_Vertex* NewPtr; - -}; - -struct BT_Quadmap_Edge -{ - char Edge; //0 - top, 1 - right,2 - bottom,3 - left - unsigned char Position; - BT_Quadmap_Vertex* Vertex; -}; - -struct BT_Quadmap_Quad -{ - //Exclude - bool Exclude; - - //Vertices - BT_Quadmap_Vertex* V1; - BT_Quadmap_Vertex* V2; - BT_Quadmap_Vertex* V3; - BT_Quadmap_Vertex* V4; - - //Size - float Size; - - //Rotation - bool Rotation; -}; - -struct BT_Meshdata_Vertex -{ - //Position - float Pos_x,Pos_y,Pos_z; - - //Normals - float Nrm_x,Nrm_y,Nrm_z; - - //UVs - float U0,V0,U1,V1; -}; - -struct s_BT_DrawBuffer; -struct BT_SectorMeshData; - -#include "rttms.h" -struct BT_RTTMS_STRUCT; -struct BT_RTTMS_VERTEX; - -class BT_QuadMap -{ -public: - void Generate(BT_Quadmap_Generator Generator); - void CalculateNormals(); - void CalculateBounds(); - void GenerateMeshData(); - void DeleteMeshData(); - void SetToMesh(s_BT_DrawBuffer* DrawBuffer); - void UpdateMesh(s_BT_DrawBuffer* DrawBuffer,bool ClearUpdateInfo); - unsigned long GetVertexCount() {return Mesh_Vertices;} - unsigned long GetIndexCount() {return Mesh_Indices;} - s_BT_DrawBuffer* GeneratePlain(); - void GenerateDBPMesh(sMesh* Mesh); - void UpdateDBPMesh(sMesh* Mesh); - bool GetPointExcluded(float x,float z); - float GetPointHeight(float x,float y,bool Round); - void SetSideLOD(unsigned char Side,unsigned long LODLevel); - float GetHighestPoint() {return HighestPoint;} - float GetLowestPoint() {return LowestPoint;} - void FillMeshData(BT_RTTMS_STRUCT* Meshdata); - void DeleteInternalData(); - void ReduceQuad(unsigned short QuadTL,unsigned short QuadTR,unsigned short QuadBL,unsigned short QuadBR,BT_Quadmap_Quad* Quads, bool CheckHeights); - void ChangeMeshData(unsigned short VertexStart,unsigned short VertexEnd,float* Vertices); - unsigned short FindVertex(unsigned short Vrow,unsigned short Vcol); - - BT_QuadMap* Above; - BT_QuadMap* Below; - BT_QuadMap* Left; - BT_QuadMap* Right; - -private: - //Generated boolean - bool Generated; - - //Vertex list - BT_Quadmap_Vertex* Vertex; - - //Quad list - BT_Quadmap_Quad* Quad; - - //QuadMap - BT_Quadmap_Quad** QuadMap; - - //Mesh data - bool MeshMade; - unsigned short Mesh_Vertices; - unsigned long Mesh_Indices; - BT_Meshdata_Vertex* Mesh_Vertex; - unsigned short* Mesh_Index; - - //Mesh updates - bool UpdateVertices; - bool UpdateIndices; - bool RefreshNormals; - - //Buffer updates - bool UpdateVertexBuffer; - bool UpdateIndexBuffer; - - //Sizes - unsigned short Vertices; - unsigned short Quads; - float Size; - float TileSize; - unsigned char TileSpan; - unsigned char QuadsAccross; - - //Highest and lowest points - float HighestPoint; - float LowestPoint; - - //Optimisation - bool Optimised; - - //Sector ID - s_BT_Sector* Sector; -}; - -void BT_Intern_StartQuadMapGeneration(BT_Quadmap_Generator Generator); -void BT_Intern_EndQuadMapGeneration(); - -struct BT_QuadMap_Main -{ - bool Locked; - BT_Quadmap_Vertex* TempVertexdata; - BT_Quadmap_Quad* TempQuaddata; - BT_Quadmap_Vertex*** TempVertexMap; - unsigned long TempVertices; - unsigned long TempQuads; -}; - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/resource.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/resource.h deleted file mode 100644 index df24636..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/resource.h +++ /dev/null @@ -1,66 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Resource.rc -// -#define IDS_STRING101 101 -#define IDS_STRING102 102 -#define IDS_STRING103 103 -#define IDS_STRING104 104 -#define IDS_STRING105 105 -#define IDS_STRING106 106 -#define IDS_STRING107 107 -#define IDS_STRING108 108 -#define IDS_STRING109 109 -#define IDS_STRING110 110 -#define IDS_STRING111 111 -#define IDS_STRING112 112 -#define IDS_STRING113 113 -#define IDS_STRING114 114 -#define IDS_STRING115 115 -#define IDS_STRING116 116 -#define IDS_STRING117 117 -#define IDS_STRING118 118 -#define IDS_STRING119 119 -#define IDS_STRING120 120 -#define IDS_STRING121 121 -#define IDS_STRING122 122 -#define IDS_STRING123 123 -#define IDS_STRING124 124 -#define IDS_STRING125 125 -#define IDS_STRING126 126 -#define IDS_STRING127 127 -#define IDS_STRING128 128 -#define IDS_STRING129 129 -#define IDS_STRING130 130 -#define IDS_STRING131 131 -#define IDS_STRING132 132 -#define IDS_STRING133 133 -#define IDS_STRING134 134 -#define IDS_STRING135 135 -#define IDS_STRING136 136 -#define IDS_STRING137 137 -#define IDS_STRING138 138 -#define IDS_STRING139 139 -#define IDS_STRING140 140 -#define IDS_STRING141 141 -#define IDS_STRING142 142 -#define IDS_STRING143 143 -#define IDS_STRING144 144 -#define IDS_STRING145 145 -#define IDS_STRING146 146 -#define IDS_STRING147 147 -#define IDS_STRING153 148 -#define IDS_STRING149 149 -#define IDS_STRING150 150 -#define IDS_STRING151 151 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/rttms.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/rttms.cpp deleted file mode 100644 index 8e0acf1..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/rttms.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "rttms.h" -#include - -extern s_BT_main BT_Main; - -#ifdef C_BT_FULLVERSION -BT_RTTMS_UpdateHandler_t* BT_RTTMS_UpdateHandlers[C_BT_MAXTERRAINS]={0}; -unsigned long BT_RTTMS_UpdateHandlerCount[C_BT_MAXTERRAINS]={0}; -#endif - -void BT_RTTMS_AddUpdateHandler(unsigned long TerrainID,BT_RTTMS_UpdateHandler_t UpdateHandler) -{ -#ifdef C_BT_FULLVERSION -//Increase update handler count - BT_RTTMS_UpdateHandlerCount[TerrainID]++; - -//Allocate new update handler list - if(BT_RTTMS_UpdateHandlers[TerrainID]==NULL){ - BT_RTTMS_UpdateHandlers[TerrainID]=(BT_RTTMS_UpdateHandler_t*)malloc(sizeof(BT_RTTMS_UpdateHandler_t)*BT_RTTMS_UpdateHandlerCount[TerrainID]); - if(BT_RTTMS_UpdateHandlers[TerrainID]==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - }else{ - BT_RTTMS_UpdateHandlers[TerrainID]=(BT_RTTMS_UpdateHandler_t*)realloc(BT_RTTMS_UpdateHandlers[TerrainID],sizeof(BT_RTTMS_UpdateHandler_t)*BT_RTTMS_UpdateHandlerCount[TerrainID]); - if(BT_RTTMS_UpdateHandlers[TerrainID]==nullptr) - BT_Intern_Error(C_BT_ERROR_MEMORYERROR); - } - -//Set new update handler - BT_RTTMS_UpdateHandlers[TerrainID][BT_RTTMS_UpdateHandlerCount[TerrainID]-1]=UpdateHandler; -#endif -} - -static void BT_RTTMS_CallUpdateHandlers(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID,unsigned short StartVertex,unsigned short EndVertex,float* Vertices) -{ -#ifdef C_BT_FULLVERSION -//Loop through update handlers and call each one - for(unsigned long i=1;i<=BT_RTTMS_UpdateHandlerCount[TerrainID];i++) - BT_RTTMS_UpdateHandlers[TerrainID][i-1](TerrainID,LODLevelID,SectorID,StartVertex,EndVertex,Vertices); -#endif -} - -void BT_RTTMS_DeleteUpdateHandlers(unsigned long TerrainID) -{ -#ifdef C_BT_FULLVERSION -//Delete update handlers - if(BT_RTTMS_UpdateHandlerCount[TerrainID]!=0){ - free(BT_RTTMS_UpdateHandlers[TerrainID]); - BT_RTTMS_UpdateHandlers[TerrainID]=NULL; - BT_RTTMS_UpdateHandlerCount[TerrainID]=0; - } -#endif -} - -void* BT_RTTMS_LockSectorVertexData(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID) -{ -//Check that the data exists - if(BT_Intern_TerrainExist(TerrainID)==false) - return NULL; - s_BT_terrain* Terrain=&BT_Main.Terrains[TerrainID]; - if(Terrain->Built==false) - return NULL; - if(LODLevelID>=Terrain->LODLevels) - return NULL; - if(SectorID>=Terrain->LODLevel[LODLevelID].Sectors) - return NULL; - if(Terrain->LODLevel[LODLevelID].Sector[SectorID].VertexDataLocked==true) - return (void*)Terrain->LODLevel[LODLevelID].Sector[SectorID].VertexDataRTTMS; - -//Get struct - BT_RTTMS_STRUCT* RTTMSStruct=Terrain->LODLevel[LODLevelID].Sector[SectorID].VertexDataRTTMS; - -//Lock vertexdata - Terrain->LODLevel[LODLevelID].Sector[SectorID].VertexDataLocked=true; - -//Fill RTTMSStruct - Terrain->LODLevel[LODLevelID].Sector[SectorID].QuadMap->FillMeshData(RTTMSStruct); - -//Return - return (void*)RTTMSStruct; -} - - -void BT_RTTMS_UnlockSectorVertexData(void* StructPtr) -{ -//Get struct - BT_RTTMS_STRUCT* RTTMSStruct=(BT_RTTMS_STRUCT*)StructPtr; - BT_RTTMS_STRUCTINTERNALS* RTTMSStructInternals=(BT_RTTMS_STRUCTINTERNALS*)RTTMSStruct->Internals; - -//Unlock vertexdata - RTTMSStructInternals->SectorPtr->VertexDataLocked=false; - -//(full version only) If the vertexdata was updated, send the new vertexdata around -#ifdef C_BT_FULLVERSION - if(RTTMSStruct->ChangedAVertex==true) - BT_RTTMS_CallUpdateHandlers(RTTMSStructInternals->TerrainID,RTTMSStructInternals->LODLevelID,RTTMSStructInternals->SectorID,RTTMSStruct->FirstUpdatedVertex,RTTMSStruct->LastUpdatedVertex,RTTMSStruct->Vertices); -#endif - -//Delete Vertices - free(RTTMSStruct->Vertices); - -//Delete mesh data if it has to be deleted - if(RTTMSStructInternals->DeleteMeshData==true) - { - RTTMSStructInternals->SectorPtr->QuadMap->DeleteMeshData(); - } -} - -unsigned short BT_RTTMS_FindVertex(void* StructPtr,unsigned short Vrow,unsigned short Vcol) -{ -//Get struct - BT_RTTMS_STRUCT* RTTMSStruct=(BT_RTTMS_STRUCT*)StructPtr; - BT_RTTMS_STRUCTINTERNALS* RTTMSStructInternals=(BT_RTTMS_STRUCTINTERNALS*)RTTMSStruct->Internals; - -//Return vertexid - return RTTMSStructInternals->SectorPtr->QuadMap->FindVertex(Vrow,Vcol); -} - - -void BT_RTTMS_UnlockTerrain(s_BT_terrain* TerrainPtr) -{ - for(unsigned char LODLevel=0;LODLevelLODLevels;LODLevel++) - { - s_BT_LODLevel* LODLevelPtr=&TerrainPtr->LODLevel[LODLevel]; - for(unsigned short Sector=0;SectorSectors;Sector++) - { - s_BT_Sector* SectorPtr=&LODLevelPtr->Sector[Sector]; - if(SectorPtr->Excluded!=true && SectorPtr->VertexDataLocked) - { - BT_RTTMS_UnlockSectorVertexData((void*)SectorPtr->VertexDataRTTMS); - } - } - } -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/rttms.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/rttms.h deleted file mode 100644 index 25691f3..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain/rttms.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _RTTMS_H -#define _RTTMS_H - -#include "main.h" - -struct BT_RTTMS_STRUCT -{ -//Counts - unsigned short VertexCount; - -//Data - float* Vertices; - -//Updated vertices - bool ChangedAVertex; - unsigned short FirstUpdatedVertex; - unsigned short LastUpdatedVertex; - -//Internals - void* Internals; -}; - -struct BT_RTTMS_STRUCTINTERNALS -{ -//Terrain, LODLevel and Sector - unsigned long TerrainID; - unsigned long LODLevelID; - unsigned long SectorID; - -//Sector pointer - s_BT_Sector* SectorPtr; - -//Delete meshdata - bool DeleteMeshData; -}; - -typedef void(*BT_RTTMS_UpdateHandler_t)(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID,unsigned short StartVertex,unsigned short EndVertex,float* Vertices); - -void BT_RTTMS_AddUpdateHandler(unsigned long TerrainID,BT_RTTMS_UpdateHandler_t UpdateHandler); -static void BT_RTTMS_CallUpdateHandlers(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID,unsigned short StartVertex,unsigned short EndVertex,float* Vertices); -void BT_RTTMS_DeleteUpdateHandlers(unsigned long TerrainID); -void* BT_RTTMS_LockSectorVertexData(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID); -void BT_RTTMS_UnlockSectorVertexData(void* StructPtr); -unsigned short BT_RTTMS_FindVertex(void* StructPtr,unsigned short Vrow,unsigned short Vcol); -struct s_BT_terrain; -void BT_RTTMS_UnlockTerrain(s_BT_terrain* TerrainPtr); - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj deleted file mode 100644 index ae0780d..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj +++ /dev/null @@ -1,306 +0,0 @@ - - - - - Debug GAME - Win32 - - - Debug GAME - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {205846E1-5ECC-4E71-81CB-3CB34045ADA2} - BlitzTerrain_RTTMSPlugin - Win32Proj - 10.0.17763.0 - - - - StaticLibrary - MultiByte - true - v141 - - - StaticLibrary - MultiByte - true - v141 - - - StaticLibrary - MultiByte - v141 - - - StaticLibrary - MultiByte - v141 - - - StaticLibrary - MultiByte - v141 - - - StaticLibrary - MultiByte - v141 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(ProjectDir)..\..\..\Lib\ - $(ProjectDir)..\..\..\Lib\ - $(Configuration)\ - $(Configuration)\ - true - true - true - true - $(ProjectDir)..\..\..\Lib\ - $(Configuration)\ - false - false - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI; - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI; - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI; - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI; - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) - - - $(ProjectDir)..\..\..\Lib64\ - - - $(ProjectDir)..\..\..\Lib64\ - - - $(ProjectDir)..\..\..\Lib64\ - - - - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_RTTMSPLUGIN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - true - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - 4005 - - - true - Windows - MachineX86 - true - F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\$(TargetName)$(TargetExt) - - - - - MachineX86 - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_RTTMSPLUGIN_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - true - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - 4005 - - - true - Windows - MachineX86 - true - F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\$(TargetName)$(TargetExt) - - - - - MachineX86 - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_RTTMSPLUGIN_EXPORTS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - true - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - 4005 - - - true - Windows - true - F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\$(TargetName)$(TargetExt) - - - - - MachineX64 - - - - - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_RTTMSPLUGIN_EXPORTS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - true - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - 4005 - - - true - Windows - true - F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\$(TargetName)$(TargetExt) - - - - - MachineX64 - - - - - MaxSpeed - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_RTTMSPLUGIN_EXPORTS;%(PreprocessorDefinitions) - MultiThreaded - true - - - Level3 - ProgramDatabase - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - StreamingSIMDExtensions - false - 4005;4995;4723 - - - true - Windows - true - true - MachineX86 - - - MachineX86 - - - - - MaxSpeed - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;BLITZTERRAIN_RTTMSPLUGIN_EXPORTS;%(PreprocessorDefinitions) - MultiThreaded - true - - - Level3 - ProgramDatabase - %(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\ - StreamingSIMDExtensions - false - 4005;4995;4723 - - - true - Windows - true - true - - - MachineX64 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj.filters b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj.filters deleted file mode 100644 index a1196ee..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj.filters +++ /dev/null @@ -1,53 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj.user b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj.user deleted file mode 100644 index be25078..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/BlitzTerrain_RTTMSPlugin.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/brush.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/brush.cpp deleted file mode 100644 index 5569150..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/brush.cpp +++ /dev/null @@ -1,432 +0,0 @@ -#include "brush.h" -#include - -#include "BlitzTerrain.h" - -void BT_SetPointHeight(unsigned long TerrainID,unsigned long TVrow,unsigned long TVcol,float Height) -{ -//Check that the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - //Get terrain info - BT_TerrainInfo* TerrainInfo=(BT_TerrainInfo*)BT_GetTerrainInfo(TerrainID); - - //Check that the terrain is built and generated - if(TerrainInfo->Built==true && TerrainInfo->Generated==true) - { - //Check that the point is on the terrain - if(TVrow>=0 && TVrow<=TerrainInfo->Heightmapsize && TVcol>=0 && TVcol<=TerrainInfo->Heightmapsize) - { - //Loop through LODLevels - bool Break=false; - unsigned char LODLevel=0; - do{ - //Get LODLevel info - BT_LODLevelInfo* LODLevelInfo=(BT_LODLevelInfo*)BT_GetLODLevelInfo(TerrainID,LODLevel); - - //Find which sector(s) the point is on - unsigned short TwoPowerLODLevel=unsigned short(pow(2.0f,float(LODLevel))); - unsigned short Vrow=unsigned short(TVrow/TwoPowerLODLevel); - unsigned short Vcol=unsigned short(TVcol/TwoPowerLODLevel); - if(Vrow*TwoPowerLODLevel!=TVrow || Vcol*TwoPowerLODLevel!=TVcol) - { - Break=true; - }else{ - unsigned short Srow=unsigned short(Vrow/float(LODLevelInfo->SectorDetail)); - unsigned short Scol=unsigned short(Vcol/float(LODLevelInfo->SectorDetail)); - bool LeftSide=false; - bool TopSide=false; - if(Srow*LODLevelInfo->SectorDetail==Vrow) - TopSide=true; - if(Scol*LODLevelInfo->SectorDetail==Vcol) - LeftSide=true; - - /* - BT_UnlockVertexData(); - BT_LockVertexdataForSector(TerrainID,LODLevel,Srow*LODLevelInfo->Split+Scol); - int x,z; - for(x=0;x<=LODLevelInfo->SectorDetail;x++){ - for(z=0;z<=LODLevelInfo->SectorDetail;z++){ - BT_SetVertexHeight(x,z,Height); - } - } - BT_UnlockVertexData(); - */ - - //Set the height of the point on this sector - BT_UnlockVertexData(); - BT_LockVertexdataForSector(TerrainID,LODLevel,Srow*LODLevelInfo->Split+Scol); - Vrow=Vrow-Srow*LODLevelInfo->SectorDetail; - Vcol=Vcol-Scol*LODLevelInfo->SectorDetail; - BT_SetVertexHeight(Vrow,Vcol,Height); - BT_UnlockVertexData(); - - //Set the height of the point on the left sector - if(LeftSide==true && Scol>0) - { - BT_UnlockVertexData(); - BT_LockVertexdataForSector(TerrainID,LODLevel,Srow*LODLevelInfo->Split+(Scol-1)); - BT_SetVertexHeight(Vrow,LODLevelInfo->SectorDetail,Height); - BT_UnlockVertexData(); - } - - //Set the height of the point on the top sector - if(TopSide==true && Srow>0) - { - BT_UnlockVertexData(); - BT_LockVertexdataForSector(TerrainID,LODLevel,(Srow-1)*LODLevelInfo->Split+Scol); - BT_SetVertexHeight(LODLevelInfo->SectorDetail,Vcol,Height); - BT_UnlockVertexData(); - } - - //Set the height of the point on the top left sector - if(LeftSide==true && TopSide==true && Srow>0 && Scol>0) - { - BT_UnlockVertexData(); - BT_LockVertexdataForSector(TerrainID,LODLevel,(Srow-1)*LODLevelInfo->Split+(Scol-1)); - BT_SetVertexHeight(LODLevelInfo->SectorDetail,LODLevelInfo->SectorDetail,Height); - BT_UnlockVertexData(); - } - - //Increase LODLevel - LODLevel++; - if(LODLevel==TerrainInfo->LODLevels) - Break=true; - } - }while(Break==false); - } - } - } -} - -void BT_SetGroundHeight(unsigned long TerrainID,float X,float Z,float Height) -{ -//Check that the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - //Get terrain info - BT_TerrainInfo* TerrainInfo=(BT_TerrainInfo*)BT_GetTerrainInfo(TerrainID); - - //Check that the terrain is built and generated - if(TerrainInfo->Built==true && TerrainInfo->Generated==true) - { - //Set the height - BT_SetPointHeight(TerrainID,unsigned short((X/TerrainInfo->Scale)+0.5),unsigned short((Z/TerrainInfo->Scale)+0.5),Height); - } - } -} - - - -//CIRCLE BRUSHES - -typedef float(*CircleBrush_t)(float XDist,float ZDist,float MidHeight,float Radius,float Amount,float CurrentHeight,float CapHeight); - -static void BT_CircleBrush(unsigned long TerrainID,float X,float Z,float Radius,float Amount,CircleBrush_t BrushFunc,bool GetMidHeight,float CapHeight) -{ -//Check that the terrain exists - if(BT_Intern_TerrainExist(TerrainID)) - { - //Get terrain info - BT_TerrainInfo* TerrainInfo=(BT_TerrainInfo*)BT_GetTerrainInfo(TerrainID); - - //Check that the terrain is built and generated - if(TerrainInfo->Built==true && TerrainInfo->Generated==true) - { - //Get mid height - float MidHeight=0.0; - -#ifdef COMPILE_GDK - if(GetMidHeight==true) - MidHeight=BT_GetGroundHeight(TerrainID,X,Z); -#else - if(GetMidHeight==true) - { - unsigned long MidHeightDword=(unsigned long)BT_GetGroundHeight(TerrainID,X,Z); - MidHeight=*(float*)&MidHeightDword; - } -#endif - - //Find sector(s) the brush is on - float OuterLeft=max(X-Radius,0); - float OuterRight=min(X+Radius,TerrainInfo->TerrainSize); - float OuterTop=max(Z-Radius,0); - float OuterBottom=min(Z+Radius,TerrainInfo->TerrainSize); - - /* For future optimisation - float InnerRadius=Radius*0.707106781f; - float InnerLeft=max(X-InnerRadius,0); - float InnerRight=X+InnerRadius; - float InnerTop=max(Z-InnerRadius,0); - float InnerBottom=Z+InnerRadius; - */ - - //Loop through LODLevels - bool Break=false; - unsigned char LODLevel=0; - - unsigned short MidVrow=unsigned short((X/TerrainInfo->Scale)); - unsigned short MidVcol=unsigned short((Z/TerrainInfo->Scale)); - do{ - //Get LODLevel info - BT_LODLevelInfo* LODLevelInfo=(BT_LODLevelInfo*)BT_GetLODLevelInfo(TerrainID,LODLevel); - - //Find the vertices the box is on - unsigned short TwoPowerLODLevel=unsigned short(pow(2.0f,float(LODLevel))); - unsigned short OuterTopV=unsigned short(floor((OuterTop/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short OuterLeftV=unsigned short(floor((OuterLeft/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short OuterBottomV=unsigned short(ceil((OuterBottom/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short OuterRightV=unsigned short(ceil((OuterRight/TerrainInfo->Scale)/TwoPowerLODLevel)); - - /* For future optimisation - unsigned short InnerTopV=unsigned short(floor((InnerTop/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short InnerLeftV=unsigned short(floor((InnerLeft/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short InnerBottomV=unsigned short(min(ceil((InnerBottom/TerrainInfo->Scale)/TwoPowerLODLevel),TerrainInfo->Heightmapsize)); - unsigned short InnerRightV=unsigned short(min(ceil((InnerRight/TerrainInfo->Scale)/TwoPowerLODLevel),TerrainInfo->Heightmapsize)); - */ - - //Find the sectors the box is on - unsigned short TopS=unsigned short(OuterTopV/float(LODLevelInfo->SectorDetail)); - unsigned short LeftS=unsigned short(OuterLeftV/float(LODLevelInfo->SectorDetail)); - unsigned short BottomS=unsigned short(OuterBottomV/float(LODLevelInfo->SectorDetail)); - unsigned short RightS=unsigned short(OuterRightV/float(LODLevelInfo->SectorDetail)); - if(TopS*LODLevelInfo->SectorDetail==OuterTopV && TopS>0) - TopS--; - if(LeftS*LODLevelInfo->SectorDetail==OuterLeftV && LeftS>0) - LeftS--; - - //Loop through sectors - for(unsigned short SectorX=LeftS;SectorX<=RightS;SectorX++) - { - for(unsigned short SectorY=TopS;SectorY<=BottomS;SectorY++) - { - //Lock vertexdata for this sector - BT_UnlockVertexData(); - BT_LockVertexdataForSector(TerrainID,LODLevel,SectorX*LODLevelInfo->Split+SectorY); - - //Edit every vertex in sector, leave it to distance check to find which ones to do - //This will be changed to inner and outer box in the future for a big speed increase - for(unsigned short Vrow=0;Vrow<=LODLevelInfo->SectorDetail;Vrow++) - { - for(unsigned short Vcol=0;Vcol<=LODLevelInfo->SectorDetail;Vcol++) - { - #ifdef COMPILE_GDK - float CurrentHeight=BT_GetVertexPositionY(Vrow,Vcol); - #else - unsigned long temp=BT_GetVertexPositionY(Vrow,Vcol); - float CurrentHeight=*(float*)&temp; - #endif - - float XDist=(MidVrow-(SectorX*LODLevelInfo->SectorDetail+Vrow)*TwoPowerLODLevel)*TerrainInfo->Scale; - float ZDist=(MidVcol-(SectorY*LODLevelInfo->SectorDetail+Vcol)*TwoPowerLODLevel)*TerrainInfo->Scale; - BT_SetVertexHeight(Vrow,Vcol,BrushFunc(XDist,ZDist,MidHeight,Radius,Amount,CurrentHeight,CapHeight)); - } - } - BT_UnlockVertexData(); - } - } - - //Increase LODLevel - LODLevel++; - if(LODLevel==TerrainInfo->LODLevels) - Break=true; - }while(Break==false); - } - } -} - - -//Currently, distance checks are done here. This will be changed in the future when I add an inner and outer box system. - -static float BT_CircleBrush_Raise(float XDist,float ZDist,float MidHeight,float Radius,float Amount,float CurrentHeight,float CapHeight) -{ - float Dist=(float)sqrt(XDist*XDist+ZDist*ZDist); - if(DistCurrentHeight ) - { - //if ( fNewHeight > CapHeight ) - //{ - fNewHeight = (CapHeight*fDegree) + (CurrentHeight*(1.0f-fDegree)); - //} - } - return fNewHeight; - }else{ - return CurrentHeight; - } -} - -static float BT_CircleBrush_Flatten(float XDist,float ZDist,float MidHeight,float Radius,float Amount,float CurrentHeight,float CapHeight) -{ - float Dist=XDist*XDist+ZDist*ZDist; - if(DistBuilt==true && TerrainInfo->Generated==true) - { - // Get mid height - float MidHeight=0.0; - unsigned long MidHeightDword = (unsigned long)BT_GetGroundHeight(TerrainID,X,Z); - MidHeight=*(float*)&MidHeightDword; - - // Find sector(s) the brush is on - float OuterLeft=max(X-Radius,0); - float OuterRight=min(X+Radius,TerrainInfo->TerrainSize); - float OuterTop=max(Z-Radius,0); - float OuterBottom=min(Z+Radius,TerrainInfo->TerrainSize); - - // Loop through LODLevels - bool Break=false; - unsigned char LODLevel=0; - unsigned short MidVrow=unsigned short((X/TerrainInfo->Scale)); - unsigned short MidVcol=unsigned short((Z/TerrainInfo->Scale)); - do - { - // Get LODLevel info - BT_LODLevelInfo* LODLevelInfo=(BT_LODLevelInfo*)BT_GetLODLevelInfo(TerrainID,LODLevel); - - // Find the vertices the box is on - unsigned short TwoPowerLODLevel=unsigned short(pow(2.0f,float(LODLevel))); - unsigned short OuterTopV=unsigned short(floor((OuterTop/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short OuterLeftV=unsigned short(floor((OuterLeft/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short OuterBottomV=unsigned short(ceil((OuterBottom/TerrainInfo->Scale)/TwoPowerLODLevel)); - unsigned short OuterRightV=unsigned short(ceil((OuterRight/TerrainInfo->Scale)/TwoPowerLODLevel)); - - // Find the sectors the box is on - unsigned short TopS=unsigned short(OuterTopV/float(LODLevelInfo->SectorDetail)); - unsigned short LeftS=unsigned short(OuterLeftV/float(LODLevelInfo->SectorDetail)); - unsigned short BottomS=unsigned short(OuterBottomV/float(LODLevelInfo->SectorDetail)); - unsigned short RightS=unsigned short(OuterRightV/float(LODLevelInfo->SectorDetail)); - if(TopS*LODLevelInfo->SectorDetail==OuterTopV && TopS>0) - TopS--; - if(LeftS*LODLevelInfo->SectorDetail==OuterLeftV && LeftS>0) - LeftS--; - - // Loop through sectors - for(unsigned short SectorX=LeftS;SectorX<=RightS;SectorX++) - { - for(unsigned short SectorY=TopS;SectorY<=BottomS;SectorY++) - { - // Lock vertexdata for this sector - BT_UnlockVertexData(); - BT_LockVertexdataForSector(TerrainID,LODLevel,SectorX*LODLevelInfo->Split+SectorY); - - // record old data - int iOldHeightsSize = LODLevelInfo->SectorDetail + 1; - float* pOldHeights = new float[iOldHeightsSize*iOldHeightsSize]; - for(unsigned short Vrow=0;Vrow<=LODLevelInfo->SectorDetail;Vrow++) - { - for(unsigned short Vcol=0;Vcol<=LODLevelInfo->SectorDetail;Vcol++) - { - unsigned long temp=BT_GetVertexPositionY(Vrow,Vcol); - float CurrentHeight=*(float*)&temp; - pOldHeights[Vrow+(Vcol*iOldHeightsSize)] = CurrentHeight; - } - } - - // Edit every vertex in sector, leave it to distance check to find which ones to do - for(unsigned short Vrow=0;Vrow<=LODLevelInfo->SectorDetail;Vrow++) - { - for(unsigned short Vcol=0;Vcol<=LODLevelInfo->SectorDetail;Vcol++) - { - // get old Y pos - float CurrentHeight = pOldHeights[Vrow+(Vcol*iOldHeightsSize)]; - float XDist=(MidVrow-(SectorX*LODLevelInfo->SectorDetail+Vrow)*TwoPowerLODLevel)*TerrainInfo->Scale; - float ZDist=(MidVcol-(SectorY*LODLevelInfo->SectorDetail+Vcol)*TwoPowerLODLevel)*TerrainInfo->Scale; - - // work out Y pos - float fNewYValue = 0.0f; - float Dist=(float)sqrt(XDist*XDist+ZDist*ZDist); - if(DistLODLevelInfo->SectorDetail ) blthisR = LODLevelInfo->SectorDetail; - if ( blthisC<0 ) blthisC = 0; - if ( blthisC>LODLevelInfo->SectorDetail ) blthisC = LODLevelInfo->SectorDetail; - float fThisHeight = pOldHeights[blthisR+(blthisC*iOldHeightsSize)]; - blCurrentHeight = blCurrentHeight + fThisHeight; - iBlCound++; - } - } - if ( iBlCound==9 ) - { - blCurrentHeight = blCurrentHeight / iBlCound; - fNewYValue = (blCurrentHeight*Amount) + (CurrentHeight*(1.0f-Amount)); - } - else - fNewYValue = CurrentHeight; - } - else - fNewYValue = CurrentHeight; - - // assign new Y pos - BT_SetVertexHeight(Vrow,Vcol,fNewYValue); - } - } - - // free usages - if ( pOldHeights ) - { - delete pOldHeights; - pOldHeights = NULL; - } - - // Unlock vertex data - BT_UnlockVertexData(); - } - } - - // Increase LODLevel - LODLevel++; - if(LODLevel==TerrainInfo->LODLevels) - Break=true; - } - while(Break==false); - } - } -} diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/brush.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/brush.h deleted file mode 100644 index c088798..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/brush.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _BRUSH_H -#define _BRUSH_H - -#include "main.h" - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/main.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/main.cpp deleted file mode 100644 index 0da1d88..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/main.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "main.h" - -#include "BlitzTerrain.h" - -static bool gBT_BlitzTerrainLoaded=false; - -// prototypes -void BT_RTTMS_AddUpdateHandler(unsigned long TerrainID,BT_RTTMS_UpdateHandler_t UpdateHandler); -static void BT_RTTMS_CallUpdateHandlers(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID,unsigned short StartVertex,unsigned short EndVertex,float* Vertices); -void BT_RTTMS_DeleteUpdateHandlers(unsigned long TerrainID); -void* BT_RTTMS_LockSectorVertexData(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID); -void BT_RTTMS_UnlockSectorVertexData(void* StructPtr); -unsigned short BT_RTTMS_FindVertex(void* StructPtr,unsigned short Vrow,unsigned short Vcol); -struct s_BT_terrain; -void BT_RTTMS_UnlockTerrain(s_BT_terrain* TerrainPtr); -void* BT_GetSectorInfo(unsigned long terrainid,unsigned long LODLevelID,unsigned long SectorID); - -void BTRTTMSConstructor() -{ - //Say that BlitzTerrain is now loaded - gBT_BlitzTerrainLoaded=true; -} - -void BTRTTMSDestructor() -{ -} - -static bool gBT_LockedASector=false; -static BT_RTTMS_STRUCT* gBT_SectorRTTMS=NULL; -static BT_TerrainInfo* gBT_LockedTerrainInfo=NULL; -static BT_LODLevelInfo* gBT_LockedLODLevelInfo=NULL; -static BT_SectorInfo* gBT_LockedSectorInfo=NULL; -static unsigned long gBT_LockedTerrainID=0; -static unsigned long gBT_LockedLODLevelID=0; -static unsigned long gBT_LockedSectorID=0; - -void BT_LockVertexdataForSector(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID) -{ -//Check that vertexdata isnt already locked - if(gBT_LockedASector==false) - { - //Lock the vertexdata (this command is very small, all it does is set a locked flag and returns the RTTMS structure) - gBT_SectorRTTMS=(BT_RTTMS_STRUCT*)BT_RTTMS_LockSectorVertexData(TerrainID,LODLevelID,SectorID); - if(gBT_SectorRTTMS==NULL) - return; - - //Set globals - gBT_LockedASector=true; - gBT_LockedTerrainID=TerrainID; - gBT_LockedLODLevelID=LODLevelID; - gBT_LockedSectorID=SectorID; - - //Get info - gBT_LockedTerrainInfo=(BT_TerrainInfo*)BT_GetTerrainInfo(TerrainID); - gBT_LockedLODLevelInfo=(BT_LODLevelInfo*)BT_GetLODLevelInfo(TerrainID,LODLevelID); - gBT_LockedSectorInfo=(BT_SectorInfo*)BT_GetSectorInfo(TerrainID,LODLevelID,SectorID); - } -} - - -unsigned long BT_LockedASector() -{ - return gBT_LockedASector; -} - - -unsigned long BT_GetLockedTerrain() -{ - return gBT_LockedTerrainID; -} - - -unsigned long BT_GetLockedLODLevel() -{ - return gBT_LockedLODLevelID; -} - - -unsigned long BT_GetLockedSector() -{ - return gBT_LockedSectorID; -} - - -void BT_UnlockVertexData() -{ -//Check that vertexdata is locked - if(gBT_LockedASector==true) - { - //Zero everything - gBT_LockedASector=false; - gBT_SectorRTTMS=NULL; - gBT_LockedTerrainID=0; - gBT_LockedLODLevelID=0; - gBT_LockedSectorID=0; - } -} - -unsigned short BT_GetVertexCount() -{ - if(gBT_LockedASector==true) - { - return gBT_SectorRTTMS->VertexCount; - }else{ - return 0; - } -} - - -#ifdef COMPILE_GDK - - - float BT_GetVertexPositionY(unsigned short VertexID) - { - if(gBT_LockedASector==true) - { - if(gBT_SectorRTTMS->VertexCount>VertexID) - return gBT_SectorRTTMS->Vertices[VertexID]; - }else{ - return 0.0f; - } - return 0.0f; - } - - float BT_GetVertexPositionY(unsigned short Vrow,unsigned short Vcol) - { - if(gBT_LockedASector==true) - { - unsigned short VertexID=BT_RTTMS_FindVertex((void*)gBT_SectorRTTMS,Vrow,Vcol); - if(VertexID!=NULL) - return BT_GetVertexPositionY(VertexID-1); - }else{ - return 0.0f; - } - return 0.0f; - } - - -#else - - unsigned long BT_GetVertexPositionY(unsigned short VertexID) - { - if(gBT_LockedASector==true) - { - if(gBT_SectorRTTMS->VertexCount>VertexID) - return *(unsigned long*)&gBT_SectorRTTMS->Vertices[VertexID]; - }else{ - return 0; - } - return 0; - } - - unsigned long BT_GetVertexPositionY(unsigned short Vrow,unsigned short Vcol) - { - if(gBT_LockedASector==true) - { - unsigned short VertexID=BT_RTTMS_FindVertex((void*)gBT_SectorRTTMS,Vrow,Vcol); - if(VertexID!=NULL) - return BT_GetVertexPositionY(VertexID-1); - }else{ - return 0; - } - return 0; - } - - -#endif - -void BT_SetVertexHeight(unsigned short VertexID,float Height) -{ - if(gBT_LockedASector==true) - { - if(gBT_SectorRTTMS->VertexCount+1>VertexID) - { - //Set position - gBT_SectorRTTMS->Vertices[VertexID]=Height; - - //Set updated vertices - if(gBT_SectorRTTMS->ChangedAVertex==false) - { - gBT_SectorRTTMS->FirstUpdatedVertex=gBT_SectorRTTMS->LastUpdatedVertex=VertexID; - gBT_SectorRTTMS->ChangedAVertex=true; - }else{ - if(VertexIDFirstUpdatedVertex) - gBT_SectorRTTMS->FirstUpdatedVertex=VertexID; - if(VertexID>gBT_SectorRTTMS->LastUpdatedVertex) - gBT_SectorRTTMS->LastUpdatedVertex=VertexID; - } - } - } -} - -void BT_SetVertexHeight(unsigned short Vrow,unsigned short Vcol,float Height) -{ - if(gBT_LockedASector==true) - { - unsigned short VertexID=BT_RTTMS_FindVertex((void*)gBT_SectorRTTMS,Vrow,Vcol); - if(VertexID!=NULL) - BT_SetVertexHeight(VertexID-1,Height); - } -} \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/main.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/main.h deleted file mode 100644 index 61361b6..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/main.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef _MAIN_H -#define _MAIN_H - -#define WIN32_LEAN_AND_MEAN -#include - - -//RTTMS STRUCTURES -struct BT_RTTMS_STRUCT -{ - unsigned short VertexCount; - float* Vertices; - bool ChangedAVertex; - unsigned short FirstUpdatedVertex; - unsigned short LastUpdatedVertex; - void* Internals; -}; - - -//BLITZTERRAIN STRUCTURES -struct BT_TerrainInfo -{ - bool Built; - bool Generated; - unsigned long Texture; - unsigned long Detailmap; - bool Smoothing; - bool QuadReduction; - bool QuadRotation; - unsigned char LODLevels; - float Scale; - float YScale; - float Tile; - bool MeshOptimisation; - unsigned short Sectors; - unsigned short Heightmapsize; - float TerrainSize; - bool MultiDetailmapping; - unsigned long DetailMapCount; - bool Exclusion; - unsigned char ExclusionThreshold; - unsigned char ATMode; - unsigned char DetailBlendMode; - void* InternalData; - //Added in 2.2 - unsigned long SmoothAmount; - void* DBPObjectPtr; -}; -struct BT_LODLevelInfo -{ - float SectorSize; - unsigned char SectorDetail; - unsigned short Sectors; - float Distance; - unsigned short Split; - unsigned char TileSpan; -}; -struct BT_SectorInfo -{ - bool Excluded; - unsigned short Row; - unsigned short Column; - float Pos_x; - float Pos_y; - float Pos_z; - void *WorldMatrix; -}; - -//UPDATE HANDLER TYPE -typedef void(*BT_RTTMS_UpdateHandler_t)(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID,unsigned short StartVertex,unsigned short EndVertex,float* Vertices); - -#define EXPORT - -typedef long(*t_dbGetImageWidth)(long); -typedef long(*t_dbGetImageHeight)(long); - -void BT_LockVertexdataForSector(unsigned long TerrainID,unsigned long LODLevelID,unsigned long SectorID); -unsigned long BT_LockedASector(); -unsigned long BT_GetLockedTerrain(); -unsigned long BT_GetLockedSector(); -void BT_UnlockVertexData(); -unsigned short BT_GetVertexCount(); -unsigned long BT_GetIndexCount(); -unsigned short BT_GetIndex(unsigned long IndexID); -#ifdef COMPILE_GDK - float BT_GetVertexPositionX(unsigned short VertexID); - float BT_GetVertexPositionX(unsigned short Vrow,unsigned short Vcol); - float BT_GetVertexPositionY(unsigned short VertexID); - float BT_GetVertexPositionY(unsigned short Vrow,unsigned short Vcol); - float BT_GetVertexPositionZ(unsigned short VertexID); - float BT_GetVertexPositionZ(unsigned short Vrow,unsigned short Vcol); -#else - unsigned long BT_GetVertexPositionX(unsigned short VertexID); - unsigned long BT_GetVertexPositionX(unsigned short Vrow,unsigned short Vcol); - unsigned long BT_GetVertexPositionY(unsigned short VertexID); - unsigned long BT_GetVertexPositionY(unsigned short Vrow,unsigned short Vcol); - unsigned long BT_GetVertexPositionZ(unsigned short VertexID); - unsigned long BT_GetVertexPositionZ(unsigned short Vrow,unsigned short Vcol); -#endif -void BT_SetVertexHeight(unsigned short VertexID,float Height); -void BT_SetVertexHeight(unsigned short Vrow,unsigned short Vcol,float Height); - - - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/paint.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/paint.cpp deleted file mode 100644 index 51e3266..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/paint.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "paint.h" -#include ".\..\..\Shared\DBOFormat\DBOData.h" - -///#pragma comment(lib,"d3dx9.lib") - -#include "BlitzTerrain.h" -#include "CImageC.h" diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/paint.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/paint.h deleted file mode 100644 index 8bbdb77..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/paint.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _PAINT_H -#define _PAINT_H - -#include "main.h" - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/resource.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/resource.h deleted file mode 100644 index 7776174..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/resource.h +++ /dev/null @@ -1,41 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDS_STRING101 101 -#define IDS_STRING102 102 -#define IDS_STRING103 103 -#define IDS_STRING104 104 -#define IDS_STRING105 105 -#define IDS_STRING106 106 -#define IDS_STRING107 107 -#define IDS_STRING108 108 -#define IDS_STRING109 109 -#define IDS_STRING110 110 -#define IDS_STRING111 111 -#define IDS_STRING112 112 -#define IDS_STRING113 113 -#define IDS_STRING114 114 -#define IDS_STRING115 115 -#define IDS_STRING116 116 -#define IDS_STRING117 117 -#define IDS_STRING118 118 -#define IDS_STRING119 119 -#define IDS_STRING120 120 -#define IDS_STRING121 121 -#define IDS_STRING122 122 -#define IDS_STRING123 123 -#define IDS_STRING124 124 -#define IDS_STRING125 125 -#define IDS_STRING126 126 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/resource.rc b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/resource.rc deleted file mode 100644 index fd13cd5..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/resource.rc +++ /dev/null @@ -1,140 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -///#define _USING_V110_SDK71_ -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United Kingdom) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,2,1 - PRODUCTVERSION 2,0,2,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "080904b0" - BEGIN - VALUE "CompanyName", "Blitzwerks" - VALUE "FileDescription", "Blitzwerks Terrain Real-Time Terrain Modification System Plugin" - VALUE "FileVersion", "2.0.2.1" - VALUE "InternalName", "BTRTTMS" - VALUE "LegalCopyright", "Copyright (C) 2011" - VALUE "ProductName", "Blitzwerks Terrain" - VALUE "ProductVersion", "2.0.2.1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x809, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_STRING101 "BT LOCKVERTEXDATAFORSECTOR%DDD%?BT_LockVertexdataForSector@@YAXKKK@Z%int TerrainID, int LODlevel, int Sector" - IDS_STRING102 "BT LOCKEDASECTOR[%D%?BT_LockedASector@@YAKXZ%* No Parameters *" - IDS_STRING103 "BT GETLOCKEDTERRAIN[%D%?BT_GetLockedTerrain@@YAKXZ%* No Parameters *" - IDS_STRING104 "BT GETLOCKEDLODLEVEL[%D%?BT_GetLockedLODLevel@@YAKXZ%* No Parameters *" - IDS_STRING105 "BT GETLOCKEDSECTOR[%D%?BT_GetLockedSector@@YAKXZ%* No Parameters *" - IDS_STRING106 "BT UNLOCKVERTEXDATA%0%?BT_UnlockVertexData@@YAXXZ%* No Parameters *" - IDS_STRING107 "BT GETVERTEXCOUNT[%D%?BT_GetVertexCount@@YAGXZ%* No Parameters *" - IDS_STRING108 "BT GETINDEXCOUNT[%D%?BT_GetIndexCount@@YAKXZ%* No Parameters *" - IDS_STRING109 "BT GETINDEX[%DD%?BT_GetIndex@@YAGK@Z%int IndexID" - IDS_STRING110 "BT GETVERTEXPOSITIONX[%FD%?BT_GetVertexPositionX@@YAKG@Z%int VertexID" - IDS_STRING111 "BT GETVERTEXPOSITIONY[%FD%?BT_GetVertexPositionY@@YAKG@Z%int VertexID" -END - -STRINGTABLE -BEGIN - IDS_STRING112 "BT GETVERTEXPOSITIONZ[%FD%?BT_GetVertexPositionZ@@YAKG@Z%int VertexID" - IDS_STRING113 "BT SETVERTEXHEIGHT%DF%?BT_SetVertexHeight@@YAXGM@Z%int VertexID, float Height" - IDS_STRING114 "BT SETPOINTHEIGHT%DDDF%?BT_SetPointHeight@@YAXKKKM@Z%int TerrainID, int Row, int Collumn, float Height" - IDS_STRING115 "BT RAISETERRAIN%DFFFF%?BT_RaiseTerrain@@YAXKMMMM@Z%int TerrainID, float X, float Z, float Radius, float Amount" - IDS_STRING116 "BT FLATTENTERRAIN%DFFF%?BT_FlattenTerrain@@YAXKMMM@Z%int TerrainID, float X, float Z, float Radius" - IDS_STRING117 "BT GETVERTEXPOSITIONX[%FDD%?BT_GetVertexPositionX@@YAKGG@Z%int Row, int Column" - IDS_STRING118 "BT GETVERTEXPOSITIONY[%FDD%?BT_GetVertexPositionY@@YAKGG@Z%int Row, int Column" - IDS_STRING119 "BT GETVERTEXPOSITIONZ[%FDD%?BT_GetVertexPositionZ@@YAKGG@Z%int Row, int Column" - IDS_STRING120 "BT SETVERTEXHEIGHT%DDF%?BT_SetVertexHeight@@YAXGGM@Z%int Row, int Column, float Height" - IDS_STRING121 "BT PAINTTERRAIN%DFFFD%?BT_PaintTerrain@@YAXKMMMK@Z%int TerrainID, float X, float Z, float Radius, dword Colour" - IDS_STRING122 "BT PAINTTERRAIN%DFFFDD%?BT_PaintTerrain@@YAXKMMMKK@Z%int TerrainID, float X, float Z, float Radius, dword MinColour, dword MaxColour" - IDS_STRING123 "BT SETPOINTCOLOUR%DFFD%?BT_SetPointColour@@YAXKMMK@Z%int TerrainID, float X, float Z, dword Colour" - IDS_STRING124 "BT UPDATETERRAINTEXTURE%D%?BT_UpdateTerrainTexture@@YAXK@Z%int TerrainID" - IDS_STRING125 "BT RAISETERRAIN%DFFFFF%?BT_RaiseTerrain@@YAXKMMMMM@Z%int TerrainID, float X, float Z, float Radius, float Amount, Cap Height" - IDS_STRING126 "BT BLENDTERRAIN%DFFFFF%?BT_BlendTerrain@@YAXKMMMMM@Z%int TerrainID, float X, float Z, float Radius, float Amount, Reserved" -END - -#endif // English (United Kingdom) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/wholeterrain.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/wholeterrain.cpp deleted file mode 100644 index aeb73cc..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/wholeterrain.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "wholeterrain.h" - diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/wholeterrain.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/wholeterrain.h deleted file mode 100644 index 0356927..0000000 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/BlitzTerrain_RTTMSPlugin/wholeterrain.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _WHOLETERRAIN_H -#define _WHOLETERRAIN_H - -#include "main.h" - -#endif \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3D.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3D.h index ef730bc..027778d 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3D.h +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3D.h @@ -371,7 +371,7 @@ inline void MemSetQuad(void *dest, UINT data, int count) { // this function fills or sets unsigned 32-bit aligned memory // count is number of quads - + /* _asm { mov edi, dest ; edi points to destination memory @@ -379,7 +379,7 @@ inline void MemSetQuad(void *dest, UINT data, int count) mov eax, data ; 32-bit data rep stosd ; move data } // end asm - + */ } // end MemSetQuad // 3D parametric line ///////////////////////////////////////// diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3DTest.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3DTest.vcxproj index 7f80c9d..96cb2e4 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3DTest.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/CPU3D/CPU3DTest.vcxproj @@ -39,51 +39,51 @@ CPU3DTest Win32Proj CPU3D - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet StaticLibrary - v141 + v143 NotSet StaticLibrary - v141 + v143 NotSet StaticLibrary - v141 + v143 NotSet @@ -159,8 +159,8 @@ false - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath);$(IncludePath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/DarkMind.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/DarkMind.vcxproj index 16d4bac..449d54c 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/DarkMind.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/DarkMind.vcxproj @@ -39,44 +39,44 @@ {4A27C896-E37C-4317-87B4-6229F5F38DC2} DarkAI Win32Proj - 10.0.17763.0 + 10.0 StaticLibrary true - v141 + v143 StaticLibrary true - v141 + v143 StaticLibrary true - v141 + v143 StaticLibrary true - v141 + v143 StaticLibrary - v141 + v143 StaticLibrary - v141 + v143 StaticLibrary - v141 + v143 StaticLibrary - v141 + v143 diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/AIThread.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/AIThread.obj new file mode 100644 index 0000000..51a07d1 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/AIThread.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Beacon.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Beacon.obj new file mode 100644 index 0000000..337fe29 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Beacon.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/CollisionTree.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/CollisionTree.obj new file mode 100644 index 0000000..e710076 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/CollisionTree.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Container.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Container.obj new file mode 100644 index 0000000..f574ee3 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Container.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DBPro Functions.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DBPro Functions.obj new file mode 100644 index 0000000..ebbc880 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DBPro Functions.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.Build.CppClean.log b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.Build.CppClean.log new file mode 100644 index 0000000..4483888 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.Build.CppClean.log @@ -0,0 +1,54 @@ +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\lib\darkai.pdb +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statechaseattack.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stateattackfromcover.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stateattack.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\polygon.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\pathfinderadvanced.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\path.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\luascript.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\leethread.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\hero.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\grid.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\entitythread.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\entitybuffer.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\entity.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\dynamicpathfinder.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\dbpro functions.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\container.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\collisiontree.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\beacon.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\aithread.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\zone.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\world.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\treenode.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\treeface.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\teamcontroller.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\team.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statewaitincover.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statestrafeattack.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stateset.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statesearcharea.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statepeekfromcorner.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statepatrol.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statemanual.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stateleaping.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stateinvestigate.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stateidle.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stategotodest.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statefallback.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statediving.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\statedefend.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\lib\darkai.lib +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\stringtable.res +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\..\..\..\lib\darkai.pdb +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\cl.command.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\cl.items.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\cl.read.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\cl.write.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\lib-link-cvtres.read.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\lib-link-cvtres.write.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\lib.command.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\rc.command.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\rc.read.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darkai\release\darkai.tlog\rc.write.1.tlog diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.lib.recipe b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.lib.recipe new file mode 100644 index 0000000..a53f961 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.lib.recipe @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.obj new file mode 100644 index 0000000..d095e98 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.command.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.command.1.tlog new file mode 100644 index 0000000..4bcf665 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.command.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.read.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.read.1.tlog new file mode 100644 index 0000000..492c86f Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.read.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.write.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.write.1.tlog new file mode 100644 index 0000000..e4108a3 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/CL.write.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Cl.items.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Cl.items.tlog new file mode 100644 index 0000000..76b4213 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Cl.items.tlog @@ -0,0 +1,40 @@ +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\AIThread.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\AIThread.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Beacon.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Beacon.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\CollisionTree.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\CollisionTree.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Container.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Container.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\DarkAI.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\DarkAI.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\DBPro Functions.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\DBPro Functions.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\DynamicPathFinder.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\DynamicPathFinder.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Entity.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Entity.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\EntityBuffer.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\EntityBuffer.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\EntityThread.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\EntityThread.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Grid.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Grid.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Hero.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Hero.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\LeeThread.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\LeeThread.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\LUAScript.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\LUAScript.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Path.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Path.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\PathFinderAdvanced.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\PathFinderAdvanced.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Polygon.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Polygon.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateAttack.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateAttack.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateAttackFromCover.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateAttackFromCover.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateChaseAttack.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateChaseAttack.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateDefend.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateDefend.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateDiving.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateDiving.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateFallBack.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateFallBack.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateGoToDest.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateGoToDest.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateIdle.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateIdle.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateInvestigate.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateInvestigate.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateLeaping.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateLeaping.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateManual.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateManual.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StatePatrol.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StatePatrol.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StatePeekFromCorner.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StatePeekFromCorner.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateSearchArea.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateSearchArea.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateSet.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateSet.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateStrafeAttack.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateStrafeAttack.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\StateMachine\StateWaitInCover.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\StateWaitInCover.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Team.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Team.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\TeamController.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\TeamController.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\TreeFace.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\TreeFace.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\TreeNode.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\TreeNode.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\World.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\World.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Zone.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Release\Zone.obj diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/DarkAI.lastbuildstate b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/DarkAI.lastbuildstate new file mode 100644 index 0000000..72089a4 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/DarkAI.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.38.33130:TargetPlatformVersion=10.0.20348.0: +Release|Win32|D:\DEV\GameGuruConverter - reduced\GameGuru Core\| diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib-link-cvtres.read.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib-link-cvtres.read.1.tlog new file mode 100644 index 0000000..cb656ed Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib-link-cvtres.read.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib-link-cvtres.write.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib-link-cvtres.write.1.tlog new file mode 100644 index 0000000..b05871f Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib-link-cvtres.write.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib.command.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib.command.1.tlog new file mode 100644 index 0000000..5e2019d Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/Lib.command.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.command.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.command.1.tlog new file mode 100644 index 0000000..6281588 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.command.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.read.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.read.1.tlog new file mode 100644 index 0000000..3e84886 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.read.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.write.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.write.1.tlog new file mode 100644 index 0000000..4c2b9ad Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkAI.tlog/rc.write.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkMind.log b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkMind.log new file mode 100644 index 0000000..94bcba2 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkMind.log @@ -0,0 +1,46 @@ + AIThread.cpp + Beacon.cpp + CollisionTree.cpp + Container.cpp + DarkAI.cpp + DBPro Functions.cpp + DynamicPathFinder.cpp + Entity.cpp +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\Entity.cpp(591,31): warning C4018: '<': signed/unsigned mismatch + EntityBuffer.cpp + EntityThread.cpp + Grid.cpp + Hero.cpp + LeeThread.cpp + LUAScript.cpp + Path.cpp + PathFinderAdvanced.cpp +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\PathFinderAdvanced.cpp(1322,24): warning C4018: '<': signed/unsigned mismatch + Polygon.cpp + StateAttack.cpp + StateAttackFromCover.cpp + StateChaseAttack.cpp + Generating Code... + Compiling... + StateDefend.cpp + StateDiving.cpp + StateFallBack.cpp + StateGoToDest.cpp + StateIdle.cpp + StateInvestigate.cpp + StateLeaping.cpp + StateManual.cpp + StatePatrol.cpp + StatePeekFromCorner.cpp + StateSearchArea.cpp + StateSet.cpp + StateStrafeAttack.cpp + StateWaitInCover.cpp + Team.cpp + TeamController.cpp + TreeFace.cpp + TreeNode.cpp + World.cpp + Zone.cpp + Generating Code... + DarkMind.vcxproj -> D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Lib\DarkAI.lib diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkMind.vcxproj.FileListAbsolute.txt b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DarkMind.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..e69de29 diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DynamicPathFinder.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DynamicPathFinder.obj new file mode 100644 index 0000000..e0b8884 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/DynamicPathFinder.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Entity.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Entity.obj new file mode 100644 index 0000000..7856d79 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Entity.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/EntityBuffer.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/EntityBuffer.obj new file mode 100644 index 0000000..319c888 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/EntityBuffer.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/EntityThread.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/EntityThread.obj new file mode 100644 index 0000000..52b658f Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/EntityThread.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Grid.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Grid.obj new file mode 100644 index 0000000..1b329a5 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Grid.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Hero.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Hero.obj new file mode 100644 index 0000000..cf10973 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Hero.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/LUAScript.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/LUAScript.obj new file mode 100644 index 0000000..4df1c24 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/LUAScript.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/LeeThread.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/LeeThread.obj new file mode 100644 index 0000000..d07d874 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/LeeThread.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Path.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Path.obj new file mode 100644 index 0000000..302b75a Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Path.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/PathFinderAdvanced.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/PathFinderAdvanced.obj new file mode 100644 index 0000000..2f7bdca Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/PathFinderAdvanced.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Polygon.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Polygon.obj new file mode 100644 index 0000000..1995ed9 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Polygon.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/RCa04820 b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/RCa04820 new file mode 100644 index 0000000..c0f230f Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/RCa04820 differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateAttack.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateAttack.obj new file mode 100644 index 0000000..fbaaecc Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateAttack.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateAttackFromCover.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateAttackFromCover.obj new file mode 100644 index 0000000..8249d74 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateAttackFromCover.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateChaseAttack.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateChaseAttack.obj new file mode 100644 index 0000000..93e8514 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateChaseAttack.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateDefend.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateDefend.obj new file mode 100644 index 0000000..cd800e2 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateDefend.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateDiving.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateDiving.obj new file mode 100644 index 0000000..6473f73 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateDiving.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateFallBack.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateFallBack.obj new file mode 100644 index 0000000..dbd63c1 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateFallBack.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateGoToDest.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateGoToDest.obj new file mode 100644 index 0000000..4f13b5d Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateGoToDest.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateIdle.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateIdle.obj new file mode 100644 index 0000000..ad2558f Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateIdle.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateInvestigate.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateInvestigate.obj new file mode 100644 index 0000000..0ead395 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateInvestigate.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateLeaping.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateLeaping.obj new file mode 100644 index 0000000..a9d862c Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateLeaping.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateManual.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateManual.obj new file mode 100644 index 0000000..0bc7a19 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateManual.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StatePatrol.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StatePatrol.obj new file mode 100644 index 0000000..cb20439 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StatePatrol.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StatePeekFromCorner.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StatePeekFromCorner.obj new file mode 100644 index 0000000..5ee6977 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StatePeekFromCorner.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateSearchArea.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateSearchArea.obj new file mode 100644 index 0000000..47df338 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateSearchArea.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateSet.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateSet.obj new file mode 100644 index 0000000..dd07b8a Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateSet.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateStrafeAttack.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateStrafeAttack.obj new file mode 100644 index 0000000..68743e2 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateStrafeAttack.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateWaitInCover.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateWaitInCover.obj new file mode 100644 index 0000000..271c23c Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/StateWaitInCover.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Team.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Team.obj new file mode 100644 index 0000000..997f912 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Team.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TeamController.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TeamController.obj new file mode 100644 index 0000000..5ac031b Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TeamController.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TreeFace.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TreeFace.obj new file mode 100644 index 0000000..91177c4 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TreeFace.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TreeNode.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TreeNode.obj new file mode 100644 index 0000000..e8d73a0 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/TreeNode.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/World.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/World.obj new file mode 100644 index 0000000..096f711 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/World.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Zone.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Zone.obj new file mode 100644 index 0000000..b74f5e1 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/Zone.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/stringtable.res b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/stringtable.res new file mode 100644 index 0000000..bdb9868 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkAI/Release/stringtable.res differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLIGHTS/LightMapper.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLIGHTS/LightMapper.vcxproj index d956465..84d3d20 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLIGHTS/LightMapper.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLIGHTS/LightMapper.vcxproj @@ -18,23 +18,23 @@ {E6C0DB75-910C-4085-B029-33D8503487A7} LightMapper Win32Proj - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v143 MultiByte true StaticLibrary - v141 + v143 NotSet StaticLibrary - v141 + v143 NotSet diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj index 46f0302..26d9037 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/DarkLUA.vcxproj @@ -38,51 +38,51 @@ {C5451FF8-7264-4300-9F2D-325FE8301E51} DarkLUA Win32Proj - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet true StaticLibrary - v141 + v143 NotSet StaticLibrary - v141 + v143 NotSet StaticLibrary - v141 + v143 NotSet StaticLibrary - v141 + v143 NotSet diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.Build.CppClean.log b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.Build.CppClean.log new file mode 100644 index 0000000..56a93f0 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.Build.CppClean.log @@ -0,0 +1,51 @@ +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.pch +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\lib\darklua.pdb +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\stdafx.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lobject.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\loadlib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lmem.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lmathlib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\llex.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\liolib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\linit.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lgc.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lfunc.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\ldump.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\ldo.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\ldebug.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\ldblib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lctype.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lcorolib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lcode.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lbitlib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lbaselib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lauxlib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lapi.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lzio.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lvm.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lundump.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\luac.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lua.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\ltm.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\ltablib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\ltable.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lstrlib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lstring.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lstate.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lparser.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\loslib.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\lopcodes.obj +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\lib\darklua.lib +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.res +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\..\..\..\lib\darklua.pdb +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\cl.command.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\cl.items.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\cl.read.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\cl.write.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\lib-link-cvtres.read.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\lib-link-cvtres.write.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\lib.command.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\rc.command.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\rc.read.1.tlog +d:\dev\gameguruconverter - reduced\gameguru core\dark basic public shared\dark basic pro sdk\darksdkmore\darklua\release\darklua.tlog\rc.write.1.tlog diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.lib.recipe b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.lib.recipe new file mode 100644 index 0000000..a53f961 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.lib.recipe @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.log b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.log new file mode 100644 index 0000000..34c8efc --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.log @@ -0,0 +1,41 @@ + stdafx.cpp + DarkLUA.cpp +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\DarkLUA.cpp(1902): warning C4715: 'AISetEntityMoveBoostPriority': not all control paths return a value + lapi.c + lauxlib.c + lbaselib.c + lbitlib.c + lcode.c + lcorolib.c + lctype.c + ldblib.c + ldebug.c + ldo.c + ldump.c + lfunc.c + lgc.c + linit.c + liolib.c + llex.c + lmathlib.c + lmem.c + loadlib.c + lobject.c + Generating Code... + Compiling... + lopcodes.c + loslib.c + lparser.c + lstate.c + lstring.c + lstrlib.c + ltable.c + ltablib.c + ltm.c + lua.c + luac.c + lundump.c + lvm.c + lzio.c + Generating Code... + DarkLUA.vcxproj -> D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Lib\DarkLUA.lib diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.obj new file mode 100644 index 0000000..43f888e Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.pch b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.pch new file mode 100644 index 0000000..c4206d9 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.pch differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.res b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.res new file mode 100644 index 0000000..22cfe06 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.res differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.command.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.command.1.tlog new file mode 100644 index 0000000..23d85c6 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.command.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.read.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.read.1.tlog new file mode 100644 index 0000000..319fffd Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.read.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.write.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.write.1.tlog new file mode 100644 index 0000000..435e43a Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/CL.write.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Cl.items.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Cl.items.tlog new file mode 100644 index 0000000..ab41bc4 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Cl.items.tlog @@ -0,0 +1,36 @@ +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\DarkLUA.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\DarkLUA.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\stdafx.cpp;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\stdafx.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lapi.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lapi.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lauxlib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lauxlib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lbaselib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lbaselib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lbitlib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lbitlib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lcode.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lcode.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lcorolib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lcorolib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lctype.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lctype.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\ldblib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\ldblib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\ldebug.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\ldebug.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\ldo.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\ldo.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\ldump.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\ldump.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lfunc.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lfunc.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lgc.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lgc.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\linit.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\linit.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\liolib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\liolib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\llex.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\llex.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lmathlib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lmathlib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lmem.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lmem.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\loadlib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\loadlib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lobject.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lobject.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lopcodes.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lopcodes.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\loslib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\loslib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lparser.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lparser.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lstate.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lstate.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lstring.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lstring.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lstrlib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lstrlib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\ltable.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\ltable.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\ltablib.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\ltablib.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\ltm.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\ltm.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lua.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lua.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\luac.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\luac.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lundump.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lundump.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lvm.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lvm.obj +D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\lzio.c;D:\DEV\GameGuruConverter - reduced\GameGuru Core\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\Release\lzio.obj diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/DarkLUA.lastbuildstate b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/DarkLUA.lastbuildstate new file mode 100644 index 0000000..72089a4 --- /dev/null +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/DarkLUA.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.38.33130:TargetPlatformVersion=10.0.20348.0: +Release|Win32|D:\DEV\GameGuruConverter - reduced\GameGuru Core\| diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib-link-cvtres.read.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib-link-cvtres.read.1.tlog new file mode 100644 index 0000000..f716a80 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib-link-cvtres.read.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib-link-cvtres.write.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib-link-cvtres.write.1.tlog new file mode 100644 index 0000000..7e40664 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib-link-cvtres.write.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib.command.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib.command.1.tlog new file mode 100644 index 0000000..b90b7e1 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/Lib.command.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.command.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.command.1.tlog new file mode 100644 index 0000000..dbe8bbd Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.command.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.read.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.read.1.tlog new file mode 100644 index 0000000..1134559 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.read.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.write.1.tlog b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.write.1.tlog new file mode 100644 index 0000000..e1129ea Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.tlog/rc.write.1.tlog differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.vcxproj.FileListAbsolute.txt b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/DarkLUA.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..e69de29 diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/RCa03880 b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/RCa03880 new file mode 100644 index 0000000..e00bacf Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/RCa03880 differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lapi.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lapi.obj new file mode 100644 index 0000000..4d64b71 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lapi.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lauxlib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lauxlib.obj new file mode 100644 index 0000000..5317da7 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lauxlib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lbaselib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lbaselib.obj new file mode 100644 index 0000000..4cf1738 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lbaselib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lbitlib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lbitlib.obj new file mode 100644 index 0000000..dd2e628 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lbitlib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lcode.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lcode.obj new file mode 100644 index 0000000..a8339ed Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lcode.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lcorolib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lcorolib.obj new file mode 100644 index 0000000..39cb408 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lcorolib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lctype.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lctype.obj new file mode 100644 index 0000000..585b25d Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lctype.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldblib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldblib.obj new file mode 100644 index 0000000..55ec572 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldblib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldebug.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldebug.obj new file mode 100644 index 0000000..7e616b2 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldebug.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldo.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldo.obj new file mode 100644 index 0000000..d8bca59 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldo.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldump.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldump.obj new file mode 100644 index 0000000..1384ebc Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ldump.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lfunc.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lfunc.obj new file mode 100644 index 0000000..b6e8271 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lfunc.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lgc.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lgc.obj new file mode 100644 index 0000000..4812695 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lgc.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/linit.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/linit.obj new file mode 100644 index 0000000..c75572a Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/linit.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/liolib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/liolib.obj new file mode 100644 index 0000000..5a44c66 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/liolib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/llex.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/llex.obj new file mode 100644 index 0000000..9bb3fae Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/llex.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lmathlib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lmathlib.obj new file mode 100644 index 0000000..ff946fc Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lmathlib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lmem.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lmem.obj new file mode 100644 index 0000000..45f4c99 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lmem.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/loadlib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/loadlib.obj new file mode 100644 index 0000000..4c424a9 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/loadlib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lobject.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lobject.obj new file mode 100644 index 0000000..14de72e Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lobject.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lopcodes.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lopcodes.obj new file mode 100644 index 0000000..c8afb27 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lopcodes.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/loslib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/loslib.obj new file mode 100644 index 0000000..08cca0a Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/loslib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lparser.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lparser.obj new file mode 100644 index 0000000..1bb42cb Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lparser.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstate.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstate.obj new file mode 100644 index 0000000..40a5cf8 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstate.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstring.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstring.obj new file mode 100644 index 0000000..cb18b44 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstring.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstrlib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstrlib.obj new file mode 100644 index 0000000..ef8fdf3 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lstrlib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltable.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltable.obj new file mode 100644 index 0000000..d4c9e69 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltable.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltablib.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltablib.obj new file mode 100644 index 0000000..758a892 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltablib.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltm.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltm.obj new file mode 100644 index 0000000..b31760e Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/ltm.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lua.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lua.obj new file mode 100644 index 0000000..5887879 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lua.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/luac.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/luac.obj new file mode 100644 index 0000000..db0b47b Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/luac.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lundump.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lundump.obj new file mode 100644 index 0000000..7c7f5a6 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lundump.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lvm.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lvm.obj new file mode 100644 index 0000000..c5e3d93 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lvm.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lzio.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lzio.obj new file mode 100644 index 0000000..315150c Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/lzio.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/stdafx.obj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/stdafx.obj new file mode 100644 index 0000000..047c450 Binary files /dev/null and b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/DarkLUA/Release/stdafx.obj differ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Main.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Main.vcxproj index 1191e08..607aa8e 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Main.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Main.vcxproj @@ -39,54 +39,54 @@ Main MFCProj Enhancements - 10.0.17763.0 + 10.0 StaticLibrary - v141 + v143 false MultiByte StaticLibrary - v141 + v143 false MultiByte StaticLibrary - v141 + v143 false MultiByte StaticLibrary - v141 + v143 false MultiByte StaticLibrary - v141 + v143 false MultiByte StaticLibrary - v141 + v143 false MultiByte StaticLibrary - v141 + v143 false MultiByte StaticLibrary - v141 + v143 false MultiByte @@ -173,8 +173,8 @@ true - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath);$(IncludePath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) false $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/OSCpuInfo.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/OSCpuInfo.cpp index e82917d..4f7be0e 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/OSCpuInfo.cpp +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/OSCpuInfo.cpp @@ -192,7 +192,7 @@ bool __cdecl CPUInfo::DoesCPUSupportCPUID ( void ) // Use SEH to determine CPUID presence __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the @@ -211,7 +211,7 @@ bool __cdecl CPUInfo::DoesCPUSupportCPUID ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -229,7 +229,7 @@ bool __cdecl CPUInfo::RetrieveCPUFeatures ( void ) __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -252,7 +252,7 @@ bool __cdecl CPUInfo::RetrieveCPUFeatures ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -277,12 +277,12 @@ bool __cdecl CPUInfo::RetrieveCPUFeatures ( void ) __try { // perform orps xmm0, xmm0 - _asm + /*_asm { _emit 0x0f _emit 0x56 _emit 0xc0 - } + }*/ // SSE FP capable processor Features.HasSSEFP = true; @@ -323,7 +323,7 @@ bool __cdecl CPUInfo::RetrieveCPUIdentity ( void ) __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -356,7 +356,7 @@ bool __cdecl CPUInfo::RetrieveCPUIdentity ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -405,7 +405,7 @@ bool __cdecl CPUInfo::RetrieveCPUCacheDetails ( void ) // L1 cache __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -431,7 +431,7 @@ bool __cdecl CPUInfo::RetrieveCPUCacheDetails ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -451,7 +451,7 @@ bool __cdecl CPUInfo::RetrieveCPUCacheDetails ( void ) { __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -477,7 +477,7 @@ bool __cdecl CPUInfo::RetrieveCPUCacheDetails ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -510,7 +510,7 @@ bool __cdecl CPUInfo::RetrieveClassicalCPUCacheDetails ( void ) { __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -536,7 +536,7 @@ bool __cdecl CPUInfo::RetrieveClassicalCPUCacheDetails ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -692,7 +692,7 @@ bool __cdecl CPUInfo::RetrieveClassicalCPUClockSpeed ( void ) __try { - _asm + /*_asm { mov eax, 0x80000000 mov ebx, CLASSICAL_CPU_FREQ_LOOP @@ -700,7 +700,7 @@ bool __cdecl CPUInfo::RetrieveClassicalCPUClockSpeed ( void ) bsf ecx,eax dec ebx jnz Timer_Loop - } + } */ } __except ( 1 ) { @@ -794,7 +794,7 @@ bool __cdecl CPUInfo::RetrieveCPUExtendedLevelSupport ( int CPULevelToCheck ) __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -814,7 +814,7 @@ bool __cdecl CPUInfo::RetrieveCPUExtendedLevelSupport ( int CPULevelToCheck ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -844,7 +844,7 @@ bool __cdecl CPUInfo::RetrieveExtendedCPUFeatures ( void ) __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -866,7 +866,7 @@ bool __cdecl CPUInfo::RetrieveExtendedCPUFeatures ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -905,7 +905,7 @@ bool __cdecl CPUInfo::RetrieveProcessorSerialNumber ( void ) __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -929,7 +929,7 @@ bool __cdecl CPUInfo::RetrieveProcessorSerialNumber ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -969,7 +969,7 @@ bool __cdecl CPUInfo::RetrieveCPUPowerManagement ( void ) __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -989,7 +989,7 @@ bool __cdecl CPUInfo::RetrieveCPUPowerManagement ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -1014,7 +1014,7 @@ bool __cdecl CPUInfo::RetrieveExtendedCPUIdentity ( void ) __try { - _asm + /*_asm { ; we must push/pop the registers <> writes to, as the ; optimiser doesn't know about <>, and so doesn't expect @@ -1055,7 +1055,7 @@ bool __cdecl CPUInfo::RetrieveExtendedCPUIdentity ( void ) pop ecx pop ebx pop eax - } + }*/ } __except ( 1 ) { @@ -1419,7 +1419,7 @@ __int64 __cdecl CPUSpeed::GetCyclesDifference (DELAY_FUNC DelayFunction, unsigne // Calculate the frequency of the CPU instructions. __try { - _asm + /*_asm { push uiParameter ; push parameter param mov ebx, DelayFunction ; store func in ebx @@ -1440,7 +1440,7 @@ __int64 __cdecl CPUSpeed::GetCyclesDifference (DELAY_FUNC DelayFunction, unsigne mov edx1, edi ; edx2 = edi mov eax1, esi ; eax2 = esi - } + }*/ } // A generic catch-all just to be sure... diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Zlib/aes_via_ace.h b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Zlib/aes_via_ace.h index bb7a9cf..20766b8 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Zlib/aes_via_ace.h +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/Enhancements/Zlib/aes_via_ace.h @@ -143,82 +143,82 @@ static unsigned char via_flags = 0; INLINE int has_cpuid(void) { char ret_value; - __asm - { pushfd /* save EFLAGS register */ - mov eax,[esp] /* copy it to eax */ - mov edx,0x00200000 /* CPUID bit position */ - xor eax,edx /* toggle the CPUID bit */ - push eax /* attempt to set EFLAGS to */ - popfd /* the new value */ - pushfd /* get the new EFLAGS value */ - pop eax /* into eax */ - xor eax,[esp] /* xor with original value */ - and eax,edx /* has CPUID bit changed? */ - setne al /* set to 1 if we have been */ - mov ret_value,al /* able to change it */ - popfd /* restore original EFLAGS */ - } + //__asm + //{ pushfd /* save EFLAGS register */ + // mov eax,[esp] /* copy it to eax */ + // mov edx,0x00200000 /* CPUID bit position */ + // xor eax,edx /* toggle the CPUID bit */ + // push eax /* attempt to set EFLAGS to */ + // popfd /* the new value */ + // pushfd /* get the new EFLAGS value */ + // pop eax /* into eax */ + // xor eax,[esp] /* xor with original value */ + // and eax,edx /* has CPUID bit changed? */ + // setne al /* set to 1 if we have been */ + // mov ret_value,al /* able to change it */ + // popfd /* restore original EFLAGS */ + //} return (int)ret_value; } INLINE int is_via_cpu(void) { char ret_value; - __asm - { push ebx - xor eax,eax /* use CPUID to get vendor */ - cpuid /* identity string */ - xor eax,eax /* is it "CentaurHauls" ? */ - sub ebx,0x746e6543 /* 'Cent' */ - or eax,ebx - sub edx,0x48727561 /* 'aurH' */ - or eax,edx - sub ecx,0x736c7561 /* 'auls' */ - or eax,ecx - sete al /* set to 1 if it is VIA ID */ - mov dl,NEH_CPU_READ /* mark CPU type as read */ - or dl,al /* & store result in flags */ - mov [via_flags],dl /* set VIA detected flag */ - mov ret_value,al /* able to change it */ - pop ebx - } + //__asm + //{ push ebx + // xor eax,eax /* use CPUID to get vendor */ + // cpuid /* identity string */ + // xor eax,eax /* is it "CentaurHauls" ? */ + // sub ebx,0x746e6543 /* 'Cent' */ + // or eax,ebx + // sub edx,0x48727561 /* 'aurH' */ + // or eax,edx + // sub ecx,0x736c7561 /* 'auls' */ + // or eax,ecx + // sete al /* set to 1 if it is VIA ID */ + // mov dl,NEH_CPU_READ /* mark CPU type as read */ + // or dl,al /* & store result in flags */ + // mov [via_flags],dl /* set VIA detected flag */ + // mov ret_value,al /* able to change it */ + // pop ebx + //} return (int)ret_value; } INLINE int read_via_flags(void) { char ret_value = 0; - __asm - { mov eax,0xC0000000 /* Centaur extended CPUID */ - cpuid - mov edx,0xc0000001 /* >= 0xc0000001 if support */ - cmp eax,edx /* for VIA extended feature */ - jnae no_rng /* flags is available */ - mov eax,edx /* read Centaur extended */ - cpuid /* feature flags */ - mov eax,NEH_FLAGS_MASK /* mask out and save */ - and eax,edx /* the RNG and ACE flags */ - or [via_flags],al /* present & enabled flags */ - mov ret_value,al /* able to change it */ -no_rng: - } + //__asm + //{ mov eax,0xC0000000 /* Centaur extended CPUID */ + // cpuid + // mov edx,0xc0000001 /* >= 0xc0000001 if support */ + // cmp eax,edx /* for VIA extended feature */ + // jnae no_rng /* flags is available */ + // mov eax,edx /* read Centaur extended */ + // cpuid /* feature flags */ + // mov eax,NEH_FLAGS_MASK /* mask out and save */ + // and eax,edx /* the RNG and ACE flags */ + // or [via_flags],al /* present & enabled flags */ + // mov ret_value,al /* able to change it */ +//no_rng: + //} return (int)ret_value; } INLINE unsigned int via_rng_in(void *buf) { char ret_value = 0x1f; - __asm - { push edi - mov edi,buf /* input buffer address */ - xor edx,edx /* try to fetch 8 bytes */ - NEH_RNG /* do RNG read operation */ - and ret_value,al /* count of bytes returned */ - pop edi - } + // __asm + // { push edi + // mov edi,buf /* input buffer address */ + // xor edx,edx /* try to fetch 8 bytes */ + // NEH_RNG /* do RNG read operation */ + // and ret_value,al /* count of bytes returned */ + // pop edi + // } return (int)ret_value; } INLINE void via_ecb_op5( const void *k, const void *c, const void *s, void *d, int l) -{ __asm +{ /*__asm { push ebx NEH_REKEY mov ebx, (k) @@ -228,12 +228,12 @@ INLINE void via_ecb_op5( mov ecx, (l) NEH_ECB pop ebx - } + }*/ } INLINE void via_cbc_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) -{ __asm +{ /* __asm { push ebx NEH_REKEY mov ebx, (k) @@ -244,12 +244,12 @@ INLINE void via_cbc_op6( mov eax, (v) NEH_CBC pop ebx - } + }*/ } INLINE void via_cbc_op7( const void *k, const void *c, const void *s, void *d, int l, void *v, void *w) -{ __asm +{ /*__asm { push ebx NEH_REKEY mov ebx, (k) @@ -266,12 +266,12 @@ INLINE void via_cbc_op7( movsd movsd pop ebx - } + }*/ } INLINE void via_cfb_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) -{ __asm +{ /*__asm { push ebx NEH_REKEY mov ebx, (k) @@ -282,12 +282,12 @@ INLINE void via_cfb_op6( mov eax, (v) NEH_CFB pop ebx - } + }*/ } INLINE void via_cfb_op7( const void *k, const void *c, const void *s, void *d, int l, void *v, void *w) -{ __asm +{ /*__asm { push ebx NEH_REKEY mov ebx, (k) @@ -304,12 +304,12 @@ INLINE void via_cfb_op7( movsd movsd pop ebx - } + }*/ } INLINE void via_ofb_op6( const void *k, const void *c, const void *s, void *d, int l, void *v) -{ __asm +{ /*__asm { push ebx NEH_REKEY mov ebx, (k) @@ -320,7 +320,7 @@ INLINE void via_ofb_op6( mov eax, (v) NEH_OFB pop ebx - } + }*/ } #elif defined( __GNUC__ ) diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/SimonReloaded/SimonReloaded.vcxproj b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/SimonReloaded/SimonReloaded.vcxproj index 69bda66..5444bca 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/SimonReloaded/SimonReloaded.vcxproj +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/DarkSDKMore/SimonReloaded/SimonReloaded.vcxproj @@ -39,58 +39,58 @@ Win32Proj SimonReloaded InfiniteVegetation - 10.0.17763.0 + 10.0 StaticLibrary true - v141 + v143 NotSet StaticLibrary true - v141 + v143 NotSet StaticLibrary true - v141 + v143 NotSet StaticLibrary true - v141 + v143 NotSet StaticLibrary false - v141 + v143 true NotSet StaticLibrary false - v141 + v143 true NotSet StaticLibrary false - v141 + v143 true NotSet StaticLibrary false - v141 + v143 true NotSet @@ -160,8 +160,8 @@ false - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(IncludePath);$(IncludePath) - C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\DirectX\Effect11\Bin;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(IncludePath) + $(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath) $(ProjectDir)..\..\..\Lib64\ diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Core/DBDLLCore.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Core/DBDLLCore.cpp index 05b4b33..f5af250 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Core/DBDLLCore.cpp +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Core/DBDLLCore.cpp @@ -59,17 +59,17 @@ #include "CTextC.h" #include "CSystemC.h" #include "BulletPhysics.H" -#include "BlitzTerrain.H" -#include "DarkAI.H" +//#include "BlitzTerrain.H" +//#include "DarkAI.H" #include "SoftwareCulling.h" -#include "DarkLUA.h" +//#include "DarkLUA.h" #include "SimonReloaded.h" #ifdef PHOTONMP #include "PhotonCommands.h" #else #include "SteamCommands.h" #endif -#include "LightMapper.h" +//#include "LightMapper.h" #include "Enchancements.h" #ifdef VRTECH @@ -2310,7 +2310,7 @@ DARKSDK DWORD InitDisplayEx(DWORD dwDisplayType, DWORD dwWidth, DWORD dwHeight, if ( g_pGlob->hWnd ) { // override window handle with new winproc - SetWindowLong ( g_pGlob->hWnd, GWL_WNDPROC, (LONG)WindowProc ); + SetWindowLong ( g_pGlob->hWnd, GWLP_WNDPROC, (LONG)WindowProc ); } else { diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Setup/CGfxC.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Setup/CGfxC.cpp index 1b7c4be..1a68ac5 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Setup/CGfxC.cpp +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/Setup/CGfxC.cpp @@ -1101,7 +1101,7 @@ DARKSDK void DB_UpdateEntireWindow(bool bFullUpdate, bool bMovement) DWORD dwActualWindowHeight = gWindowSizeY+gWindowExtraY; SetWindowPos(m_hWnd, HWND_TOP, g_pGlob->dwWindowX, g_pGlob->dwWindowY, dwActualWindowWidth, dwActualWindowHeight, SWP_SHOWWINDOW); ShowWindow(m_hWnd, gWindowVisible); - SetClassLong(m_hWnd, GCL_HICON, (LONG)gWindowIconHandle); + SetClassLong(m_hWnd, GCLP_HICON, (LONG)gWindowIconHandle); } // Paint after window switch diff --git a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/System/CSystemC.cpp b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/System/CSystemC.cpp index 42e2a7b..0b072bd 100644 --- a/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/System/CSystemC.cpp +++ b/GameGuru Core/Dark Basic Public Shared/Dark Basic Pro SDK/Shared/System/CSystemC.cpp @@ -119,7 +119,7 @@ DARKSDK bool Call(HINSTANCE hDLLModule, char* DecoratedName, DWORD* pDataAddress // Store ESP DWORD dwStore; - __asm mov dword ptr dwStore, esp + /*__asm mov dword ptr dwStore, esp // Params Pushed Onto Stack (backwards) for(int p=1; p<=paramnum; p++) @@ -127,16 +127,16 @@ DARKSDK bool Call(HINSTANCE hDLLModule, char* DecoratedName, DWORD* pDataAddress DWORD pDataItem = *((pDataAddress+paramnum)-p); __asm mov eax,dword ptr pDataItem __asm push eax - } + }*/ // Call DLL Function - __asm call dword ptr fpAddress + /*__asm call dword ptr fpAddress __asm add esp,4 __asm mov ecx,dword ptr ReturnData - __asm mov dword ptr [ecx],eax + __asm mov dword ptr [ecx],eax*/ // Restore ESP - __asm mov esp, dwStore + /*__asm mov esp, dwStore*/ // Success return true; diff --git a/GameGuru Core/GameGuru-Converter.sln b/GameGuru Core/GameGuru-Converter.sln index 55cc820..8a00bd5 100644 --- a/GameGuru Core/GameGuru-Converter.sln +++ b/GameGuru Core/GameGuru-Converter.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2048 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35013.160 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Basic2D", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDK\Basic2D\Basic2D.vcxproj", "{6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495}" EndProject @@ -49,102 +49,76 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Guru-Converter", "Guru-MapE {C22CB11E-0592-4DDD-B8D8-296FCA25F07C} = {C22CB11E-0592-4DDD-B8D8-296FCA25F07C} {35D0D628-907B-4378-95E1-EEF2B5E891BF} = {35D0D628-907B-4378-95E1-EEF2B5E891BF} {73383739-8763-47B9-8A3F-6727B491191D} = {73383739-8763-47B9-8A3F-6727B491191D} - {DC3D254B-0B9C-4272-B2DC-D0B06835D3A0} = {DC3D254B-0B9C-4272-B2DC-D0B06835D3A0} {6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495} = {6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495} {FDB42674-ABA0-41AC-9552-C5B6A6DECDDB} = {FDB42674-ABA0-41AC-9552-C5B6A6DECDDB} - {E6C0DB75-910C-4085-B029-33D8503487A7} = {E6C0DB75-910C-4085-B029-33D8503487A7} {19D06E7C-892B-4461-87C6-166634AB6513} = {19D06E7C-892B-4461-87C6-166634AB6513} {0CEC8E92-9523-4E59-A9AD-E9CB4DF8D6E9} = {0CEC8E92-9523-4E59-A9AD-E9CB4DF8D6E9} - {4A27C896-E37C-4317-87B4-6229F5F38DC2} = {4A27C896-E37C-4317-87B4-6229F5F38DC2} {8C00A1AC-3F37-494E-A463-E48F82075792} = {8C00A1AC-3F37-494E-A463-E48F82075792} {3B7BC9B2-3FDB-4129-A700-59F05B480293} = {3B7BC9B2-3FDB-4129-A700-59F05B480293} {E72F0AB4-B8E1-4424-96DC-4C23F167FCA6} = {E72F0AB4-B8E1-4424-96DC-4C23F167FCA6} {B81553CC-39BB-4542-A379-F49D2F3A73A3} = {B81553CC-39BB-4542-A379-F49D2F3A73A3} {368D8DDB-C349-4FF1-A848-1D14C0944500} = {368D8DDB-C349-4FF1-A848-1D14C0944500} - {205846E1-5ECC-4E71-81CB-3CB34045ADA2} = {205846E1-5ECC-4E71-81CB-3CB34045ADA2} {526FC1E7-C827-4701-8810-6DAEA738E0C4} = {526FC1E7-C827-4701-8810-6DAEA738E0C4} {8563B5F0-10AC-494E-B27B-0A7AFD0BD0E1} = {8563B5F0-10AC-494E-B27B-0A7AFD0BD0E1} {4A04C2F5-7052-47E2-AC88-2BA8AE2DD9F3} = {4A04C2F5-7052-47E2-AC88-2BA8AE2DD9F3} {1311DBF5-D188-4034-B25D-AE7A36878C01} = {1311DBF5-D188-4034-B25D-AE7A36878C01} - {C5451FF8-7264-4300-9F2D-325FE8301E51} = {C5451FF8-7264-4300-9F2D-325FE8301E51} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlitzTerrain", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\BlitzTerrain\BlitzTerrain.vcxproj", "{DC3D254B-0B9C-4272-B2DC-D0B06835D3A0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlitzTerrain_RTTMSPlugin", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\BlitzTerrain_RTTMSPlugin\BlitzTerrain_RTTMSPlugin.vcxproj", "{205846E1-5ECC-4E71-81CB-3CB34045ADA2}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPU3D", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\CPU3D\CPU3DTest.vcxproj", "{526FC1E7-C827-4701-8810-6DAEA738E0C4}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DarkAI", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkAI\DarkMind.vcxproj", "{4A27C896-E37C-4317-87B4-6229F5F38DC2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DarkLUA", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\DarkLUA.vcxproj", "{C5451FF8-7264-4300-9F2D-325FE8301E51}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Enhancements", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\Enhancements\Main.vcxproj", "{0CEC8E92-9523-4E59-A9AD-E9CB4DF8D6E9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InfiniteVegetation", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\SimonReloaded\SimonReloaded.vcxproj", "{8C00A1AC-3F37-494E-A463-E48F82075792}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LightMapper", "Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLIGHTS\LightMapper.vcxproj", "{E6C0DB75-910C-4085-B029-33D8503487A7}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495}.Release|Win32.ActiveCfg = Release|Win32 - {6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495}.Release|Win32.Build.0 = Release|Win32 - {D7763803-1667-4016-ACA2-F595DD7581ED}.Release|Win32.ActiveCfg = Release|Win32 - {D7763803-1667-4016-ACA2-F595DD7581ED}.Release|Win32.Build.0 = Release|Win32 - {1311DBF5-D188-4034-B25D-AE7A36878C01}.Release|Win32.ActiveCfg = Release|Win32 - {1311DBF5-D188-4034-B25D-AE7A36878C01}.Release|Win32.Build.0 = Release|Win32 - {06E6A302-6658-4E0E-A894-577D5BD556D7}.Release|Win32.ActiveCfg = Release|Win32 - {06E6A302-6658-4E0E-A894-577D5BD556D7}.Release|Win32.Build.0 = Release|Win32 - {B81553CC-39BB-4542-A379-F49D2F3A73A3}.Release|Win32.ActiveCfg = Release|Win32 - {B81553CC-39BB-4542-A379-F49D2F3A73A3}.Release|Win32.Build.0 = Release|Win32 - {19D06E7C-892B-4461-87C6-166634AB6513}.Release|Win32.ActiveCfg = Release|Win32 - {19D06E7C-892B-4461-87C6-166634AB6513}.Release|Win32.Build.0 = Release|Win32 - {C0A62805-4411-4176-A24A-91CE14219778}.Release|Win32.ActiveCfg = Release|Win32 - {C0A62805-4411-4176-A24A-91CE14219778}.Release|Win32.Build.0 = Release|Win32 - {8BA32D12-D5B1-412B-967A-C329376CBEC6}.Release|Win32.ActiveCfg = Release|Win32 - {8BA32D12-D5B1-412B-967A-C329376CBEC6}.Release|Win32.Build.0 = Release|Win32 - {3B7BC9B2-3FDB-4129-A700-59F05B480293}.Release|Win32.ActiveCfg = Release|Win32 - {3B7BC9B2-3FDB-4129-A700-59F05B480293}.Release|Win32.Build.0 = Release|Win32 - {8563B5F0-10AC-494E-B27B-0A7AFD0BD0E1}.Release|Win32.ActiveCfg = Release|Win32 - {8563B5F0-10AC-494E-B27B-0A7AFD0BD0E1}.Release|Win32.Build.0 = Release|Win32 - {FDB42674-ABA0-41AC-9552-C5B6A6DECDDB}.Release|Win32.ActiveCfg = Release|Win32 - {FDB42674-ABA0-41AC-9552-C5B6A6DECDDB}.Release|Win32.Build.0 = Release|Win32 - {5EC29E1C-8C20-4C9C-9C2D-71493CE16D73}.Release|Win32.ActiveCfg = Release|Win32 - {5EC29E1C-8C20-4C9C-9C2D-71493CE16D73}.Release|Win32.Build.0 = Release|Win32 - {C22CB11E-0592-4DDD-B8D8-296FCA25F07C}.Release|Win32.ActiveCfg = Release|Win32 - {C22CB11E-0592-4DDD-B8D8-296FCA25F07C}.Release|Win32.Build.0 = Release|Win32 - {368D8DDB-C349-4FF1-A848-1D14C0944500}.Release|Win32.ActiveCfg = Release|Win32 - {368D8DDB-C349-4FF1-A848-1D14C0944500}.Release|Win32.Build.0 = Release|Win32 - {35D0D628-907B-4378-95E1-EEF2B5E891BF}.Release|Win32.ActiveCfg = Release|Win32 - {35D0D628-907B-4378-95E1-EEF2B5E891BF}.Release|Win32.Build.0 = Release|Win32 - {73383739-8763-47B9-8A3F-6727B491191D}.Release|Win32.ActiveCfg = Release|Win32 - {73383739-8763-47B9-8A3F-6727B491191D}.Release|Win32.Build.0 = Release|Win32 - {E72F0AB4-B8E1-4424-96DC-4C23F167FCA6}.Release|Win32.ActiveCfg = Release|Win32 - {E72F0AB4-B8E1-4424-96DC-4C23F167FCA6}.Release|Win32.Build.0 = Release|Win32 - {4A04C2F5-7052-47E2-AC88-2BA8AE2DD9F3}.Release|Win32.ActiveCfg = Release|Win32 - {4A04C2F5-7052-47E2-AC88-2BA8AE2DD9F3}.Release|Win32.Build.0 = Release|Win32 - {18217E4D-F8C2-44C6-9A36-31196E758A0C}.Release|Win32.ActiveCfg = Release|Win32 - {18217E4D-F8C2-44C6-9A36-31196E758A0C}.Release|Win32.Build.0 = Release|Win32 - {18217E4D-F8C2-44C6-9A36-31196E758A0C}.Release|Win32.Deploy.0 = Release|Win32 - {DC3D254B-0B9C-4272-B2DC-D0B06835D3A0}.Release|Win32.ActiveCfg = Release|Win32 - {DC3D254B-0B9C-4272-B2DC-D0B06835D3A0}.Release|Win32.Build.0 = Release|Win32 - {205846E1-5ECC-4E71-81CB-3CB34045ADA2}.Release|Win32.ActiveCfg = Release|Win32 - {205846E1-5ECC-4E71-81CB-3CB34045ADA2}.Release|Win32.Build.0 = Release|Win32 - {526FC1E7-C827-4701-8810-6DAEA738E0C4}.Release|Win32.ActiveCfg = Release|Win32 - {526FC1E7-C827-4701-8810-6DAEA738E0C4}.Release|Win32.Build.0 = Release|Win32 - {4A27C896-E37C-4317-87B4-6229F5F38DC2}.Release|Win32.ActiveCfg = Release|Win32 - {4A27C896-E37C-4317-87B4-6229F5F38DC2}.Release|Win32.Build.0 = Release|Win32 - {C5451FF8-7264-4300-9F2D-325FE8301E51}.Release|Win32.ActiveCfg = Release|Win32 - {C5451FF8-7264-4300-9F2D-325FE8301E51}.Release|Win32.Build.0 = Release|Win32 - {0CEC8E92-9523-4E59-A9AD-E9CB4DF8D6E9}.Release|Win32.ActiveCfg = Release|Win32 - {0CEC8E92-9523-4E59-A9AD-E9CB4DF8D6E9}.Release|Win32.Build.0 = Release|Win32 - {8C00A1AC-3F37-494E-A463-E48F82075792}.Release|Win32.ActiveCfg = Release|Win32 - {8C00A1AC-3F37-494E-A463-E48F82075792}.Release|Win32.Build.0 = Release|Win32 - {E6C0DB75-910C-4085-B029-33D8503487A7}.Release|Win32.ActiveCfg = Release|Win32 - {E6C0DB75-910C-4085-B029-33D8503487A7}.Release|Win32.Build.0 = Release|Win32 + {6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495}.Release|x64.ActiveCfg = Release|x64 + {6F7FC773-D0E4-4FC4-BB3F-2FF5DC3EA495}.Release|x64.Build.0 = Release|x64 + {D7763803-1667-4016-ACA2-F595DD7581ED}.Release|x64.ActiveCfg = Release|x64 + {D7763803-1667-4016-ACA2-F595DD7581ED}.Release|x64.Build.0 = Release|x64 + {1311DBF5-D188-4034-B25D-AE7A36878C01}.Release|x64.ActiveCfg = Release|x64 + {1311DBF5-D188-4034-B25D-AE7A36878C01}.Release|x64.Build.0 = Release|x64 + {06E6A302-6658-4E0E-A894-577D5BD556D7}.Release|x64.ActiveCfg = Release|x64 + {06E6A302-6658-4E0E-A894-577D5BD556D7}.Release|x64.Build.0 = Release|x64 + {B81553CC-39BB-4542-A379-F49D2F3A73A3}.Release|x64.ActiveCfg = Release|x64 + {B81553CC-39BB-4542-A379-F49D2F3A73A3}.Release|x64.Build.0 = Release|x64 + {19D06E7C-892B-4461-87C6-166634AB6513}.Release|x64.ActiveCfg = Release|x64 + {19D06E7C-892B-4461-87C6-166634AB6513}.Release|x64.Build.0 = Release|x64 + {C0A62805-4411-4176-A24A-91CE14219778}.Release|x64.ActiveCfg = Release|x64 + {C0A62805-4411-4176-A24A-91CE14219778}.Release|x64.Build.0 = Release|x64 + {8BA32D12-D5B1-412B-967A-C329376CBEC6}.Release|x64.ActiveCfg = Release|x64 + {8BA32D12-D5B1-412B-967A-C329376CBEC6}.Release|x64.Build.0 = Release|x64 + {3B7BC9B2-3FDB-4129-A700-59F05B480293}.Release|x64.ActiveCfg = Release|x64 + {3B7BC9B2-3FDB-4129-A700-59F05B480293}.Release|x64.Build.0 = Release|x64 + {8563B5F0-10AC-494E-B27B-0A7AFD0BD0E1}.Release|x64.ActiveCfg = Release|x64 + {8563B5F0-10AC-494E-B27B-0A7AFD0BD0E1}.Release|x64.Build.0 = Release|x64 + {FDB42674-ABA0-41AC-9552-C5B6A6DECDDB}.Release|x64.ActiveCfg = Release|x64 + {FDB42674-ABA0-41AC-9552-C5B6A6DECDDB}.Release|x64.Build.0 = Release|x64 + {5EC29E1C-8C20-4C9C-9C2D-71493CE16D73}.Release|x64.ActiveCfg = Release|x64 + {5EC29E1C-8C20-4C9C-9C2D-71493CE16D73}.Release|x64.Build.0 = Release|x64 + {C22CB11E-0592-4DDD-B8D8-296FCA25F07C}.Release|x64.ActiveCfg = Release|x64 + {C22CB11E-0592-4DDD-B8D8-296FCA25F07C}.Release|x64.Build.0 = Release|x64 + {368D8DDB-C349-4FF1-A848-1D14C0944500}.Release|x64.ActiveCfg = Release|x64 + {368D8DDB-C349-4FF1-A848-1D14C0944500}.Release|x64.Build.0 = Release|x64 + {35D0D628-907B-4378-95E1-EEF2B5E891BF}.Release|x64.ActiveCfg = Release|x64 + {35D0D628-907B-4378-95E1-EEF2B5E891BF}.Release|x64.Build.0 = Release|x64 + {73383739-8763-47B9-8A3F-6727B491191D}.Release|x64.ActiveCfg = Release|x64 + {73383739-8763-47B9-8A3F-6727B491191D}.Release|x64.Build.0 = Release|x64 + {E72F0AB4-B8E1-4424-96DC-4C23F167FCA6}.Release|x64.ActiveCfg = Release|x64 + {E72F0AB4-B8E1-4424-96DC-4C23F167FCA6}.Release|x64.Build.0 = Release|x64 + {4A04C2F5-7052-47E2-AC88-2BA8AE2DD9F3}.Release|x64.ActiveCfg = Release|x64 + {4A04C2F5-7052-47E2-AC88-2BA8AE2DD9F3}.Release|x64.Build.0 = Release|x64 + {18217E4D-F8C2-44C6-9A36-31196E758A0C}.Release|x64.ActiveCfg = Release|x64 + {18217E4D-F8C2-44C6-9A36-31196E758A0C}.Release|x64.Build.0 = Release|x64 + {526FC1E7-C827-4701-8810-6DAEA738E0C4}.Release|x64.ActiveCfg = Release|x64 + {526FC1E7-C827-4701-8810-6DAEA738E0C4}.Release|x64.Build.0 = Release|x64 + {0CEC8E92-9523-4E59-A9AD-E9CB4DF8D6E9}.Release|x64.ActiveCfg = Release|x64 + {0CEC8E92-9523-4E59-A9AD-E9CB4DF8D6E9}.Release|x64.Build.0 = Release|x64 + {8C00A1AC-3F37-494E-A463-E48F82075792}.Release|x64.ActiveCfg = Release|x64 + {8C00A1AC-3F37-494E-A463-E48F82075792}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/GameGuru Core/Guru-MapEditor/DarkEXE.cpp b/GameGuru Core/Guru-MapEditor/DarkEXE.cpp index e768bfe..c743f70 100644 --- a/GameGuru Core/Guru-MapEditor/DarkEXE.cpp +++ b/GameGuru Core/Guru-MapEditor/DarkEXE.cpp @@ -14,7 +14,7 @@ #include "time.h" // Defines and Externs -#include "DarkEXE.h" +//#include "DarkEXE.h" #include "resource.h" #include "globstruct.h" #include "EXEBlock.h" diff --git a/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj b/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj index e1ee57c..76e8a50 100644 --- a/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj +++ b/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj @@ -5,19 +5,29 @@ Release Win32 + + Release + x64 + {18217E4D-F8C2-44C6-9A36-31196E758A0C} DarkEXE Guru-Converter - 8.1 + 10.0 Application false MultiByte - v141 + v143 + + + Application + false + MultiByte + v143 @@ -26,22 +36,36 @@ + + + + <_ProjectFileVersion>10.0.30319.1 - C:\DEV\BUILDS\GameGuru Classic Build Area\ + D:\DEV\BUILDS\GameGuru Classic Build Area\ $(ProjectDir)$(Configuration)\ false + false AllRules.ruleset + AllRules.ruleset + + C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\include;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\include;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.10150.0\ucrt;C:\Program Files %28x86%29\Windows Kits\8.1\Include\um;C:\Program Files %28x86%29\Windows Kits\8.1\Include\shared;$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include\;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\NVAPI;$(SolutionDir)SDK\DirectXTex\DirectXTex\;C:\Program Files\Autodesk\FBX\FBX SDK\2016.1.2\include;$(SolutionDir)SDK\VuzixSDK\inc + $(WindowsSDK_IncludePath);$(VC_IncludePath);$(SolutionDir)SDK\DirectX\;$(SolutionDir)SDK\DirectX\Include\;$(SolutionDir)SDK\DB3\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\EAX2\Include\;$(SolutionDir)SDK\VuzixSDK\inc\;D:\DEVS\GameGuruConverter\GameGuru Core\SDK\DirectX\Effect11;D:\DEVS\GameGuruConverter\GameGuru Core\SDK\DirectX\Effect11\inc;$(SolutionDir)SDK\DirectXTex\DirectXTex\;$(SolutionDir)SDK\DirectXTex\DDSTextureLoader;C:\Program Files\Autodesk\FBX\FBX SDK\2016.1.2\include $(SolutionDir)SDK\THEORA\lib\win32_static_2015\;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\atlmfc\lib;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.1A\Lib;C:\Program Files %28x86%29\Microsoft Visual Studio 14.0\VC\lib;$(SolutionDir)SDK\DirectX\Lib\x86;$(SolutionDir)SDK\NVAPI\x86;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath);$(SolutionDir)SDK\OGG\lib;$(SolutionDir)SDK\DirectX\Effect11\Bin\Release_2017;$(SolutionDir)SDK\DirectXTex\DirectXTex\Bin\Desktop_2017\Win32\Release;C:\Program Files\Autodesk\FBX\FBX SDK\2016.1.2\lib\vs2015\x86\release;$(SolutionDir)SDK\VuzixSDK\lib true true + + $(SolutionDir)SDK\DirectX\Lib\x64\;$(SolutionDir)SDK\DirectX\Effect11\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\DirectXTex\DirectXTex\Bin\Desktop_2022\x64\$(Configuration)\;$(SolutionDir)SDK\BaseClasses\;$(SolutionDir)SDK\BCG\Bin7\;$(SolutionDir)SDK\EAX2\Libs\;$(LibraryPath);$(SolutionDir)SDK\OGG\lib;C:\Program Files\Autodesk\FBX\FBX SDK\2016.1.2\lib\vs2015\x64\release;$(SolutionDir)SDK\VuzixSDK\lib + true + true + NDEBUG;%(PreprocessorDefinitions) @@ -55,7 +79,7 @@ Full Default - _USING_V110_SDK71_;DARKEXE;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + _USING_V110_SDK71_;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true Default MultiThreaded @@ -63,7 +87,8 @@ true - .\Release/DarkEXE.pch + + .\Release/ .\Release/ .\Release/ @@ -79,7 +104,7 @@ /FIXED:NO /STACK:1000000 %(AdditionalOptions) - TrackerMath.lib;D3dxof.lib;DXGI.lib;DirectXTex.lib;D3D11.lib;D3DX11.lib;D3DCompiler.lib;D3DX11Effects.lib;DBDLLCore.lib;Enhancements.lib;InfiniteVegetation.lib;DarkLua.lib;CPU3D.lib;BlitzTerrain.lib;BlitzTerrain_RTTMSPlugin.lib;DarkAI.lib;Psapi.lib;system.lib;text.lib;input.lib;Bullet.lib;setup.lib;Basic3D.lib;ftp.lib;memblocks.lib;file.lib;$(ProjectDir)..\Dark Basic Public Shared\Dark Basic Pro SDK\Shared\BaseClasses\strmbase.lib;d3dx9.lib;d3d9.lib;winmm.lib;odbc32.lib;odbccp32.lib;bitmap.lib;basic2d.lib;olepro32.lib;strmiids.lib;quartz.lib;msacm32.lib;ConvX.lib;Light.lib;Sprites.lib;Vectors.lib;Image.lib;Setup.lib;Camera.lib;Version.lib;dxguid.lib;%(AdditionalDependencies) + D3dxof.lib;DXGI.lib;DirectXTex.lib;D3DX11.lib;D3D11.lib;D3DCompiler.lib;D3DX11Effects.lib;Enhancements.lib;InfiniteVegetation.lib;DBDLLCore.lib;CPU3D.lib;system.lib;text.lib;input.lib;Bullet.lib;setup.lib;Basic3D.lib;ftp.lib;memblocks.lib;file.lib;d3dx9.lib;d3d9.lib;ConvX.lib;bitmap.lib;basic2d.lib;Light.lib;Sprites.lib;Vectors.lib;Image.lib;Setup.lib;Camera.lib;dxguid.lib;%(AdditionalDependencies) $(OutDir)$(TargetName)$(TargetExt) true @@ -110,18 +135,89 @@ + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/DarkEXE.tlb + + + + + Full + Default + _USING_V110_SDK71_;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + true + true + + + + + .\Release/ + .\Release/ + .\Release/ + Level3 + true + $(ProjectDir)..\GameGuru\Include;$(ProjectDir)..\GameGuruClassicLegacy\Include;%(AdditionalIncludeDirectories);$(ProjectDir)..\Dark Basic Public Shared\Include\;$(ProjectDir) + 4005;4995;4723 + false + + + NDEBUG;%(PreprocessorDefinitions) + 0x0809 + + + /FIXED:NO /STACK:1000000 %(AdditionalOptions) + D3dxof.lib;DXGI.lib;DirectXTex.lib;D3DX11.lib;D3D11.lib;D3DCompiler.lib;Effects11.lib;Enhancements.lib;InfiniteVegetation.lib;DBDLLCore.lib;CPU3D.lib;system.lib;text.lib;input.lib;Bullet.lib;setup.lib;Basic3D.lib;ftp.lib;memblocks.lib;file.lib;d3dx9.lib;d3d9.lib;ConvX.lib;bitmap.lib;basic2d.lib;Light.lib;Sprites.lib;Vectors.lib;Image.lib;Setup.lib;Camera.lib;dxguid.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName)$(TargetExt) + true + + + Windows + 0 + 0 + + + false + + + + + true + true + true + $(ProjectDir)..\Dark Basic Public Shared\Dark Basic Pro SDK\DarkSDKMore\DarkLUA\lua\;$(ProjectDir)..\Dark Basic Public Shared\Lib64;$(ProjectDir)..\SDK\Steamworks SDK\Steamworks SDK\public\steam\lib\win64;$(ProjectDir)..\SDK\Steamworks SDK\Steamworks SDK\redistributable_bin\win64 + + + false + No + false + false + true + + + + MaxSpeed + MaxSpeed %(PreprocessorDefinitions) + %(PreprocessorDefinitions) MaxSpeed + MaxSpeed %(PreprocessorDefinitions) + %(PreprocessorDefinitions) diff --git a/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj.user b/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj.user index 196a7c0..ce9db23 100644 --- a/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj.user +++ b/GameGuru Core/Guru-MapEditor/DarkEXE.vcxproj.user @@ -1,8 +1,13 @@  - C:\DEV\BUILDS\GameGuru Classic Build Area\Guru-Converter.exe - C:\DEV\BUILDS\GameGuru Classic Build Area\ + D:\DEV\BUILDS\GameGuru Classic Build Area\Guru-Converter.exe + D:\DEV\BUILDS\GameGuru Classic Build Area\ + WindowsLocalDebugger + + + D:\DEV\BUILDS\GameGuru Classic Build Area\Guru-Converter.exe + D:\DEV\BUILDS\GameGuru Classic Build Area\ WindowsLocalDebugger \ No newline at end of file diff --git a/GameGuru Core/Guru-MapEditor/GameGuruEngine.h b/GameGuru Core/Guru-MapEditor/GameGuruEngine.h index df77214..3f4f737 100644 --- a/GameGuru Core/Guru-MapEditor/GameGuruEngine.h +++ b/GameGuru Core/Guru-MapEditor/GameGuruEngine.h @@ -8,7 +8,7 @@ extern bool g_bCascadeQuitFlag; // Main command headers #include "CGfxC.h" -#include "CObjectsC.h" +//#include "CObjectsC.h" #include "CCameraC.h" #include "CImageC.h" #include "cVectorC.h" @@ -18,7 +18,7 @@ extern bool g_bCascadeQuitFlag; #include "CSoundC.h" #include "CBasic2DC.h" #include "CBitmapC.h" -#include "CAnimation.h" +//#include "CAnimation.h" #include "CFileC.h" #include "CMemblocks.h" #include "CFTPC.h" @@ -26,11 +26,11 @@ extern bool g_bCascadeQuitFlag; #include "CTextC.h" #include "CSystemC.h" #include "BulletPhysics.H" -#include "BlitzTerrain.H" -#include "DarkAI.H" +//#include "BlitzTerrain.H" +//#include "DarkAI.H" #include "SoftwareCulling.h" -#include "DarkLUA.h" +//#include "DarkLUA.h" #include "SimonReloaded.h" -#include "LightMapper.h" +//#include "LightMapper.h" #include "Enchancements.h" diff --git a/GameGuru Core/Guru-MapEditor/dbproexe.aps b/GameGuru Core/Guru-MapEditor/dbproexe.aps new file mode 100644 index 0000000..a3c3174 Binary files /dev/null and b/GameGuru Core/Guru-MapEditor/dbproexe.aps differ diff --git a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.sln b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.sln deleted file mode 100644 index 37e01fa..0000000 --- a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.sln +++ /dev/null @@ -1,33 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Effects11", "Effects11_2015(oldVS2015).vcxproj", "{160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Profile|Win32 = Profile|Win32 - Profile|x64 = Profile|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Debug|Win32.Build.0 = Debug|Win32 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Debug|x64.ActiveCfg = Debug|x64 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Debug|x64.Build.0 = Debug|x64 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Profile|Win32.ActiveCfg = Profile|Win32 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Profile|Win32.Build.0 = Profile|Win32 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Profile|x64.ActiveCfg = Profile|x64 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Profile|x64.Build.0 = Profile|x64 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Release|Win32.ActiveCfg = Release|Win32 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Release|Win32.Build.0 = Release|Win32 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Release|x64.ActiveCfg = Release|x64 - {160A52BC-4306-4FD5-98E3-30A8CC7E6EF8}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.vcxproj b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.vcxproj deleted file mode 100644 index 64f372e..0000000 --- a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.vcxproj +++ /dev/null @@ -1,419 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - Effects11 - {DF460EAB-570D-4B50-9089-2E2FC801BF38} - Effects11 - Win32Proj - 10.0.17763.0 - - - - StaticLibrary - Unicode - v141 - - - StaticLibrary - Unicode - v141 - - - StaticLibrary - Unicode - v141 - - - StaticLibrary - Unicode - v141 - - - StaticLibrary - Unicode - v141 - - - StaticLibrary - Unicode - v141 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Debug\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - D3DX11Effects - AllRules.ruleset - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Effects11d - AllRules.ruleset - - - Bin\Release_2017\ - Bin\Desktop_2017\$(Platform)\$(Configuration)\ - D3DX11Effects - AllRules.ruleset - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Effects11 - AllRules.ruleset - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Effects11 - AllRules.ruleset - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Effects11 - AllRules.ruleset - - - - Level4 - Disabled - MultiThreadedDebug - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - Sync - .\Binary;.\Inc;%(AdditionalIncludeDirectories) - pchfx.h - %(AdditionalOptions) - _WIN7_PLATFORM_UPDATE;WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - EditAndContinue - EnableFastChecks - Use - - - %(AdditionalOptions) - %(AdditionalDependencies) - Windows - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - Disabled - MultiThreadedDebugDLL - false - true - Fast - $(IntDir)$(TargetName).pdb - Sync - .\Binary;.\Inc;%(AdditionalIncludeDirectories) - pchfx.h - %(AdditionalOptions) - _WIN7_PLATFORM_UPDATE;WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - EnableFastChecks - Use - - - %(AdditionalOptions) - %(AdditionalDependencies) - Windows - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreaded - false - true - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - Sync - .\Binary;.\Inc;%(AdditionalIncludeDirectories) - pchfx.h - %(AdditionalOptions) - _WIN7_PLATFORM_UPDATE;WIN32;NDEBUG;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - - - %(AdditionalOptions) - %(AdditionalDependencies) - true - Windows - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - $(IntDir)$(TargetName).pdb - Sync - .\Binary;.\Inc;%(AdditionalIncludeDirectories) - pchfx.h - %(AdditionalOptions) - _WIN7_PLATFORM_UPDATE;WIN32;NDEBUG;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - - - %(AdditionalOptions) - %(AdditionalDependencies) - true - Windows - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - Sync - .\Binary;.\Inc;%(AdditionalIncludeDirectories) - pchfx.h - %(AdditionalOptions) - _WIN7_PLATFORM_UPDATE;WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - - - %(AdditionalOptions) - %(AdditionalDependencies) - true - Windows - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - $(IntDir)$(TargetName).pdb - Sync - .\Binary;.\Inc;%(AdditionalIncludeDirectories) - pchfx.h - %(AdditionalOptions) - _WIN7_PLATFORM_UPDATE;WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - - - %(AdditionalOptions) - %(AdditionalDependencies) - true - Windows - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2017.sln b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2017.sln deleted file mode 100644 index 9d0fe58..0000000 --- a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2017.sln +++ /dev/null @@ -1,31 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Effects11", "Effects11_2015.vcxproj", "{DF460EAB-570D-4B50-9089-2E2FC801BF38}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Profile|Win32 = Profile|Win32 - Profile|x64 = Profile|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Debug|Win32.ActiveCfg = Debug|Win32 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Debug|Win32.Build.0 = Debug|Win32 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Debug|x64.ActiveCfg = Debug|x64 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Debug|x64.Build.0 = Debug|x64 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Profile|Win32.ActiveCfg = Profile|Win32 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Profile|Win32.Build.0 = Profile|Win32 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Profile|x64.ActiveCfg = Profile|x64 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Profile|x64.Build.0 = Profile|x64 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Release|Win32.ActiveCfg = Release|Win32 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Release|Win32.Build.0 = Release|Win32 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Release|x64.ActiveCfg = Release|x64 - {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.sln b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.sln new file mode 100644 index 0000000..8107bfe --- /dev/null +++ b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Effects11", "Effects11_2022.vcxproj", "{DF460EAB-570D-4B50-9089-2E2FC801BF38}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Debug|x64.ActiveCfg = Debug|x64 + {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Debug|x64.Build.0 = Debug|x64 + {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Release|x64.ActiveCfg = Release|x64 + {DF460EAB-570D-4B50-9089-2E2FC801BF38}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9B12997B-D4A1-4F1C-9552-92F89F90DDBF} + EndGlobalSection +EndGlobal diff --git a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj new file mode 100644 index 0000000..b40830d --- /dev/null +++ b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj @@ -0,0 +1,171 @@ + + + + + Debug + x64 + + + Release + x64 + + + + Effects11 + {DF460EAB-570D-4B50-9089-2E2FC801BF38} + Effects11 + Win32Proj + 10.0 + + + + StaticLibrary + Unicode + v143 + + + StaticLibrary + Unicode + v143 + + + + + + + + + + + + Bin\Desktop_2022\$(Platform)\$(Configuration)\ + Bin\Desktop_2022\$(Platform)\$(Configuration)\ + Effects11 + AllRules.ruleset + + + Bin\Desktop_2022\$(Platform)\$(Configuration)\ + Bin\Desktop_2022\$(Platform)\$(Configuration)\ + Effects11 + AllRules.ruleset + + + + Level4 + Disabled + MultiThreadedDebug + false + true + Fast + $(IntDir)$(TargetName).pdb + Sync + .\Binary;.\Inc;%(AdditionalIncludeDirectories) + pchfx.h + %(AdditionalOptions) + _WIN7_PLATFORM_UPDATE;WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + EnableFastChecks + Use + stdcpp17 + + + %(AdditionalOptions) + %(AdditionalDependencies) + Windows + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + Level4 + MaxSpeed + MultiThreaded + false + true + true + Fast + $(IntDir)$(TargetName).pdb + Sync + .\Binary;.\Inc;%(AdditionalIncludeDirectories) + pchfx.h + %(AdditionalOptions) + _WIN7_PLATFORM_UPDATE;WIN32;NDEBUG;_WINDOWS;_LIB;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) + Use + stdcpp17 + + + %(AdditionalOptions) + %(AdditionalDependencies) + true + Windows + true + true + true + true + true + MachineX64 + AsInvoker + %(DelayLoadDLLs) + + + false + + + + + + + + + + + + + + + + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.vcxproj.filters b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj.filters similarity index 100% rename from GameGuru Core/SDK/DirectX/Effect11/Effects11_2015.vcxproj.filters rename to GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj.filters diff --git a/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj.user b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/GameGuru Core/SDK/DirectX/Effect11/Effects11_2022.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/D3DCSX.lib b/GameGuru Core/SDK/DirectX/Lib/x64/D3DCSX.lib new file mode 100644 index 0000000..8e2f059 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/D3DCSX.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/D3DCSXd.lib b/GameGuru Core/SDK/DirectX/Lib/x64/D3DCSXd.lib new file mode 100644 index 0000000..6735a4d Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/D3DCSXd.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/DxErr.lib b/GameGuru Core/SDK/DirectX/Lib/x64/DxErr.lib similarity index 50% rename from GameGuru Core/SDK/DirectX/Lib/x86/DxErr.lib rename to GameGuru Core/SDK/DirectX/Lib/x64/DxErr.lib index 8c7651e..a4fb226 100644 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/DxErr.lib and b/GameGuru Core/SDK/DirectX/Lib/x64/DxErr.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/X3DAudio.lib b/GameGuru Core/SDK/DirectX/Lib/x64/X3DAudio.lib new file mode 100644 index 0000000..3f73021 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/X3DAudio.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/XAPOFX.lib b/GameGuru Core/SDK/DirectX/Lib/x64/XAPOFX.lib new file mode 100644 index 0000000..02a6525 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/XAPOFX.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/XInput.lib b/GameGuru Core/SDK/DirectX/Lib/x64/XInput.lib new file mode 100644 index 0000000..5545d28 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/XInput.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d2d1.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d2d1.lib new file mode 100644 index 0000000..505e6d7 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d2d1.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3d10.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3d10.lib new file mode 100644 index 0000000..2b08450 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3d10.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3d10_1.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3d10_1.lib new file mode 100644 index 0000000..4b2ef62 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3d10_1.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3d11.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3d11.lib new file mode 100644 index 0000000..441d85b Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3d11.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3d9.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3d9.lib new file mode 100644 index 0000000..62b3f75 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3d9.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dcompiler(old43).lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dcompiler(old43).lib new file mode 100644 index 0000000..15c8301 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dcompiler(old43).lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dx10.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx10.lib new file mode 100644 index 0000000..cfd7b9f Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx10.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dx10d.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx10d.lib new file mode 100644 index 0000000..c4b45a7 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx10d.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dx11.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx11.lib new file mode 100644 index 0000000..92a666f Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx11.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dx11d.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx11d.lib new file mode 100644 index 0000000..2b116fe Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx11d.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dx9.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx9.lib new file mode 100644 index 0000000..8587d5b Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx9.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dx9d.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx9d.lib new file mode 100644 index 0000000..2f3ebf7 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dx9d.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/d3dxof.lib b/GameGuru Core/SDK/DirectX/Lib/x64/d3dxof.lib new file mode 100644 index 0000000..66dbd30 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/d3dxof.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/dinput8.lib b/GameGuru Core/SDK/DirectX/Lib/x64/dinput8.lib new file mode 100644 index 0000000..fcd91e1 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/dinput8.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/dsound.lib b/GameGuru Core/SDK/DirectX/Lib/x64/dsound.lib new file mode 100644 index 0000000..a85fc86 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/dsound.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/dwrite.lib b/GameGuru Core/SDK/DirectX/Lib/x64/dwrite.lib new file mode 100644 index 0000000..15416c6 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/dwrite.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/dxgi.lib b/GameGuru Core/SDK/DirectX/Lib/x64/dxgi.lib new file mode 100644 index 0000000..83639be Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/dxgi.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/dxguid.lib b/GameGuru Core/SDK/DirectX/Lib/x64/dxguid.lib new file mode 100644 index 0000000..f3994f9 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/dxguid.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/xapobase.lib b/GameGuru Core/SDK/DirectX/Lib/x64/xapobase.lib new file mode 100644 index 0000000..9a1bbcb Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/xapobase.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x64/xapobased.lib b/GameGuru Core/SDK/DirectX/Lib/x64/xapobased.lib new file mode 100644 index 0000000..63fd474 Binary files /dev/null and b/GameGuru Core/SDK/DirectX/Lib/x64/xapobased.lib differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/D3DCSX.lib b/GameGuru Core/SDK/DirectX/Lib/x86/D3DCSX.lib deleted file mode 100644 index fd2c502..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/D3DCSX.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/D3DCSXd.lib b/GameGuru Core/SDK/DirectX/Lib/x86/D3DCSXd.lib deleted file mode 100644 index f637815..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/D3DCSXd.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/DXUT.lib b/GameGuru Core/SDK/DirectX/Lib/x86/DXUT.lib deleted file mode 100644 index bca0171..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/DXUT.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/DXUTOpt.lib b/GameGuru Core/SDK/DirectX/Lib/x86/DXUTOpt.lib deleted file mode 100644 index aead104..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/DXUTOpt.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/X3DAudio.lib b/GameGuru Core/SDK/DirectX/Lib/x86/X3DAudio.lib deleted file mode 100644 index ffef84d..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/X3DAudio.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/XAPOFX.lib b/GameGuru Core/SDK/DirectX/Lib/x86/XAPOFX.lib deleted file mode 100644 index 53a5f0c..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/XAPOFX.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/XInput.lib b/GameGuru Core/SDK/DirectX/Lib/x86/XInput.lib deleted file mode 100644 index 4d3bd7c..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/XInput.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d2d1.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d2d1.lib deleted file mode 100644 index 751c67f..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d2d1.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3d10.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3d10.lib deleted file mode 100644 index df8ed19..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3d10.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3d10_1.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3d10_1.lib deleted file mode 100644 index 80645d6..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3d10_1.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3d11.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3d11.lib deleted file mode 100644 index 9200898..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3d11.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3d9.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3d9.lib deleted file mode 100644 index f6eddc6..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3d9.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dcompiler(old43).lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dcompiler(old43).lib deleted file mode 100644 index 36cc5d4..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dcompiler(old43).lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dcompiler.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dcompiler.lib deleted file mode 100644 index a3fdf66..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dcompiler.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx10(needed).lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dx10(needed).lib deleted file mode 100644 index a397032..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx10(needed).lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx10d(needed).lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dx10d(needed).lib deleted file mode 100644 index 5c28adf..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx10d(needed).lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx11.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dx11.lib deleted file mode 100644 index 904d157..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx11.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx11d.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dx11d.lib deleted file mode 100644 index c1c756a..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx11d.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx9.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dx9.lib deleted file mode 100644 index 11853bf..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx9.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx9d.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dx9d.lib deleted file mode 100644 index 15ed743..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dx9d.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/d3dxof.lib b/GameGuru Core/SDK/DirectX/Lib/x86/d3dxof.lib deleted file mode 100644 index bf3cde4..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/d3dxof.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/dinput8.lib b/GameGuru Core/SDK/DirectX/Lib/x86/dinput8.lib deleted file mode 100644 index c870a09..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/dinput8.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/dsetup.lib b/GameGuru Core/SDK/DirectX/Lib/x86/dsetup.lib deleted file mode 100644 index a3cfdc7..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/dsetup.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/dsound.lib b/GameGuru Core/SDK/DirectX/Lib/x86/dsound.lib deleted file mode 100644 index c07fe85..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/dsound.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/dwrite.lib b/GameGuru Core/SDK/DirectX/Lib/x86/dwrite.lib deleted file mode 100644 index aa13636..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/dwrite.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/dxgi.lib b/GameGuru Core/SDK/DirectX/Lib/x86/dxgi.lib deleted file mode 100644 index 011c928..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/dxgi.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/dxguid.lib b/GameGuru Core/SDK/DirectX/Lib/x86/dxguid.lib deleted file mode 100644 index 82835ab..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/dxguid.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/xapobase.lib b/GameGuru Core/SDK/DirectX/Lib/x86/xapobase.lib deleted file mode 100644 index 531c06b..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/xapobase.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectX/Lib/x86/xapobased.lib b/GameGuru Core/SDK/DirectX/Lib/x86/xapobased.lib deleted file mode 100644 index 900734f..0000000 Binary files a/GameGuru Core/SDK/DirectX/Lib/x86/xapobased.lib and /dev/null differ diff --git a/GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2017.vcxproj b/GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj similarity index 59% rename from GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2017.vcxproj rename to GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj index 805c1e3..2696967 100644 --- a/GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2017.vcxproj +++ b/GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj @@ -1,9 +1,13 @@  - + + Debug + x64 + + Release - Win32 + x64 @@ -11,59 +15,39 @@ {371B9FA9-4C90-4AC6-A123-ACED756D6C77} DirectXTex Win32Proj - 10.0.17763.0 + 10.0 StaticLibrary Unicode - v141 - - - StaticLibrary - Unicode - v141 + v143 StaticLibrary Unicode - v141 - - - StaticLibrary - Unicode - v141 + v143 + false - + + + + - Bin\Desktop_2017\$(Platform)\$(Configuration)\ - Bin\Desktop_2017\$(Platform)\$(Configuration)\ + Bin\Desktop_2022\$(Platform)\$(Configuration)\ + Bin\Desktop_2022\$(Platform)\$(Configuration)\ DirectXTex true true - - Bin\Desktop_2017\$(Platform)\$(Configuration)\ - Bin\Desktop_2017\$(Platform)\$(Configuration)\ - DirectXTex - false - true - - Bin\Desktop_2017\$(Platform)\$(Configuration)\ - Bin\Desktop_2017\$(Platform)\$(Configuration)\ - DirectXTex - false - true - - - Bin\Desktop_2017\$(Platform)\$(Configuration)\ - Bin\Desktop_2017\$(Platform)\$(Configuration)\ + Bin\Desktop_2022\$(Platform)\$(Configuration)\ + Bin\Desktop_2022\$(Platform)\$(Configuration)\ DirectXTex false true @@ -84,6 +68,7 @@ DirectXTexP.h $(IntDir)$(TargetName).pdb 4996 + stdcpp17 %(AdditionalOptions) @@ -109,50 +94,6 @@ - - - EnableAllWarnings - MaxSpeed - MultiThreaded - true - true - true - Fast - StreamingSIMDExtensions2 - Sync - /permissive- %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(IntDir)$(TargetName).pdb - 4996 - - - %(AdditionalOptions) - %(AdditionalDependencies) - true - Windows - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - EnableAllWarnings @@ -169,49 +110,7 @@ DirectXTexP.h $(IntDir)$(TargetName).pdb 4996 - - - %(AdditionalOptions) - %(AdditionalDependencies) - true - Windows - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - EnableAllWarnings - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - Sync - /permissive- %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0600;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(IntDir)$(TargetName).pdb - 4996 + stdcpp17 %(AdditionalOptions) @@ -267,7 +166,8 @@ - Create + Create + Create diff --git a/GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2017.vcxproj.filters b/GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj.filters similarity index 100% rename from GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2017.vcxproj.filters rename to GameGuru Core/SDK/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj.filters diff --git a/GameGuru Core/SDK/DirectXTex/DirectXTex_Desktop_2017.sln b/GameGuru Core/SDK/DirectXTex/DirectXTex_Desktop_2022.sln similarity index 50% rename from GameGuru Core/SDK/DirectXTex/DirectXTex_Desktop_2017.sln rename to GameGuru Core/SDK/DirectXTex/DirectXTex_Desktop_2022.sln index ef1307a..e286dbe 100644 --- a/GameGuru Core/SDK/DirectXTex/DirectXTex_Desktop_2017.sln +++ b/GameGuru Core/SDK/DirectXTex/DirectXTex_Desktop_2022.sln @@ -1,22 +1,25 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.2092 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32901.215 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Desktop_2017.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Desktop_2022.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release|x86 = Release|x86 + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.ActiveCfg = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.Build.0 = Release|Win32 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 + {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {557F8926-EA7E-423F-B698-A81D92290E1F} + SolutionGuid = {EBF98C64-79C2-4FB8-A1B3-185D0613A86B} EndGlobalSection EndGlobal diff --git a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2013.vcxproj b/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2013.vcxproj deleted file mode 100644 index 9ce81e0..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2013.vcxproj +++ /dev/null @@ -1,407 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texassemble - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1} - texassemble - Win32Proj - $(VCTargetsPath11) - - - - Application - Unicode - v120 - - - Application - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texassemble - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texassemble - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - - Level4 - Disabled - MultiThreadedDebugDLL - false - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EditAndContinue - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - Disabled - MultiThreadedDebugDLL - false - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2013.vcxproj.filters b/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2013.vcxproj.filters deleted file mode 100644 index 781df78..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2013.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2015.vcxproj b/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2015.vcxproj deleted file mode 100644 index 1b46a69..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2015.vcxproj +++ /dev/null @@ -1,406 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texassemble - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1} - texassemble - Win32Proj - - - - Application - Unicode - v140 - - - Application - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texassemble - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texassemble - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texassemble - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - - Level4 - Disabled - MultiThreadedDebugDLL - false - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EditAndContinue - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - Disabled - MultiThreadedDebugDLL - false - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - false - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2015.vcxproj.filters b/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2015.vcxproj.filters deleted file mode 100644 index 781df78..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texassemble/Texassemble_Desktop_2015.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2013.vcxproj b/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2013.vcxproj deleted file mode 100644 index 1b1354a..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2013.vcxproj +++ /dev/null @@ -1,407 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texconv - {C3A65381-8FD3-4F69-B29E-654B4B0ED136} - texconv - Win32Proj - $(VCTargetsPath11) - - - - Application - Unicode - v120 - - - Application - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - Application - true - Unicode - v120 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texconv - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texconv - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - Bin\Desktop_2013\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EditAndContinue - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2013.vcxproj.filters b/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2013.vcxproj.filters deleted file mode 100644 index 50ba8f9..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2013.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2015.vcxproj b/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2015.vcxproj deleted file mode 100644 index 0cb305d..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2015.vcxproj +++ /dev/null @@ -1,406 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texconv - {C3A65381-8FD3-4F69-B29E-654B4B0ED136} - texconv - Win32Proj - - - - Application - Unicode - v140 - - - Application - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texconv - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texconv - true - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - Bin\Desktop_2015\$(Platform)\$(Configuration)\ - texconv - false - true - $(ExecutablePath) - $(IncludePath) - $(LibraryPath) - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EditAndContinue - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - EnableFastChecks - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Console - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - StreamingSIMDExtensions2 - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX86 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - Level4 - MaxSpeed - MultiThreadedDLL - true - true - true - Fast - Sync - ..\DirectXTex;%(AdditionalIncludeDirectories) - %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;D3DXFX_LARGEADDRESS_HANDLE;_WIN32_WINNT=0x0600;%(PreprocessorDefinitions) - - - %(AdditionalOptions) - ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - true - MachineX64 - AsInvoker - %(DelayLoadDLLs) - - - false - - - - - - - - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2015.vcxproj.filters b/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2015.vcxproj.filters deleted file mode 100644 index 50ba8f9..0000000 --- a/GameGuru Core/SDK/DirectXTex/Texconv/Texconv_Desktop_2015.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2.dll b/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2.dll deleted file mode 100644 index 3392016..0000000 Binary files a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2.dll and /dev/null differ diff --git a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2.lib b/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2.lib deleted file mode 100644 index c878ffa..0000000 Binary files a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2.lib and /dev/null differ diff --git a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2main.lib b/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2main.lib deleted file mode 100644 index a9ec690..0000000 Binary files a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2main.lib and /dev/null differ diff --git a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2test.lib b/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2test.lib deleted file mode 100644 index 25b3b32..0000000 Binary files a/GameGuru Core/SDK/RecastContrib/SDL/lib/x86/SDL2test.lib and /dev/null differ diff --git a/GameGuru Core/SDK/Steamworks SDK/Readme.txt b/GameGuru Core/SDK/Steamworks SDK/Readme.txt new file mode 100644 index 0000000..5c38a2d --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/Readme.txt @@ -0,0 +1,720 @@ +================================================================ + +Copyright © 1996-2014, Valve Corporation, All rights reserved. + +================================================================ + + +Welcome to the Steamworks SDK. For documentation please see our partner +website at: http://partner.steamgames.com + + +Revision History: + + +---------------------------------------------------------------- +v1.32 5th February 2015 +---------------------------------------------------------------- + +General: +* Added an auto-generated "flat" C-style API for common Steamworks features (steam_api_flat.h) +* Added an auto-generated C# binding for common Steamworks features (steam_api_interop.cs) +* Expanded the ISteamFriends interface to include steam levels and friends groups +* Expanded the ISteamHTTP interface to include cookie handling, SSL certificate verification, and network timeouts +* Fixed typos in ISteamHTMLSurface interface constants + +Inventory: +* Added the initial version of ISteamInventory, a developer-preview release of our new Steam Inventory Service for managing and tracking a Steam-compatible inventory of in-game items. Please see the documentation for the Inventory Service on the partner website for more details. + + + +---------------------------------------------------------------- +v1.31 8th September 2014 +---------------------------------------------------------------- + +UGC: +* The Workshop item content API in ISteamUGC now supports legacy workshop items uploaded via the ISteamRemoteStorage interface. ISteamUGC::GetItemInstallInfo(). This will return whether the item was a legacy item or a new item. If it is a legacy item, then the pchFolder variable will be the full path to the file. + +HTML: +* Added initial version of ISteamHTMLSurface API, which allows games to get textures for html pages and interact with them. There is also a sample implementation in the SteamworksExample. + +Virtual Reality: +* Added VR_IsHmdPresent, which returns true if an HMD appears to be present but does not initialize the VR API. This is useful when enabling/disabling UI elements to offer VR mode to a user. +* Added VR_GetStringForHmdError which turns an HmdError enum value into a string. + +SteamPipe +* The example Steampipe batch file (run_build.bat) now uses run_app_build_http instead of run_app_build by default. + +ContentPrep.app +* Updated wxPython requirements for this app (version 2.7 and 2.8 supported). App will prompt with updated URL to download compatible packages if necessary. + + + +---------------------------------------------------------------- +v1.30 10th July 2014 +---------------------------------------------------------------- + +General: +* Added a new Workshop item content API in ISteamUGC that is easy to use and allows multiple files per item without any size limits. It uses the same + content system that handles regular content depots, resulting in faster and smaller downloads due to delta patching. Subscribed workshop items will + be placed in unique subfolders in the install folder, so the game doesn't need to fetch them using ISteamRemoteStorage anymore. The new API is not + backwards compatible with old items created with ISteamRemoteStorage. Added Workshop feature to steamworksexample using ISteamUGC. + + +Steam VR: +* VR_Init now requires that you call SteamAPI_Init first. + + +---------------------------------------------------------------- +v1.29 24th April 2014 +---------------------------------------------------------------- + +General: +* Adjust game server login to use a token instead of username/password. Tokens are randomly generated at account creation time and can be reset. +* Added existing text param to ISteamUtils::ShowGamepadTextInput() so games can prepopulate control before displaying to user. +* Updated retail disc installer to use a single multi-language steamsetup.exe replacing all Steam install MSI packages. +* Removed redistributable Steam libraries for dedicated servers. Standalone dedicated server should use shared "Steamworks SDK Redist" depots. +* steamcmd is now included for Linux and OSX. + +Music: +* Introducing API to control the Steam Music Player from external software. As an example this gives games the opportunity to pause the music or lower the volume, when an important cut scene is shown, and start playing afterwards. +* Added menu and code to the Steamworks Example to demonstrate this API. +* This feature is currently limited to users in the Steam Music Player Beta. It will have no effect on other users. + +UGC: +* ISteamUGC - Add m_bCachedData to SteamUGCQueryCompleted_t and SteamUGCRequestUGCDetailsResult_t which can be used to determine if the data was retrieved from the cache. +* ISteamUGC - Allow clients to get cached responses for ISteamUGC queries. This is so client code doesn't have to build their own caching layer on top of ISteamUGC. +* ISteamRemoteStorage - add the name of the shared file to RemoteStorageFileShareResult_t so it can be matched up to the request if a game has multiple outstanding FileShare requests going on at the same time + +Steam VR: +* Renamed GetEyeMatrix to GetHeadFromEyePose and made it return an HmdMatrix34t. This doesn't actually change the values it was returning, it just updates the name to match the values that were already being returned. Changed the driver interface too. +* Renamed GetWorldFromHeadPose to GetTrackerFromHeadPose to avoid confusion about the game's world space vs. the tracker's coordinate system. +* Also renamed GetLastWorldFromHeadPose to GetLastTrackerFromHeadPose. +* Added GetTrackerZeroPose method to get the tracker zero pose. +* Added VR support to the Linux/SDL version of the Steamworks Example. + +---------------------------------------------------------------- +v1.28 28th January 2014 +---------------------------------------------------------------- + +* Added Steamworks Virtual Reality API via steamvr.h. +* Added ISteamUtils::IsSteamRunningInVRMode, which returns true if the Steam Client is running in VR mode. +* Deprecated ISteamGameserver::GetGameplayStats and ISteamGameserver::GetServerReputation. These calls already return no data and will be removed in a future SDK update. +* Added result code k_EResultRateLimitExceeded, which can now be returned if a user has too many outstanding friend requests. + +---------------------------------------------------------------- +v1.26a 14th November 2013 +---------------------------------------------------------------- + +* Fix missing accessor function in steam_api.h for SteamUGC() + +---------------------------------------------------------------- +v1.26 6th November 2013 +---------------------------------------------------------------- +* Includes libsteam_api.so for 64-bit Linux. +* Callbacks ValidateAuthTicketResponse_t and GSClientApprove_t now contain the SteamID of the owner of current game. If the game is borrowed, this is different than the player's SteamID. +* Added ISteamFriends::GetPlayerNickname, which returns the nickname the current user has set for the specified player. +* Fix p2p networking apis on Linux so they work with dedicated servers +* Fix command line argument handling bug in SteamAPI_RestartAppIfNecessary on Linux and OSX. +* Added ISteamApps::GetLaunchQueryParam, which will get the value associated with the given key if a game is launched via a url with query paramaters, such as steam://run///?param1=value1;param2=value2;param3=value3. If the game is already running when such a url is executed, instead it will receive a NewLaunchQueryParameters_t callback. +* Added EUGCReadAction parameter to ISteamRemoteStorage:UGCRead that allows the game to keep the file open if it needs to seek around the file for arbitrary data, rather than always closing the file when the last byte is read. +* Added new ISteamUGC interface that is used for querying for lists of UGC details (e.g. Workshop items, screenshots, videos, artwork, guides, etc.). The ISteamUGC interface should be used instead of ISteamRemoteStorage, which contains similar, but less flexible and powerful functionality. +* Removed tools for deprecated content system + + +---------------------------------------------------------------- +v1.25 1st October 2013 +---------------------------------------------------------------- +* Fixed a crash in the 1.24 SDK update when attempting to call ISteamRemoteStorage::GetPublishedFileDetails by adding a missing parameter unMaxSecondsOld, which allows a game to request potentially-cached details (passing a value of 0 retains the previous behavior). + +---------------------------------------------------------------- +v1.24 17th July 2013 +---------------------------------------------------------------- + +User: +* Added ISteamUser::GetBadgeLevel and ISteamUser::GetPlayerSteamLevel functions + +Friends: +* Games can now initiate Steam Friend requests, removals, request -accepts and request-ignores via ISteamFriends’ ActivateGameOverlayToUser API. This prompts the user for confirmation before action is taken. + +Mac: +* Updated the OS X Content Prep tool and game wrapper for improved compatibility with OS X 10.8 (Mountain Lion). + +Linux: +* Added install script for the Steam Linux Runtime tools (run "bash tools/linux/setup.sh" to install), see tools/linux/README.txt for details. +* SteamworksExample is now available on Linux + +---------------------------------------------------------------- +v1.23a 25th February 2013 +---------------------------------------------------------------- + +Windows: +* Fix passing command-line parameters across SteamApi_RestartAppIfNeccessary() + +---------------------------------------------------------------- +v1.23 19th February 2013 +---------------------------------------------------------------- + +Cloud: +* Added ISteamScreenshots::TagPublishedFile() which allows tagging workshop content that is visible or active when a screenshot is taken. +* Added ISteamRemoteStorage::UGCDownloadToLocation() which allows a developer to specify a location on disk to download workshop content. + +Setup tool: +* Added Arabic to the supported languages for the PC Gold Master Setup Tool +* Fixed regression in localized EULA support in Mac OS X Gold Master Setup Tool + +Windows: +* Fix SteamAPI_RestartAppIfNecessary() on 64 bit Windows +* When launching a game's development build from outside of Steam, fixed using steam_appid.txt in the Steam Overlay and for authorizing microtransactions (broken in the SDK 1.22) + +Mac: +* Fixed many Steam callbacks not working for 64 bit OS X games due to mismatched structure alignment between the SDK and the Steam client +* Implemented SteamAPI_RestartAppIfNecessary() + +Linux: +* Removed the need to redistribute libtier0_s.so and libvstdlib_s.so +* Fixed finding and loading steamclient.so, so LD_LIBRARY_PATH does not need to be set for game to talk with Steam +* Implemented SteamAPI_RestartAppIfNecessary() + + +---------------------------------------------------------------- +v1.22 12th December 2012 +---------------------------------------------------------------- + +Apps +* Added new API call ISteamApps::MarkContentCorrupt() so a game can hint Steam that some of it's local content seems corrupt. Steam will verify the content next time the game is started. +* Added new API call ISteamApps::GetCurrentBetaName() so a game can get the current content beta branch name if the user chose to opt-in to a content beta. + +Cloud +* Added an offset parameter to ISteamRemoteStorage::UGCRead() to allow reading files in chunks, and increased the limit from 100MB to 200MB when downloading files this way. + +HTTP +* Added support for streaming HTTP requests with ISteamHTTP::SendHTTPRequestAndStreamResponse() and ISteamHTTP::GetHTTPStreamingResponseBodyData() + +Linux +* Updated libsteam_api.so to find Steam in its new install location + + +---------------------------------------------------------------- +v1.21 25th October 2012 +---------------------------------------------------------------- + +Big Picture +* Added ISteamUtils::ShowGamepadTextInput() to enable usage of the Big Picture gamepad text input control in-game. UI is rendered by the Steam Overlay. +* Added ISteamUtils::GetEnteredGamepadTextLength() and ISteamUtils::GetEnteredGamepadTextInput() to retrieve entered gamepad text. +* Added GamepadTextInputDismissed_t callback to detect when the user has entered gamepad data. + + +---------------------------------------------------------------- +v1.20 30th August 2012 +---------------------------------------------------------------- + +SteamPipe +* Added local server and builder tools for new content system. + +Mac +* OSX Supports 64 bit build targets. +* Spacewar has been updated to be buildable as a 64 bit OSX sample application. + +Friends +* Added a callback for the result of ISteamFriends::SetPersonaName(). +* Changed ISteamFriends::ActivateGameOverlayToStore() to take an additional parameter so app can be directly added to the cart. + +Cloud +* Added ISteamRemoteStorage::FileWriteStreamOpen(), FileWriteStreamWriteChunk(), FileWriteStreamClose() and FileWriteStreamCancel() for streaming operations. +* Changed parameters to ISteamRemoteStorage::PublisheVideo(). +* Added file type to ISteamRemoteStorage::GetPublishedFileDetails() callback result (RemoteStorageGetPublishedFileDetailsResult_t). +* Added a callback to indicate that a published file that a user owns was deleted (RemoteStoragePublishedFileDeleted_t). + +ISteamUserStats +* Added ISteamUserStats::GetNumAchievements() and ISteamUserStats::GetAchievementName(). + + +---------------------------------------------------------------- +v1.19 22nd March 2012 +---------------------------------------------------------------- + +Friends +* Added ISteamFriends::GetFollowerCount() +* Added ISteamFriends::IsFollowing() +* Added ISteamFriends::EnumerateFollowingList() + +Cloud +* Added ISteamRemoteStorage::UpdatePublishedFileSetChangeDescription() +* Added ISteamRemoteStorage::GetPublishedItemVoteDetails() +* Added ISteamRemoteStorage::UpdateUserPublishedItemVote() +* Added ISteamRemoteStorage::GetUserPublishedItemVoteDetails() +* Added ISteamRemoteStorage::EnumerateUserSharedWorkshopFiles() +* Added ISteamRemoteStorage::PublishVideo() +* Added ISteamRemoteStorage::SetUserPublishedFileAction() +* Added ISteamRemoteStorage::EnumeratePublishedFilesByUserAction() +* Added ISteamRemoteStorage::EnumeratePublishedWorkshopFiles() + +ISteamGameServer +* Updated callback for SteamGameServer::ComputeNewPlayerCompatibility to include the steam id the compatibility was calculated for + + +---------------------------------------------------------------- +v1.18 7th February 2012 +---------------------------------------------------------------- + +Cloud +* Removed ISteamRemoteStorage::PublishFile() and consolidated the API to PublishWorkshopFile() +* Updated ISteamRemoteStorage::PublishWorkshopFile() to better define the type of workshop file being published +* Replaced ISteamRemoteStorage::UpdatePublishedFile() with a new mechanism to update existing files through CreatePublishedFileUpdateRequest() UpdatePublishedFile[Property](), and CommitPublishedFileUpdate() +* Increased the description field for a workshop file from 256 -> 8000 characters +* Added ISteamRemoteStorage::GetUGCDownloadProgress() +* Added file size limit of 100MB to ISteamRemoteStorage::FileWrite() + +Apps: +* Added ISteamApps::RequestAppProofOfPurchaseKey + +---------------------------------------------------------------- +v1.17 2nd November 2011 +---------------------------------------------------------------- + +Cloud +* Added ISteamRemoteStorage::PublishFile(), PublishWorkshopFile(), UpdatePublishedFile(), DeletePublishedFile() which enables sharing, updating, and unsharing of cloud content with the Steam community +* Added ISteamRemoteStorage::EnumerateUserPublishedFiles to enumerate content that a user has shared with the Steam community +* Added ISteamRemoteStorage::GetPublishedFileDetails() which gets the metadata associated with a piece of community shared content +* Added ISteamRemoteStorage::SubscribePublishedFile(), EnumerateUserSubscribedFiles(), and UnsubscribePublishedFiles() which allow for management of community content that a user is interested in and marked as a favorite + +User +* Updated ISteamUser::GetAuthSessionTicket(), When creating a ticket for use by the AuthenticateUserTicket Web API, the calling application should wait for the callback GetAuthSessionTicketResponse_t generated by the API call before attempting to use the ticket to ensure that the ticket has been communicated to the server. If this callback does not come in a timely fashion ( 10 - 20 seconds ), your client is not connected to Steam, and the AuthenticeUserTicket will fail because it can not authenticate the user. + +Friends +* Added ISteamFriends::RequestFriendRichPresence, which allows requesting rich presence keys for any Steam user playing the same game as you +* Added a set of functions to ISteamFriends which allow games to integrate with Steam Chat. Games can both join group chats, as well as get friends chats and show them in-line in the game. This API isn’t currently used in a game, so there may be some rough edges around the user experience to work out, and some experimentation is required. + +Game Servers +* Removed the ISteamMasterServerUpdater interface. It has been merged into the ISteamGameServer interface, which is used to communicate all game server state changes. +* Significant changes to the game server init sequence. (See the comments for SteamGameServer_Init and the ISteamGameServer interface.) +* Removed interface to legacy master server mode +* Groundwork for implementing named steam accounts for game servers +* Old player auth system is deprecated. It may be removed in a future version of the SDK. + +Tools +* Added tool for automated DRM submissions in /sdk/tools/drm/ + +---------------------------------------------------------------- +v1.16 29th July 2011 +---------------------------------------------------------------- + +HTTP +* added ISteamHTTP::SetHTTPRequestRawPostBody() to set the raw body of a POST request +Screenshots +* added ISteamScreenshots interface, which enables adding screenshots to the user's screenshot library and tagging them with location data or relevant players that are visible in the screenshot. A game can provide screenshots based on game events using WriteScreenshot, AddScreenshotToLibrary, or TriggerScreenshot. A game can also choose to provide its own screenshots when the Steam screenshot hotkey is pressed by calling HookScreenshots() and listening for the ScreenshotRequested_t callback. + +---------------------------------------------------------------- +v1.15 1st June 2011 +---------------------------------------------------------------- + +Bug fixes +* Fixed exposing HTTP interface +* Fixed setting AppID for game processes started outside of Steam or which require administrative privileges + + +---------------------------------------------------------------- +v1.14 16th May 2011 +---------------------------------------------------------------- + +Stats and Achievements +* Added a set of functions for accessing global achievement unlock percentages +** RequestGlobalAchievementPercentages() to request the completion percentages from the backend +** GetMostAchievedAchievementInfo() and GetNextMostAchievedAchievementInfo() to iterate achievement completion percentages +** GetAchievementAchievedPercent() to query the global unlock percentage for a specific achievement +* Added a set of functions for accessing global stats values. To enable a global stats set stats as "aggregated" from the Steamworks admin page. +** RequestGlobalStats() to request the global stats data from the backend +** GetGlobalStat() to get the global total for a stat +** GetGlobalStatHistory() to get per day totals for a stat + +HTTP +* added ISteamHTTP::GetHTTPDownloadProgressPct() get the progress of an HTTP request + + +---------------------------------------------------------------- +v1.13 26th April 2011 +---------------------------------------------------------------- + +Rich Presence +* added a new Rich Presence system to allow for sharing game specific per user data between users +* ISteamFriends::SetRichPresense() can be used to set key/value presence data for the current user +* ISteamFriends::GetFriendRichPresence() and related functions can be used to retrieve presence data for a particular user +* Two special presence keys exist: +** the "connect" key can be set to specify a custom command line used by friends when joining that user +** the "status" key can be set to specify custom text that will show up in the 'view game info' dialog in the Steam friends list + +HTTP +* added ISteamHTTP, which exposes methods for making HTTP requests + +Downloadable Content +* added ISteamApps::GetDLCCount() and ISteamApps::BGetDLCDataByIndex() to allow for enumerating DLC content for the current title +* added ISteamApps::InstallDLC() and ISteamApps::UninstallDLC() to control installing optional content + +P2P Networking +* added ISteamNetworking::CloseP2PChannelWithUser(), to allow for closing a single channel to a user. When all channels are closed, the connection to that user is automatically closed. +* added ISteamNetworking::AllowP2PPacketRelay(), which can be used to prevent allowing P2P connections from falling back to relay + +Voice +* ISteamUser::GetAvailableVoice() & ISteamUser::GetVoice() now take the desired sample rate to determine the number of uncompressed bytes to return +* added ISteamUser::GetVoiceOptimalSampleRate() to return the frequency of the voice data as it's stored internally + +Friends +* added ISteamFriends methods to retrieve the list of users the player has recently played with + +Content Tool +* all files are now encrypted by default +* add command line option to app creation wizard +* add command line edit option by right clicking on app +* update cache size in CDDB after each build +* look for install scripts at build time and automatically add CDDB flag +* fix language names for chinese +* add menu button to easily rev version +* warn if rebuilding existing version +* allow specifying subfolder when ftp-ing depots to valve +* better error messaging if ftp fails +* clean up various small display bugs +* don't trash ValidOSList tag when updating CDDB + +OSX DirectX to OpenGL +* added the graphics layer used to port Valve games to OSX which can now be used by all Steamworks developers +* included in the Steamworks Example application. Can be enabled by building with DX9MODE=1 + + +---------------------------------------------------------------- +v1.12 10th November 2010 +---------------------------------------------------------------- + +Cloud +* added a set of function to handle publishing User Generated Content (UGC) files to the backend, and to download others users UGC files. This enables games to have users easily publish & share content with each other. +* Added ISteamRemoteStorage::FileForget() which tells a file to remain on disk but to be removed from the backend. This can be used to manage which files should be synchronized if you have more files to store than your quota allows. +* Added ISteamRemoteStorage::FilePersisted() to tell if the file is set to be synchronized with the backend. +* Added ISteamRemoteStorage::FileDelete() which tells a file to be deleted locally, from cloud, and from other clients that have the file. This can be used to properly delete a save file rather than writing a 1-byte file as a sentinel. +* Added ISteamRemoteStorage::SetSyncPlatforms(), GetSyncPlatforms() to tell steam which platforms a file should be synchronized to. This allows OSX not to download PC-specific files, or vice-versa. +* Added ISteamRemoteStorage::IsCloudEnabledForAccount(), IsCloudEnabledForApp(), and SetCloudEnabledForApp(). When cloud is disabled the APIs still work as normal and an alternate location on disk is not needed. It just means the files will not be synchronized with the backend. + +Leaderboards +* added ISteamUserStats::DownloadLeaderboardEntriesForUsers(), which downloads scores for an arbitrary set of users +* added ISteamUserStats::AttachLeaderboardUGC(), to attach a clouded file to a leaderboard entry + +Friends +* added ISteamFriends::RequestUserInformation(), to asynchronously request a users persona name & avatar by steamID +* added ISteamFriends::RequestClanOfficerList(), to asynchronously download the set of officers for a clan. GetClanOwner(), GetClanOfficerCount(), and GetClanOfficerByIndex() can then be used to access the data. + +Matchmaking +* added k_ELobbyTypePrivate option to creating lobbies - this means that the lobby won't show up to friends or be returned in searches +* added LobbyDataUpdate_t::m_bSuccess, to easily check if a RequestLobbyData() call failed to find the specified lobby + +Authentication +* added ISteamApps::GetEarliestPurchaseUnixTime(), for games that want to reward users who have played for a long time +* added ISteamApps::BIsSubscribedFromFreeWeekend(), so games can show different offers or information for users who currently only have rights to play the game due to a free weekend promotion +* added ISteamGameServer::GetAuthSessionTicket(), BeginAuthSession(), EndAuthSession(), and CancelAuthTicket(), matching what exists in ISteamUser. This allows game servers and clients to authenticate each other in a unified manner. + +OSX +* The Steamworks Spacewar example now builds/runs on OS X +* The OSX retail install setup application is now contained in goldmaster\disk_assets\SteamRetailInstaller.dmg + +PS3 +* added several functions regarding PS3 support. This is still a work in progress, and no PS3 binaries are included. + + +---------------------------------------------------------------- +v1.11 23rd August 2010 +---------------------------------------------------------------- + +Networking +* added virtual ports to the P2P networking API to help with routing messages to different systems +* added ISteamUser::BIsBehindNAT() to detect when a user is behind a NAT + +Friends / Matchmaking +* added support for retrieving large (184x184) avatars +* added ISteamUser::AdvertiseGame() which can be used send join game info to friends without using the game server APIs + +64-bit support +* 64-bit windows binaries are included in the sdk/redistributable_bin/ folder +* VAC and CEG are not yet supported + +Authentication +* added ticket based remote authentication library + +Other +* added ISteamUser::CheckFileSignature which can be used in conjunction with the signing tab on the partner site to verify that an executable has not been modified + + +---------------------------------------------------------------- +v1.10 20th July 2010 +---------------------------------------------------------------- + +Friends / Matchmaking +* added function ISteamFriends::GetClanTag(), which returns the abbreviation set for a group +* added "stats" and "achievements" options to ISteamFriends::ActivateGameOverlayToUser() +* added function ISteamFriends::ActivateGameOverlayInviteDialog() to open the invite dialog for a specific lobby +* renamed ISteamMatchmaking::SetGameType() to the more correct SetGameTags() + +Authentication +* added ISteamUtils::CheckFileSignature(), which can be used to verify that a binary has a valid signature + +Other +* added #pragma pack() in several places around structures in headers + + +---------------------------------------------------------------- +v1.09 12th May 2010 +---------------------------------------------------------------- + +Mac Steamworks! +* new binaries in the sdk/redistributable_bin/osx/ folder + +Other +* explicit pragma( pack, 8 ) added around all callbacks and structures, for devs who have use a different default packing +* renamed function ISteamGameServer::SetGameType() to the more accurate ISteamGameServer::SetGameTags() + + +---------------------------------------------------------------- +v1.08 27st January 2010 +---------------------------------------------------------------- + +Matchmaking +* added function ISteamMatching::AddRequestLobbyListDistanceFilter(), to specify how far geographically you want to search for other lobbies +* added function ISteamMatching::AddRequestLobbyListResultCountFilter(), to specify how the maximum number of lobby you results you need (less is faster) + +Stats & Achievements +* added interface ISteamGameServerStats, which enables access to stats and achievements for users to the game server +* removed function ISteamGameServer::BGetUserAchievementStatus(), now handled by ISteamGameServerStats +* added ISteamUserStats::GetAchievementAndUnlockTime(), which returns if and when a user unlocked an achievement + +Other +* added new constant k_cwchPersonaNameMax (32), which is the maximum number of unicode characters a users name can be +* removed ISteamRemoteStorage::FileDelete() - NOTE: it will be back, it's only removed since it hadn't been implemented on the back-end yet +* added function ISteamGameServer::GetServerReputation(), gives returns a game server reputation score based on how long users typically play on the server + + +---------------------------------------------------------------- +v1.07 16th December 2009 +---------------------------------------------------------------- + +* Replaced SteamAPI_RestartApp() with SteamAPI_RestartAppIfNecessary(). This new function detects if the process was started through Steam, and starts the current game through Steam if necessary. +* Added ISteamUtils::BOverlayNeedsPresent() so games with event driven rendering can determine when the Steam overlay needs to draw + + +---------------------------------------------------------------- +v1.06 30th September 2009 +---------------------------------------------------------------- + +Voice +* ISteamUser::GetCompressedVoice() has been replaced with ISteamUser::GetVoice which can be used to retrieve compressed and uncompressed voice data +* Added ISteamUser::GetAvailableVoice() to retrieve the amount of captured audio data that is available + +Matchmaking +* Added a new callback LobbyKicked_t that is sent when a user has been disconnected from a lobby +* Through ISteamMatchmakingServers, multiple server list requests of the same type can now be outstanding at the same time + +Steamworks Setup Application: +* Streamlined configuration process +* Now supports EULAs greater than 32k bytes + +Content Tool +* Added DLC checkbox to depot creation wizard + +Other +* Added SteamAPI_IsSteamRunning() +* Added SteamAPI_RestartApp() so CEG users can restart their game through Steam if launched through Windows Games Explorer + + + +---------------------------------------------------------------- +v1.05 11th June 2009 +---------------------------------------------------------------- + +Matchmaking +* Added the SteamID of the gameserver to the gameserveritem_t structure (returned only by newer game servers) +* Added ISteamUserStats::GetNumberOfCurrentPlayers(), asyncronously returns the number users currently running this game +* Added k_ELobbyComparisonNotEqual comparision functions for filters +* Added option to use comparison functions for string filters +* Added ISteamMatchmaking::AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable ) filter function, so you can find a lobby for a group of users to join +* Extended ISteamMatchmaking::CreateLobby() to take the max number of users in the lobby +* Added ISteamMatchmaking::GetLobbyDataCount(), ISteamMatchmaking::GetLobbyDataByIndex() so you can iterate all the data set on a lobby +* Added ISteamMatchmaking::DeleteLobbyData() so you can clear a key from a lobby +* Added ISteamMatchmaking::SetLobbyOwner() so that ownership of a lobby can be transferred +* Added ISteamMatchmaking::SetLobbyJoinable() +* Added ISteamGameServer::SetGameData(), so game server can set more information that can be filtered for in the server pinging API + +Networking +* Added a set of connectionless networking functions for easy use for making peer-to-peer (NAT traversal) connections. Includes supports for windowed reliable sendsand fragementation/re-assembly of large packets. See ISteamNetworking.h for more details. + +Leaderboards +* Added enum ELeaderboardUploadScoreMethod and changed ISteamUserStats::UploadLeaderboardScore() to take this - lets you force a score to be changed even if it's worse than the prior score + +Callbacks +* Added CCallbackManual<> class to steam_api.h, a version of CCallback<> that doesn't register itself automatically in it's the constructor + +Downloadable Content +* Added ISteamUser::UserHasLicenseForApp() and ISteamGameServer::UserHasLicenseForApp() to enable checking if a user owns DLC in multiplayer. See the DLC documentation for more info. + +Game Overlay +* ISteamFriends::ActivateGameOverlay() now accepts "Stats" and "Achievements" + + + +---------------------------------------------------------------- +v1.04 9th Mar 2009 +---------------------------------------------------------------- + +Added Peer To Peer Multi-Player Authentication/Authorization: +* Allows each peer to verify the unique identity of the peers ( by steam account id ) in their game and determine if that user is allowed access to the game. +* Added to the ISteamUser interface: GetAuthSessionTicket(), BeginAuthSession(), EndAuthSession() and CancelAuthTicket() +* Additional information can be found in the API Overview on the Steamworks site + +Added support for purchasing downloadable content in game: +* Added ISteamApps::BIsDlcInstalled() and the DlcInstalled_t callback, which enable a game to check if downloadable content is owned and installed +* Added ISteamFriends::ActivateGameOverlayToStore(), which opens the Steam game overlay to the store page for an appID (can be a game or DLC) + +Gold Master Creation: +* It is no longer optional to encrypt depots on a GM +* The GM configuration file now supports an included_depots key, which along with the excluded_depots key, allows you to specify exactly which depots are placed on a GM +* Simplified the configuration process for the setup application +* The documentation for creating a Gold Master has been rewritten and extended. See the Steamworks site for more information. + +Added Leaderboards: +* 10k+ leaderboards can now be created programmatically per game, and queried globally or compared to friends +* Added to ISteamUserStats interface +* See SteamworksExample for a usage example + +Other: +* Added SteamShutdown_t callback, which will alert the game when Steam wants to shut down +* Added ISteamUtils::IsOverlayEnabled(), which can be used to detect if the user has disabled the overlay in the Steam settings +* Added ISteamUserStats::ResetAllStats(), which can be used to reset all stats (and optionally achievements) for a user +* Moved SetWarningMessageHook() from ISteamClient to ISteamUtils +* Added SteamAPI_SetTryCatchCallbacks, sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks +* In CCallResult callback, CCallResult::IsActive() will return false and can now reset the CCallResult +* Added support for zero-size depots +* Properly strip illegal characters from depot names + + + +---------------------------------------------------------------- +v1.03 16th Jan 2009 +---------------------------------------------------------------- + +Major changes: +* ISteamRemoteStorage interface has been added, which contains functions to store per-user data in the Steam Cloud back-end. +** To use this, you must first use the partner web site to enable Cloud for your game. +** The current setting is allowing 1MB of storage per-game per-user (we hope to increase this over time). + +Lobby & Matchmaking related changes: +* ISteamFriends::GetFriendGamePlayed() now also return the steamID of the lobby the friend is in, if any. It now takes a pointer to a new FriendGameInfo_t struct, which it fills +* Removed ISteamFriends::GetFriendsLobbies(), since this is now redundant to ISteamFriends::GetFriendGamePlayed() +* Added enum ELobbyComparison, to set the comparison operator in ISteamMatchmaking::AddRequestLobbyListNumericalFilter() +* Changed ISteamMatchmaking::CreateLobby(), JoinLobby() and RequestLobbyList() to now return SteamAPICall_t handles, so you can easily track if a particular call has completed (see below) +* Added ISteamMatchmaking::SetLobbyType(), which can switch a lobby between searchable (public) and friends-only +* Added ISteamMatchmaking::GetLobbyOwner(), which returns the steamID of the user who is currently the owner of the lobby. The back-end ensures that one and only one user is ever the owner. If that user leaves the lobby, another user will become the owner. + +Steam game-overlay interaction: +* Added a new callback GameLobbyJoinRequested_t, which is sent to the game if the user selects 'Join friends game' from the Steam friends list, and that friend is in a lobby. The game should initiate connection to that lobby. +* Changed ISteamFriends::ActivateGameOverlay() can now go to "Friends", "Community", "Players", "Settings", "LobbyInvite", "OfficialGameGroup" +* Added ISteamFriends::ActivateGameOverlayToUser(), which can open a either a chat dialog or another users Steam community profile +* Added ISteamFriends::ActivateGameOverlayToWebPage(), which opens the Steam game-overlay web browser to the specified url + +Stats system changes: +* Added ISteamUserStats::RequestUserStats(), to download the current game stats of another user +* Added ISteamUserStats::GetUserStat() and ISteamUserStats::GetUserAchievement() to access the other users stats, once they've been downloaded + +Callback system changes: +* Added new method for handling asynchronous call results, currently used by CreateLobby(), JoinLobby(), RequestLobbyList(), and RequestUserStats(). Each of these functions returns a handle, SteamAPICall_t, that can be used to track the completion state of a call. +* Added new object CCallResult<>, which can map the completion of a SteamAPICall_t to a function, and include the right data. See SteamworksExample for a usage example. +* Added ISteamUtils::IsAPICallCompleted(), GetAPICallFailureReason(), and GetAPICallResult(), which can be used to track the state of a SteamAPICall_t (although it is recommended to use CCallResult<>, which wraps these up nicely) + +Other: +* Added ISteamGameServer::GetPublicIP(), which is the IP address of a game server as seen by the Steam back-end +* Added "allow relay" parameter to ISteamNetworking::CreateP2PConnectionSocket() and CreateListenSocket(), which specified if being bounced through Steam relay servers is OK if a direct p2p connection fails (will have a much higher latency, but increases chance of making a connection) +* Added IPCFailure_t callback, which will be posted to the game if Steam itself has crashed, or if Steam_RunCallbacks() hasn't been called in a long time + + + +---------------------------------------------------------------- +v1.02 4th Sep 2008 +---------------------------------------------------------------- + +The following interfaces have been updated: + +ISteamUser + + // Starts voice recording. Once started, use GetCompressedVoice() to get the data + virtual void StartVoiceRecording( ) = 0; + + // Stops voice recording. Because people often release push-to-talk keys early, the system will keep recording for + // a little bit after this function is called. GetCompressedVoice() should continue to be called until it returns + // k_eVoiceResultNotRecording + virtual void StopVoiceRecording( ) = 0; + + // Gets the latest voice data. It should be called as often as possible once recording has started. + // nBytesWritten is set to the number of bytes written to pDestBuffer. + virtual EVoiceResult GetCompressedVoice( void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten ) = 0; + + // Decompresses a chunk of data produced by GetCompressedVoice(). nBytesWritten is set to the + // number of bytes written to pDestBuffer. The output format of the data is 16-bit signed at + // 11025 samples per second. + virtual EVoiceResult DecompressVoice( void *pCompressed, uint32 cbCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten ) = 0; + +virtual int InitiateGameConnection( void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure ) = 0; + +This has been extended to be usable for games that don't use the other parts of Steamworks matchmaking. This allows any multiplayer game to easily notify the Steam client of the IP:Port of the game server the user is connected to, so that their friends can join them via the Steam friends list. Empty values are taken for auth blob. + + virtual bool GetUserDataFolder( char *pchBuffer, int cubBuffer ) = 0; + +This function returns a hint as a good place to store per- user per-game data. + + + +ISteamMatchmaking + +Added a set of server-side lobby filters, as well as voice chat, lobby member limits, and a way of quickly accessing the list of lobbies a users friends are in. + + // filters for lobbies + // this needs to be called before RequestLobbyList() to take effect + // these are cleared on each call to RequestLobbyList() + virtual void AddRequestLobbyListFilter( const char *pchKeyToMatch, const char *pchValueToMatch ) = 0; + // numerical comparison - 0 is equal, -1 is the lobby value is less than nValueToMatch, 1 is the lobby value is greater than nValueToMatch + virtual void AddRequestLobbyListNumericalFilter( const char *pchKeyToMatch, int nValueToMatch, int nComparisonType /* 0 is equal, -1 is less than, 1 is greater than */ ) = 0; + // sets RequestLobbyList() to only returns lobbies which aren't yet full - needs SetLobbyMemberLimit() called on the lobby to set an initial limit + virtual void AddRequestLobbyListSlotsAvailableFilter() = 0; + + // returns the details of a game server set in a lobby - returns false if there is no game server set, or that lobby doesn't exist + virtual bool GetLobbyGameServer( CSteamID steamIDLobby, uint32 *punGameServerIP, uint16 *punGameServerPort, CSteamID *psteamIDGameServer ) = 0; + + // set the limit on the # of users who can join the lobby + virtual bool SetLobbyMemberLimit( CSteamID steamIDLobby, int cMaxMembers ) = 0; + // returns the current limit on the # of users who can join the lobby; returns 0 if no limit is defined + virtual int GetLobbyMemberLimit( CSteamID steamIDLobby ) = 0; + + // asks the Steam servers for a list of lobbies that friends are in + // returns results by posting one RequestFriendsLobbiesResponse_t callback per friend/lobby pair + // if no friends are in lobbies, RequestFriendsLobbiesResponse_t will be posted but with 0 results + // filters don't apply to lobbies (currently) + virtual bool RequestFriendsLobbies() = 0; + + +ISteamUtils + // Sets the position where the overlay instance for the currently calling game should show notifications. + // This position is per-game and if this function is called from outside of a game context it will do nothing. + virtual void SetOverlayNotificationPosition( ENotificationPosition eNotificationPosition ) = 0; + + +ISteamFriends + virtual int GetFriendAvatar( CSteamID steamIDFriend, int eAvatarSize ) = 0; + +This function now takes an eAvatarSize parameter, which can be k_EAvatarSize32x32 or k_EAvatarSize64x64 (previously it always just returned a handle to the 32x32 image) + + +---------------------------------------------------------------- +v1.01 8th Aug 2008 +---------------------------------------------------------------- + +The Steamworks SDK has been updated to simplfy game server authentication and better expose application state + + +---------------------------------------------------------------- +v1.0: +---------------------------------------------------------------- + +- Initial Steamworks SDK release diff --git a/GameGuru Core/SDK/Steamworks SDK/client/steam.cfg b/GameGuru Core/SDK/Steamworks SDK/client/steam.cfg new file mode 100644 index 0000000..8071a4b --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/client/steam.cfg @@ -0,0 +1,32 @@ +# +# *********** (C) Copyright 2008 Valve, L.L.C. All rights reserved. *********** +# +# Steam Client SDK configuration-override file +# +# This file is read by the Steam engine. This file should be located +# in the same folder as steam.exe +# + +# +# Use this value to specify the dot-notation IP address or hostname +# of the Steam Content Server for development/test. +# Use "127.0.0.1" to specify the primary NIC of current host. +# +# If you need to run multiple content servers, you can specify +# multiple addresses on this line seperated by a space character +# (e.g. "11.22.33.44 11.22.33.45") +# +SdkContentServerAdrs = "127.0.0.1" + +# +# Enable the manifest fingerprint check at cache startup. +# In general, this should always be enabled if your client is connecting +# to an SDK content server. +# +ManifestFingerprintCheck = enable + + +# +# Tell Steam to only connect to your local CS when downloading +# +CacheServerSessions = 1 diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmbuffer.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmbuffer.cpp new file mode 100644 index 0000000..249c053 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmbuffer.cpp @@ -0,0 +1,362 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmbuffer.cpp +// +//=============================================================================== + +#include "glmgr.h" +#include "glmdisplay.h" +#include "cglmbuffer.h" + +// void BindBufferARB(enum target, uint buffer); +// void DeleteBuffersARB(sizei n, const uint *buffers); +// void GenBuffersARB(sizei n, uint *buffers); +// boolean IsBufferARB(uint buffer); +// +// void BufferDataARB(enum target, sizeiptrARB size, const void *data, +// enum usage); +// void BufferSubDataARB(enum target, intptrARB offset, sizeiptrARB size, +// const void *data); +// void GetBufferSubDataARB(enum target, intptrARB offset, +// sizeiptrARB size, void *data); +// +// void *MapBufferARB(enum target, enum access); +// boolean UnmapBufferARB(enum target); +// +// void GetBufferParameterivARB(enum target, enum pname, int *params); +// void GetBufferPointervARB(enum target, enum pname, void **params); +// +//New Tokens +// +// Accepted by the parameters of BindBufferARB, BufferDataARB, +// BufferSubDataARB, MapBufferARB, UnmapBufferARB, +// GetBufferSubDataARB, GetBufferParameterivARB, and +// GetBufferPointervARB: +// +// ARRAY_BUFFER_ARB 0x8892 +// ELEMENT_ARRAY_BUFFER_ARB 0x8893 +// +// Accepted by the parameter of GetBooleanv, GetIntegerv, +// GetFloatv, and GetDoublev: +// +// ARRAY_BUFFER_BINDING_ARB 0x8894 +// ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +// VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +// NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +// COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +// INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +// TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +// EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +// SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +// FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +// WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +// +// Accepted by the parameter of GetVertexAttribivARB: +// +// VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +// +// Accepted by the parameter of BufferDataARB: +// +// STREAM_DRAW_ARB 0x88E0 +// STREAM_READ_ARB 0x88E1 +// STREAM_COPY_ARB 0x88E2 +// STATIC_DRAW_ARB 0x88E4 +// STATIC_READ_ARB 0x88E5 +// STATIC_COPY_ARB 0x88E6 +// DYNAMIC_DRAW_ARB 0x88E8 +// DYNAMIC_READ_ARB 0x88E9 +// DYNAMIC_COPY_ARB 0x88EA +// +// Accepted by the parameter of MapBufferARB: +// +// READ_ONLY_ARB 0x88B8 +// WRITE_ONLY_ARB 0x88B9 +// READ_WRITE_ARB 0x88BA +// +// Accepted by the parameter of GetBufferParameterivARB: +// +// BUFFER_SIZE_ARB 0x8764 +// BUFFER_USAGE_ARB 0x8765 +// BUFFER_ACCESS_ARB 0x88BB +// BUFFER_MAPPED_ARB 0x88BC +// +// Accepted by the parameter of GetBufferPointervARB: +// +// BUFFER_MAP_POINTER_ARB 0x88BD + +// http://www.opengl.org/registry/specs/ARB/pixel_buffer_object.txt +// Accepted by the parameters of BindBuffer, BufferData, +// BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, +// GetBufferParameteriv, and GetBufferPointerv: +// PIXEL_PACK_BUFFER_ARB 0x88EB +// PIXEL_UNPACK_BUFFER_ARB 0x88EC + + + // gl_bufmode: zero means we mark all vertex/index buffers static + + // non zero means buffers are initially marked static.. + // ->but can shift to dynamic upon first 'discard' (orphaning) + +//ConVar gl_bufmode( "gl_bufmode", "1" ); +int gl_bufmode = 1; + +CGLMBuffer::CGLMBuffer( GLMContext *ctx, EGLMBufferType type, uint size, uint options ) +{ + m_ctx = ctx; + m_type = type; + switch(m_type) + { + case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER_ARB; break; + case kGLMIndexBuffer: m_buffGLTarget = GL_ELEMENT_ARRAY_BUFFER_ARB; break; + case kGLMUniformBuffer: m_buffGLTarget = GL_UNIFORM_BUFFER_EXT; break; + case kGLMPixelBuffer: m_buffGLTarget = GL_PIXEL_UNPACK_BUFFER_ARB; break; + + default: //Assert(!"Unknown buffer type" ); + break; + } + m_size = size; + m_bound = false; + m_mapped = false; + m_lastMappedAddress = NULL; + + m_enableAsyncMap = false; + m_enableExplicitFlush = false; + m_dirtyMinOffset = m_dirtyMaxOffset = 0; // adjust/grow on lock, clear on unlock + + m_ctx->CheckCurrent(); + m_revision = rand(); + + // make a decision about pseudo mode + // this looked like it didn't help much or was actually slower, so leave it available but only as opt-in. + // a more clever implementation would be able to select pseudo buf storage for small batches only.. + m_pseudo = false; // (m_type==kGLMIndexBuffer) && (CommandLine()->FindParm("-gl_enable_pseudobufs")); + if (m_pseudo) + { + m_name = 0; + m_pseudoBuf = (char*)malloc( size ); + + m_ctx->BindBufferToCtx( m_type, NULL ); // exit with no buffer bound + } + else + { + glGenBuffersARB( 1, &m_name ); + GLMCheckError(); + + m_ctx->BindBufferToCtx( m_type, this ); // causes glBindBufferARB + + // buffers start out static, but if they get orphaned and gl_bufmode is non zero, + // then they will get flipped to dynamic. + + GLenum hint = GL_STATIC_DRAW_ARB; + switch(m_type) + { + case kGLMVertexBuffer: hint = (options & GLMBufferOptionDynamic) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break; + case kGLMIndexBuffer: hint = (options & GLMBufferOptionDynamic) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break; + case kGLMUniformBuffer: hint = GL_DYNAMIC_DRAW_ARB; break; // "fwiw" - shrug + case kGLMPixelBuffer: hint = (options & GLMBufferOptionDynamic) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break; + + default: //Assert(!"Unknown buffer type" ); + break; + } + + glBufferDataARB( m_buffGLTarget, m_size, NULL, hint ); // may ultimately need more hints to set the usage correctly (esp for streaming) + + this->SetModes( false, true, true ); + + m_ctx->BindBufferToCtx( m_type, NULL ); // unbind me + } +} + +CGLMBuffer::~CGLMBuffer( ) +{ + m_ctx->CheckCurrent(); + + if (m_pseudo) + { + free (m_pseudoBuf); + m_pseudoBuf = NULL; + } + else + { + glDeleteBuffersARB( 1, &m_name ); + GLMCheckError(); + } + + m_ctx = NULL; + m_name = 0; + m_bound = 0; + + m_lastMappedAddress = NULL; +} + +void CGLMBuffer::SetModes ( bool asyncMap, bool explicitFlush, bool force ) +{ + // assumes buffer is bound. called by constructor and by Lock. + + if (m_pseudo) + { + // ignore it... + } + else + { + if (force || (m_enableAsyncMap != asyncMap) ) + { + // note the sense of the parameter, it's TRUE if you *want* serialization, so for async you turn it to false. + glBufferParameteriAPPLE( this->m_buffGLTarget, GL_BUFFER_SERIALIZED_MODIFY_APPLE, asyncMap==false ); + m_enableAsyncMap = asyncMap; + } + + if (force || (m_enableExplicitFlush != explicitFlush) ) + { + // note the sense of the parameter, it's TRUE if you *want* auto-flush-on-unmap, so for explicit-flush, you turn it to false. + glBufferParameteriAPPLE( this->m_buffGLTarget, GL_BUFFER_FLUSHING_UNMAP_APPLE, explicitFlush==false ); + m_enableExplicitFlush = explicitFlush; + } + } +} + +void CGLMBuffer::FlushRange ( uint offset, uint size ) +{ + if (m_pseudo) + { + // nothing to do + } + else + { + // assumes buffer is bound. + glFlushMappedBufferRangeAPPLE(this->m_buffGLTarget, (GLintptr)offset, (GLsizeiptr)size); + } +} + +//ConVar gl_buffer_alignment_quantum ( "gl_buffer_alignment_quantum", "32" ); // the alignment we use pre-SLGU +//ConVar gl_buffer_alignment_quantum_slgu( "gl_buffer_alignment_quantum_slgu", "2" ); // alignment used post-SLGU + +int gl_buffer_alignment_quantum = 32; +int gl_buffer_alignment_quantum_slgu = 2; + +void CGLMBuffer::Lock( GLMBuffLockParams *params, char **addressOut ) +{ + char *resultPtr = NULL; + + //Assert( !m_mapped); + + m_ctx->CheckCurrent(); + GLMCheckError(); + + if (params->m_offset >= m_size) + Debugger(); + + if (params->m_offset + params->m_size > m_size) + Debugger(); + + // bind (yes, even for pseudo - this binds name 0) + m_ctx->BindBufferToCtx( this->m_type, this ); + + if (m_pseudo) + { + // discard is a no-op + + // async map modes are a no-op + + // latch last mapped address (silly..) + m_lastMappedAddress = (float*)m_pseudoBuf; + + // calc lock address + resultPtr = m_pseudoBuf + params->m_offset; + + // dirty range is a no-op + } + else + { + // perform discard if requested + if (params->m_discard) + { + // observe gl_bufmode on any orphan event. + // if orphaned and bufmode is nonzero, flip it to dynamic. + GLenum hint = gl_bufmode /*.GetInt()*/ ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; + glBufferDataARB( m_buffGLTarget, m_size, NULL, hint ); + + m_lastMappedAddress = NULL; + + m_revision++; // revision grows on orphan event + } + + // adjust async map option appropriately, leave explicit flush unchanged + this->SetModes( params->m_nonblocking, m_enableExplicitFlush ); + + // map + char *mapPtr = (char*)glMapBufferARB( this->m_buffGLTarget, GL_READ_WRITE_ARB ); + + if (!mapPtr) + { + Debugger(); + } + + if (m_lastMappedAddress) + { + // just check if it moved + //Assert (m_lastMappedAddress == (float*)mapPtr); + } + + m_lastMappedAddress = (float*)mapPtr; + + // calculate offset location + resultPtr = mapPtr + params->m_offset; + + // adjust dirty range + if (m_dirtyMinOffset != m_dirtyMaxOffset) + { + // grow range + m_dirtyMinOffset = std::min( m_dirtyMinOffset, params->m_offset ); + m_dirtyMaxOffset = std::min( m_dirtyMaxOffset, params->m_offset+params->m_size ); + } + else + { + // set range + m_dirtyMinOffset = params->m_offset; + m_dirtyMaxOffset = params->m_offset+params->m_size; + } + + // pad and clamp dirty range to choice of boundary + uint quantum = (m_ctx->Caps().m_hasPerfPackage1) ? gl_buffer_alignment_quantum_slgu /*.GetInt()*/ : gl_buffer_alignment_quantum /*.GetInt()*/ ; + uint quantum_mask = quantum - 1; + + m_dirtyMinOffset = m_dirtyMinOffset & (~quantum_mask); + m_dirtyMaxOffset = (m_dirtyMaxOffset + quantum_mask) & (~quantum_mask); + m_dirtyMaxOffset = std::min( m_dirtyMaxOffset, m_size ); + } + + m_mapped = true; + + *addressOut = resultPtr; +} + +void CGLMBuffer::Unlock( void ) +{ + m_ctx->CheckCurrent(); + + //Assert (m_mapped); + + if (m_pseudo) + { + // nothing to do actually + } + else + { + m_ctx->BindBufferToCtx( this->m_type, this ); + + // time to do explicit flush + if (m_enableExplicitFlush) + { + this->FlushRange( m_dirtyMinOffset, m_dirtyMaxOffset - m_dirtyMinOffset ); + } + + // clear dirty range no matter what + m_dirtyMinOffset = m_dirtyMaxOffset = 0; // adjust/grow on lock, clear on unlock + + glUnmapBuffer( this->m_buffGLTarget ); + + } + + m_mapped = false; +} diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmbuffer.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmbuffer.h new file mode 100644 index 0000000..74edb7c --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmbuffer.h @@ -0,0 +1,91 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmprogram.h +// GLMgr buffers (index / vertex) +// ... maybe add PBO later as well +//=============================================================================== + +#ifndef CGLMBUFFER_H +#define CGLMBUFFER_H + +#pragma once + +// ext links + +// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt + +//=============================================================================== + +// forward declarations + +class GLMContext; + +enum EGLMBufferType +{ + kGLMVertexBuffer, + kGLMIndexBuffer, + kGLMUniformBuffer, // for bindable uniform + kGLMPixelBuffer, // for PBO + + kGLMNumBufferTypes +}; + + // pass this in "options" to constructor to make a dynamic buffer +#define GLMBufferOptionDynamic 0x00000001 + +struct GLMBuffLockParams +{ + uint m_offset; + uint m_size; + bool m_nonblocking; + bool m_discard; +}; + +class CGLMBuffer +{ + +public: + void Lock( GLMBuffLockParams *params, char **addressOut ); + void Unlock( void ); + +//protected: + friend class GLMContext; // only GLMContext can make CGLMBuffer objects + friend class GLMTester; + friend class IDirect3D9; + friend class IDirect3DDevice9; + + CGLMBuffer ( GLMContext *ctx, EGLMBufferType type, uint size, uint options ); + ~CGLMBuffer ( ); + + void SetModes ( bool asyncMap, bool explicitFlush, bool force = false ); + void FlushRange ( uint offset, uint size ); + + GLMContext *m_ctx; // link back to parent context + EGLMBufferType m_type; + uint m_size; + GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB + GLuint m_name; // name of this program in the context + uint m_revision; // bump anytime the size changes or buffer is orphaned + bool m_enableAsyncMap; // mirror of the buffer state + bool m_enableExplicitFlush; // mirror of the buffer state + + bool m_bound; // true if bound to context + bool m_mapped; // is it currently mapped + uint m_dirtyMinOffset; // when equal, range is empty + uint m_dirtyMaxOffset; + + float *m_lastMappedAddress; + + // --------------------- pseudo-VBO support below here (explicitly for dynamic index buffers) + bool m_pseudo; // true if the m_name is 0, and the backing is plain RAM + + // in pseudo mode, there is just one RAM buffer that acts as the backing. + // expectation is that this mode would only be used for dynamic indices. + // since indices have to be consumed (copied to command stream) prior to return from a drawing call, + // there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op. + + char *m_pseudoBuf; // storage for pseudo buffer +}; + + +#endif \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmfbo.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmfbo.cpp new file mode 100644 index 0000000..01d4ef1 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmfbo.cpp @@ -0,0 +1,353 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmfbo.cpp +// +//=============================================================================== + +#include "glmgr.h" +#include "cglmfbo.h" +// #include "../shaderapidx9/dxabstract.h" + + + +CGLMFBO::CGLMFBO( GLMContext *ctx ) +{ + m_ctx = ctx; + m_ctx->CheckCurrent(); + + glGenFramebuffersEXT( 1, &m_name ); + GLMCheckError(); + + memset( m_attach, 0, sizeof( m_attach ) ); + + m_sizeX = m_sizeY = 0; +} + + +CGLMFBO::~CGLMFBO( ) +{ + m_ctx->CheckCurrent(); + + // detach all known attached textures first... necessary ? + for( int index = 0; index < kAttCount; index++) + { + if (m_attach[ index ].m_tex) + { + TexDetach( (EGLMFBOAttachment)index ); + GLMCheckError(); + } + } + + glDeleteFramebuffersEXT( 1, &m_name ); + GLMCheckError(); + + m_name = 0; + m_ctx = NULL; +} + +// the tex attach path should also select a specific slice of the texture... +// and we need a way to make renderbuffers.. + +static GLenum EncodeAttachmentFBO( EGLMFBOAttachment index ) +{ + if (index < kAttDepth) + { + return GL_COLOR_ATTACHMENT0_EXT + (int) index; + } + else + { + switch( index ) + { + case kAttDepth: + return GL_DEPTH_ATTACHMENT_EXT; + break; + + case kAttStencil: + return GL_STENCIL_ATTACHMENT_EXT; + break; + + case kAttDepthStencil: + return GL_DEPTH_STENCIL_ATTACHMENT_EXT; + break; + + default: + GLMStop(); // bad news + return 0; + break; + } + } +} + +void CGLMFBO::TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint ) +{ + // force our parent context to be current + m_ctx->MakeCurrent(); + + // bind to context (will cause FBO object creation on first use) + m_ctx->BindFBOToCtx( this, fboBindPoint ); + + // it's either a plain 2D, a 2D face of a cube map, or a slice of a 3D. + CGLMTex *tex = params->m_tex; + + // always detach what is currently there, if anything + this->TexDetach( attachIndex, fboBindPoint ); + + if (!tex) + { + // andif they pass NULL to us, then we are done. + return; + } + + GLMTexLayout *layout = tex->m_layout; + GLenum target = tex->m_layout->m_key.m_texGLTarget; + + GLenum attachIndexGL = EncodeAttachmentFBO( attachIndex ); + + switch( target ) + { + case GL_TEXTURE_2D: + { + // we will attach the underlying RBO on a multisampled tex, iff the tex hasone, **and** we're not being asked to attach it to the read buffer. + // if we get a req to attach an MSAA tex to the read buffer, chances are it's BlitTex calling, andit has already resolved the tex, so in those + // cases you really do want to attach the texture and not the RBO to the FBO in question. + + bool useRBO = false; // initial state + + if (layout->m_key.m_texFlags & kGLMTexMultisampled) + { + // it is an MSAA tex + if (fboBindPoint == GL_READ_FRAMEBUFFER_EXT) + { + // I think you just want to read a resolved tex. + // But I will check that it is resolved first.. + Assert( tex->m_rboDirty == false ); + } + else + { + // you want to draw into it. You get the RBO bound instead of the tex. + useRBO = true; + } + } + + if (useRBO) + { + // MSAA path - attach the RBO, not the texture, and mark the RBO dirty + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + // you have to attach it both places... + // http://www.opengl.org/wiki/GL_EXT_framebuffer_object + + // bind the RBO to the GL_RENDERBUFFER_EXT target + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName ); + GLMCheckError(); + + // attach the GL_RENDERBUFFER_EXT target to the depth and stencil attach points + glFramebufferRenderbufferEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName); + GLMCheckError(); + + glFramebufferRenderbufferEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName); + GLMCheckError(); + + // no need to leave the RBO hanging on + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); + GLMCheckError(); + } + else + { + // color attachment (likely 0) + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName ); + GLMCheckError(); + + glFramebufferRenderbufferEXT( fboBindPoint, attachIndexGL, GL_RENDERBUFFER_EXT, tex->m_rboName); + GLMCheckError(); + + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); + GLMCheckError(); + } + tex->m_rboDirty = true; + } + else + { + // regular path - attaching a texture2d + + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + // you have to attach it both places... + // http://www.opengl.org/wiki/GL_EXT_framebuffer_object + + glFramebufferTexture2DEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, target, tex->m_texName, params->m_mip ); + GLMCheckError(); + + glFramebufferTexture2DEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, target, tex->m_texName, params->m_mip ); + GLMCheckError(); + } + else + { + glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip ); + GLMCheckError(); + } + } + } + break; + + case GL_TEXTURE_3D: + { + glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip, params->m_zslice ); + GLMCheckError(); + } + break; + + case GL_TEXTURE_CUBE_MAP: + { + // adjust target to steer to the proper face of the cube map + target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + params->m_face; + + glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip ); + GLMCheckError(); + } + break; + } + + // log the attached tex + m_attach[ attachIndex ] = *params; + + // indicate that the tex has been bound to an RT + tex->m_rtAttachCount++; +} + +void CGLMFBO::TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint ) +{ + // force our parent context to be current + m_ctx->MakeCurrent(); + + // bind to context (will cause FBO object creation on first use) + m_ctx->BindFBOToCtx( this, fboBindPoint ); + + if (m_attach[ attachIndex ].m_tex) + { + CGLMTex *tex = m_attach[ attachIndex ].m_tex; + GLMTexLayout *layout = tex->m_layout; + GLenum target = tex->m_layout->m_key.m_texGLTarget; + + GLenum attachIndexGL = EncodeAttachmentFBO( attachIndex ); + + switch( target ) + { + case GL_TEXTURE_2D: + { + if (layout->m_key.m_texFlags & kGLMTexMultisampled) + { + // MSAA path - detach the RBO, not the texture + // (is this the right time to resolve? probably better to wait until someone tries to sample the texture) + + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); + GLMCheckError(); + + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + // detach the GL_RENDERBUFFER_EXT target at depth and stencil attach points + glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); + GLMCheckError(); + + glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); + GLMCheckError(); + } + else + { + // color attachment (likely 0) + glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, attachIndexGL, GL_RENDERBUFFER_EXT, 0); + GLMCheckError(); + } + } + else + { + // plain tex detach + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + // you have to detach it both places... + // http://www.opengl.org/wiki/GL_EXT_framebuffer_object + + glFramebufferTexture2DEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, 0,0,0 ); + glFramebufferTexture2DEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, 0,0,0 ); + } + else + { + glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, 0, 0, 0 ); + } + } + } + break; + + case GL_TEXTURE_3D: + { + glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, 0, 0, 0, 0 ); + GLMCheckError(); + } + break; + + case GL_TEXTURE_CUBE_MAP: + { + glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, 0, 0, 0 ); + GLMCheckError(); + } + break; + } + + // un-log the attached tex + memset( &m_attach[ attachIndex ], 0, sizeof( m_attach[0] ) ); + + // drop the RT attach count + tex->m_rtAttachCount--; + } + else + { + //Debugger(); // odd, but not harmful - typ comes from D3D code passing NULL into SetRenderTarget + } +} + +void CGLMFBO::TexScrub( CGLMTex *tex ) +{ + // see if it's attached anywhere + for( int attachIndex = 0; attachIndex < kAttCount; attachIndex++ ) + { + if (m_attach[ attachIndex ].m_tex == tex) + { + // blammo + TexDetach( (EGLMFBOAttachment)attachIndex, GL_DRAW_FRAMEBUFFER_EXT ); + } + } +} + + +bool CGLMFBO::IsReady( void ) +{ + bool result = false; + + // ensure our parent context is current + m_ctx->CheckCurrent(); + + // bind to context (will cause FBO object creation on first use) + m_ctx->BindFBOToCtx( this ); + + GLenum status; + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + switch(status) + { + case GL_FRAMEBUFFER_COMPLETE_EXT: + result = true; + break; + + case GL_FRAMEBUFFER_UNSUPPORTED_EXT: + result = false; + Debugger(); + /* choose different formats */ + break; + + default: + result = false; + Debugger(); + /* programming error; will fail on all hardware */ + break; + } + return result; +} diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmfbo.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmfbo.h new file mode 100644 index 0000000..152e2a7 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmfbo.h @@ -0,0 +1,91 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmfbo.h +// GLMgr FBO's (render targets) +// +//=============================================================================== + +#ifndef CGLMFBO_H +#define CGLMFBO_H + +#pragma once + +#include "cglmtex.h" + +// good FBO references / recaps +// http://www.songho.ca/opengl/gl_fbo.html +// http://www.gamedev.net/reference/articles/article2331.asp + +// ext links + +// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt +// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt + +//=============================================================================== + +// tokens not in the SDK headers + +#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT + #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; + +// implicitly 16 maximum color attachments possible +enum EGLMFBOAttachment { + kAttColor0, kAttColor1, kAttColor2, kAttColor3, + kAttColor4, kAttColor5, kAttColor6, kAttColor7, + kAttColor8, kAttColor9, kAttColor10, kAttColor11, + kAttColor12, kAttColor13, kAttColor14, kAttColor15, + kAttDepth, kAttStencil, kAttDepthStencil, + kAttCount +}; + +struct GLMFBOTexAttachParams +{ + CGLMTex *m_tex; + int m_face; // keep zero if not cube map + int m_mip; // keep zero if notmip mapped + int m_zslice; // keep zero if not a 3D tex +}; + +class CGLMFBO +{ + +public: + +protected: + friend class GLMContext; // only GLMContext can make CGLMFBO objects + friend class GLMTester; + friend class CGLMTex; + + friend class IDirect3D9; + friend class IDirect3DDevice9; + + CGLMFBO( GLMContext *ctx ); + ~CGLMFBO( ); + + void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); + void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT ); + // you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other. + + void TexScrub( CGLMTex *tex ); + // search and destroy any attachment for the named texture + + bool IsReady( void ); // aka FBO completeness check - ready to draw + + GLMContext *m_ctx; // link back to parent context + + GLuint m_name; // name of this FBO in the context + + GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment + + int m_sizeX,m_sizeY; +}; + + +#endif \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmprogram.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmprogram.cpp new file mode 100644 index 0000000..55adccf --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmprogram.cpp @@ -0,0 +1,1430 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmprogram.cpp +// +//=============================================================================== + +#include "glmgr.h" +#include "cglmprogram.h" +#include "dxabstract.h" + +//=============================================================================== + +#if 0 + ConVar gl_shaderpair_cacherows_lg2( "gl_paircache_rows_lg2", "10"); // 10 is minimum + ConVar gl_shaderpair_cacheways_lg2( "gl_paircache_ways_lg2", "5"); // 5 is minimum + ConVar gl_shaderpair_cachelog( "gl_shaderpair_cachelog", "0" ); +#else + int gl_shaderpair_cacherows_lg2 = 10; + int gl_shaderpair_cacheways_lg2 = 5; + int gl_shaderpair_cachelog = 0; +#endif + +//=============================================================================== + + +GLenum GLMProgTypeToARBEnum( EGLMProgramType type ) +{ + GLenum result = 0; + switch(type) + { + case kGLMVertexProgram: result = GL_VERTEX_PROGRAM_ARB; break; + case kGLMFragmentProgram: result = GL_FRAGMENT_PROGRAM_ARB; break; + default: Assert( !"bad program type"); result = 0; break; + } + return result; +} + +GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ) +{ + GLenum result = 0; + switch(type) + { + case kGLMVertexProgram: result = GL_VERTEX_SHADER_ARB; break; + case kGLMFragmentProgram: result = GL_FRAGMENT_SHADER_ARB; break; + default: Assert( !"bad program type"); result = 0; break; + } + return result; +} + +static uint g_shader_serial = 1000000; + +CGLMProgram::CGLMProgram( GLMContext *ctx, EGLMProgramType type ) +{ + m_ctx = ctx; + m_ctx->CheckCurrent(); + + m_type = type; + m_serial = g_shader_serial++; + m_text = NULL; // no text yet + +#if GLMDEBUG + m_editable = NULL; +#endif + + memset( &m_descs, 0, sizeof( m_descs ) ); + + m_samplerMask = 0; // dxabstract sets this field later + + // create an ARB vp/fp program object name. No need to bind it yet. + GLMShaderDesc *arbDesc = &m_descs[ kGLMARB ]; + glGenProgramsARB( 1, &arbDesc->m_object.arb ); + + // create a GLSL shader object. + GLMShaderDesc *glslDesc = &m_descs[ kGLMGLSL ]; + GLenum glslStage = GLMProgTypeToGLSLEnum( m_type ); + + glslDesc->m_object.glsl = glCreateShaderObjectARB( glslStage );; + + // no text has arrived yet. That's done in SetProgramText. +} + +CGLMProgram::~CGLMProgram( ) +{ + m_ctx->CheckCurrent(); + + // if there is an arb program, delete it + GLMShaderDesc *arbDesc = &m_descs[ kGLMARB ]; + if (arbDesc->m_object.arb) + { + glDeleteProgramsARB( 1, &arbDesc->m_object.arb ); + GLMCheckError(); + arbDesc->m_object.arb = 0; + } + + // if there is a GLSL shader, delete it + GLMShaderDesc *glslDesc = &m_descs[kGLMGLSL]; + if (glslDesc->m_object.glsl) + { + glDeleteShader( (uintptr_t)glslDesc->m_object.glsl ); // why do I need a cast here again ? + GLMCheckError(); + glslDesc->m_object.glsl = 0; + } + +#if GLMDEBUG + if (m_editable) + { + delete m_editable; + m_editable = NULL; + } +#endif + + if (m_text) + { + free( m_text ); + m_text = NULL; + } + m_ctx = NULL; +} + +enum EShaderSection +{ + kGLMARBVertex, kGLMARBVertexDisabled, + kGLMARBFragment, kGLMARBFragmentDisabled, + kGLMGLSLVertex, kGLMGLSLVertexDisabled, + kGLMGLSLFragment, kGLMGLSLFragmentDisabled, + +}; + +const char *g_shaderSectionMarkers[] = // match ordering of enum +{ + "!!ARBvp", "-!!ARBvp", // enabled and disabled markers. so you can have multiple flavors in a blob and activate the one you want. + "!!ARBfp", "-!!ARBfp", + "//GLSLvp", "-//GLSLvp", + "//GLSLfp", "-//GLSLfp", + NULL +}; + +void CGLMProgram::SetProgramText( char *text ) +{ + // free old text if any + // clone new text + // scan newtext to find sections + // walk sections, and mark descs to indicate where text is at + + if (m_text) + { + free( m_text ); + m_text = NULL; + } + + // scrub desc text references + for( int i=0; im_textPresent = false; + desc->m_textOffset = 0; + desc->m_textLength = 0; + } + + m_text = strdup( text ); + Assert( m_text != NULL ); + + #if 0 // disabled in sample for now GLMDEBUG + // create editable text item, if it does not already exist + if (!m_editable) + { + char *suffix = ""; + + switch(m_type) + { + case kGLMVertexProgram: suffix = ".vsh"; break; + case kGLMFragmentProgram: suffix = ".fsh"; break; + default: GLMDebugger(); + } + + m_editable = new CGLMEditableTextItem( m_text, strlen(m_text), false, "/debugshaders/", suffix ); + + // pull our string back from the editable (it has probably munged it) + if (m_editable->HasData()) + { + ReloadStringFromEditable(); + } + } + #endif + + + // scan the text and find sections + CGLMTextSectioner sections( m_text, strlen( m_text ), g_shaderSectionMarkers ); + + int sectionCount = sections.Count(); + for( int i=0; i < sectionCount; i++ ) + { + uint subtextOffset = 0; + uint subtextLength = 0; + int markerIndex = 0; + + sections.GetSection( i, &subtextOffset, &subtextLength, &markerIndex ); + + // act on the section + GLMShaderDesc *desc = NULL; + switch( m_type ) + { + case kGLMVertexProgram: + switch( markerIndex ) + { + case kGLMARBVertex: + case kGLMGLSLVertex: + desc = &m_descs[ (markerIndex==kGLMARBVertex) ? kGLMARB : kGLMGLSL]; + + // these steps are generic across both langs + desc->m_textPresent = true; + desc->m_textOffset = subtextOffset; + desc->m_textLength = subtextLength; + desc->m_compiled = false; + desc->m_valid = false; + break; + + case kGLMARBVertexDisabled: + case kGLMGLSLVertexDisabled: + // ignore quietly + break; + + default: Assert(!"Mismatched section marker seen in SetProgramText (VP)"); break; + } + break; + + case kGLMFragmentProgram: + switch( markerIndex ) + { + case kGLMARBFragment: + case kGLMGLSLFragment: + desc = &m_descs[ (markerIndex==kGLMARBFragment) ? kGLMARB : kGLMGLSL]; + + // these steps are generic across both langs + desc->m_textPresent = true; + desc->m_textOffset = subtextOffset; + desc->m_textLength = subtextLength; + desc->m_compiled = false; + desc->m_valid = false; + break; + + case kGLMARBFragmentDisabled: + case kGLMGLSLFragmentDisabled: + // ignore quietly + break; + + default: Assert(!"Mismatched section marker seen in SetProgramText (VP)"); break; + } + break; + } + } +} + +bool CGLMProgram::CompileActiveSources ( void ) +{ + bool result = true; // assume success + + // compile everything we have text for + for( int i=0; im_object.arb ); // object created or just re-bound + GLMCheckError(); + + char *section = m_text + arbDesc->m_textOffset; + char *lastCharOfSection = section + arbDesc->m_textLength; // actually it's one past the last textual character + + #if GLMDEBUG + if(noisy) + { + GLMPRINTF((">-D- CGLMProgram::Compile submitting following text for ARB %s program (name %d) ---------------------", + arbTarget == GL_FRAGMENT_PROGRAM_ARB ? "fragment" : "vertex", + arbDesc->m_object.arb )); + + // we don't have a "print this many chars" call yet + // just temporarily null terminate the text we want to print + + char saveChar = *lastCharOfSection; + + *lastCharOfSection= 0; + GLMPRINTTEXT(( section, eDebugDump )); + *lastCharOfSection= saveChar; + + GLMPRINTF(("<-D- CGLMProgram::Compile ARB EOT--" )); + } + #endif + + glProgramStringARB( arbTarget, GL_PROGRAM_FORMAT_ASCII_ARB, arbDesc->m_textLength, section ); + GLMCheckError( true, false ); + arbDesc->m_compiled = true; // compiled but not necessarily valid + + CheckValidity( lang ); + GLMCheckError(); + // leave it bound n enabled, don't care (draw will sort it all out) + + result = arbDesc->m_valid; + } + break; + + case kGLMGLSL: + { + GLMShaderDesc *glslDesc; + + glslDesc = &m_descs[ kGLMGLSL ]; + + GLenum glslStage = GLMProgTypeToGLSLEnum( m_type ); + + // there's no binding to do for GLSL. but make sure no ARB stuff is bound for tidiness. + glSetEnable( GL_VERTEX_PROGRAM_ARB, false ); + glSetEnable( GL_FRAGMENT_PROGRAM_ARB, false ); // add check errors on these + + glBindProgramARB( GL_VERTEX_PROGRAM_ARB, 0 ); + glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, 0 ); + + // no GLSL program either + glUseProgram(0); + + // pump text into GLSL shader object + + char *section = m_text + glslDesc->m_textOffset; + char *lastCharOfSection = section + glslDesc->m_textLength; // actually it's one past the last textual character + + #if GLMDEBUG + if(noisy) + { + GLMPRINTF((">-D- CGLMProgram::Compile submitting following text for GLSL %s program (name %d) ---------------------", + glslStage == GL_FRAGMENT_SHADER_ARB ? "fragment" : "vertex", + glslDesc->m_object.glsl )); + + // we don't have a "print this many chars" call yet + // just temporarily null terminate the text we want to print + + char saveChar = *lastCharOfSection; + + *lastCharOfSection= 0; + GLMPRINTTEXT(( section, eDebugDump )); + *lastCharOfSection= saveChar; + + GLMPRINTF(("<-D- CGLMProgram::Compile GLSL EOT--" )); + } + #endif + + glShaderSourceARB( glslDesc->m_object.glsl, 1, (const GLchar **)§ion, &glslDesc->m_textLength); + GLMCheckError( true, false ); + + // compile + glCompileShaderARB( glslDesc->m_object.glsl ); + glslDesc->m_compiled = true; // compiled but not necessarily valid + GLMCheckError( true, false ); + + CheckValidity( lang ); + GLMCheckError(); + + if (loglevel>=2) + { + char tempname[128]; + int tempindex = -1; + int tempcombo = -1; + + //GetLabelIndexCombo( tempname, sizeof(tempname), &tempindex, &tempcombo ); + //printf("\ncompile: - [ %s/%d/%d ] on GL name %d ", tempname, tempindex, tempcombo, glslDesc->m_object.glsl ); + + + GetComboIndexNameString( tempname, sizeof(tempname) ); + printf("\ncompile: %s on GL name %p ", tempname, glslDesc->m_object.glsl ); + } + + result = glslDesc->m_valid; + } + break; + } + return result; +} + +#if GLMDEBUG + + bool CGLMProgram::PollForChanges( void ) + { + bool result = false; + if (m_editable) + { + result = m_editable->PollForChanges(); + } + return result; + } + + void CGLMProgram::ReloadStringFromEditable( void ) + { + uint dataSize=0; + char *data=NULL; + + m_editable->GetCurrentText( &data, &dataSize ); + + char *buf = (char *)malloc( dataSize+1 ); // we will NULL terminate it, since the mirror copy might not be + memcpy( buf, data, dataSize ); + buf[dataSize] = 0; + + SetProgramText( buf ); + + free( buf ); + } + + bool CGLMProgram::SyncWithEditable( void ) + { + bool result = false; + + if (m_editable->PollForChanges()) + { + ReloadStringFromEditable(); + + CompileActiveSources(); + + // invalidate shader pair cache entries using this shader.. + m_ctx->m_pairCache->PurgePairsWithShader( this ); + + result = true; // result true means "it changed" + } + return result; + } + +#endif + + +// attributes which are general to both stages +// VP and FP: +// +// 0x88A0 PROGRAM_INSTRUCTIONS_ARB VP FP +// 0x88A1 MAX_PROGRAM_INSTRUCTIONS_ARB VP FP +// 0x88A2 PROGRAM_NATIVE_INSTRUCTIONS_ARB VP FP +// 0x88A3 MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB VP FP +// +// 0x88A4 PROGRAM_TEMPORARIES_ARB VP FP +// 0x88A5 MAX_PROGRAM_TEMPORARIES_ARB VP FP +// 0x88A6 PROGRAM_NATIVE_TEMPORARIES_ARB VP FP +// 0x88A7 MAX_PROGRAM_NATIVE_TEMPORARIES_ARB VP FP +// +// 0x88A8 PROGRAM_PARAMETERS_ARB VP FP +// 0x88A9 MAX_PROGRAM_PARAMETERS_ARB VP FP +// 0x88AA PROGRAM_NATIVE_PARAMETERS_ARB VP FP +// 0x88AB MAX_PROGRAM_NATIVE_PARAMETERS_ARB VP FP +// +// 0x88AC PROGRAM_ATTRIBS_ARB VP FP +// 0x88AD MAX_PROGRAM_ATTRIBS_ARB VP FP +// 0x88AE PROGRAM_NATIVE_ATTRIBS_ARB VP FP +// 0x88AF MAX_PROGRAM_NATIVE_ATTRIBS_ARB VP FP +// +// 0x88B4 MAX_PROGRAM_LOCAL_PARAMETERS_ARB VP FP +// 0x88B5 MAX_PROGRAM_ENV_PARAMETERS_ARB VP FP +// 0x88B6 PROGRAM_UNDER_NATIVE_LIMITS_ARB VP FP +// +// VP only: +// +// 0x88B0 PROGRAM_ADDRESS_REGISTERS_ARB VP +// 0x88B1 MAX_PROGRAM_ADDRESS_REGISTERS_ARB VP +// 0x88B2 PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB VP +// 0x88B3 MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB VP +// +// FP only: +// +// 0x8805 PROGRAM_ALU_INSTRUCTIONS_ARB FP +// 0x880B MAX_PROGRAM_ALU_INSTRUCTIONS_ARB FP +// 0x8808 PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB FP +// 0x880E MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB FP + +// 0x8806 PROGRAM_TEX_INSTRUCTIONS_ARB FP +// 0x880C MAX_PROGRAM_TEX_INSTRUCTIONS_ARB FP +// 0x8809 PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB FP +// 0x880F MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB FP + +// 0x8807 PROGRAM_TEX_INDIRECTIONS_ARB FP +// 0x880D MAX_PROGRAM_TEX_INDIRECTIONS_ARB FP +// 0x880A PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB FP +// 0x8810 MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB FP + +struct GLMShaderLimitDesc +{ + GLenum m_valueEnum; + GLenum m_limitEnum; + const char *m_debugName; + const char m_flags; + // m_flags - 0x01 for VP, 0x02 for FP, or set both if applicable to both +}; + +// macro to help make the table of what to check +#ifndef LMD +#define LMD( val, flags ) { GL_PROGRAM_##val##_ARB, GL_MAX_PROGRAM_##val##_ARB, #val, flags } +#else +#error you need to use a different name for this macro. +#endif + +GLMShaderLimitDesc g_glmShaderLimitDescs[] = +{ + // VP and FP.. + LMD( INSTRUCTIONS, 3 ), + LMD( NATIVE_INSTRUCTIONS, 3 ), + LMD( NATIVE_TEMPORARIES, 3 ), + LMD( PARAMETERS, 3 ), + LMD( NATIVE_PARAMETERS, 3 ), + LMD( ATTRIBS, 3 ), + LMD( NATIVE_ATTRIBS, 3 ), + + // VP only.. + LMD( ADDRESS_REGISTERS, 1 ), + LMD( NATIVE_ADDRESS_REGISTERS, 1 ), + + // FP only.. + LMD( ALU_INSTRUCTIONS, 2 ), + LMD( NATIVE_ALU_INSTRUCTIONS, 2 ), + LMD( TEX_INSTRUCTIONS, 2 ), + LMD( NATIVE_TEX_INSTRUCTIONS, 2 ), + LMD( TEX_INDIRECTIONS, 2 ), + LMD( NATIVE_TEX_INDIRECTIONS, 2 ), + + { 0, 0, NULL, 0 } +}; + +#undef LMD + +bool CGLMProgram::CheckValidity( EGLMProgramLang lang ) +{ + static const char *targnames[] = { "vertex", "fragment" }; + + switch(lang) + { + case kGLMARB: + { + GLMShaderDesc *arbDesc; + arbDesc = &m_descs[ kGLMARB ]; + + GLenum arbTarget = GLMProgTypeToARBEnum( m_type ); + + Assert( arbDesc->m_compiled ); + + arbDesc->m_valid = true; // assume success til we see otherwise + + // assume program is bound. is there anything wrong with it ? + + GLint isNative=0; + glGetProgramivARB( arbTarget, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &isNative ); + GLMCheckError(); + + // If the program is over the hardware's limits, print out some information + if (isNative!=1) + { + arbDesc->m_valid = false; + + // check everything we can check + char checkmask = (1<m_valueEnum !=0; desc++ ) + { + if ( desc->m_flags & checkmask ) + { + // test it + GLint value = 0; + GLint limit = 0; + glGetProgramivARB(arbTarget, desc->m_valueEnum, &value); + GLMCheckError(); + + glGetProgramivARB(arbTarget, desc->m_limitEnum, &limit); + GLMCheckError(); + + if (value > limit) + { + GLMPRINTF(("-D- Invalid %s program: program has %d %s; limit is %d", targnames[ m_type ], value, desc->m_debugName, limit )); + } + } + } + } + + // syntax error check + GLint errorLine; + glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errorLine ); + GLMCheckError(); + + if ( errorLine!=-1 ) + { + const GLubyte* errorString = glGetString(GL_PROGRAM_ERROR_STRING_ARB); + GLMPRINTF(( "-D- Syntax error in ARB %s program: %s",targnames[ m_type ], errorString )); + arbDesc->m_valid = false; + } + if (!arbDesc->m_valid) + { + char *temp = strdup(m_text); + temp[ arbDesc->m_textOffset + arbDesc->m_textLength ] = 0; + GLMPRINTF(("-D- ----- ARB compile failed; bad source follows -----" )); + GLMPRINTTEXT(( temp + arbDesc->m_textOffset, eDebugDump, GLMPRINTTEXT_NUMBEREDLINES )); + GLMPRINTF(("-D- -----end-----" )); + free( temp ); + } + + return arbDesc->m_valid; + } + break; + + case kGLMGLSL: + { + GLMShaderDesc *glslDesc; + glslDesc = &m_descs[ kGLMGLSL ]; + + GLenum glslStage = GLMProgTypeToGLSLEnum( m_type ); + + Assert( glslDesc->m_compiled ); + + glslDesc->m_valid = true; // assume success til we see otherwise + + // GLSL error check + int compiled = 0, length = 0, laux = 0; + + glGetObjectParameterivARB( (GLhandleARB)glslDesc->m_object.glsl, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); + glGetObjectParameterivARB( (GLhandleARB)glslDesc->m_object.glsl, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); + GLcharARB *logString = (GLcharARB *)malloc(length * sizeof(GLcharARB)); + glGetInfoLogARB((GLhandleARB)glslDesc->m_object.glsl, length, &laux, logString); + + // we may not be able to check "native limits" stuff until link time. meh + + if (!compiled) + { + glslDesc->m_valid = false; + } + + if (!glslDesc->m_valid) + { + char *temp = strdup(m_text); + temp[ glslDesc->m_textOffset + glslDesc->m_textLength ] = 0; + GLMPRINTF(("-D- ----- GLSL compile failed: \n %s \n",logString )); + GLMPRINTTEXT(( temp + glslDesc->m_textOffset, eDebugDump, GLMPRINTTEXT_NUMBEREDLINES )); + GLMPRINTF(("-D- -----end-----" )); + free( temp ); + } + + free( logString ); + + return glslDesc->m_valid; + } + break; + } + + return false; +} + +void CGLMProgram::LogSlow( EGLMProgramLang lang ) +{ + // find the desc, see if it's marked + GLMShaderDesc *desc = &m_descs[ lang ]; + + if (!desc->m_slowMark) + { + // log it + printf( "\n-------------- Slow %s ( CGLMProgram @ %p, lang %s, name %d ) : \n%s \n", + m_type==kGLMVertexProgram ? "VS" : "FS", + this, + lang==kGLMGLSL ? "GLSL" : "ARB", + (int)(uintptr_t)(lang==kGLMGLSL ? (uintptr_t)desc->m_object.glsl : (uintptr_t)desc->m_object.arb), + m_text + ); + } + else // complain on a decreasing basis (powers of two) + { + if ( (desc->m_slowMark & (desc->m_slowMark-1)) == 0 ) + { + // short blurb + printf( "\n Slow %s ( CGLMProgram @ %p, lang %s, name %d ) (%d times)", + m_type==kGLMVertexProgram ? "VS" : "FS", + this, + lang==kGLMGLSL ? "GLSL" : "ARB", + (int)(lang==kGLMGLSL ? (uintptr_t)desc->m_object.glsl : (uintptr_t)desc->m_object.arb), + desc->m_slowMark+1 + ); + } + } + + // mark it + desc->m_slowMark++; + + +} + +void CGLMProgram::GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut ) +{ + // find the label string + // example: + // trans#2871 label:vs-file vertexlit_and_unlit_generic_vs20 vs-index 294912 vs-combo 1234 + + *labelOut = 0; + *indexOut = -1; + + char *lineStr = strstr( m_text, "// trans#" ); + if (lineStr) + { + char temp1[1024]; + int temp2,temp3; + int scratch=-1; + temp1[0] = 0; + temp2 = -1; + temp3 = -1; + + if (this->m_type==kGLMVertexProgram) + { + sscanf( lineStr, "// trans#%d label:vs-file %s vs-index %d vs-combo %d", &scratch, temp1, &temp2, &temp3 ); + } + else + { + sscanf( lineStr, "// trans#%d label:ps-file %s ps-index %d ps-combo %d", &scratch, temp1, &temp2, &temp3 ); + } + + if ( (strlen(temp1)!=0) ) + { + strncpy( labelOut, temp1, labelOutMaxChars ); + *indexOut = temp2; + *comboOut = temp3; + } + } +} + +void CGLMProgram::GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ) // mmmmmmmm-nnnnnnnn-filename +{ + // find the label string + // example: + // trans#2871 label:vs-file vertexlit_and_unlit_generic_vs20 vs-index 294912 vs-combo 1234 + + *stringOut = 0; + + char *lineStr = strstr( m_text, "// trans#" ); + if (lineStr) + { + char temp1[1024]; + int temp2,temp3; + int scratch=-1; + + temp1[0] = 0; + temp2 = -1; + temp3 = -1; + + if (this->m_type==kGLMVertexProgram) + { + sscanf( lineStr, "// trans#%d label:vs-file %s vs-index %d vs-combo %d", &scratch, temp1, &temp2, &temp3 ); + } + else + { + sscanf( lineStr, "// trans#%d label:ps-file %s ps-index %d ps-combo %d", &scratch, temp1, &temp2, &temp3 ); + } + + int len = strlen(temp1); + + if ( (len+20) < stringOutMaxChars ) + { + // output formatted version + sprintf( stringOut, "%08X-%08X-%s", temp3, temp2, temp1 ); + } + } +} + +//=============================================================================== + + +CGLMShaderPair::CGLMShaderPair( GLMContext *ctx ) +{ + m_ctx = ctx; + m_ctx->MakeCurrent(); + + m_vertexProg = m_fragmentProg = NULL; + + m_program = glCreateProgramObjectARB(); + GLMCheckError(); + + m_locVertexParams = -1; + m_locVertexInteger0 = -1; // "i0" + m_locVertexBool0 = -1; // "b0" + m_locVertexBool1 = -1; // "b1" + m_locVertexBool2 = -1; // "b2" + m_locVertexBool3 = -1; // "b3" + + m_locFragmentParams = -1; + m_locFragmentFakeSRGBEnable = -1; + m_fakeSRGBEnableValue = -1.0f; + + memset( m_locSamplers, 0xFF, sizeof( m_locSamplers ) ); + + m_valid = false; + m_samplersFixed = false; // fix them at draw time, and only do it once. + m_revision = 0; // bumps to 1 once linked +} + +CGLMShaderPair::~CGLMShaderPair( ) +{ + if (m_program) + { + glDeleteObjectARB( (GLhandleARB)m_program ); + m_program = 0; + } +} + +bool CGLMShaderPair::SetProgramPair ( CGLMProgram *vp, CGLMProgram *fp ) +{ + m_valid = false; // assume failure + + // true result means successful link and query + bool vpgood = (vp!=NULL) && (vp->m_descs[ kGLMGLSL ].m_valid); + bool fpgood = (fp!=NULL) && (fp->m_descs[ kGLMGLSL ].m_valid); + + if (!fpgood) + { + // fragment side allowed to be "null". + fp = m_ctx->m_nullFragmentProgram; + } + + if (vpgood && fpgood) + { + // attempt link. but first, detach any previously attached programs + if (m_vertexProg) + { + glDetachObjectARB(m_program, m_vertexProg->m_descs[kGLMGLSL].m_object.glsl); + GLMCheckError(); + m_vertexProg = NULL; + } + + if (m_fragmentProg) + { + glDetachObjectARB(m_program, m_fragmentProg->m_descs[kGLMGLSL].m_object.glsl); + GLMCheckError(); + m_fragmentProg = NULL; + } + + // now attach + + glAttachObjectARB(m_program, vp->m_descs[kGLMGLSL].m_object.glsl); + m_vertexProg = vp; + GLMCheckError(); + + glAttachObjectARB(m_program, fp->m_descs[kGLMGLSL].m_object.glsl); + m_fragmentProg = fp; + GLMCheckError(); + + // force the locations for input attributes v0-vN to be at locations 0-N + // use the vertex attrib map to know which slots are live or not... oy! we don't have that map yet... but it's OK. + // fallback - just force v0-v15 to land in locations 0-15 as a standard. + + if (vp->m_descs[kGLMGLSL].m_valid) + { + for( int i=0; i < 16; i++) + { + char tmp[16]; + sprintf(tmp, "v%d", i); // v0 v1 v2 ... et al + + glBindAttribLocationARB( m_program, i, tmp ); + GLMCheckError(); + } + } + + // now link + glLinkProgramARB( m_program ); + GLMCheckError(); + + // check for success + GLint result = 0; + glGetObjectParameterivARB(m_program,GL_OBJECT_LINK_STATUS_ARB,&result); // want GL_TRUE + + if (result == GL_TRUE) + { + // success + + m_valid = true; + m_revision++; + } + else + { + GLint length = 0; + GLint laux = 0; + + // do some digging + glGetObjectParameterivARB(m_program,GL_OBJECT_INFO_LOG_LENGTH_ARB,&length); + + GLcharARB *logString = (GLcharARB *)malloc(length * sizeof(GLcharARB)); + glGetInfoLogARB(m_program, length, &laux, logString); + + char *vtemp = strdup(vp->m_text); + vtemp[ vp->m_descs[kGLMGLSL].m_textOffset + vp->m_descs[kGLMGLSL].m_textLength ] = 0; + + char *ftemp = strdup(fp->m_text); + ftemp[ fp->m_descs[kGLMGLSL].m_textOffset + fp->m_descs[kGLMGLSL].m_textLength ] = 0; + + GLMPRINTF(("-D- ----- GLSL link failed: \n %s ",logString )); + + GLMPRINTF(("-D- ----- GLSL vertex program selected: %08x (handle %08x)", vp, vp->m_descs[kGLMGLSL].m_object.glsl )); + GLMPRINTTEXT(( vtemp + vp->m_descs[kGLMGLSL].m_textOffset, eDebugDump, GLMPRINTTEXT_NUMBEREDLINES )); + + GLMPRINTF(("-D- ----- GLSL fragment program selected: %08x (handle %08x)", fp, vp->m_descs[kGLMGLSL].m_object.glsl )); + GLMPRINTTEXT(( ftemp + fp->m_descs[kGLMGLSL].m_textOffset, eDebugDump, GLMPRINTTEXT_NUMBEREDLINES )); + + GLMPRINTF(("-D- -----end-----" )); + + free( ftemp ); + free( vtemp ); + free( logString ); + } + } + else + { + // fail + Assert(!"Can't link these programs"); + } + + if (m_valid) + { + m_locVertexParams = glGetUniformLocationARB( m_program, "vc"); + GLMCheckError(); + + m_locVertexInteger0 = glGetUniformLocationARB( m_program, "i0"); + GLMCheckError(); + + m_locVertexBool0 = glGetUniformLocationARB( m_program, "b0"); + GLMCheckError(); + m_locVertexBool1 = glGetUniformLocationARB( m_program, "b1"); + GLMCheckError(); + m_locVertexBool2 = glGetUniformLocationARB( m_program, "b2"); + GLMCheckError(); + m_locVertexBool3 = glGetUniformLocationARB( m_program, "b3"); + GLMCheckError(); + + m_locFragmentParams = glGetUniformLocationARB( m_program, "pc"); + GLMCheckError(); + + m_locFragmentFakeSRGBEnable = glGetUniformLocationARB( m_program, "flSRGBWrite"); + GLMCheckError(); + m_fakeSRGBEnableValue = -1.0f; + + for( int sampler=0; sampler<16; sampler++) + { + char tmp[16]; + sprintf(tmp, "sampler%d", sampler); // sampler0 .. sampler1.. etc + + m_locSamplers[sampler] = glGetUniformLocationARB( m_program, tmp ); + GLMCheckError(); + } + } + else + { + m_locVertexParams = -1; + + m_locVertexInteger0 = -1; + m_locVertexBool0 = -1; + m_locVertexBool1 = -1; + m_locVertexBool2 = -1; + m_locVertexBool3 = -1; + + m_locFragmentParams = -1; + m_locFragmentFakeSRGBEnable = -1; + m_fakeSRGBEnableValue = -999; + + memset( m_locSamplers, 0xFF, sizeof( m_locSamplers ) ); + + m_revision = 0; + } + + return m_valid; +} + + +bool CGLMShaderPair::RefreshProgramPair ( void ) +{ + // re-link and re-query the uniforms. + + // since SetProgramPair knows how to detach previously attached shader objects, just pass the same ones in again. + CGLMProgram *vp = m_vertexProg; + CGLMProgram *fp = m_fragmentProg; + + bool vpgood = (vp!=NULL) && (vp->m_descs[ kGLMGLSL ].m_valid); + bool fpgood = (fp!=NULL) && (fp->m_descs[ kGLMGLSL ].m_valid); + + if (vpgood && fpgood) + { + return SetProgramPair( vp, fp ); + } + else + { + Debugger(); + return false; + } +} + + +//=============================================================================== + +CGLMShaderPairCache::CGLMShaderPairCache( GLMContext *ctx ) +{ + m_ctx = ctx; + + m_mark = 1; + + m_rowsLg2 = gl_shaderpair_cacherows_lg2/* .GetInt() */; + if (m_rowsLg2 < 10) + m_rowsLg2 = 10; + m_rows = 1<Purge(); + Assert( !purgeResult ); + + if (m_entries) + { + free( m_entries ); + m_entries = NULL; + } + + if (m_evictions) + { + free( m_evictions ); + m_evictions = NULL; + } + + if (m_hits) + { + free( m_hits ); + m_hits = NULL; + } +} + + +#if 0 //turning off all the shader pair caching stuff for simplicity + +// Set this convar internally to build or add to the shader pair cache file (link hints) +// We really only expect this to work on POSIX +static ConVar glm_cacheprograms( "glm_cacheprograms", "0", FCVAR_DEVELOPMENTONLY ); + +#define PROGRAM_CACHE_FILE "program_cache.cfg" + +static void WriteToProgramCache( CGLMShaderPair *pair ) +{ + KeyValues *pProgramCache = new KeyValues( "programcache" ); + pProgramCache->LoadFromFile( g_pFullFileSystem, PROGRAM_CACHE_FILE, "MOD" ); + + if ( !pProgramCache ) + { + Warning( "Could not write to program cache file!\n" ); + return; + } + + // extract values of interest which represent a pair of shaders + + char vprogramName[128]; + int vprogramStaticIndex = -1; + int vprogramDynamicIndex = -1; + pair->m_vertexProg->GetLabelIndexCombo( vprogramName, sizeof(vprogramName), &vprogramStaticIndex, &vprogramDynamicIndex ); + + + char pprogramName[128]; + int pprogramStaticIndex = -1; + int pprogramDynamicIndex = -1; + pair->m_fragmentProg->GetLabelIndexCombo( pprogramName, sizeof(pprogramName), &pprogramStaticIndex, &pprogramDynamicIndex ); + + // make up a key - this thing is really a list of tuples, so need not be keyed by anything particular + KeyValues *pProgramKey = pProgramCache->CreateNewKey(); + Assert( pProgramKey ); + + pProgramKey->SetString ( "vs", vprogramName ); + pProgramKey->SetString ( "ps", pprogramName ); + + pProgramKey->SetInt ( "vs_static", vprogramStaticIndex ); + pProgramKey->SetInt ( "ps_static", pprogramStaticIndex ); + + pProgramKey->SetInt ( "vs_dynamic", vprogramDynamicIndex ); + pProgramKey->SetInt ( "ps_dynamic", pprogramDynamicIndex ); + + pProgramCache->SaveToFile( g_pFullFileSystem, PROGRAM_CACHE_FILE, "MOD" ); + pProgramCache->deleteThis(); +} +#endif + + +CGLMShaderPair *CGLMShaderPairCache::SelectShaderPair( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits ) +{ + CGLMShaderPair *result = NULL; + + int loglevel = gl_shaderpair_cachelog/* .GetInt() */; + char vtempname[128]; + int vtempindex = -1; + int vtempcombo = -1; + + char ptempname[128]; + int ptempindex = -1; + int ptempcombo = -1; + + + // select row where pair would be found if it exists + uint rowIndex = HashRowIndex( vp, fp, extraKeyBits ); + + CGLMPairCacheEntry *row = HashRowPtr( rowIndex ); + + // probe row and see if we get a hit + int hitway = -1;int emptyway = -1; int oldestway = -1; + + HashRowProbe( row, vp, fp, extraKeyBits, &hitway, &emptyway, &oldestway ); + + if (hitway >=0) + { + // found it. mark it and return + CGLMPairCacheEntry *hit = row + hitway; + hit->m_lastMark = m_mark; + + m_mark = m_mark+1; + if (!m_mark) // somewhat unlikely this will ever be reached.. but we need to avoid zero as a mark value + { + m_mark = 1; + } + + // count the hit + m_hits[ rowIndex ] ++; + + if (loglevel >= 3) // hits logged at level 3 and higher + { + printf("\nSSP: hit - row %05d - pair $%p (%d'th hit on row)",rowIndex, hit->m_pair, m_hits[ rowIndex ] ); + } + + result = hit->m_pair; + } + else + { + // we missed. if there is no empty way, then somebody's getting evicted. + int destway = -1; + + if (emptyway>=0) + { + destway = emptyway; + + if (loglevel >= 2) // misses logged at level 3 and higher + { + printf("\nSSP: miss - row %05d - ", rowIndex ); + } + } + else + { + // evict the oldest way + Assert( oldestway >= 0); // better not come back negative + + CGLMPairCacheEntry *evict = row + oldestway; + + Assert( evict->m_pair != NULL ); + Assert( evict->m_pair != m_ctx->m_boundPair ); // just check + + ///////////////////////FIXME may need to do a shoot-down if the pair being evicted is currently active in the context + + m_evictions[ rowIndex ]++; + + // log eviction if desired + if (loglevel >= 2) // misses logged at level 3 and higher + { + //evict->m_vertexProg->GetLabelIndexCombo( vtempname, sizeof(vtempname), &vtempindex, &vtempcombo ); + //evict->m_fragmentProg->GetLabelIndexCombo( ptempname, sizeof(ptempname), &ptempindex, &ptempcombo ); + //printf("\nSSP: miss - row %05d - [ %s/%d/%d %s/%d/%d ]'s %d'th eviction - ", rowIndex, vtempname, vtempindex, vtempcombo, ptempname, ptempindex, ptempcombo, m_evictions[ rowIndex ] ); + + evict->m_vertexProg->GetComboIndexNameString( vtempname, sizeof(vtempname) ); + evict->m_fragmentProg->GetComboIndexNameString( ptempname, sizeof(ptempname) ); + printf("\nSSP: miss - row %05d - [ %s + %s ]'s %d'th eviction - ", rowIndex, vtempname, ptempname, m_evictions[ rowIndex ] ); + } + + delete evict->m_pair; evict->m_pair = NULL; + memset( evict, 0, sizeof(*evict) ); + + destway = oldestway; + } + + // make the new entry + CGLMPairCacheEntry *newentry = row + destway; + + newentry->m_lastMark = m_mark; + newentry->m_vertexProg = vp; + newentry->m_fragmentProg = fp; + newentry->m_extraKeyBits = extraKeyBits; + newentry->m_pair = new CGLMShaderPair( m_ctx ); + newentry->m_pair->SetProgramPair( vp, fp ); + + if (loglevel >= 2) // say a little bit more + { + //newentry->m_vertexProg->GetLabelIndexCombo( vtempname, sizeof(vtempname), &vtempindex, &vtempcombo ); + //newentry->m_fragmentProg->GetLabelIndexCombo( ptempname, sizeof(ptempname), &ptempindex, &ptempcombo ); + //printf("new [ %s/%d/%d %s/%d/%d ]", vtempname, vtempindex, vtempcombo, ptempname, ptempindex, ptempcombo ); + + newentry->m_vertexProg->GetComboIndexNameString( vtempname, sizeof(vtempname) ); + newentry->m_fragmentProg->GetComboIndexNameString( ptempname, sizeof(ptempname) ); + printf("new [ %s + %s ]", vtempname, ptempname ); + } + + m_mark = m_mark+1; + if (!m_mark) // somewhat unlikely this will ever be reached.. but we need to avoid zero as a mark value + { + m_mark = 1; + } + + result = newentry->m_pair; + + /* + if (glm_cacheprograms.GetInt()) + { + WriteToProgramCache( newentry->m_pair ); + } + */ + } + + return result; +} + +void CGLMShaderPairCache::QueryShaderPair( int index, GLMShaderPairInfo *infoOut ) +{ + if ( (index<0) || ( index >= (m_rows*m_ways) ) ) + { + // no such location + memset( infoOut, sizeof(*infoOut), 0 ); + + infoOut->m_status = -1; + } + else + { + // locate the entry, and see if an active pair is present. + // if so, extract info and return with m_status=1. + // if not, exit with m_status = 0. + + CGLMPairCacheEntry *entry = &m_entries[index]; + + if (entry->m_pair) + { + // live + // extract values of interest for caller + + entry->m_pair->m_vertexProg->GetLabelIndexCombo ( infoOut->m_vsName, sizeof(infoOut->m_vsName), &infoOut->m_vsStaticIndex, &infoOut->m_vsDynamicIndex ); + entry->m_pair->m_fragmentProg->GetLabelIndexCombo ( infoOut->m_psName, sizeof(infoOut->m_psName), &infoOut->m_psStaticIndex, &infoOut->m_psDynamicIndex ); + + infoOut->m_status = 1; + } + else + { + // not + memset( infoOut, sizeof(*infoOut), 0 ); + infoOut->m_status = 0; + } + } +} + +bool CGLMShaderPairCache::PurgePairsWithShader( CGLMProgram *prog ) +{ + bool result = false; + + // walk all rows*ways + int limit = m_rows * m_ways; + for( int i=0; i < limit; i++) + { + CGLMPairCacheEntry *entry = &m_entries[i]; + + if (entry->m_pair) + { + //scrub it, if not currently bound, and if the supplied shader matches either stage + if ( (entry->m_vertexProg==prog) || (entry->m_fragmentProg==prog) ) + { + // found it, but does it conflict with bound pair ? + if (entry->m_pair == m_ctx->m_boundPair) + { + m_ctx->m_boundPair = NULL; + } + delete entry->m_pair; + memset( entry, 0, sizeof(*entry) ); + } + } + } + return result; +} + +bool CGLMShaderPairCache::Purge( void ) +{ + bool result = false; + + // walk all rows*ways + int limit = m_rows * m_ways; + for( int i=0; i < limit; i++) + { + CGLMPairCacheEntry *entry = &m_entries[i]; + + if (entry->m_pair) + { + //scrub it, unless the pair is the currently bound pair in our parent glm context + if (entry->m_pair != m_ctx->m_boundPair) + { + delete entry->m_pair; + memset( entry, 0, sizeof(*entry) ); + } + else + { + result = true; + } + } + } + return result; +} + +void CGLMShaderPairCache::DumpStats ( void ) +{ + printf("\n------------------\npair cache stats"); + int total = 0; + for( int row=0; row < m_rows; row++ ) + { + if ( (m_evictions[row] != 0) || (m_hits[row] != 0) ) + { + printf("\n row %d : %d evictions, %d hits",row,m_evictions[row], m_hits[row]); + total += m_evictions[row]; + } + } + printf("\n\npair cache evictions: %d\n-----------------------\n",total ); +} + + //=============================== + +uint CGLMShaderPairCache::HashRowIndex ( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits ) +{ + // calculate row index for this pair + uint vp_hash = vp->m_serial * 47; + uint fp_hash = fp->m_serial; + + uint hash_row_index = ((vp_hash * fp_hash) + (vp_hash ^ fp_hash) + (extraKeyBits * 7) ) & (m_rows-1); + + return hash_row_index; +} + +CGLMPairCacheEntry* CGLMShaderPairCache::HashRowPtr ( uint hashRowIndex ) +{ + return &m_entries[ hashRowIndex * m_ways ]; +} + +void CGLMShaderPairCache::HashRowProbe ( CGLMPairCacheEntry *row, CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits, int *hitwayOut, int *emptywayOut, int *oldestwayOut ) +{ + // scan this row to see if the desired pair is present + CGLMPairCacheEntry *cursor = row; + int hitway = -1; + int emptyway = -1; + int oldestway = -1; + long long oldestmark = 0xFFFFFFFFFFFFFFFFLL; + + for( int way = 0; (way < m_ways) && (hitway<0); way++) + { + if (cursor->m_lastMark != 0) // occupied slot + { + if ( (cursor->m_vertexProg == vp) && (cursor->m_fragmentProg == fp) && (cursor->m_extraKeyBits == extraKeyBits) ) // match? + { + // found it + hitway = way; + } + + // check if this is the oldest one on the row - only occupied slots are checked + if (cursor->m_lastMark < oldestmark) + { + oldestway = way; + oldestmark = cursor->m_lastMark; + } + } + else + { + // empty way, log it if first one seen + if (emptyway<0) + { + emptyway = way; + } + } + cursor++; + } + + if (hitwayOut) *hitwayOut = hitway; + if (emptywayOut) *emptywayOut = emptyway; + if (oldestwayOut) *oldestwayOut = oldestway; +} + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmprogram.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmprogram.h new file mode 100644 index 0000000..85fb305 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmprogram.h @@ -0,0 +1,291 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmprogram.h +// GLMgr programs (ARBVP/ARBfp) +// +//=============================================================================== + +#ifndef CGLMPROGRAM_H +#define CGLMPROGRAM_H + +#include + +#pragma once + +// good ARB program references +// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html +// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html + +// ext links + +// http://www.opengl.org/registry/specs/ARB/vertex_program.txt +// http://www.opengl.org/registry/specs/ARB/fragment_program.txt +// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt + + +//=============================================================================== + +// tokens not in the SDK headers + +//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT +// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9 +//#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; +class CGLMShaderPair; +class CGLMShaderPairCache; + +// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL. +// these flavors are pretty different in terms of the API's that are used to activate them - +// for example, assembler programs can just get bound to the context, whereas GLSL programs +// have to be linked. To some extent we try to hide that detail inside GLM. + +// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which +// flavor you want to use. GLMContext has to handle that. + +enum EGLMProgramType +{ + kGLMVertexProgram, + kGLMFragmentProgram, + + kGLMNumProgramTypes +}; + +enum EGLMProgramLang +{ + kGLMARB, + kGLMGLSL, + + kGLMNumProgramLangs +}; + +struct GLMShaderDesc +{ + union + { + GLuint arb; // ARB program object name + GLhandleARB glsl; // GLSL shader object handle (void*) + } m_object; + + // these can change if shader text is edited + bool m_textPresent; // is this flavor(lang) of text present in the buffer? + int m_textOffset; // where is it + int m_textLength; // how big + + bool m_compiled; // has this text been through a compile attempt + bool m_valid; // and if so, was the compile successful + + int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow. + + int m_highWater; // vount of vec4's in the major uniform array ("vc" on vs, "pc" on ps) + // written by dxabstract.... gross! +}; + +GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target +GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target + +class CGLMProgram +{ +public: + friend class CGLMShaderPairCache; + friend class CGLMShaderPair; + friend class GLMContext; // only GLMContext can make CGLMProgram objects + friend class GLMTester; + friend class IDirect3D9; + friend class IDirect3DDevice9; + + //=============================== + + // constructor is very light, it just makes one empty program object per flavor. + CGLMProgram( GLMContext *ctx, EGLMProgramType type ); + ~CGLMProgram( ); + + void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program + + bool CompileActiveSources ( void ); // compile only the flavors that were provided. + bool Compile ( EGLMProgramLang lang ); + bool CheckValidity ( EGLMProgramLang lang ); + + void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that + + void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut ); + void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename + +#if GLMDEBUG + bool PollForChanges( void ); // check mirror for changes. + void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change) + bool SyncWithEditable( void ); +#endif + + //=============================== + + // common stuff + + GLMContext *m_ctx; // link back to parent context + + EGLMProgramType m_type; // vertex or pixel + + uint m_serial; // serial number for hashing + + char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled. + // note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them +#if GLMDEBUG + CGLMEditableTextItem *m_editable; // editable text item for debugging +#endif + + GLMShaderDesc m_descs[ kGLMNumProgramLangs ]; + + uint m_samplerMask; // (1< + +//=============================================================================== + +extern int gl_errorcheckall; +extern int gl_errorcheckqueries; +extern int gl_errorchecknone; + +// how many microseconds to wait after a failed query-available test +// presently on MTGL this doesn't happen, but it could change, keep this handy +//ConVar gl_nullqueries( "gl_nullqueries", "0" ); +int gl_nullqueries = 0; + +GLenum GetQueryError( void ) +{ + if ( ( GLMDEBUG || (gl_errorcheckall != 0) || (gl_errorcheckqueries != 0) ) && (gl_errorchecknone == 0) ) + { + return glGetError(); + } + else + { + return (GLenum) 0; // whistle past graveyard + } +} + +//=============================================================================== + +CGLMQuery::CGLMQuery( GLMContext *ctx, GLMQueryParams *params ) +{ + // make sure context is current + // get the type of query requested + // generate name(s) needed + // set initial state appropriately + ctx->MakeCurrent(); + + m_ctx = ctx; + m_params = *params; + + m_name = 0; + + m_started = m_stopped = m_done = false; + + m_nullQuery = false; + // assume value of convar at start time + // does not change during individual query lifetime + // started null = stays null + // started live = stays live + + switch(m_params.m_type) + { + case EOcclusion: + { + //make an occlusion query (and a fence to go with it) + glGenQueriesARB( 1, &m_name ); + GLMPRINTF(("-A- CGLMQuery(OQ) created name %d", m_name)); + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::CGLMQuery (OQ) saw %s error (%d) from glGenQueriesARB", decodedStr, errorcode ); + m_name = 0; + } + } + break; + + case EFence: + //make a fence - no aux fence needed + glGenFencesAPPLE(1, &m_name ); + GLMPRINTF(("-A- CGLMQuery(fence) created name %d", m_name)); + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::CGLMQuery (fence) saw %s error (%d) from glGenFencesAPPLE", decodedStr, errorcode ); + m_name = 0; + } + break; + } + +} + +CGLMQuery::~CGLMQuery() +{ + GLMPRINTF(("-A-> ~CGLMQuery")); + + // make sure query has completed (might not be necessary) + // delete the name(s) + + m_ctx->MakeCurrent(); + + switch(m_params.m_type) + { + case EOcclusion: + { + // do a finish occlusion query ? + GLMPRINTF(("-A- ~CGLMQuery(OQ) deleting name %d", m_name)); + glDeleteQueries(1, &m_name ); + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::~CGLMQuery (OQ) saw %s error (%d) from glDeleteQueries", decodedStr, errorcode ); + } + } + break; + + case EFence: + { + // do a finish fence ? + GLMPRINTF(("-A- ~CGLMQuery(fence) deleting name %d", m_name)); + glDeleteFencesAPPLE(1, &m_name ); + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::~CGLMQuery (fence) saw %s error (%d) from glDeleteFencesAPPLE", decodedStr, errorcode ); + } + } + break; + } + + m_name = 0; + + GLMPRINTF(("-A-< ~CGLMQuery")); +} + + + + +void CGLMQuery::Start( void ) // "start counting" +{ + m_ctx->MakeCurrent(); + + // on occlusion query: + // glBeginQueryARB on the OQ name. counting starts. + + // on fence: glSetFence on m_name. + + // note, fences finish themselves via command progress - OQ's do not. + + Assert(!m_started); + Assert(!m_stopped); + Assert(!m_done); + + m_nullQuery = (gl_nullqueries != 0); // latch value for remainder of query life + + switch(m_params.m_type) + { + case EOcclusion: + { + if (m_nullQuery) + { + // do nothing.. + } + else + { + glBeginQueryARB( GL_SAMPLES_PASSED_ARB, m_name ); + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::Start(OQ) saw %s error (%d) from glBeginQueryARB (GL_SAMPLES_PASSED_ARB) name=%d", decodedStr, errorcode, m_name ); + } + } + } + break; + + case EFence: + glSetFenceAPPLE( m_name ); + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::Start(fence) saw %s error (%d) from glSetFenceAPPLE name=%d", decodedStr, errorcode, m_name ); + } + + m_stopped = true; // caller should not call Stop on a fence, it self-stops + break; + } + + m_started = true; +} + +void CGLMQuery::Stop( void ) // "stop counting" +{ + m_ctx->MakeCurrent(); + + Assert(m_started); + Assert(!m_stopped); // this will assert if you try to call Stop on a fence that is started + Assert(!m_done); + + switch(m_params.m_type) + { + case EOcclusion: + { + if (m_nullQuery) + { + // do nothing.. + } + else + { + glEndQueryARB( GL_SAMPLES_PASSED_ARB ); // we are only putting the request-to-stop-counting into the cmd stream. + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::Stop(OQ) saw %s error (%d) from glEndQueryARB( GL_SAMPLES_PASSED_ARB ) name=%d", decodedStr, errorcode, m_name ); + } + } + } + break; + + case EFence: + // nop - you don't "end" a fence, you just test it and/or finish it out in Complete + break; + } + + m_stopped = true; +} + +bool CGLMQuery::IsDone( void ) +{ + m_ctx->MakeCurrent(); + + Assert(m_started); + Assert(m_stopped); + + if(!m_done) // you can ask more than once, but we only check until it comes back as done. + { + // on occlusion: glGetQueryObjectivARB - large cost on pre SLGU, cheap after + // on fence: glTestFenceAPPLE on the fence + switch(m_params.m_type) + { + case EOcclusion: // just test the fence that was set after the query begin + { + if (m_nullQuery) + { + // do almost nothing.. but claim work is complete + m_done = true; + } + else + { + // prepare to pay a big price on drivers prior to 10.6.4+SLGU + + GLint available = 0; + glGetQueryObjectivARB(m_name, GL_QUERY_RESULT_AVAILABLE_ARB, &available ); + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::IsDone saw %s error (%d) from glGetQueryObjectivARB(a2) name=%d", decodedStr, errorcode, m_name ); + } + + m_done = (available != 0); + } + } + break; + + case EFence: + { + m_done = glTestFenceAPPLE( m_name ); + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::IsDone saw %s error (%d) from glTestFenceAPPLE(b) name=%d", decodedStr, errorcode, m_name ); + } + + if (m_done) + { + glFinishFenceAPPLE( m_name ); // no set fence goes un-finished + + errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::IsDone saw %s error (%d) from glFinishFenceAPPLE(b) name=%d", decodedStr, errorcode, m_name ); + } + } + } + break; + } + } + + return m_done; +} + +void CGLMQuery::Complete( uint *result ) +{ + m_ctx->MakeCurrent(); + + uint resultval = 0; + GLint available = 0; + bool bogus_available = false; + + // blocking call if not done + Assert(m_started); + Assert(m_stopped); + + switch(m_params.m_type) + { + case EOcclusion: + { + if (m_nullQuery) + { + m_done = true; + resultval = 0; // we did say "null queries..." + } + else + { + // accept that the query is going to drain pipe in 10.6.4 and prior. + // check the error on the spot. + glGetQueryObjectivARB(m_name, GL_QUERY_RESULT_AVAILABLE_ARB, &available ); + GLenum errorcode = GetQueryError(); + + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::Complete saw %s error (%d) from glGetQueryObjectivARB GL_QUERY_RESULT_AVAILABLE_ARB name=%d", decodedStr, errorcode, m_name ); + + resultval=0; + } + else + { + if (!available) + { + // this does happen with some very modest frequency. + if (!m_ctx->Caps().m_hasPerfPackage1) + { + glFlush(); // ISTR some deadlock cases on pre-SLGU drivers if you didn't do this to kick the queue along.. + } + } + + glGetQueryObjectuivARB( m_name, GL_QUERY_RESULT_ARB, &resultval); + + errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::Complete saw %s error (%d) from glGetQueryObjectivARB GL_QUERY_RESULT_ARB name=%d", decodedStr, errorcode, m_name ); + + resultval=0; + } + else + { + // resultval is legit + } + } + m_done = true; + } + } + break; + + case EFence: + { + if(!m_done) + { + glFinishFenceAPPLE( m_name ); + + GLenum errorcode = GetQueryError(); + if (errorcode) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + printf( "\nCGLMQuery::Complete saw %s error (%d) from glFinishFenceAPPLE (EFence) name=%d", decodedStr, errorcode, m_name ); + } + + m_done = true; // for clarity or if they try to Complete twice + } + } + break; + } + + Assert( m_done ); + + // reset state for re-use - i.e. you have to call Complete if you want to re-use the object + m_started = m_stopped = m_done = false; + + if (result) // caller may pass NULL if not interested in result, for example to clear a fence + { + *result = resultval; + } +} + + + + // accessors for the started/stopped state +bool CGLMQuery::IsStarted ( void ) +{ + return m_started; +} + +bool CGLMQuery::IsStopped ( void ) +{ + return m_stopped; +} + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmquery.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmquery.h new file mode 100644 index 0000000..e958f60 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmquery.h @@ -0,0 +1,84 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmquery.h +// GLMgr queries +// +//=============================================================================== + +#ifndef CGLMQUERY_H +#define CGLMQUERY_H + +#pragma once + +#ifdef OSX +#include "glmgrbasics.h" +#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; +class CGLMQuery; + +//=============================================================================== + +enum EGLMQueryType +{ + EOcclusion, + EFence, + EGLMQueryCount +}; + +struct GLMQueryParams +{ + EGLMQueryType m_type; +}; + +class CGLMQuery +{ + // leave everything public til it's running +public: + friend class GLMContext; // only GLMContext can make CGLMTex objects + friend class IDirect3DDevice9; + friend class IDirect3DQuery9; + + GLMContext *m_ctx; // link back to parent context + GLMQueryParams m_params; // params created with + + GLuint m_name; // name of the query object per se - could be fence, could be query object + + bool m_started; + bool m_stopped; + bool m_done; + + bool m_nullQuery; // was gl_nullqueries true at Start time - if so, continue to act like a null query through Stop/IsDone/Complete time + // restated - only Start should examine the convar. + + CGLMQuery( GLMContext *ctx, GLMQueryParams *params ); + ~CGLMQuery( ); + + // for an occlusion query: + // Start = BeginQuery query-start goes into stream + // Stop = EndQuery query-end goes into stream - a fence is also set so we can probe for completion + // IsDone = TestFence use the added fence to ask if query-end has passed (i.e. will Complete block?) + // Complete = GetQueryObjectuivARB(uint id, enum pname, uint *params) - extract the sample count + + // for a fence query: + // Start = SetFence fence goes into command stream + // Stop = NOP fences are self finishing - no need to call Stop on a fence + // IsDone = TestFence ask if fence passed + // Complete = FinishFence + + void Start ( void ); + void Stop ( void ); + bool IsDone ( void ); + void Complete ( uint *result ); + + // accessors for the started/stopped state + bool IsStarted ( void ); + bool IsStopped ( void ); +}; + + +#endif \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmtex.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmtex.cpp new file mode 100644 index 0000000..1efbfa3 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmtex.cpp @@ -0,0 +1,1804 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmtex.cpp +// +//=============================================================================== + +#include "glmgr.h" +#include "cglmtex.h" +#include "dxabstract.h" + +//=============================================================================== + +#define TEXSPACE_LOGGING 0 + +// encoding layout to an index where the bits read +// 4 : 1 if compressed +// 2 : 1 if not power of two +// 1 : 1 if mipmapped + +bool pwroftwo (int val ) +{ + return (val & (val-1)) == 0; +} + +int sEncodeLayoutAsIndex( GLMTexLayoutKey *key ) +{ + int index = 0; + + if (key->m_texFlags & kGLMTexMipped) + { + index |= 1; + } + + if ( ! ( pwroftwo(key->m_xSize) && pwroftwo(key->m_ySize) && pwroftwo(key->m_zSize) ) ) + { + // if not all power of two + index |= 2; + } + + if (GetFormatDesc( key->m_texFormat )->m_chunkSize >1 ) + { + index |= 4; + } + + return index; +} + +static unsigned long g_texGlobalBytes[8]; + +//=============================================================================== + +const GLMTexFormatDesc g_formatDescTable[] = +{ + // not yet handled by this table: + // D3DFMT_INDEX16, D3DFMT_VERTEXDATA // D3DFMT_INDEX32, + // WTF { D3DFMT_R5G6R5 ???, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 1, 2 }, + // WTF { D3DFMT_A ???, GL_ALPHA8, GL_ALPHA, GL_UNSIGNED_BYTE, 1, 1 }, + // ??? D3DFMT_V8U8, + // ??? D3DFMT_Q8W8V8U8, + // ??? D3DFMT_X8L8V8U8, + // ??? D3DFMT_R32F, + // ??? D3DFMT_D24X4S4 unsure how to handle or if it is ever used.. + // ??? D3DFMT_D15S1 ever used ? + // ??? D3DFMT_D24X8 ever used? + + // summ-name d3d-format gl-int-format gl-int-format-srgb gl-data-format gl-data-type chunksize, bytes-per-sqchunk + { "_D16", D3DFMT_D16, GL_DEPTH_COMPONENT16, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 1, 2 }, + { "_D24X8", D3DFMT_D24X8, GL_DEPTH_COMPONENT24, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 1, 4 }, // ??? unsure on this one + { "_D24S8", D3DFMT_D24S8, GL_DEPTH24_STENCIL8_EXT, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 1, 4 }, + + { "_A8R8G8B8", D3DFMT_A8R8G8B8, GL_RGBA8, GL_SRGB8_ALPHA8_EXT, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 1, 4 }, + { "_A4R4G4B4", D3DFMT_A4R4G4B4, GL_RGBA4, 0, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 1, 2 }, + { "_X8R8G8B8", D3DFMT_X8R8G8B8, GL_RGB8, GL_SRGB8_EXT, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 1, 4 }, + + { "_X1R5G5B5", D3DFMT_X1R5G5B5, GL_RGB5, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 1, 2 }, + { "_A1R5G5B5", D3DFMT_A1R5G5B5, GL_RGB5_A1, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 1, 2 }, + + { "_L8", D3DFMT_L8, GL_LUMINANCE8, GL_SLUMINANCE8_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE, 1, 1 }, + { "_A8L8", D3DFMT_A8L8, GL_LUMINANCE8_ALPHA8, GL_SLUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 1, 2 }, + + { "_DXT1", D3DFMT_DXT1, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_BYTE, 4, 8 }, + { "_DXT3", D3DFMT_DXT3, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE, 4, 16 }, + { "_DXT5", D3DFMT_DXT5, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE, 4, 16 }, + + { "_A16B16G16R16F", D3DFMT_A16B16G16R16F, GL_RGBA16F_ARB, 0, GL_RGBA, GL_HALF_FLOAT_ARB, 1, 8 }, + { "_A16B16G16R16", D3DFMT_A16B16G16R16, GL_RGBA16, 0, GL_RGBA, GL_UNSIGNED_SHORT, 1, 8 }, // 16bpc integer tex + + { "_A32B32G32R32F", D3DFMT_A32B32G32R32F, GL_RGBA32F_ARB, 0, GL_RGBA, GL_FLOAT, 1, 16 }, + + { "_R8G8B8", D3DFMT_R8G8B8, GL_RGB8, GL_SRGB8_EXT, GL_BGR, GL_UNSIGNED_BYTE, 1, 3 }, + + { "_A8", D3DFMT_A8, GL_ALPHA8, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 1, 1 }, + { "_R5G6B5", D3DFMT_R5G6B5, GL_RGB, GL_SRGB_EXT, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 1, 2 }, + + // fakey tex formats: the stated GL format and the memory layout may not agree (U8V8 for example) + + // _Q8W8V8U8 we just pass through as RGBA bytes. Shader does scale/bias fix + { "_Q8W8V8U8", D3DFMT_Q8W8V8U8, GL_RGBA8, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 1, 4 }, // straight ripoff of D3DFMT_A8R8G8B8 + + // U8V8 is exposed to the client as 2-bytes per texel, but we download it as 3-byte RGB. + // WriteTexels needs to do that conversion from rg8 to rgb8 in order to be able to download it correctly + { "_V8U8", D3DFMT_V8U8, GL_RGB8, 0, GL_RG, GL_BYTE, 1, 2 }, + + /* + // NV shadow depth tex + D3DFMT_NV_INTZ = 0x5a544e49, // MAKEFOURCC('I','N','T','Z') + D3DFMT_NV_RAWZ = 0x5a574152, // MAKEFOURCC('R','A','W','Z') + + // NV null tex + D3DFMT_NV_NULL = 0x4c4c554e, // MAKEFOURCC('N','U','L','L') + + // ATI shadow depth tex + D3DFMT_ATI_D16 = 0x36314644, // MAKEFOURCC('D','F','1','6') + D3DFMT_ATI_D24S8 = 0x34324644, // MAKEFOURCC('D','F','2','4') + + // ATI 1N and 2N compressed tex + D3DFMT_ATI_2N = 0x32495441, // MAKEFOURCC('A', 'T', 'I', '2') + D3DFMT_ATI_1N = 0x31495441, // MAKEFOURCC('A', 'T', 'I', '1') + */ +}; + +int g_formatDescTableCount = sizeof(g_formatDescTable) / sizeof( g_formatDescTable[0] ); + +const GLMTexFormatDesc *GetFormatDesc( D3DFORMAT format ) +{ + for( int i=0; i= range) Debugger(); + + *valuebuf = (*valuebuf << width) | scaled; +} + +// return true if successful +bool GLMGenTexels( GLMGenTexelParams *params ) +{ + unsigned char chunkbuf[256]; // can't think of any chunk this big.. + + const GLMTexFormatDesc *format = GetFormatDesc( params->m_format ); + + if (!format) + { + return FALSE; // fail + } + + // this section just generates one square chunk in the desired format + unsigned long *temp32 = (unsigned long*)chunkbuf; + unsigned int chunksize = 0; // we can sanity check against the format table with this + + switch( params->m_format ) + { + // comment shows byte order in RAM + // lowercase is bit arrangement in a byte + + case D3DFMT_A8R8G8B8: // B G R A + InsertTexelComponentFixed( params->a, 8, temp32 ); // A is inserted first and winds up at most significant bits after insertions follow + InsertTexelComponentFixed( params->r, 8, temp32 ); + InsertTexelComponentFixed( params->g, 8, temp32 ); + InsertTexelComponentFixed( params->b, 8, temp32 ); + chunksize = 4; + break; + + case D3DFMT_A4R4G4B4: // [ggggbbbb] [aaaarrrr] RA (nibbles) + InsertTexelComponentFixed( params->a, 4, temp32 ); + InsertTexelComponentFixed( params->r, 4, temp32 ); + InsertTexelComponentFixed( params->g, 4, temp32 ); + InsertTexelComponentFixed( params->b, 4, temp32 ); + chunksize = 2; + break; + + case D3DFMT_X8R8G8B8: // B G R X + InsertTexelComponentFixed( 0.0, 8, temp32 ); + InsertTexelComponentFixed( params->r, 8, temp32 ); + InsertTexelComponentFixed( params->g, 8, temp32 ); + InsertTexelComponentFixed( params->b, 8, temp32 ); + chunksize = 4; + break; + + case D3DFMT_X1R5G5B5: // [gggbbbbb] [xrrrrrgg] + InsertTexelComponentFixed( 0.0, 1, temp32 ); + InsertTexelComponentFixed( params->r, 5, temp32 ); + InsertTexelComponentFixed( params->g, 5, temp32 ); + InsertTexelComponentFixed( params->b, 5, temp32 ); + chunksize = 2; + break; + + case D3DFMT_A1R5G5B5: // [gggbbbbb] [arrrrrgg] + InsertTexelComponentFixed( params->a, 1, temp32 ); + InsertTexelComponentFixed( params->r, 5, temp32 ); + InsertTexelComponentFixed( params->g, 5, temp32 ); + InsertTexelComponentFixed( params->b, 5, temp32 ); + chunksize = 2; + break; + + case D3DFMT_L8: // L // caller, use R for L + InsertTexelComponentFixed( params->r, 8, temp32 ); + chunksize = 1; + break; + + case D3DFMT_A8L8: // L A // caller, use R for L and A for A + InsertTexelComponentFixed( params->a, 8, temp32 ); + InsertTexelComponentFixed( params->r, 8, temp32 ); + chunksize = 2; + break; + + case D3DFMT_R8G8B8: // B G R + InsertTexelComponentFixed( params->r, 8, temp32 ); + InsertTexelComponentFixed( params->g, 8, temp32 ); + InsertTexelComponentFixed( params->b, 8, temp32 ); + chunksize = 3; + break; + + case D3DFMT_A8: // A + InsertTexelComponentFixed( params->a, 8, temp32 ); + chunksize = 1; + break; + + case D3DFMT_R5G6B5: // [gggbbbbb] [rrrrrggg] + InsertTexelComponentFixed( params->r, 5, temp32 ); + InsertTexelComponentFixed( params->g, 6, temp32 ); + InsertTexelComponentFixed( params->b, 5, temp32 ); + chunksize = 2; + break; + + case D3DFMT_DXT1: + { + memset( temp32, 0, 8 ); // zap 8 bytes + + // two 565 RGB words followed by 32 bits of 2-bit interp values for a 4x4 block + // we write the same color to both slots and all zeroes for the mask (one color total) + + unsigned long dxt1_color = 0; + + // generate one such word and clone it + InsertTexelComponentFixed( params->r, 5, &dxt1_color ); + InsertTexelComponentFixed( params->g, 6, &dxt1_color ); + InsertTexelComponentFixed( params->b, 5, &dxt1_color ); + + // dupe + dxt1_color = dxt1_color | (dxt1_color<<16); + + // write into chunkbuf + *(unsigned long*)&chunkbuf[0] = dxt1_color; + + // color mask bits after that are already set to all zeroes. chunk is done. + chunksize = 8; + } + break; + + case D3DFMT_DXT3: + { + memset( temp32, 0, 16 ); // zap 16 bytes + + // eight bytes of alpha (16 4-bit alpha nibbles) + // followed by a DXT1 block + + unsigned long dxt3_alpha = 0; + for( int i=0; i<8; i++) + { + // splat same alpha through block + InsertTexelComponentFixed( params->a, 4, &dxt3_alpha ); + } + + unsigned long dxt3_color = 0; + + // generate one such word and clone it + InsertTexelComponentFixed( params->r, 5, &dxt3_color ); + InsertTexelComponentFixed( params->g, 6, &dxt3_color ); + InsertTexelComponentFixed( params->b, 5, &dxt3_color ); + + // dupe + dxt3_color = dxt3_color | (dxt3_color<<16); + + // write into chunkbuf + *(unsigned long*)&chunkbuf[0] = dxt3_alpha; + *(unsigned long*)&chunkbuf[4] = dxt3_alpha; + *(unsigned long*)&chunkbuf[8] = dxt3_color; + *(unsigned long*)&chunkbuf[12] = dxt3_color; + + chunksize = 16; + } + break; + + case D3DFMT_DXT5: + { + memset( temp32, 0, 16 ); // zap 16 bytes + + // DXT5 has 8 bytes of compressed alpha, then 8 bytes of compressed RGB like DXT1. + + // the 8 alpha bytes are 2 bytes of endpoint alpha values, then 16x3 bits of interpolants. + // so to write a single alpha value, just figure out the value, store it in both the first two bytes then store zeroes. + + InsertTexelComponentFixed( params->a, 8, (unsigned long*)&chunkbuf[0] ); + InsertTexelComponentFixed( params->a, 8, (unsigned long*)&chunkbuf[0] ); + // rest of the alpha mask was already zeroed. + + // now do colors + unsigned long dxt5_color = 0; + + // generate one such word and clone it + InsertTexelComponentFixed( params->r, 5, &dxt5_color ); + InsertTexelComponentFixed( params->g, 6, &dxt5_color ); + InsertTexelComponentFixed( params->b, 5, &dxt5_color ); + + // dupe + dxt5_color = dxt5_color | (dxt5_color<<16); + + // write into chunkbuf + *(unsigned long*)&chunkbuf[8] = dxt5_color; + *(unsigned long*)&chunkbuf[12] = dxt5_color; + + chunksize = 16; + } + break; + + + case D3DFMT_A32B32G32R32F: + { + *(float*)&chunkbuf[0] = params->r; + *(float*)&chunkbuf[4] = params->g; + *(float*)&chunkbuf[8] = params->b; + *(float*)&chunkbuf[12] = params->a; + + chunksize = 16; + } + break; + + case D3DFMT_A16B16G16R16: + memset( chunkbuf, 0, 8 ); + // R and G wind up in the first 32 bits + // B and A wind up in the second 32 bits + + InsertTexelComponentFixed( params->a, 16, (unsigned long*)&chunkbuf[4] ); // winds up as MSW of second word (note [4]) - thus last in RAM + InsertTexelComponentFixed( params->b, 16, (unsigned long*)&chunkbuf[4] ); + + InsertTexelComponentFixed( params->g, 16, (unsigned long*)&chunkbuf[0] ); + InsertTexelComponentFixed( params->r, 16, (unsigned long*)&chunkbuf[0] ); // winds up as LSW of first word, thus first in RAM + + chunksize = 8; + break; + + // not done yet + + + //case D3DFMT_D16: + //case D3DFMT_D24X8: + //case D3DFMT_D24S8: + + //case D3DFMT_A16B16G16R16F: + + default: + return FALSE; // fail + break; + } + + // once the chunk buffer is filled.. + + // sanity check the reported chunk size. + if (chunksize != format->m_bytesPerSquareChunk) + { + Debugger(); + return FALSE; + } + + // verify that the amount you want to write will not exceed the limit byte count + unsigned long destByteCount = chunksize * params->m_chunkCount; + + if (destByteCount > params->m_byteCountLimit) + { + Debugger(); + return FALSE; + } + + // write the bytes. + unsigned char *destP = (unsigned char*)params->m_dest; + for( int chunk=0; chunk < params->m_chunkCount; chunk++) + { + for( int byteindex = 0; byteindex < chunksize; byteindex++) + { + *destP++ = chunkbuf[byteindex]; + } + } + params->m_bytesWritten = destP - (unsigned char*)params->m_dest; + + return TRUE; +} + + +//=============================================================================== + +CGLMTexLayoutTable::CGLMTexLayoutTable() +{ +} + +GLMTexLayout *CGLMTexLayoutTable::NewLayoutRef( GLMTexLayoutKey *key ) +{ + // look up 'key' in the map and see if it's a hit, if so, bump the refcount and return + // if not, generate a completed layout based on the key, add to map, set refcount to 1, return that + + const GLMTexFormatDesc *formatDesc = GetFormatDesc( key->m_texFormat ); + bool compression = (formatDesc->m_chunkSize > 1); + if (!formatDesc) + { + GLMStop(); // bad news + } + + GLMTexLayoutKeyMap::iterator p = m_layoutMap.find( *key ); + if (p != m_layoutMap.end()) + { + // found it + //printf(" -hit- "); + GLMTexLayout *ptr = (*p).second; + + // bump ref count + ptr->m_refCount++; + + return ptr; + } + else + { + //printf(" -miss- "); + // need to make a new one + // to allocate it, we need to know how big to make it (slice count) + + // figure out how many mip levels are in play + int mipCount = 1; + if (key->m_texFlags & kGLMTexMipped) + { + int largestAxis = key->m_xSize; + + if (key->m_ySize > largestAxis) + largestAxis = key->m_ySize; + + if (key->m_zSize > largestAxis) + largestAxis = key->m_zSize; + + mipCount = 0; + while( largestAxis > 0 ) + { + mipCount ++; + largestAxis >>= 1; + } + } + + int faceCount = 1; + if (key->m_texGLTarget == GL_TEXTURE_CUBE_MAP) + { + faceCount = 6; + } + + int sliceCount = mipCount * faceCount; + + if (key->m_texFlags & kGLMTexMultisampled) + { + Assert( (key->m_texGLTarget == GL_TEXTURE_2D) ); + Assert( sliceCount == 1 ); + + // assume non mipped + Assert( (key->m_texFlags & kGLMTexMipped) == 0 ); + Assert( (key->m_texFlags & kGLMTexMippedAuto) == 0 ); + + // assume renderable and srgb + Assert( (key->m_texFlags & kGLMTexRenderable) !=0 ); + //Assert( (key->m_texFlags & kGLMTexSRGB) !=0 ); //FIXME don't assert on making depthstencil surfaces which are non srgb + + // double check sample count (FIXME need real limit check here against device/driver) + Assert( (key->m_texSamples==2) || (key->m_texSamples==4) || (key->m_texSamples==6) || (key->m_texSamples==8) ); + } + + // now we know enough to allocate and populate the new tex layout. + + // malloc the new layout + int layoutSize = sizeof( GLMTexLayout ) + (sliceCount * sizeof( GLMTexLayoutSlice )); + GLMTexLayout *layout = (GLMTexLayout *)malloc( layoutSize ); + memset( layout, 0, layoutSize ); + + // clone the key in there + memset( &layout->m_key, 0x00, sizeof(layout->m_key) ); + layout->m_key = *key; + + // set refcount + layout->m_refCount = 1; + + // save the format desc + layout->m_format = (GLMTexFormatDesc *)formatDesc; + + // we know the mipcount from before + layout->m_mipCount = mipCount; + + // we know the face count too + layout->m_faceCount = faceCount; + + // slice count is the product + layout->m_sliceCount = mipCount * faceCount; + + // we can now fill in the slices. + GLMTexLayoutSlice *slicePtr = &layout->m_slices[0]; + int storageOffset = 0; + + bool compressed = (formatDesc->m_chunkSize > 1); // true if DXT + + for( int mip = 0; mip < mipCount; mip ++ ) + { + for( int face = 0; face < faceCount; face++ ) + { + // note application of chunk size which is 1 for uncompressed, and 4 for compressed tex (DXT) + // note also that the *dimensions* must scale down to 1 + // but that the *storage* cannot go below 4x4. + // we introduce the "storage sizes" which are clamped, to compute the storage footprint. + + int storage_x,storage_y,storage_z; + + slicePtr->m_xSize = layout->m_key.m_xSize >> mip; + slicePtr->m_xSize = std::max( slicePtr->m_xSize, 1 ); // dimension can't go to zero + storage_x = std::max( slicePtr->m_xSize, formatDesc->m_chunkSize ); // storage extent can't go below chunk size + + slicePtr->m_ySize = layout->m_key.m_ySize >> mip; + slicePtr->m_ySize = std::max( slicePtr->m_ySize, 1 ); // dimension can't go to zero + storage_y = std::max( slicePtr->m_ySize, formatDesc->m_chunkSize ); // storage extent can't go below chunk size + + slicePtr->m_zSize = layout->m_key.m_zSize >> mip; + slicePtr->m_zSize = std::max( slicePtr->m_zSize, 1 ); // dimension can't go to zero + storage_z = std::max( slicePtr->m_zSize, 1); // storage extent for Z cannot go below '1'. + + //if (compressed) NO NO NO do not lie about the dimensionality, just fudge the storage. + //{ + // // round up to multiple of 4 in X and Y axes + // slicePtr->m_xSize = (slicePtr->m_xSize+3) & (~3); + // slicePtr->m_ySize = (slicePtr->m_ySize+3) & (~3); + //} + + int xchunks = (storage_x / formatDesc->m_chunkSize ); + int ychunks = (storage_y / formatDesc->m_chunkSize ); + + slicePtr->m_storageSize = (xchunks * ychunks * formatDesc->m_bytesPerSquareChunk) * storage_z; + slicePtr->m_storageOffset = storageOffset; + + storageOffset += slicePtr->m_storageSize; + storageOffset = ( (storageOffset+0x0F) & (~0x0F)); // keep each MIP starting on a 16 byte boundary. + + slicePtr++; + } + } + + layout->m_storageTotalSize = storageOffset; + //printf("\n size %08x for key (x=%d y=%d z=%d, fmt=%08x, bpsc=%d)", layout->m_storageTotalSize, key->m_xSize, key->m_ySize, key->m_zSize, key->m_texFormat, formatDesc->m_bytesPerSquareChunk ); + + // generate summary + // "target, format, +/- mips, base size" + char scratch[1024]; + + const char *targetname; + switch( key->m_texGLTarget ) + { + case GL_TEXTURE_2D: targetname = "2D "; break; + case GL_TEXTURE_3D: targetname = "3D "; break; + case GL_TEXTURE_CUBE_MAP: targetname = "CUBE"; break; + } + + sprintf( scratch, "[%s %s %dx%dx%d mips=%d slices=%d flags=%02lX%s]", + targetname, + formatDesc->m_formatSummary, + layout->m_key.m_xSize, layout->m_key.m_ySize, layout->m_key.m_zSize, + mipCount, + sliceCount, + layout->m_key.m_texFlags, + (layout->m_key.m_texFlags & kGLMTexSRGB) ? " SRGB" : "" + ); + layout->m_layoutSummary = strdup( scratch ); + //GLMPRINTF(("-D- new tex layout [ %s ]", scratch )); + + // then insert into map. disregard returned index. + m_layoutMap[ layout->m_key ] = layout; + + return layout; + } +} + +void CGLMTexLayoutTable::DelLayoutRef( GLMTexLayout *layout ) +{ + // locate layout in hash, drop refcount + + GLMTexLayoutKeyMap::iterator p = m_layoutMap.find( layout->m_key ); + if (p != m_layoutMap.end()) + { + // found it + GLMTexLayout *ptr = (*p).second; + + // drop ref count + ptr->m_refCount--; + } +} + +void CGLMTexLayoutTable::DumpStats( ) +{ + for( GLMTexLayoutKeyMap::iterator p = m_layoutMap.begin(); p != m_layoutMap.end(); p++ ) + { + GLMTexLayout *layout = (*p).second; + + // print it out + printf("\n%05d instances %08d bytes %08d totbytes %s", layout->m_refCount, layout->m_storageTotalSize, (layout->m_refCount*layout->m_storageTotalSize), layout->m_layoutSummary ); + } +} + +#if 0 + ConVar gl_texclientstorage( "gl_texclientstorage", "1" ); // default 1 for L4D2 + ConVar gl_texmsaalog ( "gl_texmsaalog", "0"); + ConVar gl_rt_forcergba ( "gl_rt_forcergba", "1" ); // on teximage of a renderable tex, pass GL_RGBA in place of GL_BGRA + ConVar gl_minimize_rt_tex ( "gl_minimize_rt_tex", "0" ); // if 1, set the GL_TEXTURE_MINIMIZE_STORAGE_APPLE texture parameter to cut off mipmaps for RT's + ConVar gl_minimize_all_tex ( "gl_minimize_all_tex", "1" ); // if 1, set the GL_TEXTURE_MINIMIZE_STORAGE_APPLE texture parameter to cut off mipmaps for textures which are unmipped + ConVar gl_minimize_tex_log ( "gl_minimize_tex_log", "0" ); // if 1, printf the names of the tex that got minimized +#else + int gl_texclientstorage = 1; + int gl_texmsaalog = 0; + int gl_rt_forcergba = 1; + int gl_minimize_rt_tex = 0; + int gl_minimize_all_tex =1; + int gl_minimize_tex_log =0; +#endif + + +CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, GLMTexSamplingParams *sampling, const char *debugLabel ) +{ + // caller has responsibility to make 'ctx' current, but we check to be sure. + ctx->CheckCurrent(); + + // note layout requested + m_layout = layout; + m_maxActiveMip = -1; //index of highest mip that has been written - increase as each mip arrives + m_minActiveMip = 999; //index of lowest mip that has been written - lower it as each mip arrives + + // note sampling (copy values) + m_sampling = *sampling; + + // note context owner + m_ctx = ctx; + + // clear the bind point flags + m_bindPoints = 0; // was ClearAll() with bitvec + + // clear the RT attach count + m_rtAttachCount = 0; + + // come up with a GL name for this texture. + // for MTGL friendliness, we should generate our own names at some point.. + glGenTextures( 1, &m_texName ); + + //sense whether to try and apply client storage upon teximage/subimage + m_texClientStorage = (gl_texclientstorage/* .GetInt() */ != 0); + + // flag that we have not yet been explicitly kicked into VRAM.. + m_texPreloaded = false; + + // clone the debug label if there is one. + m_debugLabel = debugLabel ? strdup(debugLabel) : NULL; + + // if tex is MSAA renderable, make an RBO, else zero the RBO name and dirty bit + if (layout->m_key.m_texFlags & kGLMTexMultisampled) + { + glGenRenderbuffersEXT( 1, &m_rboName ); + m_rboDirty = false; + + // so we have enough info to go ahead and bind the RBO and put storage on it? + // try it. + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_rboName ); + GLMCheckError(); + + // quietly clamp if sample count exceeds known limit for the device + int sampleCount = layout->m_key.m_texSamples; + + if (sampleCount > ctx->Caps().m_maxSamples) + { + sampleCount = ctx->Caps().m_maxSamples; // clamp + } + + GLenum msaaFormat = (layout->m_key.m_texFlags & kGLMTexSRGB) ? layout->m_format->m_glIntFormatSRGB : layout->m_format->m_glIntFormat; + glRenderbufferStorageMultisampleEXT( GL_RENDERBUFFER_EXT, + sampleCount, // not "layout->m_key.m_texSamples" + msaaFormat, + layout->m_key.m_xSize, + layout->m_key.m_ySize ); + GLMCheckError(); + + if (gl_texmsaalog/* .GetInt() */) + { + printf( "\n == MSAA Tex %p %s : MSAA RBO is intformat %s (%x)", this, m_debugLabel?m_debugLabel:"", GLMDecode( eGL_ENUM, msaaFormat ), msaaFormat ); + } + + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); + GLMCheckError(); + } + else + { + m_rboName = 0; + m_rboDirty = false; + } + + + // at this point we have the complete description of the texture, and a name for it, but no data and no actual GL object. + // we know this name has bever seen duty before, so we're going to hard-bind it to TMU 0, displacing any other tex that might have been bound there. + // any previously bound tex will be unbound and appropriately marked as a result. + // the active TMU will be set as a side effect. + ctx->BindTexToTMU( this, 0 ); + + // OK, our texture now exists and is bound on the active TMU. Not drawable yet though. + + // impose the sampling params we were given, unconditionally + ApplySamplingParams( sampling, true ); + + // if not an RT, create backing storage and fill it + if ( !(layout->m_key.m_texFlags & kGLMTexRenderable) ) + { + m_backing = (char *)malloc( m_layout->m_storageTotalSize ); + memset( m_backing, 0, m_layout->m_storageTotalSize ); + + // track bytes allocated for non-RT's + int formindex = sEncodeLayoutAsIndex( &layout->m_key ); + + g_texGlobalBytes[ formindex ] += m_layout->m_storageTotalSize; + + #if TEXSPACE_LOGGING + printf( "\n Tex %s added %d bytes in form %d which is now %d bytes", m_debugLabel ? m_debugLabel : "-", m_layout->m_storageTotalSize, formindex, g_texGlobalBytes[ formindex ] ); + printf( "\n\t\t[ %d %d %d %d %d %d %d %d ]", + g_texGlobalBytes[ 0 ],g_texGlobalBytes[ 1 ],g_texGlobalBytes[ 2 ],g_texGlobalBytes[ 3 ], + g_texGlobalBytes[ 4 ],g_texGlobalBytes[ 5 ],g_texGlobalBytes[ 6 ],g_texGlobalBytes[ 7 ] + ); + #endif + } + else + { + m_backing = NULL; + + m_texClientStorage = false; + } + + // init lock count + // lock reqs are tracked by the owning context + m_lockCount = 0; + + m_sliceFlags.resize( m_layout->m_sliceCount ); + for( int i=0; i< m_layout->m_sliceCount; i++) + { + m_sliceFlags[i] = 0; + // kSliceValid = false (we have not teximaged each slice yet) + // kSliceStorageValid = false (the storage allocated does not reflect what is in the tex) + // kSliceLocked = false (the slices are not locked) + // kSliceFullyDirty = false (this does not come true til first lock) + } + + // texture minimize parameter keeps driver from allocing mips when it should not, by being explicit about the ones that have no mips. + + bool setMinimizeParameter = false; + bool minimize_rt = (gl_minimize_rt_tex/* .GetInt() */!=0); + bool minimize_all = (gl_minimize_all_tex/* .GetInt() */!=0); + + if (layout->m_key.m_texFlags & kGLMTexRenderable) + { + // it's an RT. if mips were not explicitly requested, and "gl_minimize_rt_tex" is true, set the minimize parameter. + if ( (minimize_rt || minimize_all) && ( !(layout->m_key.m_texFlags & kGLMTexMipped) ) ) + { + setMinimizeParameter = true; + } + } + else + { + // not an RT. if mips were not requested, and "gl_minimize_all_tex" is true, set the minimize parameter. + if ( minimize_all && ( !(layout->m_key.m_texFlags & kGLMTexMipped) ) ) + { + setMinimizeParameter = true; + } + } + + if (setMinimizeParameter) + { + if (gl_minimize_tex_log/* .GetInt() */) + { + printf("\n minimizing storage for tex '%s' [%s] ", m_debugLabel?m_debugLabel:"-", m_layout->m_layoutSummary ); + } + glTexParameteri( m_layout->m_key.m_texGLTarget, GL_TEXTURE_MINIMIZE_STORAGE_APPLE, 1 ); + } + + // after a lot of pain with texture completeness... + // always push black into all slices of all newly created textures. + + #if 0 + bool pushRenderableSlices = (m_layout->m_key.m_texFlags & kGLMTexRenderable) != 0; + bool pushTexSlices = true; // just do it everywhere (m_layout->m_mipCount>1) && (m_layout->m_format->m_chunkSize !=1) ; + if (pushTexSlices) + { + // fill storage with mostly-opaque purple + + GLMGenTexelParams genp; + memset( &genp, 0, sizeof(genp) ); + + genp.m_format = m_layout->m_format->m_d3dFormat; + const GLMTexFormatDesc *format = GetFormatDesc( genp.m_format ); + + genp.m_dest = m_backing; // dest addr + genp.m_chunkCount = m_layout->m_storageTotalSize / format->m_bytesPerSquareChunk; // fill the whole slab + genp.m_byteCountLimit = m_layout->m_storageTotalSize; // limit writes to this amount + + genp.r = 1.0; + genp.g = 0.0; + genp.b = 1.0; + genp.a = 0.75; + + GLMGenTexels( &genp ); + } + #endif + + //if (pushRenderableSlices || pushTexSlices) + if (1) + { + for( int face=0; face m_faceCount; face++) + { + for( int mip=0; mip m_mipCount; mip++) + { + // we're not really going to lock, we're just going to write the blank data from the backing store we just made + GLMTexLockDesc desc; + + desc.m_req.m_tex = this; + desc.m_req.m_face = face; + desc.m_req.m_mip = mip; + + desc.m_sliceIndex = CalcSliceIndex( face, mip ); + + GLMTexLayoutSlice *slice = &m_layout->m_slices[ desc.m_sliceIndex ]; + + desc.m_req.m_region.xmin = desc.m_req.m_region.ymin = desc.m_req.m_region.zmin = 0; + desc.m_req.m_region.xmax = slice->m_xSize; + desc.m_req.m_region.ymax = slice->m_ySize; + desc.m_req.m_region.zmax = slice->m_zSize; + + desc.m_sliceBaseOffset = slice->m_storageOffset; // doesn't really matter... we're just pushing zeroes.. + desc.m_sliceRegionOffset = 0; + + this->WriteTexels( &desc, true, (layout->m_key.m_texFlags & kGLMTexRenderable)!=0 ); // write whole slice - but disable data source if it's an RT, as there's no backing + } + } + } + GLMPRINTF(("-A- -**TEXNEW '%-60s' name=%06d size=%09d storage=%08x label=%s ", m_layout->m_layoutSummary, m_texName, m_layout->m_storageTotalSize, m_backing, m_debugLabel ? m_debugLabel : "-" )); +} + +CGLMTex::~CGLMTex( ) +{ + if ( !(m_layout->m_key.m_texFlags & kGLMTexRenderable) ) + { + int formindex = sEncodeLayoutAsIndex( &m_layout->m_key ); + + g_texGlobalBytes[ formindex ] -= m_layout->m_storageTotalSize; + + #if TEXSPACE_LOGGING + printf( "\n Tex %s freed %d bytes in form %d which is now %d bytes", m_debugLabel ? m_debugLabel : "-", m_layout->m_storageTotalSize, formindex, g_texGlobalBytes[ formindex ] ); + printf( "\n\t\t[ %d %d %d %d %d %d %d %d ]", + g_texGlobalBytes[ 0 ],g_texGlobalBytes[ 1 ],g_texGlobalBytes[ 2 ],g_texGlobalBytes[ 3 ], + g_texGlobalBytes[ 4 ],g_texGlobalBytes[ 5 ],g_texGlobalBytes[ 6 ],g_texGlobalBytes[ 7 ] + ); + #endif + } + + GLMPRINTF(("-A- -**TEXDEL '%-60s' name=%06d size=%09d storage=%08x label=%s ", m_layout->m_layoutSummary, m_texName, m_layout->m_storageTotalSize, m_backing, m_debugLabel ? m_debugLabel : "-" )); + // check first to see if we were still bound anywhere or locked... these should be failures. + + // if all that is OK, then delete the underlying tex + glDeleteTextures( 1, &m_texName ); + GLMCheckError(); + m_texName = 0; + + if(m_rboName) + { + glDeleteRenderbuffersEXT( 1, &m_rboName ); + GLMCheckError(); + m_rboName = 0; + m_rboDirty = false; + } + + + // release our usage of the layout + m_ctx->m_texLayoutTable->DelLayoutRef( m_layout ); + m_layout = NULL; + + if (m_backing) + { + free( m_backing ); + m_backing = NULL; + } + + if (m_debugLabel) + { + free( m_debugLabel ); + m_debugLabel = NULL; + } + + m_ctx = NULL; +} + +int CGLMTex::CalcSliceIndex( int face, int mip ) +{ + // faces of the same mip level are adjacent. "face major" storage + int index = (mip * m_layout->m_faceCount) + face; + + return index; +} + +void CGLMTex::CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut ) +{ + int offset = 0; + int yStride = 0; + int zStride = 0; + + GLMTexFormatDesc *format = m_layout->m_format; + if (format->m_chunkSize==1) + { + // figure out row stride and layer stride + yStride = format->m_bytesPerSquareChunk * m_layout->m_slices[sliceIndex].m_xSize; // bytes per texel row (y stride) + zStride = yStride * m_layout->m_slices[sliceIndex].m_ySize; // bytes per texel layer (if 3D tex) + + offset = x * format->m_bytesPerSquareChunk; // lateral offset + offset += (y * yStride); // scanline offset + offset += (z * zStride); // should be zero for 2D tex + } + else + { + yStride = format->m_bytesPerSquareChunk * (m_layout->m_slices[sliceIndex].m_xSize / format->m_chunkSize); + zStride = yStride * (m_layout->m_slices[sliceIndex].m_ySize / format->m_chunkSize); + + // compressed format. scale the x,y,z values into chunks. + // assert if any of them are not multiples of a chunk. + int chunkx = x / format->m_chunkSize; + int chunky = y / format->m_chunkSize; + int chunkz = z / format->m_chunkSize; + + if ( (chunkx * format->m_chunkSize) != x) + { + GLMStop(); + } + + if ( (chunky * format->m_chunkSize) != y) + { + GLMStop(); + } + + if ( (chunkz * format->m_chunkSize) != z) + { + GLMStop(); + } + + offset = chunkx * format->m_bytesPerSquareChunk; // lateral offset + offset += (chunky * yStride); // chunk row offset + offset += (chunkz * zStride); // should be zero for 2D tex + } + + *offsetOut = offset; + *yStrideOut = yStride; + *zStrideOut = zStride; +} + +void CGLMTex::ApplySamplingParams( GLMTexSamplingParams *params, bool noCheck ) +{ + #define DIFF(fff) (noCheck || (params->fff != m_sampling.fff)) + + GLenum target = m_layout->m_key.m_texGLTarget; + + // if the texture is compressed, and has a maxActiveMip that is >=0 but less than the mip count, + // (i.e. they supplied *some* but not *all* mips needed)... + // generate them, and fix the max mip count. + + + //if ( /*(m_layout->m_format->m_chunkSize !=1) &&*/ (m_layout->m_mipCount>3) ) + //{ + // m_maxActiveMip = m_layout->m_mipCount-3; // pull back three levels + // glTexParameteri( target, GL_TEXTURE_MAX_LEVEL, m_maxActiveMip); + // GLMCheckError(); + //} + + if (DIFF(m_addressModes[0])) + { + m_sampling.m_addressModes[0] = params->m_addressModes[0]; + glTexParameteri( target, GL_TEXTURE_WRAP_S, m_sampling.m_addressModes[0]); + GLMCheckError(); + } + + if (DIFF(m_addressModes[1])) + { + m_sampling.m_addressModes[1] = params->m_addressModes[1]; + glTexParameteri( target, GL_TEXTURE_WRAP_T, m_sampling.m_addressModes[1]); + GLMCheckError(); + } + + if (DIFF(m_addressModes[2])) + { + m_sampling.m_addressModes[2] = params->m_addressModes[2]; + glTexParameteri( target, GL_TEXTURE_WRAP_R, m_sampling.m_addressModes[2]); + GLMCheckError(); + } + + if ( noCheck || memcmp( params->m_borderColor, m_sampling.m_borderColor, sizeof(m_sampling.m_borderColor) ) ) + { + memcpy( m_sampling.m_borderColor, params->m_borderColor, sizeof(params->m_borderColor) ); + glTexParameterfv( target, GL_TEXTURE_BORDER_COLOR, params->m_borderColor ); + GLMCheckError(); + } + + if (DIFF(m_magFilter)) + { + m_sampling.m_magFilter = params->m_magFilter; + glTexParameteri( target, GL_TEXTURE_MAG_FILTER, params->m_magFilter); + GLMCheckError(); + } + + if (DIFF(m_minFilter)) + { + m_sampling.m_minFilter = params->m_minFilter; + glTexParameteri( target, GL_TEXTURE_MIN_FILTER, params->m_minFilter); + GLMCheckError(); + } + + if (DIFF(m_mipmapBias)) + { + m_sampling.m_mipmapBias = params->m_mipmapBias; + //glTexParameterf( target, GL_TEXTURE_LOD_BIAS, params->m_mipmapBias ); + GLMCheckError(); + } + + if (DIFF(m_minMipLevel)) + { + // don't let minmiplevel go below min active mip level + m_sampling.m_minMipLevel = std::max( m_minActiveMip, params->m_minMipLevel ); + glTexParameteri( target, GL_TEXTURE_MIN_LOD, m_sampling.m_minMipLevel); + GLMCheckError(); + } + + if (DIFF(m_maxMipLevel)) + { + // do not let max selectable LOD exceed the max submitted mip + + m_sampling.m_maxMipLevel = std::min( m_maxActiveMip, params->m_maxMipLevel); + glTexParameteri( target, GL_TEXTURE_MAX_LOD, m_sampling.m_maxMipLevel); + GLMCheckError(); + } + + if (m_layout->m_mipCount > 1) // only apply aniso setting to mipped tex + { + if (DIFF(m_maxAniso)) + { + m_sampling.m_maxAniso = params->m_maxAniso >= 1.0f ? params->m_maxAniso : 1.0f; + glTexParameteri( target, GL_TEXTURE_MAX_ANISOTROPY_EXT, params->m_maxAniso ); + GLMCheckError(); + } + } + + if (DIFF(m_compareMode)) + { + m_sampling.m_compareMode = params->m_compareMode; + glTexParameteri( target, GL_TEXTURE_COMPARE_MODE_ARB, params->m_compareMode ); + GLMCheckError(); + + if (params->m_compareMode == GL_COMPARE_R_TO_TEXTURE_ARB) + { + glTexParameteri( target, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL ); + GLMCheckError(); + } + } + + if (DIFF(m_srgb)) + { + m_sampling.m_srgb = params->m_srgb; // we might have to re-DL the tex if the SRGB read status changes.. + } + + #undef DIFF +} + +void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice ) +{ + GLMRegion readBox; + + if (readWholeSlice) + { + readBox.xmin = readBox.ymin = readBox.zmin = 0; + + readBox.xmax = m_layout->m_slices[ desc->m_sliceIndex ].m_xSize; + readBox.ymax = m_layout->m_slices[ desc->m_sliceIndex ].m_ySize; + readBox.zmax = m_layout->m_slices[ desc->m_sliceIndex ].m_zSize; + } + else + { + readBox = desc->m_req.m_region; + } + + m_ctx->BindTexToTMU( this, 0, false ); // SelectTMU(n) is a side effect + + if (readWholeSlice) + { + // make this work first.... then write the partial path + // (Hmmmm, I don't think we will ever actually need a partial path - + // since we have no notion of a partially valid slice of storage + + GLMTexFormatDesc *format = m_layout->m_format; + GLenum target = m_layout->m_key.m_texGLTarget; + + void *sliceAddress = m_backing + m_layout->m_slices[ desc->m_sliceIndex ].m_storageOffset; // this would change for PBO + int sliceSize = m_layout->m_slices[ desc->m_sliceIndex ].m_storageSize; + + // interestingly enough, we can use the same path for both 2D and 3D fetch + + switch( target ) + { + case GL_TEXTURE_CUBE_MAP: + + // adjust target to steer to the proper face, then fall through to the 2D texture path. + target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc->m_req.m_face; + + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + { + // check compressed or not + if (format->m_chunkSize != 1) + { + // compressed path + // http://www.opengl.org/sdk/docs/man/xhtml/glGetCompressedTexImage.xml + + glGetCompressedTexImage( target, // target + desc->m_req.m_mip, // level + sliceAddress ); // destination + GLMCheckError(); + } + else + { + // uncompressed path + // http://www.opengl.org/sdk/docs/man/xhtml/glGetTexImage.xml + + glGetTexImage( target, // target + desc->m_req.m_mip, // level + format->m_glDataFormat, // dataformat + format->m_glDataType, // datatype + sliceAddress ); // destination + GLMCheckError(); + } + } + break; + } + } + else + { + GLMStop(); + } +} + +// defaulting the subimage support off, since it's breaking Ep2 at startup on some NV 9400 and friends +// defaulting it back to "1" for L4D2 and see if it flies +int gl_enabletexsubimage = 1; +//ConVar gl_enabletexsubimage( "gl_enabletexsubimage", "1" ); + +void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDataWrite ) +{ + GLMRegion writeBox; + + bool needsExpand = false; + char *expandTemp = NULL; + + switch( m_layout->m_format->m_d3dFormat) + { + case D3DFMT_V8U8: + { + needsExpand = true; + writeWholeSlice = true; + + // shoot down client storage if we have to generate a new flavor of the data + m_texClientStorage = false; + } + break; + } + + if (writeWholeSlice) + { + writeBox.xmin = writeBox.ymin = writeBox.zmin = 0; + + writeBox.xmax = m_layout->m_slices[ desc->m_sliceIndex ].m_xSize; + writeBox.ymax = m_layout->m_slices[ desc->m_sliceIndex ].m_ySize; + writeBox.zmax = m_layout->m_slices[ desc->m_sliceIndex ].m_zSize; + } + else + { + writeBox = desc->m_req.m_region; + } + + // first thing is to get the GL texture bound to a TMU, or just select one if already bound + // to get this running we will just always slam TMU 0 and let the draw time code fix it back + // a later optimization would be to hoist the bind call to the caller, do it exactly once + + m_ctx->BindTexToTMU( this, 0, false ); // SelectTMU(n) is a side effect + + GLMTexFormatDesc *format = m_layout->m_format; + + GLenum target = m_layout->m_key.m_texGLTarget; + GLenum glDataFormat = format->m_glDataFormat; // this could change if expansion kicks in + GLenum glDataType = format->m_glDataType; + + GLMTexLayoutSlice *slice = &m_layout->m_slices[ desc->m_sliceIndex ]; + void *sliceAddress = m_backing ? (m_backing + slice->m_storageOffset) : NULL; // this would change for PBO + + // allow use of subimage if the target is texture2D and it has already been teximage'd + bool mayUseSubImage = false; + if ( (target==GL_TEXTURE_2D) && (m_sliceFlags[ desc->m_sliceIndex ] & kSliceValid) ) + { + mayUseSubImage = gl_enabletexsubimage/* .GetInt() */; + } + + // check flavor, 2D, 3D, or cube map + // we also have the choice to use subimage if this is a tex already created. (open question as to benefit) + + + // SRGB select. At this level (writetexels) we firmly obey the m_texFlags. + // (mechanism not policy) + + GLenum intformat = (m_layout->m_key.m_texFlags & kGLMTexSRGB) ? format->m_glIntFormatSRGB : format->m_glIntFormat; + if (0 /* CommandLine()->FindParm("-disable_srgbtex") */) + { + // force non srgb flavor - experiment to make ATI r600 happy on 10.5.8 (maybe x1600 too!) + intformat = format->m_glIntFormat; + } + + Assert( intformat != 0 ); + + if (m_layout->m_key.m_texFlags & kGLMTexSRGB) + { + Assert( m_layout->m_format->m_glDataFormat != GL_DEPTH_COMPONENT ); + Assert( m_layout->m_format->m_glDataFormat != GL_DEPTH_STENCIL_EXT ); + Assert( m_layout->m_format->m_glDataFormat != GL_ALPHA ); + } + + // adjust min and max mip written + if (desc->m_req.m_mip > m_maxActiveMip) + { + m_maxActiveMip = desc->m_req.m_mip; + + glTexParameteri( target, GL_TEXTURE_MAX_LEVEL, desc->m_req.m_mip); + GLMCheckError(); + } + + if (desc->m_req.m_mip < m_minActiveMip) + { + m_minActiveMip = desc->m_req.m_mip; + + glTexParameteri( target, GL_TEXTURE_BASE_LEVEL, desc->m_req.m_mip); + GLMCheckError(); + } + + if (needsExpand) + { + int expandSize = 0; + + switch( m_layout->m_format->m_d3dFormat) + { + case D3DFMT_V8U8: + { + // figure out new size based on 3byte RGB format + // easy, just take the two byte size and grow it by 50% + expandSize = (slice->m_storageSize * 3) / 2; + expandTemp = (char*)malloc( expandSize ); + + char *src = (char*)sliceAddress; + char *dst = expandTemp; + + // transfer RG's to RGB's + while(expandSize>0) + { + *dst = *src++; // move first byte + *dst = *src++; // move second byte + *dst = 0xBB; // pad third byte + + expandSize -= 3; + } + + // move the slice pointer + sliceAddress = expandTemp; + + // change the data format we tell GL about + glDataFormat = GL_RGB; + } + break; + + default: Assert(!"Don't know how to expand that format.."); + } + + } + + // set up the client storage now, one way or another + glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, m_texClientStorage ); + GLMCheckError(); + + switch( target ) + { + case GL_TEXTURE_CUBE_MAP: + + // adjust target to steer to the proper face, then fall through to the 2D texture path. + target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc->m_req.m_face; + + case GL_TEXTURE_2D: + { + // check compressed or not + if (format->m_chunkSize != 1) + { + Assert( writeWholeSlice ); //subimage not implemented in this path yet + + // compressed path + // http://www.opengl.org/sdk/docs/man/xhtml/glCompressedTexImage2D.xml + glCompressedTexImage2D( target, // target + desc->m_req.m_mip, // level + intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above + slice->m_xSize, // width + slice->m_ySize, // height + 0, // border + slice->m_storageSize, // imageSize + sliceAddress ); // data + GLMCheckError(); + + + } + else + { + if (mayUseSubImage) + { + // go subimage2D if it's a replacement, not a creation + + + glPixelStorei( GL_UNPACK_ROW_LENGTH, slice->m_xSize ); // in pixels + glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels + glPixelStorei( GL_UNPACK_SKIP_ROWS, writeBox.ymin ); // in pixels + GLMCheckError(); + + glTexSubImage2D( target, + desc->m_req.m_mip, // level + writeBox.xmin, // xoffset into dest + writeBox.ymin, // yoffset into dest + writeBox.xmax - writeBox.xmin, // width (was slice->m_xSize) + writeBox.ymax - writeBox.ymin, // height (was slice->m_ySize) + glDataFormat, // format + glDataType, // type + sliceAddress // data (will be offsetted by the SKIP_PIXELS and SKIP_ROWS - let GL do the math to find the first source texel) + ); + GLMCheckError(); + + glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); + glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); + glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); + GLMCheckError(); + + /* + //http://www.opengl.org/sdk/docs/man/xhtml/glTexSubImage2D.xml + glTexSubImage2D( target, + desc->m_req.m_mip, // level + 0, // xoffset + 0, // yoffset + slice->m_xSize, // width + slice->m_ySize, // height + glDataFormat, // format + glDataType, // type + sliceAddress // data + ); + GLMCheckError(); + */ + } + else + { + if (m_layout->m_key.m_texFlags & kGLMTexRenderable) + { + if (gl_rt_forcergba/* .GetInt() */) + { + if (glDataFormat == GL_BGRA) + { + // change it + glDataFormat = GL_RGBA; + } + } + } + + // uncompressed path + // http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/teximage2d.html + glTexImage2D( target, // target + desc->m_req.m_mip, // level + intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above + slice->m_xSize, // width + slice->m_ySize, // height + 0, // border + glDataFormat, // dataformat + glDataType, // datatype + noDataWrite ? NULL : sliceAddress ); // data (optionally suppressed in case ResetSRGB desires) + + if (m_layout->m_key.m_texFlags & kGLMTexMultisampled) + { + if (gl_texmsaalog/* .GetInt() */) + { + printf( "\n == MSAA Tex %p %s : glTexImage2D for flat tex using intformat %s (%x)", this, m_debugLabel?m_debugLabel:"", GLMDecode( eGL_ENUM, intformat ), intformat ); + printf( "\n" ); + } + } + + m_sliceFlags[ desc->m_sliceIndex ] |= kSliceValid; // for next time, we can subimage.. + } + } + } + break; + + case GL_TEXTURE_3D: + { + // check compressed or not + if (format->m_chunkSize != 1) + { + // compressed path + // http://www.opengl.org/sdk/docs/man/xhtml/glCompressedTexImage3D.xml + + glCompressedTexImage3D( target, // target + desc->m_req.m_mip, // level + format->m_glIntFormat, // internalformat + slice->m_xSize, // width + slice->m_ySize, // height + slice->m_zSize, // depth + 0, // border + slice->m_storageSize, // imageSize + sliceAddress ); // data + GLMCheckError(); + } + else + { + // uncompressed path + // http://www.opengl.org/sdk/docs/man/xhtml/glTexImage3D.xml + glTexImage3D( target, // target + desc->m_req.m_mip, // level + format->m_glIntFormat, // internalformat + slice->m_xSize, // width + slice->m_ySize, // height + slice->m_zSize, // depth + 0, // border + glDataFormat, // dataformat + glDataType, // datatype + noDataWrite ? NULL : sliceAddress ); // data (optionally suppressed in case ResetSRGB desires) + GLMCheckError(); + } + } + break; + } + + glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE ); + GLMCheckError(); + + if ( expandTemp ) + { + free( expandTemp ); + } +} + + +void CGLMTex::Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut ) +{ + // locate appropriate slice in layout record + int sliceIndex = CalcSliceIndex( params->m_face, params->m_mip ); + + GLMTexLayoutSlice *slice = &m_layout->m_slices[sliceIndex]; + + // obtain offset + int sliceBaseOffset = slice->m_storageOffset; + + // cross check region req against slice bounds - figure out if it matches, exceeds, or is less than the whole slice. + char exceed = (params->m_region.xmin < 0) || (params->m_region.xmax > slice->m_xSize) || + (params->m_region.ymin < 0) || (params->m_region.ymax > slice->m_ySize) || + (params->m_region.zmin < 0) || (params->m_region.zmax > slice->m_zSize); + + char partial = (params->m_region.xmin > 0) || (params->m_region.xmax < slice->m_xSize) || + (params->m_region.ymin > 0) || (params->m_region.ymax < slice->m_ySize) || + (params->m_region.zmin > 0) || (params->m_region.zmax < slice->m_zSize); + + bool copyout = false; // set if a readback of the texture slice from GL is needed + + if (exceed) + { + // illegal rect, out of bounds + GLMStop(); + } + + // on return, these things need to be true + + // a - there needs to be storage allocated, which we will return an address within + // b - the region corresponding to the slice being locked, will have valid data there for the whole slice. + // c - the slice is marked as locked + // d - the params of the lock request have been saved in the lock table (in the context) + + // so step 1 is unambiguous. If there's no backing storage, make some. + if (!m_backing) + { + m_backing = (char *)malloc( m_layout->m_storageTotalSize ); + memset( m_backing, 0, m_layout->m_storageTotalSize ); + + // clear the kSliceStorageValid bit on all slices + for( int i=0; im_sliceCount; i++) + { + m_sliceFlags[i] &= ~kSliceStorageValid; + } + } + + // work on this slice now + + // storage is known to exist at this point, but we need to check if its contents are valid for this slice. + // this is tracked per-slice so we don't hoist all the texels back out of GL across all slices if caller only + // wanted to lock some of them. + + // (i.e. if we just alloced it, it's blank) + // if storage is invalid, but the texture itself is valid, hoist the texels back to the storage and mark it valid. + // if storage is invalid, and texture itself is also invalid, go ahead and mark storage as valid and fully dirty... to force teximage. + + // ???????????? we need to go over this more carefully re "slice valid" (it has been teximaged) vs "storage valid" (it has been copied out). + + unsigned char *sliceFlags = &m_sliceFlags[ sliceIndex ]; + + if (params->m_readback) + { + // caller is letting us know that it wants to readback the real texels. + *sliceFlags |= kSliceStorageValid; + *sliceFlags |= kSliceValid; + *sliceFlags &= ~(kSliceFullyDirty); + copyout = true; + } + else + { + // caller is pushing texels. + if (! (*sliceFlags & kSliceStorageValid) ) + { + // storage is invalid. check texture state + if ( *sliceFlags & kSliceValid ) + { + // kSliceValid set: the texture itself has a valid slice, but we don't have it in our backing copy, so copy it out. + copyout = true; + } + else + { + // kSliceValid not set: the texture does not have a valid slice to copy out - it hasn't been teximage'd yet. + // set the "full dirty" bit to make sure we teximage the whole thing on unlock. + *sliceFlags |= kSliceFullyDirty; + + // assert if they did not ask to lock the full slice size on this go-round + if (partial) + { + // choice here - + // 1 - stop cold, we don't know how to subimage yet. + // 2 - grin and bear it, mark whole slice dirty (ah, we already did... so, do nothing). + // choice 2: // GLMStop(); + } + } + + // one way or another, upon reaching here the slice storage is valid for read. + *sliceFlags |= kSliceStorageValid; + } + } + + + // when we arrive here, there is storage, and the content of the storage for this slice is valid + // (or zeroes if it's the first lock) + + // log the lock request in the context. + GLMTexLockDesc newdesc; + + newdesc.m_req = *params; + newdesc.m_active = true; + newdesc.m_sliceIndex = sliceIndex; + newdesc.m_sliceBaseOffset = m_layout->m_slices[sliceIndex].m_storageOffset; + + // to calculate the additional offset we need to look at the rect's min corner + // combined with the per-texel size and Y/Z stride + // also cross check it for 4x multiple if there is compression in play + + int offsetInSlice = 0; + int yStride = 0; + int zStride = 0; + + CalcTexelDataOffsetAndStrides( sliceIndex, params->m_region.xmin, params->m_region.ymin, params->m_region.zmin, &offsetInSlice, &yStride, &zStride ); + + // for compressed case... + // since there is presently no way to texsubimage a DXT when the rect does not cover the whole width, + // we will probably need to inflate the dirty rect in the recorded lock req so that the entire span is + // pushed across at unlock time. + + newdesc.m_sliceRegionOffset = offsetInSlice + newdesc.m_sliceBaseOffset; + + if (copyout) + { + // read the whole slice + // (odds are we'll never request anything but a whole slice to be read..) + ReadTexels( &newdesc, true ); + } // this would be a good place to fill with scrub value if in debug... + + *addressOut = m_backing + newdesc.m_sliceRegionOffset; + *yStrideOut = yStride; + *zStrideOut = zStride; + + m_ctx->m_texLocks.push_back( newdesc ); + + m_lockCount++; +} + +void CGLMTex::Unlock( GLMTexLockParams *params ) +{ + // look for an active lock request on this face and mip (doesn't necessarily matter which one, if more than one) + // and mark it inactive. + // --> if you can't find one, fail. first line of defense against mismatched locks/unlocks.. + + int i=0; + bool found = false; + while( !found && (im_texLocks.size()) ) + { + GLMTexLockDesc *desc = &m_ctx->m_texLocks[i]; + + // is lock at index 'i' targeted at the texture/face/mip in question? + if ( (desc->m_req.m_tex == this) && (desc->m_req.m_face == params->m_face) & (desc->m_req.m_mip == params->m_mip) && (desc->m_active) ) + { + // matched and active, so retire it + desc->m_active = false; + + // stop searching + found = true; + } + i++; + } + + if (!found) + { + GLMStop(); // bad news + } + + // found - so drop lock count + m_lockCount--; + + if (m_lockCount <0) + { + GLMStop(); // bad news + } + + if (m_lockCount==0) + { + // there should not be any active locks remaining on this texture. + + // motivation to defer all texel pushing til *all* open locks are closed out - + // if/when we back the texture with a PBO, we will need to unmap that PBO before teximaging from it; + // by waiting for all the locks to clear this gives us an unambiguous signal to act on. + + // scan through all the retired locks for this texture and push the texels for each one. + // after each one is dispatched, remove it from the pile. + + int j=0; + while( jm_texLocks.size() ) + { + GLMTexLockDesc *desc = &m_ctx->m_texLocks[j]; + + if ( desc->m_req.m_tex == this ) + { + // if it's active, something is wrong + if (desc->m_active) + { + GLMStop(); + } + + // write the texels + bool fullyDirty = false; + + fullyDirty |= ((m_sliceFlags[ desc->m_sliceIndex ] & kSliceFullyDirty) != 0); + + // this is not optimal and will result in full downloads on any dirty. + // we're papering over the fact that subimage isn't done yet. + // but this is safe if the slice of storage is all valid. + + // at some point we'll need to actually compare the lock box against the slice bounds. + + // fullyDirty |= (m_sliceFlags[ desc->m_sliceIndex ] & kSliceStorageValid); + + WriteTexels( desc, fullyDirty ); + + // logical place to trigger preloading + // only do it for an RT tex, if it is not yet attached to any FBO. + // also, only do it if the slice number is the last slice in the tex. + if ( desc->m_sliceIndex == (m_layout->m_sliceCount-1) ) + { + if ( !(m_layout->m_key.m_texFlags & kGLMTexRenderable) || (m_rtAttachCount==0) ) + { + m_ctx->PreloadTex( this ); + // printf("( slice %d of %d )", desc->m_sliceIndex, m_layout->m_sliceCount ); + } + } + + m_ctx->m_texLocks.erase( m_ctx->m_texLocks.begin() + j ); // remove from the pile, don't advance index + } + else + { + j++; // move on to next one + } + } + + // clear the locked and full-dirty flags for all slices + for( int slice=0; slice < m_layout->m_sliceCount; slice++) + { + m_sliceFlags[slice] &= ~( kSliceLocked | kSliceFullyDirty ); + } + } +} + + +void CGLMTex::ResetSRGB( bool srgb, bool noDataWrite ) +{ + // see if requested SRGB state differs from the known one + bool wasSRGB = (m_layout->m_key.m_texFlags & kGLMTexSRGB); + GLMTexLayout *oldLayout = m_layout; // need to m_ctx->m_texLayoutTable->DelLayoutRef on this one if we flip + + if (srgb != wasSRGB) + { + // we're going to need a new layout (though the storage size should be the same - check it) + GLMTexLayoutKey newKey = m_layout->m_key; + + newKey.m_texFlags &= (~kGLMTexSRGB); // turn off that bit + newKey.m_texFlags |= srgb ? kGLMTexSRGB : 0; // turn on that bit if it should be so + + // get new layout + GLMTexLayout *newLayout = m_ctx->m_texLayoutTable->NewLayoutRef( &newKey ); + + + // if SRGB requested, verify that the layout we just got can do it. + // if it can't, delete the new layout ref and bail. + if (srgb && (newLayout->m_format->m_glIntFormatSRGB == 0)) + { + Assert( !"Can't enable SRGB mode on this format" ); + m_ctx->m_texLayoutTable->DelLayoutRef( newLayout ); + return; + } + + // check sizes and fail if no match + if( newLayout->m_storageTotalSize != oldLayout->m_storageTotalSize ) + { + Assert( !"Bug: layout sizes don't match on SRGB change" ); + m_ctx->m_texLayoutTable->DelLayoutRef( newLayout ); + return; + } + + // commit to new layout + m_layout = newLayout; + + // check same size + Assert( m_layout->m_storageTotalSize == oldLayout->m_storageTotalSize ); + + // release old + m_ctx->m_texLayoutTable->DelLayoutRef( oldLayout ); + oldLayout = NULL; + + // force texel re-DL + + // note this messes with TMU 0 as side effect of WriteTexels + // so we save and restore the TMU 0 binding first + + // since we're likely to be called in dxabstract when it is syncing sampler state, we can't go trampling the bindings. + // a refinement would be to have each texture make a note of which TMU they're bound on, and just use that active TMU for DL instead of 0. + CGLMTex *tmu0save = m_ctx->m_samplers[0].m_drawTex; + + for( int face=0; face m_faceCount; face++) + { + for( int mip=0; mip m_mipCount; mip++) + { + // we're not really going to lock, we're just going to rewrite the orig data + GLMTexLockDesc desc; + + desc.m_req.m_tex = this; + desc.m_req.m_face = face; + desc.m_req.m_mip = mip; + + desc.m_sliceIndex = CalcSliceIndex( face, mip ); + + GLMTexLayoutSlice *slice = &m_layout->m_slices[ desc.m_sliceIndex ]; + + desc.m_req.m_region.xmin = desc.m_req.m_region.ymin = desc.m_req.m_region.zmin = 0; + desc.m_req.m_region.xmax = slice->m_xSize; + desc.m_req.m_region.ymax = slice->m_ySize; + desc.m_req.m_region.zmax = slice->m_zSize; + + desc.m_sliceBaseOffset = slice->m_storageOffset; // doesn't really matter... we're just pushing zeroes.. + desc.m_sliceRegionOffset = 0; + + this->WriteTexels( &desc, true, noDataWrite ); // write whole slice. and avoid pushing real bits if the caller requests (RT's) + } + } + + // put it back + m_ctx->BindTexToTMU( tmu0save, 0, true ); + } +} diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmtex.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmtex.h new file mode 100644 index 0000000..13d7a0e --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/cglmtex.h @@ -0,0 +1,291 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// cglmtex.h +// GLMgr textures +// +//=============================================================================== + +#ifndef CGLMTEX_H +#define CGLMTEX_H + +#pragma once + +#ifdef OSX +#include "glmgrbasics.h" +#endif + +//=============================================================================== + +// forward declarations + +class GLMContext; +class GLMTester; +class CGLMTexLayoutTable; +class CGLMTex; +class CGLMFBO; + +class IDirect3DSurface9; + +//=============================================================================== + +struct GLMTexFormatDesc +{ + const char *m_formatSummary; // for debug visibility + + D3DFORMAT m_d3dFormat; // what D3D knows it as; see public/bitmap/imageformat.h + + GLenum m_glIntFormat; // GL internal format + GLenum m_glIntFormatSRGB; // internal format if SRGB flavor + GLenum m_glDataFormat; // GL data format + GLenum m_glDataType; // GL data type + + int m_chunkSize; // 1 or 4 - 4 is used for compressed textures + int m_bytesPerSquareChunk; // how many bytes for the smallest quantum (m_chunkSize x m_chunkSize) + // this description lets us calculate size cleanly without conditional logic for compression +}; +const GLMTexFormatDesc *GetFormatDesc( D3DFORMAT format ); + +//=============================================================================== + +// utility function for generating slabs of texels. mostly for test. +typedef struct +{ + // in + D3DFORMAT m_format; + void *m_dest; // dest address + int m_chunkCount; // square chunk count (single texels or compressed blocks) + int m_byteCountLimit; // caller expectation of max number of bytes to write out + float r,g,b,a; // color desired + + // out + int m_bytesWritten; +} GLMGenTexelParams; + +// return true if successful +bool GLMGenTexels( GLMGenTexelParams *params ); + + +//=============================================================================== + +struct GLMTexLayoutSlice +{ + int m_xSize,m_ySize,m_zSize; //texel dimensions of this slice + int m_storageOffset; //where in the storage slab does this slice live + int m_storageSize; //how much storage does this slice occupy +}; + +enum EGLMTexFlags +{ + kGLMTexMipped = 0x01, + kGLMTexMippedAuto = 0x02, + kGLMTexRenderable = 0x04, + kGLMTexIsStencil = 0x08, + kGLMTexIsDepth = 0x10, + kGLMTexSRGB = 0x20, + kGLMTexMultisampled = 0x40, // has an RBO backing it. Cannot combine with Mipped, MippedAuto. One slice maximum, only targeting GL_TEXTURE_2D. + // actually not 100% positive on the mipmapping, the RBO itself can't be mipped, but the resulting texture could + // have mipmaps generated. +}; + +//=============================================================================== + +struct GLMTexLayoutKey +{ + // input values: held const, these are the hash key for the form map + GLenum m_texGLTarget; // flavor of texture: GL_TEXTURE_2D, GL_TEXTURE_3D, GLTEXTURE_CUBE_MAP + D3DFORMAT m_texFormat; // D3D texel format + unsigned long m_texFlags; // mipped, autogen mips, render target, ... ? + unsigned long m_texSamples; // zero for a plain tex, 2/4/6/8 for "MSAA tex" (RBO backed) + int m_xSize,m_ySize,m_zSize; // size of base mip +}; + +struct LessThan_GLMTexLayoutKey +{ + bool operator()(const GLMTexLayoutKey &a, const GLMTexLayoutKey &b) const + { + #define DO_LESS(fff) if (a.fff != b.fff) { return (a.fff< b.fff); } + + DO_LESS(m_texGLTarget); + DO_LESS(m_texFormat); + DO_LESS(m_texFlags); + DO_LESS(m_xSize); + DO_LESS(m_ySize) + DO_LESS(m_zSize); + + #undef DO_LESS + + return false; // they are equal + } +}; + +#define GLM_TEX_MAX_MIPS 14 +#define GLM_TEX_MAX_FACES 6 +#define GLM_TEX_MAX_SLICES (GLM_TEX_MAX_MIPS * GLM_TEX_MAX_FACES) + +struct GLMTexLayout +{ + char *m_layoutSummary; // for debug visibility + + // const inputs used for hashing + GLMTexLayoutKey m_key; + + // refcount + int m_refCount; + + // derived values: + GLMTexFormatDesc *m_format; // format specific info + int m_mipCount; // derived by starying at base size and working down towards 1x1 + int m_faceCount; // 1 for 2d/3d, 6 for cubemap + int m_sliceCount; // product of faces and mips + int m_storageTotalSize; // size of storage slab required + + // slice array + GLMTexLayoutSlice m_slices[0]; // dynamically allocated 2-d array [faces][mips] +}; + +typedef std::map< GLMTexLayoutKey, GLMTexLayout*, LessThan_GLMTexLayoutKey > GLMTexLayoutKeyMap; +class CGLMTexLayoutTable +{ +public: + CGLMTexLayoutTable(); + + GLMTexLayout *NewLayoutRef( GLMTexLayoutKey *key ); // pass in a pointer to layout key - receive ptr to completed layout + void DelLayoutRef( GLMTexLayout *layout ); // pass in pointer to completed layout. refcount is dropped. + + void DumpStats( void ); +protected: + GLMTexLayoutKeyMap m_layoutMap; +}; + +//=============================================================================== + +// a sampler specifies desired state for drawing on a given sampler index +// this is the combination of a texture choice and a set of sampler parameters +// see http://msdn.microsoft.com/en-us/library/bb172602(VS.85).aspx + + +struct GLMTexSamplingParams +{ + GLenum m_addressModes[3]; // S, T, R + GLfloat m_borderColor[4]; // R,G,B,A + + GLenum m_magFilter; + GLenum m_minFilter; + + GLfloat m_mipmapBias; + GLint m_minMipLevel; + GLint m_maxMipLevel; + GLint m_maxAniso; + GLenum m_compareMode; // only used for depth and stencil type textures + bool m_srgb; // srgb texture read... +}; + +struct GLMTexLockParams +{ + // input params which identify the slice of interest + CGLMTex *m_tex; + int m_face; + int m_mip; + + // identifies the region of the slice + GLMRegion m_region; + + // tells GLM to force re-read of the texels back from GL + // i.e. "I know I stepped on those texels with a draw or blit - the GLM copy is stale" + bool m_readback; +}; + +struct GLMTexLockDesc +{ + GLMTexLockParams m_req; // form of the lock request + + bool m_active; // set true at lock time. cleared at unlock time. + + int m_sliceIndex; // which slice in the layout + int m_sliceBaseOffset; // where is that in the texture data + int m_sliceRegionOffset; // offset to the start (lowest address corner) of the region requested +}; + +//=============================================================================== + +#define GLM_SAMPLER_COUNT 16 + +typedef unsigned short CTexBindMask; // 16 bits, who needs bitvec... + +enum EGLMTexSliceFlag +{ + kSliceValid = 0x01, // slice has been teximage'd in whole at least once - set to 0 initially + kSliceStorageValid = 0x02, // if backing store is available, this slice's data is a valid copy - set to 0 initially + kSliceLocked = 0x04, // are one or more locks outstanding on this slice + kSliceFullyDirty = 0x08, // does the slice need to be fully downloaded at unlock time (disregard dirty rects) +}; + +class CGLMTex +{ + +public: + + void Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut ); + void Unlock( GLMTexLockParams *params ); + +protected: + friend class GLMContext; // only GLMContext can make CGLMTex objects + friend class GLMTester; + friend class CGLMFBO; + + friend class IDirect3DDevice9; + friend class IDirect3DBaseTexture9; + friend class IDirect3DTexture9; + friend class IDirect3DSurface9; + friend class IDirect3DCubeTexture9; + friend class IDirect3DVolumeTexture9; + + CGLMTex( GLMContext *ctx, GLMTexLayout *layout, GLMTexSamplingParams *sampling, const char *debugLabel = NULL ); + ~CGLMTex( ); + + int CalcSliceIndex( int face, int mip ); + void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut ); + + void ApplySamplingParams( GLMTexSamplingParams *params, bool noCheck=FALSE ); + + void ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true ); + void WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice=true, bool noDataWrite=false ); + // last param lets us send NULL data ptr (only legal with uncompressed formats, beware) + // this helps out ResetSRGB. + + void ResetSRGB( bool srgb, bool noDataWrite ); + // re-specify texture format to match desired sRGB form + // noWrite means send NULL for texel source addresses instead of actual data - ideal for RT's + + GLMTexLayout *m_layout; // layout of texture (shared across all tex with same layout) + int m_minActiveMip;//index of lowest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. + int m_maxActiveMip;//index of highest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL. + + GLMTexSamplingParams m_sampling; // mirror of sampling params currently embodied in the texture + // (consult this at draw time, in order to know if changes need to be made) + + GLMContext *m_ctx; // link back to parent context + + GLuint m_texName; // name of this texture in the context + bool m_texClientStorage; // was CS selecetd for texture + bool m_texPreloaded; // has it been kicked into VRAM with GLMContext::PreloadTex yet + + GLuint m_rboName; // name of MSAA RBO backing the tex if MSAA enabled (or zero) + bool m_rboDirty; // has RBO been drawn on - i.e. needs to be blitted back to texture if texture is going to be sampled from + + CTexBindMask m_bindPoints; // true for each place in the parent ctx where currently + // bound (indexed via EGLMTexCtxBindingIndex) + + int m_rtAttachCount; // how many RT's have this texture attached somewhere + + char *m_backing; // backing storage if available + + int m_lockCount; // lock reqs are stored in the GLMContext for tracking + + std::vector m_sliceFlags; + + char *m_debugLabel; // strdup() of debugLabel passed in, or NULL +}; + + +#endif \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/dx9asmtogl2.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/dx9asmtogl2.cpp new file mode 100644 index 0000000..95366e8 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/dx9asmtogl2.cpp @@ -0,0 +1,3515 @@ +//------------------------------------------------------------------------------ +// DX9AsmToGL2.cpp +//------------------------------------------------------------------------------ + +#include "dxabstract.h" +#include "DX9AsmToGL2.h" + + +void Error( const char *fmt, ... ) +{ +} + +#define DST_REGISTER 0 +#define SRC_REGISTER 1 + +// Tracking and naming sampler dimensions +#define SAMPLER_TYPE_2D 0 +#define SAMPLER_TYPE_CUBE 1 +#define SAMPLER_TYPE_3D 2 +#define SAMPLER_TYPE_UNUSED 3 + +// Flags to PrintUsageAndIndexToString. +#define SEMANTIC_OUTPUT 0x01 +#define SEMANTIC_INPUT 0x02 + +#define UNDECLARED_OUTPUT 0xFFFFFFFF + +#ifndef POSIX +#define Debugger() Assert(0) +#endif + +static const char *g_szVecZeros[] = { NULL, "0.0", "vec2( 0.0, 0.0 )", "vec3( 0.0, 0.0, 0.0 )", "vec4( 0.0, 0.0, 0.0, 0.0 )" }; +static const char *g_szVecOnes[] = { NULL, "1.0", "vec2( 1.0, 1.0 )", "vec3( 1.0, 1.0, 1.0 )", "vec4( 1.0, 1.0, 1.0, 1.0 )" }; +static const char *g_szDefaultSwizzle = "xyzw"; +static const char *g_szDefaultSwizzleStrings[] = { "x", "y", "z", "w" }; +static const char *g_szSamplerStrings[] = { "2D", "CUBE", "3D" }; + +static const char *g_pAtomicTempVarName = "atomic_temp_var"; +static const char *g_pTangentAttributeName = "g_tangent"; + +int __cdecl SortInts( const int *a, const int *b ) +{ + if ( *a < *b ) + return -1; + else if ( *a > *b ) + return 1; + else + return 0; +} + +void StripExtraTrailingZeros( char *pStr ) +{ + int len = (int)V_strlen( pStr ); + while ( len >= 2 && pStr[len-1] == '0' && pStr[len-2] != '.' ) + { + pStr[len-1] = 0; + --len; + } +} + +void PrintToBuf( CUtlBuffer &buf, const char *pFormat, ... ) +{ + va_list marker; + va_start( marker, pFormat ); + + char szTemp[1024]; + V_vsnprintf( szTemp, sizeof( szTemp ), pFormat, marker ); + va_end( marker ); + + strcat_s( (char*)buf.Base(), buf.Size(), szTemp ); +} + +void PrintToBuf( char *pOut, int nOutSize, const char *pFormat, ... ) +{ + int nStrlen = V_strlen( pOut ); + pOut += nStrlen; + nOutSize -= nStrlen; + + va_list marker; + va_start( marker, pFormat ); + V_vsnprintf( pOut, nOutSize, pFormat, marker ); + va_end( marker ); +} + +// Return the number of letters following the dot. +// Returns 4 if there is no dot. +// (So "r0.xy" returns 2 and "r0" returns 4). +int GetNumWriteMaskEntries( const char *pParam ) +{ + const char *pDot = strchr( pParam, '.' ); + if ( pDot ) + return V_strlen( pDot + 1 ); + else + return 4; +} + +const char* GetSwizzleDot( const char *pParam ) +{ + const char *pDot = strrchr( pParam, '.' ); + + // The test against ')' here is for stuff like vec4( gl_Normal, 0.0 ) - we want to treat that as a whole param name. + if ( pDot && strrchr( pParam, ')' ) < pDot && strrchr( pParam, ']' ) < pDot ) + return pDot; + else + return NULL; +} + +int GetNumSwizzleComponents( const char *pParam ) +{ + // Special scalar output which won't accept a swizzle + if ( !V_stricmp( pParam, "gl_FogFragCoord" ) ) + return 1; + + // Special scalar output which won't accept a swizzle + if ( !V_stricmp( pParam, "gl_FragDepth" ) ) + return 1; + + // Special scalar output which won't accept a swizzle + if ( !V_stricmp( pParam, "a0" ) ) + return 1; + + const char *pDot = GetSwizzleDot( pParam ); + if ( pDot ) + return V_strlen( pDot + 1 ); + else + return 0; +} + +char GetSwizzleComponent( const char *pParam, int n ) +{ + Assert( n < 4 ); + + const char *pDot = GetSwizzleDot( pParam ); + if ( pDot ) + { + ++pDot; + int nComponents = (int)V_strlen( pDot ); + Assert( nComponents > 0 ); + + if ( n < nComponents ) + return pDot[n]; + else + return pDot[nComponents-1]; + } + + return g_szDefaultSwizzle[n]; +} + +// Replace the parameter name and leave the swizzle intact. +// So "somevar.xyz" becomes "othervar.xyz". +void ReplaceParamName( const char *pSrc, const char *pNewParamName, char *pOut, int nOutLen ) +{ + // Start with the new parameter name. + V_strncpy( pOut, pNewParamName, nOutLen ); + + // Now add the swizzle if necessary. + const char *pDot = GetSwizzleDot( pSrc ); + if ( pDot ) + { + strncat( pOut, pDot, nOutLen - strlen( pOut ) - 1 ); + } +} + +void GetParamNameWithoutSwizzle( const char *pParam, char *pOut, int nOutLen ) +{ + const char *pDot = GetSwizzleDot( pParam ); + + // The test against ')' here is for stuff like vec4( gl_Normal, 0.0 ) - we want to treat that as a whole param name. + if ( pDot ) + { + int nToCopy = std::min( nOutLen-1, pDot - pParam ); + memcpy( pOut, pParam, nToCopy ); + pOut[nToCopy] = 0; + } + else + { + V_strncpy( pOut, pParam, nOutLen ); + } +} + +bool DoParamNamesMatch( const char *pParam1, const char *pParam2 ) +{ + char szTemp[2][256]; + GetParamNameWithoutSwizzle( pParam1, szTemp[0], sizeof( szTemp[0] ) ); + GetParamNameWithoutSwizzle( pParam2, szTemp[1], sizeof( szTemp[1] ) ); + return ( V_stricmp( szTemp[0], szTemp[1] ) == 0 ); +} + + + +// Extract the n'th component of the swizzle mask. +// If n would exceed the length of the swizzle mask, then it looks up into "xyzw". +void WriteParamWithSingleMaskEntry( const char *pParam, int n, char *pOut, int nOutLen ) +{ + GetParamNameWithoutSwizzle( pParam, pOut, nOutLen ); + PrintToBuf( pOut, nOutLen, "." ); + PrintToBuf( pOut, nOutLen, "%c", GetSwizzleComponent( pParam, n ) ); +} + + +float uint32ToFloat( uint32 dw ) +{ + return *((float*)&dw); +} + +CUtlString EnsureNumSwizzleComponents( const char *pStr, int nComponents ) +{ + int nExisting = GetNumSwizzleComponents( pStr ); + if ( nExisting == nComponents ) + return pStr; + + char szReg[256]; + GetParamNameWithoutSwizzle( pStr, szReg, sizeof( szReg ) ); + if ( nComponents == 0 ) + return szReg; + + PrintToBuf( szReg, sizeof( szReg ), "." ); + if ( nExisting > nComponents ) + { + // DX ASM will sometimes have statements like "NRM r0.xyz, r1.yzww", where it just doesn't use the last part of r1. So we won't either. + for ( int i=0; i < nComponents; i++ ) + { + PrintToBuf( szReg, sizeof( szReg ), "%c", GetSwizzleComponent( pStr, i ) ); + } + } + else + { + if ( nExisting == 0 ) + { + // We've got something like r0 and need N more components, so add as much of "xyzw" is needed. + for ( int i=0; i < nComponents; i++ ) + PrintToBuf( szReg, sizeof( szReg ), "%c", g_szDefaultSwizzle[i] ); + } + else + { + // We've got something like r0.x and need N more components, so replicate the X so it looks like r0.xxx + V_strncpy( szReg, pStr, sizeof( szReg ) ); + char cLast = pStr[ V_strlen( pStr ) - 1 ]; + for ( int i=nExisting; i < nComponents; i++ ) + { + PrintToBuf( szReg, sizeof( szReg ), "%c", cLast ); + } + } + } + + return szReg; +} + +D3DToGL::D3DToGL() +{ +} + +uint32 D3DToGL::GetNextToken( void ) +{ + uint32 dwToken = *m_pdwNextToken; + m_pdwNextToken++; + return dwToken; +} + +void D3DToGL::SkipTokens( uint32 numToSkip ) +{ + m_pdwNextToken += numToSkip; +} + +uint32 D3DToGL::Opcode( uint32 dwToken ) +{ + return ( dwToken & D3DSI_OPCODE_MASK ); +} + +uint32 D3DToGL::OpcodeSpecificData (uint32 dwToken) +{ + return ( ( dwToken & D3DSP_OPCODESPECIFICCONTROL_MASK ) >> D3DSP_OPCODESPECIFICCONTROL_SHIFT ); +} + +uint32 D3DToGL::TextureType ( uint32 dwToken ) +{ + return ( dwToken & D3DSP_TEXTURETYPE_MASK ); // Note this one doesn't shift due to weird D3DSAMPLER_TEXTURE_TYPE enum +} + + + +// Print GLSL intrinsic corresponding to particular instruction +bool D3DToGL::OpenIntrinsic( uint32 inst, char* buff, int nBufLen, uint32 destDimension, uint32 nArgumentDimension ) +{ + // Some GLSL intrinsics need type conversion, which we do in this routine + // As a result, the caller must sometimes close both parentheses, not just one + bool bDoubleClose = false; + + if ( nArgumentDimension == 0 ) + { + nArgumentDimension = 4; + } + + switch ( inst ) + { + case D3DSIO_RSQ: + V_snprintf( buff, nBufLen, "inversesqrt( " ); + break; + case D3DSIO_DP3: + case D3DSIO_DP4: + if ( destDimension == 1 ) + { + V_snprintf( buff, nBufLen, "dot( " ); + } + else + { + V_snprintf( buff, nBufLen, "vec%d( dot( ", destDimension ); + bDoubleClose = true; + } + break; + case D3DSIO_MIN: + V_snprintf( buff, nBufLen, "min( " ); + break; + case D3DSIO_MAX: + V_snprintf( buff, nBufLen, "max( " ); + break; + case D3DSIO_SLT: + if ( nArgumentDimension == 1 ) + { + V_snprintf( buff, nBufLen, "float( " ); // lessThan doesn't have a scalar version + } + else + { + V_snprintf( buff, nBufLen, "vec%d( lessThan( ", nArgumentDimension ); + bDoubleClose = true; + } + break; + case D3DSIO_SGE: + if ( nArgumentDimension == 1 ) + { + V_snprintf( buff, nBufLen, "float( " ); // greaterThanEqual doesn't have a scalar version + } + else + { + V_snprintf( buff, nBufLen, "vec%d( greaterThanEqual( ", nArgumentDimension ); + bDoubleClose = true; + } + break; + case D3DSIO_EXP: + V_snprintf( buff, nBufLen, "exp( " ); // exp2 ? + break; + case D3DSIO_LOG: + V_snprintf( buff, nBufLen, "log( " ); // log2 ? + break; + case D3DSIO_LIT: + Assert(0); + V_snprintf( buff, nBufLen, "lit( " ); // gonna have to write this one + break; + case D3DSIO_DST: + Assert(0); + V_snprintf( buff, nBufLen, "dst( " ); // gonna have to write this one + break; + case D3DSIO_LRP: + Assert( !m_bVertexShader ); + V_snprintf( buff, nBufLen, "mix( " ); + break; + case D3DSIO_FRC: + V_snprintf( buff, nBufLen, "fract( " ); + break; + case D3DSIO_M4x4: + Assert(0); + V_snprintf( buff, nBufLen, "m4x4" ); + break; + case D3DSIO_M4x3: + case D3DSIO_M3x4: + case D3DSIO_M3x3: + case D3DSIO_M3x2: + case D3DSIO_CALL: + case D3DSIO_CALLNZ: + case D3DSIO_LOOP: + case D3DSIO_RET: + case D3DSIO_ENDLOOP: + case D3DSIO_LABEL: + case D3DSIO_DCL: + Assert(0); + break; + case D3DSIO_POW: + V_snprintf( buff, nBufLen, "pow( " ); + break; + case D3DSIO_CRS: + V_snprintf( buff, nBufLen, "cross( " ); + break; + case D3DSIO_SGN: + Assert(0); + V_snprintf( buff, nBufLen, "sign( " ); + break; + case D3DSIO_ABS: + V_snprintf( buff, nBufLen, "abs( " ); + break; + case D3DSIO_NRM: + Assert( 0 ); + V_snprintf( buff, nBufLen, "normalize( " ); + break; + case D3DSIO_SINCOS: + Assert( 0 ); + V_snprintf( buff, nBufLen, "sincos( " ); // gonna have to write this one + break; + case D3DSIO_REP: + case D3DSIO_ENDREP: + case D3DSIO_IF: + case D3DSIO_IFC: + case D3DSIO_ELSE: + case D3DSIO_ENDIF: + case D3DSIO_BREAK: + case D3DSIO_BREAKC: // TODO: these are the reason we even need GLSL...gotta make these work + Assert(0); + break; + case D3DSIO_DEFB: + case D3DSIO_DEFI: + Assert(0); + break; + case D3DSIO_TEXCOORD: + V_snprintf( buff, nBufLen, "texcoord" ); + break; + case D3DSIO_TEXKILL: + V_snprintf( buff, nBufLen, "kill( " ); // wrap the discard instruction? + break; + case D3DSIO_TEX: + Assert(0); + V_snprintf( buff, nBufLen, "TEX" ); // We shouldn't get here + break; + case D3DSIO_TEXBEM: + case D3DSIO_TEXBEML: + case D3DSIO_TEXREG2AR: + case D3DSIO_TEXREG2GB: + case D3DSIO_TEXM3x2PAD: + case D3DSIO_TEXM3x2TEX: + case D3DSIO_TEXM3x3PAD: + case D3DSIO_TEXM3x3TEX: + case D3DSIO_TEXM3x3SPEC: + case D3DSIO_TEXM3x3VSPEC: + Assert(0); + break; + case D3DSIO_EXPP: + V_snprintf( buff, nBufLen, "exp( " ); + break; + case D3DSIO_LOGP: + V_snprintf( buff, nBufLen, "log( " ); + break; + case D3DSIO_CND: + Assert(0); + break; + case D3DSIO_DEF: + Assert(0); + V_snprintf( buff, nBufLen, "DEF" ); + break; + case D3DSIO_TEXREG2RGB: + case D3DSIO_TEXDP3TEX: + case D3DSIO_TEXM3x2DEPTH: + case D3DSIO_TEXDP3: + case D3DSIO_TEXM3x3: + Assert(0); + break; + case D3DSIO_TEXDEPTH: + V_snprintf( buff, nBufLen, "texdepth" ); + break; + case D3DSIO_CMP: + Assert(0); + Assert( !m_bVertexShader ); + V_snprintf( buff, nBufLen, "CMP" ); + break; + case D3DSIO_BEM: + Assert(0); + break; + case D3DSIO_DP2ADD: + Assert(0); + break; + case D3DSIO_DSX: + case D3DSIO_DSY: + Assert(0); + break; + case D3DSIO_TEXLDD: + V_snprintf( buff, nBufLen, "texldd" ); + break; + case D3DSIO_SETP: + Assert(0); + break; + case D3DSIO_TEXLDL: + V_snprintf( buff, nBufLen, "texldl" ); + break; + case D3DSIO_BREAKP: + case D3DSIO_PHASE: + Assert(0); + break; + } + + return bDoubleClose; +} + + +const char* D3DToGL::GetGLSLOperatorString( uint32 inst ) +{ + if ( inst == D3DSIO_ADD ) + return "+"; + else if ( inst == D3DSIO_SUB ) + return "-"; + else if ( inst == D3DSIO_MUL ) + return "*"; + + Error( "GetGLSLOperatorString: unknown operator" ); + return "zzzz"; +} + + +// Print ASM opcode +void D3DToGL::PrintOpcode( uint32 inst, char* buff, int nBufLen ) +{ + switch ( inst ) + { + case D3DSIO_NOP: + V_snprintf( buff, nBufLen, "NOP" ); + Assert(0); + break; + case D3DSIO_MOV: + V_snprintf( buff, nBufLen, "MOV" ); + break; + case D3DSIO_ADD: + V_snprintf( buff, nBufLen, "ADD" ); + break; + case D3DSIO_SUB: + V_snprintf( buff, nBufLen, "SUB" ); + break; + case D3DSIO_MAD: + V_snprintf( buff, nBufLen, "MAD" ); + break; + case D3DSIO_MUL: + V_snprintf( buff, nBufLen, "MUL" ); + break; + case D3DSIO_RCP: + V_snprintf( buff, nBufLen, "RCP" ); + break; + case D3DSIO_RSQ: + V_snprintf( buff, nBufLen, "RSQ" ); + break; + case D3DSIO_DP3: + V_snprintf( buff, nBufLen, "DP3" ); + break; + case D3DSIO_DP4: + V_snprintf( buff, nBufLen, "DP4" ); + break; + case D3DSIO_MIN: + V_snprintf( buff, nBufLen, "MIN" ); + break; + case D3DSIO_MAX: + V_snprintf( buff, nBufLen, "MAX" ); + break; + case D3DSIO_SLT: + V_snprintf( buff, nBufLen, "SLT" ); + break; + case D3DSIO_SGE: + V_snprintf( buff, nBufLen, "SGE" ); + break; + case D3DSIO_EXP: + V_snprintf( buff, nBufLen, "EX2" ); + break; + case D3DSIO_LOG: + V_snprintf( buff, nBufLen, "LG2" ); + break; + case D3DSIO_LIT: + V_snprintf( buff, nBufLen, "LIT" ); + break; + case D3DSIO_DST: + V_snprintf( buff, nBufLen, "DST" ); + break; + case D3DSIO_LRP: + Assert( !m_bVertexShader ); + V_snprintf( buff, nBufLen, "LRP" ); + break; + case D3DSIO_FRC: + V_snprintf( buff, nBufLen, "FRC" ); + break; + case D3DSIO_M4x4: + V_snprintf( buff, nBufLen, "m4x4" ); + break; + case D3DSIO_M4x3: + case D3DSIO_M3x4: + case D3DSIO_M3x3: + case D3DSIO_M3x2: + case D3DSIO_CALL: + case D3DSIO_CALLNZ: + case D3DSIO_LOOP: + case D3DSIO_RET: + case D3DSIO_ENDLOOP: + case D3DSIO_LABEL: + Assert(0); + break; + case D3DSIO_DCL: + V_snprintf( buff, nBufLen, "DCL" ); + break; + case D3DSIO_POW: + V_snprintf( buff, nBufLen, "POW" ); + break; + case D3DSIO_CRS: + V_snprintf( buff, nBufLen, "XPD" ); + break; + case D3DSIO_SGN: + Assert(0); + V_snprintf( buff, nBufLen, "SGN" ); + break; + case D3DSIO_ABS: + V_snprintf( buff, nBufLen, "ABS" ); + break; + case D3DSIO_NRM: + Assert( 0 ); + V_snprintf( buff, nBufLen, "NRM" ); + break; + case D3DSIO_SINCOS: + Assert( !m_bVertexShader ); + V_snprintf( buff, nBufLen, "SCS" ); + break; + case D3DSIO_REP: + case D3DSIO_ENDREP: + case D3DSIO_IF: + case D3DSIO_IFC: + case D3DSIO_ELSE: + case D3DSIO_ENDIF: + case D3DSIO_BREAK: + case D3DSIO_BREAKC: + Assert(0); + break; + case D3DSIO_MOVA: + Assert( m_bVertexShader ); + V_snprintf( buff, nBufLen, "MOV" ); // We're always moving into a temp instead, so this is MOV instead of ARL + break; + case D3DSIO_DEFB: + case D3DSIO_DEFI: + Assert(0); + break; + case D3DSIO_TEXCOORD: + V_snprintf( buff, nBufLen, "texcoord" ); + break; + case D3DSIO_TEXKILL: + V_snprintf( buff, nBufLen, "KIL" ); + break; + case D3DSIO_TEX: + V_snprintf( buff, nBufLen, "TEX" ); + break; + case D3DSIO_TEXBEM: + case D3DSIO_TEXBEML: + case D3DSIO_TEXREG2AR: + case D3DSIO_TEXREG2GB: + case D3DSIO_TEXM3x2PAD: + case D3DSIO_TEXM3x2TEX: + case D3DSIO_TEXM3x3PAD: + case D3DSIO_TEXM3x3TEX: + case D3DSIO_TEXM3x3SPEC: + case D3DSIO_TEXM3x3VSPEC: + Assert(0); + break; + case D3DSIO_EXPP: + V_snprintf( buff, nBufLen, "EXP" ); + break; + case D3DSIO_LOGP: + V_snprintf( buff, nBufLen, "LOG" ); + break; + case D3DSIO_CND: + Assert(0); + break; + case D3DSIO_DEF: + V_snprintf( buff, nBufLen, "DEF" ); + break; + case D3DSIO_TEXREG2RGB: + case D3DSIO_TEXDP3TEX: + case D3DSIO_TEXM3x2DEPTH: + case D3DSIO_TEXDP3: + case D3DSIO_TEXM3x3: + Assert(0); + break; + case D3DSIO_TEXDEPTH: + V_snprintf( buff, nBufLen, "texdepth" ); + break; + case D3DSIO_CMP: + Assert( !m_bVertexShader ); + V_snprintf( buff, nBufLen, "CMP" ); + break; + case D3DSIO_BEM: + Assert(0); + break; + case D3DSIO_DP2ADD: + Assert(0); + break; + case D3DSIO_DSX: + case D3DSIO_DSY: + Assert(0); + break; + case D3DSIO_TEXLDD: + V_snprintf( buff, nBufLen, "texldd" ); + break; + case D3DSIO_SETP: + Assert(0); + break; + case D3DSIO_TEXLDL: + V_snprintf( buff, nBufLen, "texldl" ); + break; + case D3DSIO_BREAKP: + case D3DSIO_PHASE: + Assert(0); + break; + } +} + +CUtlString D3DToGL::GetUsageAndIndexString( uint32 dwToken, int fSemanticFlags ) +{ + char szTemp[1024]; + PrintUsageAndIndexToString( dwToken, szTemp, sizeof( szTemp ), fSemanticFlags ); + return szTemp; +} + +//------------------------------------------------------------------------------ +// Helper function which prints ASCII representation of usage-usageindex pair to string +// +// Strictly used by vertex shaders +// not used any more now that we have attribmap metadata +//------------------------------------------------------------------------------ +void D3DToGL::PrintUsageAndIndexToString( uint32 dwToken, char* strUsageUsageIndexName, int nBufLen, int fSemanticFlags ) +{ + uint32 dwUsage = ( dwToken & D3DSP_DCL_USAGE_MASK ); + uint32 dwUsageIndex = ( dwToken & D3DSP_DCL_USAGEINDEX_MASK ) >> D3DSP_DCL_USAGEINDEX_SHIFT; + + switch ( dwUsage ) + { + case D3DDECLUSAGE_POSITION: + if ( m_bGLSL ) + { + if ( m_bVertexShader ) + { + if ( fSemanticFlags & SEMANTIC_OUTPUT ) + V_snprintf( strUsageUsageIndexName, nBufLen, "vTempPos" ); // effectively gl_Position + else + V_snprintf( strUsageUsageIndexName, nBufLen, "gl_Vertex" ); + } + else + { + // .xy = position in viewport coordinates + // .z = depth + V_snprintf( strUsageUsageIndexName, nBufLen, "gl_FragCoord" ); + } + } + else + { + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[0]" ); //"vertex.position" ); // aka generic [0] + } + break; + case D3DDECLUSAGE_BLENDWEIGHT: + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[1]" ); // "vertex.attrib[12]" ); // or [1] + break; + case D3DDECLUSAGE_BLENDINDICES: + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[13]" ); // "vertex.attrib[13]" ); // or [ 7 ] + break; + case D3DDECLUSAGE_NORMAL: + V_snprintf( strUsageUsageIndexName, nBufLen, m_bGLSL ? "vec4( gl_Normal, 0.0 )" : "vertex.attrib[2]" ); + break; + case D3DDECLUSAGE_PSIZE: + Assert(0); + V_snprintf( strUsageUsageIndexName, nBufLen, "_psize" ); // no analog + break; + case D3DDECLUSAGE_TEXCOORD: + if ( m_bGLSL ) + { + // GLSL vs output and ps inputs reference gl_TexCoord[n], not gl_MultiTexCoord. + if ( !m_bVertexShader || (fSemanticFlags & SEMANTIC_OUTPUT) ) + V_snprintf( strUsageUsageIndexName, nBufLen, "gl_TexCoord[%d]", dwUsageIndex ); + else + V_snprintf( strUsageUsageIndexName, nBufLen, "gl_MultiTexCoord%d", dwUsageIndex ); + } + else + { + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[%d]", 8+dwUsageIndex ); // "vertex.texcoord[%d]", dwUsageIndex ); // aka [8] - [15] ? + } + break; + case D3DDECLUSAGE_TANGENT: + if ( m_bGLSL ) + { + NoteTangentInputUsed(); + V_strncpy( strUsageUsageIndexName, g_pTangentAttributeName, nBufLen ); + } + else + { + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[15]" ); // aka texc[7] + } + break; + case D3DDECLUSAGE_BINORMAL: + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[14]" ); // aka texc[6] + break; +// case D3DDECLUSAGE_TESSFACTOR: +// Assert(0); +// V_snprintf( strUsageUsageIndexName, nBufLen, "_position" ); // no analog +// break; +// case D3DDECLUSAGE_POSITIONT: +// Assert(0); +// V_snprintf( strUsageUsageIndexName, nBufLen, "_positiont" ); // no analog +// break; + case D3DDECLUSAGE_COLOR: + if ( m_bGLSL ) + { +// if ( fSemanticFlags & SEMANTIC_OUTPUT ) +// V_snprintf( strUsageUsageIndexName, nBufLen, dwUsageIndex != 0 ? "gl_BackColor" : "gl_FrontColor" ); +// else + V_snprintf( strUsageUsageIndexName, nBufLen, dwUsageIndex != 0 ? "gl_SecondaryColor" : "gl_Color" ); + } + else + { + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[%d]", 3+dwUsageIndex ); //dwUsageIndex ); // != 0 ? "vertex.color.secondary" : "vertex.color" ); // aka [3] / [4] (second) + } + break; + case D3DDECLUSAGE_FOG: + Assert( !m_bGLSL ); + V_snprintf( strUsageUsageIndexName, nBufLen, "vertex.attrib[5]" ); //"vertex.position" /* "_fog" */ ); //FIXME, evil // aka [5] / vertex.fogcoord + break; + case D3DDECLUSAGE_DEPTH: + Assert(0); + V_snprintf( strUsageUsageIndexName, nBufLen, "_depth" ); // no analog + break; + case D3DDECLUSAGE_SAMPLE: + Assert(0); + V_snprintf( strUsageUsageIndexName, nBufLen, "_sample" ); // no analog + break; + default: + Debugger(); + break; + } +} + +uint32 D3DToGL::GetRegType( uint32 dwRegToken ) +{ + return ( ( dwRegToken & D3DSP_REGTYPE_MASK2 ) >> D3DSP_REGTYPE_SHIFT2 ) | ( ( dwRegToken & D3DSP_REGTYPE_MASK ) >> D3DSP_REGTYPE_SHIFT ); +} + +void D3DToGL::PrintIndentation( char *pBuf, int nBufLen ) +{ + for( int i=0; i 5 && V_strcmp( &pRegister[nLen-5], ".xyzw" ) == 0 ) + pRegister[nLen-5] = 0; +} + + +// This returns 0 for x, 1 for y, 2 for z, and 3 for w. +int GetSwizzleComponentVectorIndex( char chMask ) +{ + if ( chMask == 'x' ) + return 0; + else if ( chMask == 'y' ) + return 1; + else if ( chMask == 'z' ) + return 2; + else if ( chMask == 'w' ) + return 3; + + Error( "GetSwizzleComponentVectorIndex( '%c' ) - invalid parameter.\n", chMask ); + return 0; +} + + +// GLSL needs the # of src masks to match the dest write mask. +// +// So this: +// r0.xy = r1 + r2; +// becomes: +// r0.xy = r1.xy + r2.xy; +// +// +// Also, and this is the trickier one: GLSL reads the source registers from their first component on +// whereas D3D reads them as referenced in the dest register mask! +// +// So this code in D3D: +// r0.yz = c0.x + c1.wxyz +// Really means: +// r0.y = c0.x + c1.x +// r0.z = c0.x + c1.y +// So we translate it to this in GLSL: +// r0.yz = c0.xx + c1.wx +// r0.yz = c0.xx + c1.xy +// +CUtlString D3DToGL::FixGLSLSwizzle( const char *pDestRegisterName, const char *pSrcRegisterName ) +{ + if ( !m_bGLSL ) + return pSrcRegisterName; + + int nSwizzlesInDest = GetNumSwizzleComponents( pDestRegisterName ); + if ( nSwizzlesInDest == 0 ) + nSwizzlesInDest = 4; + + char szFixedSrcRegister[128]; + GetParamNameWithoutSwizzle( pSrcRegisterName, szFixedSrcRegister, sizeof( szFixedSrcRegister ) ); + strncat( szFixedSrcRegister, ".", sizeof(szFixedSrcRegister) - strlen(szFixedSrcRegister) - 1 ); + for ( int i=0; i < nSwizzlesInDest; i++ ) + { + char chDestWriteMask = GetSwizzleComponent( pDestRegisterName, i ); + int nVectorIndex = GetSwizzleComponentVectorIndex( chDestWriteMask ); + + char ch[2]; + ch[0] = GetSwizzleComponent( pSrcRegisterName, nVectorIndex ); + ch[1] = 0; + strncat( szFixedSrcRegister, ch, sizeof(szFixedSrcRegister) - strlen(szFixedSrcRegister) - 1 ); + } + + SimplifyFourParamRegister( szFixedSrcRegister ); + return szFixedSrcRegister; +} + +// Weird encoding...bits are split apart in the dwToken +inline uint32 GetRegTypeFromToken( uint32 dwToken ) +{ + return ( ( dwToken & D3DSP_REGTYPE_MASK2 ) >> D3DSP_REGTYPE_SHIFT2 ) | ( ( dwToken & D3DSP_REGTYPE_MASK ) >> D3DSP_REGTYPE_SHIFT ); +} + +void D3DToGL::FlagIndirectRegister( uint32 dwToken, int *pARLDestReg ) +{ + if ( !pARLDestReg ) + return; + + switch ( dwToken & D3DVS_SWIZZLE_MASK & D3DVS_X_W ) + { + case D3DVS_X_X: + *pARLDestReg = ARL_DEST_X; + break; + case D3DVS_X_Y: + *pARLDestReg = ARL_DEST_Y; + break; + case D3DVS_X_Z: + *pARLDestReg = ARL_DEST_Z; + break; + case D3DVS_X_W: + *pARLDestReg = ARL_DEST_W; + break; + } +} + + +//------------------------------------------------------------------------------ +// PrintParameterToString() +// +// Helper function which prints ASCII representation of passed Parameter dwToken +// to string. Token defines parameter details. The dwSourceOrDest parameter says +// whether or not this is a source or destination register +//------------------------------------------------------------------------------ +void D3DToGL::PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, char *pRegisterName, int nBufLen, bool bForceScalarSource, int *pARLDestReg ) +{ + char buff[32]; + bool bAllowWriteMask = true; + bool bAllowSwizzle = true; + + uint32 dwRegNum = dwToken & D3DSP_REGNUM_MASK; + + uint32 dwRegType, dwSwizzle; + uint32 dwSrcModifier = D3DSPSM_NONE; + + // Clear string to zero length + V_snprintf( pRegisterName, nBufLen, "" ); + + dwRegType = GetRegTypeFromToken( dwToken ); + + // If this is a dest register + if ( dwSourceOrDest == DST_REGISTER ) + { + // Instruction modifiers + if ( dwToken & D3DSPDM_PARTIALPRECISION ) + { +// strcat_s( pRegisterName, nBufLen, "_pp" ); + } + + if ( dwToken & D3DSPDM_SATURATE && !m_bGLSL ) + { + strcat_s( pRegisterName, nBufLen, "_SAT" ); + } + + if ( dwToken & D3DSPDM_MSAMPCENTROID) + { +// strcat_s( pRegisterName, nBufLen, "_centroid" ); + } + + if ( !m_bGLSL ) + { + strcat_s( pRegisterName, nBufLen, " " ); + } + } + + // If this is a source register + if ( dwSourceOrDest == SRC_REGISTER ) + { + dwSrcModifier = dwToken & D3DSP_SRCMOD_MASK; + + // If there are any source modifiers, check to see if they're at + // least partially "prefix" and prepend appropriately + if ( dwSrcModifier != D3DSPSM_NONE ) + { + switch ( dwSrcModifier ) + { + // These four start with just minus... (some may result in "postfix" notation as well later on) + case D3DSPSM_NEG: // negate + strcat_s( pRegisterName, nBufLen, "-" ); + break; + case D3DSPSM_BIASNEG: // bias and negate + case D3DSPSM_SIGNNEG: // sign and negate + case D3DSPSM_X2NEG: // *2 and negate + Assert(0); + strcat_s( pRegisterName, nBufLen, "-" ); + break; + case D3DSPSM_COMP: // complement + Assert(0); + strcat_s( pRegisterName, nBufLen, "1-" ); + break; + case D3DSPSM_ABS: // abs() + if ( m_bGLSL ) + { + strcat_s( pRegisterName, nBufLen, "abs(" ); + } + else if ( !m_bGeneratingDebugText ) + { + Assert( false ); + } + break; + case D3DSPSM_ABSNEG: // -abs() + if ( m_bGLSL ) + { + strcat_s( pRegisterName, nBufLen, "-abs(" ); + } + else if ( !m_bGeneratingDebugText ) + { + Assert( false ); + } + break; + case D3DSPSM_NOT: // for predicate register: "!p0" + Assert(0); + strcat_s( pRegisterName, nBufLen, "!" ); + break; + } + } + } + + // Register name (from type and number) + switch ( dwRegType ) + { + case D3DSPR_TEMP: + V_snprintf( buff, sizeof( buff ), "r%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + m_dwTempUsageMask |= 0x00000001 << dwRegNum; // Keep track of the use of this temp + break; + case D3DSPR_INPUT: + if ( !m_bVertexShader && ( dwSourceOrDest == SRC_REGISTER ) && m_bGLSL ) + { + V_snprintf( buff, sizeof( buff ), dwRegNum == 0 ? "gl_Color" : "gl_SecondaryColor" ); + strcat_s( pRegisterName, nBufLen, buff ); + } + else if ( m_bVertexShader || ( dwSourceOrDest == SRC_REGISTER ) || m_bGLSL ) + { + V_snprintf( buff, sizeof( buff ), "v%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + } + else // asm pixel shader declaration syntax: + { + V_snprintf( buff, sizeof( buff ), dwRegNum == 0 ? "v0 = fragment.color" : "v1 = fragment.color.secondary" ); + strcat_s( pRegisterName, nBufLen, buff ); + bAllowWriteMask = false; + } + break; + case D3DSPR_CONST: + if ( m_bConstantRegisterDefined[dwRegNum] ) + { + char szConstantRegName[3]; + if ( m_bVertexShader ) + { + V_snprintf( szConstantRegName, 3, "vd" ); + } + else + { + V_snprintf( szConstantRegName, 3, "pd" ); + } + + // Put defined constants into their own namespace "d" + V_snprintf( buff, sizeof( buff ), "%s%d", szConstantRegName, dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + } + else if ( dwToken & D3DSHADER_ADDRESSMODE_MASK ) // Indirect addressing (e.g. skinning in a vertex shader) + { + char szConstantRegName[3]; + if ( m_bVertexShader ) + { + V_snprintf( szConstantRegName, 3, "vc" ); + } + else // No indirect addressing in PS, this shouldn't happen + { + Assert(0); + V_snprintf( szConstantRegName, 3, "pc" ); + } + + // Index into single pc/vc[] register array with relative addressing + FlagIndirectRegister( GetNextToken(), pARLDestReg ); + V_snprintf( buff, sizeof( buff ), m_bGLSL ? "%s[a0 + %d]" : "%s[a0.x + %d]", szConstantRegName, dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + bAllowSwizzle = false; + + m_nHighestRegister = DXABSTRACT_VS_PARAM_SLOTS - 1; + } + else // Direct addressing of constant array + { + char szConstantRegName[3]; + V_snprintf( szConstantRegName, 3, m_bVertexShader ? "vc" : "pc" ); + + // Index into single pc/vc[] register array with absolute addressing, same for GLSL and ASM + V_snprintf( buff, sizeof( buff ), "%s[%d]", szConstantRegName, dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + + //// NOGO if (dwRegNum != 255) // have seen cases where dwRegNum is 0xFF... need to figure out where those opcodes are coming from + { + m_nHighestRegister = std::max( m_nHighestRegister, dwRegNum ); + } + + Assert( m_nHighestRegister < DXABSTRACT_VS_PARAM_SLOTS ); + } + break; + case D3DSPR_ADDR: // aliases to D3DSPR_TEXTURE + if ( m_bVertexShader ) + { + if ( m_bGLSL ) + { + Assert( dwRegNum == 0 ); + + V_snprintf( buff, sizeof( buff ), "va_r" ); + } + else + { + V_snprintf( buff, sizeof( buff ), "VA_REG" ); // Move into our temp, rather than a0 + } + } + else // D3DSPR_TEXTURE in the pixel shader + { + // If dest reg, this is an iterator/varying declaration + if ( dwSourceOrDest == DST_REGISTER ) + { + if ( m_bGLSL ) + { + // Is this iterator centroid? + if ( m_nCentroidMask & ( 0x00000001 << dwRegNum ) ) + { + V_snprintf( buff, sizeof( buff ), "centroid varying vec4 oT%d", dwRegNum ); // centroid varying + } + else + { + V_snprintf( buff, sizeof( buff ), "varying vec4 oT%d", dwRegNum ); + } + } + else + { + V_snprintf( buff, sizeof( buff ), "t%d = fragment.texcoord[%d]", dwRegNum, dwRegNum ); + } + + bAllowWriteMask = false; + } + else // source register + { + if ( m_bGLSL ) + { + V_snprintf( buff, sizeof( buff ), "oT%d", dwRegNum ); + } + else + { + V_snprintf( buff, sizeof( buff ), "t%d", dwRegNum ); + } + } + } + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_RASTOUT: // vertex shader oPos + Assert( m_bVertexShader ); + switch( dwRegNum ) + { + case D3DSRO_POSITION: + strcat_s( pRegisterName, nBufLen, m_bGLSL ? "vTempPos" : "oPos" ); // In GLSL, this ends up in gl_Position later on + m_bDeclareVSOPos = true; + break; + + case D3DSRO_FOG: + strcat_s( pRegisterName, nBufLen, m_bGLSL ? "gl_FogFragCoord" : "oFog" ); + m_bDeclareVSOFog = true; + break; + + default: + printf( "\nD3DSPR_RASTOUT: dwRegNum is %08x and token is %08x", dwRegNum, dwToken ); + Assert(0); + break; + } + break; + case D3DSPR_ATTROUT: + Assert( m_bVertexShader ); + if ( m_bGLSL ) + { + if ( dwRegNum == 0 ) + { + V_snprintf( buff, sizeof( buff ), "gl_FrontColor" ); + } + else if ( dwRegNum == 1 ) + { + V_snprintf( buff, sizeof( buff ), "gl_FrontSecondaryColor" ); + } + else + { + Error( "Invalid D3DSPR_ATTROUT index" ); + } + } + else + { + V_snprintf( buff, sizeof( buff ), "oD%d", dwRegNum ); + } + strcat_s( pRegisterName, nBufLen, buff ); + m_bOutputColorRegister[dwRegNum] = true; + break; + case D3DSPR_TEXCRDOUT: // aliases to D3DSPR_OUTPUT + if ( m_bVertexShader ) + { + if ( m_bGLSL ) + { + V_snprintf( buff, sizeof( buff ), "oT%d", dwRegNum ); + } + else + { + V_snprintf( buff, sizeof( buff ), "oT%d", dwRegNum ); + } + m_dwTexCoordOutMask |= ( 0x00000001 << dwRegNum ); + } + else + { + V_snprintf( buff, sizeof( buff ), "oC%d", dwRegNum ); + } + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_CONSTINT: + Assert( m_bGLSL && m_bAllowStaticControlFlow ); + V_snprintf( buff, sizeof( buff ), "i%d", dwRegNum ); // Loops use these + strcat_s( pRegisterName, nBufLen, buff ); + m_dwConstIntUsageMask |= 0x00000001 << dwRegNum; // Keep track of the use of this integer constant + break; + case D3DSPR_COLOROUT: + if ( m_bGLSL ) + { + V_snprintf( buff, sizeof( buff ), "gl_FragData[%d]", dwRegNum ); + } + else + { + V_snprintf( buff, sizeof( buff ), "oC%d", dwRegNum ); + } + strcat_s( pRegisterName, nBufLen, buff ); + m_bOutputColorRegister[dwRegNum] = true; + break; + case D3DSPR_DEPTHOUT: + V_snprintf( buff, sizeof( buff ), m_bGLSL ? "gl_FragDepth" : "oDepth" ); + strcat_s( pRegisterName, nBufLen, buff ); + m_bOutputDepthRegister = true; + break; + case D3DSPR_SAMPLER: + V_snprintf( buff, sizeof( buff ), m_bGLSL ? "sampler%d" : "texture[%d]", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_CONST2: + Assert(0); + V_snprintf( buff, sizeof( buff ), "c%d", dwRegNum+2048); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_CONST3: + Assert(0); + V_snprintf( buff, sizeof( buff ), "c%d", dwRegNum+4096); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_CONST4: + Assert(0); + V_snprintf( buff, sizeof( buff ), "c%d", dwRegNum+6144); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_CONSTBOOL: + Assert( m_bGLSL && m_bAllowStaticControlFlow ); + V_snprintf( buff, sizeof( buff ), "b%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + m_dwConstBoolUsageMask |= 0x00000001 << dwRegNum; // Keep track of the use of this bool constant + break; + case D3DSPR_LOOP: + Assert(0); + V_snprintf( buff, sizeof( buff ), "aL%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_TEMPFLOAT16: + Assert(0); + V_snprintf( buff, sizeof( buff ), "temp_float16_xxx%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_MISCTYPE: + if ( !m_bGLSL && !m_bGeneratingDebugText ) + { + Assert(0); + } + V_snprintf( buff, sizeof( buff ), "misc%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_LABEL: + Assert(0); + V_snprintf( buff, sizeof( buff ), "label%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + break; + case D3DSPR_PREDICATE: + Assert(0); + V_snprintf( buff, sizeof( buff ), "p%d", dwRegNum ); + strcat_s( pRegisterName, nBufLen, buff ); + break; + } + + // If this is a dest register + if ( dwSourceOrDest == DST_REGISTER ) + { + // + // Write masks + // + // If some (not all, not none) of the write masks are set, we should include them + // + if ( bAllowWriteMask && ( !((dwToken & D3DSP_WRITEMASK_ALL) == D3DSP_WRITEMASK_ALL) || ((dwToken & D3DSP_WRITEMASK_ALL) == 0x00000000) ) ) + { + // Put the dot on there + strcat_s( pRegisterName, nBufLen, "." ); + + // Optionally put on the x, y, z or w + int nMasksWritten = 0; + if ( dwToken & D3DSP_WRITEMASK_0 ) + { + strcat_s( pRegisterName, nBufLen, "x" ); + ++nMasksWritten; + } + if ( dwToken & D3DSP_WRITEMASK_1 ) + { + strcat_s( pRegisterName, nBufLen, "y" ); + ++nMasksWritten; + } + if ( dwToken & D3DSP_WRITEMASK_2 ) + { + strcat_s( pRegisterName, nBufLen, "z" ); + ++nMasksWritten; + } + if ( dwToken & D3DSP_WRITEMASK_3 ) + { + strcat_s( pRegisterName, nBufLen, "w" ); + ++nMasksWritten; + } + } + } + else // must be a source register + { + if ( bAllowSwizzle ) // relative addressing hard-codes the swizzle on a0.x + { + uint32 dwXSwizzle, dwYSwizzle, dwZSwizzle, dwWSwizzle; + + // Mask out the swizzle modifier + dwSwizzle = dwToken & D3DVS_SWIZZLE_MASK; + + // If there are any swizzles at all, tack on the appropriate notation + if ( dwSwizzle != D3DVS_NOSWIZZLE ) + { + // Separate out the two-bit codes for each component swizzle + dwXSwizzle = dwSwizzle & D3DVS_X_W; + dwYSwizzle = dwSwizzle & D3DVS_Y_W; + dwZSwizzle = dwSwizzle & D3DVS_Z_W; + dwWSwizzle = dwSwizzle & D3DVS_W_W; + + // Put on the dot + strcat_s( pRegisterName, nBufLen, "." ); + + // See where X comes from + switch ( dwXSwizzle ) + { + case D3DVS_X_X: + strcat_s( pRegisterName, nBufLen, "x" ); + break; + case D3DVS_X_Y: + strcat_s( pRegisterName, nBufLen, "y" ); + break; + case D3DVS_X_Z: + strcat_s( pRegisterName, nBufLen, "z" ); + break; + case D3DVS_X_W: + strcat_s( pRegisterName, nBufLen, "w" ); + break; + } + + if ( !bForceScalarSource ) + { + // If the source of the remaining components are aren't + // identical to the source of x, continue with swizzle + if ( ((dwXSwizzle >> D3DVS_SWIZZLE_SHIFT) != (dwYSwizzle >> (D3DVS_SWIZZLE_SHIFT + 2))) || // X and Y sources match? + ((dwXSwizzle >> D3DVS_SWIZZLE_SHIFT) != (dwZSwizzle >> (D3DVS_SWIZZLE_SHIFT + 4))) || // X and Z sources match? + ((dwXSwizzle >> D3DVS_SWIZZLE_SHIFT) != (dwWSwizzle >> (D3DVS_SWIZZLE_SHIFT + 6)))) // X and W sources match? + { + + // OpenGL seems to want us to have either 1 or 4 components in a swizzle, so just plow on through the rest + switch ( dwYSwizzle ) + { + case D3DVS_Y_X: + strcat_s( pRegisterName, nBufLen, "x" ); + break; + case D3DVS_Y_Y: + strcat_s( pRegisterName, nBufLen, "y" ); + break; + case D3DVS_Y_Z: + strcat_s( pRegisterName, nBufLen, "z" ); + break; + case D3DVS_Y_W: + strcat_s( pRegisterName, nBufLen, "w" ); + break; + } + + switch ( dwZSwizzle ) + { + case D3DVS_Z_X: + strcat_s( pRegisterName, nBufLen, "x" ); + break; + case D3DVS_Z_Y: + strcat_s( pRegisterName, nBufLen, "y" ); + break; + case D3DVS_Z_Z: + strcat_s( pRegisterName, nBufLen, "z" ); + break; + case D3DVS_Z_W: + strcat_s( pRegisterName, nBufLen, "w" ); + break; + } + + switch ( dwWSwizzle ) + { + case D3DVS_W_X: + strcat_s( pRegisterName, nBufLen, "x" ); + break; + case D3DVS_W_Y: + strcat_s( pRegisterName, nBufLen, "y" ); + break; + case D3DVS_W_Z: + strcat_s( pRegisterName, nBufLen, "z" ); + break; + case D3DVS_W_W: + strcat_s( pRegisterName, nBufLen, "w" ); + break; + } + + } + + } // end !bForceScalarSource + } + else // dwSwizzle == D3DVS_NOSWIZZLE + { + // If this is a MOVA / ARL, GL on the Mac requires us to tack the .x onto the source register + if ( bForceScalarSource ) + { + strcat_s( pRegisterName, nBufLen, ".x" ); + } + } + } // bAllowSwizzle + + // If there are any source modifiers, check to see if they're at + // least partially "postfix" and tack them on as appropriate + if ( dwSrcModifier != D3DSPSM_NONE ) + { + switch ( dwSrcModifier ) + { + case D3DSPSM_BIAS: // bias + case D3DSPSM_BIASNEG: // bias and negate + Assert(0); + strcat_s( pRegisterName, nBufLen, "_bx2" ); + break; + case D3DSPSM_SIGN: // sign + case D3DSPSM_SIGNNEG: // sign and negate + Assert(0); + strcat_s( pRegisterName, nBufLen, "_sgn" ); + break; + case D3DSPSM_X2: // *2 + case D3DSPSM_X2NEG: // *2 and negate + Assert(0); + strcat_s( pRegisterName, nBufLen, "_x2" ); + break; + case D3DSPSM_ABS: // abs() + case D3DSPSM_ABSNEG: // -abs() + if ( m_bGLSL ) + { + strcat_s( pRegisterName, nBufLen, ")" ); + } + break; + case D3DSPSM_DZ: // divide through by z component + Assert(0); + strcat_s( pRegisterName, nBufLen, "_dz" ); + break; + case D3DSPSM_DW: // divide through by w component + Assert(0); + strcat_s( pRegisterName, nBufLen, "_dw" ); + break; + } + } // end postfix modifiers (really only ps.1.x) + } +} + +void D3DToGL::RecordInputAndOutputPositions() +{ + // Remember where we are in the token stream. + m_pRecordedInputTokenStart = m_pdwNextToken; + + // Remember where our outputs are. + m_nRecordedParamCodeStrlen = V_strlen( (char*)m_pBufParamCode->Base() ); + m_nRecordedALUCodeStrlen = V_strlen( (char*)m_pBufALUCode->Base() ); + m_nRecordedAttribCodeStrlen = V_strlen( (char*)m_pBufAttribCode->Base() ); +} +void D3DToGL::AddTokenHexCodeToBuffer( char *pBuffer, int nSize, int nLastStrlen ) +{ + int nCurStrlen = V_strlen( pBuffer ); + if ( nCurStrlen == nLastStrlen ) + return; + + // Build a string with all the hex codes of the tokens since last time. + char szHex[512]; + szHex[0] = '\n'; + V_snprintf( &szHex[1], sizeof( szHex )-1, HEXCODE_HEADER ); + int nTokens = std::min( 10, m_pdwNextToken - m_pRecordedInputTokenStart ); + for ( int i=0; i < nTokens; i++ ) + { + char szTemp[32]; + V_snprintf( szTemp, sizeof( szTemp ), "0x%x ", m_pRecordedInputTokenStart[i] ); + strncat( szHex, szTemp, sizeof(szHex) - strlen(szHex) - 1 ); + } + strncat( szHex, "\n", sizeof(szHex) - strlen(szHex) - 1 ); + + // Insert the hex codes into the string. + int nBytesToInsert = V_strlen( szHex ); + if ( nCurStrlen + nBytesToInsert + 1 >= nSize ) + Error( "Buffer overflow writing token hex codes" ); + + if ( m_bPutHexCodesAfterLines ) + { + // Put it at the end of the last line. + if ( pBuffer[nCurStrlen-1] == '\n' ) + pBuffer[nCurStrlen-1] = 0; + + strncat( pBuffer, &szHex[1], nSize - strlen( pBuffer ) - 1 ); + } + else + { + memmove( pBuffer + nLastStrlen + nBytesToInsert, pBuffer + nLastStrlen, nCurStrlen - nLastStrlen + 1 ); + memcpy( pBuffer + nLastStrlen, szHex, nBytesToInsert ); + } +} + +void D3DToGL::AddTokenHexCode() +{ + if ( m_pdwNextToken > m_pRecordedInputTokenStart ) + { + AddTokenHexCodeToBuffer( (char*)m_pBufParamCode->Base(), m_pBufParamCode->Size(), m_nRecordedParamCodeStrlen ); + AddTokenHexCodeToBuffer( (char*)m_pBufALUCode->Base(), m_pBufALUCode->Size(), m_nRecordedALUCodeStrlen ); + AddTokenHexCodeToBuffer( (char*)m_pBufAttribCode->Base(), m_pBufAttribCode->Size(), m_nRecordedAttribCodeStrlen ); + } +} + +uint32 D3DToGL::MaintainAttributeMap( uint32 dwToken, uint32 dwRegToken ) +{ + // Check that this reg index has not been used before - if it has, let Houston know + uint dwRegIndex = dwRegToken & D3DSP_REGNUM_MASK; + if ( m_dwAttribMap[ dwRegIndex ] == 0xFFFFFFFF ) + { + // log it + // semantic/usage in the higher nibble + // usage index in the low nibble + + uint usage = dwToken & D3DSP_DCL_USAGE_MASK; + uint usageindex = ( dwToken & D3DSP_DCL_USAGEINDEX_MASK ) >> D3DSP_DCL_USAGEINDEX_SHIFT; + + m_dwAttribMap[ dwRegIndex ] = ( usage << 4 ) | usageindex; + + // avoid writing 0xBB since runtime code uses that for an 'unused' marker + if ( m_dwAttribMap[ dwRegIndex ] == 0xBB ) + { + Debugger(); + } + } + else + { + //not OK + Debugger(); + } + + return dwRegIndex; +} + +void D3DToGL::Handle_DCL() +{ + uint32 dwToken = GetNextToken(); // What kind of dcl is this... + uint32 dwRegToken = GetNextToken(); // Look ahead to register token + + if ( m_bVertexShader ) + { + // If this is an output, remember the index (what the ASM code calls o0, o1, o2..) and the semantic. + // When GetParameterString( DST_REGISTER ) hits this one, we'll return "oN". + // At the end of the main() function, we'll insert a bunch of statements like "gl_Color = o2" based on what we remembered here. + if ( m_bGLSL ) + { + if ( m_dwMajorVersion >= 3 && GetRegTypeFromToken( dwRegToken ) == D3DSPR_OUTPUT ) + { + uint32 dwRegNum = dwRegToken & D3DSP_REGNUM_MASK; + + if ( dwRegNum >= MAX_DECLARED_OUTPUTS ) + Error( "Output register number (%d) too high (only %d supported).", dwRegNum, MAX_DECLARED_OUTPUTS ); + + if ( m_DeclaredOutputs[dwRegNum] != UNDECLARED_OUTPUT ) + Error( "Output dcl_ hit for register #%d more than once!", dwRegNum ); + + Assert( dwToken != UNDECLARED_OUTPUT ); + m_DeclaredOutputs[dwRegNum] = dwToken; + + if ( m_bAddHexCodeComments ) + { + CUtlString sParam2 = GetUsageAndIndexString( dwToken, SEMANTIC_OUTPUT ); + PrintToBuf( *m_pBufHeaderCode, "// [GL remembering that o%d maps to %s]\n", dwRegNum, sParam2.String() ); + } + + PrintToBuf( *m_pBufHeaderCode, "varying vec4 o%d = vec4( 0.0, 0.0, 0.0, 0.0 );\n", dwRegNum ); + } + else + { + CUtlString sParam1 = GetParameterString( dwRegToken, DST_REGISTER, false, NULL ); + CUtlString sParam2 = GetUsageAndIndexString( dwToken, SEMANTIC_INPUT ); + + sParam2 = FixGLSLSwizzle( sParam1, sParam2 ); + PrintToBuf( *m_pBufHeaderCode, "attribute vec4 %s; // ", sParam1.String() ); + + MaintainAttributeMap( dwToken, dwRegToken ); + + char temp[128]; + // regnum goes straight into the vertex.attrib[n] index + sprintf( temp, "%08x %08x\n", dwToken, dwRegToken ); + StrcatToHeaderCode( temp ); + } + } + else // ARB_vertex_program ASM + { + StrcatToAttribCode( "ATTRIB" ); + char buff[64]; + PrintParameterToString( dwRegToken, DST_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToAttribCode( buff ); + StrcatToAttribCode( " = " ); + + uint regIndex = MaintainAttributeMap( dwToken, dwRegToken ); + + char temp[128]; + // regnum goes straight into the vertex.attrib[n] index + sprintf( temp, "vertex.attrib[%d]; # %08x %08x\n", regIndex, dwToken, dwRegToken ); + StrcatToAttribCode( temp ); + + // ASM +// CUtlString sParam1 = GetParameterString( dwRegToken, DST_REGISTER ); +// CUtlString sParam2 = GetUsageAndIndexString( dwToken, SEMANTIC_INPUT ); +// PrintToBuf( m_pAttribCode, m_nAttribCodeBufSize, "ATTRIB%s = %s;\n", sParam1.String(), sParam2.String() ); + } + } + else // Pixel shader + { + // If the register is a sampler, the dcl has a dimension decorator that we have to save for subsequent TEX instructions + uint32 nRegType = GetRegType( dwRegToken ); + if ( nRegType == D3DSPR_SAMPLER ) + { + int nRegNum = dwRegToken & D3DSP_REGNUM_MASK; + switch ( TextureType( dwToken ) ) + { + default: + case D3DSTT_UNKNOWN: + case D3DSTT_2D: + m_dwSamplerTypes[nRegNum] = SAMPLER_TYPE_2D; + break; + case D3DSTT_CUBE: + m_dwSamplerTypes[nRegNum] = SAMPLER_TYPE_CUBE; + break; + case D3DSTT_VOLUME: + m_dwSamplerTypes[nRegNum] = SAMPLER_TYPE_3D; + break; + } + + // Track sampler declarations + m_dwSamplerUsageMask |= 1 << nRegNum; + } + else // Not a sampler, we're going to generate vaying declaration code + { + if ( m_bGLSL ) + { + // In pixel shaders we only declare texture coordinate varyings since they may be using centroid + if ( (!m_bVertexShader) && ( GetRegType( dwRegToken ) == D3DSPR_TEXTURE ) ) + { + char buff[256]; + PrintParameterToString( dwRegToken, DST_REGISTER, buff, sizeof( buff ), false, NULL ); + PrintToBuf( *m_pBufHeaderCode, "%s;\n",buff ); + } + } + else // asm + { + char buff[256]; + PrintParameterToString( dwRegToken, DST_REGISTER, buff, sizeof( buff ), false, NULL ); + PrintToBuf( *m_pBufAttribCode, "ATTRIB%s;\n", buff ); + } + } + } +} + + +void D3DToGL::Handle_DEF() +{ + // + // JasonM TODO: catch D3D's sincos-specific D3DSINCOSCONST1 and D3DSINCOSCONST2 constants and filter them out here + // + + // Which register is being defined + uint32 dwToken = GetNextToken(); + + // Note that this constant was explicitly defined + m_bConstantRegisterDefined[dwToken & D3DSP_REGNUM_MASK] = true; + CUtlString sParamName = GetParameterString( dwToken, DST_REGISTER, false, NULL ); + + const char float_fmt[] = "%.12f"; + const char float_fmt_commaspace[] = "%.12f, "; // %g causes GLSL compile problems around consts like "1e+2.0" - try %f + + if ( m_bGLSL ) + { + PrintToBuf( *m_pBufParamCode, "vec4 %s = vec4( ", sParamName.String() ); + + // Run through the 4 floats + for ( int i=0; i < 4; i++ ) + { + float fConst = uint32ToFloat( GetNextToken() ); + + // It must have a decimal point. + char szTemp[256]; + V_snprintf( szTemp, sizeof( szTemp ), float_fmt, fConst ); + StripExtraTrailingZeros( szTemp ); // Turn 1.00000 into 1.0 + + if ( !strchr( szTemp, '.' ) ) + { + strncat( szTemp, ".0", sizeof(szTemp) - strlen(szTemp) - 1 ); + } + + PrintToBuf( *m_pBufParamCode, i != 3 ? "%s, " : "%s", szTemp ); // end with comma-space + } + + PrintToBuf( *m_pBufParamCode, " );\n" ); + } + else + { + PrintToBuf( *m_pBufParamCode, "PARAM%s = { ", sParamName.String() ); + + // Run through the 4 floats + for ( int i=0; i < 4; i++ ) + { + float fConst = uint32ToFloat( GetNextToken() ); + PrintToBuf( *m_pBufParamCode, i != 3 ? float_fmt_commaspace : float_fmt, fConst ); // end with comma-space + } + + PrintToBuf( *m_pBufParamCode, " };\n" ); + } +} + +void D3DToGL::Handle_MAD( uint32 nInstruction ) +{ + uint32 nDestToken = GetNextToken(); + CUtlString sParam1 = GetParameterString( nDestToken, DST_REGISTER, false, NULL ); + int nARLComp0 = ARL_DEST_NONE; + CUtlString sParam2 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp0 ); + int nARLComp1 = ARL_DEST_NONE; + CUtlString sParam3 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp1 ); + int nARLComp2 = ARL_DEST_NONE; + CUtlString sParam4 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp2 ); + + // This optionally inserts a move from our dummy address register to the .x component of the real one + InsertMoveFromAddressRegister( m_pBufALUCode, nARLComp0, nARLComp1, nARLComp2 ); + + if ( m_bGLSL ) + { + sParam2 = FixGLSLSwizzle( sParam1, sParam2 ); + sParam3 = FixGLSLSwizzle( sParam1, sParam3 ); + sParam4 = FixGLSLSwizzle( sParam1, sParam4 ); + PrintToBuf( *m_pBufALUCode, "%s = %s * %s + %s;\n", sParam1.String(), sParam2.String(), sParam3.String(), sParam4.String() ); + + // If the _SAT instruction modifier is used, then do a saturate here. + if ( nDestToken & D3DSPDM_SATURATE ) + { + int nComponents = GetNumSwizzleComponents( sParam1.String() ); + if ( nComponents == 0 ) + nComponents = 4; + + PrintToBuf( *m_pBufALUCode, "%s = clamp( %s, %s, %s );\n", sParam1.String(), sParam1.String(), g_szVecZeros[nComponents], g_szVecOnes[nComponents] ); + } + } + else + { + char buff[256]; + PrintOpcode( nInstruction, buff, sizeof( buff ) ); + PrintToBuf( *m_pBufALUCode, "%s%s, %s, %s, %s;\n", buff, sParam1.String(), sParam2.String(), sParam3.String(), sParam4.String() ); + + if ( nDestToken & D3DSPDM_SATURATE ) + { + // Need to saturate asm! + Assert(0); + } + } +} + + +void D3DToGL::Handle_DP2ADD() +{ + char pDestReg[16], pSrc0Reg[16], pSrc1Reg[16], pSrc2Reg[16]; + uint32 nDestToken = GetNextToken(); + PrintParameterToString( nDestToken, DST_REGISTER, pDestReg, sizeof( pDestReg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc0Reg, sizeof( pSrc0Reg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc1Reg, sizeof( pSrc1Reg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc2Reg, sizeof( pSrc2Reg ), false, NULL ); + + if ( m_bGLSL ) + { + // We should only be assigning to a single component of the dest. + Assert( GetNumSwizzleComponents( pDestReg ) == 1 ); + Assert( GetNumSwizzleComponents( pSrc2Reg ) == 1 ); + + // This is a 2D dot product, so we only want two entries from the middle components. + CUtlString sArg0 = EnsureNumSwizzleComponents( pSrc0Reg, 2 ); + CUtlString sArg1 = EnsureNumSwizzleComponents( pSrc1Reg, 2 ); + + PrintToBuf( *m_pBufALUCode, "%s = dot( %s, %s ) + %s;\n", pDestReg, sArg0.String(), sArg1.String(), pSrc2Reg ); + + // If the _SAT instruction modifier is used, then do a saturate here. + if ( nDestToken & D3DSPDM_SATURATE ) + { + int nComponents = GetNumSwizzleComponents( pDestReg ); + if ( nComponents == 0 ) + nComponents = 4; + + PrintToBuf( *m_pBufALUCode, "%s = clamp( %s, %s, %s );\n", pDestReg, pDestReg, g_szVecZeros[nComponents], g_szVecOnes[nComponents] ); + } + } + else + { + m_bNeedsD2AddTemp = true; + + PrintToBuf( *m_pBufALUCode, "MOV DP2A0, %s;\n", pSrc0Reg ); // MOV DP2A0, src0; + PrintToBuf( *m_pBufALUCode, "MOV DP2A0.z, 1;\n" ); // MOV DP2A0.z, 1; + + PrintToBuf( *m_pBufALUCode, "MOV DP2A1, %s;\n", pSrc1Reg ); // MOV DP2A1, src1; + PrintToBuf( *m_pBufALUCode, "MOV DP2A1.z, %s;\n", pSrc2Reg ); // MOV DP2A1.z, src2; + + PrintToBuf( *m_pBufALUCode, "DP3%s, DP2A0, DP2A1;\n", pDestReg ); // DP3 dest, DP2A0, DP2A1; + + if ( nDestToken & D3DSPDM_SATURATE ) + { + // Need to saturate asm! + Assert(0); + } + } +} + + +void D3DToGL::Handle_SINCOS() +{ + char pDestReg[16], pSrc0Reg[16]; + PrintParameterToString( GetNextToken(), DST_REGISTER, pDestReg, sizeof( pDestReg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc0Reg, sizeof( pSrc0Reg ), true, NULL ); + m_bNeedsSinCosDeclarations = true; + + if ( m_bGLSL ) + { + CUtlString sDest( pDestReg ); + CUtlString sArg0 = EnsureNumSwizzleComponents( pSrc0Reg, 1 );// Ensure input is scalar + CUtlString sResult( "vSinCosTmp.xy" ); // Always going to populate this + sResult = FixGLSLSwizzle( sDest, sResult ); // Make sure we match the desired output reg + + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.z = %s * %s;\n", sArg0.String(), sArg0.String() ); + + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.xy = vSinCosTmp.zz * scA.xy + scA.wz;\n" ); + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.xy = vSinCosTmp.xy * vSinCosTmp.zz + scB.xy;\n" ); + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.xy = vSinCosTmp.xy * vSinCosTmp.zz + scB.wz;\n" ); + + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.x = vSinCosTmp.x * %s;\n", sArg0.String() ); + + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.xy = vSinCosTmp.xy * vSinCosTmp.xx;\n" ); + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.xy = vSinCosTmp.xy + vSinCosTmp.xy;\n" ); + PrintToBuf( *m_pBufALUCode, "vSinCosTmp.x = -vSinCosTmp.x + scB.z;\n" ); + + PrintToBuf( *m_pBufALUCode, "%s = %s;\n", sDest.String(), sResult.String() ); + } + else + { + // This is the code sequence recommended to IHVs by Microsoft in the DirectX 9 DDK: + // + // http://msdn.microsoft.com/en-us/library/ms800337.aspx + // + // MUL SC_TEMP.z, src, src; + // MAD SC_TEMP.xy, SC_TEMP.z, scA, scA.wzyx; + // MAD SC_TEMP.xy, SC_TEMP, SC_TEMP.z, scB; + // MAD SC_TEMP.xy, SC_TEMP, SC_TEMP.z, scB.wzyx; + // MUL SC_TEMP.x, SC_TEMP.x, src; + // MUL SC_TEMP.xy, SC_TEMP, SC_TEMP.x; + // ADD SC_TEMP.xy, SC_TEMP, SC_TEMP; + // ADD SC_TEMP.x, -SC_TEMP.x, scB.z; + + StrcatToALUCode( "MUL SC_TEMP.z, " ); // MUL SC_TEMP.z, src, src; + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ", " ); + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ";\n" ); + + StrcatToALUCode( "MAD SC_TEMP.xy, SC_TEMP.z, scA, scA.wzyx;\n" ); + StrcatToALUCode( "MAD SC_TEMP.xy, SC_TEMP, SC_TEMP.z, scB;\n" ); + StrcatToALUCode( "MAD SC_TEMP.xy, SC_TEMP, SC_TEMP.z, scB.wzyx;\n" ); + + StrcatToALUCode( "MUL SC_TEMP.x, SC_TEMP.x, " ); + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ";\n" ); + StrcatToALUCode( "MUL SC_TEMP.xy, SC_TEMP, SC_TEMP.x;\n" ); + StrcatToALUCode( "ADD SC_TEMP.xy, SC_TEMP, SC_TEMP;\n" ); + StrcatToALUCode( "ADD SC_TEMP.x, -SC_TEMP.x, scB.z;\n" ); + + StrcatToALUCode( "MOV" ); + StrcatToALUCode( pDestReg ); + StrcatToALUCode( ", SC_TEMP;\n" ); + } + + // Eat two more tokens since D3D defines Taylor series constants that we won't need + SkipTokens( 2 ); +} + + +void D3DToGL::Handle_LRP( uint32 nInstruction ) +{ + if ( m_bGLSL ) + { + uint32 nDestToken = GetNextToken(); + CUtlString sDest = GetParameterString( nDestToken, DST_REGISTER, false, NULL ); + int nARLComp0 = ARL_DEST_NONE; + CUtlString sParam0 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp0 ); + int nARLComp1 = ARL_DEST_NONE; + CUtlString sParam1 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp1 ); + int nARLComp2 = ARL_DEST_NONE; + CUtlString sParam2 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp2 ); + + // This optionally inserts a move from our dummy address register to the .x component of the real one + InsertMoveFromAddressRegister( m_pBufALUCode, nARLComp0, nARLComp1, nARLComp2 ); + + sParam0 = FixGLSLSwizzle( sDest, sParam0 ); + sParam1 = FixGLSLSwizzle( sDest, sParam1 ); + sParam2 = FixGLSLSwizzle( sDest, sParam2 ); + + // dest = src0 * (src1 - src2) + src2; + PrintToBuf( *m_pBufALUCode, "%s = %s * ( %s - %s ) + %s;\n", sDest.String(), sParam0.String(), sParam1.String(), sParam2.String(), sParam2.String() ); + + // If the _SAT instruction modifier is used, then do a saturate here. + if ( nDestToken & D3DSPDM_SATURATE ) + { + int nComponents = GetNumSwizzleComponents( sDest.String() ); + if ( nComponents == 0 ) + nComponents = 4; + + PrintToBuf( *m_pBufALUCode, "%s = clamp( %s, %s, %s );\n", sDest.String(), sDest.String(), g_szVecZeros[nComponents], g_szVecOnes[nComponents] ); + } + } + else + { + if ( !m_bVertexShader ) + { + char buff[256]; + PrintOpcode( nInstruction, buff, sizeof( buff ) ); + StrcatToALUCode( buff ); + PrintParameterToString( GetNextToken(), DST_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ";\n" ); + } + else // VS doesn't actually have a LRP instruction. Emulate with a SUB and a MAD + { + char pDestReg[16], pSrc0Reg[16], pSrc1Reg[16], pSrc2Reg[16]; + + m_bNeedsLerpTemp = true; + + // dest = src0 * (src1 - src2) + src2; + PrintParameterToString( GetNextToken(), DST_REGISTER, pDestReg, sizeof( pDestReg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc0Reg, sizeof( pSrc0Reg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc1Reg, sizeof( pSrc1Reg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc2Reg, sizeof( pSrc2Reg ), false, NULL ); + + StrcatToALUCode( "SUB LRP_TEMP, " ); // SUB LRP_TEMP, src1, src2; + StrcatToALUCode( pSrc1Reg ); + StrcatToALUCode( ", " ); + StrcatToALUCode( pSrc2Reg ); + StrcatToALUCode( ";\n" ); + + StrcatToALUCode( "MAD" ); // MAD dst, src0, LRP_TEMP, src2; + StrcatToALUCode( pDestReg ); + StrcatToALUCode( ", " ); + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ", LRP_TEMP, " ); + StrcatToALUCode( pSrc2Reg ); + StrcatToALUCode( ";\n" ); + } + } +} + + +void D3DToGL::Handle_TEX( uint32 dwToken, bool bIsTexLDL ) +{ + char pDestReg[64], pSrc0Reg[64], pSrc1Reg[64]; + PrintParameterToString( GetNextToken(), DST_REGISTER, pDestReg, sizeof( pDestReg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc0Reg, sizeof( pSrc0Reg ), false, NULL ); + + DWORD dwSrc1Token = GetNextToken(); + PrintParameterToString( dwSrc1Token, SRC_REGISTER, pSrc1Reg, sizeof( pSrc1Reg ), false, NULL ); + + + if ( m_bGLSL ) + { + Assert( (dwSrc1Token & D3DSP_REGNUM_MASK) < ARRAYSIZE( m_dwSamplerTypes ) ); + uint32 nSamplerType = m_dwSamplerTypes[dwSrc1Token & D3DSP_REGNUM_MASK]; + if ( nSamplerType == SAMPLER_TYPE_2D ) + { + CUtlString sCoordVar = EnsureNumSwizzleComponents( pSrc0Reg, 2 ); + + if ( bIsTexLDL ) + { + // Strip out the W component of the pSrc0Reg and pass that as the LOD to texture2DLod. + char szLOD[128], szExtra[8]; + GetParamNameWithoutSwizzle( pSrc0Reg, szLOD, sizeof( szLOD ) ); + V_snprintf( szExtra, sizeof( szExtra ), ".%c", GetSwizzleComponent( pSrc0Reg, 3 ) ); + strncat( szLOD, szExtra, sizeof(szLOD) - strlen(szLOD) - 1 ); + + PrintToBuf( *m_pBufALUCode, "%s = texture2DLod( %s, %s, %s );\n", pDestReg, pSrc1Reg, sCoordVar.String(), szLOD ); + } + else if ( ( (int) ( dwSrc1Token & D3DSP_REGNUM_MASK ) ) == m_nShadowDepthSampler ) // Syntax for shadow depth sampler + { + // .z is meant to contain the object depth, while .xy contains the 2D tex coords + CUtlString sCoordVar3D = EnsureNumSwizzleComponents( pSrc0Reg, 3 ); + + PrintToBuf( *m_pBufALUCode, "%s = shadow2D( %s, %s );\n", pDestReg, pSrc1Reg, sCoordVar3D.String() ); + Assert( m_dwSamplerTypes[dwSrc1Token & D3DSP_REGNUM_MASK] == SAMPLER_TYPE_2D ); + } + else if( ( OpcodeSpecificData( dwToken ) << D3DSP_OPCODESPECIFICCONTROL_SHIFT ) == D3DSI_TEXLD_PROJECT ) + { + // This projective case is after the shadow case intentionally, due to the way that "projective" + // loads are overloaded in our D3D shaders for shadow lookups. + // + // We use the vec4 variant of texture2DProj() intentionally here, since it lines up well with Direct3D. + + CUtlString s4DProjCoords = EnsureNumSwizzleComponents( pSrc0Reg, 4 ); // Ensure vec4 variant + PrintToBuf( *m_pBufALUCode, "%s = texture2DProj( %s, %s );\n", pDestReg, pSrc1Reg, s4DProjCoords.String() ); + } + else + { + PrintToBuf( *m_pBufALUCode, "%s = texture2D( %s, %s );\n", pDestReg, pSrc1Reg, sCoordVar.String() ); + } + } + else if ( nSamplerType == SAMPLER_TYPE_3D ) + { + CUtlString sCoordVar = EnsureNumSwizzleComponents( pSrc0Reg, 3 ); + PrintToBuf( *m_pBufALUCode, "%s = texture3D( %s, %s );\n", pDestReg, pSrc1Reg, sCoordVar.String() ); + } + else if ( nSamplerType == SAMPLER_TYPE_CUBE ) + { + CUtlString sCoordVar = EnsureNumSwizzleComponents( pSrc0Reg, 3 ); + PrintToBuf( *m_pBufALUCode, "%s = textureCube( %s, %s );\n", pDestReg, pSrc1Reg, sCoordVar.String() ); + } + else + { + Error( "TEX instruction: unsupported sampler type used" ); + } + } + else + { + Assert( !( bIsTexLDL && !m_bGeneratingDebugText ) ); + + if( ( OpcodeSpecificData( dwToken ) << D3DSP_OPCODESPECIFICCONTROL_SHIFT ) == D3DSI_TEXLD_PROJECT ) + { + StrcatToALUCode( "TXP" ); + } + else if( ( OpcodeSpecificData( dwToken ) << D3DSP_OPCODESPECIFICCONTROL_SHIFT) == D3DSI_TEXLD_BIAS ) + { + StrcatToALUCode( "TXB" ); + } + else + { + StrcatToALUCode( "TEX" ); + } + + // Destination + StrcatToALUCode( pDestReg ); + StrcatToALUCode( ", " ); + + // Source0 + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ", " ); + + // Source1 + StrcatToALUCode( pSrc1Reg ); + StrcatToALUCode( ", " ); + + // Syntax for shadow depth sampler + if ( ( (int) ( dwSrc1Token & D3DSP_REGNUM_MASK ) ) == m_nShadowDepthSampler ) + { + m_bDeclareShadowOption = true; + + StrcatToALUCode( "SHADOW" ); // Should result in SHADOW2D target + Assert( m_dwSamplerTypes[dwSrc1Token & D3DSP_REGNUM_MASK] == SAMPLER_TYPE_2D ); + } + + // Sampler dimension (2D, CUBE, 3D) determined by earlier declaration + StrcatToALUCode( g_szSamplerStrings[m_dwSamplerTypes[dwSrc1Token & D3DSP_REGNUM_MASK]] ); + StrcatToALUCode( ";\n" ); + } +} + +void D3DToGL::StrcatToHeaderCode( const char *pBuf ) +{ + strcat_s( (char*)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), pBuf ); +} + +void D3DToGL::StrcatToALUCode( const char *pBuf ) +{ + strcat_s( (char*)m_pBufALUCode->Base(), m_pBufALUCode->Size(), pBuf ); +} + +void D3DToGL::StrcatToParamCode( const char *pBuf ) +{ + strcat_s( (char*)m_pBufParamCode->Base(), m_pBufParamCode->Size(), pBuf ); +} + +void D3DToGL::StrcatToAttribCode( const char *pBuf ) +{ + strcat_s( (char*)m_pBufAttribCode->Base(), m_pBufAttribCode->Size(), pBuf ); +} + +void D3DToGL::Handle_TexLDD( uint32 nInstruction ) +{ + Assert( !m_bGLSL ); // Not supported yet, but can be if we need it. + + char buff[256]; + PrintOpcode( nInstruction, buff, sizeof( buff ) ); + + StrcatToALUCode( buff ); + PrintParameterToString( GetNextToken(), DST_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ";\n" ); +} + + +void D3DToGL::Handle_TexCoord() +{ + Assert(0); + + // If ps_1_4, this is texcrd + if ( (m_dwMajorVersion == 1) && (m_dwMinorVersion == 4) && (!m_bVertexShader) ) + { + StrcatToALUCode( "texcrd" ); + } + else // else it's texcoord + { + Assert(0); + StrcatToALUCode( "texcoord" ); + } + + char buff[256]; + PrintParameterToString( GetNextToken(), DST_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + + // If ps_1_4, texcrd also has a source parameter + if ((m_dwMajorVersion == 1) && (m_dwMinorVersion == 4) && (!m_bVertexShader)) + { + StrcatToALUCode( ", " ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + } + + StrcatToALUCode( ";\n" ); +} + +void D3DToGL::HandleBinaryOp_GLSL( uint32 nInstruction ) +{ + uint32 nDestToken = GetNextToken(); + CUtlString sParam1 = GetParameterString( nDestToken, DST_REGISTER, false, NULL ); + int nARLComp0 = ARL_DEST_NONE; + CUtlString sParam2 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp0 ); + int nARLComp1 = ARL_DEST_NONE; + CUtlString sParam3 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp1 ); + + // This optionally inserts a move from our dummy address register to the .x component of the real one + InsertMoveFromAddressRegister( m_pBufALUCode, nARLComp0, nARLComp1 ); + + // DST is a weird one. I haven't seen it used anywhere yet but can add support if necessary. This is what it does: + // dest.x = 1; + // dest.y = src0.y * src1.y; + // dest.z = src0.z; + // dest.w = src1.w; + Assert( nInstruction != D3DSIO_DST ); + + // Since DP3 and DP4 have a scalar as the dest and vectors as the src, don't screw with the swizzle specifications. + if ( nInstruction == D3DSIO_DP3 ) + { + sParam2 = EnsureNumSwizzleComponents( sParam2, 3 ); + sParam3 = EnsureNumSwizzleComponents( sParam3, 3 ); + } + else if ( nInstruction == D3DSIO_DP4 ) + { + sParam2 = EnsureNumSwizzleComponents( sParam2, 4 ); + sParam3 = EnsureNumSwizzleComponents( sParam3, 4 ); + } + else + { + sParam2 = FixGLSLSwizzle( sParam1, sParam2 ); + sParam3 = FixGLSLSwizzle( sParam1, sParam3 ); + } + + char buff[256]; + if ( nInstruction == D3DSIO_ADD || nInstruction == D3DSIO_SUB || nInstruction == D3DSIO_MUL ) + { + // These all look like x = y op z + PrintToBuf( *m_pBufALUCode, "%s = %s %s %s;\n", sParam1.String(), sParam2.String(), GetGLSLOperatorString( nInstruction ), sParam3.String() ); + } + else + { + if ( ( nInstruction == D3DSIO_SGE ) || ( nInstruction == D3DSIO_SLT ) ) + { + sParam2 = FixGLSLSwizzle( sParam1, sParam2 ); + sParam3 = FixGLSLSwizzle( sParam1, sParam3 ); + } + + int nDestComponents = GetNumSwizzleComponents( sParam1.String() ); + int nSrcComponents = GetNumSwizzleComponents( sParam2.String() ); + + // All remaining instructions can use GLSL intrinsics like dot() and cross(). + bool bDoubleClose = OpenIntrinsic( nInstruction, buff, sizeof( buff ), nDestComponents, nSrcComponents ); + + if ( ( nSrcComponents == 1 ) && ( nInstruction == D3DSIO_SGE ) ) + { + PrintToBuf( *m_pBufALUCode, "%s = %s%s >= %s );\n", sParam1.String(), buff, sParam2.String(), sParam3.String() ); + } + else if ( ( nSrcComponents == 1 ) && ( nInstruction == D3DSIO_SLT ) ) + { + PrintToBuf( *m_pBufALUCode, "%s = %s%s < %s );\n", sParam1.String(), buff, sParam2.String(), sParam3.String() ); + } + else + { + PrintToBuf( *m_pBufALUCode, "%s = %s%s, %s %s;\n", sParam1.String(), buff, sParam2.String(), sParam3.String(), bDoubleClose ? ") )" : ")" ); + } + } + + // If the _SAT instruction modifier is used, then do a saturate here. + if ( nDestToken & D3DSPDM_SATURATE ) + { + int nComponents = GetNumSwizzleComponents( sParam1.String() ); + if ( nComponents == 0 ) + nComponents = 4; + + PrintToBuf( *m_pBufALUCode, "%s = clamp( %s, %s, %s );\n", sParam1.String(), sParam1.String(), g_szVecZeros[nComponents], g_szVecOnes[nComponents] ); + } +} + +void D3DToGL::HandleBinaryOp_ASM( uint32 nInstruction ) +{ + CUtlString sParam1 = GetParameterString( GetNextToken(), DST_REGISTER, false, NULL ); + int nARLComp0 = ARL_DEST_NONE; + CUtlString sParam2 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp0 ); + int nARLComp1 = ARL_DEST_NONE; + CUtlString sParam3 = GetParameterString( GetNextToken(), SRC_REGISTER, false, &nARLComp1 ); + + // This optionally inserts a move from our dummy address register to the .x component of the real one + InsertMoveFromAddressRegister( m_pBufALUCode, nARLComp0, nARLComp1 ); + + char buff[256]; + PrintOpcode( nInstruction, buff, sizeof( buff ) ); + PrintToBuf( *m_pBufALUCode, "%s%s, %s, %s;\n", buff, sParam1.String(), sParam2.String(), sParam3.String() ); +} + +void D3DToGL::WriteGLSLCmp( const char *pDestReg, const char *pSrc0Reg, const char *pSrc1Reg, const char *pSrc2Reg ) +{ + int nWriteMaskEntries = GetNumWriteMaskEntries( pDestReg ); + for ( int i=0; i < nWriteMaskEntries; i++ ) + { + char params[4][256]; + WriteParamWithSingleMaskEntry( pDestReg, i, params[0], sizeof( params[0] ) ); + WriteParamWithSingleMaskEntry( pSrc0Reg, i, params[1], sizeof( params[1] ) ); + WriteParamWithSingleMaskEntry( pSrc1Reg, i, params[2], sizeof( params[2] ) ); + WriteParamWithSingleMaskEntry( pSrc2Reg, i, params[3], sizeof( params[3] ) ); + + PrintToBuf( *m_pBufALUCode, "%s = ( %s >= 0.0 ) ? %s : %s;\n", params[0], params[1], params[2], params[3] ); + } +} + +void D3DToGL::Handle_CMP() +{ + // In Direct3D, result = (src0 >= 0.0) ? src1 : src2 + // In OpenGL, result = (src0 < 0.0) ? src1 : src2 + // + // As a result, arguments are effectively in a different order than Direct3D! !#$&*!%#$& + char pDestReg[64], pSrc0Reg[64], pSrc1Reg[64], pSrc2Reg[64]; + uint32 nDestToken = GetNextToken(); + PrintParameterToString( nDestToken, DST_REGISTER, pDestReg, sizeof( pDestReg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc0Reg, sizeof( pSrc0Reg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc1Reg, sizeof( pSrc1Reg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc2Reg, sizeof( pSrc2Reg ), false, NULL ); + + if ( m_bGLSL ) + { + // These are a tricky case.. we have to expand it out into multiple statements. + char szDestBase[256]; + GetParamNameWithoutSwizzle( pDestReg, szDestBase, sizeof( szDestBase ) ); + + V_strncpy( pSrc0Reg, FixGLSLSwizzle( pDestReg, pSrc0Reg ), sizeof( pSrc0Reg ) ); + V_strncpy( pSrc1Reg, FixGLSLSwizzle( pDestReg, pSrc1Reg ), sizeof( pSrc1Reg ) ); + V_strncpy( pSrc2Reg, FixGLSLSwizzle( pDestReg, pSrc2Reg ), sizeof( pSrc2Reg ) ); + + if ( DoParamNamesMatch( pDestReg, pSrc0Reg ) && GetNumSwizzleComponents( pDestReg ) > 1 ) + { + // So the dest register is the same as the comperand. We're in danger of screwing up our results. + // + // For example, this code: + // CMP r0.xy, r0.xx, r1, r2 + // would generate this: + // r0.x = (r0.x >= 0) ? r1.x : r2.x; + // r0.y = (r0.x >= 0) ? r1.x : r2.x; + // + // But the first lines changes r0.x and thus screws the atomicity of the CMP instruction for the second line. + // So we assign r0 to a temporary first and then write to the temporary. + PrintToBuf( *m_pBufALUCode, "%s = %s;\n", g_pAtomicTempVarName, szDestBase ); + + char szTempVar[256]; + ReplaceParamName( pDestReg, g_pAtomicTempVarName, szTempVar, sizeof( szTempVar ) ); + WriteGLSLCmp( szTempVar, pSrc0Reg, pSrc1Reg, pSrc2Reg ); + + PrintToBuf( *m_pBufALUCode, "%s = %s;\n", szDestBase, g_pAtomicTempVarName ); + m_bUsedAtomicTempVar = true; + } + else + { + // Just write out the simple expanded version of the CMP. No need to use atomic_temp_var. + WriteGLSLCmp( pDestReg, pSrc0Reg, pSrc1Reg, pSrc2Reg ); + } + + // If the _SAT instruction modifier is used, then do a saturate here. + if ( nDestToken & D3DSPDM_SATURATE ) + { + int nComponents = GetNumSwizzleComponents( pDestReg ); + if ( nComponents == 0 ) + nComponents = 4; + + PrintToBuf( *m_pBufALUCode, "%s = clamp( %s, %s, %s );\n", pDestReg, pDestReg, g_szVecZeros[nComponents], g_szVecOnes[nComponents] ); + } + } + else + { + StrcatToALUCode( "CMP" ); + StrcatToALUCode( pDestReg ); + StrcatToALUCode( ", " ); + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ", " ); + StrcatToALUCode( pSrc2Reg ); // Src 2 | + StrcatToALUCode( ", " ); // |--- Swap these guys from Direct3D's convention + StrcatToALUCode( pSrc1Reg ); // Src 1 | + StrcatToALUCode( ";\n" ); + } +} + +void D3DToGL::Handle_NRM() +{ + char pDestReg[64]; + char pSrc0Reg[64]; + PrintParameterToString( GetNextToken(), DST_REGISTER, pDestReg, sizeof( pDestReg ), false, NULL ); + PrintParameterToString( GetNextToken(), SRC_REGISTER, pSrc0Reg, sizeof( pSrc0Reg ), false, NULL ); + + if ( m_bGLSL ) + { + CUtlString sSrc = EnsureNumSwizzleComponents( pSrc0Reg, 3 ); + PrintToBuf( *m_pBufALUCode, "%s = normalize( %s );\n", pDestReg, sSrc.String() ); + } + else + { + m_bNeedsNRMTemp = true; + + StrcatToALUCode( "DP3 NRM_TEMP.w, " ); + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ", " ); + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ";\nRSQ NRM_TEMP.w, NRM_TEMP.w;\nMUL" ); + StrcatToALUCode( pDestReg ); + StrcatToALUCode( ", NRM_TEMP.w, " ); + StrcatToALUCode( pSrc0Reg ); + StrcatToALUCode( ";\n" ); + } +} + +void D3DToGL::Handle_UnaryOp( uint32 nInstruction ) +{ + uint32 nDestToken = GetNextToken(); + CUtlString sParam1 = GetParameterString( nDestToken, DST_REGISTER, false, NULL ); + CUtlString sParam2 = GetParameterString( GetNextToken(), SRC_REGISTER, ( nInstruction == D3DSIO_MOVA) && !m_bGLSL, NULL ); + sParam2 = FixGLSLSwizzle( sParam1, sParam2 ); + + if ( m_bGLSL ) + { + if ( nInstruction == D3DSIO_MOV ) + { + PrintToBuf( *m_pBufALUCode, "%s = %s;\n", sParam1.String(), sParam2.String() ); + } + else if ( nInstruction == D3DSIO_RSQ ) + { + PrintToBuf( *m_pBufALUCode, "%s = inversesqrt( %s );\n", sParam1.String(), sParam2.String() ); + } + else if ( nInstruction == D3DSIO_RCP ) + { + PrintToBuf( *m_pBufALUCode, "%s = 1.0 / %s;\n", sParam1.String(), sParam2.String() ); + } + else if ( nInstruction == D3DSIO_EXP ) + { + PrintToBuf( *m_pBufALUCode, "%s = exp2( %s );\n", sParam1.String(), sParam2.String() ); + } + else if ( nInstruction == D3DSIO_FRC ) + { + PrintToBuf( *m_pBufALUCode, "%s = fract( %s );\n", sParam1.String(), sParam2.String() ); + } + else if ( nInstruction == D3DSIO_LOG ) // d3d 'log' is log base 2 + { + PrintToBuf( *m_pBufALUCode, "%s = log2( %s );\n", sParam1.String(), sParam2.String() ); + } + else if ( nInstruction == D3DSIO_ABS ) // rbarris did this one, Jason please check + { + PrintToBuf( *m_pBufALUCode, "%s = abs( %s );\n", sParam1.String(), sParam2.String() ); + } + else if ( nInstruction == D3DSIO_MOVA ) + { + m_bDeclareAddressReg = true; + PrintToBuf( *m_pBufALUCode, "%s = %s;\n", sParam1.String(), sParam2.String() ); + + m_nHighestRegister = DXABSTRACT_VS_PARAM_SLOTS - 1; + } + else + { + Error( "Unsupported instruction" ); + } + + // If the _SAT instruction modifier is used, then do a saturate here. + if ( nDestToken & D3DSPDM_SATURATE ) + { + int nComponents = GetNumSwizzleComponents( sParam1.String() ); + if ( nComponents == 0 ) + { + nComponents = 4; + } + + PrintToBuf( *m_pBufALUCode, "%s = clamp( %s, %s, %s );\n", sParam1.String(), sParam1.String(), g_szVecZeros[nComponents], g_szVecOnes[nComponents] ); + } + } + else + { + if ( nInstruction == D3DSIO_MOVA ) + { + m_bDeclareAddressReg = true; + m_nHighestRegister = DXABSTRACT_VS_PARAM_SLOTS - 1; + Assert( m_nHighestRegister < DXABSTRACT_VS_PARAM_SLOTS ); + } + + char buff[256]; + PrintOpcode( nInstruction, buff, sizeof( buff ) ); + PrintToBuf( *m_pBufALUCode, "%s%s, %s;\n", buff, sParam1.String(), sParam2.String() ); + } +} + +void D3DToGL::WriteGLSLSamplerDefinitions() +{ + int nSamplersWritten = 0; + for ( int i=0; i < ARRAYSIZE( m_dwSamplerTypes ); i++ ) + { + if ( m_dwSamplerTypes[i] == SAMPLER_TYPE_2D ) + { + if ( i == m_nShadowDepthSampler ) + { + PrintToBuf( *m_pBufHeaderCode, "uniform sampler2DShadow sampler%d;\n", i ); + } + else + { + PrintToBuf( *m_pBufHeaderCode, "uniform sampler2D sampler%d;\n", i ); + } + ++nSamplersWritten; + } + else if ( m_dwSamplerTypes[i] == SAMPLER_TYPE_3D ) + { + PrintToBuf( *m_pBufHeaderCode, "uniform sampler3D sampler%d;\n", i ); + ++nSamplersWritten; + } + else if ( m_dwSamplerTypes[i] == SAMPLER_TYPE_CUBE ) + { + PrintToBuf( *m_pBufHeaderCode, "uniform samplerCube sampler%d;\n", i ); + ++nSamplersWritten; + } + else if ( m_dwSamplerTypes[i] != SAMPLER_TYPE_UNUSED ) + { + Error( "Unknown sampler type." ); + } + } + + if ( nSamplersWritten > 0 ) + PrintToBuf( *m_pBufHeaderCode, "\n\n" ); +} + +void D3DToGL::WriteGLSLOutputVariableAssignments() +{ + if ( m_bVertexShader ) + { + // Map output "oN" registers back to GLSL output variables. + if ( m_bAddHexCodeComments ) + { + PrintToBuf( *m_pBufAttribCode, "\n// Now we're storing the oN variables from the output dcl_ statements back into their GLSL equivalents.\n" ); + } + + for ( int i=0; i < ARRAYSIZE( m_DeclaredOutputs ); i++ ) + { + if ( m_DeclaredOutputs[i] == UNDECLARED_OUTPUT ) + continue; + + CUtlString sOutputName = GetUsageAndIndexString( m_DeclaredOutputs[i], SEMANTIC_OUTPUT ); + PrintToBuf( *m_pBufAttribCode, "%s = oT%d;\n", sOutputName.String(), i ); + } + } +} + +void D3DToGL::Handle_DeclarativeNonDclOp( uint32 nInstruction ) +{ + char buff[128]; + uint32 dwToken = GetNextToken(); + PrintParameterToString( dwToken, DST_REGISTER, buff, sizeof( buff ), false, NULL ); + + if ( m_bGLSL && nInstruction == D3DSIO_TEXKILL ) + { + // TEXKILL is supposed to discard the pixel if any of the src register's X, Y, or Z components are less than zero. + // We have to translate it to something like: + // if ( r0.x < 0.0 || r0.y < 0.0 ) + // discard; + char c[3]; + c[0] = GetSwizzleComponent( buff, 0 ); + c[1] = GetSwizzleComponent( buff, 1 ); + c[2] = GetSwizzleComponent( buff, 2 ); + + // Get the unique components. + char cUnique[3]; + cUnique[0] = c[0]; + + int nUnique = 1; + if ( c[1] != c[0] ) + cUnique[nUnique++] = c[1]; + + if ( c[2] != c[1] && c[2] != c[0] ) + cUnique[nUnique++] = c[2]; + + // Get the src register base name. + char szBase[256]; + GetParamNameWithoutSwizzle( buff, szBase, sizeof( szBase ) ); + + PrintToBuf( *m_pBufALUCode, "if ( %s.%c < 0.0 ", szBase, cUnique[0] ); + for ( int i=1; i < nUnique; i++ ) + { + PrintToBuf( *m_pBufALUCode, "|| %s.%c < 0.0 ", szBase, cUnique[i] ); + } + PrintToBuf( *m_pBufALUCode, ")\n{\n\tdiscard;\n}\n" ); + } + else + { + char szOpcode[128]; + PrintOpcode( nInstruction, szOpcode, sizeof( szOpcode ) ); + StrcatToALUCode( szOpcode ); + + StrcatToALUCode( buff ); + StrcatToALUCode( ";\n" ); + } +} + + +void D3DToGL::NoteTangentInputUsed() +{ + if ( !m_bTangentInputUsed ) + { + m_bTangentInputUsed = true; +// PrintToBuf( *m_pBufParamCode, "attribute vec4 %s;\n", g_pTangentAttributeName ); + } +} + + +// These are the only ARL instructions that should appear in the instruction stream +void D3DToGL::InsertMoveInstruction( CUtlBuffer *pCode, int nARLComponent ) +{ + switch ( nARLComponent ) + { + case ARL_DEST_X: + strcat_s( ( char * )pCode->Base(), pCode->Size(), m_bGLSL ? "a0 = int( va_r.x );\n" : "ARL a0.x, VA_REG.x;\n" ); + break; + case ARL_DEST_Y: + strcat_s( ( char * )pCode->Base(), pCode->Size(), m_bGLSL ? "a0 = int( va_r.y );\n" : "ARL a0.x, VA_REG.y;\n" ); + break; + case ARL_DEST_Z: + strcat_s( ( char * )pCode->Base(), pCode->Size(), m_bGLSL ? "a0 = int( va_r.z );\n" : "ARL a0.x, VA_REG.z;\n" ); + break; + case ARL_DEST_W: + strcat_s( ( char * )pCode->Base(), pCode->Size(), m_bGLSL ? "a0 = int( va_r.w );\n" : "ARL a0.x, VA_REG.w;\n" ); + break; + } +} + +// This optionally inserts a move from our dummy address register to the .x component of the real one +void D3DToGL::InsertMoveFromAddressRegister( CUtlBuffer *pCode, int nARLComp0, int nARLComp1, int nARLComp2 /* = ARL_DEST_NONE */ ) +{ + int nNumSwizzles = 0; + + if ( nARLComp0 != ARL_DEST_NONE ) + nNumSwizzles++; + + if ( nARLComp1 != ARL_DEST_NONE ) + nNumSwizzles++; + + if ( nARLComp2 != ARL_DEST_NONE ) + nNumSwizzles++; + + // We shouldn't have any more than one indirect address usage in a single instruction + Assert( nNumSwizzles <= 1 ); + + if ( nARLComp0 != ARL_DEST_NONE ) + { + InsertMoveInstruction( pCode, nARLComp0 ); + } + else if ( nARLComp1 != ARL_DEST_NONE ) + { + InsertMoveInstruction( pCode, nARLComp1 ); + } + else if ( nARLComp2 != ARL_DEST_NONE ) + { + InsertMoveInstruction( pCode, nARLComp2 ); + } +} + + +//------------------------------------------------------------------------------ +// TranslateShader() +// +// This is the main function that the outside world sees. A pointer to the +// uint32 stream returned from the D3DX compile routine is parsed and used +// to write human-readable asm code into the character array pointed to by +// pDisassembledCode. An error code is returned. +//------------------------------------------------------------------------------ + +static int g_translationCounter = 0; + +int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bool *bVertexShader, uint32 options, int32 nShadowDepthSampler, uint32 nCentroidMask, char *debugLabel ) +{ + CUtlString sLine, sParamName; + uint32 i, dwToken, nInstruction, nNumTokensToSkip; + char buff[256]; + + // obey options + m_bUseEnvParams = (options & D3DToGL_OptionUseEnvParams) != 0; + m_bDoFixupZ = (options & D3DToGL_OptionDoFixupZ) != 0; + m_bDoFixupY = (options & D3DToGL_OptionDoFixupY) != 0; + m_bDoUserClipPlanes = (options & D3DToGL_OptionDoUserClipPlanes) != 0; + m_bGLSL = (options & D3DToGL_OptionGLSL) != 0; + m_bAllowStaticControlFlow = m_bGLSL && (options & D3DToGL_OptionAllowStaticControlFlow) != 0; + m_bAddHexCodeComments = (options & D3DToGL_AddHexComments) != 0; + m_bPutHexCodesAfterLines = (options & D3DToGL_PutHexCommentsAfterLines) != 0; + m_bGeneratingDebugText = (options & D3DToGL_GeneratingDebugText) != 0; + m_bUseBindableUniforms = (options & D3DToGL_OptionUseBindableUniforms) != 0; + m_bGenerateSRGBWriteSuffix = (options & D3DToGL_OptionSRGBWriteSuffix) != 0; + + m_nLoopDepth = 0; + + // debugging + m_bSpew = (options & D3DToGL_OptionSpew) != 0; + + // m_bSpew |= (g_translationCounter == 1012 ); // interested in this specific translation run + + // These are not accessed below in a way that will cause them to glow, so + // we could overflow these and/or the buffer pointed to by pDisassembledCode + m_pBufAttribCode = new CUtlBuffer( 100, 10000, CUtlBuffer::TEXT_BUFFER ); + m_pBufParamCode = new CUtlBuffer( 100, 10000, CUtlBuffer::TEXT_BUFFER ); + m_pBufALUCode = new CUtlBuffer( 100, 60000, CUtlBuffer::TEXT_BUFFER ); + + // Pointers to text buffers for assembling sections of the program + m_pBufHeaderCode = pBufDisassembledCode; + char *pAttribMapStart = NULL; + ((char*)m_pBufHeaderCode->Base())[0] = 0; + ((char*)m_pBufAttribCode->Base())[0] = 0; + ((char*)m_pBufParamCode->Base())[0] = 0; + ((char*)m_pBufALUCode->Base())[0] = 0; + + + for ( i=0; iBase(), m_pBufHeaderCode->Size(), m_bGLSL ? "#version 120\n%s" : "!!ARBfp1.0\n%s", glslBindableUniformExtText ); + m_bVertexShader = false; + } + else // vertex shader + { + m_bGenerateSRGBWriteSuffix = false; + + if ( m_bGLSL ) + { + V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "#version 120\n%s//ATTRIBMAP-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx\n", glslBindableUniformExtText ); + } + else // asm + { + if ( m_bDoUserClipPlanes ) + { + // include "OPTION NV_vertex_program2;" + V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "!!ARBvp1.0\n#//ATTRIBMAP-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx\nOPTION NV_vertex_program2;\n" ); + } + else + { + // do not include "OPTION NV_vertex_program2;" + V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "!!ARBvp1.0\n#//ATTRIBMAP-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx\n" ); + } + } + + // find that first '-xx' which is where the attrib map will be written later. + pAttribMapStart = strstr( (char *)m_pBufHeaderCode->Base(), "-xx" ) + 1; + + m_bVertexShader = true; + } + + *bVertexShader = m_bVertexShader; + + if ( m_bAddHexCodeComments ) + { + RecordInputAndOutputPositions(); + } + + if ( m_bSpew ) + { + printf("\n************* translating shader " ); + } + + int opcounter = 0; + + // Loop until we hit the end dwToken...note that D3DPS_END() == D3DVS_END() so this works for either + while ( dwToken != D3DPS_END() ) + { + if ( m_bAddHexCodeComments ) + { + AddTokenHexCode(); + RecordInputAndOutputPositions(); + } + +#ifdef POSIX + int tokenIndex = m_pdwNextToken - code; +#endif + int aluCodeLength0 = V_strlen( (char *) m_pBufALUCode->Base() ); + + dwToken = GetNextToken(); // Get next dwToken in the stream + nInstruction = Opcode( dwToken ); // Mask out the instruction opcode + + if ( m_bSpew ) + { +#ifdef POSIX + printf("\n** token# %04x inst# %04d opcode %s (%08x)", tokenIndex, opcounter, GLMDecode(eD3D_SIO, nInstruction), dwToken ); +#endif + opcounter++; + } + + switch ( nInstruction ) + { + // -- No arguments at all ----------------------------------------------- + case D3DSIO_NOP: + case D3DSIO_PHASE: + case D3DSIO_RET: + case D3DSIO_ENDLOOP: + case D3DSIO_BREAK: + Assert(0); + PrintOpcode( nInstruction, buff, sizeof( buff ) ); + StrcatToALUCode( buff ); + StrcatToALUCode( ";\n" ); + break; + + // -- "Declarative" non dcl ops ---------------------------------------- + case D3DSIO_TEXDEPTH: + case D3DSIO_TEXKILL: + Handle_DeclarativeNonDclOp( nInstruction ); + break; + + // -- Unary ops ------------------------------------------------- + case D3DSIO_BEM: + case D3DSIO_TEXBEM: + case D3DSIO_TEXBEML: + case D3DSIO_TEXDP3: + case D3DSIO_TEXDP3TEX: + case D3DSIO_TEXM3x2DEPTH: + case D3DSIO_TEXM3x2TEX: + case D3DSIO_TEXM3x3: + case D3DSIO_TEXM3x3PAD: + case D3DSIO_TEXM3x3TEX: + case D3DSIO_TEXM3x3VSPEC: + case D3DSIO_TEXREG2AR: + case D3DSIO_TEXREG2GB: + case D3DSIO_TEXREG2RGB: + case D3DSIO_LABEL: + case D3DSIO_CALL: + case D3DSIO_LOOP: + case D3DSIO_BREAKP: + case D3DSIO_DSX: + case D3DSIO_DSY: + Assert(0); + break; + + case D3DSIO_IF: + Assert( m_bGLSL && m_bAllowStaticControlFlow ); + if ( m_bGLSL && m_bAllowStaticControlFlow ) + { + dwToken = GetNextToken(); + PrintParameterToString( dwToken, SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + + // In practice, this is the only form of for loop that will appear in DX asm + PrintToBuf( *m_pBufALUCode, "if ( %s ) {\n", buff ); + } + break; + + case D3DSIO_ELSE: + Assert( m_bGLSL && m_bAllowStaticControlFlow ); + if ( m_bGLSL && m_bAllowStaticControlFlow ) + { + StrcatToALUCode( "}\nelse\n{\n" ); + } + break; + + case D3DSIO_ENDIF: + Assert( m_bGLSL && m_bAllowStaticControlFlow ); + if ( m_bGLSL && m_bAllowStaticControlFlow ) + { + StrcatToALUCode( "}\n" ); + } + break; + + case D3DSIO_REP: // Start a for loop - GLSL only + Assert( m_bGLSL && m_bAllowStaticControlFlow ); + if ( m_bGLSL && m_bAllowStaticControlFlow ) + { + dwToken = GetNextToken(); + PrintParameterToString( dwToken, SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + + // In practice, this is the only form of for loop that will appear in DX asm + PrintToBuf( *m_pBufALUCode, "for( int i=0; i < %s; i++ ) {\n", buff ); + + m_nLoopDepth++; + + // For now, we don't deal with loop nesting + // Easy enough to fix later with an array of loop names i, j, k etc + Assert( m_nLoopDepth <= 1 ); + } + break; + + case D3DSIO_ENDREP: + Assert( m_bGLSL && m_bAllowStaticControlFlow ); + if ( m_bGLSL && m_bAllowStaticControlFlow ) + { + m_nLoopDepth--; + StrcatToALUCode( "}\n" ); + } + break; + + case D3DSIO_NRM: + Handle_NRM(); + break; + + case D3DSIO_MOVA: + + if ( m_bGLSL ) + { + Handle_UnaryOp( nInstruction ); + } + else // asm + { + m_bDeclareAddressReg = true; + m_nHighestRegister = DXABSTRACT_VS_PARAM_SLOTS - 1; + + PrintOpcode( nInstruction, buff, sizeof( buff ) ); + StrcatToALUCode( buff ); + + dwToken = GetNextToken(); + PrintParameterToString( dwToken, DST_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ", " ); + + dwToken = GetNextToken(); + PrintParameterToString( dwToken, SRC_REGISTER, buff, sizeof( buff ), false, NULL ); + StrcatToALUCode( buff ); + StrcatToALUCode( ";\n" ); + } + + break; + + // Unary operations + case D3DSIO_MOV: + case D3DSIO_RCP: + case D3DSIO_RSQ: + case D3DSIO_EXP: + case D3DSIO_EXPP: + case D3DSIO_LOG: + case D3DSIO_LOGP: + case D3DSIO_FRC: + case D3DSIO_LIT: + case D3DSIO_ABS: + Handle_UnaryOp( nInstruction ); + break; + + // -- Binary ops ------------------------------------------------- + case D3DSIO_TEXM3x3SPEC: + case D3DSIO_M4x4: + case D3DSIO_M4x3: + case D3DSIO_M3x4: + case D3DSIO_M3x3: + case D3DSIO_M3x2: + case D3DSIO_CALLNZ: + case D3DSIO_IFC: + case D3DSIO_BREAKC: + case D3DSIO_SETP: + Assert(0); + break; + + // Binary Operations + case D3DSIO_ADD: + case D3DSIO_SUB: + case D3DSIO_MUL: + case D3DSIO_DP3: + case D3DSIO_DP4: + case D3DSIO_MIN: + case D3DSIO_MAX: + case D3DSIO_DST: + case D3DSIO_SLT: + case D3DSIO_SGE: + case D3DSIO_CRS: + case D3DSIO_POW: + if ( m_bGLSL ) + { + HandleBinaryOp_GLSL( nInstruction ); + } + else + { + HandleBinaryOp_ASM( nInstruction ); + } + break; + + // -- Ternary ops ------------------------------------------------- + case D3DSIO_DP2ADD: + Handle_DP2ADD(); + break; + case D3DSIO_LRP: + Handle_LRP( nInstruction ); + break; + case D3DSIO_SGN: + Assert( m_bVertexShader ); + Assert(0); // TODO emulate with SLT etc + break; + case D3DSIO_CND: + Assert(0); + break; + case D3DSIO_CMP: + Handle_CMP(); + break; + case D3DSIO_SINCOS: + Handle_SINCOS(); + break; + case D3DSIO_MAD: + Handle_MAD( nInstruction ); + break; + + // -- Quaternary op ------------------------------------------------ + case D3DSIO_TEXLDD: + Handle_TexLDD( nInstruction ); + break; + + // -- Special cases: texcoord vs texcrd and tex vs texld ----------- + case D3DSIO_TEXCOORD: + Handle_TexCoord(); + break; + + case D3DSIO_TEX: + Handle_TEX( dwToken, false ); + break; + + case D3DSIO_TEXLDL: + Handle_TEX( nInstruction, true ); + break; + + case D3DSIO_DCL: + Handle_DCL(); + break; + + case D3DSIO_DEFB: + case D3DSIO_DEFI: + // Shouldn't be using bool or integer constants + Assert(0); + break; + + case D3DSIO_DEF: + Handle_DEF(); + break; + + case D3DSIO_COMMENT: + // Using OpcodeSpecificData() can fail here since the comments can be longer than 0xff dwords + nNumTokensToSkip = ( dwToken & 0x0fff0000 ) >> 16; + SkipTokens( nNumTokensToSkip ); + break; + + case D3DSIO_END: + break; + } + + if ( m_bSpew ) + { + int aluCodeLength1 = V_strlen( (char *) m_pBufALUCode->Base() ); + if ( aluCodeLength1 != aluCodeLength0 ) + { + // code was emitted + printf( "\n > %s", ((char *)m_pBufALUCode->Base()) + aluCodeLength0 ); + + aluCodeLength0 = aluCodeLength1; + } + } + } + + // Note that this constant packing expects .wzyx swizzles in case we ever use the SINCOS code in a ps_2_x shader + // + // The Microsoft documentation on this is all kinds of broken and, strangely, these numbers don't even + // match the D3DSINCOSCONST1 and D3DSINCOSCONST2 constants used by the D3D assembly sincos instruction... + if ( m_bNeedsSinCosDeclarations ) + { + if ( m_bGLSL ) + { + StrcatToParamCode( "vec4 scA = vec4( -1.55009923e-6, -2.17013894e-5, 0.00260416674, 0.00026041668 );\n" ); + StrcatToParamCode( "vec4 scB = vec4( -0.020833334, -0.125, 1.0, 0.5 );\n" ); + } + else + { + StrcatToParamCode( "PARAM scA = { -1.55009923e-6, -2.17013894e-5, 0.00260416674, 0.00026041668 };\n" ); + StrcatToParamCode( "PARAM scB = { -0.020833334, -0.125, 1.0, 0.5 };\n" ); + } + } + + // Stick in the sampler mask in hex + PrintToBuf( *m_pBufHeaderCode, "%sSAMPLERMASK-%x\n", m_bGLSL ? "//" : "#", m_dwSamplerUsageMask ); + + // Uniforms + if ( m_bGLSL ) + { + PrintToBuf( *m_pBufHeaderCode, "//HIGHWATER-%d\n", m_nHighestRegister ); + PrintToBuf( *m_pBufHeaderCode, "\n%suniform vec4 %s[%d];\n", m_bUseBindableUniforms ? "bindable " : "", m_bVertexShader ? "vc" : "pc", m_nHighestRegister + 1 ); + + // On GLSL vertex shaders, we may have integer and boolean constants + if ( m_bAllowStaticControlFlow && m_bVertexShader ) + { + for( int i=0; i<32; i++ ) + { + if ( m_dwConstIntUsageMask & ( 0x00000001 << i ) ) + { + PrintToBuf( *m_pBufHeaderCode, "uniform int i%d;\n", i ); + } + } + + for( int i=0; i<32; i++ ) + { + if ( m_dwConstBoolUsageMask & ( 0x00000001 << i ) ) + { + PrintToBuf( *m_pBufHeaderCode, "uniform bool b%d;\n", i ); + } + } + } + + // Control bit for sRGB Write suffix + if ( m_bGenerateSRGBWriteSuffix ) + { + // R500 Hookup + // Set this guy to 1 when the sRGBWrite state is true, otherwise 0 + StrcatToHeaderCode( "uniform float flSRGBWrite;\n" ); + } + + PrintToBuf( *m_pBufHeaderCode, "\n" ); + + // Write samplers + WriteGLSLSamplerDefinitions(); + } + else + { + PrintToBuf( *m_pBufParamCode, "#HIGHWATER-%d\n", m_nHighestRegister ); + PrintToBuf( *m_pBufParamCode, "PARAM %s[%d] = { program.%s[0..%d] };\n", m_bVertexShader ? "vc" : "pc", m_nHighestRegister + 1, m_bUseEnvParams ? "env" : "local", m_nHighestRegister ); + } + + if ( m_bDeclareAddressReg ) + { + m_nHighestRegister = DXABSTRACT_VS_PARAM_SLOTS - 1; + + if ( m_bGLSL ) + { + StrcatToParamCode( "vec4 va_r;\nint a0;\n" ); + } + else + { + StrcatToParamCode( "ADDRESS a0;\n" ); + StrcatToParamCode( "TEMP VA_REG;\n" ); + } + } + + const char *pTempVarStr = "TEMP"; + if ( m_bGLSL ) + { + pTempVarStr = "vec4"; + } + + // Declare temps in Param code buffer + for( int i=0; i<32; i++ ) + { + if ( m_dwTempUsageMask & ( 0x00000001 << i ) ) + { + PrintToBuf( *m_pBufParamCode, "%s r%d;\n", pTempVarStr, i ); + } + } + + if ( m_bGLSL && m_bVertexShader ) + { + StrcatToParamCode( "vec4 vTempPos;\n" ); + } + + if ( m_bNeedsSinCosDeclarations ) + { + if ( m_bGLSL ) + { + StrcatToParamCode( "vec3 vSinCosTmp;\n" ); // declare temp used by GLSL sin and cos intrinsics + } + else + { + PrintToBuf( *m_pBufParamCode, "%s SC_TEMP;\n", pTempVarStr ); + } + } + + // Optional temps needed to emulate d2add instruction in DX pixel shaders + if ( m_bNeedsD2AddTemp ) + { + PrintToBuf( *m_pBufParamCode, "%s DP2A0;\n%s DP2A1;\n", pTempVarStr, pTempVarStr ); + } + + // Optional temp needed to emulate lerp instruction in DX vertex shaders + if ( m_bNeedsLerpTemp ) + { + PrintToBuf( *m_pBufParamCode, "%s LRP_TEMP;\n", pTempVarStr ); + } + + // Optional temp needed to emulate NRM instruction in DX shaders + if ( m_bNeedsNRMTemp ) + { + PrintToBuf( *m_pBufParamCode, "%s NRM_TEMP;\n", pTempVarStr ); + } + + // Pixel shader color outputs (MRT support?...just declare MRT outputs as useless TEMPS) + if ( !m_bGLSL && !m_bVertexShader ) + { + if ( m_bOutputColorRegister[1] ) + { + StrcatToParamCode( "TEMP oC1;\n" ); + } + if ( m_bOutputColorRegister[2] ) + { + StrcatToParamCode( "TEMP oC2;\n" ); + } + if ( m_bOutputColorRegister[3] ) + { + StrcatToParamCode( "TEMP oC3;\n" ); + } + if ( m_bOutputColorRegister[0] ) + { + StrcatToParamCode( "OUTPUT oC0 = result.color;\n" ); + } + } + + if ( m_bDeclareVSOPos && m_bVertexShader ) + { + if ( m_bGLSL ) + { + if (m_bDoUserClipPlanes) + { + StrcatToALUCode( "gl_ClipVertex = vTempPos;\n" ); // if user clip is enabled, jam clip space position into gl_ClipVertex + } + } + + if ( m_bDoFixupZ || m_bDoFixupY ) + { + if ( !m_bGLSL ) + { + // don't write to real reg - declare a temp and then declare a new output reg oPosGL + StrcatToParamCode( "TEMP oPos;\n" ); + StrcatToParamCode( "OUTPUT oPosGL = result.position;\n" ); + } + + // TODO: insert clip distance computation something like this: + // + // StrcatToALUCode( "DP4 oCLP[0].x, oPos, vc[215]; \n" ); + // + + if ( m_bDoFixupZ ) + { + if ( m_bGLSL ) + { + StrcatToALUCode( "vTempPos.z = vTempPos.z * vc[0].z - vTempPos.w; // z' = (2*z)-w\n" ); + } + else + { + // append instructions to perform Z fixup + // new Z = (old Z * 2.0) - W + + // negate Z, double it, then add the 'w'. + // near: Z=0 -> Z' = +1.0. this seems wrong.... + // far: Z=1 -> Z' = -1.0 uh, this ain't right... + // StrcatToALUCode( "MAD r0.z, -oPos.z, vc[0].z, oPos.w; # z' = (2*-z)+w\n" ); + + // double Z, subtract 'w'. + // near: Z=0 -> Z' = -1.0. + // far: Z=1 -> Z' = +1.0 + //StrcatToALUCode( "MAD r0.z, oPos.z, vc[0].z, -oPos.w; # z' = (2*z)-w\n" ); + StrcatToALUCode( "MAD oPos.z, oPos.z, vc[0].z, -oPos.w; # z' = (2*z)-w\n" ); + } + } + + if ( m_bDoFixupY ) + { + // append instructions to flip Y over + // new Y = -(old Y) + if ( m_bGLSL ) + { + StrcatToALUCode( "vTempPos.y = -vTempPos.y; // y' = -y \n" ); + } + else + { + StrcatToALUCode( "MOV oPos.y, -oPos.y; # y' = -y \n" ); + } + } + + if ( m_bGLSL ) + { + StrcatToALUCode( "gl_Position = vTempPos;\n" ); + } + else + { + StrcatToALUCode( "MOV oPosGL, oPos;\n" ); + } + + } + else + { + StrcatToParamCode( "OUTPUT oPos = result.position;\n" ); + + // TODO: insert clip distance computation something like this: + // + // StrcatToALUCode( "DP4 oCLP[0].x, oPos, c[215]; \n" ); + // + } + } + + if ( m_bVertexShader && m_bDoUserClipPlanes && !m_bGLSL ) + { + // insert oCLP generation instructions + char temp[256]; + + if(0) + { + V_snprintf( temp, sizeof( temp ), "DP4 result.clip[0].x, oPos, c[%d];\n", DXABSTRACT_VS_CLIP_PLANE_BASE ); // ask GLM where to stash the secret params + V_snprintf( temp, sizeof( temp ), "DP4 result.clip[1].x, oPos, c[%d];\n", DXABSTRACT_VS_CLIP_PLANE_BASE+1 ); + } + + if(0) + { + V_snprintf( temp, sizeof( temp ), "DP4 o[CLP0].x, oPos, c[%d];\n", DXABSTRACT_VS_CLIP_PLANE_BASE ); // ask GLM where to stash the secret params + V_snprintf( temp, sizeof( temp ), "DP4 o[CLP1].x, oPos, c[%d];\n", DXABSTRACT_VS_CLIP_PLANE_BASE+1 ); + } + + if(1) + { + V_snprintf( temp, sizeof( temp ), "DP4 oClip0.x, oPos, c[%d];\n", DXABSTRACT_VS_CLIP_PLANE_BASE ); // ask GLM where to stash the secret params + V_snprintf( temp, sizeof( temp ), "DP4 oClip1.x, oPos, c[%d];\n", DXABSTRACT_VS_CLIP_PLANE_BASE+1 ); + } + + StrcatToALUCode( temp ); + } + + if ( m_bGLSL ) + { + if ( m_bVertexShader ) + { + for ( int i=0; i<32; i++ ) + { + char outTexCoordBuff[64]; + if ( m_dwTexCoordOutMask & ( 0x00000001 << i ) ) + { + if ( m_nCentroidMask & ( 0x00000001 << i ) ) + { + V_snprintf( outTexCoordBuff, sizeof( outTexCoordBuff ), "centroid varying vec4 oT%d;\n", i ); // centroid varying + StrcatToHeaderCode( outTexCoordBuff ); + } + else + { + V_snprintf( outTexCoordBuff, sizeof( outTexCoordBuff ), "varying vec4 oT%d;\n", i ); + StrcatToHeaderCode( outTexCoordBuff ); + } + } + } + } + } + else // asm + { + if ( m_bDeclareVSOFog && m_bVertexShader ) + { + StrcatToParamCode( "OUTPUT oFog = result.fogcoord;\n" ); + } + + for ( int i=0; i<32; i++ ) + { + char outTexCoordBuff[64]; + if ( m_dwTexCoordOutMask & ( 0x00000001 << i ) ) + { + V_snprintf( outTexCoordBuff, sizeof( outTexCoordBuff ), "OUTPUT oT%d = result.texcoord[%d];\n", i, i ); + StrcatToParamCode( outTexCoordBuff ); + } + } + + if ( m_bOutputColorRegister[0] && m_bVertexShader ) + { + StrcatToParamCode( "OUTPUT oD0 = result.color;\n" ); + } + + if ( m_bOutputColorRegister[1] && m_bVertexShader ) + { + StrcatToParamCode( "OUTPUT oD1 = result.color.secondary;\n" ); + } + } + + if ( m_bOutputDepthRegister && !m_bVertexShader && !m_bGLSL ) + { + StrcatToParamCode( "OUTPUT oDepth = result.depth;\n" ); + } + + if ( m_bDoUserClipPlanes && m_bVertexShader && !m_bGLSL ) + { + StrcatToParamCode( "OUTPUT oClip0 = result.clip[0];\n" ); + StrcatToParamCode( "OUTPUT oClip1 = result.clip[1];\n" ); + } + + // do some annotation at the end of the attrib block + { + char temp[1000]; + + if ( m_bVertexShader ) + { + // write attrib map into the text starting at pAttribMapStart - two hex digits per attrib + for( int i=0; i<16; i++ ) + { + if ( m_dwAttribMap[i] != 0xFFFFFFFF ) + { + V_snprintf( temp, sizeof(temp), "%02X", m_dwAttribMap[i] ); + memcpy( pAttribMapStart + (i*3), temp, 2 ); + } + } + } + + V_snprintf( temp, sizeof(temp), "%s trans#%d label:%s\n", m_bGLSL ? "//" : "#", g_translationCounter, debugLabel ? debugLabel : "none" ); + StrcatToAttribCode( temp ); + + g_translationCounter++; + } + + // If we actually sample from a shadow depth sampler, we need to declare the shadow option at the top + if ( m_bDeclareShadowOption ) + { + StrcatToHeaderCode( "OPTION ARB_fragment_program_shadow;\n" ); + } + + if ( m_bGLSL ) + { + StrcatToHeaderCode( "\nvoid main()\n{\n" ); + if ( m_bUsedAtomicTempVar ) + { + PrintToBuf( *m_pBufHeaderCode, "vec4 %s;\n\n", g_pAtomicTempVarName ); + } + } + + // sRGB Write suffix + if ( m_bGenerateSRGBWriteSuffix ) + { + Assert( m_bGLSL ); + if ( m_bGLSL ) + { + StrcatToALUCode( "vec3 sRGBFragData;\n" ); + StrcatToALUCode( "sRGBFragData.xyz = log( gl_FragData[0].xyz );\n" ); + StrcatToALUCode( "sRGBFragData.xyz = sRGBFragData.xyz * vec3( 0.454545f, 0.454545f, 0.454545f );\n" ); + StrcatToALUCode( "sRGBFragData.xyz = exp( sRGBFragData.xyz );\n" ); + StrcatToALUCode( "gl_FragData[0].xyz = mix( gl_FragData[0].xyz, sRGBFragData, flSRGBWrite );\n" ); + } + } + + if ( m_bGLSL ) + { + WriteGLSLOutputVariableAssignments(); + StrcatToALUCode( "\n}\n" ); + } + else + { + StrcatToALUCode( "END\n\0" ); + } + + // Put all of the strings together for final program ( pHeaderCode + pAttribCode + pParamCode + pALUCode ) + StrcatToHeaderCode( (char*)m_pBufAttribCode->Base() ); + StrcatToHeaderCode( (char*)m_pBufParamCode->Base() ); + StrcatToHeaderCode( (char*)m_pBufALUCode->Base() ); + + // Cleanup - don't touch m_pBufHeaderCode, as it is managed by the caller + delete m_pBufAttribCode; + delete m_pBufParamCode; + delete m_pBufALUCode; + m_pBufAttribCode = m_pBufParamCode = m_pBufALUCode = NULL; + + if ( m_bSpew ) + { + printf("\n************* translation complete\n\n " ); + } + + return DISASM_OK; +} diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/dx9asmtogl2.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/dx9asmtogl2.h new file mode 100644 index 0000000..41ce477 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/dx9asmtogl2.h @@ -0,0 +1,233 @@ +//------------------------------------------------------------------------------ +// DX9AsmToGL2.h +//------------------------------------------------------------------------------ + +#ifndef DX9_ASM_TO_GL_2_H +#define DX9_ASM_TO_GL_2_H + +#include "glmgr.h" + +//============================================================================== + + +#define DISASM_OK 0 +#define DISASM_ERROR 1 + +#define MAX_SHADER_CONSTANTS 512 + +#define MAX_DECLARED_OUTPUTS 32 + +#define HEXCODE_HEADER "// Hex: " + +// Option bits +#define D3DToGL_OptionUseEnvParams 0x001 +#define D3DToGL_OptionDoFixupZ 0x002 // Add instructions to put Z in the right interval for GL +#define D3DToGL_OptionDoFixupY 0x004 // Add instructions to flip the Y over for GL +#define D3DToGL_OptionDoUserClipPlanes 0x008 // ARB mode: Include OPTION vertex_program_2 and append DP4's to write into oCLP[0] and oCLP[1] + // GLSL mode: generate code to write gl_ClipVertex +#define D3DToGL_OptionGLSL 0x010 // Output GLSL, rather than ASM +#define D3DToGL_AddHexComments 0x020 // Include hex comments in the code for debugging +#define D3DToGL_PutHexCommentsAfterLines 0x040 // If D3DToGL_AddHexComments is set, this puts the codes to the right, rather than on separate lines +#define D3DToGL_GeneratingDebugText 0x080 // This tells it that we're just getting info for debugging so go easy on asserts and errors +#define D3DToGL_OptionAllowStaticControlFlow 0x100 +#define D3DToGL_OptionUseBindableUniforms 0x200 // add "bindable" in front of "vc" / "pc" constant arrays (GLSL only) +#define D3DToGL_OptionSRGBWriteSuffix 0x400 // Tack sRGB conversion suffix on to pixel shaders +#define D3DToGL_OptionSpew 0x80000000 + +// Code for which component of the "dummy" address register is needed by an instruction +#define ARL_DEST_NONE -1 +#define ARL_DEST_X 0 +#define ARL_DEST_Y 1 +#define ARL_DEST_Z 2 +#define ARL_DEST_W 3 + +class D3DToGL +{ +private: + // Pointers for dwToken stream management + uint32* m_pdwBaseToken; + uint32* m_pdwNextToken; + + // Vertex shader or pixel shader, and version (necessary because some opcodes alias) + bool m_bVertexShader; + uint32 m_dwMinorVersion; + uint32 m_dwMajorVersion; + + // Option flags + bool m_bUseEnvParams; // set D3DToGL_OptionUseEnvParams in 'options' to use + bool m_bDoFixupZ; // set D3DToGL_OptionDoFixupZ + bool m_bDoFixupY; // set D3DToGL_OptionDoFixupZ + bool m_bDoUserClipPlanes; // set D3DToGL_OptionDoUserClipPlanes + bool m_bSpew; // set D3DToGL_OptionSpew + bool m_bUseBindableUniforms; // set D3DToGL_OptionUseBindableUniforms + bool m_bGenerateSRGBWriteSuffix; // set D3DToGL_OptionSRGBWriteSuffix + + // Default: false + // If you set this to true, it'll convert to GLSL instead of GL ASM. + bool m_bGLSL; // set D3DToGL_OptionGLSL + + // Default: false + bool m_bAllowStaticControlFlow; // set D3DToGL_OptionAllowStaticControlFlow + + // Counter for dealing with nested loops + int m_nLoopDepth; + + // Add "// Hex: 0xFFEEF00"-type statements after each instruction is parsed. + bool m_bAddHexCodeComments; // set D3DToGL_AddHexComments + + // Only applicable if m_bAddHexCodeComments is true. + // If this is true, then it puts the hex code comments to the right of the instructions in a comment + // rather than preceding the instructions. + // Defaults to FALSE. + bool m_bPutHexCodesAfterLines; // set D3DToGL_PutHexCommentsAtEnd + + // This tells it that we're just getting info for debugging so go easy on asserts and errors. + // Defaults to FALSE. + bool m_bGeneratingDebugText; + + // Various scratch temps needed to handle mis-matches in instruction sets between D3D and OpenGL + bool m_bNeedsD2AddTemp; + bool m_bNeedsNRMTemp; + bool m_bDeclareAddressReg; + bool m_bNeedsLerpTemp; + bool m_bNeedsSinCosDeclarations; + + // Keep track of which vs outputs are used so we can declare them + bool m_bDeclareVSOPos; + bool m_bDeclareVSOFog; + uint32 m_dwTexCoordOutMask; + + // Mask of varyings which need centroid decoration + uint32 m_nCentroidMask; + + // Keep track of which temps are used so they can be declared + uint32 m_dwTempUsageMask; + bool m_bOutputColorRegister[4]; + bool m_bOutputDepthRegister; + + // Declaration of integer and bool constants + uint32 m_dwConstIntUsageMask; + uint32 m_dwConstBoolUsageMask; + + // Did we use atomic_temp_var? + bool m_bUsedAtomicTempVar; + + // Track constants so we know how to declare them + bool m_bConstantRegisterDefined[MAX_SHADER_CONSTANTS]; + + // Track sampler types when declared so we can properly decorate TEX instructions + uint32 m_dwSamplerTypes[32]; + + // Track sampler usage + uint32 m_dwSamplerUsageMask; + + // Track shadow sampler usage + int m_nShadowDepthSampler; + bool m_bDeclareShadowOption; + + // Track attribute references + // init to 0xFFFFFFFF (unhit) + // index by (dwRegToken & D3DSP_REGNUM_MASK) in VS DCL insns + // fill with (usage<<4) | (usage index). + uint32 m_dwAttribMap[16]; + + // Register high water mark + uint32 m_nHighestRegister; + + // GLSL does indentation for readability + int m_NumIndentTabs; + + // Output buffers. + CUtlBuffer *m_pBufHeaderCode; + CUtlBuffer *m_pBufAttribCode; + CUtlBuffer *m_pBufParamCode; + CUtlBuffer *m_pBufALUCode; + + char *m_pFinalAssignmentsCode; + int m_nFinalAssignmentsBufSize; + + // Recorded positions for debugging. + uint32* m_pRecordedInputTokenStart; + int m_nRecordedParamCodeStrlen; + int m_nRecordedALUCodeStrlen; + int m_nRecordedAttribCodeStrlen; + + // In GLSL mode, these store the semantic attached to each oN register. + // They are the values that you pass to GetUsageIndexAndString. + uint32 m_DeclaredOutputs[MAX_DECLARED_OUTPUTS]; + + // Have they used the tangent input semantic (i.e. is g_pTangentAttributeName declared)? + bool m_bTangentInputUsed; + + +private: + // Utilities to aid in decoding token stream + uint32 GetNextToken( void ); + void SkipTokens( uint32 numToSkip ); + uint32 Opcode( uint32 dwToken ); + uint32 OpcodeSpecificData( uint32 dwToken ); + uint32 TextureType ( uint32 dwToken ); + uint32 GetRegType( uint32 dwRegToken ); + + // Write to the different buffers. + void StrcatToHeaderCode( const char *pBuf ); + void StrcatToALUCode( const char *pBuf ); + void StrcatToParamCode( const char *pBuf ); + void StrcatToAttribCode( const char *pBuf ); + + // This helps write the token hex codes into the output stream for debugging. + void AddTokenHexCodeToBuffer( char *pBuffer, int nSize, int nLastStrlen ); + void RecordInputAndOutputPositions(); + void AddTokenHexCode(); + + // Utilities for decoding tokens in to strings according to ASM syntax + void PrintOpcode( uint32 inst, char* buff, int nBufLen ); + + // fSemanticFlags is SEMANTIC_INPUT or SEMANTIC_OUTPUT. + void PrintUsageAndIndexToString( uint32 dwToken, char* strUsageUsageIndexName, int nBufLen, int fSemanticFlags ); + CUtlString GetUsageAndIndexString( uint32 dwToken, int fSemanticFlags ); + CUtlString GetParameterString( uint32 dwToken, uint32 dwSourceOrDest, bool bForceScalarSource, int *pARLDestReg ); + const char* GetGLSLOperatorString( uint32 inst ); + + void PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, char *pRegisterName, int nBufLen, bool bForceScalarSource, int *pARLDestReg ); + + void InsertMoveFromAddressRegister( CUtlBuffer *pCode, int nARLComp0, int nARLComp1, int nARLComp2 = ARL_DEST_NONE ); + void InsertMoveInstruction( CUtlBuffer *pCode, int nARLComponent ); + void FlagIndirectRegister( uint32 dwToken, int *pARLDestReg ); + + // Utilities for decoding tokens in to strings according to GLSL syntax + bool OpenIntrinsic( uint32 inst, char* buff, int nBufLen, uint32 destDimension, uint32 nArgumentDimension ); + void PrintIndentation( char *pBuf, int nBufLen ); + + uint32 MaintainAttributeMap( uint32 dwToken, uint32 dwRegToken ); + + CUtlString FixGLSLSwizzle( const char *pDestRegisterName, const char *pSrcRegisterName ); + void WriteGLSLCmp( const char *pDestReg, const char *pSrc0Reg, const char *pSrc1Reg, const char *pSrc2Reg ); + void WriteGLSLSamplerDefinitions(); + void WriteGLSLOutputVariableAssignments(); + void NoteTangentInputUsed(); + + void Handle_DCL(); + void Handle_DEF(); + void Handle_MAD( uint32 nInstruction ); + void Handle_DP2ADD(); + void Handle_SINCOS(); + void Handle_LRP( uint32 nInstruction ); + void Handle_TEX( uint32 dwToken, bool bIsTexLDL ); + void Handle_TexLDD( uint32 nInstruction ); + void Handle_TexCoord(); + void Handle_UnaryOp( uint32 nInstruction ); + void HandleBinaryOp_GLSL( uint32 nInstruction ); + void HandleBinaryOp_ASM( uint32 nInstruction ); + void Handle_CMP(); + void Handle_NRM(); + void Handle_DeclarativeNonDclOp( uint32 nInstruction ); + +public: + D3DToGL(); + + int TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bool *bVertexShader, uint32 options, int32 nShadowDepthSampler, uint32 nCentroidMask, char *debugLabel ); +}; + + +#endif // DX9_ASM_TO_GL_2_H diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/dxabstract.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/dxabstract.cpp new file mode 100644 index 0000000..b197af7 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/dxabstract.cpp @@ -0,0 +1,5929 @@ +//================ Copyright (c) 1996-2009 Valve Corporation. All Rights Reserved. ================= +// +// +// +//================================================================================================== + +#include "dxabstract.h" +#include "dx9asmtogl2.h" +#include "mathlite.h" + +#ifdef OSX +#include "glmgr.h" + +#include "../SteamWorksExample/gameengineosx.h" + +#if DX9MODE + extern CGameEngineGL *g_engine; // so dxabstract (which is C++) can call up to the game engine ObjC object and ask for things.. +#endif + +#include +#endif + +#ifdef USE_ACTUAL_DX + +#pragma comment( lib, "../../dx9sdk/lib/d3d9.lib" ) +#pragma comment( lib, "../../dx9sdk/lib/d3dx9.lib" ) + +#else + +// ------------------------------------------------------------------------------------------------------------------------------ // + +bool g_useASMTranslations = true; +//static D3DToGL_ASM g_D3DToOpenGLTranslatorASM; // old translator retired +static D3DToGL g_D3DToOpenGLTranslatorASM; // same class as the GLSL one, just invoked with different options + +bool g_useGLSLTranslations = true; +static D3DToGL g_D3DToOpenGLTranslatorGLSL; + +bool g_bUseControlFlow = false; + +// ------------------------------------------------------------------------------------------------------------------------------ // + +void GlobalMemoryStatus( MEMORYSTATUS *pOut ) +{ + //cheese: return 2GB physical + pOut->dwTotalPhys = (1<<31); +} + +void Sleep( unsigned int ms ) +{ + Assert(0); +} + +bool IsIconic( VD3DHWND hWnd ) +{ + // FIXME for now just act non-minimized all the time + return false; +} + +void GetClientRect( void *hWnd, RECT *destRect ) +{ + // the only useful answer this call can offer, is the size of the canvas. + // actually getting the window bounds is not useful. + // so, see if a D3D device is up and running, and if so, + // dig in and find out its backbuffer size and use that. + +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + uint width, height; + g_engine->RenderedSize( width, height, false ); // false = get them, don't set them + Assert( width!=0 && height!=0 ); + + destRect->left = 0; + destRect->top = 0; + destRect->right = width; + destRect->bottom = height; + + //GLMPRINTF(( "-D- GetClientRect returning rect of (0,0, %d,%d)",width,height )); +#endif + + return; +} + +BOOL ClientToScreen( VD3DHWND hWnd, LPPOINT pPoint ) +{ + Assert(0); + return true; +} + +void* GetCurrentThread() +{ + Assert(0); + return 0; +} + +void SetThreadAffinityMask( void *hThread, int nMask ) +{ + Assert(0); +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#if 0 +#pragma mark ----- D3DXMATRIX operators + +D3DXMATRIX D3DXMATRIX::operator*( const D3DXMATRIX &o ) const +{ + D3DXMATRIX result; + + D3DXMatrixMultiply( &result, this, &o ); // this = lhs o = rhs result = this * o + + return result; +} + +D3DXMATRIX::operator FLOAT* () +{ + return (float*)this; +} + +float& D3DXMATRIX::operator()( int row, int column ) +{ + return m[row][column]; +} + +const float& D3DXMATRIX::operator()( int row, int column ) const +{ + return m[row][column]; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- D3DXPLANE operators + +float& D3DXPLANE::operator[]( int i ) +{ + return ((float*)this)[i]; +} + +bool D3DXPLANE::operator==( const D3DXPLANE &o ) +{ + return a == o.a && b == o.b && c == o.c && d == o.d; +} + +bool D3DXPLANE::operator!=( const D3DXPLANE &o ) +{ + return !( *this == o ); +} + +D3DXPLANE::operator float*() +{ + return (float*)this; +} + +D3DXPLANE::operator const float*() const +{ + return (const float*)this; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- D3DXVECTOR2 operators + +D3DXVECTOR2::operator FLOAT* () +{ + return (float*)this; +} + +D3DXVECTOR2::operator CONST FLOAT* () const +{ + return (const float*)this; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- D3DXVECTOR3 operators + +D3DXVECTOR3::D3DXVECTOR3( float a, float b, float c ) +{ + x = a; + y = b; + z = c; +} + +D3DXVECTOR3::operator FLOAT* () +{ + return (float*)this; +} + +D3DXVECTOR3::operator CONST FLOAT* () const +{ + return (const float*)this; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + + +#pragma mark ----- D3DXVECTOR4 operators + +D3DXVECTOR4::D3DXVECTOR4( float a, float b, float c, float d ) +{ + x = a; + y = b; + z = c; + w = d; +} +#endif + +// ------------------------------------------------------------------------------------------------------------------------------ // + +DWORD IDirect3DResource9::SetPriority(DWORD PriorityNew) +{ +// Debugger(); +// GLMPRINTF(( "-X- SetPriority" )); + // no-op city + return 0; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DBaseTexture9 + +IDirect3DBaseTexture9::~IDirect3DBaseTexture9() +{ + GLMPRINTF(( ">-A- ~IDirect3DBaseTexture9" )); + + if (m_device) + { + GLMPRINTF(( "-A- ~IDirect3DBaseTexture9 taking normal delete path on %08x, device is %08x ", this, m_device )); + m_device->ReleasedTexture( this ); + + if (m_tex) + { + GLMPRINTF(("-A- ~IDirect3DBaseTexture9 deleted '%s' @ %08x (GLM %08x) %s",m_tex->m_layout->m_layoutSummary, this, m_tex, m_tex->m_debugLabel ? m_tex->m_debugLabel : "" )); + + m_tex->m_ctx->DelTex( m_tex ); + m_tex = NULL; + } + else + { + GLMPRINTF(( "-A- ~IDirect3DBaseTexture9 : whoops, no tex to delete here ?" )); + } + m_device = NULL; // ** THIS ** is the only place to scrub this. Don't do it in the subclass destructors. + } + else + { + GLMPRINTF(( "-A- ~IDirect3DBaseTexture9 taking strange delete path on %08x, device is %08x ", this, m_device )); + } + + GLMPRINTF(( "<-A- ~IDirect3DBaseTexture9" )); +} + +D3DRESOURCETYPE IDirect3DBaseTexture9::GetType() +{ + return m_restype; //D3DRTYPE_TEXTURE; +} + +DWORD IDirect3DBaseTexture9::GetLevelCount() +{ + return m_tex->m_layout->m_mipCount; +} + +HRESULT IDirect3DBaseTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc) +{ + Assert (Level < m_tex->m_layout->m_mipCount); + + D3DSURFACE_DESC result = m_descZero; + // then mutate it for the level of interest + + GLMTexLayoutSlice *slice = &m_tex->m_layout->m_slices[ m_tex->CalcSliceIndex( 0, Level ) ]; + + result.Width = slice->m_xSize; + result.Height = slice->m_ySize; + + *pDesc = result; + + return S_OK; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DTexture9 + +HRESULT IDirect3DDevice9::CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture9** ppTexture,VD3DHANDLE* pSharedHandle, char *debugLabel) +{ + GLMPRINTF((">-A-IDirect3DDevice9::CreateTexture")); + IDirect3DTexture9 *dxtex = new IDirect3DTexture9; + dxtex->m_restype = D3DRTYPE_TEXTURE; + + dxtex->m_device = this; + + dxtex->m_descZero.Format = Format; + dxtex->m_descZero.Type = D3DRTYPE_TEXTURE; + dxtex->m_descZero.Usage = Usage; + dxtex->m_descZero.Pool = Pool; + + dxtex->m_descZero.MultiSampleType = D3DMULTISAMPLE_NONE; + dxtex->m_descZero.MultiSampleQuality = 0; + dxtex->m_descZero.Width = Width; + dxtex->m_descZero.Height = Height; + + GLMTexLayoutKey key; + memset( &key, 0, sizeof(key) ); + + key.m_texGLTarget = GL_TEXTURE_2D; + key.m_texFormat = Format; + + if (Levels>1) + { + key.m_texFlags |= kGLMTexMipped; + } + + // http://msdn.microsoft.com/en-us/library/bb172625(VS.85).aspx + + // complain if any usage bits come down that I don't know. + uint knownUsageBits = (D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_RENDERTARGET | D3DUSAGE_DYNAMIC | D3DUSAGE_TEXTURE_SRGB | D3DUSAGE_DEPTHSTENCIL); + if ( (Usage & knownUsageBits) != Usage ) + { + GLMDebugger(); + } + + if (Usage & D3DUSAGE_AUTOGENMIPMAP) + { + key.m_texFlags |= kGLMTexMipped | kGLMTexMippedAuto; + } + + if (Usage & D3DUSAGE_DYNAMIC) + { + // GLMPRINTF(("-X- DYNAMIC tex usage ignored..")); //FIXME + } + + if (Usage & D3DUSAGE_TEXTURE_SRGB) + { + key.m_texFlags |= kGLMTexSRGB; + } + + if (Usage & D3DUSAGE_RENDERTARGET) + { + Assert( !(Usage & D3DUSAGE_DEPTHSTENCIL) ); + + key.m_texFlags |= kGLMTexRenderable; + key.m_texFlags |= kGLMTexSRGB; // this catches callers of CreateTexture who set the "renderable" option - they get an SRGB tex + + if (m_ctx->Caps().m_cantAttachSRGB) + { + // this config can't support SRGB render targets. quietly turn off the sRGB bit. + key.m_texFlags &= ~kGLMTexSRGB; + } + } + + key.m_xSize = Width; + key.m_ySize = Height; + key.m_zSize = 1; + + CGLMTex *tex = m_ctx->NewTex( &key, debugLabel ); + if (!tex) + { + GLMDebugger(); + } + dxtex->m_tex = tex; + + dxtex->m_srgbFlipCount = 0; + + dxtex->m_surfZero = new IDirect3DSurface9; + dxtex->m_surfZero->m_restype = (D3DRESOURCETYPE)0; // this is a ref to a tex, not the owner... + + // do not do an AddRef here. + + dxtex->m_surfZero->m_device = this; + + dxtex->m_surfZero->m_desc = dxtex->m_descZero; + dxtex->m_surfZero->m_tex = tex; + dxtex->m_surfZero->m_face = 0; + dxtex->m_surfZero->m_mip = 0; + + GLMPRINTF(("-A- IDirect3DDevice9::CreateTexture created '%s' @ %08x (GLM %08x) %s",tex->m_layout->m_layoutSummary, dxtex, tex, debugLabel ? debugLabel : "" )); + + *ppTexture = dxtex; + + GLMPRINTF(("<-A-IDirect3DDevice9::CreateTexture")); + return S_OK; +} + + +IDirect3DTexture9::~IDirect3DTexture9() +{ + GLMPRINTF(( ">-A- IDirect3DTexture9" )); + + // IDirect3DBaseTexture9::~IDirect3DBaseTexture9 frees up m_tex + // we take care of surfZero + + if (m_device) + { + m_device->ReleasedTexture( this ); + + if (m_surfZero) + { + ULONG refc = m_surfZero->Release( 0, "~IDirect3DTexture9 public release (surfZero)" ); + Assert( !refc ); + m_surfZero = NULL; + } + // leave m_device alone! + } + + GLMPRINTF(( "<-A- IDirect3DTexture9" )); +} + +HRESULT IDirect3DTexture9::LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) +{ + // basically same code as in direct3dsurface9::lockrect + + GLMTexLockParams lockreq; + memset( &lockreq, 0, sizeof(lockreq) ); + + lockreq.m_tex = this->m_tex; + lockreq.m_face = 0; //2D texture, no faces + lockreq.m_mip = Level; + + // pRect can be NULL in which case, default to full size of slice + lockreq.m_region.xmin = pRect? pRect->left : 0; + lockreq.m_region.ymin = pRect ? pRect->top : 0; + lockreq.m_region.zmin = 0; + lockreq.m_region.xmax = pRect ? pRect->right : m_tex->m_layout->m_slices[ m_tex->CalcSliceIndex( 0, Level ) ].m_xSize; + lockreq.m_region.ymax = pRect ? pRect->bottom : m_tex->m_layout->m_slices[ m_tex->CalcSliceIndex( 0, Level ) ].m_ySize; + lockreq.m_region.zmax = 1; + + if ((Flags & (D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK)) == (D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK) ) + { + // smells like readback, force texel readout + lockreq.m_readback = true; + } + + char *lockAddress; + int yStride; + int zStride; + + lockreq.m_tex->Lock( &lockreq, &lockAddress, &yStride, &zStride ); + + pLockedRect->Pitch = yStride; + pLockedRect->pBits = lockAddress; + + return S_OK; +} + +HRESULT IDirect3DTexture9::UnlockRect(UINT Level) +{ + GLMTexLockParams lockreq; + memset( &lockreq, 0, sizeof(lockreq) ); + + lockreq.m_tex = this->m_tex; + lockreq.m_face = 0; //2D texture, no faces + lockreq.m_mip = Level; + + lockreq.m_tex->Unlock( &lockreq ); + + return S_OK; +} + +HRESULT IDirect3DTexture9::GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel) +{ + // we create and pass back a surface, and the client is on the hook to release it. tidy. + + IDirect3DSurface9 *surf = new IDirect3DSurface9; + surf->m_restype = (D3DRESOURCETYPE)0; // 0 is special and means this 'surface' does not own its m_tex + + // Dicey...higher level code seems to want this and not want this. Are we missing some AddRef/Release behavior elsewhere? + // trying to turn this off - experimental - 26Oct2010 surf->AddRef(); + + surf->m_device = this->m_device; + + GLMTexLayoutSlice *slice = &m_tex->m_layout->m_slices[ m_tex->CalcSliceIndex( 0, Level ) ]; + + surf->m_desc = m_descZero; + surf->m_desc.Width = slice->m_xSize; + surf->m_desc.Height = slice->m_ySize; + + surf->m_tex = m_tex; + surf->m_face = 0; + surf->m_mip = Level; + + *ppSurfaceLevel = surf; + + return S_OK; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DCubeTexture9 + +HRESULT IDirect3DDevice9::CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture9** ppCubeTexture,VD3DHANDLE* pSharedHandle, char *debugLabel) +{ + GLMPRINTF((">-A- IDirect3DDevice9::CreateCubeTexture")); + + IDirect3DCubeTexture9 *dxtex = new IDirect3DCubeTexture9; + dxtex->m_restype = D3DRTYPE_CUBETEXTURE; + + dxtex->m_device = this; + + dxtex->m_descZero.Format = Format; + dxtex->m_descZero.Type = D3DRTYPE_CUBETEXTURE; + dxtex->m_descZero.Usage = Usage; + dxtex->m_descZero.Pool = Pool; + + dxtex->m_descZero.MultiSampleType = D3DMULTISAMPLE_NONE; + dxtex->m_descZero.MultiSampleQuality = 0; + dxtex->m_descZero.Width = EdgeLength; + dxtex->m_descZero.Height = EdgeLength; + + GLMTexLayoutKey key; + memset( &key, 0, sizeof(key) ); + + key.m_texGLTarget = GL_TEXTURE_CUBE_MAP; + key.m_texFormat = Format; + + if (Levels>1) + { + key.m_texFlags |= kGLMTexMipped; + } + + // http://msdn.microsoft.com/en-us/library/bb172625(VS.85).aspx + // complain if any usage bits come down that I don't know. + uint knownUsageBits = (D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_RENDERTARGET | D3DUSAGE_DYNAMIC | D3DUSAGE_TEXTURE_SRGB); + if ( (Usage & knownUsageBits) != Usage ) + { + GLMDebugger(); + } + + if (Usage & D3DUSAGE_AUTOGENMIPMAP) + { + key.m_texFlags |= kGLMTexMipped | kGLMTexMippedAuto; + } + + if (Usage & D3DUSAGE_RENDERTARGET) + { + key.m_texFlags |= kGLMTexRenderable; + } + + if (Usage & D3DUSAGE_DYNAMIC) + { + //GLMPRINTF(("-X- DYNAMIC tex usage ignored..")); //FIXME + } + + if (Usage & D3DUSAGE_TEXTURE_SRGB) + { + key.m_texFlags |= kGLMTexSRGB; + } + + key.m_xSize = EdgeLength; + key.m_ySize = EdgeLength; + key.m_zSize = 1; + + CGLMTex *tex = m_ctx->NewTex( &key, debugLabel ); + if (!tex) + { + GLMDebugger(); + } + dxtex->m_tex = tex; + + dxtex->m_srgbFlipCount = 0; + + for( int face = 0; face < 6; face ++) + { + dxtex->m_surfZero[face] = new IDirect3DSurface9; + dxtex->m_surfZero[face]->m_restype = (D3DRESOURCETYPE)0; // 0 is special and means this 'surface' does not own its m_tex + // do not do an AddRef here. + + dxtex->m_surfZero[face]->m_device = this; + + dxtex->m_surfZero[face]->m_desc = dxtex->m_descZero; + dxtex->m_surfZero[face]->m_tex = tex; + dxtex->m_surfZero[face]->m_face = face; + dxtex->m_surfZero[face]->m_mip = 0; + } + + GLMPRINTF(("-A- IDirect3DDevice9::CreateCubeTexture created '%s' @ %08x (GLM %08x)",tex->m_layout->m_layoutSummary, dxtex, tex )); + + *ppCubeTexture = dxtex; + + GLMPRINTF(("<-A- IDirect3DDevice9::CreateCubeTexture")); + + return S_OK; +} + +IDirect3DCubeTexture9::~IDirect3DCubeTexture9() +{ + GLMPRINTF(( ">-A- ~IDirect3DCubeTexture9" )); + + if (m_device) + { + GLMPRINTF(( "-A- ~IDirect3DCubeTexture9 taking normal delete path on %08x, device is %08x, surfzero[0] is %08x ", this, m_device, m_surfZero[0] )); + m_device->ReleasedTexture( this ); + + // let IDirect3DBaseTexture9::~IDirect3DBaseTexture9 free up m_tex + // we handle the surfZero array for the faces + + for( int face = 0; face < 6; face ++) + { + if (m_surfZero[face]) + { + Assert( m_surfZero[face]->m_device = m_device ); + ULONG refc = m_surfZero[face]->Release( 0, "~IDirect3DCubeTexture9 public release (surfZero)"); + if ( refc!=0 ) + { + GLMPRINTF(( "-A- ~IDirect3DCubeTexture9 seeing non zero refcount on surfzero[%d] => %d ", face, refc )); + } + m_surfZero[face] = NULL; + } + } + // leave m_device alone! + } + else + { + GLMPRINTF(( "-A- ~IDirect3DCubeTexture9 taking strange delete path on %08x, device is %08x, surfzero[0] is %08x ", this, m_device, m_surfZero[0] )); + } + + GLMPRINTF(( "<-A- ~IDirect3DCubeTexture9" )); +} + +HRESULT IDirect3DCubeTexture9::GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface) +{ + // we create and pass back a surface, and the client is on the hook to release it... + + IDirect3DSurface9 *surf = new IDirect3DSurface9; + surf->m_restype = (D3DRESOURCETYPE)0; // 0 is special and means this 'surface' does not own its m_tex + + GLMTexLayoutSlice *slice = &m_tex->m_layout->m_slices[ m_tex->CalcSliceIndex( FaceType, Level ) ]; + + surf->m_device = this->m_device; + + surf->m_desc = m_descZero; + surf->m_desc.Width = slice->m_xSize; + surf->m_desc.Height = slice->m_ySize; + + surf->m_tex = m_tex; + surf->m_face = FaceType; + surf->m_mip = Level; + + *ppCubeMapSurface = surf; + + return S_OK; +} + +HRESULT IDirect3DCubeTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc) +{ + Assert (Level < m_tex->m_layout->m_mipCount); + + D3DSURFACE_DESC result = m_descZero; + // then mutate it for the level of interest + + GLMTexLayoutSlice *slice = &m_tex->m_layout->m_slices[ m_tex->CalcSliceIndex( 0, Level ) ]; + + result.Width = slice->m_xSize; + result.Height = slice->m_ySize; + + *pDesc = result; + + return S_OK; +} + + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DVolumeTexture9 + +HRESULT IDirect3DDevice9::CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture9** ppVolumeTexture,VD3DHANDLE* pSharedHandle, char *debugLabel) +{ + GLMPRINTF((">-A- IDirect3DDevice9::CreateVolumeTexture")); + // set dxtex->m_restype to D3DRTYPE_VOLUMETEXTURE... + + IDirect3DVolumeTexture9 *dxtex = new IDirect3DVolumeTexture9; + dxtex->m_restype = D3DRTYPE_VOLUMETEXTURE; + + dxtex->m_device = this; + + dxtex->m_descZero.Format = Format; + dxtex->m_descZero.Type = D3DRTYPE_VOLUMETEXTURE; + dxtex->m_descZero.Usage = Usage; + dxtex->m_descZero.Pool = Pool; + + dxtex->m_descZero.MultiSampleType = D3DMULTISAMPLE_NONE; + dxtex->m_descZero.MultiSampleQuality = 0; + dxtex->m_descZero.Width = Width; + dxtex->m_descZero.Height = Height; + + // also a volume specific desc + dxtex->m_volDescZero.Format = Format; + dxtex->m_volDescZero.Type = D3DRTYPE_VOLUMETEXTURE; + dxtex->m_volDescZero.Usage = Usage; + dxtex->m_volDescZero.Pool = Pool; + + dxtex->m_volDescZero.Width = Width; + dxtex->m_volDescZero.Height = Height; + dxtex->m_volDescZero.Depth = Depth; + + GLMTexLayoutKey key; + memset( &key, 0, sizeof(key) ); + + key.m_texGLTarget = GL_TEXTURE_3D; + key.m_texFormat = Format; + + if (Levels>1) + { + key.m_texFlags |= kGLMTexMipped; + } + + // http://msdn.microsoft.com/en-us/library/bb172625(VS.85).aspx + // complain if any usage bits come down that I don't know. + uint knownUsageBits = (D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_RENDERTARGET | D3DUSAGE_DYNAMIC | D3DUSAGE_TEXTURE_SRGB); + if ( (Usage & knownUsageBits) != Usage ) + { + Debugger(); + } + + if (Usage & D3DUSAGE_AUTOGENMIPMAP) + { + key.m_texFlags |= kGLMTexMipped | kGLMTexMippedAuto; + } + + if (Usage & D3DUSAGE_RENDERTARGET) + { + key.m_texFlags |= kGLMTexRenderable; + } + + if (Usage & D3DUSAGE_DYNAMIC) + { + GLMPRINTF(("-X- DYNAMIC tex usage ignored..")); //FIXME + } + + if (Usage & D3DUSAGE_TEXTURE_SRGB) + { + key.m_texFlags |= kGLMTexSRGB; + } + + key.m_xSize = Width; + key.m_ySize = Height; + key.m_zSize = Depth; + + CGLMTex *tex = m_ctx->NewTex( &key, debugLabel ); + if (!tex) + { + Debugger(); + } + dxtex->m_tex = tex; + + dxtex->m_srgbFlipCount = 0; + + dxtex->m_surfZero = new IDirect3DSurface9; + dxtex->m_surfZero->m_restype = (D3DRESOURCETYPE)0; // this is a ref to a tex, not the owner... + // do not do an AddRef here. + + dxtex->m_surfZero->m_device = this; + + dxtex->m_surfZero->m_desc = dxtex->m_descZero; + dxtex->m_surfZero->m_tex = tex; + dxtex->m_surfZero->m_face = 0; + dxtex->m_surfZero->m_mip = 0; + + GLMPRINTF(("-A- IDirect3DDevice9::CreateVolumeTexture created '%s' @ %08x (GLM %08x)",tex->m_layout->m_layoutSummary, dxtex, tex )); + + *ppVolumeTexture = dxtex; + + GLMPRINTF(("<-A- IDirect3DDevice9::CreateVolumeTexture")); + + return S_OK; +} + +IDirect3DVolumeTexture9::~IDirect3DVolumeTexture9() +{ + GLMPRINTF((">-A- ~IDirect3DVolumeTexture9")); + + if (m_device) + { + m_device->ReleasedTexture( this ); + + // let IDirect3DBaseTexture9::~IDirect3DBaseTexture9 free up m_tex + // we handle m_surfZero + + if (m_surfZero) + { + ULONG refc = m_surfZero->Release( 0, "~IDirect3DVolumeTexture9 public release (surfZero)" ); + Assert( !refc ); + m_surfZero = NULL; + } + // leave m_device alone! + } + + GLMPRINTF(("<-A- ~IDirect3DVolumeTexture9")); +} + +HRESULT IDirect3DVolumeTexture9::LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) +{ + GLMTexLockParams lockreq; + memset( &lockreq, 0, sizeof(lockreq) ); + + lockreq.m_tex = this->m_tex; + lockreq.m_face = 0; + lockreq.m_mip = Level; + + lockreq.m_region.xmin = pBox->Left; + lockreq.m_region.ymin = pBox->Top; + lockreq.m_region.zmin = pBox->Front; + lockreq.m_region.xmax = pBox->Right; + lockreq.m_region.ymax = pBox->Bottom; + lockreq.m_region.zmax = pBox->Back; + + char *lockAddress; + int yStride; + int zStride; + + lockreq.m_tex->Lock( &lockreq, &lockAddress, &yStride, &zStride ); + + pLockedVolume->RowPitch = yStride; + pLockedVolume->SlicePitch = yStride; + pLockedVolume->pBits = lockAddress; + + return S_OK; +} + +HRESULT IDirect3DVolumeTexture9::UnlockBox(UINT Level) +{ + GLMTexLockParams lockreq; + memset( &lockreq, 0, sizeof(lockreq) ); + + lockreq.m_tex = this->m_tex; + lockreq.m_face = 0; + lockreq.m_mip = Level; + + this->m_tex->Unlock( &lockreq ); + + return S_OK; +} + +HRESULT IDirect3DVolumeTexture9::GetLevelDesc( UINT Level, D3DVOLUME_DESC *pDesc ) +{ + if (Level > m_tex->m_layout->m_mipCount) + { + Debugger(); + } + + D3DVOLUME_DESC result = m_volDescZero; + // then mutate it for the level of interest + + GLMTexLayoutSlice *slice = &m_tex->m_layout->m_slices[ m_tex->CalcSliceIndex( 0, Level ) ]; + + result.Width = slice->m_xSize; + result.Height = slice->m_ySize; + result.Depth = slice->m_zSize; + + *pDesc = result; + + return S_OK; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DSurface9 + +IDirect3DSurface9::~IDirect3DSurface9() +{ + // not much to do here, but good to verify that these things are being freed (and they are) + //GLMPRINTF(("-A- ~IDirect3DSurface9 - signpost")); + + if (m_device) + { + GLMPRINTF(("-A- ~IDirect3DSurface9 - taking real delete path on %08x device %08x", this, m_device)); + m_device->ReleasedSurface( this ); + + memset( &m_desc, 0, sizeof(m_desc) ); + + if (m_restype != 0) // signal that we are a surface that owns this tex (render target) + { + if (m_tex) + { + GLMPRINTF(("-A- ~IDirect3DSurface9 deleted '%s' @ %08x (GLM %08x) %s",m_tex->m_layout->m_layoutSummary, this, m_tex, m_tex->m_debugLabel ? m_tex->m_debugLabel : "" )); + + m_tex->m_ctx->DelTex( m_tex ); + m_tex = NULL; + } + else + { + GLMPRINTF(( "-A- ~IDirect3DSurface9 : whoops, no tex to delete here ?" )); + } + } + else + { + m_tex = NULL; // we are just a view on the tex, we don't own the tex, do not delete it + } + + m_face = m_mip = 0; + + m_device = NULL; + } + else + { + GLMPRINTF(("-A- ~IDirect3DSurface9 - taking strange delete path on %08x device %08x", this, m_device)); + } +} + +HRESULT IDirect3DSurface9::LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) +{ + GLMTexLockParams lockreq; + memset( &lockreq, 0, sizeof(lockreq) ); + + lockreq.m_tex = this->m_tex; + lockreq.m_face = this->m_face; + lockreq.m_mip = this->m_mip; + + lockreq.m_region.xmin = pRect->left; + lockreq.m_region.ymin = pRect->top; + lockreq.m_region.zmin = 0; + lockreq.m_region.xmax = pRect->right; + lockreq.m_region.ymax = pRect->bottom; + lockreq.m_region.zmax = 1; + + if ((Flags & (D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK)) == (D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK) ) + { + // smells like readback, force texel readout + lockreq.m_readback = true; + } + + char *lockAddress; + int yStride; + int zStride; + + lockreq.m_tex->Lock( &lockreq, &lockAddress, &yStride, &zStride ); + + pLockedRect->Pitch = yStride; + pLockedRect->pBits = lockAddress; + + return S_OK; +} + +HRESULT IDirect3DSurface9::UnlockRect() +{ + GLMTexLockParams lockreq; + memset( &lockreq, 0, sizeof(lockreq) ); + + lockreq.m_tex = this->m_tex; + lockreq.m_face = this->m_face; + lockreq.m_mip = this->m_mip; + + lockreq.m_tex->Unlock( &lockreq ); + + return S_OK; +} + +HRESULT IDirect3DSurface9::GetDesc(D3DSURFACE_DESC *pDesc) +{ + *pDesc = m_desc; + return S_OK; +} + + +// ------------------------------------------------------------------------------------------------------------------------------ // + + +#pragma mark ----- IDirect3D9 ------------------------------------------------------- + +IDirect3D9::~IDirect3D9() +{ + GLMPRINTF(("-A- ~IDirect3D9 - signpost")); +} + +UINT IDirect3D9::GetAdapterCount() +{ +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + GLMgr::NewGLMgr(); // init GL manager + + GLMDisplayDB *db = g_engine->GetDisplayDB(); + int dxAdapterCount = db->GetFakeAdapterCount(); + + return dxAdapterCount; +#else + Debugger(); + return 0; +#endif +} + +HRESULT IDirect3D9::GetDeviceCaps(UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps) +{ + // Generally called from "CShaderDeviceMgrDx8::ComputeCapsFromD3D" in ShaderDeviceDX8.cpp + +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + // "Adapter" is used to index amongst the set of fake-adapters maintained in the display DB + GLMDisplayDB *db = g_engine->GetDisplayDB(); + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + + bool result = db->GetFakeAdapterInfo( Adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert (!result); + // just leave glmRendererInfo filled out for subsequent code to look at as needed. + + // fill in the pCaps record for adapter... we zero most of it and just fill in the fields that we think the caller wants. + V_memset( pCaps, 0, sizeof(*pCaps) ); + + + /* Device Info */ + pCaps->DeviceType = D3DDEVTYPE_HAL; + + /* Caps from DX7 Draw */ + pCaps->Caps = 0; // does anyone look at this ? + + pCaps->Caps2 = D3DCAPS2_DYNAMICTEXTURES; + /* Cursor Caps */ + pCaps->CursorCaps = 0; // nobody looks at this + + /* 3D Device Caps */ + pCaps->DevCaps = D3DDEVCAPS_HWTRANSFORMANDLIGHT; + + pCaps->TextureCaps = D3DPTEXTURECAPS_CUBEMAP | D3DPTEXTURECAPS_MIPCUBEMAP | D3DPTEXTURECAPS_NONPOW2CONDITIONAL | D3DPTEXTURECAPS_PROJECTED; + // D3DPTEXTURECAPS_NOPROJECTEDBUMPENV ? + // D3DPTEXTURECAPS_POW2 ? + // caller looks at POT support like this: + // pCaps->m_SupportsNonPow2Textures = + // ( !( caps.TextureCaps & D3DPTEXTURECAPS_POW2 ) || + // ( caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL ) ); + // so we should set D3DPTEXTURECAPS_NONPOW2CONDITIONAL bit ? + + + pCaps->PrimitiveMiscCaps = 0; //only the HDR setup looks at this for D3DPMISCCAPS_SEPARATEALPHABLEND. + // ? D3DPMISCCAPS_SEPARATEALPHABLEND + // ? D3DPMISCCAPS_BLENDOP + // ? D3DPMISCCAPS_CLIPPLANESCALEDPOINTS + // ? D3DPMISCCAPS_CLIPTLVERTS D3DPMISCCAPS_COLORWRITEENABLE D3DPMISCCAPS_MASKZ D3DPMISCCAPS_TSSARGTEMP + + + pCaps->RasterCaps = D3DPRASTERCAPS_SCISSORTEST + | D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS // ref'd in CShaderDeviceMgrDx8::ComputeCapsFromD3D + | D3DPRASTERCAPS_DEPTHBIAS // ref'd in CShaderDeviceMgrDx8::ComputeCapsFromD3D + ; + + pCaps->TextureFilterCaps = D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MAGFANISOTROPIC; + + pCaps->MaxTextureWidth = 4096; + pCaps->MaxTextureHeight = 4096; + pCaps->MaxVolumeExtent = 1024; //guesses + + pCaps->MaxTextureAspectRatio = 0; // imply no limit on AR + + pCaps->MaxAnisotropy = 8; //guess + + pCaps->TextureOpCaps = D3DTEXOPCAPS_ADD | D3DTEXOPCAPS_MODULATE2X; //guess + DWORD MaxTextureBlendStages; + DWORD MaxSimultaneousTextures; + + pCaps->VertexProcessingCaps = D3DVTXPCAPS_TEXGEN_SPHEREMAP; + + pCaps->MaxActiveLights = 8; // guess + + + // MaxUserClipPlanes. A bit complicated.. + // it's difficult to make this fluid without teaching the engine about a cap that could change during run. + + // start it out set to '2'. + // turn it off, if we're in GLSL mode but do not have native clip plane capability. + pCaps->MaxUserClipPlanes = 2; // assume good news + + // is user asking for it to be off ? + if ( 0 /* CommandLine()->CheckParm( "-nouserclip" ) */ ) + { + pCaps->MaxUserClipPlanes = 0; + } + + g_bUseControlFlow = false; //CommandLine()->CheckParm( "-glslcontrolflow" ); + + // are we ARB mode and not forcing GLSL control flow mode? + if ( 0 /* CommandLine()->CheckParm( "-arbmode" ) && !g_bUseControlFlow */ ) + { + pCaps->MaxUserClipPlanes = 0; + } + + + pCaps->MaxVertexBlendMatrices = 0; // see if anyone cares + pCaps->MaxVertexBlendMatrixIndex = 0; // see if anyone cares + + pCaps->MaxPrimitiveCount = 32768; // guess + pCaps->MaxStreams = 4; // guess + + pCaps->VertexShaderVersion = 0x200; // model 2.0 + pCaps->MaxVertexShaderConst = DXABSTRACT_VS_PARAM_SLOTS; // number of vertex shader constant registers + + pCaps->PixelShaderVersion = 0x200; // model 2.0 + + // Here are the DX9 specific ones + pCaps->DevCaps2 = D3DDEVCAPS2_STREAMOFFSET; + + pCaps->PS20Caps.NumInstructionSlots = 512; // guess + // only examined once: + // pCaps->m_SupportsPixelShaders_2_b = ( ( caps.PixelShaderVersion & 0xffff ) >= 0x0200) && (caps.PS20Caps.NumInstructionSlots >= 512); + //pCaps->m_SupportsPixelShaders_2_b = 1; + + pCaps->NumSimultaneousRTs = 1; // Will be at least 1 + pCaps->MaxVertexShader30InstructionSlots = 0; + pCaps->MaxPixelShader30InstructionSlots = 0; + + #if POSIX + pCaps->FakeSRGBWrite = !glmRendererInfo.m_hasGammaWrites; + pCaps->CanDoSRGBReadFromRTs = !glmRendererInfo.m_cantAttachSRGB; + pCaps->MixedSizeTargets = glmRendererInfo.m_hasMixedAttachmentSizes; + #endif + +#endif + + return S_OK; +} + +HRESULT IDirect3D9::GetAdapterIdentifier( UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9* pIdentifier ) +{ + // Generally called from "CShaderDeviceMgrDx8::ComputeCapsFromD3D" in ShaderDeviceDX8.cpp + +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + + Assert( Flags == D3DENUM_WHQL_LEVEL ); // we're not handling any other queries than this yet + + V_memset( pIdentifier, 0, sizeof(*pIdentifier) ); + + GLMDisplayDB *db = g_engine->GetDisplayDB(); + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + + // the D3D "Adapter" number feeds the fake adapter index + bool result = db->GetFakeAdapterInfo( Adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert (!result); + + sprintf( pIdentifier->Driver, "OpenGL %s (%08x)", + GLMDecode( eGL_RENDERER, glmRendererInfo.m_rendererID & 0x00FFFF00 ), + glmRendererInfo.m_rendererID + ); + + sprintf( pIdentifier->Description, "%s - %dx%d - %dMB VRAM", + GLMDecode( eGL_RENDERER, glmRendererInfo.m_rendererID & 0x00FFFF00 ), + glmDisplayInfo.m_displayPixelWidth, glmDisplayInfo.m_displayPixelHeight, + glmRendererInfo.m_vidMemory >> 20 ); + + pIdentifier->VendorId = glmRendererInfo.m_pciVendorID; // 4318; + pIdentifier->DeviceId = glmRendererInfo.m_pciDeviceID; // 401; + pIdentifier->SubSysId = 0; // 3358668866; + pIdentifier->Revision = 0; // 162; + pIdentifier->VideoMemory = glmRendererInfo.m_vidMemory; // amount of video memory in bytes + + #if 0 + // this came from the shaderapigl effort + V_strncpy( pIdentifier->Driver, "Fake-Video-Card", MAX_DEVICE_IDENTIFIER_STRING ); + V_strncpy( pIdentifier->Description, "Fake-Video-Card", MAX_DEVICE_IDENTIFIER_STRING ); + pIdentifier->VendorId = 4318; + pIdentifier->DeviceId = 401; + pIdentifier->SubSysId = 3358668866; + pIdentifier->Revision = 162; + #endif + + return S_OK; +#else + Debugger(); + return D3DERR_INVALIDCALL; +#endif + +} + +HRESULT IDirect3D9::CheckDeviceFormat(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) +{ +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + + if (0) // hush for now, less spew + { + GLMPRINTF(("-X- ** IDirect3D9::CheckDeviceFormat: \n -- Adapter=%d || DeviceType=%4x:%s || AdapterFormat=%8x:%s\n -- RType %8x: %s\n -- CheckFormat %8x: %s\n -- Usage %8x: %s", + Adapter, + DeviceType, GLMDecode(eD3D_DEVTYPE, DeviceType), + AdapterFormat, GLMDecode(eD3D_FORMAT, AdapterFormat), + RType, GLMDecode(eD3D_RTYPE, RType), + CheckFormat, GLMDecode(eD3D_FORMAT, CheckFormat), + Usage, GLMDecodeMask( eD3D_USAGE, Usage ) )); + } + + HRESULT result = D3DERR_NOTAVAILABLE; // failure + + DWORD knownUsageMask = D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL | D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP + | D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_FILTER | D3DUSAGE_QUERY_SRGBWRITE | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING + | D3DUSAGE_QUERY_VERTEXTEXTURE; + + // FramebufferSRGB stuff. + // basically a format is only allowed to have SRGB usage for writing, if you have the framebuffer SRGB extension. + // so, check for that capability with GLM adapter db, and if it's not there, don't mark that bit as usable in any of our formats. + GLMDisplayDB *db = g_engine->GetDisplayDB(); + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + + bool dbresult = db->GetFakeAdapterInfo( Adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert (!dbresult); + + Assert ((Usage & knownUsageMask) == Usage); + + DWORD legalUsage = 0; + switch( AdapterFormat ) + { + case D3DFMT_X8R8G8B8: + switch( RType ) + { + case D3DRTYPE_TEXTURE: + switch( CheckFormat ) + { + case D3DFMT_DXT1: + case D3DFMT_DXT3: + case D3DFMT_DXT5: + legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + legalUsage |= D3DUSAGE_QUERY_SRGBREAD; + + //open question: is auto gen of mipmaps is allowed or attempted on any DXT textures. + break; + + case D3DFMT_A8R8G8B8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + legalUsage |= D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING; + break; + + case D3DFMT_R32F: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + legalUsage |= D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING; + break; + + case D3DFMT_A16B16G16R16: + legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + legalUsage |= D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING; + break; + + case D3DFMT_A16B16G16R16F: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE; + + if ( !glmRendererInfo.m_atiR5xx ) + { + legalUsage |= D3DUSAGE_QUERY_FILTER | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING; + } + break; + + case D3DFMT_A32B32G32R32F: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_RENDERTARGET | D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE; + + if ( !glmRendererInfo.m_atiR5xx && !glmRendererInfo.m_nvG7x ) + { + legalUsage |= D3DUSAGE_QUERY_FILTER | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING; + } + break; + + case D3DFMT_R5G6B5: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + //----------------------------------------------------------- + // these come in from TestTextureFormat in ColorFormatDX8.cpp which is being driven by InitializeColorInformation... + // which is going to try all 8 combinations of (vertex texturable / render targetable / filterable ) on every image format it knows. + + case D3DFMT_R8G8B8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + legalUsage |= D3DUSAGE_QUERY_SRGBREAD; + break; + + case D3DFMT_X8R8G8B8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + legalUsage |= D3DUSAGE_QUERY_SRGBREAD | D3DUSAGE_QUERY_SRGBWRITE; + break; + + // one and two channel textures... we'll have to fake these as four channel tex if we want to support them + case D3DFMT_L8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + case D3DFMT_A8L8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + case D3DFMT_A8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + // going to need to go back and double check all of these.. + case D3DFMT_X1R5G5B5: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + case D3DFMT_A4R4G4B4: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + case D3DFMT_A1R5G5B5: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + case D3DFMT_V8U8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + break; + + case D3DFMT_Q8W8V8U8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + // what the heck is QWVU8 ... ? + break; + + case D3DFMT_X8L8V8U8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_AUTOGENMIPMAP | D3DUSAGE_QUERY_FILTER; + // what the heck is XLVU8 ... ? + break; + + // formats with depth... + + case D3DFMT_D16: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL; + // just a guess on the legal usages + break; + + case D3DFMT_D24S8: legalUsage = D3DUSAGE_DYNAMIC | D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL; + // just a guess on the legal usages + break; + + // vendor formats... try marking these all invalid for now + case D3DFMT_NV_INTZ: + case D3DFMT_NV_RAWZ: + case D3DFMT_NV_NULL: + case D3DFMT_ATI_D16: + case D3DFMT_ATI_D24S8: + case D3DFMT_ATI_2N: + case D3DFMT_ATI_1N: + legalUsage = 0; + break; + + //----------------------------------------------------------- + + default: + Assert(!"Unknown check format"); + result = D3DERR_NOTAVAILABLE; + break; + } + + if ((Usage & legalUsage) == Usage) + { + result = S_OK; + } + else + { + DWORD unsatBits = Usage & (~legalUsage); // clear the bits of the req that were legal, leaving the illegal ones + GLMPRINTF(( "-X- --> NOT OK: flags %8x:%s", unsatBits,GLMDecodeMask( eD3D_USAGE, unsatBits ) )); + result = D3DERR_NOTAVAILABLE; + } + break; + + case D3DRTYPE_SURFACE: + switch( CheckFormat ) + { + case 0x434f5441: + case 0x41415353: + result = D3DERR_NOTAVAILABLE; + break; + + case D3DFMT_D24S8: + result = S_OK; + break; + //** IDirect3D9::CheckDeviceFormat adapter=0, DeviceType= 1:D3DDEVTYPE_HAL, AdapterFormat= 5:D3DFMT_X8R8G8B8, RType= 1:D3DRTYPE_SURFACE, CheckFormat=434f5441:UNKNOWN + //** IDirect3D9::CheckDeviceFormat adapter=0, DeviceType= 1:D3DDEVTYPE_HAL, AdapterFormat= 5:D3DFMT_X8R8G8B8, RType= 1:D3DRTYPE_SURFACE, CheckFormat=41415353:UNKNOWN + //** IDirect3D9::CheckDeviceFormat adapter=0, DeviceType= 1:D3DDEVTYPE_HAL, AdapterFormat= 5:D3DFMT_X8R8G8B8, RType= 1:D3DRTYPE_SURFACE, CheckFormat=434f5441:UNKNOWN + //** IDirect3D9::CheckDeviceFormat adapter=0, DeviceType= 1:D3DDEVTYPE_HAL, AdapterFormat= 5:D3DFMT_X8R8G8B8, RType= 1:D3DRTYPE_SURFACE, CheckFormat=41415353:UNKNOWN + + default: + Assert(!"Unknown format"); + result = D3DERR_NOTAVAILABLE; + break; + } + break; + + default: + Assert(!"Unknown resource type"); + result = D3DERR_NOTAVAILABLE; + break; + } + break; + + default: + Assert(!"Unknown adapter format"); + result = D3DERR_NOTAVAILABLE; + break; + } + + return result; +#else + Debugger(); + return D3DERR_INVALIDCALL; +#endif +} + +UINT IDirect3D9::GetAdapterModeCount(UINT Adapter,D3DFORMAT Format) +{ +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + + GLMPRINTF(( "-X- IDirect3D9::GetAdapterModeCount: Adapter=%d || Format=%8x:%s", Adapter, Format, GLMDecode(eD3D_FORMAT, Format) )); + + uint modeCount=0; + + GLMDisplayDB *db = g_engine->GetDisplayDB(); + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + + // the D3D "Adapter" number feeds the fake adapter index + bool result = db->GetFakeAdapterInfo( Adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert (!result); + + modeCount = db->GetModeCount( glmRendererIndex, glmDisplayIndex ); + GLMPRINTF(( "-X- --> result is %d", modeCount )); + + return modeCount; +#else + Debugger(); + return 0; +#endif +} + +HRESULT IDirect3D9::EnumAdapterModes(UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode) +{ +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + + GLMPRINTF(( "-X- IDirect3D9::EnumAdapterModes: Adapter=%d || Format=%8x:%s || Mode=%d", Adapter, Format, GLMDecode(eD3D_FORMAT, Format), Mode )); + + Assert(Format==D3DFMT_X8R8G8B8); + + GLMDisplayDB *db = g_engine->GetDisplayDB(); + + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + GLMDisplayModeInfoFields glmModeInfo; + + // the D3D "Adapter" number feeds the fake adapter index + bool result = db->GetFakeAdapterInfo( Adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert (!result); + if (result) return D3DERR_NOTAVAILABLE; + + bool result2 = db->GetModeInfo( glmRendererIndex, glmDisplayIndex, Mode, &glmModeInfo ); + Assert( !result2 ); + if (result2) return D3DERR_NOTAVAILABLE; + + pMode->Width = glmModeInfo.m_modePixelWidth; + pMode->Height = glmModeInfo.m_modePixelHeight; + pMode->RefreshRate = glmModeInfo.m_modeRefreshHz; // "adapter default" + pMode->Format = Format; // whatever you asked for ? + + GLMPRINTF(( "-X- IDirect3D9::EnumAdapterModes returning mode size (%d,%d) and D3DFMT_X8R8G8B8",pMode->Width,pMode->Height )); + return S_OK; +#else + Debugger(); + return D3DERR_INVALIDCALL; +#endif +} + +HRESULT IDirect3D9::CheckDeviceType(UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed) +{ + //FIXME: we just say "OK" on any query + + GLMPRINTF(( "-X- IDirect3D9::CheckDeviceType: Adapter=%d || DevType=%d:%s || AdapterFormat=%d:%s || BackBufferFormat=%d:%s || bWindowed=%d", + Adapter, + DevType, GLMDecode(eD3D_DEVTYPE,DevType), + AdapterFormat, GLMDecode(eD3D_FORMAT, AdapterFormat), + BackBufferFormat, GLMDecode(eD3D_FORMAT, BackBufferFormat), + (int) bWindowed )); + + return S_OK; +} + +HRESULT IDirect3D9::GetAdapterDisplayMode(UINT Adapter,D3DDISPLAYMODE* pMode) +{ +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + + // asking what the current mode is + GLMPRINTF(("-X- IDirect3D9::GetAdapterDisplayMode: Adapter=%d", Adapter )); + + GLMDisplayDB *db = g_engine->GetDisplayDB(); + + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + GLMDisplayModeInfoFields glmModeInfo; + + // the D3D "Adapter" number feeds the fake adapter index + bool result = db->GetFakeAdapterInfo( Adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert(!result); + if (result) return D3DERR_INVALIDCALL; + + int modeIndex = -1; // pass -1 as a mode index to find out about whatever the current mode is on the selected display + + bool modeResult = db->GetModeInfo( glmRendererIndex, glmDisplayIndex, modeIndex, &glmModeInfo ); + Assert (!modeResult); + if (modeResult) return D3DERR_INVALIDCALL; + + pMode->Width = glmModeInfo.m_modePixelWidth; + pMode->Height = glmModeInfo.m_modePixelHeight; + pMode->RefreshRate = glmModeInfo.m_modeRefreshHz; // "adapter default" + pMode->Format = D3DFMT_X8R8G8B8; //FIXME, this is a SWAG + + return S_OK; +#else + Debugger(); + return D3DERR_INVALIDCALL; +#endif +} + +HRESULT IDirect3D9::CheckDepthStencilMatch(UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) +{ + GLMPRINTF(("-X- IDirect3D9::CheckDepthStencilMatch: Adapter=%d || DevType=%d:%s || AdapterFormat=%d:%s || RenderTargetFormat=%d:%s || DepthStencilFormat=%d:%s", + Adapter, + DeviceType, GLMDecode(eD3D_DEVTYPE,DeviceType), + AdapterFormat, GLMDecode(eD3D_FORMAT, AdapterFormat), + RenderTargetFormat, GLMDecode(eD3D_FORMAT, RenderTargetFormat), + DepthStencilFormat, GLMDecode(eD3D_FORMAT, DepthStencilFormat) )); + + // one known request looks like this: + // AdapterFormat=5:D3DFMT_X8R8G8B8 || RenderTargetFormat=3:D3DFMT_A8R8G8B8 || DepthStencilFormat=2:D3DFMT_D24S8 + + // return S_OK for that one combo, Debugger() on anything else + HRESULT result = D3DERR_NOTAVAILABLE; // failure + + switch( AdapterFormat ) + { + case D3DFMT_X8R8G8B8: + { + if ( (RenderTargetFormat == D3DFMT_A8R8G8B8) && (DepthStencilFormat == D3DFMT_D24S8) ) + { + result = S_OK; + } + } + break; + + default: + Assert(!"Unhandled format"); + result = D3DERR_NOTAVAILABLE; + break; + } + + Assert( result == S_OK ); + + return result; +} + +HRESULT IDirect3D9::CheckDeviceMultiSampleType( UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels ) +{ +#if DX9MODE // can only make these calls if DX9MODE is on, if not, we won't get here + + GLMDisplayDB *db = g_engine->GetDisplayDB(); + + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + GLMDisplayModeInfoFields glmModeInfo; + + // the D3D "Adapter" number feeds the fake adapter index + bool result = db->GetFakeAdapterInfo( Adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert( !result ); + if ( result ) + return D3DERR_INVALIDCALL; + + + if ( 1 /* !CommandLine()->FindParm("-glmenabletrustmsaa") */ ) + { + // These ghetto drivers don't get MSAA + if ( ( glmRendererInfo.m_nvG7x || glmRendererInfo.m_atiR5xx ) && ( MultiSampleType > D3DMULTISAMPLE_NONE ) ) + { + if ( pQualityLevels ) + { + *pQualityLevels = 0; + } + return D3DERR_NOTAVAILABLE; + } + } + + switch ( MultiSampleType ) + { + case D3DMULTISAMPLE_NONE: // always return true + if ( pQualityLevels ) + { + *pQualityLevels = 1; + } + return S_OK; + break; + + case D3DMULTISAMPLE_2_SAMPLES: + case D3DMULTISAMPLE_4_SAMPLES: + case D3DMULTISAMPLE_6_SAMPLES: + case D3DMULTISAMPLE_8_SAMPLES: + // note the fact that the d3d enums for 2, 4, 6, 8 samples are equal to 2,4,6,8... + if (glmRendererInfo.m_maxSamples >= (int)MultiSampleType ) + { + if ( pQualityLevels ) + { + *pQualityLevels = 1; + } + return S_OK; + } + else + { + return D3DERR_NOTAVAILABLE; + } + break; + + default: + if ( pQualityLevels ) + { + *pQualityLevels = 0; + } + return D3DERR_NOTAVAILABLE; + break; + } + return D3DERR_NOTAVAILABLE; +#else + Debugger(); + return D3DERR_NOTAVAILABLE; +#endif + +} + +HRESULT IDirect3D9::CreateDevice(UINT Adapter,D3DDEVTYPE DeviceType,VD3DHWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface) +{ + // constrain these inputs for the time being + // BackBufferFormat -> A8R8G8B8 + // BackBufferCount -> 1; + // MultiSampleType -> D3DMULTISAMPLE_NONE + // AutoDepthStencilFormat -> D3DFMT_D24S8 + + // NULL out the return pointer so if we exit early it is not set + *ppReturnedDeviceInterface = NULL; + + // assume success unless something is sour + HRESULT result = S_OK; + + // relax this check for now + //if (pPresentationParameters->BackBufferFormat != D3DFMT_A8R8G8B8) + //{ + // Debugger(); + // result = -1; + //} + + //rbarris 24Aug10 - relaxing this check - we don't care if the game asks for two backbuffers, it's moot + //if ( pPresentationParameters->BackBufferCount != 1 ) + //{ + // Debugger(); + // result = D3DERR_NOTAVAILABLE; + //} + + if ( pPresentationParameters->AutoDepthStencilFormat != D3DFMT_D24S8 ) + { + Debugger(); + result = D3DERR_NOTAVAILABLE; + } + + if ( result == S_OK ) + { + // create an IDirect3DDevice9 + // it will make a GLMContext and set up some drawables + + IDirect3DDevice9Params devparams; + memset( &devparams, 0, sizeof(devparams) ); + + devparams.m_adapter = Adapter; + devparams.m_deviceType = DeviceType; + devparams.m_focusWindow = hFocusWindow; // is this meaningful? is this a WindowRef ? follow it up the chain.. + devparams.m_behaviorFlags = BehaviorFlags; + devparams.m_presentationParameters = *pPresentationParameters; + + IDirect3DDevice9 *dev = new IDirect3DDevice9; + + result = dev->Create( &devparams ); + + if ( result == S_OK ) + { + *ppReturnedDeviceInterface = dev; + } + } + return result; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DQuery9 + +HRESULT IDirect3DQuery9::Issue(DWORD dwIssueFlags) +{ + // Flags field for Issue + // #define D3DISSUE_END (1 << 0) // Tells the runtime to issue the end of a query, changing it's state to "non-signaled". + // #define D3DISSUE_BEGIN (1 << 1) // Tells the runtime to issue the beginng of a query. + + if (dwIssueFlags & D3DISSUE_BEGIN) + { + switch( m_type ) + { + case D3DQUERYTYPE_OCCLUSION: + m_query->Start(); // drop "start counter" call into stream + break; + + default: + Assert(!"Can't use D3DISSUE_BEGIN on this query"); + break; + } + } + + if (dwIssueFlags & D3DISSUE_END) + { + switch( m_type ) + { + case D3DQUERYTYPE_OCCLUSION: + m_query->Stop(); // drop "end counter" call into stream + break; + + case D3DQUERYTYPE_EVENT: + // End is very weird with respect to Events (fences). + // DX9 docs say to use End to put the fence in the stream. So we map End to GLM's Start. + // http://msdn.microsoft.com/en-us/library/ee422167(VS.85).aspx + m_query->Start(); // drop "set fence" into stream + break; + } + } + return S_OK; +} + +HRESULT IDirect3DQuery9::GetData(void* pData,DWORD dwSize,DWORD dwGetDataFlags) +{ + HRESULT result = -1; + + // GetData is not always called with the flush bit. + + // if an answer is not yet available - return S_FALSE. + // if an answer is available - return S_OK and write the answer into *pData. + bool done = false; + bool flush = (dwGetDataFlags & D3DGETDATA_FLUSH) != 0; // aka spin until done + + // hmmm both of these paths are the same, maybe we could fold them up + if ( !m_query->IsStarted() ) + { + Assert(!"Can't GetData before issue/start"); + printf("\n** IDirect3DQuery9::GetData: can't GetData before issue/start"); + result = -1; + } + else if ( !m_query->IsStopped() ) + { + Assert(!"Can't GetData before issue-end/stop"); + printf("\n** IDirect3DQuery9::GetData: can't GetData before issue-end/stop"); + result = -1; + } + else + { + switch( m_type ) + { + case D3DQUERYTYPE_OCCLUSION: + { + // expectation - caller already did an issue begin (start) and an issue end (stop). + // we can probe using IsDone. + if (flush && (!m_ctx->Caps().m_hasPerfPackage1) ) + { + glFlush(); + } + do + { + done = m_query->IsDone(); + if (done) + { + uint oqValue = 0; // or we could just pass pData directly to Complete... + m_query->Complete(&oqValue); + if (pData) + { + *(uint*)pData = oqValue; + } + result = S_OK; + } + else + { + result = S_FALSE; + } + } while( flush && (!done) ); + } + break; + + case D3DQUERYTYPE_EVENT: + { + // expectation - caller already did an issue end (for fence => start) but has not done anything that would call Stop. + // that's ok because Stop is a no-op for fences. + if (flush && (!m_ctx->Caps().m_hasPerfPackage1) ) + { + glFlush(); + } + + done = m_query->IsDone(); + if (done) + { + m_query->Complete(NULL); // this will block on pre-SLGU + *(uint*)pData = 0; + result = S_OK; + } + else + { + result = S_FALSE; + } + } + break; + } + } + + return result; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DVertexBuffer9 + +HRESULT IDirect3DDevice9::CreateVertexBuffer(UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer9** ppVertexBuffer,VD3DHANDLE* pSharedHandle) +{ + GLMPRINTF(( ">-A- IDirect3DDevice9::CreateVertexBuffer" )); + + IDirect3DVertexBuffer9 *newbuff = new IDirect3DVertexBuffer9; + + newbuff->m_device = this; + + newbuff->m_ctx = m_ctx; + + // FIXME need to find home or use for the Usage, FVF, Pool values passed in + uint options = 0; + + if (Usage&D3DUSAGE_DYNAMIC) + { + options |= GLMBufferOptionDynamic; + } + + newbuff->m_vtxBuffer = m_ctx->NewBuffer( kGLMVertexBuffer, Length, options ) ; + + newbuff->m_vtxDesc.Type = D3DRTYPE_VERTEXBUFFER; + newbuff->m_vtxDesc.Usage = Usage; + newbuff->m_vtxDesc.Pool = Pool; + newbuff->m_vtxDesc.Size = Length; + + *ppVertexBuffer = newbuff; + + GLMPRINTF(( "<-A- IDirect3DDevice9::CreateVertexBuffer" )); + + return S_OK; +} + +IDirect3DVertexBuffer9::~IDirect3DVertexBuffer9() +{ + GLMPRINTF(( ">-A- ~IDirect3DVertexBuffer9" )); + + if (m_device) + { + m_device->ReleasedVertexBuffer( this ); + + if (m_ctx && m_vtxBuffer) + { + GLMPRINTF(( ">-A- ~IDirect3DVertexBuffer9 deleting m_vtxBuffer" )); + m_ctx->DelBuffer( m_vtxBuffer ); + m_vtxBuffer = NULL; + GLMPRINTF(( "<-A- ~IDirect3DVertexBuffer9 deleting m_vtxBuffer - done" )); + } + m_device = NULL; + } + + GLMPRINTF(( "<-A- ~IDirect3DVertexBuffer9" )); +} + +HRESULT IDirect3DVertexBuffer9::Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) +{ + // FIXME would be good to have "can't lock twice" logic + + Assert( !(Flags & D3DLOCK_READONLY) ); // not impl'd +// Assert( !(Flags & D3DLOCK_NOSYSLOCK) ); // not impl'd - it triggers though + + GLMBuffLockParams lockreq; + lockreq.m_offset = OffsetToLock; + lockreq.m_size = SizeToLock; + lockreq.m_nonblocking = (Flags & D3DLOCK_NOOVERWRITE) != 0; + lockreq.m_discard = (Flags & D3DLOCK_DISCARD) != 0; + + m_vtxBuffer->Lock( &lockreq, (char**)ppbData ); + + GLMPRINTF(("-X- IDirect3DDevice9::Lock on D3D buf %p (GL name %d) offset %d, size %d => address %p", this, this->m_vtxBuffer->m_name, OffsetToLock, SizeToLock, *ppbData)); + return S_OK; +} + +HRESULT IDirect3DVertexBuffer9::Unlock() +{ + m_vtxBuffer->Unlock(); + return S_OK; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + + +#pragma mark ----- IDirect3DIndexBuffer9 + +HRESULT IDirect3DDevice9::CreateIndexBuffer(UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer9** ppIndexBuffer,VD3DHANDLE* pSharedHandle) +{ + GLMPRINTF(( ">-A- IDirect3DDevice9::CreateIndexBuffer" )); + + // it is important to save all the create info, since GetDesc could get called later to query it + + IDirect3DIndexBuffer9 *newbuff = new IDirect3DIndexBuffer9; + + newbuff->m_device = this; + + newbuff->m_restype = D3DRTYPE_INDEXBUFFER; // hmmmmmmm why are we not derived from d3dresource.. + + newbuff->m_ctx = m_ctx; + + // FIXME need to find home or use for the Usage, Format, Pool values passed in + uint options = 0; + + if (Usage&D3DUSAGE_DYNAMIC) + { + options |= GLMBufferOptionDynamic; + } + + newbuff->m_idxBuffer = m_ctx->NewBuffer( kGLMIndexBuffer, Length, options ) ; + + newbuff->m_idxDesc.Format = Format; + newbuff->m_idxDesc.Type = D3DRTYPE_INDEXBUFFER; + newbuff->m_idxDesc.Usage = Usage; + newbuff->m_idxDesc.Pool = Pool; + newbuff->m_idxDesc.Size = Length; + + *ppIndexBuffer = newbuff; + + GLMPRINTF(( "<-A- IDirect3DDevice9::CreateIndexBuffer" )); + + return S_OK; +} + +IDirect3DIndexBuffer9::~IDirect3DIndexBuffer9() +{ + GLMPRINTF(( ">-A- ~IDirect3DIndexBuffer9" )); + + if (m_device) + { + m_device->ReleasedIndexBuffer( this ); + + if (m_ctx && m_idxBuffer) + { + GLMPRINTF(( ">-A- ~IDirect3DIndexBuffer9 deleting m_idxBuffer" )); + m_ctx->DelBuffer( m_idxBuffer ); + GLMPRINTF(( "<-A- ~IDirect3DIndexBuffer9 deleting m_idxBuffer - done" )); + } + m_device = NULL; + } + else + { + } + + GLMPRINTF(( "<-A- ~IDirect3DIndexBuffer9" )); +} + + +HRESULT IDirect3DIndexBuffer9::Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags) +{ + // FIXME would be good to have "can't lock twice" logic + + GLMBuffLockParams lockreq; + lockreq.m_offset = OffsetToLock; + lockreq.m_size = SizeToLock; + lockreq.m_nonblocking = (Flags & D3DLOCK_NOOVERWRITE) != 0; + lockreq.m_discard = (Flags & D3DLOCK_DISCARD) != 0; + + m_idxBuffer->Lock( &lockreq, (char**)ppbData ); + + return S_OK; +} + +HRESULT IDirect3DIndexBuffer9::Unlock() +{ + m_idxBuffer->Unlock(); + + return S_OK; +} + +HRESULT IDirect3DIndexBuffer9::GetDesc(D3DINDEXBUFFER_DESC *pDesc) +{ + *pDesc = m_idxDesc; + return S_OK; +} + + +// ------------------------------------------------------------------------------------------------------------------------------ // + +#pragma mark ----- IDirect3DDevice9 ------------------------------------------------- + +void ConvertPresentationParamsToGLMDisplayParams( D3DPRESENT_PARAMETERS *d3dp, GLMDisplayParams *gldp ) +{ + memset( gldp, 0, sizeof(*gldp) ); + + gldp->m_fsEnable = !d3dp->Windowed; + + // see http://msdn.microsoft.com/en-us/library/ee416515(VS.85).aspx + // note that the values below are the only ones mentioned by Source engine; there are many others + switch(d3dp->PresentationInterval) + { + case D3DPRESENT_INTERVAL_ONE: + gldp->m_vsyncEnable = true; // "The driver will wait for the vertical retrace period (the runtime will beam-follow to prevent tearing)." + break; + + case D3DPRESENT_INTERVAL_IMMEDIATE: + gldp->m_vsyncEnable = false; // "The runtime updates the window client area immediately and might do so more than once during the adapter refresh period." + break; + + default: + gldp->m_vsyncEnable = true; // if I don't know it, you're getting vsync enabled. + break; + } + + gldp->m_backBufferWidth = d3dp->BackBufferWidth; + gldp->m_backBufferHeight = d3dp->BackBufferHeight; + gldp->m_backBufferFormat = d3dp->BackBufferFormat; + gldp->m_multiSampleCount = d3dp->MultiSampleType; // it's a count really + + gldp->m_enableAutoDepthStencil = d3dp->EnableAutoDepthStencil; + gldp->m_autoDepthStencilFormat = d3dp->AutoDepthStencilFormat; + + gldp->m_fsRefreshHz = d3dp->FullScreen_RefreshRateInHz; + + // some fields in d3d PB we're not acting on yet... + // UINT BackBufferCount; + // DWORD MultiSampleQuality; + // D3DSWAPEFFECT SwapEffect; + // VD3DHWND hDeviceWindow; + // DWORD Flags; +} + +HRESULT IDirect3DDevice9::Create( IDirect3DDevice9Params *params ) +{ +#if DX9MODE + + GLMPRINTF((">-X-IDirect3DDevice9::Create")); + HRESULT result = S_OK; + + // create an IDirect3DDevice9 + // make a GLMContext and set up some drawables + m_params = *params; + + m_ctx = NULL; + m_drawableFBO = NULL; + + memset( m_rtSurfaces, 0, sizeof(m_rtSurfaces) ); + m_dsSurface = NULL; + + m_defaultColorSurface = NULL; + m_defaultDepthStencilSurface = NULL; + + memset( m_streams, 0, sizeof(m_streams) ); + memset( m_textures, 0, sizeof(m_textures) ); + memset( m_samplers, 0, sizeof(m_samplers) ); + + + //============================================================================ + // param block for GLM context create + GLMDisplayParams glmParams; + ConvertPresentationParamsToGLMDisplayParams( ¶ms->m_presentationParameters, &glmParams ); + + glmParams.m_mtgl = true; // forget this idea -> (params->m_behaviorFlags & D3DCREATE_MULTITHREADED) != 0; + // the call above fills in a bunch of things, but doesn't know about anything outside of the presentation params. + // those tend to be the things that do not change after create, so we do those here in Create. + + glmParams.m_focusWindow = params->m_focusWindow; + + #if 0 //FIXME-HACK + // map the D3D "adapter" to a renderer/display pair + // (that GPU will have to stay set as-is for any subsequent mode changes) + + int glmRendererIndex = -1; + int glmDisplayIndex = -1; + + GLMRendererInfoFields glmRendererInfo; + GLMDisplayInfoFields glmDisplayInfo; + + // the D3D "Adapter" number feeds the fake adapter index + bool adaptResult = GLMgr::aGLMgr()->GetDisplayDB()->GetFakeAdapterInfo( params->m_adapter, &glmRendererIndex, &glmDisplayIndex, &glmRendererInfo, &glmDisplayInfo ); + Assert(!adaptResult); + + glmParams.m_rendererIndex = glmRendererIndex; + glmParams.m_displayIndex = glmDisplayIndex; + // glmParams.m_modeIndex hmmmmm, client doesn't give us a mode number, just a resolution.. + #endif + + m_ctx = GLMgr::aGLMgr()->NewContext( &glmParams ); + if (!m_ctx) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Create (error out)")); + return (HRESULT) -1; + } + + // make an FBO to draw into and activate it. + m_drawableFBO = m_ctx->NewFBO(); + + m_ctx->SetDrawingFBO( m_drawableFBO ); + + // bind it to context. will receive attachments shortly. + m_ctx->BindFBOToCtx( m_drawableFBO, GL_READ_FRAMEBUFFER_EXT ); + m_ctx->BindFBOToCtx( m_drawableFBO, GL_DRAW_FRAMEBUFFER_EXT ); + + // we create two IDirect3DSurface9's. These will be known as the internal render target 0 and the depthstencil. + + GLMPRINTF(("-X- IDirect3DDevice9::Create making color render target...")); + // color surface + result = this->CreateRenderTarget( + m_params.m_presentationParameters.BackBufferWidth, // width + m_params.m_presentationParameters.BackBufferHeight, // height + m_params.m_presentationParameters.BackBufferFormat, // format + m_params.m_presentationParameters.MultiSampleType, // MSAA depth + m_params.m_presentationParameters.MultiSampleQuality, // MSAA quality + true, // lockable + &m_defaultColorSurface, // ppSurface + NULL // shared handle + ); + + if (result != S_OK) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Create (error out)")); + return result; + } + // do not do an AddRef.. + + GLMPRINTF(("-X- IDirect3DDevice9::Create making color render target complete -> %08x", m_defaultColorSurface )); + + GLMPRINTF(("-X- IDirect3DDevice9::Create setting color render target...")); + result = this->SetRenderTarget(0, m_defaultColorSurface); + if (result != S_OK) + { + GLMPRINTF(("< IDirect3DDevice9::Create (error out)")); + return result; + } + GLMPRINTF(("-X- IDirect3DDevice9::Create setting color render target complete.")); + + Assert (m_params.m_presentationParameters.EnableAutoDepthStencil); + + GLMPRINTF(("-X- IDirect3DDevice9::Create making depth-stencil...")); + result = CreateDepthStencilSurface( + m_params.m_presentationParameters.BackBufferWidth, // width + m_params.m_presentationParameters.BackBufferHeight, // height + m_params.m_presentationParameters.AutoDepthStencilFormat, // format + m_params.m_presentationParameters.MultiSampleType, // MSAA depth + m_params.m_presentationParameters.MultiSampleQuality, // MSAA quality + TRUE, // enable z-buffer discard ???? + &m_defaultDepthStencilSurface, // ppSurface + NULL // shared handle + ); + if (result != S_OK) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Create (error out)")); + return result; + } + // do not do an AddRef here.. + + GLMPRINTF(("-X- IDirect3DDevice9::Create making depth-stencil complete -> %08x", m_defaultDepthStencilSurface)); + GLMPRINTF(("-X- Direct3DDevice9::Create setting depth-stencil render target...")); + result = this->SetDepthStencilSurface(m_defaultDepthStencilSurface); + if (result != S_OK) + { + GLMDebugger(); + GLMPRINTF(("<-X- IDirect3DDevice9::Create (error out)")); + return result; + } + GLMPRINTF(("-X- IDirect3DDevice9::Create setting depth-stencil render target complete.")); + + bool ready = m_drawableFBO->IsReady(); + if (!ready) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Create (error out)")); + return (HRESULT)-1; + } + + // this next part really needs to be inside GLMContext.. or replaced with D3D style viewport setup calls. + m_ctx->GenDebugFontTex(); + + // blast the gl state mirror... + memset( &this->gl, 0, sizeof( this->gl ) ); + + GLScissorEnable_t defScissorEnable = { true }; + GLScissorBox_t defScissorBox = { 0,0, m_params.m_presentationParameters.BackBufferWidth,m_params.m_presentationParameters.BackBufferHeight }; + GLViewportBox_t defViewportBox = { 0,0, m_params.m_presentationParameters.BackBufferWidth,m_params.m_presentationParameters.BackBufferHeight }; + GLViewportDepthRange_t defViewportDepthRange = { 0.1, 1000.0 }; + GLCullFaceEnable_t defCullFaceEnable = { true }; + GLCullFrontFace_t defCullFrontFace = { GL_CCW }; + + gl.m_ScissorEnable = defScissorEnable; + gl.m_ScissorBox = defScissorBox; + gl.m_ViewportBox = defViewportBox; + gl.m_ViewportDepthRange = defViewportDepthRange; + gl.m_CullFaceEnable = defCullFaceEnable; + gl.m_CullFrontFace = defCullFrontFace; + + gl.m_stateDirtyMask = (1<RenderedSize( m_params.m_presentationParameters.BackBufferWidth, m_params.m_presentationParameters.BackBufferHeight, true ); // true = set + + return result; +#else + Debugger(); + return D3DERR_INVALIDCALL; +#endif +} + +IDirect3DDevice9::~IDirect3DDevice9() +{ + GLMPRINTF(( "-D- IDirect3DDevice9::~IDirect3DDevice9 signpost" )); // want to know when this is called, if ever +} + +#pragma mark ----- Basics - (IDirect3DDevice9) + + +HRESULT IDirect3DDevice9::Reset(D3DPRESENT_PARAMETERS* pPresentationParameters) +{ +#if DX9MODE + HRESULT result = S_OK; + + // define the task of reset as: + // provide new drawable RT's for the backbuffer (color and depthstencil). + // fix up viewport / scissor.. + // then pass the new presentation parameters through to GLM. + // (it will in turn notify appframework on the next present... which may be very soon, as mode changes are usually spotted inside Present() ). + + // so some of this looks a lot like Create - we're just a subset of what it does. + // with a little work you could refactor this to be common code. + + //------------------------------------------------------------------------------- absorb new presentation params.. + + m_params.m_presentationParameters = *pPresentationParameters; + + //------------------------------------------------------------------------------- color buffer.. + // release old color surface if it's there.. + if (m_defaultColorSurface) + { + ULONG refc = m_defaultColorSurface->Release( 0, "IDirect3DDevice9::Reset public release color surface" ); + Assert( !refc ); + m_defaultColorSurface = NULL; + } + + GLMPRINTF(("-X- IDirect3DDevice9::Reset making new color render target...")); + // color surface + result = this->CreateRenderTarget( + m_params.m_presentationParameters.BackBufferWidth, // width + m_params.m_presentationParameters.BackBufferHeight, // height + m_params.m_presentationParameters.BackBufferFormat, // format + m_params.m_presentationParameters.MultiSampleType, // MSAA depth + m_params.m_presentationParameters.MultiSampleQuality, // MSAA quality + true, // lockable + &m_defaultColorSurface, // ppSurface + NULL // shared handle + ); + + if (result != S_OK) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Reset (error out)")); + return result; + } + // do not do an AddRef here.. + + GLMPRINTF(("-X- IDirect3DDevice9::Reset making color render target complete -> %08x", m_defaultColorSurface )); + + GLMPRINTF(("-X- IDirect3DDevice9::Reset setting color render target...")); + result = this->SetRenderTarget(0, m_defaultColorSurface); + if (result != S_OK) + { + GLMPRINTF(("< IDirect3DDevice9::Reset (error out)")); + return result; + } + GLMPRINTF(("-X- IDirect3DDevice9::Reset setting color render target complete.")); + + + //-------------------------------------------------------------------------------depth stencil buffer + // release old depthstencil surface if it's there.. + if (m_defaultDepthStencilSurface) + { + ULONG refc = m_defaultDepthStencilSurface->Release( 0, "IDirect3DDevice9::Reset public release depthstencil surface" ); + Assert(!refc); + m_defaultDepthStencilSurface = NULL; + } + + Assert (m_params.m_presentationParameters.EnableAutoDepthStencil); + + GLMPRINTF(("-X- IDirect3DDevice9::Reset making depth-stencil...")); + result = CreateDepthStencilSurface( + m_params.m_presentationParameters.BackBufferWidth, // width + m_params.m_presentationParameters.BackBufferHeight, // height + m_params.m_presentationParameters.AutoDepthStencilFormat, // format + m_params.m_presentationParameters.MultiSampleType, // MSAA depth + m_params.m_presentationParameters.MultiSampleQuality, // MSAA quality + TRUE, // enable z-buffer discard ???? + &m_defaultDepthStencilSurface, // ppSurface + NULL // shared handle + ); + if (result != S_OK) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Reset (error out)")); + return result; + } + // do not do an AddRef here.. + + GLMPRINTF(("-X- IDirect3DDevice9::Reset making depth-stencil complete -> %08x", m_defaultDepthStencilSurface)); + + GLMPRINTF(("-X- IDirect3DDevice9::Reset setting depth-stencil render target...")); + result = this->SetDepthStencilSurface(m_defaultDepthStencilSurface); + if (result != S_OK) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Reset (error out)")); + return result; + } + GLMPRINTF(("-X- IDirect3DDevice9::Reset setting depth-stencil render target complete.")); + + bool ready = m_drawableFBO->IsReady(); + if (!ready) + { + GLMPRINTF(("<-X- IDirect3DDevice9::Reset (error out)")); + return D3DERR_DEVICELOST; + } + + //-------------------------------------------------------------------------------zap viewport and scissor to new backbuffer size + + GLScissorEnable_t defScissorEnable = { true }; + GLScissorBox_t defScissorBox = { 0,0, m_params.m_presentationParameters.BackBufferWidth,m_params.m_presentationParameters.BackBufferHeight }; + GLViewportBox_t defViewportBox = { 0,0, m_params.m_presentationParameters.BackBufferWidth,m_params.m_presentationParameters.BackBufferHeight }; + GLViewportDepthRange_t defViewportDepthRange = { 0.1, 1000.0 }; + GLCullFaceEnable_t defCullFaceEnable = { true }; + GLCullFrontFace_t defCullFrontFace = { GL_CCW }; + + gl.m_ScissorEnable = defScissorEnable; + gl.m_ScissorBox = defScissorBox; + gl.m_ViewportBox = defViewportBox; + gl.m_ViewportDepthRange = defViewportDepthRange; + gl.m_CullFaceEnable = defCullFaceEnable; + gl.m_CullFrontFace = defCullFrontFace; + + gl.m_stateDirtyMask |= (1<m_displayParams.m_focusWindow; + Assert( glmParams.m_focusWindow != NULL ); + + // so GetClientRect can return sane answers + uint width, height; + g_engine->RenderedSize( pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight, true ); // true = set + + m_ctx->SetDisplayParams( &glmParams ); + + return S_OK; +#else + Debugger(); + return D3DERR_INVALIDCALL; +#endif +} + +HRESULT IDirect3DDevice9::SetViewport(CONST D3DVIEWPORT9* pViewport) +{ + GLMPRINTF(("-X- IDirect3DDevice9::SetViewport : minZ %f, maxZ %f",pViewport->MinZ, pViewport->MaxZ )); + + gl.m_ViewportBox.x = pViewport->X; + gl.m_ViewportBox.width = pViewport->Width; + + gl.m_ViewportBox.y = pViewport->Y; + gl.m_ViewportBox.height = pViewport->Height; + + gl.m_stateDirtyMask |= (1<MinZ; + gl.m_ViewportDepthRange.far = pViewport->MaxZ; + + gl.m_stateDirtyMask |= (1<BeginFrame(); + + return S_OK; +} + +HRESULT IDirect3DDevice9::EndScene() +{ + m_ctx->EndFrame(); + return S_OK; +} + + +// stolen from glmgrbasics.cpp + +enum ECarbonModKeyIndex +{ + EcmdKeyBit = 8, /* command key down?*/ + EshiftKeyBit = 9, /* shift key down?*/ + EalphaLockBit = 10, /* alpha lock down?*/ + EoptionKeyBit = 11, /* option key down?*/ + EcontrolKeyBit = 12 /* control key down?*/ +}; + +enum ECarbonModKeyMask +{ + EcmdKey = 1 << EcmdKeyBit, + EshiftKey = 1 << EshiftKeyBit, + EalphaLock = 1 << EalphaLockBit, + EoptionKey = 1 << EoptionKeyBit, + EcontrolKey = 1 << EcontrolKeyBit +}; + +//ConVar gl_blitmode( "gl_blitmode", "1" ); +int gl_blitmode = 1; + +HRESULT IDirect3DDevice9::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,VD3DHWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) +{ + // before attempting to present a tex, make sure it's been resolved if it was MSAA. + // if we push that responsibility down to m_ctx->Present, it could probably do it without an extra copy. + // i.e. anticipate the blit from the resolvedtex to GL_BACK, and just do that instead. + + // no explicit ResolveTex call first - that got pushed down into GLMContext::Present + m_ctx->Present( m_defaultColorSurface->m_tex ); + + return S_OK; +} + +#pragma mark ----- Textures - (IDirect3DDevice9) +#pragma mark ( create functions for each texture are now adjacent to the rest of the methods for each texture class) + + +HRESULT IDirect3DDevice9::SetTexture(DWORD Stage,IDirect3DBaseTexture9* pTexture) +{ + // texture sets are sent through immediately to GLM + // but we also latch the value so we know which TMU's are active. + // whuch can help FlushSamplers do less work. + + // place new tex + m_textures[Stage] = pTexture; + if (!pTexture) + { + m_ctx->SetSamplerTex( Stage, NULL ); + } + else + { + m_ctx->SetSamplerTex( Stage, pTexture->m_tex ); + } + + return S_OK; +} + +HRESULT IDirect3DDevice9::GetTexture(DWORD Stage,IDirect3DBaseTexture9** ppTexture) +{ + // if implemented, should it increase the ref count ?? + GLMDebugger(); + return S_OK; +} + + +#pragma mark ----- RT's and Surfaces - (IDirect3DDevice9) + +HRESULT IDirect3DDevice9::CreateRenderTarget(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Lockable,IDirect3DSurface9** ppSurface,VD3DHANDLE* pSharedHandle, char *debugLabel) +{ + HRESULT result = S_OK; + + IDirect3DSurface9 *surf = new IDirect3DSurface9; + surf->m_restype = D3DRTYPE_SURFACE; + + surf->m_device = this; // always set device on creations! + + GLMTexLayoutKey rtkey; + memset( &rtkey, 0, sizeof(rtkey) ); + + rtkey.m_texGLTarget = GL_TEXTURE_2D; + rtkey.m_xSize = Width; + rtkey.m_ySize = Height; + rtkey.m_zSize = 1; + + rtkey.m_texFormat = Format; + rtkey.m_texFlags = kGLMTexRenderable; + + rtkey.m_texFlags |= kGLMTexSRGB; // all render target tex are SRGB mode + if (m_ctx->Caps().m_cantAttachSRGB) + { + // this config can't support SRGB render targets. quietly turn off the sRGB bit. + rtkey.m_texFlags &= ~kGLMTexSRGB; + } + + if ( (MultiSample !=0) && (!m_ctx->Caps().m_nvG7x) ) + { + rtkey.m_texFlags |= kGLMTexMultisampled; + rtkey.m_texSamples = MultiSample; + // FIXME no support for "MS quality" yet + } + + surf->m_tex = m_ctx->NewTex( &rtkey, debugLabel ); + surf->m_face = 0; + surf->m_mip = 0; + + //desc + surf->m_desc.Format = Format; + surf->m_desc.Type = D3DRTYPE_SURFACE; + surf->m_desc.Usage = 0; //FIXME ??????????? + surf->m_desc.Pool = D3DPOOL_DEFAULT; //FIXME ??????????? + surf->m_desc.MultiSampleType = MultiSample; + surf->m_desc.MultiSampleQuality = MultisampleQuality; + surf->m_desc.Width = Width; + surf->m_desc.Height = Height; + + *ppSurface = (result==S_OK) ? surf : NULL; + + #if IUNKNOWN_ALLOC_SPEW + char scratch[1024]; + sprintf(scratch,"RT %s", surf->m_tex->m_layout->m_layoutSummary ); + surf->SetMark( true, scratch ); + #endif + + + return result; +} + +HRESULT IDirect3DDevice9::SetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9* pRenderTarget) +{ + HRESULT result = S_OK; + + GLMPRINTF(("-F- SetRenderTarget index=%d, surface=%8x (tex=%8x %s)", + RenderTargetIndex, + pRenderTarget, + pRenderTarget ? pRenderTarget->m_tex : NULL, + pRenderTarget ? pRenderTarget->m_tex->m_layout->m_layoutSummary : "" + )); + + // note that it is OK to pass NULL for pRenderTarget, it implies that you would like to detach any color buffer from that target index + + // behaviors... + // if new surf is same as old surf, no change in refcount, in fact, it's early exit + IDirect3DSurface9 *oldTarget = m_rtSurfaces[RenderTargetIndex]; + + if (pRenderTarget == oldTarget) + { + GLMPRINTF(("-F- --> no change",RenderTargetIndex)); + return S_OK; + } + + // we now know that the new surf is not the same as the old surf. + // you can't assume either one is non NULL here though. + + if (m_rtSurfaces[RenderTargetIndex]) + { + m_rtSurfaces[RenderTargetIndex]->Release( 1, "-A SetRenderTarget private release" ); // note this is the private refcount being lowered + } + + if (pRenderTarget) + { + pRenderTarget->AddRef( 1, "+A SetRenderTarget private addref" ); // again, private refcount being raised + } + + m_rtSurfaces[RenderTargetIndex] = pRenderTarget; // emplace it whether NULL or not + + if (!pRenderTarget) + { + GLMPRINTF(("-F- --> Setting NULL render target on index=%d ",RenderTargetIndex)); + } + else + { + GLMPRINTF(("-F- --> attaching index=%d on drawing FBO (%8x)",RenderTargetIndex, m_drawableFBO)); + // attach color to FBO + GLMFBOTexAttachParams rtParams; + memset( &rtParams, 0, sizeof(rtParams) ); + + rtParams.m_tex = pRenderTarget->m_tex; + rtParams.m_face = pRenderTarget->m_face; + rtParams.m_mip = pRenderTarget->m_mip; + rtParams.m_zslice = 0; // FIXME if you ever want to be able to render to slices of a 3D tex.. + + m_drawableFBO->TexAttach( &rtParams, (EGLMFBOAttachment)(kAttColor0 + RenderTargetIndex) ); + } + + return result; +} + +HRESULT IDirect3DDevice9::GetRenderTarget(DWORD RenderTargetIndex,IDirect3DSurface9** ppRenderTarget) +{ + if ( !m_rtSurfaces[ RenderTargetIndex ] ) + return D3DERR_NOTFOUND; + + if ( ( RenderTargetIndex > 4 ) || !ppRenderTarget ) + return D3DERR_INVALIDCALL; + + // safe because of early exit on NULL above + m_rtSurfaces[ RenderTargetIndex ]->AddRef(0, "+B GetRenderTarget public addref"); // per http://msdn.microsoft.com/en-us/library/bb174404(VS.85).aspx + + *ppRenderTarget = m_rtSurfaces[ RenderTargetIndex ]; + + return S_OK; +} + +HRESULT IDirect3DDevice9::CreateOffscreenPlainSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DPOOL Pool,IDirect3DSurface9** ppSurface,VD3DHANDLE* pSharedHandle) +{ + // set surf->m_restype to D3DRTYPE_SURFACE... + + // this is almost identical to CreateRenderTarget.. + + HRESULT result = S_OK; + + IDirect3DSurface9 *surf = new IDirect3DSurface9; + surf->m_restype = D3DRTYPE_SURFACE; + + surf->m_device = this; // always set device on creations! + + GLMTexLayoutKey rtkey; + memset( &rtkey, 0, sizeof(rtkey) ); + + rtkey.m_texGLTarget = GL_TEXTURE_2D; + rtkey.m_xSize = Width; + rtkey.m_ySize = Height; + rtkey.m_zSize = 1; + + rtkey.m_texFormat = Format; + rtkey.m_texFlags = kGLMTexRenderable; + + surf->m_tex = m_ctx->NewTex( &rtkey, "offscreen plain surface" ); + surf->m_face = 0; + surf->m_mip = 0; + + //desc + surf->m_desc.Format = Format; + surf->m_desc.Type = D3DRTYPE_SURFACE; + surf->m_desc.Usage = 0; + surf->m_desc.Pool = D3DPOOL_DEFAULT; + surf->m_desc.MultiSampleType = D3DMULTISAMPLE_NONE; + surf->m_desc.MultiSampleQuality = 0; + surf->m_desc.Width = Width; + surf->m_desc.Height = Height; + + *ppSurface = (result==S_OK) ? surf : NULL; + + return result; +} + +HRESULT IDirect3DDevice9::CreateDepthStencilSurface(UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,DWORD MultisampleQuality,BOOL Discard,IDirect3DSurface9** ppSurface,VD3DHANDLE* pSharedHandle) +{ + HRESULT result = S_OK; + + IDirect3DSurface9 *surf = new IDirect3DSurface9; + surf->m_restype = D3DRTYPE_SURFACE; + + surf->m_device = this; // always set device on creations! + + GLMTexLayoutKey depthkey; + memset( &depthkey, 0, sizeof(depthkey) ); + + depthkey.m_texGLTarget = GL_TEXTURE_2D; + depthkey.m_xSize = Width; + depthkey.m_ySize = Height; + depthkey.m_zSize = 1; + + depthkey.m_texFormat = Format; + depthkey.m_texFlags = kGLMTexRenderable | kGLMTexIsDepth | kGLMTexIsStencil; + + if ( (MultiSample !=0) && (!m_ctx->Caps().m_nvG7x) ) + { + depthkey.m_texFlags |= kGLMTexMultisampled; + depthkey.m_texSamples = MultiSample; + // FIXME no support for "MS quality" yet + } + + surf->m_tex = m_ctx->NewTex( &depthkey, "depth-stencil surface" ); + surf->m_face = 0; + surf->m_mip = 0; + + //desc + + surf->m_desc.Format = Format; + surf->m_desc.Type = D3DRTYPE_SURFACE; + surf->m_desc.Usage = 0; //FIXME ??????????? + surf->m_desc.Pool = D3DPOOL_DEFAULT; //FIXME ??????????? + surf->m_desc.MultiSampleType = MultiSample; + surf->m_desc.MultiSampleQuality = MultisampleQuality; + surf->m_desc.Width = Width; + surf->m_desc.Height = Height; + + *ppSurface = (result==S_OK) ? surf : NULL; + + return result; +} + +HRESULT IDirect3DDevice9::SetDepthStencilSurface(IDirect3DSurface9* pNewZStencil) +{ + HRESULT result = S_OK; + + GLMPRINTF(("-F- SetDepthStencilSurface, surface=%8x (tex=%8x %s)", + pNewZStencil, + pNewZStencil ? pNewZStencil->m_tex : NULL, + pNewZStencil ? pNewZStencil->m_tex->m_layout->m_layoutSummary : "" + )); + + if (pNewZStencil) + { + pNewZStencil->AddRef(1, "+A SetDepthStencilSurface private addref"); + } + + if (m_dsSurface) + { + m_dsSurface->Release(1, "-A SetDepthStencilSurface private release"); + // do not do a Release here.. + } + + if (m_dsSurface != pNewZStencil) + { + GLMPRINTF(("-F- --> attaching depthstencil %8x on drawing FBO (%8x)", pNewZStencil, m_drawableFBO)); + + m_dsSurface = pNewZStencil; + + // aka FBO attach + + GLMFBOTexAttachParams depthParams; + memset( &depthParams, 0, sizeof(depthParams) ); + + // NULL is OK - it means unbind the depth buffer + depthParams.m_tex = (pNewZStencil) ? pNewZStencil->m_tex : NULL; + depthParams.m_face = 0; + depthParams.m_mip = 0; + depthParams.m_zslice= 0; + + // brute force baby + // clear old attachments in all D/S categories + m_drawableFBO->TexDetach( kAttStencil ); + m_drawableFBO->TexDetach( kAttDepth ); + m_drawableFBO->TexDetach( kAttDepthStencil ); + + // select dest for new attachment + + if (depthParams.m_tex!=NULL) + { + EGLMFBOAttachment destAttach = (depthParams.m_tex->m_layout->m_format->m_glDataFormat != 34041) ? kAttDepth : kAttDepthStencil; + m_drawableFBO->TexAttach( &depthParams, destAttach ); // attach(NULL) is allowed to mean "detach". + } + } + else + { + GLMPRINTF(("-F- --> no change")); + } + + return result; +} + +HRESULT IDirect3DDevice9::GetDepthStencilSurface(IDirect3DSurface9** ppZStencilSurface) +{ + if ( !ppZStencilSurface ) + { + return D3DERR_INVALIDCALL; + } + + if ( !m_dsSurface ) + { + *ppZStencilSurface = NULL; + return D3DERR_NOTFOUND; + } + + m_dsSurface->AddRef(0, "+B GetDepthStencilSurface public addref"); // per http://msdn.microsoft.com/en-us/library/bb174384(VS.85).aspx + + *ppZStencilSurface = m_dsSurface; + + return S_OK; +} + +HRESULT IDirect3DDevice9::GetRenderTargetData(IDirect3DSurface9* pRenderTarget,IDirect3DSurface9* pDestSurface) +{ + // is it just a blit ? + + this->StretchRect( pRenderTarget, NULL, pDestSurface, NULL, D3DTEXF_NONE ); // is this good enough ??? + + return S_OK; +} + +HRESULT IDirect3DDevice9::GetFrontBufferData(UINT iSwapChain,IDirect3DSurface9* pDestSurface) +{ + Debugger(); + return S_OK; +} + +HRESULT IDirect3DDevice9::StretchRect(IDirect3DSurface9* pSourceSurface,CONST RECT* pSourceRect,IDirect3DSurface9* pDestSurface,CONST RECT* pDestRect,D3DTEXTUREFILTERTYPE Filter) +{ + // find relevant slices in GLM tex + + CGLMTex *srcTex = pSourceSurface->m_tex; + int srcSliceIndex = srcTex->CalcSliceIndex( pSourceSurface->m_face, pSourceSurface->m_mip ); + GLMTexLayoutSlice *srcSlice = &srcTex->m_layout->m_slices[ srcSliceIndex ]; + + CGLMTex *dstTex = pDestSurface->m_tex; + int dstSliceIndex = dstTex->CalcSliceIndex( pDestSurface->m_face, pDestSurface->m_mip ); + GLMTexLayoutSlice *dstSlice = &dstTex->m_layout->m_slices[ dstSliceIndex ]; + + if ( dstTex->m_rboName != 0 ) + { + Assert(!"No path yet for blitting into an MSAA tex"); + return S_OK; + } + + bool useFastBlit = (gl_blitmode != 0); + + if ( !useFastBlit && (srcTex->m_rboName !=0)) // old way, we do a resolve to scratch tex first (necessitating two step blit) + { + m_ctx->ResolveTex( srcTex, true ); + } + + // set up source/dest rect in GLM form + GLMRect srcRect, dstRect; + + // d3d nomenclature: + // Y=0 is the visual top and also aligned with V=0. + + srcRect.xmin = pSourceRect ? pSourceRect->left : 0; + srcRect.xmax = pSourceRect ? pSourceRect->right : srcSlice->m_xSize; + srcRect.ymin = pSourceRect ? pSourceRect->top : 0; + srcRect.ymax = pSourceRect ? pSourceRect->bottom : srcSlice->m_ySize; + + dstRect.xmin = pDestRect ? pDestRect->left : 0; + dstRect.xmax = pDestRect ? pDestRect->right : dstSlice->m_xSize; + dstRect.ymin = pDestRect ? pDestRect->top : 0; + dstRect.ymax = pDestRect ? pDestRect->bottom : dstSlice->m_ySize; + + GLenum filterGL = 0; + switch(Filter) + { + case D3DTEXF_NONE: + case D3DTEXF_POINT: + filterGL = GL_NEAREST; + break; + + case D3DTEXF_LINEAR: + filterGL = GL_LINEAR; + break; + + default: // D3DTEXF_ANISOTROPIC + Assert(!"Impl aniso stretch"); + break; + } + + if (useFastBlit) + { + m_ctx->Blit2( srcTex, &srcRect, pSourceSurface->m_face, pSourceSurface->m_mip, + dstTex, &dstRect, pDestSurface->m_face, pDestSurface->m_mip, + filterGL + ); + } + else + { + m_ctx->BlitTex( srcTex, &srcRect, pSourceSurface->m_face, pSourceSurface->m_mip, + dstTex, &dstRect, pDestSurface->m_face, pDestSurface->m_mip, + filterGL + ); + } + + return S_OK; +} + + +// This totally sucks, but this information can't be gleaned any +// other way when translating from D3D to GL at this level +// +// This returns a mask, since multiple GLSL "varyings" can be tagged with centroid +static uint32 CentroidMaskFromName( bool bPixelShader, const char *pName ) +{ + if ( !pName ) + return 0; + + if ( bPixelShader ) + { + if ( V_stristr( pName, "lightmappedgeneric_ps" ) || V_strstr( pName, "worldtwotextureblend_ps" ) ) + { + return (0x01 << 2) | (0x01 << 3); // iterators 2 and 3 + } + else if ( V_stristr( pName, "lightmappedreflective_ps" ) || V_stristr( pName, "water_ps" ) ) + { + return (0x01 << 6) | (0x01 << 7); // iterators 6 and 7 + } + else if ( V_stristr( pName, "shadow_ps" ) ) + { + return (0x01 << 0) | (0x01 << 1) | (0x01 << 3) | (0x01 << 3) | (0x01 << 4); // iterators 0 through 4 + } + else if ( V_stristr( pName, "ShaderedGlass_ps" ) ) + { + return (0x01 << 2); // iterator 2 + } + else if ( V_stristr( pName, "WorldVertexAlpha_ps" ) || V_stristr( pName, "WorldVertexTransition_ps" ) ) + { + // These pixel shaders want centroid but shouldn't be used + Assert(0); + return 0; + } + } + else // vertex shader + { + // Vertex shaders also + if ( V_stristr( pName, "lightmappedgeneric_vs" ) ) + { + return (0x01 << 2) | (0x01 << 3); // iterators 2 and 3 + } + else if ( V_stristr( pName, "lightmappedreflective_vs" ) || V_stristr( pName, "water_vs" ) ) + { + return (0x01 << 6) | (0x01 << 7); // iterators 6 and 7 + } + else if ( V_stristr( pName, "shadow_vs" ) ) + { + return (0x01 << 0) | (0x01 << 1) | (0x01 << 3) | (0x01 << 3) | (0x01 << 4); // iterators 0 through 4 + } + else if ( V_stristr( pName, "ShaderedGlass_vs" ) ) + { + return (0x01 << 2); // iterator 2 + } + } + + // This shader doesn't have any centroid iterators + return 0; +} + + +// This totally sucks, but this information can't be gleaned any +// other way when translating from D3D to GL at this level +static int ShadowDepthSamplerFromName( const char *pName ) +{ + if ( !pName ) + return -1; + + if ( V_stristr( pName, "water_ps" ) ) + { + return 7; + } + else if ( V_stristr( pName, "infected_ps" ) ) + { + return 1; + } + else if ( V_stristr( pName, "phong_ps" ) ) + { + return 4; + } + else if ( V_stristr( pName, "vertexlit_and_unlit_generic_bump_ps" ) ) + { + return 8; + } + else if ( V_stristr( pName, "vertexlit_and_unlit_generic_ps" ) ) + { + return 8; + } + else if ( V_stristr( pName, "eye_refract_ps" ) ) + { + return 6; + } + else if ( V_stristr( pName, "eyes_flashlight_ps" ) ) + { + return 4; + } + else if ( V_stristr( pName, "worldtwotextureblend_ps" ) ) + { + return 7; + } + else if ( V_stristr( pName, "teeth_flashlight_ps" ) ) + { + return 2; + } + else if ( V_stristr( pName, "flashlight_ps" ) ) // substring of above, make sure this comes last!! + { + return 7; + } + + // This shader doesn't have a shadow depth map sampler + return -1; +} + + +#pragma mark ----- Pixel Shaders - (IDirect3DDevice9) + +HRESULT IDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixelShader9** ppShader, const char *pShaderName, char *debugLabel) +{ + HRESULT result = D3DERR_INVALIDCALL; + *ppShader = NULL; + + int nShadowDepthSampler = ShadowDepthSamplerFromName( pShaderName ); + uint32 nCentroidMask = CentroidMaskFromName( true, pShaderName ); + + bool passthrough = ( memcmp( pFunction, "//GLSLfp", 8 ) ==0 ); // if we were given GLSL text, pass it through instead of treating it as bytecodes.. + + if ( g_bUseControlFlow || !m_ctx->Caps().m_hasDualShaders ) + { + // either having control-flow 'on' or -glmdualshaders 'off' disqualifies ARB assembler mode + g_useASMTranslations = false; + } + + if ( ! (g_useASMTranslations || g_useGLSLTranslations) ) + { + Assert(!"Must set at least one translation option.."); + *ppShader = NULL; + return -1; + } + else + { + int numTranslations = (g_useASMTranslations!=0) + (g_useGLSLTranslations!=0); + + bool bVertexShader = false; + + // we can do one or two translated forms. they go together in a single buffer with some markers to allow GLM to break it up. + // this also lets us mirror each set of translations to disk with a single file making it easier to view and edit side by side. + + int maxTranslationSize = 50000; // size of any one translation + + CUtlBuffer transbuf( 3000, numTranslations * maxTranslationSize, CUtlBuffer::TEXT_BUFFER ); + CUtlBuffer tempbuf( 3000, maxTranslationSize, CUtlBuffer::TEXT_BUFFER ); + + if (passthrough) + { + // no-translation path - copy text to transbuf + transbuf.AppendString ( (char*)pFunction ); + transbuf.AppendString( "\n\n" ); // whitespace + + bVertexShader = false; + } + else + { + if ( g_useASMTranslations ) + { + // no extra tag needed for ARBfp, just use the !!ARBfp marker + + tempbuf.EnsureCapacity( maxTranslationSize ); + g_D3DToOpenGLTranslatorASM.TranslateShader( (uint32 *) pFunction, &tempbuf, &bVertexShader, D3DToGL_OptionUseEnvParams, nShadowDepthSampler, 0, debugLabel ); + + // grow to encompass... + transbuf.AppendString ( (char*)tempbuf.Base() ); + transbuf.AppendString( "\n\n" ); // whitespace + } + + if ( g_useGLSLTranslations ) + { + transbuf.AppendString( "//GLSLfp\n" ); // this is required so GLM can crack the text apart + + // note the GLSL translator wants its own buffer + tempbuf.EnsureCapacity( maxTranslationSize ); + + uint glslPixelShaderOptions = D3DToGL_OptionGLSL | D3DToGL_OptionUseEnvParams; + + + // Fake SRGB mode - needed on R500, probably indefinitely. + // Do this stuff if caps show m_needsFakeSRGB=true and the sRGBWrite state is true + // (but not if it's engine_post which is special) + + if (!m_ctx->Caps().m_hasGammaWrites) + { + if ( pShaderName ) + { + if ( !V_stristr( pShaderName, "engine_post" ) ) + { + glslPixelShaderOptions |= D3DToGL_OptionSRGBWriteSuffix; + } + } + } + + if (m_ctx->Caps().m_hasBindableUniforms) + { + glslPixelShaderOptions |= D3DToGL_OptionUseBindableUniforms; + } + g_D3DToOpenGLTranslatorGLSL.TranslateShader( (uint32 *) pFunction, &tempbuf, &bVertexShader, glslPixelShaderOptions, nShadowDepthSampler, nCentroidMask, debugLabel ); + + transbuf.AppendString( (char*)tempbuf.Base() ); + transbuf.AppendString( "\n\n" ); // whitespace + } + } + + if ( bVertexShader ) + { + // don't cross the streams + Assert(!"Can't accept vertex shader in CreatePixelShader"); + result = D3DERR_INVALIDCALL; + } + else + { + IDirect3DPixelShader9 *newprog = new IDirect3DPixelShader9; + + newprog->m_pixProgram = m_ctx->NewProgram( kGLMFragmentProgram, (char *)transbuf.Base() ) ; + + newprog->m_device = this; + + //------ find the frag program metadata and extract it.. note this takes place even for passthrough shaders, so they need to supply the needed string too + + // find the highwater mark + const char *highWaterPrefix = "//HIGHWATER-"; // try to arrange this so it can work with pure GLSL if needed + const char *highWaterStr = strstr( (char *)transbuf.Base(), highWaterPrefix ); + if (highWaterStr) + { + const char *highWaterActualData = highWaterStr + strlen( highWaterPrefix ); + + int value = -1; + sscanf( highWaterActualData, "%d", &value ); + + newprog->m_pixHighWater = value; + newprog->m_pixProgram->m_descs[kGLMGLSL].m_highWater = value; + } + else + { + Assert(!"couldn't find highwater mark in pixel shader"); + } + + // find the sampler map + const char *samplerMaskPrefix = "//SAMPLERMASK-"; // try to arrange this so it can work with pure GLSL if needed + + char *samplerMaskStr = strstr( (char *)transbuf.Base(), samplerMaskPrefix ); + if (samplerMaskStr) + { + char *samplerMaskActualData = samplerMaskStr + strlen( samplerMaskPrefix ); + + int value = -1; + sscanf( samplerMaskActualData, "%04x", &value ); + + newprog->m_pixSamplerMask = value; + newprog->m_pixProgram->m_samplerMask = value; // helps GLM maintain a better linked pair cache even when SRGB sampler state changes + } + else + { + Assert(!"couldn't find sampler map in pixel shader"); + } + + *ppShader = newprog; + + result = S_OK; + } + } + + + return result; +} + +IDirect3DPixelShader9::~IDirect3DPixelShader9() +{ + GLMPRINTF(( ">-A- ~IDirect3DPixelShader9" )); + + if (m_device) + { + m_device->ReleasedPixelShader( this ); + + if (m_pixProgram) + { + m_pixProgram->m_ctx->DelProgram( m_pixProgram ); + m_pixProgram = NULL; + } + m_device = NULL; + } + + GLMPRINTF(( "<-A- ~IDirect3DPixelShader9" )); +} + + +HRESULT IDirect3DDevice9::SetPixelShader(IDirect3DPixelShader9* pShader) +{ + if (pShader) + { + m_ctx->SetDrawingProgram( kGLMFragmentProgram, pShader->m_pixProgram ); + } + else + { + m_ctx->SetDrawingProgram( kGLMFragmentProgram, NULL ); + } + m_pixelShader = pShader; + + return S_OK; +} + +HRESULT IDirect3DDevice9::SetPixelShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) +{ + m_ctx->SetProgramParametersF( kGLMFragmentProgram, StartRegister, (float *)pConstantData, Vector4fCount ); + + return S_OK; +} + +HRESULT IDirect3DDevice9::SetPixelShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) +{ + GLMPRINTF(("-X- Ignoring IDirect3DDevice9::SetPixelShaderConstantB call, count was %d", BoolCount )); +// actually no way to do this yet. +// m_ctx->SetProgramParametersB( kGLMFragmentProgram, StartRegister, pConstantData, BoolCount ); + + return S_OK; +} + +HRESULT IDirect3DDevice9::SetPixelShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) +{ + GLMPRINTF(("-X- Ignoring IDirect3DDevice9::SetPixelShaderConstantI call, count was %d", Vector4iCount )); +// m_ctx->SetProgramParametersI( kGLMFragmentProgram, StartRegister, pConstantData, Vector4iCount ); + return S_OK; +} + + +#pragma mark ----- Vertex Shaders - (IDirect3DDevice9) + +HRESULT IDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader, const char *pShaderName, char *debugLabel) +{ + HRESULT result = D3DERR_INVALIDCALL; + *ppShader = NULL; + + uint32 nCentroidMask = CentroidMaskFromName( false, pShaderName ); + + bool passthrough = ( memcmp( pFunction, "//GLSLvp", 8 ) ==0 ); // if we were given GLSL text, pass it through instead of treating it as bytecodes.. + + if ( ! (g_useASMTranslations || g_useGLSLTranslations) ) + { + Assert(!"Must set at least one translation option.."); + *ppShader = NULL; + return -1; + } + else + { + int numTranslations = (g_useASMTranslations!=0) + (g_useGLSLTranslations!=0); + + bool bVertexShader = false; + + // we can do one or two translated forms. they go together in a single buffer with some markers to allow GLM to break it up. + // this also lets us mirror each set of translations to disk with a single file making it easier to view and edit side by side. + + int maxTranslationSize = 500000; // size of any one translation + + CUtlBuffer transbuf( 1000, numTranslations * maxTranslationSize, CUtlBuffer::TEXT_BUFFER ); + CUtlBuffer tempbuf( 1000, maxTranslationSize, CUtlBuffer::TEXT_BUFFER ); + + if (passthrough) + { + // no-translation path - copy text to transbuf + transbuf.AppendString ( (char*)pFunction ); + transbuf.AppendString( "\n\n" ); // whitespace + + char *checktext = transbuf.Base(); + bVertexShader = true; + } + else + { + if ( g_useASMTranslations ) + { + // no extra tag needed for ARBvp, just use the !!ARBvp marker + + tempbuf.EnsureCapacity( maxTranslationSize ); + + uint asmTransOptions = D3DToGL_OptionUseEnvParams | D3DToGL_OptionDoFixupZ | D3DToGL_OptionDoFixupY; + + // D3DToGL_OptionDoUserClipPlanes not being set for asm yet, it generates NV VP 2.. + g_D3DToOpenGLTranslatorASM.TranslateShader( (uint32 *) pFunction, &tempbuf, &bVertexShader, asmTransOptions, -1, 0, debugLabel ); + + // grow to encompass... + transbuf.AppendString ( (char*)tempbuf.Base() ); + transbuf.AppendString( "\n\n" ); // whitespace + } + + if ( g_useGLSLTranslations ) + { + transbuf.AppendString( "//GLSLvp\n" ); // this is required so GLM can crack the text apart + + // note the GLSL translator wants its own buffer + tempbuf.EnsureCapacity( maxTranslationSize ); + + uint glslVertexShaderOptions = D3DToGL_OptionGLSL | D3DToGL_OptionUseEnvParams | D3DToGL_OptionDoFixupZ | D3DToGL_OptionDoFixupY; + + if ( g_bUseControlFlow ) + { + glslVertexShaderOptions |= D3DToGL_OptionAllowStaticControlFlow; + } + + if ( m_ctx->Caps().m_hasNativeClipVertexMode ) + { + // note the matched trickery over in IDirect3DDevice9::FlushStates - + // if on a chipset that does no have native gl_ClipVertex support, then + // omit writes to gl_ClipVertex, and instead submit plane equations that have been altered, + // and clipping will take place in GL space using gl_Position instead of gl_ClipVertex. + + // note that this is very much a hack to mate up with ATI R5xx hardware constraints, and with older + // drivers even for later ATI parts like r6xx/r7xx. And it doesn't work on NV parts, so you really + // do have to choose the right way to go. + + glslVertexShaderOptions |= D3DToGL_OptionDoUserClipPlanes; + } + + if (m_ctx->Caps().m_hasBindableUniforms) + { + glslVertexShaderOptions |= D3DToGL_OptionUseBindableUniforms; + } + + g_D3DToOpenGLTranslatorGLSL.TranslateShader( (uint32 *) pFunction, &tempbuf, &bVertexShader, glslVertexShaderOptions, -1, nCentroidMask, debugLabel ); + + transbuf.AppendString( (char*)tempbuf.Base() ); + transbuf.AppendString( "\n\n" ); // whitespace + } + } + + if ( !bVertexShader ) + { + // don't cross the streams + Assert(!"Can't accept pixel shader in CreateVertexShader"); + result = D3DERR_INVALIDCALL; + } + else + { + IDirect3DVertexShader9 *newprog = new IDirect3DVertexShader9; + + newprog->m_device = this; + + newprog->m_vtxProgram = m_ctx->NewProgram( kGLMVertexProgram, (char *)transbuf.Base() ) ; + + // find the highwater mark.. note this takes place even for passthrough shaders, so they need to supply the needed string too + + const char *highWaterPrefix = "//HIGHWATER-"; // try to arrange this so it can work with pure GLSL if needed + const char *highWaterStr = strstr( (char *)transbuf.Base(), highWaterPrefix ); + if (highWaterStr) + { + const char *highWaterActualData = highWaterStr + strlen( highWaterPrefix ); + + int value = -1; + sscanf( highWaterActualData, "%d", &value ); + + newprog->m_vtxHighWater = value; + newprog->m_vtxProgram->m_descs[kGLMGLSL].m_highWater = value; + } + else + { + Assert(!"couldn't find highwater mark in vertex shader"); + } + + // find the attrib map.. + const char *attribMapPrefix = "//ATTRIBMAP-"; // try to arrange this so it can work with pure GLSL if needed + const char *textbase = (char *)transbuf.Base(); + + const char *attribMapStr = strstr( textbase, attribMapPrefix ); + if (attribMapStr) + { + const char *attribMapActualData = attribMapStr + strlen( attribMapPrefix ); + for( int i=0; i<16; i++) + { + int value = -1; + const char *dataItem = attribMapActualData + (i*3); + sscanf( dataItem, "%02x", &value ); + if (value >=0) + { + // make sure it's not a terminator + if (value == 0xBB) + { + Debugger(); + } + } + else + { + // probably an 'xx'... check + if ( (dataItem[0] != 'x') || (dataItem[1] != 'x') ) + { + Debugger(); // bad news + } + else + { + value = 0xBB; // not likely to see one of these... "fog with usage index 11" + } + } + newprog->m_vtxAttribMap[i] = value; + } + } + else + { + Debugger(); // that's bad... + } + + *ppShader = newprog; + + result = S_OK; + } + } + + return result; +} + +IDirect3DVertexShader9::~IDirect3DVertexShader9() +{ + GLMPRINTF(( ">-A- ~IDirect3DVertexShader9" )); + + if (m_device) + { + m_device->ReleasedVertexShader( this ); + + if (m_vtxProgram) + { + m_vtxProgram->m_ctx->DelProgram( m_vtxProgram ); + m_vtxProgram = NULL; + } + m_device = NULL; + } + else + { + } + + + GLMPRINTF(( "<-A- ~IDirect3DVertexShader9" )); +} + +HRESULT IDirect3DDevice9::SetVertexShader(IDirect3DVertexShader9* pShader) +{ + if (pShader) + { + m_ctx->SetDrawingProgram( kGLMVertexProgram, pShader->m_vtxProgram ); + } + else + { + m_ctx->SetDrawingProgram( kGLMVertexProgram, NULL ); + } + m_vertexShader = pShader; + + return S_OK; +} + +HRESULT IDirect3DDevice9::SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) // groups of 4 floats! +{ + m_ctx->SetProgramParametersF( kGLMVertexProgram, StartRegister, (float *)pConstantData, Vector4fCount ); + return S_OK; +} + +HRESULT IDirect3DDevice9::SetVertexShaderConstantB(UINT StartRegister,CONST BOOL* pConstantData,UINT BoolCount) // individual bool count! +{ + m_ctx->SetProgramParametersB( kGLMVertexProgram, StartRegister, (int *)pConstantData, BoolCount ); + return S_OK; +} + +HRESULT IDirect3DDevice9::SetVertexShaderConstantI(UINT StartRegister,CONST int* pConstantData,UINT Vector4iCount) // groups of 4 ints! +{ + m_ctx->SetProgramParametersI( kGLMVertexProgram, StartRegister, (int *)pConstantData, Vector4iCount ); + return S_OK; +} + + +#pragma mark ----- Shader Pairs - (IDirect3DDevice9) + +// callers need to ifdef POSIX this, because this method does not exist on real DX9 +HRESULT IDirect3DDevice9::LinkShaderPair( IDirect3DVertexShader9* vs, IDirect3DPixelShader9* ps ) +{ + // these are really GLSL "shaders" not "programs" but the old reference to "program" persists due to the assembler heritage + if (vs->m_vtxProgram && ps->m_pixProgram) + { + m_ctx->LinkShaderPair( vs->m_vtxProgram, ps->m_pixProgram ); + } + return S_OK; +} + +// callers need to ifdef POSIX this, because this method does not exist on real DX9 +// +HRESULT IDirect3DDevice9::QueryShaderPair( int index, GLMShaderPairInfo *infoOut ) +{ + // these are really GLSL "shaders" not "programs" ... + + m_ctx->QueryShaderPair( index, infoOut ); + + return S_OK; +} + + +#pragma mark ----- Vertex Buffers and Vertex Declarations - (IDirect3DDevice9) + +HRESULT IDirect3DDevice9::CreateVertexDeclaration(CONST D3DVERTEXELEMENT9* pVertexElements,IDirect3DVertexDeclaration9** ppDecl) +{ + *ppDecl = NULL; + + // the goal here is to arrive at something which lets us quickly generate GLMVertexSetups. + + // the information we don't have, that must be inferred from the decls, is: + // -> how many unique streams (buffers) are used - pure curiosity + // -> what the stride and offset is for each decl. Size you can figure out on the spot, stride requires surveying all the components in each stream first. + // so init an array of per-stream offsets to 0. + // each one is a cursor that gets bumped by decls. + uint streamOffsets[ D3D_MAX_STREAMS ]; + uint streamCount = 0; + + uint attribMap[16]; + uint attribMapIndex = 0; + memset( attribMap, 0xFF, sizeof( attribMap ) ); + + memset( streamOffsets, 0, sizeof( streamOffsets ) ); + + IDirect3DVertexDeclaration9 *decl9 = new IDirect3DVertexDeclaration9; + + decl9->m_elemCount = 0; + + for (const D3DVERTEXELEMENT9 *src = pVertexElements; (src->Stream != 0xFF); src++) + { + // element + D3DVERTEXELEMENT9_GL *elem = &decl9->m_elements[ decl9->m_elemCount++ ]; + + // copy the D3D decl wholesale. + elem->m_dxdecl = *src; + + // latch current offset in this stream. + elem->m_gldecl.m_offset = streamOffsets[ elem->m_dxdecl.Stream ]; + + // figure out size of this attr and move the cursor + // if cursor was on zero, bump the active stream count + + if (!streamOffsets[ elem->m_dxdecl.Stream ]) + streamCount++; + + int bytes = 0; + switch( elem->m_dxdecl.Type ) + { + case D3DDECLTYPE_FLOAT1: elem->m_gldecl.m_datasize = 1; elem->m_gldecl.m_datatype = GL_FLOAT; elem->m_gldecl.m_normalized=0; bytes = 4; break; + case D3DDECLTYPE_FLOAT2: elem->m_gldecl.m_datasize = 2; elem->m_gldecl.m_datatype = GL_FLOAT; elem->m_gldecl.m_normalized=0; bytes = 8; break; + + //case D3DVSDT_FLOAT3: + case D3DDECLTYPE_FLOAT3: elem->m_gldecl.m_datasize = 3; elem->m_gldecl.m_datatype = GL_FLOAT; elem->m_gldecl.m_normalized=0; bytes = 12; break; + + //case D3DVSDT_FLOAT4: + case D3DDECLTYPE_FLOAT4: elem->m_gldecl.m_datasize = 4; elem->m_gldecl.m_datatype = GL_FLOAT; elem->m_gldecl.m_normalized=0; bytes = 16; break; + + // case D3DVSDT_UBYTE4: + case D3DDECLTYPE_D3DCOLOR: + case D3DDECLTYPE_UBYTE4: + + // Force this path since we're on 10.6.2 and can't rely on EXT_vertex_array_bgra + if ( 1 ) + { + // pass 4 UB's but we know this is out of order compared to D3DCOLOR data + elem->m_gldecl.m_datasize = 4; elem->m_gldecl.m_datatype = GL_UNSIGNED_BYTE; + } + else + { + // pass a GL BGRA color courtesy of http://www.opengl.org/registry/specs/ARB/vertex_array_bgra.txt + elem->m_gldecl.m_datasize = GL_BGRA; elem->m_gldecl.m_datatype = GL_UNSIGNED_BYTE; + } + + elem->m_gldecl.m_normalized = (elem->m_dxdecl.Type == D3DDECLTYPE_D3DCOLOR); + + bytes = 4; + break; + + case D3DDECLTYPE_SHORT2: + // pass 2 US's but we know this is out of order compared to D3DCOLOR data + elem->m_gldecl.m_datasize = 2; elem->m_gldecl.m_datatype = GL_UNSIGNED_SHORT; + + elem->m_gldecl.m_normalized = 0; + + bytes = 4; + break; + + default: Debugger(); return D3DERR_INVALIDCALL; break; + + /* + typedef enum _D3DDECLTYPE + { + D3DDECLTYPE_FLOAT1 = 0, // 1D float expanded to (value, 0., 0., 1.) + D3DDECLTYPE_FLOAT2 = 1, // 2D float expanded to (value, value, 0., 1.) + D3DDECLTYPE_FLOAT3 = 2, // 3D float expanded to (value, value, value, 1.) + D3DDECLTYPE_FLOAT4 = 3, // 4D float + D3DDECLTYPE_D3DCOLOR = 4, // 4D packed unsigned bytes mapped to 0. to 1. range + // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A) + D3DDECLTYPE_UBYTE4 = 5, // 4D unsigned byte + D3DDECLTYPE_SHORT2 = 6, // 2D signed short expanded to (value, value, 0., 1.) + D3DDECLTYPE_SHORT4 = 7, // 4D signed short + + // The following types are valid only with vertex shaders >= 2.0 + + + D3DDECLTYPE_UBYTE4N = 8, // Each of 4 bytes is normalized by dividing to 255.0 + D3DDECLTYPE_SHORT2N = 9, // 2D signed short normalized (v[0]/32767.0,v[1]/32767.0,0,1) + D3DDECLTYPE_SHORT4N = 10, // 4D signed short normalized (v[0]/32767.0,v[1]/32767.0,v[2]/32767.0,v[3]/32767.0) + D3DDECLTYPE_USHORT2N = 11, // 2D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,0,1) + D3DDECLTYPE_USHORT4N = 12, // 4D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,v[2]/65535.0,v[3]/65535.0) + D3DDECLTYPE_UDEC3 = 13, // 3D unsigned 10 10 10 format expanded to (value, value, value, 1) + D3DDECLTYPE_DEC3N = 14, // 3D signed 10 10 10 format normalized and expanded to (v[0]/511.0, v[1]/511.0, v[2]/511.0, 1) + D3DDECLTYPE_FLOAT16_2 = 15, // Two 16-bit floating point values, expanded to (value, value, 0, 1) + D3DDECLTYPE_FLOAT16_4 = 16, // Four 16-bit floating point values + D3DDECLTYPE_UNUSED = 17, // When the type field in a decl is unused. + } D3DDECLTYPE; + */ + } + + // write the offset and move the cursor + elem->m_gldecl.m_offset = streamOffsets[elem->m_dxdecl.Stream]; + streamOffsets[ elem->m_dxdecl.Stream ] += bytes; + + // cannot write m_stride yet, so zero it + elem->m_gldecl.m_stride = 0; + + elem->m_gldecl.m_buffer = NULL; // must be filled in at draw time.. + + // elem count was already bumped. + + // update attrib map + attribMap[ attribMapIndex++ ] = (elem->m_dxdecl.Usage << 4) | (elem->m_dxdecl.UsageIndex); + } + // the loop is done, we now know how many active streams there are, how many atribs are active in the declaration, + // and how big each one is in terms of stride. + + // all that is left is to go back and write the strides - the stride comes from the stream offset cursors accumulated earlier. + for( int j=0; j< decl9->m_elemCount; j++) + { + D3DVERTEXELEMENT9_GL *elem = &decl9->m_elements[ j ]; + + elem->m_gldecl.m_stride = streamOffsets[ elem->m_dxdecl.Stream ]; + } + + *ppDecl = decl9; + + return S_OK; +} + +IDirect3DVertexDeclaration9::~IDirect3DVertexDeclaration9() +{ + GLMPRINTF(("-A- ~IDirect3DVertexDeclaration9 signpost")); +} + +HRESULT IDirect3DDevice9::SetVertexDeclaration(IDirect3DVertexDeclaration9* pDecl) +{ + // we just latch it. At draw time we combine the current vertex decl with the current stream set and generate a vertex setup for GLM. + // GLM can see what the differences are and act accordingly to adjust vert attrib bindings. + + m_vertDecl = pDecl; + + return S_OK; +} + +HRESULT IDirect3DDevice9::SetFVF(DWORD FVF) +{ + Debugger(); + return D3DERR_INVALIDCALL; +} + +HRESULT IDirect3DDevice9::GetFVF(DWORD* pFVF) +{ + Debugger(); + return D3DERR_INVALIDCALL; +} + + +#pragma mark ----- Vertex Buffers and Streams - (IDirect3DDevice9) + +#pragma mark ----- Create function moved to be adjacent to other buffer methods + +HRESULT IDirect3DDevice9::SetStreamSource(UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride) +{ + // perfectly legal to see a vertex buffer of NULL get passed in here. + // so we need an array to track these. + // OK, we are being given the stride, we don't need to calc it.. + + GLMPRINTF(("-X- IDirect3DDevice9::SetStreamSource setting stream #%d to D3D buf %p (GL name %d); offset %d, stride %d", StreamNumber, pStreamData, (pStreamData) ? pStreamData->m_vtxBuffer->m_name: -1, OffsetInBytes, Stride)); + + if (pStreamData) + { + m_streams[ StreamNumber ].m_vtxBuffer = pStreamData; + m_streams[ StreamNumber ].m_offset = OffsetInBytes; + m_streams[ StreamNumber ].m_stride = Stride; + } + else + { + m_streams[ StreamNumber ].m_vtxBuffer = NULL; + m_streams[ StreamNumber ].m_offset = 0; + m_streams[ StreamNumber ].m_stride = 0; + } + + return S_OK; +} + +#pragma mark ----- Index Buffers - (IDirect3DDevice9) +#pragma mark ----- Creatue function relocated to be adjacent to the rest of the index buffer methods + +HRESULT IDirect3DDevice9::SetIndices(IDirect3DIndexBuffer9* pIndexData) +{ + // just latch it. + m_indices.m_idxBuffer = pIndexData; + return S_OK; +} + + +#pragma mark ----- Release Handlers - (IDirect3DDevice9) +void IDirect3DDevice9::ReleasedTexture( IDirect3DBaseTexture9 *baseTex ) +{ + // see if this texture is referenced in any of the texture units and scrub it if so. + for( int i=0; i<16; i++) + { + if (m_textures[i] == baseTex) + { + m_textures[i] = NULL; + m_ctx->SetSamplerTex( i, NULL ); // texture sets go straight through to GLM, no dirty bit + } + } +} + +void IDirect3DDevice9::ReleasedSurface( IDirect3DSurface9 *surface ) +{ + for( int i=0; i<16; i++) + { + if (m_rtSurfaces[i]==surface) + { + // this was a surprise release... scrub it + m_rtSurfaces[i] = NULL; + GLMPRINTF(( "-A- Scrubbed surface %08x from m_rtSurfaces[%d]", surface, i )); + } + } + if( m_dsSurface == surface ) + { + m_dsSurface = NULL; + GLMPRINTF(( "-A- Scrubbed surface %08x from m_dsSurface", surface )); + } + + if ( m_defaultColorSurface == surface ) + { + m_defaultColorSurface = NULL; + GLMPRINTF(( "-A- Scrubbed surface %08x from m_defaultColorSurface", surface )); + } + + if ( m_defaultDepthStencilSurface == surface ) + { + m_defaultDepthStencilSurface = NULL; + GLMPRINTF(( "-A- Scrubbed surface %08x from m_defaultDepthStencilSurface", surface )); + } +} + +void IDirect3DDevice9::ReleasedPixelShader( IDirect3DPixelShader9 *pixelShader ) +{ + if ( m_pixelShader == pixelShader ) + { + m_pixelShader = NULL; + GLMPRINTF(( "-A- Scrubbed pixel shader %08x from m_pixelShader", pixelShader )); + } +} + +void IDirect3DDevice9::ReleasedVertexShader( IDirect3DVertexShader9 *vertexShader ) +{ + if ( m_vertexShader == vertexShader ) + { + m_vertexShader = NULL; + GLMPRINTF(( "-A- Scrubbed vertex shader %08x from m_vertexShader", vertexShader )); + } +} + +void IDirect3DDevice9::ReleasedVertexBuffer( IDirect3DVertexBuffer9 *vertexBuffer ) +{ + for (int i=0; i< D3D_MAX_STREAMS; i++) + { + if ( m_streams[i].m_vtxBuffer == vertexBuffer ) + { + m_streams[i].m_vtxBuffer = NULL; + GLMPRINTF(( "-A- Scrubbed vertex buffer %08x from m_streams[%d]", vertexBuffer, i )); + } + } +} + +void IDirect3DDevice9::ReleasedIndexBuffer( IDirect3DIndexBuffer9 *indexBuffer ) +{ + if ( m_indices.m_idxBuffer == indexBuffer ) + { + m_indices.m_idxBuffer = NULL; + GLMPRINTF(( "-A- Scrubbed index buffer %08x from m_indices", indexBuffer )); + } +} + + +void IDirect3DDevice9::ReleasedQuery( IDirect3DQuery9 *query ) +{ + // nothing to do yet.. +} + + + + +#pragma mark ----- Queries - (IDirect3DDevice9) + +// note that detection of whether queries are supported is done by trying to create one. +// so for GL, be observant here of whether we have that capability or not. +// pretty much have this everywhere but i950. + +HRESULT IDirect3DDevice9::CreateQuery(D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery) +{ + if (m_ctx->Caps().m_hasOcclusionQuery) + { + IDirect3DQuery9 *newquery = new IDirect3DQuery9; + + newquery->m_device = this; + + newquery->m_type = Type; + newquery->m_ctx = m_ctx; + + GLMQueryParams params; + memset( ¶ms, 0, sizeof(params) ); + + bool known = false; + switch(newquery->m_type) + { + case D3DQUERYTYPE_OCCLUSION: /* D3DISSUE_BEGIN, D3DISSUE_END */ + // create an occlusion query + params.m_type = EOcclusion; + break; + + case D3DQUERYTYPE_EVENT: /* D3DISSUE_END */ + params.m_type = EFence; + break; + + case D3DQUERYTYPE_RESOURCEMANAGER: /* D3DISSUE_END */ + case D3DQUERYTYPE_TIMESTAMP: /* D3DISSUE_END */ + case D3DQUERYTYPE_TIMESTAMPFREQ: /* D3DISSUE_END */ + case D3DQUERYTYPE_INTERFACETIMINGS: /* D3DISSUE_BEGIN, D3DISSUE_END */ + case D3DQUERYTYPE_PIXELTIMINGS: /* D3DISSUE_BEGIN, D3DISSUE_END */ + case D3DQUERYTYPE_CACHEUTILIZATION: /* D3DISSUE_BEGIN, D3DISSUE_END */ + Assert( !"Un-implemented query type" ); + break; + + default: + Assert( !"Unknown query type" ); + break; + } + newquery->m_query = m_ctx->NewQuery( ¶ms ); + + *ppQuery = newquery; + return S_OK; + } + else + { + *ppQuery = NULL; + return -1; // failed + } + +} + +IDirect3DQuery9::~IDirect3DQuery9() +{ + GLMPRINTF((">-A- ~IDirect3DQuery9")); + + if (m_device) + { + m_device->ReleasedQuery( this ); + + if (m_query) + { + GLMPRINTF((">-A- ~IDirect3DQuery9 freeing m_query")); + + m_query->m_ctx->DelQuery( m_query ); + m_query = NULL; + + GLMPRINTF(("<-A- ~IDirect3DQuery9 freeing m_query done")); + } + m_device = NULL; + } + + GLMPRINTF(("<-A- ~IDirect3DQuery9")); +} + +#pragma mark ----- Render States - (IDirect3DDevice9) + +struct D3D_RSINFO +{ + int m_class; + D3DRENDERSTATETYPE m_state; + DWORD m_defval; + // m_class runs 0-3. + // 3 = must implement - fully general - "obey" + // 2 = implement setup to the default value (it has a GL effect but does not change later) "obey once" + // 1 = "fake implement" setup to the default value no GL effect, debug break if anything but default value comes through - "ignore" + // 0 = game never ever sets this one, break if someone even tries. "complain" +}; + +#define D3DRS_VALUE_LIMIT 210 +bool g_D3DRS_INFO_unpacked_ready = false; // set to true after unpack +D3D_RSINFO g_D3DRS_INFO_unpacked[ D3DRS_VALUE_LIMIT+1 ]; + +#ifdef D3D_RSI + #error macro collision... rename this +#else + #define D3D_RSI(nclass,nstate,ndefval) { nclass, nstate, ndefval } +#endif + +// FP conversions to hex courtesy of http://babbage.cs.qc.cuny.edu/IEEE-754/Decimal.html +#define CONST_DZERO 0x00000000 +#define CONST_DONE 0x3F800000 +#define CONST_D64 0x42800000 +#define DONT_KNOW_YET 0x31415926 + + +// see http://www.toymaker.info/Games/html/render_states.html + +D3D_RSINFO g_D3DRS_INFO_packed[] = +{ + // these do not have to be in any particular order. they get unpacked into the empty array above for direct indexing. + + D3D_RSI( 3, D3DRS_ZENABLE, DONT_KNOW_YET ), // enable Z test (or W buffering) + D3D_RSI( 3, D3DRS_ZWRITEENABLE, DONT_KNOW_YET ), // enable Z write + D3D_RSI( 3, D3DRS_ZFUNC, DONT_KNOW_YET ), // select Z func + + D3D_RSI( 3, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA ), // see transitiontable.cpp "APPLY_RENDER_STATE_FUNC( D3DRS_COLORWRITEENABLE, ColorWriteEnable )" + + D3D_RSI( 3, D3DRS_CULLMODE, D3DCULL_CCW ), // backface cull control + + D3D_RSI( 3, D3DRS_ALPHABLENDENABLE, DONT_KNOW_YET ), // ->CTransitionTable::ApplySeparateAlphaBlend and ApplyAlphaBlend + D3D_RSI( 3, D3DRS_BLENDOP, D3DBLENDOP_ADD ), + D3D_RSI( 3, D3DRS_SRCBLEND, DONT_KNOW_YET ), + D3D_RSI( 3, D3DRS_DESTBLEND, DONT_KNOW_YET ), + + D3D_RSI( 1, D3DRS_SEPARATEALPHABLENDENABLE, FALSE ), // hit in CTransitionTable::ApplySeparateAlphaBlend + D3D_RSI( 1, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ), // going to demote these to class 1 until I figure out if they are implementable + D3D_RSI( 1, D3DRS_DESTBLENDALPHA, D3DBLEND_ZERO ), + D3D_RSI( 1, D3DRS_BLENDOPALPHA, D3DBLENDOP_ADD ), + + // what is the deal with alpha test... looks like it is inited to off. + D3D_RSI( 3, D3DRS_ALPHATESTENABLE, 0 ), + D3D_RSI( 3, D3DRS_ALPHAREF, 0 ), + D3D_RSI( 3, D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL ), + + D3D_RSI( 3, D3DRS_STENCILENABLE, FALSE ), + D3D_RSI( 3, D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP ), + D3D_RSI( 3, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP ), + D3D_RSI( 3, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ), + D3D_RSI( 3, D3DRS_STENCILFUNC, D3DCMP_ALWAYS ), + D3D_RSI( 3, D3DRS_STENCILREF, 0 ), + D3D_RSI( 3, D3DRS_STENCILMASK, 0xFFFFFFFF ), + D3D_RSI( 3, D3DRS_STENCILWRITEMASK, 0xFFFFFFFF ), + + D3D_RSI( 3, D3DRS_TWOSIDEDSTENCILMODE, FALSE ), + D3D_RSI( 3, D3DRS_CCW_STENCILFAIL, D3DSTENCILOP_KEEP ), + D3D_RSI( 3, D3DRS_CCW_STENCILZFAIL, D3DSTENCILOP_KEEP ), + D3D_RSI( 3, D3DRS_CCW_STENCILPASS, D3DSTENCILOP_KEEP ), + D3D_RSI( 3, D3DRS_CCW_STENCILFUNC, D3DCMP_ALWAYS ), + + D3D_RSI( 3, D3DRS_FOGENABLE, FALSE ), // see CShaderAPIDx8::FogMode and friends - be ready to do the ARB fog linear option madness + D3D_RSI( 3, D3DRS_FOGCOLOR, 0 ), + D3D_RSI( 3, D3DRS_FOGTABLEMODE, D3DFOG_NONE ), + D3D_RSI( 3, D3DRS_FOGSTART, CONST_DZERO ), + D3D_RSI( 3, D3DRS_FOGEND, CONST_DONE ), + D3D_RSI( 3, D3DRS_FOGDENSITY, CONST_DZERO ), + D3D_RSI( 3, D3DRS_RANGEFOGENABLE, FALSE ), + D3D_RSI( 3, D3DRS_FOGVERTEXMODE, D3DFOG_NONE ), // watch out for CShaderAPIDx8::CommitPerPassFogMode.... + + D3D_RSI( 3, D3DRS_MULTISAMPLEANTIALIAS, TRUE ), + D3D_RSI( 3, D3DRS_MULTISAMPLEMASK, 0xFFFFFFFF ), + + D3D_RSI( 3, D3DRS_SCISSORTESTENABLE, FALSE ), // heed IDirect3DDevice9::SetScissorRect + + D3D_RSI( 3, D3DRS_DEPTHBIAS, CONST_DZERO ), + D3D_RSI( 3, D3DRS_SLOPESCALEDEPTHBIAS, CONST_DZERO ), + + D3D_RSI( 3, D3DRS_COLORWRITEENABLE1, 0x0000000f ), + D3D_RSI( 3, D3DRS_COLORWRITEENABLE2, 0x0000000f ), + D3D_RSI( 3, D3DRS_COLORWRITEENABLE3, 0x0000000f ), + + D3D_RSI( 3, D3DRS_SRGBWRITEENABLE, 0 ), // heeded but ignored.. + + D3D_RSI( 2, D3DRS_CLIPPING, TRUE ), // um, yeah, clipping is enabled (?) + D3D_RSI( 3, D3DRS_CLIPPLANEENABLE, 0 ), // mask 1<m_class >= 0; packed++ ) + { + if ( (packed->m_state <0) || (packed->m_state >= D3DRS_VALUE_LIMIT) ) + { + // bad + Debugger(); + } + else + { + // dispatch it to the unpacked array + g_D3DRS_INFO_unpacked[ packed->m_state ] = *packed; + } + } +} + +// convenience functions + +GLenum D3DCompareFuncToGL( DWORD function ) +{ + switch ( function ) + { + case D3DCMP_NEVER : return GL_NEVER; // Always fail the test. + case D3DCMP_LESS : return GL_LESS; // Accept the new pixel if its value is less than the value of the current pixel. + case D3DCMP_EQUAL : return GL_EQUAL; // Accept the new pixel if its value equals the value of the current pixel. + case D3DCMP_LESSEQUAL : return GL_LEQUAL; // Accept the new pixel if its value is less than or equal to the value of the current pixel. ** + case D3DCMP_GREATER : return GL_GREATER; // Accept the new pixel if its value is greater than the value of the current pixel. + case D3DCMP_NOTEQUAL : return GL_NOTEQUAL; // Accept the new pixel if its value does not equal the value of the current pixel. + case D3DCMP_GREATEREQUAL: return GL_GEQUAL; // Accept the new pixel if its value is greater than or equal to the value of the current pixel. + case D3DCMP_ALWAYS : return GL_ALWAYS; // Always pass the test. + default : Debugger(); return 0xFFFFFFFF; + } +} + +static GLenum D3DStencilOpToGL( DWORD operation ) +{ + switch( operation ) + { + case D3DSTENCILOP_KEEP : return GL_KEEP; + case D3DSTENCILOP_ZERO : return GL_ZERO; + case D3DSTENCILOP_REPLACE : return GL_REPLACE; + case D3DSTENCILOP_INCRSAT : return GL_INCR; + case D3DSTENCILOP_DECRSAT : return GL_DECR; + case D3DSTENCILOP_INVERT : return GL_INVERT; + case D3DSTENCILOP_INCR : return GL_INCR_WRAP_EXT; + case D3DSTENCILOP_DECR : return GL_DECR_WRAP_EXT; + default : Debugger(); return 0xFFFFFFFF; + } +} + +static GLenum D3DBlendFactorToGL( DWORD equation ) +{ + switch (equation) + { + case D3DBLEND_ZERO : return GL_ZERO; // Blend factor is (0, 0, 0, 0). + case D3DBLEND_ONE : return GL_ONE; // Blend factor is (1, 1, 1, 1). + case D3DBLEND_SRCCOLOR : return GL_SRC_COLOR; // Blend factor is (Rs, Gs, Bs, As). + case D3DBLEND_INVSRCCOLOR : return GL_ONE_MINUS_SRC_COLOR; // Blend factor is (1 - Rs, 1 - Gs, 1 - Bs, 1 - As). + case D3DBLEND_SRCALPHA : return GL_SRC_ALPHA; // Blend factor is (As, As, As, As). + case D3DBLEND_INVSRCALPHA : return GL_ONE_MINUS_SRC_ALPHA; // Blend factor is ( 1 - As, 1 - As, 1 - As, 1 - As). + case D3DBLEND_DESTALPHA : return GL_DST_ALPHA; // Blend factor is (Ad Ad Ad Ad). + case D3DBLEND_INVDESTALPHA : return GL_ONE_MINUS_DST_ALPHA; // Blend factor is (1 - Ad 1 - Ad 1 - Ad 1 - Ad). + case D3DBLEND_DESTCOLOR : return GL_DST_COLOR; // Blend factor is (Rd, Gd, Bd, Ad). + case D3DBLEND_INVDESTCOLOR : return GL_ONE_MINUS_DST_COLOR; // Blend factor is (1 - Rd, 1 - Gd, 1 - Bd, 1 - Ad). + case D3DBLEND_SRCALPHASAT : return GL_SRC_ALPHA_SATURATE; // Blend factor is (f, f, f, 1); where f = min(As, 1 - Ad). + + /* + // these are weird.... break if we hit them + case D3DBLEND_BOTHSRCALPHA : Assert(0); return GL_ZERO; // Obsolete. Starting with DirectX 6, you can achieve the same effect by setting the source and destination blend factors to D3DBLEND_SRCALPHA and D3DBLEND_INVSRCALPHA in separate calls. + case D3DBLEND_BOTHINVSRCALPHA: Assert(0); return GL_ZERO; // Source blend factor is (1 - As, 1 - As, 1 - As, 1 - As), and destination blend factor is (As, As, As, As); the destination blend selection is overridden. This blend mode is supported only for the D3DRS_SRCBLEND render state. + case D3DBLEND_BLENDFACTOR : Assert(0); return GL_ZERO; // Constant color blending factor used by the frame-buffer blender. This blend mode is supported only if D3DPBLENDCAPS_BLENDFACTOR is set in the SrcBlendCaps or DestBlendCaps members of D3DCAPS9. + + dxabstract.h has not heard of these, so let them hit the debugger if they come through + case D3DBLEND_INVBLENDFACTOR: //Inverted constant color-blending factor used by the frame-buffer blender. This blend mode is supported only if the D3DPBLENDCAPS_BLENDFACTOR bit is set in the SrcBlendCaps or DestBlendCaps members of D3DCAPS9. + case D3DBLEND_SRCCOLOR2: // Blend factor is (PSOutColor[1]r, PSOutColor[1]g, PSOutColor[1]b, not used). This flag is available in Direct3D 9Ex only. + case D3DBLEND_INVSRCCOLOR2: // Blend factor is (1 - PSOutColor[1]r, 1 - PSOutColor[1]g, 1 - PSOutColor[1]b, not used)). This flag is available in Direct3D 9Ex only. + */ + default: + Debugger(); + return 0xFFFFFFFF; + break; + } +} + +static GLenum D3DBlendOperationToGL( DWORD operation ) +{ + switch (operation) + { + case D3DBLENDOP_ADD : return GL_FUNC_ADD; // The result is the destination added to the source. Result = Source + Destination + + /* not covered by dxabstract.h.. + case D3DBLENDOP_SUBTRACT : return GL_FUNC_SUBTRACT; // The result is the destination subtracted from to the source. Result = Source - Destination + case D3DBLENDOP_REVSUBTRACT : return GL_FUNC_REVERSE_SUBTRACT; // The result is the source subtracted from the destination. Result = Destination - Source + case D3DBLENDOP_MIN : return GL_MIN; // The result is the minimum of the source and destination. Result = MIN(Source, Destination) + case D3DBLENDOP_MAX : return GL_MAX; // The result is the maximum of the source and destination. Result = MAX(Source, Destination) + */ + + default: + Debugger(); + return 0xFFFFFFFF; + break; + + } +} + +HRESULT IDirect3DDevice9::SetRenderState( D3DRENDERSTATETYPE State, DWORD Value ) +{ + char rsSpew = 1; + char ignored = 0; + + if (!g_D3DRS_INFO_unpacked_ready) + { + UnpackD3DRSITable(); + g_D3DRS_INFO_unpacked_ready = true; + } + + if (State >= D3DRS_VALUE_LIMIT) + { + Debugger(); // bad + } + else + { + D3D_RSINFO *info = &g_D3DRS_INFO_unpacked[ State ]; + + if (info->m_state != State) + { + Debugger(); // bad - we never set up that state in our list + } + + if (rsSpew) + { + GLMPRINTF(("-X- IDirect3DDevice9::SetRenderState: set %s(%d) to %d(0x%08x) ( class %d, defval is %d(0x%08x) )", GLMDecode( eD3D_RSTATE,State),State, Value,Value, info->m_class, info->m_defval,info->m_defval )); + } + + switch( info->m_class ) + { + case 0: // just ignore quietly. example: D3DRS_LIGHTING + ignored = 1; + break; + + case 1: + { + // no GL response - and no error as long as the write value matches the default + if (Value != info->m_defval) + { + static char stop_here_1 = 0; + if (stop_here_1) + Debugger(); + } + } + break; + + case 2: + + // provide GL response, but only support known default value + if (Value != info->m_defval) + { + static char stop_here_2 = 0; + if (stop_here_2) + Debugger(); + } + // fall through to mode 3 + + case 3: + + // full GL response, support any legal value + // note we're handling the class-2's as well. + switch(State) + { + case D3DRS_ZENABLE: // kGLDepthTestEnable + gl.m_DepthTestEnable.enable = Value; + gl.m_stateDirtyMask |= (1< GL blend equation + { + GLenum equation = D3DBlendOperationToGL( Value ); + gl.m_BlendEquation.equation = equation; + gl.m_stateDirtyMask |= (1< GL blend factor + case D3DRS_DESTBLEND: // kGLBlendFactor + { + GLenum factor = D3DBlendFactorToGL( Value ); + + if (State==D3DRS_SRCBLEND) + { + gl.m_BlendFactor.srcfactor = factor; + } + else + { + gl.m_BlendFactor.dstfactor = factor; + } + gl.m_stateDirtyMask |= (1< GL_STENCIL_TEST_TWO_SIDE_EXT... not yet implemented ? + case D3DRS_CCW_STENCILFAIL: // GLStencilOp_t + case D3DRS_CCW_STENCILZFAIL: // GLStencilOp_t + case D3DRS_CCW_STENCILPASS: // GLStencilOp_t + case D3DRS_CCW_STENCILFUNC: // GLStencilFunc_t + ignored = 1; + break; + + case D3DRS_FOGENABLE: // none of these are implemented yet... erk + gl.m_FogEnable = (Value != 0); + GLMPRINTF(("-D- fogenable = %d",Value )); + //ignored = 1; + break; + + case D3DRS_FOGCOLOR: + case D3DRS_FOGTABLEMODE: + case D3DRS_FOGSTART: + case D3DRS_FOGEND: + case D3DRS_FOGDENSITY: + case D3DRS_RANGEFOGENABLE: + case D3DRS_FOGVERTEXMODE: + ignored = 1; + break; + + case D3DRS_MULTISAMPLEANTIALIAS: + case D3DRS_MULTISAMPLEMASK: + ignored = 1; + break; + + case D3DRS_SCISSORTESTENABLE: // kGLScissorEnable + { + gl.m_ScissorEnable.enable = Value; + + gl.m_stateDirtyMask |= (1<m_addressModes[ Type - (int)D3DSAMP_ADDRESSU ] = (D3DTEXTUREADDRESS)Value; + break; + + case D3DSAMP_BORDERCOLOR: + samp->m_borderColor = Value; + break; + + case D3DSAMP_MAGFILTER: samp->m_magFilter = (D3DTEXTUREFILTERTYPE)Value; break; + case D3DSAMP_MINFILTER: samp->m_minFilter = (D3DTEXTUREFILTERTYPE)Value; break; + case D3DSAMP_MIPFILTER: samp->m_mipFilter = (D3DTEXTUREFILTERTYPE)Value; break; + case D3DSAMP_MIPMAPLODBIAS: samp->m_mipmapBias = Value; break; // float in sheep's clothing - check this one out + case D3DSAMP_MAXMIPLEVEL: samp->m_maxMipLevel = Value; break; + case D3DSAMP_MAXANISOTROPY: samp->m_maxAniso = Value; break; + case D3DSAMP_SRGBTEXTURE: samp->m_srgb = Value; break; + case D3DSAMP_SHADOWFILTER: samp->m_shadowFilter = Value; break; + + default: + Assert(!"Unknown sampler parameter"); + break; + + } + gl.m_samplerDirtyMask |= (1<WriteAlphaTestEnable( &gl.m_AlphaTestEnable ); + + if ( stateHitMask & (1<WriteAlphaTestFunc( &gl.m_AlphaTestFunc ); + + if ( stateHitMask & (1<WriteAlphaToCoverageEnable( &gl.m_AlphaToCoverageEnable ); + + if ( stateHitMask & (1<WriteCullFaceEnable( &gl.m_CullFaceEnable ); + + if ( stateHitMask & (1<WriteCullFrontFace( &gl.m_CullFrontFace ); + + if ( stateHitMask & (1<WritePolygonMode( &gl.m_PolygonMode ); + + if ( stateHitMask & (1<WriteDepthBias( &gl.m_DepthBias ); + + if ( stateHitMask & (1<WriteScissorEnable( &gl.m_ScissorEnable ); + + if ( stateHitMask & (1<WriteScissorBox( &gl.m_ScissorBox ); + + if ( stateHitMask & (1<WriteViewportBox( &gl.m_ViewportBox ); + + if ( stateHitMask & (1<WriteViewportDepthRange( &gl.m_ViewportDepthRange ); + + if ( stateHitMask & (1<WriteClipPlaneEnable( &gl.m_ClipPlaneEnable[x], x ); + } + } + + if ( stateHitMask & (1<Caps().m_hasNativeClipVertexMode ) + { + // hacked coeffs = { src->x, -src->y, 0.5f * src->z, src->w + (0.5f * src->z) }; + // Antonio's trick - so we can use gl_Position as the clippee, not gl_ClipVertex. + + GLClipPlaneEquation_t *equ = &gl.m_ClipPlaneEquation[x]; + + ///////////////// temp1 + temp1.x = equ->x; + temp1.y = equ->y * -1.0; + temp1.z = equ->z * 0.5; + temp1.w = equ->w + (equ->z * 0.5); + + + //////////////// temp2 + VMatrix mat1( 1, 0, 0, 0, + 0, -1, 0, 0, + 0, 0, 2, -1, + 0, 0, 0, 1 + ); + //mat1 = mat1.Transpose(); + + VMatrix mat2; + bool success = mat1.InverseGeneral( mat2 ); + + if (success) + { + VMatrix mat3; + mat3 = mat2.Transpose(); + + VPlane origPlane( Vector( equ->x, equ->y, equ->z ), equ->w ); + VPlane newPlane; + + newPlane = mat3 * origPlane /* * mat3 */; + + VPlane finalPlane = newPlane; + + temp2.x = newPlane.m_Normal.x; + temp2.y = newPlane.m_Normal.y; + temp2.z = newPlane.m_Normal.z; + temp2.w = newPlane.m_Dist; + } + else + { + temp2.x = 0; + temp2.y = 0; + temp2.z = 0; + temp2.w = 0; + } + } + else + { + temp1 = temp2 = gl.m_ClipPlaneEquation[x]; + } + + if (1) //GLMKnob("caps-key",NULL)==0.0) + { + m_ctx->WriteClipPlaneEquation( &temp1, x ); // no caps lock = Antonio or classic + + /* + if (x<1) + { + GLMPRINTF(( " plane %d √vers1[ %5.2f %5.2f %5.2f %5.2f ] vers2[ %5.2f %5.2f %5.2f %5.2f ]", + x, + temp1.x,temp1.y,temp1.z,temp1.w, + temp2.x,temp2.y,temp2.z,temp2.w + )); + } + */ + } + else + { + m_ctx->WriteClipPlaneEquation( &temp2, x ); // caps = our way or classic + + /* + if (x<1) + { + GLMPRINTF(( " plane %d vers1[ %5.2f %5.2f %5.2f %5.2f ] √vers2[ %5.2f %5.2f %5.2f %5.2f ]", + x, + temp1.x,temp1.y,temp1.z,temp1.w, + temp2.x,temp2.y,temp2.z,temp2.w + )); + } + */ + } + } + } + + if ( stateHitMask & (1<WriteColorMaskSingle( &gl.m_ColorMaskSingle ); + +// if ( stateHitMask & (1<WriteColorMaskMultiple( &gl.m_ColorMaskMultiple ); // ???????????? hmmmmmmmm + + if ( stateHitMask & (1<WriteBlendEnable( &gl.m_BlendEnable ); + + if ( stateHitMask & (1<WriteBlendFactor( &gl.m_BlendFactor ); + + if ( stateHitMask & (1<WriteBlendEquation( &gl.m_BlendEquation ); + + if ( stateHitMask & (1<WriteBlendColor( &gl.m_BlendColor ); + + if ( stateHitMask & (1<WriteBlendEnableSRGB( &gl.m_BlendEnableSRGB ); + + if ( stateHitMask & (1<WriteDepthTestEnable( &gl.m_DepthTestEnable ); + + if ( stateHitMask & (1<WriteDepthFunc( &gl.m_DepthFunc ); + + if ( stateHitMask & (1<WriteDepthMask( &gl.m_DepthMask ); + + if ( stateHitMask & (1<WriteStencilTestEnable( &gl.m_StencilTestEnable ); + + if ( stateHitMask & (1<WriteStencilFunc( &gl.m_StencilFunc ); + + if ( stateHitMask & (1<WriteStencilOp( &gl.m_StencilOp,0 ); + m_ctx->WriteStencilOp( &gl.m_StencilOp,1 ); // ********* need to recheck this + } + + if ( stateHitMask & (1<WriteStencilWriteMask( &gl.m_StencilWriteMask ); + + if ( stateHitMask & (1<WriteClearColor( &gl.m_ClearColor ); + + if ( stateHitMask & (1<WriteClearDepth( &gl.m_ClearDepth ); + + if ( stateHitMask & (1<WriteClearStencil( &gl.m_ClearStencil ); + + gl.m_stateDirtyMask &= (~stateHitMask); + + return S_OK; +} + + + // addressing modes + // 1 D3DTADDRESS_WRAP Tile the texture at every integer junction. + // D3DTADDRESS_MIRROR Similar to D3DTADDRESS_WRAP, except that the texture is flipped at every integer junction. + // 3 D3DTADDRESS_CLAMP Texture coordinates outside the range [0.0, 1.0] are set to the texture color at 0.0 or 1.0, respectively. + // 4 D3DTADDRESS_BORDER Texture coordinates outside the range [0.0, 1.0] are set to the border color. + // D3DTADDRESS_MIRRORONCE Similar to D3DTADDRESS_MIRROR and D3DTADDRESS_CLAMP. + // Takes the absolute value of the texture coordinate (thus, mirroring around 0), + // and then clamps to the maximum value. The most common usage is for volume textures, + // where support for the full D3DTADDRESS_MIRRORONCE texture-addressing mode is not + // necessary, but the data is symmetric around the one axis. +static GLenum dxtogl_addressMode[] = +{ + GL_REPEAT, // 0 is an invalid sampler addressing mode, if it comes up, just use REPEAT + GL_REPEAT, // from D3DTADDRESS_WRAP + (GLenum)-1, // no D3DTADDRESS_MIRROR support + GL_CLAMP_TO_EDGE, // from D3DTADDRESS_CLAMP + GL_CLAMP, // from D3DTADDRESS_BORDER + (GLenum)-1, // no D3DTADDRESS_MIRRORONCE support +}; + +/* + _D3DTEXTUREFILTERTYPE: + D3DTEXF_NONE = 0, // filtering disabled (valid for mip filter only) + D3DTEXF_POINT = 1, // nearest + D3DTEXF_LINEAR = 2, // linear interpolation + D3DTEXF_ANISOTROPIC = 3, // anisotropic +*/ + +static GLenum dxtogl_magFilter[4] = // indexed by _D3DTEXTUREFILTERTYPE +{ + GL_NEAREST, // D3DTEXF_NONE not applicable to mag filter but we handle it like POINT (mat_showmiplevels hits this) + GL_NEAREST, // D3DTEXF_POINT + GL_LINEAR, // D3DTEXF_LINEAR + GL_LINEAR, // D3DTEXF_ANISOTROPIC (aniso will be driven by setting maxAniso, not by a GL filter mode) +}; + +static GLenum dxtogl_minFilter[4][4] = // indexed by _D3DTEXTUREFILTERTYPE on both axes: [row is min filter][col is mip filter]. +{ + // mip filter ---------------> D3DTEXF_NONE D3DTEXF_POINT D3DTEXF_LINEAR (D3DTEXF_ANISOTROPIC not applicable to mip filter) + /* min = D3DTEXF_NONE */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 }, // D3DTEXF_NONE we just treat like POINT + /* min = D3DTEXF_POINT */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 }, + /* min = D3DTEXF_LINEAR */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 }, + /* min = D3DTEXF_ANISOTROPIC */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 }, // no diff from prior row, set maxAniso to effect the sampling +}; + +HRESULT IDirect3DDevice9::FlushSamplers( uint mask ) +{ + // a minor optimization we could do here would be to only write sampler state for + // TMU's that are active (i.e. consult m_textures) + uint activeSamplerMask = m_pixelShader ? m_pixelShader->m_pixSamplerMask : 0; // if no pixel shader bound at time of draw, act like it references no samplers + // (and avoid an access violation while yer at it) + + // ho, we're not clearing the dirty mask for samplers as we go... need to do that... + uint samplerHitMask = gl.m_samplerDirtyMask & mask; + for( int index = 0; (index < 16) && (samplerHitMask !=0); index++) + { + uint mask = 1<m_addressModes[0] = dxtogl_addressMode[ dxsamp->m_addressModes[0] ]; + glsamp->m_addressModes[1] = dxtogl_addressMode[ dxsamp->m_addressModes[1] ]; + glsamp->m_addressModes[2] = dxtogl_addressMode[ dxsamp->m_addressModes[2] ]; + + // border color + uint dxcolor = dxsamp->m_borderColor; + glsamp->m_borderColor[0] = ((dxcolor >> 16) & 0xFF) / 255.0f; //R + glsamp->m_borderColor[1] = ((dxcolor >> 8) & 0xFF) / 255.0f; //G + glsamp->m_borderColor[2] = ((dxcolor ) & 0xFF) / 255.0f; //B + glsamp->m_borderColor[3] = ((dxcolor >> 24) & 0xFF) / 255.0f; //A + + // filter state + + // mag filter - pretty easy + Assert( dxsamp->m_magFilter <= D3DTEXF_ANISOTROPIC ); + Assert( dxsamp->m_magFilter >= D3DTEXF_POINT ); + + glsamp->m_magFilter = dxtogl_magFilter[ dxsamp->m_magFilter ]; + + // min filter - more involved + Assert( dxsamp->m_minFilter <= D3DTEXF_ANISOTROPIC ); + Assert( dxsamp->m_minFilter >= D3DTEXF_POINT ); + Assert( dxsamp->m_mipFilter <= D3DTEXF_LINEAR ); + Assert( dxsamp->m_mipFilter >= D3DTEXF_NONE ); + + D3DTEXTUREFILTERTYPE mipFilterLimit = D3DTEXF_LINEAR; + + /* + if (GLMKnob("caps-key",NULL) > 0.0) + { + if (dxsamp->m_mipFilter > D3DTEXF_NONE) + { + // evil hack + glsamp->m_magFilter = GL_LINEAR_MIPMAP_NEAREST; + } + } + + if (GLMKnob("option-key",NULL) > 0.0) + { + // limit to point + mipFilterLimit = D3DTEXF_POINT; + } + + if (GLMKnob("control-key",NULL) > 0.0) + { + // limit to none + mipFilterLimit = D3DTEXF_NONE; + } + */ + + D3DTEXTUREFILTERTYPE mipFilterChoice = std::min( dxsamp->m_mipFilter, mipFilterLimit ); + glsamp->m_minFilter = dxtogl_minFilter[ dxsamp->m_minFilter ][ mipFilterChoice ]; + + // should we check for mip filtering being requested on unmipped textures ? does it matter ? + + // mipmap bias + glsamp->m_mipmapBias = dxsamp->m_mipmapBias; + + // d3d "MAX MIP LEVEL" means the *largest size* MIP that will be selected. (max size) + // this is the same as GL's "MIN LOD level" which means the GL_TEXTURE_MIN_LOD level. (min index) + + int texMipCount = m_textures[index]->m_tex->m_layout->m_mipCount; + Assert( texMipCount >=1 ); + + glsamp->m_minMipLevel = dxsamp->m_maxMipLevel; // it says gl_minMipLevel because we're setting GL's "GL_TEXTURE_MIN_LOD" aka d3d's "maximum mip size index". + if (glsamp->m_minMipLevel >= texMipCount) + { + // clamp - you can't have the GL base tex level be higher than the index of the last mip + glsamp->m_minMipLevel = texMipCount - 1; + } + + // d3d has no idea of a "MIN MIP LEVEL" i.e. smallest size allowed. + // this would be expressed in GL by setting the GL_TEXTURE_MIN_LOD meaning largest index to select. + // for now, just set it to the index of the last mip. + glsamp->m_maxMipLevel = texMipCount-1; // d3d has no value for constraining how small we can sample. + // however we may need to set this more intelligently if textures are not being fully submitted. + + // aniso, and check for questionable combinations + Assert( ((dxsamp->m_minFilter == D3DTEXF_ANISOTROPIC) && (dxsamp->m_maxAniso >= 1)) || ((dxsamp->m_minFilter < D3DTEXF_ANISOTROPIC) && (dxsamp->m_maxAniso >= 1)) ); + glsamp->m_maxAniso = dxsamp->m_maxAniso; + + // SRGB + glsamp->m_srgb = dxsamp->m_srgb != 0; + + // write that sampler. + m_ctx->SetSamplerParams( index, glsamp ); + samplerHitMask ^= mask; //turn bit off + + // finally, if the SRGB state of the sampler does not match the SRGB format of the underlying texture... + // ... and the tex is not a renderable... + // ... and it is possible to re-submit the tex in an sRGB format... + + // ******** AND THE TEX IS ACTUALLY REFERENCED BY THE ACTIVE PIXEL SHADER ******* + + // fix it. + // else complain ? + + if (mask & activeSamplerMask) // don't do SRGB check on unreferenced textures. + { + bool texsrgb = (m_textures[index]->m_tex->m_layout->m_key.m_texFlags & kGLMTexSRGB) != 0; + bool mismatch = (texsrgb != glsamp->m_srgb); + bool mismatchFixed = false; + bool srgbCapableTex = false; // not yet known + bool renderableTex = false; // not yet known. + + if (mismatch) + { + srgbCapableTex = m_textures[index]->m_tex->m_layout->m_format->m_glIntFormatSRGB != 0; + renderableTex = (m_textures[index]->m_tex->m_layout->m_key.m_texFlags & kGLMTexRenderable) != 0; + // we can fix it if it's not a renderable, and an sRGB enabled format variation is available. + + if (srgbCapableTex && !renderableTex) + { + const char *texname = m_textures[index]->m_tex->m_debugLabel; + if (!texname) texname = "-"; + + m_textures[index]->m_srgbFlipCount++; + + //policy: print the ones that have flipped 1 or N times + bool print_allflips = false; //CommandLine()->FindParm("-glmspewallsrgbflips"); + bool print_firstflips = false; //CommandLine()->FindParm("-glmspewfirstsrgbflips"); + bool print_freqflips = false; //CommandLine()->FindParm("-glmspewfreqsrgbflips"); + bool print_crawls = false; //CommandLine()->FindParm("-glmspewsrgbcrawls"); + bool print_maxcrawls = false; //CommandLine()->FindParm("-glmspewsrgbmaxcrawls"); + bool print_it = false; + + if (print_allflips) + { + print_it = true; + } + if (print_firstflips) // report on first flip + { + print_it |= m_textures[index]->m_srgbFlipCount==1; + } + if (print_freqflips) // report on 50th flip + { + print_it |= m_textures[index]->m_srgbFlipCount==50; + } + + if ( print_it ) + { + const char *formatStr = "srgb change (samp=%d): tex '%-30s' %08x %s (srgb=%d, %d times)"; + + if (strlen(texname) >= 30) + { + formatStr = "srgb change (samp=%d): tex '%s' %08x %s (srgb=%d, %d times)"; + } + + printf( "\n" ); + printf( formatStr, index, texname, m_textures[index], m_textures[index]->m_tex->m_layout->m_layoutSummary, (int)glsamp->m_srgb, m_textures[index]->m_srgbFlipCount ); + + #if 0 // stack crawling not implemented in steamworks example + if (print_crawls) + { + static char *interesting_crawl_substrs[] = { "CShader::OnDrawElements", NULL }; // add more as needed + + CStackCrawlParams cp; + memset( &cp, 0, sizeof(cp) ); + cp.m_frameLimit = 20; + + g_extCocoaMgr->GetStackCrawl(&cp); + + for( int i=0; i< cp.m_frameCount; i++) + { + // for each row of crawl, decide if name is interesting + bool hit = print_maxcrawls; + + for( char **match = interesting_crawl_substrs; (!hit) && (*match != NULL); match++) + { + if (strstr(cp.m_crawlNames[i], *match)) + { + hit = true; + } + } + + if (hit) + { + printf( "\n\t%s", cp.m_crawlNames[i] ); + } + } + printf( "\n"); + } + #endif + } + + #if GLMDEBUG && 0 + //"toi" = texture of interest + static char s_toi[256] = "colorcorrection"; + if (strstr( texname, s_toi )) + { + // breakpoint on this if you like + GLMPRINTF(( "srgb change %d for %s", m_textures[index]->m_srgbFlipCount, texname )); + } + #endif + + // re-submit the tex unless we're stifling it + if ( 1 /* !CommandLine()->FindParm( "-glmnosrgbflips" ) */ ) + { + m_textures[index]->m_tex->ResetSRGB( glsamp->m_srgb, false ); + } + } + else + { + //GLMPRINTF(("-Z- srgb sampling conflict: NOT fixing tex %08x [%s] (srgb req: %d) because (tex-srgb-capable=%d tex-renderable=%d)", m_textures[index], m_textures[index]->m_tex->m_layout->m_layoutSummary, (int)glsamp->m_srgb, (int)srgbCapableTex, (int)renderableTex )); + // we just leave the sampler state where it is, and that's life + } + } + } + + glsamp->m_compareMode = dxsamp->m_shadowFilter ? GL_COMPARE_R_TO_TEXTURE_ARB : GL_NONE; + } + } + + return S_OK; +} + +HRESULT IDirect3DDevice9::FlushIndexBindings( void ) +{ + // push index buffer state + m_ctx->SetIndexBuffer( m_indices.m_idxBuffer->m_idxBuffer ); + + return S_OK; +} + +#if 0 +HRESULT IDirect3DDevice9::FlushVertexBindings( void ) +{ + // push vertex buffer state for the current vertex decl + + GLMVertexSetup setup; + IDirect3DVertexDeclaration9 *vxdecl = m_vertDecl; + + memset( &setup, 0, sizeof( setup ) ); + + // see if the elems in the vertex decl match the attrib map of the shader we're about to draw with. + // can we do this in a simple style that handles both matched and unmatched orderings? + // just pick up each elem from the decl. + // visit the same slot in the shader attrib map. + // if the usage/usageindex matches, you're good. + // if not, hunt through the shader attrib map and find it. + // if you can't find it, then the shader is not consuming that attribute - odd but not fatal ? + // the serious one is shader trying to consume an attrib that isn't being sourced. + // we can check for that though with a little more work (copy the shader attrib map and mark the attribs as each one gets satisfied) + + unsigned char vshAttribMap[ 16 ]; + uint activeAttribCount = 0; + for( int i=0; i<16; i++) + { + vshAttribMap[i] = m_vertexShader->m_vtxAttribMap[i]; + if (vshAttribMap[i] != 0xBB) + { + activeAttribCount++; // this counting could be done at shader creation time, or changed to a mask + } + } + + for( int elemIndex=0; elemIndexm_elemCount; elemIndex++) + { + D3DVERTEXELEMENT9_GL *srcelem = &vxdecl->m_elements[elemIndex]; + + int matchIndex = elemIndex; // initial guess - will iterate if this does not match + int tries = 0; // >16 means done + bool matched = false; + + do + { + if ( ((vshAttribMap[matchIndex] >>4) == srcelem->m_dxdecl.Usage) && ((vshAttribMap[matchIndex] & 0x0F) == srcelem->m_dxdecl.UsageIndex) ) + { + // hit + int attribIndex = matchIndex; + int streamIndex = srcelem->m_dxdecl.Stream; + + GLMVertexAttributeDesc *dstAttr = &setup.m_attrs[ matchIndex ]; + + // copy whole thing + *dstAttr = srcelem->m_gldecl; + + // then fix buffer, stride, offset + dstAttr->m_buffer = m_streams[ streamIndex ].m_vtxBuffer->m_vtxBuffer; + dstAttr->m_stride = m_streams[ streamIndex ].m_stride; + dstAttr->m_offset += m_streams[ streamIndex ].m_offset; + + // set mask + setup.m_attrMask |= (1<FindParm("-hushasserts") */) + { + AssertOnce( !"Vertex shader not consuming attribs that are sourced by decl"); + } + } + } + + if (activeAttribCount >0) + { + // this one is more serious + if (1 /*!CommandLine()->FindParm("-hushasserts") */) + { + Assert( !"Vertex shader consuming attribs not sourced by decl"); + } + } + + // pass the whole shebang to GLM + m_ctx->SetVertexAttributes( &setup ); +} +#endif + + +HRESULT IDirect3DDevice9::FlushVertexBindings( uint baseVertexIndex ) +{ + // push vertex buffer state for the current vertex decl + // in this variant we just walk the attrib map in the VS and do a pull for each one. + // if we can't find a match in the vertex decl, we may fall back to the secret 'dummy' VBO that GLM maintains + + GLMVertexSetup setup; + memset( &setup, 0, sizeof( setup ) ); + + IDirect3DVertexDeclaration9 *vxdecl = m_vertDecl; + unsigned char *vshAttribMap = m_vertexShader->m_vtxAttribMap; + + // this loop could be tightened if we knew the number of live entries in the shader attrib map. + // which of course would be easy to do in the create shader function or even in the translator. + + GLMVertexAttributeDesc *dstAttr = setup.m_attrs; + for( int i=0; i<16; i++,dstAttr++ ) + { + unsigned char vshattrib = vshAttribMap[ i ]; + if (vshattrib != 0xBB) + { + // try to find the match in the decl. + // idea: put some inverse table in the decl which could accelerate this search. + + D3DVERTEXELEMENT9_GL *elem = m_vertDecl->m_elements; + for( int j=0; j< m_vertDecl->m_elemCount; j++,elem++) + { + // if it matches, install it, change vshattrib so the code below does not trigger, then end the loop + if ( ((vshattrib>>4) == elem->m_dxdecl.Usage) && ((vshattrib & 0x0F) == elem->m_dxdecl.UsageIndex) ) + { + // targeting attribute #i in the setup with element data #j from the decl + + *dstAttr = elem->m_gldecl; + + // then fix buffer, stride, offset - note that we honor the base vertex index here by fiddling the offset + int streamIndex = elem->m_dxdecl.Stream; + dstAttr->m_buffer = m_streams[ streamIndex ].m_vtxBuffer->m_vtxBuffer; + dstAttr->m_stride = m_streams[ streamIndex ].m_stride; + dstAttr->m_offset += m_streams[ streamIndex ].m_offset + (baseVertexIndex * dstAttr->m_stride); + + // set mask + setup.m_attrMask |= (1<m_buffer = NULL; + dstAttr->m_stride = 0; + dstAttr->m_offset = 0; + + // only implement certain usages... if we haven't seen it before, stop. + switch( vshattrib >>4 ) // aka usage + { + case D3DDECLUSAGE_POSITION: + case D3DDECLUSAGE_BLENDWEIGHT: + case D3DDECLUSAGE_BLENDINDICES: + Debugger(); + break; + + case D3DDECLUSAGE_NORMAL: + dstAttr->m_datasize = 3; + dstAttr->m_datatype = GL_FLOAT; + dstAttr->m_normalized = false; + break; + + case D3DDECLUSAGE_PSIZE: + Debugger(); + break; + + case D3DDECLUSAGE_TEXCOORD: + dstAttr->m_datasize = 3; + dstAttr->m_datatype = GL_FLOAT; + dstAttr->m_normalized = false; + break; + + case D3DDECLUSAGE_TANGENT: + case D3DDECLUSAGE_BINORMAL: + case D3DDECLUSAGE_TESSFACTOR: + case D3DDECLUSAGE_PLUGH: + Debugger(); + break; + + case D3DDECLUSAGE_COLOR: + dstAttr->m_datasize = 4; + dstAttr->m_datatype = GL_UNSIGNED_BYTE; + dstAttr->m_normalized = true; + break; + + case D3DDECLUSAGE_FOG: + case D3DDECLUSAGE_DEPTH: + case D3DDECLUSAGE_SAMPLE: + Debugger(); + break; + } + } + } + } + + // copy active program's vertex attrib map into the vert setup info + memcpy( &setup.m_vtxAttribMap, m_vertexShader->m_vtxAttribMap, sizeof( m_vertexShader->m_vtxAttribMap ) ); + + m_ctx->SetVertexAttributes( &setup ); + + return S_OK; +} + + + +HRESULT IDirect3DDevice9::FlushGLM( void ) +{ + Debugger();// old routine not used now + return D3DERR_INVALIDCALL; +} + +HRESULT IDirect3DDevice9::DrawPrimitive(D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) +{ + this->FlushStates( 0xFFFFFFFF ); + this->FlushSamplers( 0xFFFFFFFF ); + //this->FlushIndexBindings( ); //indices not really used.. + this->FlushVertexBindings( 0 /*StartVertex*/ ); //no stream base offsetting for drawarrays mode + m_ctx->FlushDrawStates( true ); + + switch(PrimitiveType) + { + case D3DPT_POINTLIST: + m_ctx->DrawArrays( (GLenum)GL_POINTS, StartVertex, (GLsizei)PrimitiveCount ); + break; + + case D3DPT_LINELIST: + m_ctx->DrawArrays( (GLenum)GL_LINES, StartVertex, (GLsizei)PrimitiveCount*2 ); + break; + + case D3DPT_TRIANGLELIST: + m_ctx->DrawArrays( (GLenum)GL_TRIANGLES, StartVertex, (GLsizei)PrimitiveCount*3 ); + break; + + case D3DPT_TRIANGLESTRIP: + m_ctx->DrawArrays( (GLenum)GL_TRIANGLE_STRIP, StartVertex, (GLsizei)PrimitiveCount+2 ); + break; + } + + return S_OK; +} + +// Type +// [in] Member of the D3DPRIMITIVETYPE enumerated type, describing the type of primitive to render. D3DPT_POINTLIST is not supported with this method. See Remarks. + +// BaseVertexIndex +// [in] Offset from the start of the vertex buffer to the first vertex. See Scenario 4. + +// MinIndex +// [in] Minimum vertex index for vertices used during this call. This is a zero based index relative to BaseVertexIndex. + +// NumVertices +// [in] Number of vertices used during this call. The first vertex is located at index: BaseVertexIndex + MinIndex. + +// StartIndex +// [in] Index of the first index to use when accesssing the vertex buffer. Beginning at StartIndex to index vertices from the vertex buffer. + +// PrimitiveCount +// [in] Number of primitives to render. The number of vertices used is a function of the primitive count and the primitive type. The maximum number of primitives allowed is determined by checking the MaxPrimitiveCount member of the D3DCAPS9 structure. + + +HRESULT IDirect3DDevice9::DrawIndexedPrimitive( D3DPRIMITIVETYPE Type,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount ) +{ + this->FlushStates( 0xFFFFFFFF ); + + this->FlushSamplers( 0xFFFFFFFF ); + + this->FlushIndexBindings( ); + this->FlushVertexBindings( BaseVertexIndex ); + m_ctx->FlushDrawStates( true ); + + if (gl.m_FogEnable) + { + GLMPRINTF(("-D- IDirect3DDevice9::DrawIndexedPrimitive is seeing enabled fog...")); + } + + switch(Type) + { + case D3DPT_POINTLIST: + Debugger(); + break; + + case D3DPT_LINELIST: + GLMPRINTF(("-X- IDirect3DDevice9::DrawIndexedPrimitive( D3DPT_LINELIST ) - ignored.")); +// Debugger(); + m_ctx->DrawRangeElements( (GLenum)GL_LINES, (GLuint)MinVertexIndex, (GLuint)(MinVertexIndex + NumVertices), (GLsizei)primCount*2, (GLenum)GL_UNSIGNED_SHORT, (const GLvoid *)(startIndex * sizeof(short)) ); + break; + + case D3DPT_TRIANGLELIST: + m_ctx->DrawRangeElements(GL_TRIANGLES, (GLuint)MinVertexIndex, (GLuint)(MinVertexIndex + NumVertices), (GLsizei)primCount*3, (GLenum)GL_UNSIGNED_SHORT, (const GLvoid *)(startIndex * sizeof(short)) ); + break; + + case D3DPT_TRIANGLESTRIP: + // enabled... Debugger(); + m_ctx->DrawRangeElements(GL_TRIANGLE_STRIP, (GLuint)MinVertexIndex, (GLuint)(MinVertexIndex + NumVertices), (GLsizei)(2+primCount), (GLenum)GL_UNSIGNED_SHORT, (const GLvoid *)(startIndex * sizeof(short)) ); + break; + } + + return S_OK; +} + +HRESULT IDirect3DDevice9::DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) +{ + this->FlushStates( 0xFFFFFFFF ); + + Debugger(); + return S_OK; +} + + + + +BOOL IDirect3DDevice9::ShowCursor(BOOL bShow) +{ + // FIXME NOP + //Debugger(); + return TRUE; +} + +void d3drect_to_glmbox( D3DRECT *src, GLScissorBox_t *dst ) +{ + // to convert from a d3d rect to a GL rect you have to fix up the vertical axis, since D3D Y=0 is the top, but GL Y=0 is the bottom. + // you can't fix it without knowing the height. + + dst->width = src->x2 - src->x1; + dst->x = src->x1; // left edge + + dst->height = src->y2 - src->y1; + dst->y = src->y1; // bottom edge - take large Y from d3d and subtract from surf height. +} + +HRESULT IDirect3DDevice9::Clear(DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) +{ + + this->FlushStates( (1<FlushDrawStates( false ); + + + // for debug Color = (rand() | 0xFF0000FF) & 0xFF3F3FFF; + if (!Count) + { + // run clear with no added rectangle + m_ctx->Clear( (Flags&D3DCLEAR_TARGET)!=0, Color, + (Flags&D3DCLEAR_ZBUFFER)!=0, Z, + (Flags&D3DCLEAR_STENCIL)!=0, Stencil, + NULL + ); + } + else + { + GLScissorBox_t tempbox; + + // do the rects one by one and convert each one to GL form + for( int i=0; iClear( (Flags&D3DCLEAR_TARGET)!=0, Color, + (Flags&D3DCLEAR_ZBUFFER)!=0, Z, + (Flags&D3DCLEAR_STENCIL)!=0, Stencil, + &tempbox + ); + } + } + + return S_OK; +} + +HRESULT IDirect3DDevice9::SetTransform(D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) +{ + Debugger(); + return S_OK; +} + +HRESULT IDirect3DDevice9::SetTextureStageState(DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) +{ + Debugger(); + return S_OK; +} + +HRESULT IDirect3DDevice9::ValidateDevice(DWORD* pNumPasses) +{ + Debugger(); + return S_OK; +} + +HRESULT IDirect3DDevice9::SetMaterial(CONST D3DMATERIAL9* pMaterial) +{ + GLMPRINTF(("-X- IDirect3DDevice9::SetMaterial - ignored.")); +// Debugger(); + return S_OK; +} + + +HRESULT IDirect3DDevice9::LightEnable(DWORD Index,BOOL Enable) +{ + Debugger(); + return S_OK; +} + +HRESULT IDirect3DDevice9::SetScissorRect(CONST RECT* pRect) +{ + int nSurfaceHeight = m_drawableFBO->m_attach[ kAttColor0 ].m_tex->m_layout->m_key.m_ySize; + + GLScissorBox_t newScissorBox = { (GLint)pRect->left, (GLint)pRect->top, (GLint)(pRect->right - pRect->left), (GLint)(pRect->bottom - pRect->top) }; + gl.m_ScissorBox = newScissorBox; + gl.m_stateDirtyMask |= (1<SetVertexShaderConstantF( DXABSTRACT_VS_CLIP_PLANE_BASE+Index, pPlane, 1 ); // stash the clip plane values into shader param - translator knows where to look + } + + // if GLSL mode... latch it and let FlushStates push it out + { + GLClipPlaneEquation_t peq; + peq.x = pPlane[0]; + peq.y = pPlane[1]; + peq.z = pPlane[2]; + peq.w = pPlane[3]; + + gl.m_ClipPlaneEquation[ Index ] = peq; + gl.m_stateDirtyMask |= (1<WriteClipPlaneEquation( &peq, Index ); + } + + return S_OK; +} + +HRESULT IDirect3DDevice9::EvictManagedResources() +{ + GLMPRINTF(("-X- IDirect3DDevice9::EvictManagedResources --> IGNORED")); + return S_OK; +} + +HRESULT IDirect3DDevice9::SetLight(DWORD Index,CONST D3DLIGHT9*) +{ + Debugger(); + return S_OK; +} + +void IDirect3DDevice9::SetGammaRamp(UINT iSwapChain,DWORD Flags,CONST D3DGAMMARAMP* pRamp) +{ + // just slam it directly for the time being + // this code is OS X specific + + CGDisplayErr cgErr; + + CGGammaValue redt[256]; + CGGammaValue grnt[256]; + CGGammaValue blut[256]; + for( int i=0; i<256; i++) + { + redt[i] = ((float)pRamp->red[i]) / 65535.0f; + grnt[i] = ((float)pRamp->green[i]) / 65535.0f; + blut[i] = ((float)pRamp->blue[i]) / 65535.0f; + } + cgErr = CGSetDisplayTransferByTable( 0, 256, redt, grnt, blut ); + +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + +void* ID3DXBuffer::GetBufferPointer() +{ + Debugger(); + return NULL; +} + +DWORD ID3DXBuffer::GetBufferSize() +{ + Debugger(); + return 0; +} + + + +#if 0 //d3dx not provided in steamworks example + +#pragma mark ----- More D3DX stuff + +// ------------------------------------------------------------------------------------------------------------------------------ // +// D3DX stuff. +// ------------------------------------------------------------------------------------------------------------------------------ // + +// matrix stack... + +HRESULT D3DXCreateMatrixStack( DWORD Flags, LPD3DXMATRIXSTACK* ppStack) +{ + + *ppStack = new ID3DXMatrixStack; + + (*ppStack)->Create(); + + return S_OK; +} + +HRESULT ID3DXMatrixStack::Create() +{ + m_stack.EnsureCapacity( 16 ); // 1KB ish + m_stack.AddToTail(); + m_stackTop = 0; // top of stack is at index 0 currently + + LoadIdentity(); + + return S_OK; +} + +D3DXMATRIX* ID3DXMatrixStack::GetTop() +{ + return (D3DXMATRIX*)&m_stack[ m_stackTop ]; +} + +void ID3DXMatrixStack::Push() +{ + D3DMATRIX temp = m_stack[ m_stackTop ]; + m_stack.AddToTail( temp ); + m_stackTop ++; +} + +void ID3DXMatrixStack::Pop() +{ + int elem = m_stackTop--; + m_stack.Remove( elem ); +} + +void ID3DXMatrixStack::LoadIdentity() +{ + D3DXMATRIX *mat = GetTop(); + + D3DXMatrixIdentity( mat ); +} + +void ID3DXMatrixStack::LoadMatrix( const D3DXMATRIX *pMat ) +{ + *(GetTop()) = *pMat; +} + + +void ID3DXMatrixStack::MultMatrix( const D3DXMATRIX *pMat ) +{ + + // http://msdn.microsoft.com/en-us/library/bb174057(VS.85).aspx + // This method right-multiplies the given matrix to the current matrix + // (transformation is about the current world origin). + // m_pstack[m_currentPos] = m_pstack[m_currentPos] * (*pMat); + // This method does not add an item to the stack, it replaces the current + // matrix with the product of the current matrix and the given matrix. + + + Debugger(); +} + +void ID3DXMatrixStack::MultMatrixLocal( const D3DXMATRIX *pMat ) +{ + // http://msdn.microsoft.com/en-us/library/bb174058(VS.85).aspx + // This method left-multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object). + // m_pstack[m_currentPos] = (*pMat) * m_pstack[m_currentPos]; + // This method does not add an item to the stack, it replaces the current + // matrix with the product of the given matrix and the current matrix. + + + Debugger(); +} + +HRESULT ID3DXMatrixStack::ScaleLocal(FLOAT x, FLOAT y, FLOAT z) +{ + // http://msdn.microsoft.com/en-us/library/bb174066(VS.85).aspx + // Scale the current matrix about the object origin. + // This method left-multiplies the current matrix with the computed + // scale matrix. The transformation is about the local origin of the object. + // + // D3DXMATRIX tmp; + // D3DXMatrixScaling(&tmp, x, y, z); + // m_stack[m_currentPos] = tmp * m_stack[m_currentPos]; + + Debugger(); +} + + +HRESULT ID3DXMatrixStack::RotateAxisLocal(CONST D3DXVECTOR3* pV, FLOAT Angle) +{ + // http://msdn.microsoft.com/en-us/library/bb174062(VS.85).aspx + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) + + // D3DXMATRIX tmp; + // D3DXMatrixRotationAxis( &tmp, pV, angle ); + // m_stack[m_currentPos] = tmp * m_stack[m_currentPos]; + // Because the rotation is left-multiplied to the matrix stack, the rotation + // is relative to the object's local coordinate space. + + Debugger(); +} + +HRESULT ID3DXMatrixStack::TranslateLocal(FLOAT x, FLOAT y, FLOAT z) +{ + // http://msdn.microsoft.com/en-us/library/bb174068(VS.85).aspx + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + + // D3DXMATRIX tmp; + // D3DXMatrixTranslation( &tmp, x, y, z ); + // m_stack[m_currentPos] = tmp * m_stack[m_currentPos]; + + Debugger(); +} + + + + +const char* D3DXGetPixelShaderProfile( IDirect3DDevice9 *pDevice ) +{ + Debugger(); + return ""; +} + + +D3DXMATRIX* D3DXMatrixMultiply( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ) +{ + D3DXMATRIX temp; + + for( int i=0; i<4; i++) + { + for( int j=0; j<4; j++) + { + temp.m[i][j] = (pM1->m[ i ][ 0 ] * pM2->m[ 0 ][ j ]) + + (pM1->m[ i ][ 1 ] * pM2->m[ 1 ][ j ]) + + (pM1->m[ i ][ 2 ] * pM2->m[ 2 ][ j ]) + + (pM1->m[ i ][ 3 ] * pM2->m[ 3 ][ j ]); + } + } + *pOut = temp; + return pOut; +} + +D3DXVECTOR3* D3DXVec3TransformCoord( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ) // http://msdn.microsoft.com/en-us/library/ee417622(VS.85).aspx +{ + // this one is tricky because + // "Transforms a 3D vector by a given matrix, projecting the result back into w = 1". + // but the vector has no W attached to it coming in, so we have to go through the motions of figuring out what w' would be + // assuming the input vector had a W of 1. + + // dot product of [a b c 1] against w column + float wp = (pM->m[3][0] * pV->x) + (pM->m[3][1] * pV->y) + (pM->m[3][2] * pV->z) + (pM->m[3][3]); + + if (wp == 0.0f ) + { + // do something to avoid dividing by zero.. + Debugger(); + } + else + { + // unclear on whether I should include the fake W in the sum (last term) before dividing by wp... hmmmm + // leave it out for now and see how well it works + pOut->x = ((pM->m[0][0] * pV->x) + (pM->m[0][1] * pV->y) + (pM->m[0][2] * pV->z) /* + (pM->m[0][3]) */ ) / wp; + pOut->y = ((pM->m[1][0] * pV->x) + (pM->m[1][1] * pV->y) + (pM->m[1][2] * pV->z) /* + (pM->m[1][3]) */ ) / wp; + pOut->z = ((pM->m[2][0] * pV->x) + (pM->m[2][1] * pV->y) + (pM->m[2][2] * pV->z) /* + (pM->m[2][3]) */ ) / wp; + } + + return pOut; +} + + +void D3DXMatrixIdentity( D3DXMATRIX *mat ) +{ + for( int i=0; i<4; i++) + { + for( int j=0; j<4; j++) + { + mat->m[i][j] = (i==j) ? 1.0f : 0.0f; // 1's on the diagonal. + } + } +} + +D3DXMATRIX* D3DXMatrixTranslation( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ) +{ + D3DXMatrixIdentity( pOut ); + pOut->m[3][0] = x; + pOut->m[3][1] = y; + pOut->m[3][2] = z; + return pOut; +} + +D3DXMATRIX* D3DXMatrixInverse( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ) +{ + Assert( sizeof( D3DXMATRIX ) == (16 * sizeof(float) ) ); + Assert( sizeof( VMatrix ) == (16 * sizeof(float) ) ); + Assert( pDeterminant == NULL ); // homey don't play that + + VMatrix *origM = (VMatrix*)pM; + VMatrix *destM = (VMatrix*)pOut; + + bool success = MatrixInverseGeneral( *origM, *destM ); + Assert( success ); + + return pOut; +} + + +D3DXMATRIX* D3DXMatrixTranspose( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ) +{ + if (pOut != pM) + { + for( int i=0; i<4; i++) + { + for( int j=0; j<4; j++) + { + pOut->m[i][j] = pM->m[j][i]; + } + } + } + else + { + D3DXMATRIX temp = *pM; + D3DXMatrixTranspose( pOut, &temp ); + } + + return NULL; +} + + +D3DXPLANE* D3DXPlaneNormalize( D3DXPLANE *pOut, CONST D3DXPLANE *pP) +{ + // not very different from normalizing a vector. + // figure out the square root of the sum-of-squares of the x,y,z components + // make sure that's non zero + // then divide all four components by that value + // or return some dummy plane like 0,0,1,0 if it fails + + float len = sqrt( (pP->a * pP->a) + (pP->b * pP->b) + (pP->c * pP->c) ); + if (len > 1e-10) //FIXME need a real epsilon here ? + { + pOut->a = pP->a / len; pOut->b = pP->b / len; pOut->c = pP->c / len; pOut->d = pP->d / len; + } + else + { + pOut->a = 0.0f; pOut->b = 0.0f; pOut->c = 1.0f; pOut->d = 0.0f; + } + return pOut; +} + + +D3DXVECTOR4* D3DXVec4Transform( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ) +{ + VMatrix *mat = (VMatrix*)pM; + Vector4D *vIn = (Vector4D*)pV; + Vector4D *vOut = (Vector4D*)pOut; + + Vector4DMultiplyTranspose( *mat, *vIn, *vOut ); + + return pOut; +} + + + +D3DXVECTOR4* D3DXVec4Normalize( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ) +{ + Vector4D *vIn = (Vector4D*) pV; + Vector4D *vOut = (Vector4D*) pOut; + + *vOut = *vIn; + Vector4DNormalize( *vOut ); + + return pOut; +} + + +D3DXMATRIX* D3DXMatrixOrthoOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,FLOAT zf ) +{ + Debugger(); + return NULL; +} + + +D3DXMATRIX* D3DXMatrixPerspectiveRH( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ) +{ + Debugger(); + return NULL; +} + + +D3DXMATRIX* D3DXMatrixPerspectiveOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ) +{ + Debugger(); + return NULL; +} + + +D3DXPLANE* D3DXPlaneTransform( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ) +{ + float *out = &pOut->a; + + // dot dot dot + for( int x=0; x<4; x++ ) + { + out[x] = (pM->m[0][x] * pP->a) + + (pM->m[1][x] * pP->b) + + (pM->m[2][x] * pP->c) + + (pM->m[3][x] * pP->d); + } + + return pOut; +} + +void D3DPERF_SetOptions( DWORD dwOptions ) +{ +} + + +HRESULT D3DXCompileShader( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable) +{ + Debugger(); // is anyone calling this ? + return S_OK; +} + +#endif + +// ------------------------------------------------------------------------------------------------------------------------------ // + +IDirect3D9 *Direct3DCreate9(UINT SDKVersion) +{ + GLMPRINTF(( "-X- Direct3DCreate9: %d", SDKVersion )); + + return new IDirect3D9; +} + +// ------------------------------------------------------------------------------------------------------------------------------ // + + +#endif + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/dxabstract.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/dxabstract.h new file mode 100644 index 0000000..ff5058e --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/dxabstract.h @@ -0,0 +1,2420 @@ +//================ Copyright (c) 1996-2009 Valve Corporation. All Rights Reserved. ================= +// +// +// +//================================================================================================== + +#ifndef DXABSTRACT_H +#define DXABSTRACT_H +#ifdef _WIN32 +#pragma once +#endif + +//================================================================================================== + +// Source engine only #include "materialsystem/IShader.h" +// constants below copied from that header + +// size of the VS register bank in ARB / GLSL we expose +// it's not 256, because you can't use all 256 slots in 10.5.x. +// use this constant everywhere you might normally use "256" in reference to a parameter array size. +// The highest vertex shader constant is c216, plus we allocate c217 and c218 for two clip planes +#define DXABSTRACT_VS_PARAM_SLOTS 219 + +// user clip plane 0 goes in DXABSTRACT_VS_CLIP_PLANE_BASE... plane 1 goes in the slot after that +// dxabstract uses these constants to check plane index limit and to deliver planes to shader for DP4 -> oCLP[n] +#define DXABSTRACT_VS_CLIP_PLANE_BASE (DXABSTRACT_VS_PARAM_SLOTS-2) + +//================================================================================================== + + +// Uncomment this on Windows if you want to compile the Windows GL version. +// #undef USE_ACTUAL_DX + +#ifdef USE_ACTUAL_DX + +#ifndef WIN32 +#error sorry man +#endif +#ifdef _X360 +#include "d3d9.h" +#include "d3dx9.h" +#else +#include +#include "../../dx9sdk/include/d3d9.h" +#include "../../dx9sdk/include/d3dx9.h" +#endif +typedef HWND VD3DHWND; + +#else + +#ifdef WIN32 +#error Gl on win32? +#endif + +#define DX_TO_GL_ABSTRACTION + +#include "imageformat.h" +#include "glmgr.h" + +extern "C" void Debugger(void); + +// ------------------------------------------------------------------------------------------------------------------------------ // +// DEFINES +// ------------------------------------------------------------------------------------------------------------------------------ // + +typedef void* VD3DHWND; +typedef void* VD3DHANDLE; + +// +// +// Stuff that would be in windows.h +// +// +#ifdef _WINNT_ +#error "No interoperability with windows.h!" +#else + +#ifndef __stdcall +#define __stdcall +#endif + + typedef int INT; + typedef unsigned long ULONG; + typedef long LONG; + typedef float FLOAT; + typedef unsigned int DWORD; + typedef unsigned short WORD; + typedef long long LONGLONG; + typedef unsigned int UINT; + typedef long HRESULT; + typedef unsigned char BYTE; + #define CONST const + typedef unsigned long ULONG_PTR; + typedef ULONG_PTR SIZE_T; + typedef signed char BOOL; + + typedef const char* LPCSTR; + typedef char* LPSTR; + typedef DWORD* LPDWORD; + + #define ZeroMemory RtlZeroMemory + #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length)) + + typedef union _LARGE_INTEGER { + struct { + DWORD LowPart; + LONG HighPart; + }; + struct { + DWORD LowPart; + LONG HighPart; + } u; + LONGLONG QuadPart; + } LARGE_INTEGER; + + /* + typedef struct _GUID { + + bool operator==( const struct _GUID &other ) const; + + unsigned long Data1; + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[ 8 ]; + } GUID; + */ + +#ifndef VALVE_RECT_DEFINED +#define VALVE_RECT_DEFINED + + typedef struct tagRECT + { + LONG left; + LONG top; + LONG right; + LONG bottom; + } RECT; + + #define _RECT tagRECT +#endif + // turn this on to get refcount logging from IUnknown + + #define IUNKNOWN_ALLOC_SPEW 0 + #define IUNKNOWN_ALLOC_SPEW_MARK_ALL 0 + + struct IUnknown + { + public: + int m_refcount[2]; + bool m_mark; + + IUnknown( void ) + { + m_refcount[0] = 1; + m_refcount[1] = 0; + m_mark = (IUNKNOWN_ALLOC_SPEW_MARK_ALL != 0); // either all are marked, or only the ones that have SetMark(true) called on them + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUnew (%08x) refc -> (%d,%d) ",this,m_refcount[0],m_refcount[1])); + } + #endif + }; + + virtual ~IUnknown( void ) + { + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUdel (%08x) ",this )); + } + #endif + }; + + void AddRef( int which=0, const char *comment = NULL ) + { + Assert( which >= 0 ); + Assert( which < 2 ); + m_refcount[which]++; + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IUAddRef (%08x,%d) refc -> (%d,%d) [%s]",this,which,m_refcount[0],m_refcount[1],comment?comment:"...")) ; + if (!comment) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + } + #endif + }; + + ULONG __stdcall Release( int which=0, const char *comment = NULL ) + { + Assert( which >= 0 ); + Assert( which < 2 ); + + //int oldrefcs[2] = { m_refcount[0], m_refcount[1] }; + bool deleting = false; + + m_refcount[which]--; + if ( (!m_refcount[0]) && (!m_refcount[1]) ) + { + deleting = true; + } + + #if IUNKNOWN_ALLOC_SPEW + if (m_mark) + { + GLMPRINTF(("-A- IURelease (%08x,%d) refc -> (%d,%d) [%s] %s",this,which,m_refcount[0],m_refcount[1],comment?comment:"...",deleting?"->DELETING":"")); + if (!comment) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + } + #endif + + if (deleting) + { + if (m_mark) + { + GLMPRINTF(("")) ; // place to hang a breakpoint + } + delete this; + return 0; + } + else + { + return m_refcount[0]; + } + }; + void SetMark( bool markValue, char *comment=NULL ) + { + #if IUNKNOWN_ALLOC_SPEW + if (!m_mark && markValue) // leading edge detect + { + // print the same thing that the constructor would have printed if it had been marked from the beginning + // i.e. it's anticipated that callers asking for marking will do so right at create time + GLMPRINTF(("-A- IUSetMark (%08x) refc -> (%d,%d) (%s) ",this,m_refcount[0],m_refcount[1],comment?comment:"...")); + } + #endif + + m_mark = markValue; + } + }; + + typedef struct tagPOINT + { + LONG x; + LONG y; + } POINT, *PPOINT, *LPPOINT; + + typedef struct _MEMORYSTATUS { + DWORD dwLength; + SIZE_T dwTotalPhys; + } MEMORYSTATUS, *LPMEMORYSTATUS; + + + typedef DWORD COLORREF; + #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) + + #define MAKE_HRESULT(sev,fac,code) \ + ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) ) + + #define S_FALSE ((HRESULT)0x00000001L) + #define S_OK 0 + #define E_OUTOFMEMORY ((HRESULT)(0x8007000EL)) + + #define FAILED(hr) ((HRESULT)(hr) < 0) + #define SUCCEEDED(hr) ((HRESULT)(hr) >= 0) + + #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ + ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) + + struct RGNDATA + { + public: + }; + + void Sleep( unsigned int ms ); + bool IsIconic( VD3DHWND hWnd ); + void GetClientRect( VD3DHWND hWnd, RECT *destRect ); + BOOL ClientToScreen( VD3DHWND hWnd, LPPOINT pPoint ); + + typedef const void* LPCVOID; + + void* GetCurrentThread(); + void SetThreadAffinityMask( void *hThread, int nMask ); + void GlobalMemoryStatus( MEMORYSTATUS *pOut ); + +#endif + +#define D3DSI_OPCODE_MASK 0x0000FFFF +#define D3DSP_TEXTURETYPE_MASK 0x78000000 + +#define D3DUSAGE_AUTOGENMIPMAP (0x00000400L) +#define D3DSP_DCL_USAGE_MASK 0x0000000f + +#define D3DSP_OPCODESPECIFICCONTROL_MASK 0x00ff0000 +#define D3DSP_OPCODESPECIFICCONTROL_SHIFT 16 + + +/* Flags to construct D3DRS_COLORWRITEENABLE */ +#define D3DCOLORWRITEENABLE_RED (1L<<0) +#define D3DCOLORWRITEENABLE_GREEN (1L<<1) +#define D3DCOLORWRITEENABLE_BLUE (1L<<2) +#define D3DCOLORWRITEENABLE_ALPHA (1L<<3) + +#define D3DSGR_NO_CALIBRATION 0x00000000L + + +#define D3DXINLINE inline + +#define D3D_SDK_VERSION 32 + +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) + + +#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) +#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) +#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) +#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) +#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) +#define D3D_OK S_OK + +#define D3DPRESENT_RATE_DEFAULT 0x00000000 + +// +// DevCaps +// + // we need to see who in Source land is interested in these values, as dxabstract is currently reporting zero for the whole Caps word +#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ +#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */ +#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080L /* Device can use TL buffers from video memory */ +#define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100L /* Device can texture from system memory */ +#define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200L /* Device can texture from device memory */ +#define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400L /* Device can draw TLVERTEX primitives */ +#define D3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800L /* Device can render without waiting for flip to complete */ +#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000L /* Device can texture from nonlocal video memory */ +#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */ +#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */ +#define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000L /* Device supports a Tex Blt from system memory to non-local vidmem */ +#define D3DDEVCAPS_HWRASTERIZATION 0x00080000L /* Device has HW acceleration for rasterization */ +#define D3DDEVCAPS_PUREDEVICE 0x00100000L /* Device supports D3DCREATE_PUREDEVICE */ +#define D3DDEVCAPS_QUINTICRTPATCHES 0x00200000L /* Device supports quintic Beziers and BSplines */ +#define D3DDEVCAPS_RTPATCHHANDLEZERO 0x00800000L /* Indicates that RT Patches may be drawn efficiently using handle 0 */ +#define D3DDEVCAPS_NPATCHES 0x01000000L /* Device supports N-Patches */ + +// +// PrimitiveMiscCaps +// +#define D3DPMISCCAPS_MASKZ 0x00000002L +#define D3DPMISCCAPS_CULLNONE 0x00000010L +#define D3DPMISCCAPS_CULLCW 0x00000020L +#define D3DPMISCCAPS_CULLCCW 0x00000040L +#define D3DPMISCCAPS_COLORWRITEENABLE 0x00000080L +#define D3DPMISCCAPS_CLIPPLANESCALEDPOINTS 0x00000100L /* Device correctly clips scaled points to clip planes */ +#define D3DPMISCCAPS_CLIPTLVERTS 0x00000200L /* device will clip post-transformed vertex primitives */ +#define D3DPMISCCAPS_TSSARGTEMP 0x00000400L /* device supports D3DTA_TEMP for temporary register */ +#define D3DPMISCCAPS_BLENDOP 0x00000800L /* device supports D3DRS_BLENDOP */ +#define D3DPMISCCAPS_NULLREFERENCE 0x00001000L /* Reference Device that doesnt render */ +#define D3DPMISCCAPS_PERSTAGECONSTANT 0x00008000L /* Device supports per-stage constants */ +#define D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS 0x00040000L /* Device supports different bit depths for MRT */ +#define D3DPMISCCAPS_FOGVERTEXCLAMPED 0x00100000L /* Device clamps fog blend factor per vertex */ + +// Flags field for Issue +#define D3DISSUE_END (1 << 0) // Tells the runtime to issue the end of a query, changing it's state to "non-signaled". +#define D3DISSUE_BEGIN (1 << 1) // Tells the runtime to issue the beginng of a query. + + +#define D3DPRESENT_INTERVAL_ONE 0x00000001L +#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L + +/* + * Options for clearing + */ +#define D3DCLEAR_TARGET 0x00000001l /* Clear target surface */ +#define D3DCLEAR_ZBUFFER 0x00000002l /* Clear target z buffer */ +#define D3DCLEAR_STENCIL 0x00000004l /* Clear stencil planes */ + + +#define D3DENUM_WHQL_LEVEL 0x00000002L + + + + +#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation + in programmable and fixed function pixel shaders */ +#define D3DDEVCAPS2_STREAMOFFSET 0x00000001L /* Device supports offsets in streams. Must be set by DX9 drivers */ + +#define D3DDEVCAPS_PUREDEVICE 0x00100000L /* Device supports D3DCREATE_PUREDEVICE */ + +#define D3DCREATE_PUREDEVICE 0x00000010L +#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L +#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L +#define D3DCREATE_FPU_PRESERVE 0x00000002L +#define D3DPRASTERCAPS_FOGRANGE 0x00010000L +#define D3DPRASTERCAPS_FOGTABLE 0x00000100L +#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L +#define D3DPRASTERCAPS_WFOG 0x00100000L +#define D3DPRASTERCAPS_ZFOG 0x00200000L +#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L +#define D3DPRASTERCAPS_WBUFFER 0x00040000L +#define D3DPRASTERCAPS_ZTEST 0x00000010L + +// +// Caps2 +// +#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L +#define D3DPRASTERCAPS_SCISSORTEST 0x01000000L +#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ +#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ +#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ +#define D3DCREATE_MULTITHREADED 0x00000004L +#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */ +#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L +#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L +#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ +#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ +#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L +#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ +#define D3DTEXOPCAPS_ADD 0x00000040L +#define D3DTEXOPCAPS_MODULATE2X 0x00000010L +#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L +#define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000L +#define D3DVTXPCAPS_TEXGEN_SPHEREMAP 0x00000100L /* device supports D3DTSS_TCI_SPHEREMAP */ +#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L + +// The following usages are valid only for querying CheckDeviceFormat +#define D3DUSAGE_QUERY_SRGBREAD (0x00010000L) +#define D3DUSAGE_QUERY_FILTER (0x00020000L) +#define D3DUSAGE_QUERY_SRGBWRITE (0x00040000L) +#define D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING (0x00080000L) +#define D3DUSAGE_QUERY_VERTEXTEXTURE (0x00100000L) + +/* Usages for Vertex/Index buffers */ +#define D3DUSAGE_WRITEONLY (0x00000008L) +#define D3DUSAGE_SOFTWAREPROCESSING (0x00000010L) +#define D3DUSAGE_DONOTCLIP (0x00000020L) +#define D3DUSAGE_POINTS (0x00000040L) +#define D3DUSAGE_RTPATCHES (0x00000080L) +#define D3DUSAGE_NPATCHES (0x00000100L) + + +// Flags field for GetData +#define D3DGETDATA_FLUSH (1 << 0) // Tells the runtime to flush if the query is outstanding. + +// Flexible vertex format bits +// +#define D3DFVF_RESERVED0 0x001 +#define D3DFVF_POSITION_MASK 0x400E +#define D3DFVF_XYZ 0x002 +#define D3DFVF_XYZRHW 0x004 +#define D3DFVF_XYZB1 0x006 +#define D3DFVF_XYZB2 0x008 +#define D3DFVF_XYZB3 0x00a +#define D3DFVF_XYZB4 0x00c +#define D3DFVF_XYZB5 0x00e +#define D3DFVF_XYZW 0x4002 +#define D3DFVF_NORMAL 0x010 +#define D3DFVF_PSIZE 0x020 +#define D3DFVF_DIFFUSE 0x040 +#define D3DFVF_SPECULAR 0x080 +#define D3DFVF_TEXCOUNT_MASK 0xf00 +#define D3DFVF_TEXCOUNT_SHIFT 8 +#define D3DFVF_TEX0 0x000 +#define D3DFVF_TEX1 0x100 +#define D3DFVF_TEX2 0x200 +#define D3DFVF_TEX3 0x300 +#define D3DFVF_TEX4 0x400 +#define D3DFVF_TEX5 0x500 +#define D3DFVF_TEX6 0x600 +#define D3DFVF_TEX7 0x700 +#define D3DFVF_TEX8 0x800 +#define D3DFVF_LASTBETA_UBYTE4 0x1000 +#define D3DFVF_LASTBETA_D3DCOLOR 0x8000 +#define D3DFVF_RESERVED2 0x6000 // 2 reserved bits + + +#define D3DTA_SELECTMASK 0x0000000f // mask for arg selector +#define D3DTA_DIFFUSE 0x00000000 // select diffuse color (read only) +#define D3DTA_CURRENT 0x00000001 // select stage destination register (read/write) +#define D3DTA_TEXTURE 0x00000002 // select texture color (read only) +#define D3DTA_TFACTOR 0x00000003 // select D3DRS_TEXTUREFACTOR (read only) +#define D3DTA_SPECULAR 0x00000004 // select specular color (read only) +#define D3DTA_TEMP 0x00000005 // select temporary register color (read/write) +#define D3DTA_CONSTANT 0x00000006 // select texture stage constant +#define D3DTA_COMPLEMENT 0x00000010 // take 1.0 - x (read modifier) +#define D3DTA_ALPHAREPLICATE 0x00000020 // replicate alpha to color components (read modifier) + + +#define D3DUSAGE_RENDERTARGET (0x00000001L) +#define D3DUSAGE_QUERY_VERTEXTEXTURE (0x00100000L) +#define D3DUSAGE_QUERY_FILTER (0x00020000L) +#define D3DUSAGE_DEPTHSTENCIL (0x00000002L) +#define D3DUSAGE_WRITEONLY (0x00000008L) +#define D3DUSAGE_SOFTWAREPROCESSING (0x00000010L) +#define D3DUSAGE_DYNAMIC (0x00000200L) + +#define D3DSI_INSTLENGTH_MASK 0x0F000000 +#define D3DSI_INSTLENGTH_SHIFT 24 +#define D3DSP_TEXTURETYPE_SHIFT 27 +#define D3DSP_REGTYPE_SHIFT 28 +#define D3DSP_REGTYPE_SHIFT2 8 +#define D3DSP_REGTYPE_MASK 0x70000000 +#define D3DSP_REGTYPE_MASK2 0x00001800 + +#define D3DSP_REGNUM_MASK 0x000007FF + +#define D3DSP_DSTMOD_SHIFT 20 +#define D3DSP_DSTMOD_MASK 0x00F00000 +#define D3DSPDM_MSAMPCENTROID (4<>8)&0xFF) +#define D3DSHADER_VERSION_MINOR(_Version) (((_Version)>>0)&0xFF) + +#define D3DSHADER_ADDRESSMODE_SHIFT 13 +#define D3DSHADER_ADDRESSMODE_MASK (1 << D3DSHADER_ADDRESSMODE_SHIFT) + +#define D3DPS_END() 0x0000FFFF + +// ps_2_0 texld controls +#define D3DSI_TEXLD_PROJECT (0x01 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) +#define D3DSI_TEXLD_BIAS (0x02 << D3DSP_OPCODESPECIFICCONTROL_SHIFT) + + +// destination parameter write mask +#define D3DSP_WRITEMASK_0 0x00010000 // Component 0 (X;Red) +#define D3DSP_WRITEMASK_1 0x00020000 // Component 1 (Y;Green) +#define D3DSP_WRITEMASK_2 0x00040000 // Component 2 (Z;Blue) +#define D3DSP_WRITEMASK_3 0x00080000 // Component 3 (W;Alpha) +#define D3DSP_WRITEMASK_ALL 0x000F0000 // All Components + +#define D3DVS_SWIZZLE_SHIFT 16 +#define D3DVS_SWIZZLE_MASK 0x00FF0000 + +// The following bits define where to take component X from: + +#define D3DVS_X_X (0 << D3DVS_SWIZZLE_SHIFT) +#define D3DVS_X_Y (1 << D3DVS_SWIZZLE_SHIFT) +#define D3DVS_X_Z (2 << D3DVS_SWIZZLE_SHIFT) +#define D3DVS_X_W (3 << D3DVS_SWIZZLE_SHIFT) + +// The following bits define where to take component Y from: + +#define D3DVS_Y_X (0 << (D3DVS_SWIZZLE_SHIFT + 2)) +#define D3DVS_Y_Y (1 << (D3DVS_SWIZZLE_SHIFT + 2)) +#define D3DVS_Y_Z (2 << (D3DVS_SWIZZLE_SHIFT + 2)) +#define D3DVS_Y_W (3 << (D3DVS_SWIZZLE_SHIFT + 2)) + +// The following bits define where to take component Z from: + +#define D3DVS_Z_X (0 << (D3DVS_SWIZZLE_SHIFT + 4)) +#define D3DVS_Z_Y (1 << (D3DVS_SWIZZLE_SHIFT + 4)) +#define D3DVS_Z_Z (2 << (D3DVS_SWIZZLE_SHIFT + 4)) +#define D3DVS_Z_W (3 << (D3DVS_SWIZZLE_SHIFT + 4)) + +// The following bits define where to take component W from: + +#define D3DVS_W_X (0 << (D3DVS_SWIZZLE_SHIFT + 6)) +#define D3DVS_W_Y (1 << (D3DVS_SWIZZLE_SHIFT + 6)) +#define D3DVS_W_Z (2 << (D3DVS_SWIZZLE_SHIFT + 6)) +#define D3DVS_W_W (3 << (D3DVS_SWIZZLE_SHIFT + 6)) + +// source parameter modifiers +#define D3DSP_SRCMOD_SHIFT 24 +#define D3DSP_SRCMOD_MASK 0x0F000000 + + +struct IDirect3DSurface9; +struct IDirect3DDevice9; +struct IDirect3DCubeTexture9; +struct IDirect3DVertexDeclaration9; +struct IDirect3DQuery9; + + + + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// ENUMS +// ------------------------------------------------------------------------------------------------------------------------------ // + +typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE +{ + D3DSPSM_NONE = 0<= 2.0 + + + D3DDECLTYPE_UBYTE4N = 8, // Each of 4 bytes is normalized by dividing to 255.0 + D3DDECLTYPE_SHORT2N = 9, // 2D signed short normalized (v[0]/32767.0,v[1]/32767.0,0,1) + D3DDECLTYPE_SHORT4N = 10, // 4D signed short normalized (v[0]/32767.0,v[1]/32767.0,v[2]/32767.0,v[3]/32767.0) + D3DDECLTYPE_USHORT2N = 11, // 2D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,0,1) + D3DDECLTYPE_USHORT4N = 12, // 4D unsigned short normalized (v[0]/65535.0,v[1]/65535.0,v[2]/65535.0,v[3]/65535.0) + D3DDECLTYPE_UDEC3 = 13, // 3D unsigned 10 10 10 format expanded to (value, value, value, 1) + D3DDECLTYPE_DEC3N = 14, // 3D signed 10 10 10 format normalized and expanded to (v[0]/511.0, v[1]/511.0, v[2]/511.0, 1) + D3DDECLTYPE_FLOAT16_2 = 15, // Two 16-bit floating point values, expanded to (value, value, 0, 1) + D3DDECLTYPE_FLOAT16_4 = 16, // Four 16-bit floating point values + D3DDECLTYPE_UNUSED = 17, // When the type field in a decl is unused. +} D3DDECLTYPE; + +typedef enum _D3DDECLMETHOD +{ + D3DDECLMETHOD_DEFAULT = 0, + D3DDECLMETHOD_PARTIALU, + D3DDECLMETHOD_PARTIALV, + D3DDECLMETHOD_CROSSUV, // Normal + D3DDECLMETHOD_UV, + D3DDECLMETHOD_LOOKUP, // Lookup a displacement map + D3DDECLMETHOD_LOOKUPPRESAMPLED, // Lookup a pre-sampled displacement map +} D3DDECLMETHOD; + +typedef enum _D3DDECLUSAGE +{ + D3DDECLUSAGE_POSITION = 0, + D3DDECLUSAGE_BLENDWEIGHT = 1, + D3DDECLUSAGE_BLENDINDICES = 2, + D3DDECLUSAGE_NORMAL = 3, + D3DDECLUSAGE_PSIZE = 4, + D3DDECLUSAGE_TEXCOORD = 5, + D3DDECLUSAGE_TANGENT = 6, + D3DDECLUSAGE_BINORMAL = 7, + D3DDECLUSAGE_TESSFACTOR = 8, + D3DDECLUSAGE_PLUGH = 9, // mystery value + D3DDECLUSAGE_COLOR = 10, + D3DDECLUSAGE_FOG = 11, + D3DDECLUSAGE_DEPTH = 12, + D3DDECLUSAGE_SAMPLE = 13, +} D3DDECLUSAGE; + +typedef enum _D3DPRIMITIVETYPE { + D3DPT_POINTLIST = 1, + D3DPT_LINELIST = 2, + D3DPT_TRIANGLELIST = 4, + D3DPT_TRIANGLESTRIP = 5, + D3DPT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DPRIMITIVETYPE; + + + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// STRUCTURES +// ------------------------------------------------------------------------------------------------------------------------------ // + +typedef struct D3DXPLANE +{ + float& operator[]( int i ); + bool operator==( const D3DXPLANE &o ); + bool operator!=( const D3DXPLANE &o ); + operator float*(); + operator const float*() const; + + float a, b, c, d; +} D3DXPLANE; + +typedef enum _D3DVERTEXBLENDFLAGS +{ + D3DVBF_DISABLE = 0, // Disable vertex blending + D3DVBF_1WEIGHTS = 1, // 2 matrix blending + D3DVBF_2WEIGHTS = 2, // 3 matrix blending + D3DVBF_3WEIGHTS = 3, // 4 matrix blending + D3DVBF_TWEENING = 255, // blending using D3DRS_TWEENFACTOR + D3DVBF_0WEIGHTS = 256, // one matrix is used with weight 1.0 + D3DVBF_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum +} D3DVERTEXBLENDFLAGS; + +typedef struct _D3DINDEXBUFFER_DESC +{ + D3DFORMAT Format; + D3DRESOURCETYPE Type; + DWORD Usage; + D3DPOOL Pool; + UINT Size; +} D3DINDEXBUFFER_DESC; + +typedef struct _D3DVERTEXELEMENT9 +{ + WORD Stream; // Stream index + WORD Offset; // Offset in the stream in bytes + BYTE Type; // Data type + BYTE Method; // Processing method + BYTE Usage; // Semantics + BYTE UsageIndex; // Semantic index +} D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9; + + +#define MAX_DEVICE_IDENTIFIER_STRING 512 +typedef struct _D3DADAPTER_IDENTIFIER9 +{ + char Driver[MAX_DEVICE_IDENTIFIER_STRING]; + char Description[MAX_DEVICE_IDENTIFIER_STRING]; + char DeviceName[32]; /* Device name for GDI (ex. \\.\DISPLAY1) */ + + LARGE_INTEGER DriverVersion; /* Defined for 32 bit components */ + + DWORD VendorId; + DWORD DeviceId; + DWORD SubSysId; + DWORD Revision; + DWORD VideoMemory; + +} D3DADAPTER_IDENTIFIER9; + + +typedef struct _D3DCOLORVALUE { + float r; + float g; + float b; + float a; +} D3DCOLORVALUE; + +typedef struct _D3DMATERIAL9 { + D3DCOLORVALUE Diffuse; /* Diffuse color RGBA */ + D3DCOLORVALUE Ambient; /* Ambient color RGB */ + D3DCOLORVALUE Specular; /* Specular 'shininess' */ + D3DCOLORVALUE Emissive; /* Emissive color RGB */ + float Power; /* Sharpness if specular highlight */ +} D3DMATERIAL9; + +typedef struct _D3DVOLUME_DESC +{ + D3DFORMAT Format; + D3DRESOURCETYPE Type; + DWORD Usage; + D3DPOOL Pool; + + UINT Width; + UINT Height; + UINT Depth; +} D3DVOLUME_DESC; + +typedef struct _D3DVIEWPORT9 { + DWORD X; + DWORD Y; /* Viewport Top left */ + DWORD Width; + DWORD Height; /* Viewport Dimensions */ + float MinZ; /* Min/max of clip Volume */ + float MaxZ; +} D3DVIEWPORT9; + +typedef struct _D3DPSHADERCAPS2_0 +{ + DWORD Caps; + INT DynamicFlowControlDepth; + INT NumTemps; + INT StaticFlowControlDepth; + INT NumInstructionSlots; +} D3DPSHADERCAPS2_0; + +typedef struct _D3DCAPS9 +{ + /* Device Info */ + D3DDEVTYPE DeviceType; + + /* Caps from DX7 Draw */ + DWORD Caps; + DWORD Caps2; + + /* Cursor Caps */ + DWORD CursorCaps; + + /* 3D Device Caps */ + DWORD DevCaps; + + DWORD PrimitiveMiscCaps; + DWORD RasterCaps; + DWORD TextureCaps; + DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's + + DWORD MaxTextureWidth, MaxTextureHeight; + DWORD MaxVolumeExtent; + + DWORD MaxTextureAspectRatio; + DWORD MaxAnisotropy; + + DWORD TextureOpCaps; + DWORD MaxTextureBlendStages; + DWORD MaxSimultaneousTextures; + + DWORD VertexProcessingCaps; + DWORD MaxActiveLights; + DWORD MaxUserClipPlanes; + DWORD MaxVertexBlendMatrices; + DWORD MaxVertexBlendMatrixIndex; + + DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call + DWORD MaxStreams; + + DWORD VertexShaderVersion; + DWORD MaxVertexShaderConst; // number of vertex shader constant registers + + DWORD PixelShaderVersion; + + // Here are the DX9 specific ones + DWORD DevCaps2; + D3DPSHADERCAPS2_0 PS20Caps; + + DWORD NumSimultaneousRTs; // Will be at least 1 + DWORD MaxVertexShader30InstructionSlots; + DWORD MaxPixelShader30InstructionSlots; + + // only on Posix/GL + #if POSIX + DWORD FakeSRGBWrite; // 1 for parts which can't support SRGB writes due to driver issues - 0 for others + DWORD MixedSizeTargets; // 1 for parts which can mix attachment sizes (RT's color vs depth) + DWORD CanDoSRGBReadFromRTs; // 0 when we're on Leopard, 1 when on Snow Leopard + #endif +} D3DCAPS9; + +typedef struct _D3DDISPLAYMODE +{ + UINT Width; + UINT Height; + UINT RefreshRate; + D3DFORMAT Format; +} D3DDISPLAYMODE; + +typedef struct _D3DGAMMARAMP +{ + WORD red [256]; + WORD green[256]; + WORD blue [256]; +} D3DGAMMARAMP; + + +/* Resize Optional Parameters */ +typedef struct _D3DPRESENT_PARAMETERS_ +{ + UINT BackBufferWidth; + UINT BackBufferHeight; + D3DFORMAT BackBufferFormat; + UINT BackBufferCount; + + D3DMULTISAMPLE_TYPE MultiSampleType; + DWORD MultiSampleQuality; + + D3DSWAPEFFECT SwapEffect; + VD3DHWND hDeviceWindow; + BOOL Windowed; + BOOL EnableAutoDepthStencil; + D3DFORMAT AutoDepthStencilFormat; + DWORD Flags; + + /* FullScreen_RefreshRateInHz must be zero for Windowed mode */ + UINT FullScreen_RefreshRateInHz; + UINT PresentationInterval; +} D3DPRESENT_PARAMETERS; + +typedef struct _D3DDEVICE_CREATION_PARAMETERS +{ + UINT AdapterOrdinal; + D3DDEVTYPE DeviceType; + VD3DHWND hFocusWindow; + DWORD BehaviorFlags; +} D3DDEVICE_CREATION_PARAMETERS; + +/* Structures for LockBox */ +typedef struct _D3DBOX +{ + UINT Left; + UINT Top; + UINT Right; + UINT Bottom; + UINT Front; + UINT Back; +} D3DBOX; + +typedef struct _D3DLOCKED_BOX +{ + INT RowPitch; + INT SlicePitch; + void* pBits; +} D3DLOCKED_BOX; + +typedef struct _D3DSURFACE_DESC +{ + D3DFORMAT Format; + D3DRESOURCETYPE Type; + DWORD Usage; + D3DPOOL Pool; + + D3DMULTISAMPLE_TYPE MultiSampleType; + DWORD MultiSampleQuality; + UINT Width; + UINT Height; +} D3DSURFACE_DESC; + + +typedef struct _D3DLOCKED_RECT +{ + INT Pitch; + void* pBits; +} D3DLOCKED_RECT; + + +typedef struct _D3DRASTER_STATUS +{ + BOOL InVBlank; + UINT ScanLine; +} D3DRASTER_STATUS; + +typedef enum _D3DLIGHTTYPE { + D3DLIGHT_POINT = 1, + D3DLIGHT_SPOT = 2, + D3DLIGHT_DIRECTIONAL = 3, + D3DLIGHT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DLIGHTTYPE; + +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; + +class D3DXVECTOR2 +{ +public: + operator FLOAT* (); + operator CONST FLOAT* () const; + + float x,y; +}; + +class D3DXVECTOR3 : public D3DVECTOR +{ +public: + D3DXVECTOR3() {} + D3DXVECTOR3( float a, float b, float c ); + operator FLOAT* (); + operator CONST FLOAT* () const; +}; + +typedef enum _D3DXINCLUDE_TYPE +{ + D3DXINC_LOCAL, + + // force 32-bit size enum + D3DXINC_FORCE_DWORD = 0x7fffffff + +} D3DXINCLUDE_TYPE; + +typedef struct _D3DLIGHT9 { + D3DLIGHTTYPE Type; /* Type of light source */ + D3DCOLORVALUE Diffuse; /* Diffuse color of light */ + D3DCOLORVALUE Specular; /* Specular color of light */ + D3DCOLORVALUE Ambient; /* Ambient color of light */ + D3DVECTOR Position; /* Position in world space */ + D3DVECTOR Direction; /* Direction in world space */ + float Range; /* Cutoff range */ + float Falloff; /* Falloff */ + float Attenuation0; /* Constant attenuation */ + float Attenuation1; /* Linear attenuation */ + float Attenuation2; /* Quadratic attenuation */ + float Theta; /* Inner angle of spotlight cone */ + float Phi; /* Outer angle of spotlight cone */ +} D3DLIGHT9; + +class D3DXVECTOR4 +{ +public: + D3DXVECTOR4() {} + D3DXVECTOR4( float a, float b, float c, float d ); + + float x,y,z,w; +}; + +//---------------------------------------------------------------------------- +// D3DXMACRO: +// ---------- +// Preprocessor macro definition. The application pass in a NULL-terminated +// array of this structure to various D3DX APIs. This enables the application +// to #define tokens at runtime, before the file is parsed. +//---------------------------------------------------------------------------- + +typedef struct _D3DXMACRO +{ + LPCSTR Name; + LPCSTR Definition; + +} D3DXMACRO, *LPD3DXMACRO; + + + + + + + + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------------------------------------------------------ // +// **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. +// +// Also look for any functions marked with "**** FIXED FUNCTION STUFF" +// +// It's only laying around here so we don't have to chop up the shader system a lot to strip out the fixed function code paths. +// ------------------------------------------------------------------------------------------------------------------------------ // +// ------------------------------------------------------------------------------------------------------------------------------ // + +// **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. +typedef enum _D3DTRANSFORMSTATETYPE { + D3DTS_VIEW = 2, + D3DTS_PROJECTION = 3, + D3DTS_TEXTURE0 = 16, + D3DTS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTRANSFORMSTATETYPE; + +// **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. +typedef enum _D3DTEXTUREOP +{ + // Control + D3DTOP_DISABLE = 1, // disables stage + D3DTOP_SELECTARG1 = 2, // the default + D3DTOP_SELECTARG2 = 3, + + // Modulate + D3DTOP_MODULATE = 4, // multiply args together + D3DTOP_MODULATE2X = 5, // multiply and 1 bit + D3DTOP_MODULATE4X = 6, // multiply and 2 bits + + // Add + D3DTOP_ADD = 7, // add arguments together + D3DTOP_ADDSIGNED = 8, // add with -0.5 bias + D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit + D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation + D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product + // Arg1 + Arg2 - Arg1*Arg2 + // = Arg1 + (1-Arg1)*Arg2 + + // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) + D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha + D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha + D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRS_TEXTUREFACTOR + + // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) + D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha + D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color + + // Specular mapping + D3DTOP_PREMODULATE = 17, // modulate with next texture before use + D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB + // COLOROP only + D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A + // COLOROP only + D3DTOP_MODULATEINVALPHA_ADDCOLOR = 20, // (1-Arg1.A)*Arg2.RGB + Arg1.RGB + // COLOROP only + D3DTOP_MODULATEINVCOLOR_ADDALPHA = 21, // (1-Arg1.RGB)*Arg2.RGB + Arg1.A + // COLOROP only + + // Bump mapping + D3DTOP_BUMPENVMAP = 22, // per pixel env map perturbation + D3DTOP_BUMPENVMAPLUMINANCE = 23, // with luminance channel + + // This can do either diffuse or specular bump mapping with correct input. + // Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B) + // where each component has been scaled and offset to make it signed. + // The result is replicated into all four (including alpha) channels. + // This is a valid COLOROP only. + D3DTOP_DOTPRODUCT3 = 24, + + // Triadic ops + D3DTOP_MULTIPLYADD = 25, // Arg0 + Arg1*Arg2 + D3DTOP_LERP = 26, // (Arg0)*Arg1 + (1-Arg0)*Arg2 + + D3DTOP_FORCE_DWORD = 0x7fffffff, +} D3DTEXTUREOP; + +// **** FIXED FUNCTION STUFF - None of this stuff needs support in GL. +typedef enum _D3DTEXTURESTAGESTATETYPE +{ + D3DTSS_COLOROP = 1, /* D3DTEXTUREOP - per-stage blending controls for color channels */ + D3DTSS_COLORARG1 = 2, /* D3DTA_* (texture arg) */ + D3DTSS_COLORARG2 = 3, /* D3DTA_* (texture arg) */ + D3DTSS_ALPHAOP = 4, /* D3DTEXTUREOP - per-stage blending controls for alpha channel */ + D3DTSS_ALPHAARG1 = 5, /* D3DTA_* (texture arg) */ + D3DTSS_ALPHAARG2 = 6, /* D3DTA_* (texture arg) */ + D3DTSS_BUMPENVMAT00 = 7, /* float (bump mapping matrix) */ + D3DTSS_BUMPENVMAT01 = 8, /* float (bump mapping matrix) */ + D3DTSS_BUMPENVMAT10 = 9, /* float (bump mapping matrix) */ + D3DTSS_BUMPENVMAT11 = 10, /* float (bump mapping matrix) */ + D3DTSS_TEXCOORDINDEX = 11, /* identifies which set of texture coordinates index this texture */ + D3DTSS_BUMPENVLOFFSET = 23, /* float offset for bump map luminance */ + D3DTSS_TEXTURETRANSFORMFLAGS = 24, /* D3DTEXTURETRANSFORMFLAGS controls texture transform */ + D3DTSS_COLORARG0 = 26, /* D3DTA_* third arg for triadic ops */ + D3DTSS_RESULTARG = 28, /* D3DTA_* arg for result (CURRENT or TEMP) */ + + + D3DTSS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +} D3DTEXTURESTAGESTATETYPE; + + + + + + + +// ------------------------------------------------------------------------------------------------------------------------------ // +// INTERFACES +// ------------------------------------------------------------------------------------------------------------------------------ // + +struct IDirect3DResource9 : public IUnknown +{ + IDirect3DDevice9 *m_device; // parent device + D3DRESOURCETYPE m_restype; + + DWORD SetPriority(DWORD PriorityNew); +}; + +struct IDirect3DBaseTexture9 : public IDirect3DResource9 // "A Texture.." +{ + D3DSURFACE_DESC m_descZero; // desc of top level. + CGLMTex *m_tex; // a CGLMTex can represent all forms of tex + int m_srgbFlipCount; + + virtual ~IDirect3DBaseTexture9(); + D3DRESOURCETYPE GetType(); + DWORD GetLevelCount(); + HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); +}; + +struct IDirect3DTexture9 : public IDirect3DBaseTexture9 // "Texture 2D" +{ + IDirect3DSurface9 *m_surfZero; // surf of top level. + + virtual ~IDirect3DTexture9(); + + HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); + HRESULT UnlockRect(UINT Level); + HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel); +}; + +typedef struct IDirect3DTexture9 *LPDIRECT3DTEXTURE9, *PDIRECT3DTEXTURE9; + +struct IDirect3DCubeTexture9 : public IDirect3DBaseTexture9 // "Texture Cube Map" +{ + IDirect3DSurface9 *m_surfZero[6]; // surfs of top level. + + virtual ~IDirect3DCubeTexture9(); + + HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface); + HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc); +}; + +struct IDirect3DVolumeTexture9 : public IDirect3DBaseTexture9 // "Texture 3D" +{ + IDirect3DSurface9 *m_surfZero; // surf of top level. + D3DVOLUME_DESC m_volDescZero; // volume desc top level + + virtual ~IDirect3DVolumeTexture9(); + + HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags); + HRESULT UnlockBox(UINT Level); + HRESULT GetLevelDesc( UINT level, D3DVOLUME_DESC *pDesc ); +}; + + +// for the moment, a "D3D surface" is modeled as a GLM tex, a face, and a mip. +// no Create method, these are filled in by the various create surface methods. + +struct IDirect3DSurface9 : public IDirect3DResource9 +{ + virtual ~IDirect3DSurface9(); + + HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags); + HRESULT UnlockRect(); + HRESULT GetDesc(D3DSURFACE_DESC *pDesc); + + D3DSURFACE_DESC m_desc; + CGLMTex *m_tex; + int m_face; + int m_mip; +}; + + + +struct IDirect3D9 : public IUnknown +{ +public: + virtual ~IDirect3D9(); + + UINT GetAdapterCount(); //cheese: returns 1 + + HRESULT GetDeviceCaps (UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps); + HRESULT GetAdapterIdentifier (UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier); + HRESULT CheckDeviceFormat (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat); + UINT GetAdapterModeCount (UINT Adapter,D3DFORMAT Format); + HRESULT EnumAdapterModes (UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode); + HRESULT CheckDeviceType (UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed); + HRESULT GetAdapterDisplayMode (UINT Adapter,D3DDISPLAYMODE* pMode); + HRESULT CheckDepthStencilMatch (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat); + HRESULT CheckDeviceMultiSampleType (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels); + + HRESULT CreateDevice (UINT Adapter,D3DDEVTYPE DeviceType,VD3DHWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface); +}; + +struct IDirect3DSwapChain9 : public IUnknown +{ +}; + + + + // typedef enum D3DDECLUSAGE + // { + // D3DDECLUSAGE_POSITION = 0, + // D3DDECLUSAGE_BLENDWEIGHT = 1, + // D3DDECLUSAGE_BLENDINDICES = 2, + // D3DDECLUSAGE_NORMAL = 3, + // D3DDECLUSAGE_PSIZE = 4, + // D3DDECLUSAGE_TEXCOORD = 5, + // D3DDECLUSAGE_TANGENT = 6, + // D3DDECLUSAGE_BINORMAL = 7, + // D3DDECLUSAGE_TESSFACTOR = 8, + // D3DDECLUSAGE_POSITIONT = 9, + // D3DDECLUSAGE_COLOR = 10, + // D3DDECLUSAGE_FOG = 11, + // D3DDECLUSAGE_DEPTH = 12, + // D3DDECLUSAGE_SAMPLE = 13, + // } D3DDECLUSAGE, *LPD3DDECLUSAGE; + // Constants + // + // D3DDECLUSAGE_POSITION + // Position data ranging from (-1,-1) to (1,1). Use D3DDECLUSAGE_POSITION with + // a usage index of 0 to specify untransformed position for fixed function + // vertex processing and the n-patch tessellator. Use D3DDECLUSAGE_POSITION + // with a usage index of 1 to specify untransformed position in the fixed + // function vertex shader for vertex tweening. + // + // D3DDECLUSAGE_BLENDWEIGHT + // Blending weight data. Use D3DDECLUSAGE_BLENDWEIGHT with a usage index of 0 + // to specify the blend weights used in indexed and nonindexed vertex + // blending. + // + // D3DDECLUSAGE_BLENDINDICES + // Blending indices data. Use D3DDECLUSAGE_BLENDINDICES with a usage index of + // 0 to specify matrix indices for indexed paletted skinning. + // + // D3DDECLUSAGE_NORMAL + // Vertex normal data. Use D3DDECLUSAGE_NORMAL with a usage index of 0 to + // specify vertex normals for fixed function vertex processing and the n-patch + // tessellator. Use D3DDECLUSAGE_NORMAL with a usage index of 1 to specify + // vertex normals for fixed function vertex processing for vertex tweening. + // + // D3DDECLUSAGE_PSIZE + // Point size data. Use D3DDECLUSAGE_PSIZE with a usage index of 0 to specify + // the point-size attribute used by the setup engine of the rasterizer to + // expand a point into a quad for the point-sprite functionality. + // + // D3DDECLUSAGE_TEXCOORD + // Texture coordinate data. Use D3DDECLUSAGE_TEXCOORD, n to specify texture + // coordinates in fixed function vertex processing and in pixel shaders prior + // to ps_3_0. These can be used to pass user defined data. + // + // D3DDECLUSAGE_TANGENT + // Vertex tangent data. + // + // D3DDECLUSAGE_BINORMAL + // Vertex binormal data. + // + // D3DDECLUSAGE_TESSFACTOR + // Single positive floating point value. Use D3DDECLUSAGE_TESSFACTOR with a + // usage index of 0 to specify a tessellation factor used in the tessellation + // unit to control the rate of tessellation. For more information about the + // data type, see D3DDECLTYPE_FLOAT1. + // + // D3DDECLUSAGE_POSITIONT + // Vertex data contains transformed position data ranging from (0,0) to + // (viewport width, viewport height). Use D3DDECLUSAGE_POSITIONT with a usage + // index of 0 to specify transformed position. When a declaration containing + // this is set, the pipeline does not perform vertex processing. + // + // D3DDECLUSAGE_COLOR + // Vertex data contains diffuse or specular color. Use D3DDECLUSAGE_COLOR with + // a usage index of 0 to specify the diffuse color in the fixed function + // vertex shader and pixel shaders prior to ps_3_0. Use D3DDECLUSAGE_COLOR + // with a usage index of 1 to specify the specular color in the fixed function + // vertex shader and pixel shaders prior to ps_3_0. + // + // D3DDECLUSAGE_FOG + // Vertex data contains fog data. Use D3DDECLUSAGE_FOG with a usage index of 0 + // to specify a fog blend value used after pixel shading finishes. This + // applies to pixel shaders prior to version ps_3_0. + // + // D3DDECLUSAGE_DEPTH + // Vertex data contains depth data. + // + // D3DDECLUSAGE_SAMPLE + // Vertex data contains sampler data. Use D3DDECLUSAGE_SAMPLE with a usage + // index of 0 to specify the displacement value to look up. It can be used + // only with D3DDECLUSAGE_LOOKUPPRESAMPLED or D3DDECLUSAGE_LOOKUP. + + //note the form of the list terminator.. + + // #define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0} + // typedef struct _D3DVERTEXELEMENT9 + // { + // WORD Stream; // Stream index + // WORD Offset; // Offset in the stream in bytes + // BYTE Type; // Data type + // BYTE Method; // Processing method + // BYTE Usage; // Semantics + // BYTE UsageIndex; // Semantic index + // } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9; + +#define MAX_D3DVERTEXELEMENTS 16 + +struct D3DVERTEXELEMENT9_GL +{ + // fields right out of the original decl element (copied) + D3DVERTEXELEMENT9 m_dxdecl; // d3d info + // WORD Stream; // Stream index + // WORD Offset; // Offset in the stream in bytes + // BYTE Type; // Data type + // BYTE Method; // Processing method + // BYTE Usage; // Semantics + // BYTE UsageIndex; // Semantic index + + GLMVertexAttributeDesc m_gldecl; + // CGLMBuffer *m_buffer; // late-dropped from selected stream desc (left NULL, will replace with stream source buffer at sync time) + // GLuint m_datasize; // component count (1,2,3,4) of the attrib + // GLenum m_datatype; // data type of the attribute (GL_FLOAT et al) + // GLuint m_stride; // late-dropped from stream desc + // GLuint m_offset; // net offset to attribute 'zero' within the stream data. Add the stream offset before passing to GL. + // GLuint m_normalized; // net offset to attribute 'zero' within the stream data. Add the stream offset before passing to GL. +}; + +struct IDirect3DVertexDeclaration9 : public IUnknown +{ +//public: + uint m_elemCount; + D3DVERTEXELEMENT9_GL m_elements[ MAX_D3DVERTEXELEMENTS ]; + + virtual ~IDirect3DVertexDeclaration9(); +}; + +struct IDirect3DQuery9 : public IDirect3DResource9 //was IUnknown +{ +//public: + D3DQUERYTYPE m_type; // D3DQUERYTYPE_OCCLUSION or D3DQUERYTYPE_EVENT + GLMContext *m_ctx; + CGLMQuery *m_query; + + virtual ~IDirect3DQuery9(); + + HRESULT Issue(DWORD dwIssueFlags); + HRESULT GetData(void* pData,DWORD dwSize,DWORD dwGetDataFlags); +}; + +struct IDirect3DVertexBuffer9 : public IDirect3DResource9 //was IUnknown +{ +//public: + GLMContext *m_ctx; + CGLMBuffer *m_vtxBuffer; + D3DVERTEXBUFFER_DESC m_vtxDesc; // to satisfy GetDesc + + virtual ~IDirect3DVertexBuffer9(); + HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); + HRESULT Unlock(); + +}; + +struct IDirect3DIndexBuffer9 : public IDirect3DResource9 //was IUnknown +{ +//public: + GLMContext *m_ctx; + CGLMBuffer *m_idxBuffer; + D3DINDEXBUFFER_DESC m_idxDesc; // to satisfy GetDesc + + virtual ~IDirect3DIndexBuffer9(); + + HRESULT Lock(UINT OffsetToLock,UINT SizeToLock,void** ppbData,DWORD Flags); + HRESULT Unlock(); + HRESULT GetDesc(D3DINDEXBUFFER_DESC *pDesc); +}; + +struct IDirect3DPixelShader9 : public IDirect3DResource9 //was IUnknown +{ +//public: + CGLMProgram *m_pixProgram; + uint m_pixHighWater; // count of active constant slots referenced by shader. + uint m_pixSamplerMask; // (1< m_stack; + int m_stackTop; // top of stack is at the highest index, this is that index. push increases, pop decreases. + + HRESULT Create( void ); + + D3DXMATRIX* GetTop(); + void Push(); + void Pop(); + void LoadIdentity(); + void LoadMatrix( const D3DXMATRIX *pMat ); + void MultMatrix( const D3DXMATRIX *pMat ); + void MultMatrixLocal( const D3DXMATRIX *pMat ); + HRESULT ScaleLocal(FLOAT x, FLOAT y, FLOAT z); + + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) + HRESULT RotateAxisLocal(CONST D3DXVECTOR3* pV, FLOAT Angle); + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + HRESULT TranslateLocal(FLOAT x, FLOAT y, FLOAT z); +}; +typedef ID3DXMatrixStack* LPD3DXMATRIXSTACK; + +struct IDirect3DDevice9Params +{ + UINT m_adapter; + D3DDEVTYPE m_deviceType; + VD3DHWND m_focusWindow; + DWORD m_behaviorFlags; + D3DPRESENT_PARAMETERS m_presentationParameters; +}; + +#define D3D_MAX_STREAMS 4 +struct D3DStreamDesc +{ + IDirect3DVertexBuffer9 *m_vtxBuffer; + uint m_offset; + uint m_stride; +}; + +struct D3DIndexDesc +{ + IDirect3DIndexBuffer9 *m_idxBuffer; +}; + +// we latch sampler values until draw time and then convert them all to GL form +// note these are similar in name to the fields of a GLMTexSamplingParams but contents are not +// particularly in the texture filtering area + +struct D3DSamplerDesc +{ + D3DTEXTUREADDRESS m_addressModes[3]; // D3DTEXTUREADDRESS modes for S,T,R + DWORD m_borderColor; // DWORD bordercolor + D3DTEXTUREFILTERTYPE m_magFilter; // mag filter + D3DTEXTUREFILTERTYPE m_minFilter; // min filter + D3DTEXTUREFILTERTYPE m_mipFilter; // mip filter + float m_mipmapBias; // float: mipmap bias + DWORD m_maxMipLevel; // DWORD 0..(n-1) LOD index of largest map to use (0 == largest) + DWORD m_maxAniso; // D3DSAMP_MAXANISOTROPY max aniso + DWORD m_srgb; // D3DSAMP_SRGBTEXTURE 0 = no SRGB sampling + DWORD m_shadowFilter; // D3DSAMP_SHADOWFILTER +}; + +struct IDirect3DDevice9 : public IUnknown +{ +public: + // members + + IDirect3DDevice9Params m_params; // mirror of the creation inputs + + // D3D flavor stuff + IDirect3DSurface9 *m_rtSurfaces[16]; // current color RT surfaces. [0] is initially == m_defaultColorSurface + IDirect3DSurface9 *m_dsSurface; // current DS RT surface. can be changed! + + IDirect3DSurface9 *m_defaultColorSurface; // default color surface. + IDirect3DSurface9 *m_defaultDepthStencilSurface; // queried by GetDepthStencilSurface. + + IDirect3DVertexDeclaration9 *m_vertDecl; // Set by SetVertexDeclaration... + D3DStreamDesc m_streams[ D3D_MAX_STREAMS ]; // Set by SetStreamSource.. + D3DIndexDesc m_indices; // Set by SetIndices.. + + IDirect3DVertexShader9 *m_vertexShader; // Set by SetVertexShader... + IDirect3DPixelShader9 *m_pixelShader; // Set by SetPixelShader... + + IDirect3DBaseTexture9 *m_textures[16]; // set by SetTexture... NULL if stage inactive + D3DSamplerDesc m_samplers[16]; // set by SetSamplerState.. + // GLM flavor stuff + GLMContext *m_ctx; + CGLMFBO *m_drawableFBO; // this FBO should have all the attachments set to match m_rtSurfaces and m_dsSurface. + + // GL state + struct + { + // render state buckets + GLAlphaTestEnable_t m_AlphaTestEnable; + GLAlphaTestFunc_t m_AlphaTestFunc; + + GLAlphaToCoverageEnable_t m_AlphaToCoverageEnable; + + GLDepthTestEnable_t m_DepthTestEnable; + GLDepthMask_t m_DepthMask; + GLDepthFunc_t m_DepthFunc; + + GLClipPlaneEnable_t m_ClipPlaneEnable[kGLMUserClipPlanes]; + GLClipPlaneEquation_t m_ClipPlaneEquation[kGLMUserClipPlanes]; + + GLColorMaskSingle_t m_ColorMaskSingle; + GLColorMaskMultiple_t m_ColorMaskMultiple; + + GLCullFaceEnable_t m_CullFaceEnable; + GLCullFrontFace_t m_CullFrontFace; + GLPolygonMode_t m_PolygonMode; + GLDepthBias_t m_DepthBias; + GLScissorEnable_t m_ScissorEnable; + GLScissorBox_t m_ScissorBox; + GLViewportBox_t m_ViewportBox; + GLViewportDepthRange_t m_ViewportDepthRange; + + GLBlendEnable_t m_BlendEnable; + GLBlendFactor_t m_BlendFactor; + GLBlendEquation_t m_BlendEquation; + GLBlendColor_t m_BlendColor; + GLBlendEnableSRGB_t m_BlendEnableSRGB; + + GLStencilTestEnable_t m_StencilTestEnable; + GLStencilFunc_t m_StencilFunc; + GLStencilOp_t m_StencilOp; + GLStencilWriteMask_t m_StencilWriteMask; + + GLClearColor_t m_ClearColor; + GLClearDepth_t m_ClearDepth; + GLClearStencil_t m_ClearStencil; + + bool m_FogEnable; // not really pushed to GL, just latched here + + // samplers + GLMTexSamplingParams m_samplers[ 16 ]; + + // bindings...hmmm... + + // dirty-bits + uint m_stateDirtyMask; // covers the state blocks, indexed by 1<x = pV1->x - pV2->x; + pOut->y = pV1->y - pV2->y; + pOut->z = pV1->z - pV2->z; + return pOut; +} + +D3DXINLINE D3DXVECTOR3* D3DXVec3Cross( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + D3DXVECTOR3 v; + + v.x = pV1->y * pV2->z - pV1->z * pV2->y; + v.y = pV1->z * pV2->x - pV1->x * pV2->z; + v.z = pV1->x * pV2->y - pV1->y * pV2->x; + + *pOut = v; + return pOut; +} + +D3DXINLINE FLOAT D3DXVec3Dot( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ) +{ + return pV1->x * pV2->x + pV1->y * pV2->y + pV1->z * pV2->z; +} + +D3DXMATRIX* D3DXMatrixInverse( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +D3DXMATRIX* D3DXMatrixTranspose( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +D3DXPLANE* D3DXPlaneNormalize( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +D3DXVECTOR4* D3DXVec4Transform( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + + +D3DXVECTOR4* D3DXVec4Normalize( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +D3DXMATRIX* D3DXMatrixTranslation( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* D3DXMatrixOrthoOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,FLOAT zf ); + +D3DXMATRIX* D3DXMatrixPerspectiveRH( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +D3DXMATRIX* D3DXMatrixPerspectiveOffCenterRH( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf ); + +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +D3DXPLANE* D3DXPlaneTransform( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +IDirect3D9 *Direct3DCreate9(UINT SDKVersion); + +void D3DPERF_SetOptions( DWORD dwOptions ); + +HRESULT D3DXCompileShader( + LPCSTR pSrcData, + UINT SrcDataLen, + CONST D3DXMACRO* pDefines, + LPD3DXINCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + DWORD Flags, + LPD3DXBUFFER* ppShader, + LPD3DXBUFFER* ppErrorMsgs, + LPD3DXCONSTANTTABLE* ppConstantTable); + +#endif // USE_ACTUAL_DX + +// fake D3D usage constant for SRGB tex creation +#define D3DUSAGE_TEXTURE_SRGB (0x80000000L) + +#endif // DXABSTRACT_H + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmdebug.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmdebug.h new file mode 100644 index 0000000..eb59c26 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmdebug.h @@ -0,0 +1,45 @@ +#ifndef GLMDEBUG_H +#define GLMDEBUG_H + +// include this anywhere you need to be able to compile-out code related specifically to GLM debugging. + +// we expect DEBUG to be driven by the build system so you can include this header anywhere. +// when we come out, GLMDEBUG will be defined to a value - 0, 1, or 2 +// 0 means no GLM debugging is possible +// 1 means it's possible and resulted from being a debug build +// 2 means it's possible and resulted from being manually forced on for a release build + +#ifdef POSIX + #ifndef GLMDEBUG + #ifdef DEBUG + #define GLMDEBUG 1 // normally 1 here, testing + #else + // #define GLMDEBUG 2 // don't check this in enabled.. + #endif + + #ifndef GLMDEBUG + #define GLMDEBUG 0 + #endif + #endif +#else + #ifndef GLMDEBUG + #define GLMDEBUG 0 + #endif +#endif + +// helpful macro if you are in a position to call GLM functions directly (i.e. you live in materialsystem / shaderapidx9) +#if GLMDEBUG + #define GLMPRINTF(args) GLMPrintf args + #define GLMPRINTSTR(args) GLMPrintStr args + #define GLMPRINTTEXT(args) GLMPrintText args + #define GLMBEGINPIXEVENT(args) GLMBeginPIXEvent args + #define GLMENDPIXEVENT(args) GLMEndPIXEvent args +#else + #define GLMPRINTF(args) + #define GLMPRINTSTR(args) + #define GLMPRINTTEXT(args) + #define GLMBEGINPIXEVENT(args) + #define GLMENDPIXEVENT(args) +#endif + +#endif diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmdisplay.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmdisplay.h new file mode 100644 index 0000000..9bfe2e4 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmdisplay.h @@ -0,0 +1,275 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// glmdisplay.h +// display related stuff - used by both GLMgr and the CocoaMgr +// +//=============================================================================== + +#ifndef GLMDISPLAY_H +#define GLMDISPLAY_H + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include "glmgrbasics.h" + +typedef void _PseudoNSGLContext; // aka NSOpenGLContext +typedef _PseudoNSGLContext *PseudoNSGLContextPtr; + +struct GLMDisplayModeInfoFields +{ + uint m_modePixelWidth; + uint m_modePixelHeight; + uint m_modeRefreshHz; + // are we even going to talk about bit depth... not yet +}; + +struct GLMDisplayInfoFields +{ + CGDirectDisplayID m_cgDisplayID; + CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID. + + uint m_displayPixelWidth; + uint m_displayPixelHeight; +}; + +struct GLMRendererInfoFields +{ + /*properties of interest and their desired values. + + kCGLRPFullScreen = 54, true + kCGLRPAccelerated = 73, true + kCGLRPWindow = 80, true + + kCGLRPRendererID = 70, informational + kCGLRPDisplayMask = 84, informational + kCGLRPBufferModes = 100, informational + kCGLRPColorModes = 103, informational + kCGLRPAccumModes = 104, informational + kCGLRPDepthModes = 105, informational + kCGLRPStencilModes = 106, informational + kCGLRPMaxAuxBuffers = 107, informational + kCGLRPMaxSampleBuffers = 108, informational + kCGLRPMaxSamples = 109, informational + kCGLRPSampleModes = 110, informational + kCGLRPSampleAlpha = 111, informational + kCGLRPVideoMemory = 120, informational + kCGLRPTextureMemory = 121, informational + kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination + + kCGLRPOffScreen = 53, D/C + kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback + kCGLRPBackingStore = 76, D/C + kCGLRPMPSafe = 78, D/C + kCGLRPMultiScreen = 81, D/C + kCGLRPCompliant = 83, D/C + */ + + + //--------------------------- info we have from CGL renderer queries, IOKit, Gestalt + //--------------------------- these are set up in the displayDB by CocoaMgr + GLint m_fullscreen; + GLint m_accelerated; + GLint m_windowed; + + GLint m_rendererID; + GLint m_displayMask; + GLint m_bufferModes; + GLint m_colorModes; + GLint m_accumModes; + GLint m_depthModes; + GLint m_stencilModes; + + GLint m_maxAuxBuffers; + GLint m_maxSampleBuffers; + GLint m_maxSamples; + GLint m_sampleModes; + GLint m_sampleAlpha; + + GLint m_vidMemory; + GLint m_texMemory; + + uint m_pciVendorID; + uint m_pciDeviceID; + char m_pciModelString[64]; + char m_driverInfoString[64]; + + //--------------------------- OS version related - set up by CocoaMgr + + // OS version found + uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508. + + //--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid + + bool m_ati; + bool m_atiR5xx; + bool m_atiR6xx; + bool m_atiR7xx; + bool m_atiR8xx; + bool m_atiNewer; + + bool m_intel; + bool m_intel95x; + bool m_intel3100; + bool m_intelNewer; + + bool m_nv; + bool m_nvG7x; + bool m_nvG8x; + bool m_nvNewer; + + //--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref) + + // booleans + bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT) + bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string + bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string + bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode + bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based + bool m_hasOcclusionQuery; // occlusion query: do you speak it ?! + bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?! + bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update) + + // counts + int m_maxAniso; // aniso limit - context query + + // other exts + bool m_hasBindableUniforms; + bool m_hasUniformBuffers; + + // runtime options that aren't negotiable once set + bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only + + //--------------------------- " can'ts " - specific problems that need to be worked around + + bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes + bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites + bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule + bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule + bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen + + + //--------------------------- " bads " - known bad drivers + bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues +}; + +//////////////////////////////////////////////////////////////////////////////////////// + + +// this stuff is all sitting in glmgrcocoa.mm since it needs to make ObjC calls. + +//=============================================================================== + +// modes, displays, and renderers +// think of renderers as being at the top of a tree. +// each renderer has displays hanging off of it. +// each display has modes hanging off of it. +// the tree is populated on demand and then queried as needed. + +//=============================================================================== + +// GLMDisplayModeInfoFields is in glmdisplay.h + +class GLMDisplayMode +{ +public: + GLMDisplayModeInfoFields m_info; + + GLMDisplayMode( uint width, uint height, uint refreshHz ); + ~GLMDisplayMode( void ); + + void Dump( int which ); +}; + +//=============================================================================== + +// GLMDisplayInfoFields is in glmdisplay.h + +class GLMDisplayInfo +{ +public: + GLMDisplayInfoFields m_info; + std::vector< GLMDisplayMode* > *m_modes; // starts out NULL, set by PopulateModes + + GLMDisplayInfo( CGDirectDisplayID displayID, CGOpenGLDisplayMask displayMask ); + ~GLMDisplayInfo( void ); + + void PopulateModes( void ); + + void Dump( int which ); +}; + +//=============================================================================== + +// GLMRendererInfoFields is in glmdisplay.h + +class GLMRendererInfo +{ +public: + GLMRendererInfoFields m_info; + std::vector< GLMDisplayInfo* > *m_displays; // starts out NULL, set by PopulateDisplays + + GLMRendererInfo ( GLMRendererInfoFields *info ); + ~GLMRendererInfo ( void ); + + void PopulateDisplays( void ); + void Dump( int which ); +}; + +//=============================================================================== + +// this is just a tuple describing fake adapters which are really renderer/display pairings. +// dxabstract bridges the gap between the d3d adapter-centric world and the GL renderer+display world. +// this makes it straightforward to handle cases like two video cards with two displays on one, and one on the other - +// you get three fake adapters which represent each useful screen. + +// the constraint that dxa will have to follow though, is that if the user wants to change their +// display selection for full screen, they would only be able to pick on that has the same underlying renderer. +// can't change fakeAdapter from one to another with different GL renderer under it. Screen hop but no card hop. + +struct GLMFakeAdapter +{ + int m_rendererIndex; + int m_displayIndex; +}; + +class GLMDisplayDB +{ +public: + std::vector< GLMRendererInfo* > *m_renderers; // starts out NULL, set by PopulateRenderers + + std::vector< GLMFakeAdapter > m_fakeAdapters; + + GLMDisplayDB ( void ); + ~GLMDisplayDB ( void ); + + virtual void PopulateRenderers( void ); + virtual void PopulateFakeAdapters( uint realRendererIndex ); // fake adapters = one real adapter times however many displays are on it + virtual void Populate( void ); + + // The info-get functions return false on success. + virtual int GetFakeAdapterCount( void ); + virtual bool GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut ); + + virtual int GetRendererCount( void ); + virtual bool GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut ); + + virtual int GetDisplayCount( int rendererIndex ); + virtual bool GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut ); + + virtual int GetModeCount( int rendererIndex, int displayIndex ); + virtual bool GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut ); + + virtual void Dump( void ); +}; + + + +#endif diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgr.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgr.cpp new file mode 100644 index 0000000..7fef16f --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgr.cpp @@ -0,0 +1,7076 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// glmgr.cpp +// +//=============================================================================== + +#include "glmgr.h" +#include "glmdisplay.h" +#include "dxabstract.h" // need to be able to see D3D enums +#include "../SteamWorksExample/gameengineosx.h" + +extern CGameEngineGL *g_engine; // so glmgr (which is C++) can call up to the game engine ObjC object and ask for things.. + +#ifdef __clang__ +#pragma clang diagnostic warning "-Wint-to-pointer-cast" +#endif + + +//=============================================================================== + +char g_nullFragmentProgramText [] = +{ + "!!ARBfp1.0 \n" + "PARAM black = { 0.0, 0.0, 0.0, 1.0 }; \n" // opaque black + "MOV result.color, black; \n" + "END \n\n\n" + "//GLSLfp\n" + "void main()\n" + "{\n" + "gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n" + "}\n" + +}; + + + + // make dummy programs for doing texture preload via dummy draw +char g_preloadTexVertexProgramText[] = +{ + "//GLSLvp \n" + "#version 120 \n" + "varying vec4 otex; \n" + "void main() \n" + "{ \n" + "vec4 pos = ftransform(); // vec4( 0.1, 0.1, 0.1, 0.1 ); \n" + "vec4 tex = vec4( 0.0, 0.0, 0.0, 0.0 ); \n" + " \n" + "gl_Position = pos; \n" + "otex = tex; \n" + "} \n" +}; + +char g_preload2DTexFragmentProgramText[] = +{ + "//GLSLfp \n" + "#version 120 \n" + "varying vec4 otex; \n" + "//SAMPLERMASK-8000 // may not be needed \n" + "//HIGHWATER-30 // may not be needed \n" + " \n" + "uniform vec4 pc[31]; \n" + "uniform sampler2D sampler15; \n" + " \n" + "void main() \n" + "{ \n" + "vec4 r0; \n" + "r0 = texture2D( sampler15, otex.xy ); \n" + "gl_FragColor = r0; //discard; \n" + "} \n" +}; + +char g_preload3DTexFragmentProgramText[] = +{ + "//GLSLfp \n" + "#version 120 \n" + "varying vec4 otex; \n" + "//SAMPLERMASK-8000 // may not be needed \n" + "//HIGHWATER-30 // may not be needed \n" + " \n" + "uniform vec4 pc[31]; \n" + "uniform sampler3D sampler15; \n" + " \n" + "void main() \n" + "{ \n" + "vec4 r0; \n" + "r0 = texture3D( sampler15, otex.xyz ); \n" + "gl_FragColor = r0; //discard; \n" + "} \n" +}; + +char g_preloadCubeTexFragmentProgramText[] = +{ + "//GLSLfp \n" + "#version 120 \n" + "varying vec4 otex; \n" + "//SAMPLERMASK-8000 // may not be needed \n" + "//HIGHWATER-30 // may not be needed \n" + " \n" + "uniform vec4 pc[31]; \n" + "uniform samplerCube sampler15; \n" + " \n" + "void main() \n" + "{ \n" + "vec4 r0; \n" + "r0 = textureCube( sampler15, otex.xyz ); \n" + "gl_FragColor = r0; //discard; \n" + "} \n" +}; + + + + + + + +//=============================================================================== +// helper routines for debug + +static bool hasnonzeros( float *values, int count ) +{ + for( int i=0; i [ %10.5f %10.5f %10.5f %10.5f ]", + baseSlotNumber+islot, + row[0],row[1],row[2],row[3], + col[0],col[1],col[2],col[3] + )); + } + else + { + if (islot<3) + { + GLMPRINTF(( "-D- %03d: [ %10.5f %10.5f %10.5f %10.5f ] T=> [ %10.5f %10.5f %10.5f ]", + baseSlotNumber+islot, + row[0],row[1],row[2],row[3], + col[0],col[1],col[2] + )); + } + else + { + GLMPRINTF(( "-D- %03d: T=> [ %10.5f %10.5f %10.5f ]", + baseSlotNumber+islot, + col[0],col[1],col[2] + )); + } + } + } + GLMPRINTSTR(("-D-")); + } + else + { + GLMPRINTF(("-D- %s - (all 0.0)", label )); + } + +} + + +static void transform_dp4( float *in4, float *m00, int slots, float *out4 ) +{ + // m00 points to a column. + // each DP is one column of the matrix ( m00[4*n] + // if we are passed a three slot matrix, this is three columns, the source W plays into all three columns, but we must set the final output W to 1 ? + for( int n=0; nm_ctx ); + if (cgl_err) + { + // give up + GLMStop(); + } +} + +GLMContext *GLMgr::GetCurrentContext( void ) +{ + CGLContextObj ctx = CGLGetCurrentContext(); + + GLint glm_context_link = 0; + + CGLGetParameter( ctx, kCGLCPClientStorage, &glm_context_link ); + + if ( glm_context_link ) + { + return (GLMContext*) glm_context_link; + } + else + { + return NULL; + } +} + + +//=============================================================================== +// GLMContext public methods +void GLMContext::MakeCurrent( void ) +{ +// GLM_FUNC; + + CGLSetCurrentContext( m_ctx ); +} + +void GLMContext::CheckCurrent( void ) +{ + #if 1 +// GLM_FUNC; + + // probably want to make this a no-op for release builds + // but we can't, because someone is messing with current context and not sure where yet + CGLContextObj curr = CGLGetCurrentContext(); + if (curr != m_ctx) + { + if (1 /*!CommandLine()->FindParm("-hushasserts") */) + { + Assert( !"Current context mismatch"); + + #if GLMDEBUG + Debugger(); + #endif + } + MakeCurrent(); // you're welcome + } + #endif +} + + +const GLMRendererInfoFields& GLMContext::Caps( void ) +{ + return m_caps; +} + +void GLMContext::DumpCaps( void ) +{ + /* + #define dumpfield( fff ) printf( "\n "#fff" : %d", (int) m_caps.fff ) + #define dumpfield_hex( fff ) printf( "\n "#fff" : 0x%08x", (int) m_caps.fff ) + #define dumpfield_str( fff ) printf( "\n "#fff" : %s", m_caps.fff ) + */ + + #define dumpfield( fff ) printf( "\n %-30s : %d", #fff, (int) m_caps.fff ) + #define dumpfield_hex( fff ) printf( "\n %-30s : 0x%08x", #fff, (int) m_caps.fff ) + #define dumpfield_str( fff ) printf( "\n %-30s : %s", #fff, m_caps.fff ) + + printf("\n-------------------------------- context caps for context %p", this); + + dumpfield( m_fullscreen ); + dumpfield( m_accelerated ); + dumpfield( m_windowed ); + dumpfield_hex( m_rendererID ); + dumpfield( m_displayMask ); + dumpfield( m_bufferModes ); + dumpfield( m_colorModes ); + dumpfield( m_accumModes ); + dumpfield( m_depthModes ); + dumpfield( m_stencilModes ); + dumpfield( m_maxAuxBuffers ); + dumpfield( m_maxSampleBuffers ); + dumpfield( m_maxSamples ); + dumpfield( m_sampleModes ); + dumpfield( m_sampleAlpha ); + dumpfield_hex( m_vidMemory ); + dumpfield_hex( m_texMemory ); + + dumpfield_hex( m_pciVendorID ); + dumpfield_hex( m_pciDeviceID ); + dumpfield_str( m_pciModelString ); + dumpfield_str( m_driverInfoString ); + + printf( "\n m_osComboVersion: 0x%08x (%d.%d.%d)", m_caps.m_osComboVersion, (m_caps.m_osComboVersion>>16)&0xFF, (m_caps.m_osComboVersion>>8)&0xFF, (m_caps.m_osComboVersion)&0xFF ); + + dumpfield( m_ati ); + if (m_caps.m_ati) + { + dumpfield( m_atiR5xx ); + dumpfield( m_atiR6xx ); + dumpfield( m_atiR7xx ); + dumpfield( m_atiR8xx ); + dumpfield( m_atiNewer ); + } + + dumpfield( m_intel ); + if (m_caps.m_intel) + { + dumpfield( m_intel95x ); + dumpfield( m_intel3100 ); + dumpfield( m_intelNewer ); + } + + dumpfield( m_nv ); + if (m_caps.m_nv) + { + //dumpfield( m_nvG7x ); + dumpfield( m_nvG8x ); + dumpfield( m_nvNewer ); + } + + dumpfield( m_hasGammaWrites ); + dumpfield( m_hasMixedAttachmentSizes ); + dumpfield( m_hasBGRA ); + dumpfield( m_hasNewFullscreenMode ); + dumpfield( m_hasNativeClipVertexMode ); + dumpfield( m_maxAniso ); + dumpfield( m_hasBindableUniforms ); + dumpfield( m_hasUniformBuffers ); + dumpfield( m_hasPerfPackage1 ); + + dumpfield( m_cantBlitReliably ); + dumpfield( m_cantAttachSRGB ); + dumpfield( m_cantResolveFlipped ); + dumpfield( m_cantResolveScaled ); + dumpfield( m_costlyGammaFlips ); + dumpfield( m_badDriver1064NV ); + + printf("\n--------------------------------"); + + #undef dumpfield + #undef dumpfield_hex + #undef dumpfield_str +} + +void DefaultSamplingParams( GLMTexSamplingParams *samp, GLMTexLayoutKey *key ) +{ + memset( samp, 0, sizeof(*samp) ); + + // Default to black, it may make drivers happier + samp->m_borderColor[0] = 0.0f; + samp->m_borderColor[0] = 0.0f; + samp->m_borderColor[0] = 0.0f; + samp->m_borderColor[0] = 1.0f; + + // generally speaking.. + // if it's a render target, default it to GL_CLAMP_TO_BORDER, else GL_REPEAT + // if it has mipmaps, default the min filter to GL_LINEAR_MIPMAP_LINEAR, else GL_LINEAR + + // ** none of these really matter all that much because the first time we go to render, the d3d sampler state will be consulted + // and applied directly to the tex object without regard to any previous values.. + + GLenum rtclamp = GL_CLAMP_TO_EDGE; //GL_CLAMP_TO_BORDER + + switch( key->m_texFlags & (kGLMTexRenderable|kGLMTexMipped) ) + { + case 0: + // -- mipped, -- renderable + samp->m_addressModes[0] = GL_REPEAT; + samp->m_addressModes[1] = GL_REPEAT; + samp->m_addressModes[2] = GL_REPEAT; + + samp->m_magFilter = GL_LINEAR; + samp->m_minFilter = GL_LINEAR; + break; + + case kGLMTexRenderable: + // -- mipped, ++ renderable + samp->m_addressModes[0] = rtclamp; + samp->m_addressModes[1] = rtclamp; + samp->m_addressModes[2] = rtclamp; + + samp->m_magFilter = GL_LINEAR; + samp->m_minFilter = GL_LINEAR; + break; + + case kGLMTexMipped: + // ++ mipped, -- renderable + samp->m_addressModes[0] = GL_REPEAT; + samp->m_addressModes[1] = GL_REPEAT; + samp->m_addressModes[2] = GL_REPEAT; + + samp->m_magFilter = GL_LINEAR; + samp->m_minFilter = GL_LINEAR_MIPMAP_LINEAR; // was GL_NEAREST_MIPMAP_LINEAR; + break; + + case kGLMTexRenderable | kGLMTexMipped: + // ++ mipped, ++ renderable + samp->m_addressModes[0] = rtclamp; + samp->m_addressModes[1] = rtclamp; + samp->m_addressModes[2] = rtclamp; + + samp->m_magFilter = GL_LINEAR; + samp->m_minFilter = GL_LINEAR_MIPMAP_LINEAR; // was GL_NEAREST_MIPMAP_LINEAR; + break; + + } + + samp->m_mipmapBias = 0.0f; + + samp->m_minMipLevel = 0; // this drives GL_TEXTURE_MIN_LOD - i.e. lowest MIP selection index clamp (largest size), not "slice defined" boundary + samp->m_maxMipLevel = 16; // this drives GL_TEXTURE_MAX_LOD - i.e. highest MIP selection clamp (smallest size), not "slice defined" boundary + + samp->m_maxAniso = 1; + samp->m_compareMode = GL_NONE; // only for depth or stencil tex + + samp->m_srgb = false; +} + +CGLMTex *GLMContext::NewTex( GLMTexLayoutKey *key, const char *debugLabel ) +{ + //hushed GLM_FUNC; + MakeCurrent(); + + // get a layout based on the key + GLMTexLayout *layout = m_texLayoutTable->NewLayoutRef( key ); + + GLMTexSamplingParams defsamp; + DefaultSamplingParams( &defsamp, key ); + + CGLMTex *tex = new CGLMTex( this, layout, &defsamp, debugLabel ); + + return tex; +} + +void GLMContext::DelTex( CGLMTex *tex ) +{ + //hushed GLM_FUNC; + MakeCurrent(); + + for( int i=0; iBindTexToTMU( NULL, i ); + m_samplers[i].m_boundTex = NULL; // for clarity + + tex->m_bindPoints &= ~(1<m_rtAttachCount !=0) + { + // leak it and complain - we may have to implement a deferred-delete system for tex like these + + GLMPRINTF(("-D- ################## Leaking tex %08x [ %s ] - was attached for drawing at time of delete",tex, tex->m_layout->m_layoutSummary )); + + #if 0 + // can't actually do this yet as the draw calls will tank + FOR_EACH_VEC( m_fboTable, i ) + { + CGLMFBO *fbo = m_fboTable[i]; + fbo->TexScrub( tex ); + } + tex->m_rtAttachCount = 0; + #endif + } + else + { + delete tex; + } +} + + + + // push and pop attrib when blit has mixed srgb source and dest? +//ConVar gl_radar7954721_workaround_mixed ( "gl_radar7954721_workaround_mixed", "1" ); +int gl_radar7954721_workaround_mixed = 1; + + // push and pop attrib on any blit? +//ConVar gl_radar7954721_workaround_all ( "gl_radar7954721_workaround_all", "0" ); +int gl_radar7954721_workaround_all = 0; + + // what attrib mask to use ? +//ConVar gl_radar7954721_workaround_maskval ( "gl_radar7954721_workaround_maskval", "0" ); +int gl_radar7954721_workaround_maskval = 0; + +enum eBlitFormatClass +{ + eColor, + eDepth, // may not get used. not sure.. + eDepthStencil +}; + +uint glAttachFromClass[ 3 ] = { GL_COLOR_ATTACHMENT0_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_STENCIL_ATTACHMENT_EXT }; + +void glScrubFBO ( GLenum target ) +{ + glFramebufferRenderbufferEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, 0); GLMCheckError(); + glFramebufferRenderbufferEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); GLMCheckError(); + glFramebufferRenderbufferEXT ( target, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); GLMCheckError(); + + glFramebufferTexture2DEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0 ); GLMCheckError(); + glFramebufferTexture2DEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 ); GLMCheckError(); + glFramebufferTexture2DEXT ( target, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 ); GLMCheckError(); +} + +void glAttachRBOtoFBO ( GLenum target, eBlitFormatClass formatClass, uint rboName ) +{ + switch( formatClass ) + { + case eColor: + glFramebufferRenderbufferEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, rboName); GLMCheckError(); + break; + + case eDepth: + glFramebufferRenderbufferEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboName); GLMCheckError(); + break; + + case eDepthStencil: + glFramebufferRenderbufferEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboName); GLMCheckError(); + glFramebufferRenderbufferEXT ( target, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboName); GLMCheckError(); + break; + } +} + +void glAttachTex2DtoFBO ( GLenum target, eBlitFormatClass formatClass, uint texName, uint texMip ) +{ + switch( formatClass ) + { + case eColor: + glFramebufferTexture2DEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texName, texMip ); GLMCheckError(); + break; + + case eDepth: + glFramebufferTexture2DEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texName, texMip ); GLMCheckError(); + break; + + case eDepthStencil: + glFramebufferTexture2DEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texName, texMip ); GLMCheckError(); + glFramebufferTexture2DEXT ( target, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, texName, texMip ); GLMCheckError(); + break; + } +} + +//ConVar gl_can_resolve_flipped("gl_can_resolve_flipped", "0" ); +int gl_can_resolve_flipped = 0; + +//ConVar gl_cannot_resolve_flipped("gl_cannot_resolve_flipped", "0" ); +int gl_cannot_resolve_flipped = 0; + + +// these are only consulted if the m_cant_resolve_scaled cap bool is false. + +//ConVar gl_minify_resolve_mode("gl_minify_resolve_mode", "1" ); // if scaled resolve available, for downscaled resolve blits only (i.e. internal blits) +int gl_minify_resolve_mode = 1; + +//ConVar gl_magnify_resolve_mode("gl_magnify_resolve_mode", "2" ); // if scaled resolve available, for upscaled resolve blits only +int gl_magnify_resolve_mode = 2; + + + // 0 == old style, two steps + // 1 == faster, one step blit aka XGL_SCALED_RESOLVE_FASTEST_EXT - if available. + // 2 == faster, one step blit aka XGL_SCALED_RESOLVE_NICEST_EXT - if available. + +unsigned short foo[4]; + +void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcMip, CGLMTex *dstTex, GLMRect *dstRect, int dstFace, int dstMip, uint filter ) +{ + Assert( srcFace == 0 ); + Assert( dstFace == 0 ); + +// glColor4usv( foo ); + + //----------------------------------------------------------------- format assessment + + eBlitFormatClass formatClass; + uint blitMask= 0; + + switch( srcTex->m_layout->m_format->m_glDataFormat ) + { + case GL_BGRA: case GL_RGB: case GL_RGBA: case GL_ALPHA: case GL_LUMINANCE: case GL_LUMINANCE_ALPHA: + formatClass = eColor; + blitMask = GL_COLOR_BUFFER_BIT; + break; + + case GL_DEPTH_COMPONENT: + formatClass = eDepth; + blitMask = GL_DEPTH_BUFFER_BIT; + break; + + case GL_DEPTH_STENCIL_EXT: + formatClass = eDepthStencil; + blitMask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; + break; + + default: + Assert(!"Unsupported format for blit" ); + GLMStop(); + break; + } + + //----------------------------------------------------------------- blit assessment + + + bool blitResolves = srcTex->m_rboName != 0; + bool blitScales = ((srcRect->xmax - srcRect->xmin) != (dstRect->xmax - dstRect->xmin)) || ((srcRect->ymax - srcRect->ymin) != (dstRect->ymax - dstRect->ymin)); + + bool blitToBack = (dstTex == NULL); + bool blitFlips = blitToBack; // implicit y-flip upon blit to GL_BACK supplied + + //should we support blitFromBack ? + + bool srcGamma = srcTex && ((srcTex->m_layout->m_key.m_texFlags & kGLMTexSRGB) != 0); + bool dstGamma = dstTex && ((dstTex->m_layout->m_key.m_texFlags & kGLMTexSRGB) != 0); + + bool doPushPop = (srcGamma != dstGamma) && gl_radar7954721_workaround_mixed/*.GetInt()*/ && m_caps.m_nv; // workaround for cross gamma blit problems on NV + // ^^ need to re-check this on some post-10.6.3 build on NV to see if it was fixed + + if (doPushPop) + { + glPushAttrib( 0 ); + } + + //----------------------------------------------------------------- figure out the plan + + bool blitTwoStep = false; // think positive + + // each subsequent segment here can only set blitTwoStep, not clear it. + // the common case where these get hit is resolve out to presentation + // there may be GL extensions or driver revisions which start doing these safely. + // ideally many blits internally resolve without scaling and can thus go direct without using the scratch tex. + + if (blitResolves && (blitFlips||blitToBack)) // flips, blit to back, same thing (for now) + { + if( gl_cannot_resolve_flipped/*.GetInt()*/ ) + { + blitTwoStep = true; + } + else if (!gl_can_resolve_flipped/*.GetInt()*/) + { + blitTwoStep = blitTwoStep || m_caps.m_cantResolveFlipped; // if neither convar renders an opinion, fall back to the caps to decide if we have to two-step. + } + } + + // only consider trying to use the scaling resolve filter, + // if we are confident we are not headed for two step mode already. + if (!blitTwoStep) + { + if (blitResolves && blitScales) + { + if (m_caps.m_cantResolveScaled) + { + // filter is unchanged, two step mode switches on + blitTwoStep = true; + } + else + { + bool blitScalesDown = ((srcRect->xmax - srcRect->xmin) > (dstRect->xmax - dstRect->xmin)) || ((srcRect->ymax - srcRect->ymin) > (dstRect->ymax - dstRect->ymin)); + int mode = (blitScalesDown) ? gl_minify_resolve_mode/*.GetInt()*/ : gl_magnify_resolve_mode/*.GetInt()*/; + + // roughly speaking, resolve blits that minify represent setup for special effects ("copy framebuffer to me") + // resolve blits that magnify are almost always on the final present in the case where remder size < display size + + switch( mode ) + { + case 0: + default: + // filter is unchanged, two step mode + blitTwoStep = true; + break; + + case 1: + // filter goes to fastest, one step mode + blitTwoStep = false; + filter = XGL_SCALED_RESOLVE_FASTEST_EXT; + break; + + case 2: + // filter goes to nicest, one step mode + blitTwoStep = false; + filter = XGL_SCALED_RESOLVE_NICEST_EXT; + break; + } + } + } + } + + //----------------------------------------------------------------- save old scissor state and disable scissor + GLScissorEnable_t oldsciss,newsciss; + m_ScissorEnable.Read( &oldsciss, 0 ); + + // turn off scissor + newsciss.enable = false; + m_ScissorEnable.Write( &newsciss, true, true ); + + //----------------------------------------------------------------- fork in the road, depending on two-step or not + if (blitTwoStep) + { + // a resolve that can't be done directly due to constraints on scaling or flipping. + + // bind scratch FBO0 to read, scrub it, attach RBO + BindFBOToCtx ( m_scratchFBO[0], GL_READ_FRAMEBUFFER_EXT ); GLMCheckError(); + glScrubFBO ( GL_READ_FRAMEBUFFER_EXT ); + glAttachRBOtoFBO ( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_rboName ); + + // bind scratch FBO1 to write, scrub it, attach scratch tex + BindFBOToCtx ( m_scratchFBO[1], GL_DRAW_FRAMEBUFFER_EXT ); GLMCheckError(); + glScrubFBO ( GL_DRAW_FRAMEBUFFER_EXT ); + glAttachTex2DtoFBO ( GL_DRAW_FRAMEBUFFER_EXT, formatClass, srcTex->m_texName, 0 ); + + // set read and draw buffers appropriately + glReadBuffer ( glAttachFromClass[formatClass] ); + glDrawBuffer ( glAttachFromClass[formatClass] ); + + // blit#1 - to resolve to scratch + // implicitly means no scaling, thus will be done with NEAREST sampling + + GLenum resolveFilter = GL_NEAREST; + + glBlitFramebufferEXT( 0, 0, srcTex->m_layout->m_key.m_xSize, srcTex->m_layout->m_key.m_ySize, + 0, 0, srcTex->m_layout->m_key.m_xSize, srcTex->m_layout->m_key.m_ySize, // same source and dest rect, whole surface + blitMask, resolveFilter ); + GLMCheckError(); + + // FBO1 now holds the interesting content. + // scrub FBO0, bind FBO1 to READ, fall through to next stage of blit where 1 goes onto 0 (or BACK) + + glScrubFBO ( GL_READ_FRAMEBUFFER_EXT ); // zap FBO0 + BindFBOToCtx ( m_scratchFBO[1], GL_READ_FRAMEBUFFER_EXT ); GLMCheckError(); + } + else + { + // arrange source surface on FBO1 for blit directly to dest (which could be FBO0 or BACK) + BindFBOToCtx ( m_scratchFBO[1], GL_READ_FRAMEBUFFER_EXT ); GLMCheckError(); + glScrubFBO ( GL_READ_FRAMEBUFFER_EXT ); + if (blitResolves) + { + glAttachRBOtoFBO( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_rboName ); + } + else + { + glAttachTex2DtoFBO( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_texName, srcMip ); + } + + glReadBuffer( glAttachFromClass[formatClass] ); + } + + //----------------------------------------------------------------- zero or one blits may have happened above, whichever took place, FBO1 is now on read + + bool yflip = false; + if (blitToBack) + { + // backbuffer is special - FBO0 is left out (either scrubbed already, or not used) + + BindFBOToCtx ( NULL, GL_DRAW_FRAMEBUFFER_EXT ); GLMCheckError(); + glDrawBuffer ( GL_BACK ); GLMCheckError(); + + yflip = true; + } + else + { + // not going to GL_BACK - use FBO0. set up dest tex or RBO on it. i.e. it's OK to blit from MSAA to MSAA if needed, though unlikely. + Assert( dstTex != NULL ); + + BindFBOToCtx ( m_scratchFBO[0], GL_DRAW_FRAMEBUFFER_EXT ); GLMCheckError(); + glScrubFBO ( GL_DRAW_FRAMEBUFFER_EXT ); + + if (dstTex->m_rboName) + { + glAttachRBOtoFBO( GL_DRAW_FRAMEBUFFER_EXT, formatClass, dstTex->m_rboName ); + } + else + { + glAttachTex2DtoFBO( GL_DRAW_FRAMEBUFFER_EXT, formatClass, dstTex->m_texName, dstMip ); + } + + glDrawBuffer ( glAttachFromClass[formatClass] ); GLMCheckError(); + } + + // final blit + + // i think in general, if we are blitting same size, gl_nearest is the right filter to pass. + // this re-steering won't kick in if there is scaling or a special scaled resolve going on. + if (!blitScales) + { + // steer it + filter = GL_NEAREST; + } + + // this is blit #1 or #2 depending on what took place above. + if (yflip) + { + glBlitFramebufferEXT( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax, + dstRect->xmin, dstRect->ymax, dstRect->xmax, dstRect->ymin, // note dest Y's are flipped + blitMask, filter ); + } + else + { + glBlitFramebufferEXT( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax, + dstRect->xmin, dstRect->ymin, dstRect->xmax, dstRect->ymax, + blitMask, filter ); + } + GLMCheckError(); + + //----------------------------------------------------------------- scrub READ and maybe DRAW FBO, and unbind + + glScrubFBO ( GL_READ_FRAMEBUFFER_EXT ); + BindFBOToCtx ( NULL, GL_READ_FRAMEBUFFER_EXT ); GLMCheckError(); + if (!blitToBack) + { + glScrubFBO ( GL_DRAW_FRAMEBUFFER_EXT ); + BindFBOToCtx ( NULL, GL_DRAW_FRAMEBUFFER_EXT ); GLMCheckError(); + } + + //----------------------------------------------------------------- restore GLM's drawing FBO + + // restore GLM drawing FBO + BindFBOToCtx( m_drawingFBO, GL_READ_FRAMEBUFFER_EXT ); GLMCheckError(); + BindFBOToCtx( m_drawingFBO, GL_DRAW_FRAMEBUFFER_EXT ); GLMCheckError(); + + if (doPushPop) + { + glPopAttrib( ); + } + + + //----------------------------------------------------------------- restore old scissor state + m_ScissorEnable.Write( &oldsciss, true, true ); +} + + +void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcMip, CGLMTex *dstTex, GLMRect *dstRect, int dstFace, int dstMip, GLenum filter, bool useBlitFB ) +{ + switch( srcTex->m_layout->m_format->m_glDataFormat ) + { + case GL_BGRA: + case GL_RGB: + case GL_RGBA: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + #if 0 + if (GLMKnob("caps-key",NULL) > 0.0) + { + useBlitFB = false; + } + #endif + + if ( m_caps.m_cantBlitReliably ) // this is referring to a problem with the x3100.. + { + useBlitFB = false; + } + break; + } + + if (0) + { + GLMPRINTF(("-D- Blit from %d %d %d %d to %d %d %d %d", + srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax, + dstRect->xmin, dstRect->ymin, dstRect->xmax, dstRect->ymax + )); + + GLMPRINTF(( "-D- src tex layout is %s", srcTex->m_layout->m_layoutSummary )); + GLMPRINTF(( "-D- dst tex layout is %s", dstTex->m_layout->m_layoutSummary )); + } + + int pushed = 0; + uint pushmask = gl_radar7954721_workaround_maskval/*.GetInt()*/; + //GL_COLOR_BUFFER_BIT + //| GL_CURRENT_BIT + //| GL_ENABLE_BIT + //| GL_FOG_BIT + //| GL_PIXEL_MODE_BIT + //| GL_SCISSOR_BIT + //| GL_STENCIL_BUFFER_BIT + //| GL_TEXTURE_BIT + //GL_VIEWPORT_BIT + //; + + if (gl_radar7954721_workaround_all/*.GetInt()*/!=0) + { + glPushAttrib( pushmask ); + pushed++; + } + else + { + bool srcGamma = (srcTex->m_layout->m_key.m_texFlags & kGLMTexSRGB) != 0; + bool dstGamma = (dstTex->m_layout->m_key.m_texFlags & kGLMTexSRGB) != 0; + + if (srcGamma != dstGamma) + { + if (gl_radar7954721_workaround_mixed/*.GetInt()*/) + { + glPushAttrib( pushmask ); + pushed++; + } + } + } + + if (useBlitFB) + { + // state we need to save + // current setting of scissor + // current setting of the drawing fbo (no explicit save, it's in the context) + GLScissorEnable_t oldsciss,newsciss; + m_ScissorEnable.Read( &oldsciss, 0 ); + + // remember to restore m_drawingFBO at end of effort + + // setup + // turn off scissor + newsciss.enable = false; + m_ScissorEnable.Write( &newsciss, true, true ); + + // select which attachment enum we're going to use for the blit + // default to color0, unless it's a depth or stencil flava + + Assert( srcTex->m_layout->m_format->m_glDataFormat == dstTex->m_layout->m_format->m_glDataFormat ); + + EGLMFBOAttachment attachIndex = (EGLMFBOAttachment)0; + GLenum attachIndexGL = 0; + GLuint blitMask = 0; + switch( srcTex->m_layout->m_format->m_glDataFormat ) + { + case GL_BGRA: + case GL_RGB: + case GL_RGBA: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + attachIndex = kAttColor0; + attachIndexGL = GL_COLOR_ATTACHMENT0_EXT; + blitMask = GL_COLOR_BUFFER_BIT; + break; + + case GL_DEPTH_COMPONENT: + attachIndex = kAttDepth; + attachIndexGL = GL_DEPTH_ATTACHMENT_EXT; + blitMask = GL_DEPTH_BUFFER_BIT; + break; + + case GL_DEPTH_STENCIL_EXT: + attachIndex = kAttDepthStencil; + attachIndexGL = GL_DEPTH_STENCIL_ATTACHMENT_EXT; + blitMask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; + break; + + default: + Assert(0); + break; + } + + // set the read fb, attach read tex at appropriate attach point, set read buffer + BindFBOToCtx( m_blitReadFBO, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + + GLMFBOTexAttachParams attparams; + attparams.m_tex = srcTex; + attparams.m_face = srcFace; + attparams.m_mip = srcMip; + attparams.m_zslice = 0; + m_blitReadFBO->TexAttach( &attparams, attachIndex, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + + glReadBuffer( attachIndexGL ); + GLMCheckError(); + + + // set the write fb and buffer, and attach write tex + BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + attparams.m_tex = dstTex; + attparams.m_face = dstFace; + attparams.m_mip = dstMip; + attparams.m_zslice = 0; + m_blitDrawFBO->TexAttach( &attparams, attachIndex, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + glDrawBuffer( attachIndexGL ); + GLMCheckError(); + + // do the blit + glBlitFramebufferEXT( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax, + dstRect->xmin, dstRect->ymin, dstRect->xmax, dstRect->ymax, + blitMask, filter ); + GLMCheckError(); + + // cleanup + // unset the read fb and buffer, detach read tex + // unset the write fb and buffer, detach write tex + + m_blitReadFBO->TexDetach( attachIndex, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + + m_blitDrawFBO->TexDetach( attachIndex, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + // put the original FB back in place (both read and draw) + // this bind will hit both read and draw bindings + BindFBOToCtx( m_drawingFBO, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + BindFBOToCtx( m_drawingFBO, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + // set the read and write buffers back to... what ? does it matter for anything but copies ? don't worry about it + + // restore the scissor state + m_ScissorEnable.Write( &oldsciss, true, true ); + } + else + { + // textured quad style + + // we must attach the dest tex as the color buffer on the blit draw FBO + // so that means we need to re-set the drawing FBO on exit + + EGLMFBOAttachment attachIndex = (EGLMFBOAttachment)0; + GLenum attachIndexGL = 0; + switch( srcTex->m_layout->m_format->m_glDataFormat ) + { + case GL_BGRA: + case GL_RGB: + case GL_RGBA: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + attachIndex = kAttColor0; + attachIndexGL = GL_COLOR_ATTACHMENT0_EXT; + break; + + default: + Assert(!"Can't blit that format"); + break; + } + + BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + GLMFBOTexAttachParams attparams; + attparams.m_tex = dstTex; + attparams.m_face = dstFace; + attparams.m_mip = dstMip; + attparams.m_zslice = 0; + m_blitDrawFBO->TexAttach( &attparams, attachIndex, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + glDrawBuffer( attachIndexGL ); + GLMCheckError(); + + // attempt to just set states directly the way we want them, then use the latched states to repair them afterward. + this->NullProgram(); // out of program mode + + glDisable ( GL_ALPHA_TEST ); + glDisable ( GL_CULL_FACE ); + glDisable ( GL_POLYGON_OFFSET_FILL ); + glDisable ( GL_SCISSOR_TEST ); + + glDisable ( GL_CLIP_PLANE0 ); + glDisable ( GL_CLIP_PLANE1 ); + + glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + glDisable ( GL_BLEND ); + + glDepthMask ( GL_FALSE ); + glDisable ( GL_DEPTH_TEST ); + + glDisable ( GL_STENCIL_TEST ); + glStencilMask ( GL_FALSE ); + + GLMCheckError(); + + // now do the unlit textured quad... + glActiveTexture( GL_TEXTURE0 ); + glBindTexture( GL_TEXTURE_2D, srcTex->m_texName ); + GLMCheckError(); + + glEnable(GL_TEXTURE_2D); + GLMCheckError(); + + // immediate mode is fine + + float topv = 1.0; + float botv = 0.0; + + glBegin(GL_QUADS); + glTexCoord2f ( 0.0, botv ); + glVertex3f ( -1.0, -1.0, 0.0 ); + + glTexCoord2f ( 1.0, botv ); + glVertex3f ( 1.0, -1.0, 0.0 ); + + glTexCoord2f ( 1.0, topv ); + glVertex3f ( 1.0, 1.0, 0.0 ); + + glTexCoord2f ( 0.0, topv ); + glVertex3f ( -1.0, 1.0, 0.0 ); + glEnd(); + GLMCheckError(); + + glBindTexture( GL_TEXTURE_2D, 0 ); + GLMCheckError(); + + glDisable(GL_TEXTURE_2D); + GLMCheckError(); + + // invalidate tex binding 0 so it gets reset + m_samplers[0].m_boundTex = NULL; + + // leave active program empty - flush draw states will fix + + // then restore states using the scoreboard + + m_AlphaTestEnable.Flush( true ); + m_AlphaToCoverageEnable.Flush( true ); + m_CullFaceEnable.Flush( true ); + m_DepthBias.Flush( true ); + m_ScissorEnable.Flush( true ); + + m_ClipPlaneEnable.FlushIndex( 0, true ); + m_ClipPlaneEnable.FlushIndex( 1, true ); + + m_ColorMaskSingle.Flush( true ); + m_BlendEnable.Flush( true ); + + m_DepthMask.Flush( true ); + m_DepthTestEnable.Flush( true ); + + m_StencilWriteMask.Flush( true ); + m_StencilTestEnable.Flush( true ); + + // unset the write fb and buffer, detach write tex + + m_blitDrawFBO->TexDetach( attachIndex, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + // put the original FB back in place (both read and draw) + BindFBOToCtx( m_drawingFBO, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + BindFBOToCtx( m_drawingFBO, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + } + + while(pushed) + { + glPopAttrib(); + pushed--; + } +} + +void GLMContext::ResolveTex( CGLMTex *tex, bool forceDirty ) +{ + // only run resolve if it's (a) possible and (b) dirty or force-dirtied + if ( (tex->m_rboName) && ((tex->m_rboDirty)||forceDirty) ) + { + // state we need to save + // current setting of scissor + // current setting of the drawing fbo (no explicit save, it's in the context) + GLScissorEnable_t oldsciss,newsciss; + m_ScissorEnable.Read( &oldsciss, 0 ); + + // remember to restore m_drawingFBO at end of effort + + // setup + // turn off scissor + newsciss.enable = false; + m_ScissorEnable.Write( &newsciss, true, true ); + + // select which attachment enum we're going to use for the blit + // default to color0, unless it's a depth or stencil flava + + // for resolve, only handle a modest subset of the possible formats + EGLMFBOAttachment attachIndex = (EGLMFBOAttachment)0; + GLenum attachIndexGL = 0; + GLuint blitMask = 0; + switch( tex->m_layout->m_format->m_glDataFormat ) + { + case GL_BGRA: + case GL_RGB: + case GL_RGBA: + // case GL_ALPHA: + // case GL_LUMINANCE: + // case GL_LUMINANCE_ALPHA: + attachIndex = kAttColor0; + attachIndexGL = GL_COLOR_ATTACHMENT0_EXT; + blitMask = GL_COLOR_BUFFER_BIT; + break; + + // case GL_DEPTH_COMPONENT: + // attachIndex = kAttDepth; + // attachIndexGL = GL_DEPTH_ATTACHMENT_EXT; + // blitMask = GL_DEPTH_BUFFER_BIT; + // break; + + case GL_DEPTH_STENCIL_EXT: + attachIndex = kAttDepthStencil; + attachIndexGL = GL_DEPTH_STENCIL_ATTACHMENT_EXT; + blitMask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; + break; + + default: + Assert(!"Unsupported format for MSAA resolve" ); + break; + } + + + // set the read fb, attach read RBO at appropriate attach point, set read buffer + BindFBOToCtx( m_blitReadFBO, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + + // going to avoid the TexAttach / TexDetach calls due to potential confusion, implement it directly here + + //----------------------------------------------------------------------------------- + // put tex->m_rboName on the read FB's attachment + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + // you have to attach it both places... + // http://www.opengl.org/wiki/GL_EXT_framebuffer_object + + // bind the RBO to the GL_RENDERBUFFER_EXT target - is this extraneous ? + //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName ); + //GLMCheckError(); + + // attach the GL_RENDERBUFFER_EXT target to the depth and stencil attach points + glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName); + GLMCheckError(); + + glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName); + GLMCheckError(); + + // no need to leave the RBO hanging on + //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); + //GLMCheckError(); + } + else + { + //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName ); + //GLMCheckError(); + + glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, attachIndexGL, GL_RENDERBUFFER_EXT, tex->m_rboName); + GLMCheckError(); + + //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); + //GLMCheckError(); + } + + glReadBuffer( attachIndexGL ); + GLMCheckError(); + + //----------------------------------------------------------------------------------- + // put tex->m_texName on the draw FBO attachment + + // set the write fb and buffer, and attach write tex + BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + // regular path - attaching a texture2d + + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, tex->m_texName, 0 ); + GLMCheckError(); + + glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, tex->m_texName, 0 ); + GLMCheckError(); + } + else + { + glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, attachIndexGL, GL_TEXTURE_2D, tex->m_texName, 0 ); + GLMCheckError(); + } + + glDrawBuffer( attachIndexGL ); + GLMCheckError(); + + //----------------------------------------------------------------------------------- + + // blit + glBlitFramebufferEXT( 0, 0, tex->m_layout->m_key.m_xSize, tex->m_layout->m_key.m_ySize, + 0, 0, tex->m_layout->m_key.m_xSize, tex->m_layout->m_key.m_ySize, + blitMask, GL_NEAREST ); + // or should it be GL_LINEAR? does it matter ? + + GLMCheckError(); + + //----------------------------------------------------------------------------------- + // cleanup + //----------------------------------------------------------------------------------- + + + // unset the read fb and buffer, detach read RBO + //glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); + //GLMCheckError(); + + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + // detach the GL_RENDERBUFFER_EXT target from the depth and stencil attach points + glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); + GLMCheckError(); + + glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0); + GLMCheckError(); + } + else + { + glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, attachIndexGL, GL_RENDERBUFFER_EXT, 0); + GLMCheckError(); + } + + //----------------------------------------------------------------------------------- + // unset the write fb and buffer, detach write tex + + + if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT) + { + glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 ); + GLMCheckError(); + + glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 ); + GLMCheckError(); + } + else + { + glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, attachIndexGL, GL_TEXTURE_2D, 0, 0 ); + GLMCheckError(); + } + + // put the original FB back in place (both read and draw) + // this bind will hit both read and draw bindings + BindFBOToCtx( m_drawingFBO, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + BindFBOToCtx( m_drawingFBO, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + // set the read and write buffers back to... what ? does it matter for anything but copies ? don't worry about it + + // restore the scissor state + m_ScissorEnable.Write( &oldsciss, true, true ); + + // mark the RBO clean on the resolved tex + tex->m_rboDirty = false; + } +} + +void GLMContext::PreloadTex( CGLMTex *tex, bool force ) +{ + #if 0 // disabled in sample for time being + // if conditions allow (i.e. a drawing surface is active) + // bind the texture on TMU 15 + // set up a dummy program to sample it but not write (use 'discard') + // draw a teeny little triangle that won't generate a lot of fragments + if (!m_pairCache) + return; + + if (!m_drawingFBO) + return; + + if (!m_drawingFBO) + return; + + if (tex->m_texPreloaded && !force) // only do one preload unless forced to re-do + { + //printf("\nnot-preloading %s", tex->m_debugLabel ? tex->m_debugLabel : "(unknown)"); + return; + } + + //printf("\npreloading %s", tex->m_debugLabel ? tex->m_debugLabel : "(unknown)"); + + CGLMProgram *vp = m_preloadTexVertexProgram; + CGLMProgram *fp = NULL; + switch(tex->m_layout->m_key.m_texGLTarget) + { + case GL_TEXTURE_2D: fp = m_preload2DTexFragmentProgram; + break; + + case GL_TEXTURE_3D: fp = m_preload3DTexFragmentProgram; + break; + + case GL_TEXTURE_CUBE_MAP: fp = m_preloadCubeTexFragmentProgram; + break; + } + if (!fp) + return; + + CGLMShaderPair *preloadPair = m_pairCache->SelectShaderPair( vp, fp, 0 ); + if (!preloadPair) + return; + + GLhandleARB pairProgram = preloadPair->m_program; + uint pairRevision = preloadPair->m_revision; + + m_boundPair = preloadPair; + m_boundPairProgram = pairProgram; + m_boundPairRevision = pairRevision; + + glUseProgram( (GLuint)pairProgram ); + GLMCheckError(); + + // note the binding (not really bound.. just sitting in the linked active GLSL program) + m_boundProgram[ kGLMVertexProgram ] = vp; + m_boundProgram[ kGLMFragmentProgram ] = fp; + + // almost ready to draw... + + int tmuForPreload = 15; + if(!m_boundPair->m_samplersFixed) + { + if (m_boundPair->m_locSamplers[tmuForPreload] >=0) + { + glUniform1iARB( m_boundPair->m_locSamplers[tmuForPreload], tmuForPreload ); + GLMCheckError(); + } + m_boundPair->m_samplersFixed = true; + } + + // shut down all the generic attribute arrays on the detention level - next real draw will activate them again + m_lastKnownVertexAttribMask = 0; + for( int index=0; index < kGLMVertexAttributeIndexMax; index++ ) + { + glDisableVertexAttribArray( index ); + GLMCheckError(); + } + + + // bind texture + this->BindTexToTMU( tex, 15 ); + + // unbind vertex/index buffers + this->BindBufferToCtx( kGLMVertexBuffer, NULL ); + this->BindBufferToCtx( kGLMIndexBuffer, NULL ); + + // draw + static float posns[] = { 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f }; + + static int indices[] = { 0, 1, 2 }; + + + glEnableVertexAttribArray( 0 ); + GLMCheckError(); + + glVertexAttribPointer( 0, 3, GL_FLOAT, 0, 0, posns ); + GLMCheckError(); + + glDrawRangeElements( GL_TRIANGLES, 0, 3, 3, GL_UNSIGNED_INT, indices); + GLMCheckError(); + + glDisableVertexAttribArray( 0 ); + GLMCheckError(); + + m_lastKnownVertexAttribMask = 0; + m_lastKnownVertexAttribs[0].m_bufferRevision -= 1; // force mismatch so next FlushDrawStates restores the right attrib source + + this->BindTexToTMU( NULL, 15 ); + + tex->m_texPreloaded = true; + #endif +} + + +void GLMContext::SetSamplerTex( int sampler, CGLMTex *tex ) +{ + GLM_FUNC; + CheckCurrent(); + + m_samplers[sampler].m_drawTex = tex; +} + +void GLMContext::SetSamplerParams( int sampler, GLMTexSamplingParams *params ) +{ + GLM_FUNC; + CheckCurrent(); + + m_samplers[sampler].m_samp = *params; +} + + +CGLMFBO *GLMContext::NewFBO( void ) +{ + GLM_FUNC; + MakeCurrent(); + + CGLMFBO *fbo = new CGLMFBO( this ); + + m_fboTable.push_back( fbo ); + + return fbo; +} + +void GLMContext::DelFBO( CGLMFBO *fbo ) +{ + GLM_FUNC; + MakeCurrent(); + + if (m_drawingFBO == fbo) + { + m_drawingFBO = NULL; //poof! + } + + if (m_boundReadFBO == fbo ) + { + this->BindFBOToCtx( NULL, GL_READ_FRAMEBUFFER_EXT ); + m_boundReadFBO = NULL; + } + + if (m_boundDrawFBO == fbo ) + { + this->BindFBOToCtx( NULL, GL_DRAW_FRAMEBUFFER_EXT ); + m_boundDrawFBO = NULL; + } + + std::vector< CGLMFBO * >::iterator p = find( m_fboTable.begin(), m_fboTable.end(), fbo ); + if (p != m_fboTable.end() ) + { + m_fboTable.erase( p ); + } + + delete fbo; +} + +void GLMContext::SetDrawingFBO( CGLMFBO *fbo ) +{ + GLM_FUNC; + CheckCurrent(); + + // might want to validate that fbo object? + m_drawingFBO = fbo; +} + +//=============================================================================== + +CGLMProgram *GLMContext::NewProgram( EGLMProgramType type, char *progString ) +{ + //hushed GLM_FUNC; + + MakeCurrent(); + + CGLMProgram *prog = new CGLMProgram( this, type ); + + prog->SetProgramText( progString ); + bool compile_ok = prog->CompileActiveSources(); + + //AssertOnce( compile_ok ); + + return prog; +} + +void GLMContext::DelProgram( CGLMProgram *prog ) +{ + GLM_FUNC; + + this->MakeCurrent(); + + if (m_drawingProgram[ prog->m_type ] == prog) + { + m_drawingProgram[ prog->m_type ] = NULL; + } + + // make sure to eliminate any cached pairs using this shader + bool purgeResult = m_pairCache->PurgePairsWithShader( prog ); + Assert( !purgeResult ); // very unlikely to trigger + + this->NullProgram(); + + delete prog; +} + +void GLMContext::NullProgram( void ) +{ + // just unbind everything on a prog delete + glSetEnable( GL_VERTEX_PROGRAM_ARB, false ); + glSetEnable( GL_FRAGMENT_PROGRAM_ARB, false ); + + glBindProgramARB( GL_VERTEX_PROGRAM_ARB, 0 ); + glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, 0 ); + + glUseProgram( 0 ); + m_boundPair = NULL; + m_boundPairRevision = 0xFFFFFFFF; + m_boundPairProgram = (GLhandleARB)0xFFFFFFFF; + + m_boundProgram[ kGLMVertexProgram ] = NULL; + m_boundProgram[ kGLMFragmentProgram ] = NULL; +} + +void GLMContext::SetDrawingProgram( EGLMProgramType type, CGLMProgram *prog ) +{ + GLM_FUNC; + + this->MakeCurrent(); + + if (prog) // OK to pass NULL.. + { + if (type != prog->m_type) + { + Debugger(); + } + } + else + { + // if a null fragment program is passed, we activate our special null program + // thus FP is always always enabled. + if (type==kGLMFragmentProgram) + { + prog = m_nullFragmentProgram; + } + else + { + //Assert(!"Tried to set NULL vertex program"); + } + } + m_drawingProgram[type] = prog; +} + +void GLMContext::SetDrawingLang( EGLMProgramLang lang, bool immediate ) +{ + if ( !m_caps.m_hasDualShaders ) return; // ignore attempts to change language when -glmdualshaders is not engaged + + m_drawingLangAtFrameStart = lang; + if (immediate) + { + this->NullProgram(); + + m_drawingLang = m_drawingLangAtFrameStart; + } +} + +void GLMContext::LinkShaderPair( CGLMProgram *vp, CGLMProgram *fp ) +{ + if ( (m_pairCache) && (m_drawingLang==kGLMGLSL) && (vp && vp->m_descs[kGLMGLSL].m_valid) && (fp && fp->m_descs[kGLMGLSL].m_valid) ) + { + CGLMShaderPair *pair = m_pairCache->SelectShaderPair( vp, fp, 0 ); + + Assert( pair != NULL ); + + this->NullProgram(); // clear out any binds that were done - next draw will set it right + } +} + +void GLMContext::ClearShaderPairCache( void ) +{ + if (m_pairCache) + { + this->NullProgram(); + m_pairCache->Purge(); // bye bye all linked pairs + this->NullProgram(); + } +} + +void GLMContext::QueryShaderPair( int index, GLMShaderPairInfo *infoOut ) +{ + if (m_pairCache) + { + m_pairCache->QueryShaderPair( index, infoOut ); + } + else + { + memset( infoOut, sizeof( *infoOut ), 0 ); + infoOut->m_status = -1; + } +} + +void GLMContext::SetProgramParametersF( EGLMProgramType type, uint baseSlot, float *slotData, uint slotCount ) +{ + GLM_FUNC; + + Assert( baseSlot < kGLMProgramParamFloat4Limit ); + Assert( baseSlot+slotCount <= kGLMProgramParamFloat4Limit ); + + GLMPRINTF(("-S-GLMContext::SetProgramParametersF %s slots %d - %d: ", (type==kGLMVertexProgram) ? "VS" : "FS", baseSlot, baseSlot + slotCount - 1 )); + for( int i=0; i m_programParamsF[type].m_dirtySlotCount) + { + m_programParamsF[type].m_dirtySlotCount = baseSlot+slotCount; + } +} + +void GLMContext::SetProgramParametersB( EGLMProgramType type, uint baseSlot, int *slotData, uint boolCount ) +{ + GLM_FUNC; + + Assert( m_drawingLang == kGLMGLSL ); + Assert( type==kGLMVertexProgram ); + + Assert( baseSlot < kGLMProgramParamBoolLimit ); + Assert( baseSlot+boolCount <= kGLMProgramParamBoolLimit ); + + GLMPRINTF(("-S-GLMContext::SetProgramParametersB %s bools %d - %d: ", (type==kGLMVertexProgram) ? "VS" : "FS", baseSlot, baseSlot + boolCount - 1 )); + for( int i=0; i m_programParamsB[type].m_dirtySlotCount) + { + m_programParamsB[type].m_dirtySlotCount = baseSlot+boolCount; + } +} + +void GLMContext::SetProgramParametersI( EGLMProgramType type, uint baseSlot, int *slotData, uint slotCount ) // groups of 4 ints... +{ + GLM_FUNC; + + Assert( m_drawingLang == kGLMGLSL ); + Assert( type==kGLMVertexProgram ); + + Assert( baseSlot < kGLMProgramParamInt4Limit ); + Assert( baseSlot+slotCount <= kGLMProgramParamInt4Limit ); + + GLMPRINTF(("-S-GLMContext::SetProgramParametersI %s slots %d - %d: ", (type==kGLMVertexProgram) ? "VS" : "FS", baseSlot, baseSlot + slotCount - 1 )); + for( int i=0; i m_programParamsI[type].m_dirtySlotCount) + { + m_programParamsI[type].m_dirtySlotCount = baseSlot+slotCount; + } +} + + +CGLMBuffer *GLMContext::NewBuffer( EGLMBufferType type, uint size, uint options ) +{ + //hushed GLM_FUNC; + + MakeCurrent(); + + CGLMBuffer *prog = new CGLMBuffer( this, type, size, options ); + + return prog; +} + +void GLMContext::DelBuffer( CGLMBuffer *buff ) +{ + GLM_FUNC; + + this->MakeCurrent(); + + for( int index=0; index < kGLMVertexAttributeIndexMax; index++ ) + { + if (m_drawVertexSetup.m_attrs[index].m_buffer == buff) + { + // just clear the enable mask - this will force all the attrs to get re-sent on next sync + m_drawVertexSetup.m_attrMask = 0; + } + } + + if (m_drawIndexBuffer == buff) + { + m_drawIndexBuffer = NULL; + } + + if (m_lastKnownBufferBinds[ buff->m_type ] == buff) + { + // shoot it down + this->BindBufferToCtx( buff->m_type, NULL ); + m_lastKnownBufferBinds[ buff->m_type ] = NULL; + } + + delete buff; +} + + +void GLMContext::SetIndexBuffer( CGLMBuffer *buff ) +{ + GLM_FUNC; + CheckCurrent(); + + m_drawIndexBuffer = buff; + + // draw time is welcome to re-check, but we bind it immediately. + this->BindBufferToCtx( kGLMIndexBuffer, buff ); +} + +GLMVertexSetup g_blank_setup; + +void GLMContext::SetVertexAttributes( GLMVertexSetup *setup ) +{ + GLM_FUNC; + + // we now just latch the vert setup and then execute on it at flushdrawstatestime if shaders are enabled. + if (setup) + { + m_drawVertexSetup = *setup; + } + else + { + memset( &m_drawVertexSetup, 0, sizeof(m_drawVertexSetup) ); + } + + return; +} + +void GLMContext::Clear( bool color, unsigned long colorValue, bool depth, float depthValue, bool stencil, unsigned int stencilValue, GLScissorBox_t *box ) +{ + GLM_FUNC; + m_debugBatchIndex++; // clears are batches too (maybe blits should be also...) + +#if GLMDEBUG + GLMDebugHookInfo info; + memset( &info, 0, sizeof(info) ); + info.m_caller = eClear; + + do + { +#endif + uint mask = 0; + + GLClearColor_t clearcol; + GLClearDepth_t cleardep = { depthValue }; + GLClearStencil_t clearsten = { (GLint)stencilValue }; + + // depth write mask must be saved&restored + GLDepthMask_t olddepthmask; + GLDepthMask_t newdepthmask = { true }; + + // stencil write mask must be saved and restored + GLStencilWriteMask_t oldstenmask; + GLStencilWriteMask_t newstenmask = { ~(GLint)0 }; + + GLColorMaskSingle_t oldcolormask; + GLColorMaskSingle_t newcolormask = { -1,-1,-1,-1 }; // D3D clears do not honor color mask, so force it + + if (color) + { + // #define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) + + clearcol.r = ((colorValue >> 16) & 0xFF) / 255.0f; //R + clearcol.g = ((colorValue >> 8) & 0xFF) / 255.0f; //G + clearcol.b = ((colorValue ) & 0xFF) / 255.0f; //B + clearcol.a = ((colorValue >> 24) & 0xFF) / 255.0f; //A + + m_ClearColor.Write( &clearcol, true, true ); // no check, no wait + mask |= GL_COLOR_BUFFER_BIT; + + // save and set color mask + m_ColorMaskSingle.Read( &oldcolormask, 0 ); + m_ColorMaskSingle.Write( &newcolormask, true, true ); + } + + if (depth) + { + // get old depth write mask + m_DepthMask.Read( &olddepthmask, 0 ); + m_DepthMask.Write( &newdepthmask, true, true ); + m_ClearDepth.Write( &cleardep, true, true ); // no check, no wait + mask |= GL_DEPTH_BUFFER_BIT; + } + + if (stencil) + { + m_ClearStencil.Write( &clearsten, true, true ); // no check, no wait + mask |= GL_STENCIL_BUFFER_BIT; + + // save and set sten mask + m_StencilWriteMask.Read( &oldstenmask, 0 ); + m_StencilWriteMask.Write( &newstenmask, true, true ); + } + + bool subrect = (box != NULL); + GLScissorEnable_t scissorEnableSave; + GLScissorEnable_t scissorEnableNew = { true }; + + GLScissorBox_t scissorBoxSave; + GLScissorBox_t scissorBoxNew; + + if (subrect) + { + // save current scissorbox and enable + m_ScissorEnable.Read( &scissorEnableSave, 0 ); + m_ScissorBox.Read( &scissorBoxSave, 0 ); + + if(0) + { + // calc new scissorbox as intersection against *box + + // max of the mins + scissorBoxNew.x = std::max(scissorBoxSave.x, box->x); + scissorBoxNew.y = std::max(scissorBoxSave.y, box->y); + + // min of the maxes + scissorBoxNew.width = ( std::min(scissorBoxSave.x+scissorBoxSave.width, box->x+box->width)) - scissorBoxNew.x; + + // height is just min of the max y's, minus the new base Y + scissorBoxNew.height = ( std::min(scissorBoxSave.y+scissorBoxSave.height, box->y+box->height)) - scissorBoxNew.y; + } + else + { + // ignore old scissor box completely. + scissorBoxNew = *box; + } + // set new box and enable + m_ScissorEnable.Write( &scissorEnableNew, true, true ); + m_ScissorBox.Write( &scissorBoxNew, true, true ); + } + + glClear( mask ); + + if (subrect) + { + // put old scissor box and enable back + m_ScissorEnable.Write( &scissorEnableSave, true, true ); + m_ScissorBox.Write( &scissorBoxSave, true, true ); + } + + if (depth) + { + // put old depth write mask + m_DepthMask.Write( &olddepthmask ); + } + + if (color) + { + // put old color write mask + m_ColorMaskSingle.Write( &oldcolormask, true, true ); + } + + if (stencil) + { + // put old sten mask + m_StencilWriteMask.Write( &oldstenmask, true, true ); + } + +#if GLMDEBUG + this->DebugHook( &info ); + } while (info.m_loop); +#endif +} + + +// stolen from glmgrbasics.cpp +extern "C" uint GetCurrentKeyModifiers( void ); +enum ECarbonModKeyIndex +{ + EcmdKeyBit = 8, /* command key down?*/ + EshiftKeyBit = 9, /* shift key down?*/ + EalphaLockBit = 10, /* alpha lock down?*/ + EoptionKeyBit = 11, /* option key down?*/ + EcontrolKeyBit = 12 /* control key down?*/ +}; + +enum ECarbonModKeyMask +{ + EcmdKey = 1 << EcmdKeyBit, + EshiftKey = 1 << EshiftKeyBit, + EalphaLock = 1 << EalphaLockBit, + EoptionKey = 1 << EoptionKeyBit, + EcontrolKey = 1 << EcontrolKeyBit +}; + +#if 0 + static ConVar gl_flushpaircache ("gl_flushpaircache", "0"); + static ConVar gl_paircachestats ("gl_paircachestats", "0"); + static ConVar gl_mtglflush_at_tof ("gl_mtglflush_at_tof", "0"); + static ConVar gl_texlayoutstats ("gl_texlayoutstats", "0" ); +#else + int gl_flushpaircache =0; + int gl_paircachestats =0; + int gl_mtglflush_at_tof =0; + int gl_texlayoutstats =0; +#endif + +void GLMContext::BeginFrame( void ) +{ + GLM_FUNC; + + MakeCurrent(); + + m_debugFrameIndex++; + m_debugBatchIndex = -1; + + // check for lang change at TOF + if (m_caps.m_hasDualShaders) + { + if (m_drawingLang != m_drawingLangAtFrameStart) + { + // language change. unbind everything.. + this->NullProgram(); + + m_drawingLang = m_drawingLangAtFrameStart; + } + } + + // scrub some critical shock absorbers + for( int i=0; i< 16; i++) + { + glDisableVertexAttribArray( i ); // enable GLSL attribute- this is just client state - will be turned back off + GLMCheckError(); + } + m_lastKnownVertexAttribMask = 0; + + //FIXME should we also zap the m_lastKnownAttribs array ? (worst case it just sets them all again on first batch) + + BindBufferToCtx( kGLMVertexBuffer, NULL, true ); + BindBufferToCtx( kGLMIndexBuffer, NULL, true ); + + if (gl_flushpaircache/*.GetInt()*/) + { + // do the flush and then set back to zero + this->ClearShaderPairCache(); + + printf("\n\n##### shader pair cache cleared\n\n"); + gl_flushpaircache = 0; //.SetValue( 0 ); + } + + if (gl_paircachestats/*.GetInt()*/) + { + // do the flush and then set back to zero + this->m_pairCache->DumpStats(); + + gl_paircachestats = 0; //.SetValue( 0 ); + } + + if (gl_texlayoutstats/*.GetInt()*/) + { + this->m_texLayoutTable->DumpStats(); + + gl_texlayoutstats = 0; //.SetValue( 0 ); + } + + if (gl_mtglflush_at_tof/*.GetInt()*/) + { + glFlush(); // TOF flush - skip this if benchmarking, enable it if human playing (smoothness) + } + +#if GLMDEBUG + // init debug hook information + GLMDebugHookInfo info; + memset( &info, 0, sizeof(info) ); + info.m_caller = eBeginFrame; + + do + { + this->DebugHook( &info ); + } while (info.m_loop); + +#endif + +} + +void GLMContext::EndFrame( void ) +{ + GLM_FUNC; + +#if GLMDEBUG + // init debug hook information + GLMDebugHookInfo info; + memset( &info, 0, sizeof(info) ); + info.m_caller = eEndFrame; + + do + { +#endif + if (!m_oneCtxEnable) // if using dual contexts, this flush is needed + { + glFlush(); + } +#if GLMDEBUG + this->DebugHook( &info ); + } while (info.m_loop); +#endif +} + +//=============================================================================== + +CGLMQuery *GLMContext::NewQuery( GLMQueryParams *params ) +{ + CGLMQuery *query = new CGLMQuery( this, params ); + + return query; +} + +void GLMContext::DelQuery( CGLMQuery *query ) +{ + // may want to do some finish/ + delete query; +} + +// static ConVar mat_vsync( "mat_vsync", "0", 0, "Force sync to vertical retrace", true, 0.0, true, 1.0 ); +int mat_vsync = 1; + +//=============================================================================== + +// ConVar glm_nullrefresh_capslock( "glm_nullrefresh_capslock", "0" ); +// ConVar glm_literefresh_capslock( "glm_literefresh_capslock", "0" ); + +// extern ConVar gl_blitmode; +extern int gl_blitmode; + +void GLMContext::Present( CGLMTex *tex ) +{ +#if DX9MODE + GLM_FUNC; + + MakeCurrent(); + + // this is the path whether full screen or windowed... we always blit. + CShowPixelsParams showparams; + memset( &showparams, 0, sizeof(showparams) ); + + showparams.m_srcTexName = tex->m_texName; + showparams.m_width = tex->m_layout->m_key.m_xSize; + showparams.m_height = tex->m_layout->m_key.m_ySize; +// showparams.m_vsyncEnable = m_displayParams.m_vsyncEnable = mat_vsync; //.GetBool(); +// showparams.m_fsEnable = m_displayParams.m_fsEnable; + + // we call showpixels once with the "only sync view" arg set, so we know what the latest surface size is, before trying to do our own blit ! +// showparams.m_onlySyncView = true; +// g_engine->ShowPixels(&showparams); // doesn't actually show anything, just syncs window/fs state (would make a useful separate call) +// showparams.m_onlySyncView = false; + + // blit to GL_BACK done here, not in engine, this lets us do resolve directly if conditions are right + + GLMRect srcRect, dstRect; + + uint dstWidth,dstHeight; + g_engine->DisplayedSize( dstWidth,dstHeight ); + + srcRect.xmin = 0; + srcRect.ymin = 0; + srcRect.xmax = showparams.m_width; + srcRect.ymax = showparams.m_height; + + dstRect.xmin = 0; + dstRect.ymin = 0; + dstRect.xmax = dstWidth; + dstRect.ymax = dstHeight; + + // do not ask for LINEAR if blit is unscaled + // NULL means targeting GL_BACK. Blit2 will break it down into two steps if needed, and will handle resolve, scale, flip. + bool blitScales = (showparams.m_width != dstWidth) || (showparams.m_height != dstHeight); + this->Blit2( tex, &srcRect, 0,0, + NULL, &dstRect, 0,0, + blitScales ? GL_LINEAR : GL_NEAREST ); + + if (m_oneCtxEnable) // if using single context, we need to blast some state so GLM will recover after the FBO fiddlin' + { + BindFBOToCtx( NULL, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + BindFBOToCtx( NULL, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + } + + g_engine->ShowPixels(&showparams); + + if (m_oneCtxEnable) + { + // put the original FB back in place (both read and draw) + // this bind will hit both read and draw bindings + BindFBOToCtx( m_drawingFBO, GL_READ_FRAMEBUFFER_EXT ); + GLMCheckError(); + BindFBOToCtx( m_drawingFBO, GL_DRAW_FRAMEBUFFER_EXT ); + GLMCheckError(); + + // put em back !! + m_ScissorEnable.Flush( true ); + m_ScissorBox.Flush( true ); + m_ViewportBox.Flush( true ); + } + else + { + MakeCurrent(); + } +#endif +} + + + +//=============================================================================== +// GLMContext protected methods + +// a naive implementation of this would just clear-drawable on the context at entry, +// and then capture and set fullscreen if requested. +// however that would glitch thescreen every time the user changed resolution while staying in full screen. +// but in windowed mode there's really not much to do in here. Yeah, this routine centers around obtaining +// drawables for fullscreen mode, and/or dropping those drawables if we're going back to windowed. + +// um, are we expected to re-make the standard surfaces (color, depthstencil) if the res changes? is that now this routine's job ? + +// so, kick it off with an assessment of whather we were FS previously or not. +// if there was no prior display params latched, then it wasn't. + +// changes in here take place immediately. If you want to defer display changes then that's going to be a different method. +// common assumption is that there will be two places that call this: context create and the implementation of the DX9 Reset method. +// in either case the client code is aware of what it signed up for. + +bool GLMContext::SetDisplayParams( GLMDisplayParams *params ) +{ + m_displayParams = *params; // latch em + m_displayParamsValid = true; + return true; +} + +//extern ConVar gl_singlecontext; // single context mode go-ahead if 10.6.3 or higher +extern int gl_singlecontext; // it's in glmgrbasics.cpp + +//ConVar gl_can_query_fast("gl_can_query_fast", "0"); +int gl_can_query_fast = 1; // assume SLGU + +GLMContext::GLMContext( GLMDisplayParams *params ) +{ +#if DX9MODE + // flag our copy of display params as blank + m_displayParamsValid = false; + + // peek at any CLI options + m_slowAssertEnable = false;//CommandLine()->FindParm("-glmassertslow"); + m_slowSpewEnable = false; //CommandLine()->FindParm("-glmspewslow"); + m_slowCheckEnable = m_slowAssertEnable || m_slowSpewEnable; + + m_drawingLangAtFrameStart = m_drawingLang = kGLMGLSL; // default to GLSL + + // this affects FlushDrawStates which will route program bindings, uniform delivery, sampler setup, and enables accordingly. + + if ( 0 /*CommandLine()->FindParm("-glslmode")*/ ) + { + m_drawingLangAtFrameStart = m_drawingLang = kGLMGLSL; + } + if ( 0 /* CommandLine()->FindParm("-arbmode") && !CommandLine()->FindParm("-glslcontrolflow") */ ) + { + m_drawingLangAtFrameStart = m_drawingLang = kGLMARB; + } + + // proceed with rest of init + + m_nsctx = NULL; + m_ctx = NULL; + + // call engine, ask for the attrib list (also naming the specific renderer ID) and use that to make our context + CGLPixelFormatAttribute *selAttribs = NULL; + uint selWords = 0; + + memset( &m_caps, 0, sizeof( m_caps ) ); + //g_engine->GetDesiredPixelFormatAttribsAndRendererInfo( (uint**)&selAttribs, &selWords, &m_caps ); + g_engine->GetRendererInfo( &m_caps ); + uint selBytes = selWords * sizeof( uint ); + + // call engine, ask it about the window we're targeting, get the NSGLContext back, share against that + PseudoNSGLContextPtr shareNsCtx = g_engine->GetNSGLContextForWindow( (void*)params->m_focusWindow ); + + + // decide if we're going to try single context mode. + m_oneCtxEnable = true; // 10.6 only... //(m_caps.m_osComboVersion >= 0x000A0603) && (gl_singlecontext/*.GetInt()*/ ); + + bool success = false; + if(m_oneCtxEnable) + { + // just steal the window's context + m_nsctx = shareNsCtx; + m_ctx = GetCGLContextFromNSGL( shareNsCtx ); + + success = (m_nsctx != NULL) && (m_ctx != NULL); + } + else + { + // this is the old 10.5.x two-context path.... ugh + success = NewNSGLContext( (unsigned long*)selAttribs, shareNsCtx, &m_nsctx, &m_ctx ); + } + + if (success) + { + //write a cookie into the CGL context leading back to the GLM context object + GLint glm_context_link = (GLint)((uintptr_t)this); + CGLSetParameter( m_ctx, kCGLCPClientStorage, &glm_context_link ); + + // save off the pixel format attributes we used + memcpy(m_pixelFormatAttribs, selAttribs, selBytes ); + } + else + { + Debugger(); //FIXME #PMB# bad news, maybe exit to shell if this happens + } + + if ( 1 /* CommandLine()->FindParm("-glmspewcaps") */) //FIXME change to '0' later + { + DumpCaps(); + } + + SetDisplayParams( params ); + + m_texLayoutTable = new CGLMTexLayoutTable; + + memset( m_samplers, 0, sizeof( m_samplers ) ); + m_activeTexture = -1; + + m_texLocks.reserve( 16 ); + + // FIXME need a texture tracking table so we can reliably delete CGLMTex objects at context teardown + + m_boundReadFBO = NULL; + m_boundDrawFBO = NULL; + m_drawingFBO = NULL; + + memset( m_boundProgram, 0, sizeof(m_boundProgram) ); + memset( m_drawingProgram, 0, sizeof(m_boundProgram) ); + memset( m_programParamsF , 0, sizeof (m_programParamsF) ); + memset( m_programParamsB , 0, sizeof (m_programParamsB) ); + memset( m_programParamsI , 0, sizeof (m_programParamsI) ); + + m_paramWriteMode = eParamWriteDirtySlotRange; // default to fastest mode + /* + if (CommandLine()->FindParm("-glmwriteallslots")) m_paramWriteMode = eParamWriteAllSlots; + if (CommandLine()->FindParm("-glmwriteshaderslots")) m_paramWriteMode = eParamWriteShaderSlots; + if (CommandLine()->FindParm("-glmwriteshaderslotsoptional")) m_paramWriteMode = eParamWriteShaderSlotsOptional; + if (CommandLine()->FindParm("-glmwritedirtyslotrange")) m_paramWriteMode = eParamWriteDirtySlotRange; + */ + + m_attribWriteMode = eAttribWriteDirty; + + /* + if (CommandLine()->FindParm("-glmwriteallattribs")) m_attribWriteMode = eAttribWriteAll; + if (CommandLine()->FindParm("-glmwritedirtyattribs")) m_attribWriteMode = eAttribWriteDirty; + */ + + m_pairCache = new CGLMShaderPairCache( this ); + m_boundPair = NULL; + m_boundPairRevision = 0xFFFFFFFF; + m_boundPairProgram = (GLhandleARB)0xFFFFFFFF; // GLSL only + + memset( m_lastKnownBufferBinds, 0, sizeof(m_lastKnownBufferBinds) ); + memset( m_lastKnownVertexAttribs, 0, sizeof(m_lastKnownVertexAttribs) ); + m_lastKnownVertexAttribMask = 0; + + // make a null program for use when client asks for NULL FP + m_nullFragmentProgram = this->NewProgram(kGLMFragmentProgram, g_nullFragmentProgramText ); + + // make dummy programs for doing texture preload via dummy draw + m_preloadTexVertexProgram = this->NewProgram(kGLMVertexProgram, g_preloadTexVertexProgramText ); + m_preload2DTexFragmentProgram = this->NewProgram(kGLMFragmentProgram, g_preload2DTexFragmentProgramText ); + m_preload3DTexFragmentProgram = this->NewProgram(kGLMFragmentProgram, g_preload3DTexFragmentProgramText ); + m_preloadCubeTexFragmentProgram = this->NewProgram(kGLMFragmentProgram, g_preloadCubeTexFragmentProgramText ); + + m_drawIndexBuffer = NULL; + + //memset( &m_drawVertexSetup, 0, sizeof(m_drawVertexSetup) ); + SetVertexAttributes( NULL ); // will set up all the entries in m_drawVertexSetup + + m_debugFontTex = NULL; + + // debug state + m_debugFrameIndex = -1; + m_debugBatchIndex = -1; + +#if GLMDEBUG + // ####################################################################################### + + // DebugHook state - we could set these to more interesting values in response to a CLI arg like "startpaused" or something if desired + //m_paused = false; + m_holdFrameBegin = -1; + m_holdFrameEnd = -1; + m_holdBatch = m_holdBatchFrame = -1; + + m_debugDelayEnable = false; + m_debugDelay = 1<<19; // ~0.5 sec delay + + m_autoClearColor = m_autoClearDepth = m_autoClearStencil = false; + m_autoClearColorValues[0] = 0.0; //red + m_autoClearColorValues[1] = 1.0; //green + m_autoClearColorValues[2] = 0.0; //blue + m_autoClearColorValues[3] = 1.0; //alpha + + m_selKnobIndex = 0; + m_selKnobMinValue = -10.0f; + m_selKnobMaxValue = 10.0f; + m_selKnobIncrement = 1/256.0f; + + // ####################################################################################### +#endif + + // make two scratch FBO's for blit purposes + m_blitReadFBO = this->NewFBO(); + m_blitDrawFBO = this->NewFBO(); + + for( int i=0; iNewFBO(); + } + + bool new_mtgl = m_caps.m_hasPerfPackage1; // i.e. 10.6.4 plus new driver + + /* + if ( CommandLine()->FindParm("-glmenablemtgl2") ) + { + new_mtgl = true; + } + + if ( CommandLine()->FindParm("-glmdisablemtgl2") ) + { + new_mtgl = false; + } + */ + + bool mtgl_on = params->m_mtgl; + /* + if (CommandLine()->FindParm("-glmenablemtgl")) + { + mtgl_on = true; + } + + if (CommandLine()->FindParm("-glmdisablemtgl")) + { + mtgl_on = false; + } + */ + + CGLError result = (CGLError)0; + if (mtgl_on) + { + bool ready = false; + + if (new_mtgl) + { + // afterburner + CGLContextEnable kCGLCPGCDMPEngine = ((CGLContextEnable)1314); + result = CGLEnable( m_ctx, kCGLCPGCDMPEngine ); + if (!result) + { + ready = true; // succeeded - no need to try non-MTGL + printf("\nMTGL detected.\n"); + } + else + { + printf("\nMTGL *not* detected, falling back.\n"); + } + } + + if (!ready) + { + // try old MTGL + result = CGLEnable( m_ctx, kCGLCEMPEngine ); + if (!result) + { + printf("\nMTGL has been detected.\n"); + ready = true; // succeeded - no need to try non-MTGL + } + } + } + + // also, set the remote convar "gl_can_query_fast" to 1 if perf package present, else 0. + gl_can_query_fast = m_caps.m_hasPerfPackage1?1:0; //.SetValue( m_caps.m_hasPerfPackage1?1:0 ); + + GLMCheckError(); +#endif +} + +GLMContext::~GLMContext () +{ + // a lot of stuff that needs to be freed / destroyed + + if (m_debugFontTex) + { + this->DelTex( m_debugFontTex ); + m_debugFontTex = NULL; + } + + if ( m_nullFragmentProgram ) + { + this->DelProgram( m_nullFragmentProgram ); + m_nullFragmentProgram = NULL; + } + + // walk m_fboTable and free them up.. + for( std::vector< CGLMFBO * >::iterator p = m_fboTable.begin(); p != m_fboTable.end(); p++ ) + { + CGLMFBO *fbo = *p; + this->DelFBO( fbo ); + } + m_fboTable.clear(); + + if (m_pairCache) + { + delete m_pairCache; + m_pairCache = NULL; + } + + // we need a m_texTable I think.. + + // m_texLayoutTable can be scrubbed once we know that all the tex are freed + + if (m_nsctx && (!m_oneCtxEnable) ) + { + DelNSGLContext( m_nsctx ); + m_nsctx = NULL; + m_ctx = NULL; + } +} + + + +void GLMContext::SelectTMU( int tmu ) +{ + //GLM_FUNC; + + CheckCurrent(); + if (tmu != m_activeTexture) + { + glActiveTexture( GL_TEXTURE0+tmu ); + GLMCheckError(); + + m_activeTexture = tmu; + } +} + +int GLMContext::BindTexToTMU( CGLMTex *tex, int tmu, bool noCheck ) +{ + GLM_FUNC; + GLMPRINTF(("--- GLMContext::BindTexToTMU tex %p GL name %d -> TMU %d ", tex, tex ? tex->m_texName : -1, tmu )); + + CheckCurrent(); + + #if GLMDEBUG + if ( tex && tex->m_debugLabel && (!strcmp( tex->m_debugLabel, "error" ) ) ) + { + static char stop_here = 0; + if (stop_here) + { + stop_here = 1; + } + } + #endif + + if (tex && (tex->m_layout->m_key.m_texFlags & kGLMTexMultisampled) ) + { + if (tex->m_rboDirty) + { + // the texture must be a multisampled render target which has been targeted recently for drawing. + // check that it's not still attached... + Assert( tex->m_rtAttachCount==0 ); + + // let it resolve the MSAA RBO back to the texture + ResolveTex( tex ); + } + } + + SelectTMU( tmu ); + + // if another texture was previously bound there, mark it not bound now + // this should not be skipped + + if (m_samplers[tmu].m_boundTex) + { + m_samplers[tmu].m_boundTex->m_bindPoints &= ~(1<m_layout->m_key.m_texGLTarget, m_samplers[tmu].m_boundTex->m_texName ); + //} + + // note m_samplers[tmu].m_boundTex is now stale but we will step on it shortly + } + + // if texture chosen is different, or if noCheck is set, do the bind + if (tex) + { + // bind new tex and mark it + if ((tex != m_samplers[tmu].m_boundTex) || noCheck) + { + // if not being forced, we should see if the bind point (target) of the departing tex is different. + if (!noCheck) + { + if ( (m_samplers[tmu].m_boundTex) ) + { + // there is an outgoing tex. + // same target? + if ( m_samplers[tmu].m_boundTex->m_layout->m_key.m_texGLTarget != tex->m_layout->m_key.m_texGLTarget ) + { + // no, different target. inbound tex will be set below. Here, just clear the different target of the outbound tex. + glBindTexture( m_samplers[tmu].m_boundTex->m_layout->m_key.m_texGLTarget, 0 ); + } + else + { + // same target, new tex, no work to do. + } + } + } + else + { + // mega scrub + glBindTexture( GL_TEXTURE_1D, 0 ); + glBindTexture( GL_TEXTURE_2D, 0 ); + glBindTexture( GL_TEXTURE_3D, 0 ); + glBindTexture( GL_TEXTURE_CUBE_MAP, 0 ); + } + + glBindTexture( tex->m_layout->m_key.m_texGLTarget, tex->m_texName ); + GLMCheckError(); + } + tex->m_bindPoints |= (1<m_layout->m_key.m_texGLTarget, 0 ); + GLMCheckError(); + } + else + { + // none was bound before, so no action + } + m_samplers[tmu].m_boundTex = NULL; + } + + return 0; +} + +void GLMContext::BindFBOToCtx( CGLMFBO *fbo, GLenum bindPoint ) +{ + GLM_FUNC; + GLMPRINTF(( "--- GLMContext::BindFBOToCtx fbo %p, GL name %d", fbo, (fbo) ? fbo->m_name : -1 )); + + CheckCurrent(); + + bool targetRead = (bindPoint==GL_READ_FRAMEBUFFER_EXT) || (bindPoint==GL_FRAMEBUFFER_EXT); + bool targetDraw = (bindPoint==GL_DRAW_FRAMEBUFFER_EXT) || (bindPoint==GL_FRAMEBUFFER_EXT); + + if (targetRead) + { + if (fbo) // you can pass NULL to go back to no-FBO + { + glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, fbo->m_name ); + GLMCheckError(); + + m_boundReadFBO = fbo; + //dontcare fbo->m_bound = true; + } + else + { + glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, 0 ); + GLMCheckError(); + + m_boundReadFBO = NULL; + } + } + + if (targetDraw) + { + if (fbo) // you can pass NULL to go back to no-FBO + { + glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, fbo->m_name ); + GLMCheckError(); + + m_boundDrawFBO = fbo; + //dontcare fbo->m_bound = true; + } + else + { + glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, 0 ); + GLMCheckError(); + + m_boundDrawFBO = NULL; + } + } +} + +void GLMContext::BindBufferToCtx( EGLMBufferType type, CGLMBuffer *buff, bool force ) +{ + GLM_FUNC; + GLMPRINTF(( "--- GLMContext::BindBufferToCtx buff %p, GL name %d", buff, (buff) ? buff->m_name : -1 )); + + CheckCurrent(); + + if (!force) + { + // compare desired bind to last known bind, and see if we can bail + if (m_lastKnownBufferBinds[ type ] == buff) + { + return; + } + } + + GLenum target=0; + switch( type ) + { + case kGLMVertexBuffer: target = GL_ARRAY_BUFFER_ARB; break; + case kGLMIndexBuffer: target = GL_ELEMENT_ARRAY_BUFFER_ARB; break; + case kGLMUniformBuffer: target = GL_UNIFORM_BUFFER_EXT; break; + case kGLMPixelBuffer: target = GL_PIXEL_UNPACK_BUFFER_ARB; break; + + default: Assert(!"Unknown buffer type" ); + } + + bool wasBound = false; + bool isBound = false; + + if (m_lastKnownBufferBinds[type]) + { + m_lastKnownBufferBinds[type]->m_bound = false; + m_lastKnownBufferBinds[type] = NULL; + wasBound = true; + } + + if (buff) + { + if (buff->m_buffGLTarget != target) + Debugger(); + + glBindBufferARB( buff->m_buffGLTarget, buff->m_name ); + GLMCheckError(); + + m_lastKnownBufferBinds[ type ] = buff; + buff->m_bound = true; + + isBound = true; + } + else + { + // isBound stays false + // bind name 0 + // note that no buffer is bound in the ctx state + + glBindBufferARB( target, 0 ); + GLMCheckError(); + + m_lastKnownBufferBinds[ type ] = NULL; + } +} + +//ConVar gl_can_mix_shader_gammas( "gl_can_mix_shader_gammas", 0 ); +int gl_can_mix_shader_gammas = 0; + +//ConVar gl_cannot_mix_shader_gammas( "gl_cannot_mix_shader_gammas", 0 ); +int gl_cannot_mix_shader_gammas = 0; + +void GLMContext::FlushDrawStates( bool shadersOn ) // shadersOn = true for draw calls, false for clear calls +{ + GLM_FUNC; + + CheckCurrent(); + + // FBO + if ( (m_drawingFBO != m_boundDrawFBO) || (m_drawingFBO != m_boundReadFBO) ) + { + //GLMPRINTF(("\nGLMContext::FlushDrawStates, setting FBO to %8x(gl %d), was %8x(gl %d)", m_drawingFBO, (m_drawingFBO? m_drawingFBO->m_name: -1),m_boundFBO, (m_boundFBO ? m_boundFBO->m_name : -1) )); + this->BindFBOToCtx( m_drawingFBO, GL_READ_FRAMEBUFFER_EXT ); + this->BindFBOToCtx( m_drawingFBO, GL_DRAW_FRAMEBUFFER_EXT ); + } + + // if drawing FBO has any MSAA attachments, mark them dirty + { + CGLMTex *tex; + for( int att=kAttColor0; attm_attach[ att ].m_tex) + { + CGLMTex *tex = m_drawingFBO->m_attach[ att ].m_tex; + + if (tex->m_rboName) // is it MSAA + { + // mark it dirty + tex->m_rboDirty = true; + } + } + } + } + + // renderstates + this->FlushStates(); // latched renderstates.. + + // if there is no color target - bail out + // OK, this doesn't work in general - you can't leave the color target floating(null) or you will get FBO errors + //if (!m_boundDrawFBO[0].m_attach[0].m_tex) + //{ + // GLMPRINTF(("-D- GLMContext::FlushDrawStates -> no color target! exiting.. " )); + // return; + //} + + bool tex0_srgb = (m_boundDrawFBO[0].m_attach[0].m_tex->m_layout->m_key.m_texFlags & kGLMTexSRGB) != 0; + + // you can only actually use the sRGB FB state on some systems.. check caps + if (m_caps.m_hasGammaWrites) + { + GLBlendEnableSRGB_t writeSRGBState; + m_BlendEnableSRGB.Read( &writeSRGBState, 0 ); // the client set value, not the API-written value yet.. + bool draw_srgb = writeSRGBState.enable; + + if (draw_srgb) + { + if (tex0_srgb) + { + // good - draw mode and color tex agree + } + else + { + // bad + + // Client has asked to write sRGB into a texture that can't do it. + // there is no way to satisfy this unless we change the RT tex and we avoid doing that. + // (although we might consider a ** ONE TIME ** promotion. + // this shouldn't be a big deal if the tex format is one where it doesn't matter like 32F. + + GLMPRINTF(("-Z- srgb-enabled FBO conflict: attached tex %08x [%s] is not SRGB", m_boundDrawFBO[0].m_attach[0].m_tex, m_boundDrawFBO[0].m_attach[0].m_tex->m_layout->m_layoutSummary )); + + // do we shoot down the srgb-write state for this batch? + // I think the runtime will just ignore it. + } + } + else + { + if (tex0_srgb) + { + // odd - client is not writing sRGB into a texture which *can* do it. + //GLMPRINTF(( "-Z- srgb-disabled FBO conflict: attached tex %08x [%s] is SRGB", m_boundFBO[0].m_attach[0].m_tex, m_boundFBO[0].m_attach[0].m_tex->m_layout->m_layoutSummary )); + //writeSRGBState.enable = true; + //m_BlendEnableSRGB.Write( &writeSRGBState ); + } + else + { + // good - draw mode and color tex agree + } + } + + // now go ahead and flush the SRGB write state for real + // set the noDefer on it too + m_BlendEnableSRGB.Flush( /*true*/ ); + } + // else... FlushDrawStates will work it out via flSRGBWrite in the fragment shader.. + + // textures and sampling + // note we generate a mask of which samplers are running "decode sRGB" mode, to help out the shader pair cache mechanism below. + uint srgbMask = 0; + for( int i=0; im_boundTex != samp->m_drawTex) + { + this->BindTexToTMU( samp->m_drawTex, i ); + samp->m_boundTex = samp->m_drawTex; + } + + // push sampling params? it will check each one individually. + if (samp->m_boundTex) + { + samp->m_boundTex->ApplySamplingParams( &samp->m_samp ); + } + + if (samp->m_samp.m_srgb) + { + srgbMask |= (1<m_descs[ kGLMARB ].m_valid) + { + glSetEnable( GL_VERTEX_PROGRAM_ARB, true ); + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vp->m_descs[ kGLMARB ].m_object.arb); + GLMCheckError(); + + m_boundProgram[ kGLMVertexProgram ] = vp; + vpgood = true; + } + else + { + //Assert( !"Trying to draw with invalid ARB vertex program" ); + } + } + else + { + //Assert( !"Trying to draw with NULL ARB vertex program" ); + } + } + + // fragment side + { + CGLMProgram *fp = m_drawingProgram[ kGLMFragmentProgram ]; + if (fp) + { + if (fp->m_descs[ kGLMARB ].m_valid) + { + glSetEnable( GL_FRAGMENT_PROGRAM_ARB, true ); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fp->m_descs[ kGLMARB ].m_object.arb); + GLMCheckError(); + + m_boundProgram[ kGLMFragmentProgram ] = fp; + fpgood = true; + } + else + { + //Assert( !"Trying to draw with invalid ARB fragment program" ); + m_boundProgram[ kGLMFragmentProgram ] = NULL; + } + } + else + { + // this is actually OK, we substitute a dummy shader + glSetEnable( GL_FRAGMENT_PROGRAM_ARB, true ); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_nullFragmentProgram->m_descs[kGLMARB].m_object.arb ); + m_boundProgram[ kGLMFragmentProgram ] = m_nullFragmentProgram; + fpgood = true; + } + } + + if (fpgood & vpgood) + { + // flush parameter values to both stages + // FIXME: this can be optimized by dirty range, since ARB supports single-parameter-bank aka .env + // FIXME: magic numbers, yuk + + glProgramEnvParameters4fvEXT( GL_VERTEX_PROGRAM_ARB, 0, 256, (const GLfloat*)&m_programParamsF[kGLMVertexProgram].m_values[0][0] ); + GLMCheckError(); + + glProgramEnvParameters4fvEXT( GL_FRAGMENT_PROGRAM_ARB, 0, 32, (const GLfloat*)&m_programParamsF[kGLMFragmentProgram].m_values[0][0] ); + GLMCheckError(); + } + else + { + // silence all (clears wind up here for example) + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0 ); + glSetEnable( GL_VERTEX_PROGRAM_ARB, false ); + m_boundProgram[ kGLMVertexProgram ] = NULL; + + glSetEnable( GL_FRAGMENT_PROGRAM_ARB, false ); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0 ); + m_boundProgram[ kGLMFragmentProgram ] = NULL; + } +/////////////////////////////////// + + // ARB vert setup. maybe generalize this to handle both ARB and GLSL after we see what GLSL attrib setup looks like. + + //http://www.opengl.org/sdk/docs/man/xhtml/glVertexAttribPointer.xml + //http://www.opengl.org/sdk/docs/man/xhtml/glEnableVertexAttribArray.xml + + // for (each attrib) + // if (enable unchanged and off) -> do nothing + // if (enable changed to off) -> disable that array ... set the attrib pointer to nil for clarity + // if (enable changed to on) -> bind the appropriate vertex buffer, set that attrib, log it + // if (enable unchanged and on) -> diff the attrib setup, re-bind if needed, log it + + GLMVertexSetup *setup = &m_drawVertexSetup; + uint relevantMask = setup->m_attrMask; + + for( int index=0; index < kGLMVertexAttributeIndexMax; index++ ) + { + uint mask = 1<m_attrs[index]; // ptr to desired setup + CGLMBuffer * buf = setdesc->m_buffer; // bind buffer + Assert( buf ); + + BindBufferToCtx( kGLMVertexBuffer, buf ); + + glEnableVertexAttribArray( index ); // enable attribute, set pointer. + GLMCheckError(); + + glVertexAttribPointer( index, setdesc->m_datasize, setdesc->m_datatype, setdesc->m_normalized, setdesc->m_stride, ( const GLvoid *)setdesc->m_offset ); + GLMCheckError(); + //GLMPRINTF(("--- GLMContext::SetVertexAttributes attr %d set to offset/stride %d/%d in buffer %d (normalized=%s)", index, setdesc->m_offset, setdesc->m_stride, setdesc->m_buffer->m_name, setdesc->m_normalized?"true":"false" )); + } + else + { + // disable attribute + glDisableVertexAttribArray( index ); + GLMCheckError(); + //GLMPRINTF((" -- GLMContext::SetVertexAttributes attr %d is disabled", index )); + + // tidy up in case there was garbage? necessary ? + memset ( &setup->m_attrs[index], 0, sizeof(setup->m_attrs[index]) ); + } + } + +/////////////////////////////////// + } + break; + + case kGLMGLSL: + { + // early out if one of the stages is not set. + // draw code needs to watch for this too. + if ( (m_drawingProgram[ kGLMVertexProgram ]==NULL) || (m_drawingProgram[ kGLMFragmentProgram ]==NULL) ) + { + this->NullProgram(); + return; + } + + // examine selected drawing programs for both stages + // try to find a match in thelinked-pair-cache + // if no match, link one + // examine metadata + // get uniform locations for parameters, attributes, and samplers + // put in cache + + // dispatch vertex attribute locations to shader (could be one-time) + // dispatch parameter values to both stages (could be optimized with UBO) + // dispatch sampler locations to shader (need sampler metadata) + + // new way - use the pair cache + + // cook up some extra bits so that we can track different srgb-usages of the same vp/fp pair. + // note that this is only important on some hardware/OS combos. + // let the pair cache decide if it needs to honor the extra key bits or not. + + + // decide if we need to mix extra bits into the lookup key. + bool useExtraKeyBits = m_caps.m_costlyGammaFlips; + + // the "can" variable is allowed to override the static assessment. + if ( gl_can_mix_shader_gammas/*.GetInt()*/ ) + { + useExtraKeyBits = false; + } + + // the "cannot" variable is allowed to override the first two + if ( gl_cannot_mix_shader_gammas/*.GetInt()*/ ) + { + useExtraKeyBits = true; + } + + uint extraKeyBits = 0; + + if (useExtraKeyBits) + { + extraKeyBits = (srgbMask & m_drawingProgram[ kGLMFragmentProgram ]->m_samplerMask); + } + + CGLMShaderPair *newPair = m_pairCache->SelectShaderPair( m_drawingProgram[ kGLMVertexProgram ], m_drawingProgram[ kGLMFragmentProgram ], extraKeyBits ); + GLhandleARB newPairProgram = newPair->m_program; + uint newPairRevision = newPair->m_revision; + + // you cannot only key on the pair address, since pairs get evicted and pair records likely get recycled. + // so key on all three - pair address, program name, revision number + // this will also catch cases where a pair is re-linked (batch debugger / live edit) + + if ( (newPair != m_boundPair) || (newPairProgram != m_boundPairProgram) || (newPairRevision != m_boundPairRevision) ) + { + m_boundPair = newPair; + m_boundPairProgram = newPairProgram; + m_boundPairRevision = newPairRevision; + + glUseProgram( (uintptr_t)newPairProgram ); + GLMCheckError(); + + // set the dirty levels appropriately since the program changed and has never seen any of the current values. + m_programParamsF[kGLMVertexProgram].m_dirtySlotCount = m_drawingProgram[ kGLMVertexProgram ]->m_descs[kGLMGLSL].m_highWater+1; + m_programParamsF[kGLMFragmentProgram].m_dirtySlotCount = m_drawingProgram[ kGLMFragmentProgram ]->m_descs[kGLMGLSL].m_highWater+1; + + // bool and int dirty levels get set to max, we don't have actual high water marks for them + // code which sends the values must clamp on these types. + m_programParamsB[kGLMVertexProgram].m_dirtySlotCount = kGLMProgramParamBoolLimit; + m_programParamsB[kGLMFragmentProgram].m_dirtySlotCount = 0; + + m_programParamsI[kGLMVertexProgram].m_dirtySlotCount = kGLMProgramParamInt4Limit; + m_programParamsI[kGLMFragmentProgram].m_dirtySlotCount = 0; + } + + // note the binding (not really bound.. just sitting in the linked active GLSL program) + m_boundProgram[ kGLMVertexProgram ] = m_drawingProgram[ kGLMVertexProgram ]; + m_boundProgram[ kGLMFragmentProgram ] = m_drawingProgram[ kGLMFragmentProgram ]; + + // now pave the way for drawing + + // parameters - find and set + + // vertex stage -------------------------------------------------------------------- + // find "vc" in VS + GLint vconstLoc = m_boundPair->m_locVertexParams; + if (vconstLoc >=0) + { + #if GLMDEBUG + static uint paramsPushed=0,paramsSkipped=0,callsPushed=0; // things that happened on pushed param trips + static uint callsSkipped=0,paramsSkippedByCallSkip=0; // on unpushed param trips (zero dirty) + #endif + + int slotCountToPush = 0; + int shaderSlots = m_boundPair->m_vertexProg->m_descs[kGLMGLSL].m_highWater+1; + int dirtySlots = m_programParamsF[kGLMVertexProgram].m_dirtySlotCount; + + + switch( m_paramWriteMode ) + { + case eParamWriteAllSlots: slotCountToPush = kGLMVertexProgramParamFloat4Limit; break; + case eParamWriteShaderSlots: slotCountToPush = shaderSlots; break; + + case eParamWriteShaderSlotsOptional: + { + slotCountToPush = shaderSlots; + + // ...unless, we're actually unchanged since last draw + if (dirtySlots == 0) + { + // write none + slotCountToPush = 0; + } + } + break; + + case eParamWriteDirtySlotRange: slotCountToPush = dirtySlots; break; + } + + if (slotCountToPush) + { + glUniform4fv( vconstLoc, slotCountToPush, &m_programParamsF[kGLMVertexProgram].m_values[0][0] ); + GLMCheckError(); + + #if GLMDEBUG + paramsPushed += slotCountToPush; + paramsSkipped += shaderSlots - slotCountToPush; + + callsPushed++; + #endif + } + else + { + #if GLMDEBUG + paramsSkippedByCallSkip += shaderSlots; + + callsSkipped++; + #endif + } + + #if GLMDEBUG && 0 + if (GLMKnob("caps-key",NULL) > 0.0) + { + // spew + GLMPRINTF(("VP callsPushed=%d ( paramsPushed=%d paramsSkipped=%d ) callsSkipped=%d (paramsSkippedByCallSkip=%d)", + callsPushed, paramsPushed, paramsSkipped, callsSkipped, paramsSkippedByCallSkip + )); + } + #endif + + m_programParamsF[kGLMVertexProgram].m_dirtySlotCount = 0; //ack + } + + // see if VS uses i0, b0, b1, b2, b3. + // use a glUniform1i to set any one of these if active. skip all of them if no dirties reported. + // my kingdom for the UBO extension! + + // ------- bools ---------- // + if ( 1 /*m_programParamsB[kGLMVertexProgram].m_dirtySlotCount*/ ) // optimize this later after the float param pushes are proven out + { + GLint vconstBool0Loc = m_boundPair->m_locVertexBool0; //glGetUniformLocationARB( prog, "b0"); + if ( vconstBool0Loc >= 0 ) + { + glUniform1i( vconstBool0Loc, m_programParamsB[kGLMVertexProgram].m_values[0] ); //FIXME magic number + GLMCheckError(); + } + + GLint vconstBool1Loc = m_boundPair->m_locVertexBool1; //glGetUniformLocationARB( prog, "b1"); + if ( vconstBool1Loc >= 0 ) + { + glUniform1i( vconstBool1Loc, m_programParamsB[kGLMVertexProgram].m_values[1] ); //FIXME magic number + GLMCheckError(); + } + + GLint vconstBool2Loc = m_boundPair->m_locVertexBool2; //glGetUniformLocationARB( prog, "b2"); + if ( vconstBool2Loc >= 0 ) + { + glUniform1i( vconstBool2Loc, m_programParamsB[kGLMVertexProgram].m_values[2] ); //FIXME magic number + GLMCheckError(); + } + + GLint vconstBool3Loc = m_boundPair->m_locVertexBool3; //glGetUniformLocationARB( prog, "b3"); + if ( vconstBool3Loc >= 0 ) + { + glUniform1i( vconstBool3Loc, m_programParamsB[kGLMVertexProgram].m_values[3] ); //FIXME magic number + GLMCheckError(); + } + m_programParamsB[kGLMVertexProgram].m_dirtySlotCount = 0; //ack + } + + // ------- int ---------- // + if ( 1 /*m_programParamsI[kGLMVertexProgram].m_dirtySlotCount*/ ) // optimize this later after the float param pushes are proven out + { + GLint vconstInt0Loc = m_boundPair->m_locVertexInteger0; //glGetUniformLocationARB( prog, "i0"); + if ( vconstInt0Loc >= 0 ) + { + glUniform1i( vconstInt0Loc, m_programParamsI[kGLMVertexProgram].m_values[0][0] ); //FIXME magic number + GLMCheckError(); + } + m_programParamsI[kGLMVertexProgram].m_dirtySlotCount = 0; //ack + } + + + // attribs - find and set + // GLSL vert setup - clone/edit of ARB setup. try to re-unify these later. + + GLMVertexSetup *setup = &m_drawVertexSetup; + uint relevantMask = setup->m_attrMask; + + //static char *attribnames[] = { "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15" }; + + CGLMBuffer *loopCurrentBuf = NULL; // local shock absorber for this loop + for( int index=0; index < kGLMVertexAttributeIndexMax; index++ ) + { + uint mask = 1<m_attrs[index]; // ptr to desired setup + + bool writeAttrib = false; + + switch(m_attribWriteMode) + { + case eAttribWriteAll: + writeAttrib = true; + break; + + case eAttribWriteDirty: + static uint hits=0,misses=0; + // first see if we have to do anything at all. + // the equality operator checks buffer name, offset, stride, datatype and normalized. + // we check buffer revision separately, submitter of vertex setup is not expected to provide it (zero is preferred). + // consult the actual buffer directly. + + // note also, we're only doing thi compare when attrib #index is active for this batch. + // previously-active attribs which are becoming disabled need not be checked.. + + GLMVertexAttributeDesc *lastDesc = &m_lastKnownVertexAttribs[index]; + if ( (!(*newDesc == *lastDesc)) || (newDesc->m_buffer->m_revision != lastDesc->m_bufferRevision) ) + { + *lastDesc = *newDesc; // latch new setup + lastDesc->m_bufferRevision = newDesc->m_buffer->m_revision; // including proper revision of the sourcing buffer + + writeAttrib = true; + misses++; + } + else + { + hits++; + } + + #if 0 + if ( ((hits+misses) % 10000)==0) + { + printf("\n** attrib setup hits %d misses %d",hits,misses); + } + #endif + break; + } + + if( writeAttrib ) + { + CGLMBuffer * buf = newDesc->m_buffer; // bind buffer + Assert( buf ); + + if (buf != loopCurrentBuf) + { + BindBufferToCtx( kGLMVertexBuffer, buf ); // (if not already on the bind point of interest) + GLMCheckError(); + + loopCurrentBuf = buf; + } + + glVertexAttribPointer( index, newDesc->m_datasize, newDesc->m_datatype, newDesc->m_normalized, newDesc->m_stride, ( const GLvoid *)newDesc->m_offset ); + GLMCheckError(); + } + + // enable is checked separately from the attrib binding + if (! (m_lastKnownVertexAttribMask & (1<m_locFragmentParams; + if (fconstLoc >=0) + { + #if GLMDEBUG + static uint paramsPushed=0,paramsSkipped=0,callsPushed=0; // things that happened on pushed param trips + static uint callsSkipped=0,paramsSkippedByCallSkip=0; // on unpushed param trips (zero dirty) + #endif + + int slotCountToPush = 0; + int shaderSlots = m_boundPair->m_fragmentProg->m_descs[kGLMGLSL].m_highWater+1; + int dirtySlots = m_programParamsF[kGLMFragmentProgram].m_dirtySlotCount; + + switch( m_paramWriteMode ) + { + case eParamWriteAllSlots: slotCountToPush = kGLMFragmentProgramParamFloat4Limit; break; + case eParamWriteShaderSlots: slotCountToPush = shaderSlots; break; + + case eParamWriteShaderSlotsOptional: + { + slotCountToPush = shaderSlots; + + // ...unless, we're actually unchanged since last draw + if (dirtySlots == 0) + { + // write none + slotCountToPush = 0; + } + } + break; + + case eParamWriteDirtySlotRange: slotCountToPush = dirtySlots; break; + } + + if (slotCountToPush) + { + glUniform4fv( fconstLoc, slotCountToPush, &m_programParamsF[kGLMFragmentProgram].m_values[0][0] ); + GLMCheckError(); + + #if GLMDEBUG + paramsPushed += slotCountToPush; + paramsSkipped += shaderSlots - slotCountToPush; + + callsPushed++; + #endif + } + else + { + #if GLMDEBUG + paramsSkippedByCallSkip += shaderSlots; + + callsSkipped++; + #endif + } + + #if GLMDEBUG && 0 + if ( 0 && (GLMKnob("caps-key",NULL) > 0.0) ) // turn on as needed + { + // spew + GLMPRINTF(("FP callsPushed=%d ( paramsPushed=%d paramsSkipped=%d ) callsSkipped=%d (paramsSkippedByCallSkip=%d)", + callsPushed, paramsPushed, paramsSkipped, callsSkipped, paramsSkippedByCallSkip + )); + } + #endif + + m_programParamsF[kGLMFragmentProgram].m_dirtySlotCount = 0; //ack + } + + // fake SRGB + if (!m_caps.m_hasGammaWrites) // do we need to think about fake SRGB? + { + if (m_boundPair->m_locFragmentFakeSRGBEnable >= 0) // does the shader have that uniform handy? + { + float desiredValue = m_FakeBlendEnableSRGB ? 1.0 : 0.0; // what should it be set to? + + if (desiredValue != m_boundPair->m_fakeSRGBEnableValue) // and is that different from what it is known to be set to ? + { + glUniform1f( m_boundPair->m_locFragmentFakeSRGBEnable, desiredValue ); // if so, write it + GLMCheckError(); + + m_boundPair->m_fakeSRGBEnableValue = desiredValue; // and recall that we did so + } + } + } + + //samplers + if (m_boundPair) + { + if(!m_boundPair->m_samplersFixed) + { + for( int sampler=0; sampler<16; sampler++) + { + if (m_boundPair->m_locSamplers[sampler] >=0) + { + glUniform1iARB( m_boundPair->m_locSamplers[sampler], sampler ); + GLMCheckError(); + } + } + m_boundPair->m_samplersFixed = true; + } + } + } + break; + } + } + else + { + this->NullProgram(); + } +} + + +#if GLMDEBUG + +enum EGLMDebugDumpOptions +{ + eDumpBatchInfo, + eDumpSurfaceInfo, + eDumpStackCrawl, + eDumpShaderLinks, +// eDumpShaderText, // we never use this one + eDumpShaderParameters, + eDumpTextureSetup, + eDumpVertexAttribSetup, + eDumpVertexData, + eOpenShadersForEdit +}; + +enum EGLMVertDumpMode +{ + // options that affect eDumpVertexData above + eDumpVertsNoTransformDump, + eDumpVertsTransformedByViewProj, + eDumpVertsTransformedByModelViewProj, + eDumpVertsTransformedByBoneZeroThenViewProj, + eDumpVertsTransformedByBonesThenViewProj, + eLastDumpVertsMode +}; + +const char *g_vertDumpModeNames[] = +{ + "noTransformDump", + "transformedByViewProj", + "transformedByModelViewProj", + "transformedByBoneZeroThenViewProj", + "transformedByBonesThenViewProj" +}; + +static void CopyTilEOL( char *dst, char *src, int dstSize ) +{ + dstSize--; + + int i=0; + while ( (im_caller==eDrawElements) || (info->m_caller==eDrawArrays) ); + const char *batchtype = is_draw ? "draw" : "clear"; + + if (options & (1<m_attach[i].m_tex; + if (tex) + { + GLMPRINTF(("-D- bound FBO (%8x) attachment %d = tex %8x (GL %d) (%s)", fbo, i, tex, tex->m_texName, tex->m_layout->m_layoutSummary )); + } + else + { + // warning if no depthstencil attachment + switch(i) + { + case kAttDepth: + case kAttStencil: + case kAttDepthStencil: + GLMPRINTF(("-D- bound FBO (%8x) attachment %d = NULL, warning!", fbo, i )); + break; + } + } + } + } + + #if 0 // disabled in steamworks sample for the time being + if (options & (1<GetStackCrawl(&cp); + + GLMPRINTF(("-D-" )); + GLMPRINTF(("-D- stack crawl")); + for( int i=0; i< cp.m_frameCount; i++) + { + GLMPRINTF(("-D-\t%s", cp.m_crawlNames[i] )); + } + } + #endif + + if ( (options & (1<m_text, "#//ATTRIBMAP"); + if (attribmap) + { + CopyTilEOL( attribtemp, attribmap, sizeof(attribtemp) ); + } + else + { + strcpy( attribtemp, "no attrib map" ); + } + + char *trans = strstr(vp->m_text, "#// trans#"); + if (trans) + { + CopyTilEOL( transtemp, trans, sizeof(transtemp) ); + } + else + { + strcpy( transtemp, "no translation info" ); + } + + const char *linkpath = "no file link"; + + #if GLMDEBUG && 0 // no editable shader support in example code + linkpath = vp->m_editable->m_mirror->m_path; + + GLMPRINTF(("-D-")); + GLMPRINTF(("-D- ARBVP || GL %d || Path %s ", vp->m_descs[kGLMARB].m_object.arb, linkpath )); + GLMPRINTF(("-D- Attribs %s", attribtemp )); + GLMPRINTF(("-D- Trans %s", transtemp )); + #endif + + /* + if ( (options & (1<m_string, eDebugDump )); + } + */ + } + else + { + GLMPRINTF(("-D- VP (none)" )); + } + + if (fp) + { + char *trans = strstr(fp->m_text, "#// trans#"); + if (trans) + { + CopyTilEOL( transtemp, trans, sizeof(transtemp) ); + } + else + { + strcpy( transtemp, "no translation info" ); + } + + const char *linkpath = "no file link"; + + #if GLMDEBUG && 0 // no editable shader support in example code + linkpath = fp->m_editable->m_mirror->m_path; + + GLMPRINTF(("-D-")); + GLMPRINTF(("-D- FP || GL %d || Path %s ", fp->m_descs[kGLMARB].m_object.arb, linkpath )); + GLMPRINTF(("-D- Trans %s", transtemp )); + #endif + + /* + if ( (options & (1<m_string, eDebugDump)); + } + */ + } + else + { + GLMPRINTF(("-D- FP (none)" )); + } + } + + if ( (options & (1<m_drawVertexSetup; + for( int index=0; index < kGLMVertexAttributeIndexMax; index++ ) + { + usesSkinning |= (setup->m_attrMask & (1<m_vtxAttribMap[index]>>4)== D3DDECLUSAGE_BLENDWEIGHT); + } + if (usesSkinning) + { + upperSlotLimit = 256; + } + + while( slotIndex < upperSlotLimit ) + { + // if slot index is in a masked range, skip it + // if slot index is the start of a matrix, label it, print it, skip ahead 4 slots + for( int maski=0; vmaskranges[maski] >=0; maski+=2) + { + if ( (slotIndex >= vmaskranges[maski]) && (slotIndex <= vmaskranges[maski+1]) ) + { + // that index is masked. set to one past end of range, print a blank line for clarity + slotIndex = vmaskranges[maski+1]+1; + GLMPrintStr("-D- ....."); + } + } + + if (slotIndex < upperSlotLimit) + { + float *values = &m_programParamsF[ kGLMVertexProgram ].m_values[slotIndex][0]; + + #if 0 // Source specific + switch( slotIndex ) + { + case 4: + printmat( "MODELVIEWPROJ", slotIndex, 4, values ); + slotIndex += 4; + break; + + case 8: + printmat( "VIEWPROJ", slotIndex, 4, values ); + slotIndex += 4; + break; + + default: + if (slotIndex>=58) + { + // bone + char bonelabel[100]; + + sprintf(bonelabel, "MODEL_BONE%-2d", (slotIndex-58)/3 ); + printmat( bonelabel, slotIndex, 3, values ); + + slotIndex += 3; + } + else + { + // just print the one slot + GLMPRINTF(("-D- %03d: [ %10.5f %10.5f %10.5f %10.5f ] %s", slotIndex, values[0], values[1], values[2], values[3], label )); + slotIndex++; + } + break; + } + #else + // just print the one slot + GLMPRINTF(("-D- %03d: [ %10.5f %10.5f %10.5f %10.5f ] %s", slotIndex, values[0], values[1], values[2], values[3], label )); + slotIndex++; + #endif + } + } + + // VP stage still, if in GLSL mode, find the bound pair and see if it has live i0, b0-b3 uniforms + if (m_boundPair) // should only be non-NULL in GLSL mode + { + if (m_boundPair->m_locVertexBool0>=0) + { + GLMPRINTF(("-D- GLSL 'b0': %d", m_programParamsB[kGLMVertexProgram].m_values[0] )); + } + + if (m_boundPair->m_locVertexBool1>=0) + { + GLMPRINTF(("-D- GLSL 'b1': %d", m_programParamsB[kGLMVertexProgram].m_values[1] )); + } + + if (m_boundPair->m_locVertexBool2>=0) + { + GLMPRINTF(("-D- GLSL 'b2': %d", m_programParamsB[kGLMVertexProgram].m_values[2] )); + } + + if (m_boundPair->m_locVertexBool3>=0) + { + GLMPRINTF(("-D- GLSL 'b3': %d", m_programParamsB[kGLMVertexProgram].m_values[3] )); + } + + if (m_boundPair->m_locVertexInteger0>=0) + { + GLMPRINTF(("-D- GLSL 'i0': %d", m_programParamsI[kGLMVertexProgram].m_values[0][0] )); + } + } + + GLMPRINTF(("-D-")); + GLMPRINTF(("-D- FP parameters " )); + + static int fmaskranges[] = { 40,41, -1,-1 }; + + slotIndex = 0; + label = ""; + while(slotIndex < 4) // reduced from 40 for example code + { + // if slot index is in a masked range, skip it + // if slot index is the start of a matrix, label it, print it, skip ahead 4 slots + for( int maski=0; fmaskranges[maski] >=0; maski+=2) + { + if ( (slotIndex >= fmaskranges[maski]) && (slotIndex <= fmaskranges[maski+1]) ) + { + // that index is masked. set to one past end of range, print a blank line for clarity + slotIndex = fmaskranges[maski+1]+1; + GLMPrintStr("-D- ....."); + } + } + + if (slotIndex < 40) + { + float *values = &m_programParamsF[ kGLMFragmentProgram ].m_values[slotIndex][0]; + #if 0 //Source specific + switch( slotIndex ) + { + case 0: label = "g_EnvmapTint"; break; + case 1: label = "g_DiffuseModulation"; break; + case 2: label = "g_EnvmapContrast_ShadowTweaks"; break; + case 3: label = "g_EnvmapSaturation_SelfIllumMask (xyz, and w)"; break; + case 4: label = "g_SelfIllumTint_and_BlendFactor (xyz, and w)"; break; + + case 12: label = "g_ShaderControls"; break; + case 13: label = "g_DepthFeatheringConstants"; break; + + case 20: label = "g_EyePos"; break; + case 21: label = "g_FogParams"; break; + case 22: label = "g_FlashlightAttenuationFactors"; break; + case 23: label = "g_FlashlightPos"; break; + case 24: label = "g_FlashlightWorldToTexture"; break; + + case 28: label = "cFlashlightColor"; break; + case 29: label = "g_LinearFogColor"; break; + case 30: label = "cLightScale"; break; + case 31: label = "cFlashlightScreenScale"; break; + + default: + label = ""; + break; + } + #else + label = ""; + #endif + GLMPRINTF(("-D- %03d: [ %10.5f %10.5f %10.5f %10.5f ] %s", slotIndex, values[0], values[1], values[2], values[3], label )); + + slotIndex ++; + } + } + + //if (m_boundPair->m_locFragmentFakeSRGBEnable) + //{ + // GLMPRINTF(("-D- GLSL 'flEnableSRGBWrite': %f", m_boundPair->m_fakeSRGBEnableValue )); + //} + } + + if ( (options & (1<m_layout->m_layoutSummary )); + + GLMPRINTF(("-D- addressMode[ %s %s %s ]", + GLMDecode( eGL_ENUM, samp->m_addressModes[0] ), + GLMDecode( eGL_ENUM, samp->m_addressModes[1] ), + GLMDecode( eGL_ENUM, samp->m_addressModes[2] ) + )); + + GLMPRINTF(("-D- magFilter [ %s ]", GLMDecode( eGL_ENUM, samp->m_magFilter ) )); + GLMPRINTF(("-D- minFilter [ %s ]", GLMDecode( eGL_ENUM, samp->m_minFilter ) )); + GLMPRINTF(("-D- srgb [ %s ]", samp->m_srgb ? "T" : "F" )); + + // add more as needed later.. + } + } + } + + if ( (options & (1<m_drawVertexSetup; + + uint relevantMask = setup->m_attrMask; + for( int index=0; index < kGLMVertexAttributeIndexMax; index++ ) + { + uint mask = 1<m_attrs[index]; + + char sizestr[100]; + if (setdesc->m_datasize < 32) + { + sprintf( sizestr, "%d", setdesc->m_datasize); + } + else + { + strcpy( sizestr, GLMDecode( eGL_ENUM, setdesc->m_datasize ) ); + } + + if (setup->m_vtxAttribMap[index] != 0xBB) + { + GLMPRINTF(("-D- attr=%-2d decl=$%s%1d stride=%-2d offset=%-3d buf=%08x bufbase=%08x size=%s type=%s normalized=%s ", + index, + GLMDecode(eD3D_VTXDECLUSAGE, setup->m_vtxAttribMap[index]>>4 ), + setup->m_vtxAttribMap[index]&0x0F, + setdesc->m_stride, + setdesc->m_offset, + setdesc->m_buffer, + setdesc->m_buffer->m_lastMappedAddress, + sizestr, + GLMDecode( eGL_ENUM, setdesc->m_datatype), + setdesc->m_normalized?"Y":"N" + )); + } + else + { + // the attrib map is referencing an attribute that is not wired up in the vertex setup... + Debugger(); + } + } + } + } + + if ( (options & (1<m_drawVertexSetup; + int start = info->m_drawStart; + int end = info->m_drawEnd; + int endLimit = start + (1<=0) + { + mark += sprintf(mark, "-D- %04d: ", vtxIndex ); + } + + // for transform dumping, we latch values as we spot them + float vtxPos[4]; + int vtxBoneIndices[4]; // only three get used + float vtxBoneWeights[4]; // only three get used and index 2 is synthesized from 0 and 1 + + vtxPos[0] = vtxPos[1] = vtxPos[2] = 0.0; + vtxPos[3] = 1.0; + + vtxBoneIndices[0] = vtxBoneIndices[1] = vtxBoneIndices[2] = vtxBoneIndices[3] = 0; + vtxBoneWeights[0] = vtxBoneWeights[1] = vtxBoneWeights[2] = vtxBoneWeights[3] = 0.0; + + for( int attr = 0; attr < kGLMVertexAttributeIndexMax; attr++ ) + { + if (setup->m_attrMask & (1<m_attrs[ attr ]; + + // print that attribute. + + // on OSX, VB's never move unless resized. You can peek at them when unmapped. Safe enough for debug.. + char *bufferBase = (char*)desc->m_buffer->m_lastMappedAddress; + + uint stride = desc->m_stride; + uint fieldoffset = desc->m_offset; + uint baseoffset = vtxIndex * stride; + + char *attrBase = bufferBase + baseoffset + fieldoffset; + + uint usage = setup->m_vtxAttribMap[attr]>>4; + uint usageindex = setup->m_vtxAttribMap[attr]&0x0F; + + if (vtxIndex <0) + { + mark += sprintf(mark, "[%s%1d @ offs=%04d / strd %03d] ", GLMDecode(eD3D_VTXDECLUSAGE, usage ), usageindex, fieldoffset, stride ); + } + else + { + mark += sprintf(mark, "[%s%1d ", GLMDecode(eD3D_VTXDECLUSAGE, usage ), usageindex ); + + if (desc->m_datasize<32) + { + for( int which = 0; which < desc->m_datasize; which++ ) + { + static const char *fieldname = "xyzw"; + switch( desc->m_datatype ) + { + case GL_FLOAT: + { + float *floatbase = (float*)attrBase; + mark += sprintf(mark, (usage != D3DDECLUSAGE_TEXCOORD) ? "%c%7.3f " : "%c%.3f", fieldname[which], floatbase[which] ); + + if (usage==D3DDECLUSAGE_POSITION) + { + if (which<4) + { + // latch pos + vtxPos[which] = floatbase[which]; + } + } + + if (usage==D3DDECLUSAGE_BLENDWEIGHT) + { + if (which<4) + { + // latch weight + vtxBoneWeights[which] = floatbase[which]; + } + } + } + break; + + case GL_UNSIGNED_BYTE: + { + unsigned char *unchbase = (unsigned char*)attrBase; + mark += sprintf(mark, "%c$%02X ", fieldname[which], unchbase[which] ); + } + break; + + default: + // hold off on other formats for now + mark += sprintf(mark, "%c????? ", fieldname[which] ); + break; + } + } + } + else // special path for BGRA bytes which are expressed in GL by setting the *size* to GL_BGRA (gross large enum) + { + switch(desc->m_datasize) + { + case GL_BGRA: // byte reversed color + { + for( int which = 0; which < 4; which++ ) + { + static const char *fieldname = "BGRA"; + switch( desc->m_datatype ) + { + case GL_UNSIGNED_BYTE: + { + unsigned char *unchbase = (unsigned char*)attrBase; + mark += sprintf(mark, "%c$%02X ", fieldname[which], unchbase[which] ); + + if (usage==D3DDECLUSAGE_BLENDINDICES) + { + if (which<4) + { + // latch index + vtxBoneIndices[which] = unchbase[which]; // ignoring the component reverse which BGRA would inflict, but we also ignore it below so it matches up. + } + } + } + break; + + default: + Debugger(); + break; + } + } + } + break; + } + } + mark += sprintf(mark, "] " ); + } + } + } + GLMPrintStr( buf, eDebugDump ); + + if (vtxIndex >=0) + { + // if transform dumping requested, and we've reached the actual vert dump phase, do it + float vtxout[4]; + const char *translabel = NULL; // NULL means no print... + + switch( g_vertDumpMode ) + { + case eDumpVertsNoTransformDump: break; + + case eDumpVertsTransformedByViewProj: // viewproj is slot 8 + { + float *viewproj = &m_programParamsF[ kGLMVertexProgram ].m_values[8][0]; + transform_dp4( vtxPos, viewproj, 4, vtxout ); + translabel = "post-viewproj"; + } + break; + + case eDumpVertsTransformedByModelViewProj: // modelviewproj is slot 4 + { + float *modelviewproj = &m_programParamsF[ kGLMVertexProgram ].m_values[4][0]; + transform_dp4( vtxPos, modelviewproj, 4, vtxout ); + translabel = "post-modelviewproj"; + } + break; + + case eDumpVertsTransformedByBoneZeroThenViewProj: + { + float postbone[4]; + postbone[3] = 1.0; + + float *bonemat = &m_programParamsF[ kGLMVertexProgram ].m_values[58][0]; + transform_dp4( vtxPos, bonemat, 3, postbone ); + + float *viewproj = &m_programParamsF[ kGLMVertexProgram ].m_values[8][0]; // viewproj is slot 8 + transform_dp4( postbone, viewproj, 4, vtxout ); + + translabel = "post-bone0-viewproj"; + } + break; + + case eDumpVertsTransformedByBonesThenViewProj: + { + float bone[4][4]; // [bone index][bone member] // members are adjacent + + vtxout[0] = vtxout[1] = vtxout[2] = vtxout[3] = 0; + + // unpack the third weight + vtxBoneWeights[2] = 1.0 - (vtxBoneWeights[0] + vtxBoneWeights[1]); + + for( int ibone=0; ibone<3; ibone++ ) + { + int boneindex = vtxBoneIndices[ ibone ]; + float *bonemat = &m_programParamsF[ kGLMVertexProgram ].m_values[58+(boneindex*3)][0]; + + float boneweight = vtxBoneWeights[ibone]; + + float postbonevtx[4]; + + transform_dp4( vtxPos, bonemat, 3, postbonevtx ); + + // add weighted sum into output + for( int which=0; which<4; which++ ) + { + vtxout[which] += boneweight * postbonevtx[which]; + } + } + + // fix W ? do we care ? check shaders to see what they do... + translabel = "post-skin3bone-viewproj"; + } + break; + } + if(translabel) + { + // for extra credit, do the perspective divide and viewport + + GLMPRINTF(("-D- %-24s: [ %7.4f %7.4f %7.4f %7.4f ]", translabel, vtxout[0],vtxout[1],vtxout[2],vtxout[3] )); + GLMPRINTF(("-D-" )); + } + } + + if (vtxIndex<0) + { + vtxIndex = start-1; // for printing of the data (note it will be incremented at bottom of loop, so bias down by 1) + } + else + { // no more < and > around vert dump lines + //mark += sprintf(mark, "" ); + } + } + } + + if (options & (1<m_editable->OpenInEditor(); + } + + if (m_drawingProgram[ kGLMFragmentProgram ]) + { + m_drawingProgram[ kGLMFragmentProgram ]->m_editable->OpenInEditor(); + } + #endif + } +/* + if (options & (1<<)) + { + } +*/ + // trailer line + GLMPRINTF(("-D- ===================================================================================== end %s %d frame %d", batchtype, m_debugBatchIndex, m_debugFrameIndex )); + + GLMSetIndent(oldIndent); +} + +// here is the table that binds knob numbers to names. change at will. +const char *g_knobnames[] = +{ +/*0*/ "dummy", + +/*1*/ "FB-SRGB", + #if 0 + /*1*/ "tex-U0-bias", // src left + /*2*/ "tex-V0-bias", // src upper + /*3*/ "tex-U1-bias", // src right + /*4*/ "tex-V1-bias", // src bottom + + /*5*/ "pos-X0-bias", // dst left + /*6*/ "pos-Y0-bias", // dst upper + /*7*/ "pos-X1-bias", // dst right + /*8*/ "pos-Y1-bias", // dst bottom + #endif + +}; +int g_knobcount = sizeof( g_knobnames ) / sizeof( g_knobnames[0] ); + +void GLMContext::DebugHook( GLMDebugHookInfo *info ) +{ +#if 0 // disabled in steamworks example for time being + bool debughook = false; + // debug hook is called after an action has taken place. + // that would be the initial action, or a repeat. + // if paused, we stay inside this function until return. + // when returning, we inform the caller if it should repeat its last action or continue. + // there is no global pause state. The rest of the app runs at the best speed it can. + + // initial stuff we do unconditionally + + // increment iteration + info->m_iteration++; // can be thought of as "number of times the caller's action has now occurred - starting at 1" + + // now set initial state guess for the info block (outcome may change below) + info->m_loop = false; + + // check prior hold-conditions to see if any of them hit. + // note we disarm each trigger once the hold has occurred (one-shot style) + + switch( info->m_caller ) + { + case eBeginFrame: + if (debughook) GLMPRINTF(("-D- Caller: BeginFrame" )); + if ( (m_holdFrameBegin>=0) && (m_holdFrameBegin==m_debugFrameIndex) ) // did we hit a frame breakpoint? + { + if (debughook) GLMPRINTF(("-D- BeginFrame trigger match, clearing m_holdFrameBegin, hold=true" )); + + m_holdFrameBegin = -1; + + info->m_holding = true; + } + break; + + case eClear: + if (debughook) GLMPRINTF(("-D- Caller: Clear" )); + if ( (m_holdBatch>=0) && (m_holdBatchFrame>=0) && (m_holdBatch==m_debugBatchIndex) && (m_holdBatchFrame==m_debugFrameIndex) ) + { + if (debughook) GLMPRINTF(("-D- Clear trigger match, clearing m_holdBatch&Frame, hold=true" )); + + m_holdBatch = m_holdBatchFrame = -1; + + info->m_holding = true; + } + break; + + case eDrawElements: + if (debughook) GLMPRINTF(( (info->m_caller==eClear) ? "-D- Caller: Clear" : "-D- Caller: Draw" )); + if ( (m_holdBatch>=0) && (m_holdBatchFrame>=0) && (m_holdBatch==m_debugBatchIndex) && (m_holdBatchFrame==m_debugFrameIndex) ) + { + if (debughook) GLMPRINTF(("-D- Draw trigger match, clearing m_holdBatch&Frame, hold=true" )); + + m_holdBatch = m_holdBatchFrame = -1; + + info->m_holding = true; + } + break; + + case eEndFrame: + if (debughook) GLMPRINTF(("-D- Caller: EndFrame" )); + + // check for any expired batch hold req + if ( (m_holdBatch>=0) && (m_holdBatchFrame>=0) && (m_holdBatchFrame==m_debugFrameIndex) ) + { + // you tried to say 'next batch', but there wasn't one in this frame. + // target first batch of next frame instead + if (debughook) GLMPRINTF(("-D- EndFrame noticed an expired draw hold trigger, rolling to next frame, hold=false")); + + m_holdBatch = 0; + m_holdBatchFrame++; + + info->m_holding = false; + } + + // now check for an explicit hold on end of this frame.. + if ( (m_holdFrameEnd>=0) && (m_holdFrameEnd==m_debugFrameIndex) ) + { + if (debughook) GLMPRINTF(("-D- EndFrame trigger match, clearing m_holdFrameEnd, hold=true" )); + + m_holdFrameEnd = -1; + + info->m_holding = true; + } + break; + } + + // spin until event queue is empty *and* hold is false + + int evtcount=0; + + bool refresh = info->m_holding || m_debugDelayEnable; // only refresh once per initial visit (if paused!) or follow up event input + int breakToDebugger = 0; + // 1 = break to GDB + // 2 = break to OpenGL Profiler if attached + + do + { + if (refresh) + { + if (debughook) GLMPRINTF(("-D- pushing pixels" )); + this->DebugPresent(); // show pixels + + uint minidumpOptions = (1<DebugDump( info, minidumpOptions, g_vertDumpMode ); + + usleep(10000); // lil sleep + + refresh = false; + } + + bool eventCheck = true; // event pull will be skipped if we detect a shader edit being done + // keep editable shaders in sync + #if GLMDEBUG + + bool redrawBatch = false; + if (m_drawingProgram[ kGLMVertexProgram ]) + { + if( m_drawingProgram[ kGLMVertexProgram ]->SyncWithEditable() ) + { + redrawBatch = true; + } + } + + if (m_drawingProgram[ kGLMFragmentProgram ]) + { + if( m_drawingProgram[ kGLMFragmentProgram ]->SyncWithEditable() ) + { + redrawBatch = true; + } + } + + if (redrawBatch) + { + // act as if user pressed the option-\ key + + if (m_drawingLang == kGLMGLSL) + { + // if GLSL mode, force relink - and refresh the pair cache as needed + if (m_boundPair) + { + // fix it in place + m_boundPair->RefreshProgramPair(); + } + } + FlushDrawStates( true ); // this is key, because the linked shader pair may have changed (note call to PurgePairsWithShader in cglmprogram.cpp) + + GLMPRINTF(("-- Shader changed, re-running batch" )); + + m_holdBatch = m_debugBatchIndex; + m_holdBatchFrame = m_debugFrameIndex; + m_debugDelayEnable = false; + + info->m_holding = false; + info->m_loop = true; + + eventCheck = false; + } + #endif + + if(eventCheck) + { + g_extCocoaMgr->PumpWindowsMessageLoop(); + CCocoaEvent evt; + evtcount = g_extCocoaMgr->GetEvents( &evt, 1, true ); // asking for debug events only. + if (evtcount) + { + // print it + if (debughook) GLMPRINTF(("-D- Received debug key '%c' with modifiers %x", evt.m_UnicodeKeyUnmodified, evt.m_ModifierKeyMask )); + + // flag for refresh if we spin again + refresh = 1; + + switch(evt.m_UnicodeKeyUnmodified) + { + case ' ': // toggle pause + // clear all the holds to be sure + m_holdFrameBegin = m_holdFrameEnd = m_holdBatch = m_holdBatchFrame = -1; + info->m_holding = !info->m_holding; + + if (!info->m_holding) + { + m_debugDelayEnable = false; // coming out of pause means no slow mo + } + + GLMPRINTF((info->m_holding ? "-D- Paused." : "-D- Unpaused." )); + break; + + case 'f': // frame advance + GLMPRINTF(("-D- Command: next frame" )); + m_holdFrameBegin = m_debugFrameIndex+1; // stop at top of next numbered frame + m_debugDelayEnable = false; // get there fast + + info->m_holding = false; + break; + + case ']': // ahead 1 batch + case '}': // ahead ten batches + { + int delta = evt.m_UnicodeKeyUnmodified == ']' ? 1 : 10; + m_holdBatch = m_debugBatchIndex+delta; + m_holdBatchFrame = m_debugFrameIndex; + m_debugDelayEnable = false; // get there fast + info->m_holding = false; + GLMPRINTF(("-D- Command: advance %d batches to %d", delta, m_holdBatch )); + } + break; + + case '[': // back one batch + case '{': // back 10 batches + { + int delta = evt.m_UnicodeKeyUnmodified == '[' ? -1 : -10; + m_holdBatch = m_debugBatchIndex + delta; + if (m_holdBatch<0) + { + m_holdBatch = 0; + } + m_holdBatchFrame = m_debugFrameIndex+1; // next frame, but prev batch # + m_debugDelayEnable = false; // get there fast + info->m_holding = false; + GLMPRINTF(("-D- Command: rewind %d batches to %d", delta, m_holdBatch )); + } + break; + + case '\\': // batch rerun + + m_holdBatch = m_debugBatchIndex; + m_holdBatchFrame = m_debugFrameIndex; + m_debugDelayEnable = false; + info->m_holding = false; + info->m_loop = true; + GLMPRINTF(("-D- Command: re-run batch %d", m_holdBatch )); + break; + + case 'c': // toggle auto color clear + m_autoClearColor = !m_autoClearColor; + GLMPRINTF((m_autoClearColor ? "-D- Auto color clear ON" : "-D- Auto color clear OFF" )); + break; + + case 's': // toggle auto stencil clear + m_autoClearStencil = !m_autoClearStencil; + GLMPRINTF((m_autoClearStencil ? "-D- Auto stencil clear ON" : "-D- Auto stencil clear OFF" )); + break; + + case 'd': // toggle auto depth clear + m_autoClearDepth = !m_autoClearDepth; + GLMPRINTF((m_autoClearDepth ? "-D- Auto depth clear ON" : "-D- Auto depth clear OFF" )); + break; + + case '.': // break to debugger or insta-quit + if (evt.m_ModifierKeyMask & (1<m_holding = true; + info->m_loop = true; // so when you come back from debugger, you get another spin (i.e. you enter paused mode) + } + break; + + case 'g': // break to OGLP and enable OGLP logging of spew + if (GLMDetectOGLP()) // if this comes back true, there will be a breakpoint set on glColor4sv. + { + uint channelMask = GLMDetectAvailableChannels(); // will re-assert whether spew goes to OGLP log + + if (channelMask & (1<m_holding = true; + info->m_loop = true; // so when you come back from debugger, you get another spin (i.e. you enter paused mode) + } + } + break; + + case '_': // toggle slow mo + m_debugDelayEnable = !m_debugDelayEnable; + break; + + case '-': // go slower + if (m_debugDelayEnable) + { + // already in slow mo, so lower speed + m_debugDelay <<= 1; // double delay + if (m_debugDelay > (1<<24)) + { + m_debugDelay = (1<<24); + } + } + else + { + // enter slow mo + m_debugDelayEnable = true; + } + break; + + case '=': // go faster + if (m_debugDelayEnable) + { + // already in slow mo, so raise speed + m_debugDelay >>= 1; // halve delay + if (m_debugDelay < (1<<17)) + { + m_debugDelay = (1<<17); + } + } + else + { + // enter slow mo + m_debugDelayEnable = true; + } + break; + + case 'v': + // open vs in editor (foreground pop) + #if GLMDEBUG + if (m_boundProgram[ kGLMVertexProgram ]) + { + m_boundProgram[ kGLMVertexProgram ]->m_editable->OpenInEditor( true ); + } + #endif + break; + + case 'p': + // open fs/ps in editor (foreground pop) + #if GLMDEBUG + if (m_boundProgram[ kGLMFragmentProgram ]) + { + m_boundProgram[ kGLMFragmentProgram ]->m_editable->OpenInEditor( true ); + } + #endif + break; + + case '<': // dump fewer verts + case '>': // dump more verts + { + int delta = (evt.m_UnicodeKeyUnmodified=='>') ? 1 : -1; + g_maxVertsToDumpLog2 = MIN( MAX( g_maxVertsToDumpLog2+delta, 0 ), 16 ); + + // just re-dump the verts + DebugDump( info, 1<= eLastDumpVertsMode) + { + // wrap + newmode = eDumpVertsNoTransformDump; + } + g_vertDumpMode = (EGLMVertDumpMode)newmode; + + GLMPRINTF(("-D- New vert dump mode is %s", g_vertDumpModeNames[g_vertDumpMode] )); + } + break; + + case 'u': // more crawl + { + CStackCrawlParams cp; + memset( &cp, 0, sizeof(cp) ); + cp.m_frameLimit = kMaxCrawlFrames; + + g_extCocoaMgr->GetStackCrawl(&cp); + + GLMPRINTF(("-D-" )); + GLMPRINTF(("-D- extended stack crawl:")); + for( int i=0; i< cp.m_frameCount; i++) + { + GLMPRINTF(("-D-\t%s", cp.m_crawlNames[i] )); + } + } + break; + + case 'q': + DebugDump( info, 0xFFFFFFFF, g_vertDumpMode ); + break; + + + case 'H': + case 'h': + { + // toggle drawing language. hold down shift key to do it immediately. + + if (m_caps.m_hasDualShaders) + { + bool immediate; + + immediate = evt.m_UnicodeKeyUnmodified == 'H'; // (evt.m_ModifierKeyMask & (1<=0) && (flavorSelect m_selKnobMaxValue) + { + val = m_selKnobMaxValue; + } + // send new value back to the knob + GLMKnob( g_knobnames[ m_selKnobIndex ], &val ); + } + + if (evt.m_UnicodeKeyUnmodified == 'z') + { + // zero + val = 0.0f; + + // send new value back to the knob + GLMKnob( g_knobnames[ m_selKnobIndex ], &val ); + } + + GLMPRINTF(("-D- Knob # %d (%s) set to %f (%f/1024.0)", m_selKnobIndex, g_knobnames[ m_selKnobIndex ], val, val * 1024.0 )); + + usleep( 500000 ); + refresh = false; + } + } + break; + + } + } + } + } while( ((evtcount>0) || info->m_holding) && (!breakToDebugger) ); + + if (m_debugDelayEnable) + { + usleep( m_debugDelay ); + } + + if (breakToDebugger) + { + switch (breakToDebugger) + { + case 1: + Debugger(); + break; + + case 2: + short fakecolor[4]; + glColor4sv( fakecolor ); // break to OGLP + break; + } + // re-flush all GLM states so you can fiddle with them in the debugger. then run the batch again and spin.. + FlushStates( true ); + } +#endif +} + +void GLMContext::DebugPresent( void ) +{ + CGLMTex *drawBufferTex = m_drawingFBO->m_attach[kAttColor0].m_tex; + glFinish(); + this->Present( drawBufferTex ); +} + +void GLMContext::DebugClear( void ) +{ + // get old clear color + GLClearColor_t clearcol_orig; + m_ClearColor.Read( &clearcol_orig,0 ); + + // new clear color + GLClearColor_t clearcol; + clearcol.r = m_autoClearColorValues[0]; + clearcol.g = m_autoClearColorValues[1]; + clearcol.b = m_autoClearColorValues[2]; + clearcol.a = m_autoClearColorValues[3]; + m_ClearColor.Write( &clearcol, true, true ); // don't check, don't defer + + uint mask = 0; + + if (m_autoClearColor) mask |= GL_COLOR_BUFFER_BIT; + if (m_autoClearDepth) mask |= GL_DEPTH_BUFFER_BIT; + if (m_autoClearStencil) mask |= GL_STENCIL_BUFFER_BIT; + + glClear( mask ); + glFinish(); + + // put old color back + m_ClearColor.Write( &clearcol_orig, true, true ); // don't check, don't defer +} + +#endif + +void GLMContext::DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices ) +{ + GLM_FUNC; + +// CheckCurrent(); + + m_debugBatchIndex++; // batch index increments unconditionally on entry + + bool hasVP = m_boundProgram[ kGLMVertexProgram ] != NULL; + bool hasFP = m_boundProgram[ kGLMFragmentProgram ] != NULL; + + void *indicesActual = (void*)indices; + if (m_drawIndexBuffer->m_pseudo) + { + // you have to pass actual address, not offset... shhh... secret + indicesActual = (void*)((uintptr_t)indicesActual + (uintptr_t)m_drawIndexBuffer->m_pseudoBuf); + } + +#if GLMDEBUG + // init debug hook information + GLMDebugHookInfo info; + memset( &info, 0, sizeof(info) ); + info.m_caller = eDrawElements; + + // relay parameters we're operating under + info.m_drawMode = mode; + info.m_drawStart = start; + info.m_drawEnd = end; + info.m_drawCount = count; + info.m_drawType = type; + info.m_drawIndices = indices; + + do + { + // obey global options re pre-draw clear + if (m_autoClearColor || m_autoClearDepth || m_autoClearStencil) + { + GLMPRINTF(("-- DrawRangeElements auto clear" )); + this->DebugClear(); + } + + // always sync with editable shader text prior to draw + #if GLMDEBUG + //FIXME disengage this path if context is in GLSL mode.. + // it will need fixes to get the shader pair re-linked etc if edits happen anyway. + + if (m_boundProgram[ kGLMVertexProgram ]) + { + m_boundProgram[ kGLMVertexProgram ]->SyncWithEditable(); + } + else + { + //AssertOnce(!"drawing with no vertex program bound"); + } + + + if (m_boundProgram[ kGLMFragmentProgram ]) + { + m_boundProgram[ kGLMFragmentProgram ]->SyncWithEditable(); + } + else + { + //AssertOnce(!"drawing with no fragment program bound"); + } + #endif + + // do the drawing + if (hasVP && hasFP) + { + glDrawRangeElements( mode, start, end, count, type, indicesActual ); + GLMCheckError(); + + if (m_slowCheckEnable) + { + CheckNative(); + } + } + this->DebugHook( &info ); + } while (info.m_loop); +#else + if (hasVP && hasFP) + { + glDrawRangeElements( mode, start, end, count, type, indicesActual ); + GLMCheckError(); + + if (m_slowCheckEnable) + { + CheckNative(); + } + } +#endif +} + +void GLMContext::DrawArrays( GLenum mode, GLuint first, GLuint count ) +{ + GLM_FUNC; + + m_debugBatchIndex++; // batch index increments unconditionally on entry + + bool hasVP = m_boundProgram[ kGLMVertexProgram ] != NULL; + bool hasFP = m_boundProgram[ kGLMFragmentProgram ] != NULL; + + // note that the GLMDEBUG path is not wired up here yet + if (hasVP && hasFP) + { + #if GLMDEBUG && 0 + // init debug hook information + GLMDebugHookInfo info; + memset( &info, 0, sizeof(info) ); + info.m_caller = eDrawArrays; + + // relay parameters we're operating under + info.m_drawMode = mode; + info.m_drawStart = first; + info.m_drawEnd = first+count; + info.m_drawCount = count; + info.m_drawType = 0; // no one was using this anyway.. + info.m_drawIndices = NULL; + + glDrawArrays(mode, first, count); + GLMCheckError(); + + DebugDump( &info, 0xFFFFFFFF, g_vertDumpMode ); + #else + glDrawArrays(mode, first, count); + GLMCheckError(); + #endif + + if (m_slowCheckEnable) + { + CheckNative(); + } + } +} + +void GLMContext::CheckNative( void ) +{ + // note that this is available in release. We don't use GLMPRINTF for that reason. + // note we do not get called unless either slow-batch asserting or logging is enabled. + + bool gpuProcessing; + GLint fragmentGPUProcessing, vertexGPUProcessing; + + CGLGetParameter (CGLGetCurrentContext(), kCGLCPGPUFragmentProcessing, &fragmentGPUProcessing); + CGLGetParameter(CGLGetCurrentContext(), kCGLCPGPUVertexProcessing, &vertexGPUProcessing); + + // spews then asserts. + // that way you can enable both, get log output on a pair if it's slow, and then the debugger will pop. + if(m_slowSpewEnable) + { + if ( !vertexGPUProcessing ) + { + m_boundProgram[ kGLMVertexProgram ]->LogSlow( m_drawingLang ); + } + if ( !fragmentGPUProcessing ) + { + m_boundProgram[ kGLMFragmentProgram ]->LogSlow( m_drawingLang ); + } + } + + if(m_slowAssertEnable) + { + if ( !vertexGPUProcessing || !fragmentGPUProcessing) + { + Assert( !"slow batch" ); + } + } +} + + + +// debug font +void GLMContext::GenDebugFontTex( void ) +{ + if(!m_debugFontTex) + { + // make a 128x128 RGBA texture + GLMTexLayoutKey key; + memset( &key, 0, sizeof(key) ); + + key.m_texGLTarget = GL_TEXTURE_2D; + key.m_xSize = 128; + key.m_ySize = 128; + key.m_zSize = 1; + key.m_texFormat = D3DFMT_A8R8G8B8; + key.m_texFlags = 0; + + m_debugFontTex = this->NewTex( &key, "GLM debug font" ); + + + //----------------------------------------------------- + GLMTexLockParams lockreq; + + lockreq.m_tex = m_debugFontTex; + lockreq.m_face = 0; + lockreq.m_mip = 0; + + GLMTexLayoutSlice *slice = &m_debugFontTex->m_layout->m_slices[ lockreq.m_tex->CalcSliceIndex( lockreq.m_face, lockreq.m_mip ) ]; + + lockreq.m_region.xmin = lockreq.m_region.ymin = lockreq.m_region.zmin = 0; + lockreq.m_region.xmax = slice->m_xSize; + lockreq.m_region.ymax = slice->m_ySize; + lockreq.m_region.zmax = slice->m_zSize; + + char *lockAddress; + int yStride; + int zStride; + + m_debugFontTex->Lock( &lockreq, &lockAddress, &yStride, &zStride ); + GLMCheckError(); + + //----------------------------------------------------- + // fetch elements of font data and make texels... we're doing the whole slab so we don't really need the stride info + unsigned long *destTexelPtr = (unsigned long *)lockAddress; + + for( int index = 0; index < 16384; index++ ) + { + if (g_glmDebugFontMap[index] == ' ') + { + // clear + *destTexelPtr = 0x00000000; + } + else + { + // opaque white (drawing code can modulate if desired) + *destTexelPtr = 0xFFFFFFFF; + } + destTexelPtr++; + } + + //----------------------------------------------------- + GLMTexLockParams unlockreq; + + unlockreq.m_tex = m_debugFontTex; + unlockreq.m_face = 0; + unlockreq.m_mip = 0; + + // region need not matter for unlocks + unlockreq.m_region.xmin = unlockreq.m_region.ymin = unlockreq.m_region.zmin = 0; + unlockreq.m_region.xmax = unlockreq.m_region.ymax = unlockreq.m_region.zmax = 0; + + m_debugFontTex->Unlock( &unlockreq ); + GLMCheckError(); + + //----------------------------------------------------- + // change up the tex sampling on this texture to be "nearest" not linear + + //----------------------------------------------------- + + // don't leave texture bound on the TMU + this->BindTexToTMU(NULL, 0 ); + + // also make the index and vertex buffers for use - up to 1K indices and 1K verts + + uint indexBufferSize = 1024*2; + + m_debugFontIndices = this->NewBuffer(kGLMIndexBuffer, indexBufferSize, 0); // two byte indices + + // we go ahead and lock it now, and fill it with indices 0-1023. + char *indices = NULL; + GLMBuffLockParams idxLock; + idxLock.m_offset = 0; + idxLock.m_size = indexBufferSize; + idxLock.m_nonblocking = false; + idxLock.m_discard = false; + m_debugFontIndices->Lock( &idxLock, &indices ); + for( int i=0; i<1024; i++) + { + unsigned short *idxPtr = &((unsigned short*)indices)[i]; + *idxPtr = i; + } + m_debugFontIndices->Unlock(); + + m_debugFontVertices = this->NewBuffer(kGLMVertexBuffer, 1024 * 128, 0); // up to 128 bytes per vert + } +} + +#define MAX_DEBUG_CHARS 256 +struct GLMDebugTextVertex +{ + float x,y,z; + float u,v; + char rgba[4]; +}; + +void GLMContext::DrawDebugText( float x, float y, float z, float drawCharWidth, float drawCharHeight, char *string ) +{ + if (!m_debugFontTex) + { + GenDebugFontTex(); + } + + // setup needed to draw text + + // we're assuming that +x goes left to right on screen, no billboarding math in here + // and that +y goes bottom up + // caller knows projection / rectangle so it gets to decide vertex spacing + + // debug font must be bound to TMU 0 + // texturing enabled + // alpha blending enabled + // generate a quad per character + // characters are 6px wide by 11 px high. + // upper left character in tex is 0x20 + // y axis will need to be flipped for display + + // for any character in 0x20 - 0x7F - here are the needed UV's + + // leftU = ((character % 16) * 6.0f / 128.0f) + // rightU = lowU + (6.0 / 128.0); + // topV = ((character - 0x20) * 11.0f / 128.0f) + // bottomV = lowV + (11.0f / 128.0f) + + int stringlen = strlen( string ); + if (stringlen > MAX_DEBUG_CHARS) + { + stringlen = MAX_DEBUG_CHARS; + } + + // lock + char *vertices = NULL; + GLMBuffLockParams vtxLock; + vtxLock.m_offset = 0; + vtxLock.m_size = 1024 * stringlen; + vtxLock.m_nonblocking = false; + vtxLock.m_discard = false; + m_debugFontVertices->Lock( &vtxLock, &vertices ); + + GLMDebugTextVertex *vtx = (GLMDebugTextVertex*)vertices; + GLMDebugTextVertex *vtxOutPtr = vtx; + + for( int charindex = 0; charindex < stringlen; charindex++ ) + { + float leftU,rightU,topV,bottomV; + + int character = (int)string[charindex]; + character -= 0x20; + if ( (character<0) || (character > 0x7F) ) + { + character = '*' - 0x20; + } + + leftU = ((character & 0x0F) * 6.0f ) / 128.0f; + rightU = leftU + (6.0f / 128.0f); + + topV = ((character >> 4) * 11.0f ) / 128.0f; + bottomV = topV + (11.0f / 128.0f); + + float posx,posy,posz; + + posx = x + (drawCharWidth * (float)charindex); + posy = y; + posz = z; + + // generate four verts + // first vert will be upper left of displayed quad (low X, high Y) then we go clockwise + for( int quadvert = 0; quadvert < 4; quadvert++ ) + { + bool isTop = (quadvert <2); // verts 0 and 1 + bool isLeft = (quadvert & 1) == (quadvert >> 1); // verts 0 and 3 + + vtxOutPtr->x = posx + (isLeft ? 0.0f : drawCharWidth); + vtxOutPtr->y = posy + (isTop ? drawCharHeight : 0.0f); + vtxOutPtr->z = posz; + + vtxOutPtr->u = isLeft ? leftU : rightU; + vtxOutPtr->v = isTop ? topV : bottomV; + + vtxOutPtr++; + } + } + + // verts are done. + // unlock... + + m_debugFontVertices->Unlock(); + + // make a vertex setup + GLMVertexSetup vertSetup; + + // position, color, tc = 0, 3, 8 + vertSetup.m_attrMask = (1<BindTexToTMU( m_debugFontTex, 0 ); + + SelectTMU(0); // somewhat redundant + + glDisable( GL_DEPTH_TEST ); + + glEnable(GL_TEXTURE_2D); + GLMCheckError(); + + if (0) + { + glEnableClientState(GL_VERTEX_ARRAY); + GLMCheckError(); + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + GLMCheckError(); + + glVertexPointer( 3, GL_FLOAT, sizeof( vtx[0] ), &vtx[0].x ); + GLMCheckError(); + + glClientActiveTexture(GL_TEXTURE0); + GLMCheckError(); + + glTexCoordPointer( 2, GL_FLOAT, sizeof( vtx[0] ), &vtx[0].u ); + GLMCheckError(); + } + else + { + SetVertexAttributes( &vertSetup ); + } + + glDrawArrays( GL_QUADS, 0, stringlen * 4 ); + GLMCheckError(); + + // disable all the input streams + if (0) + { + glDisableClientState(GL_VERTEX_ARRAY); + GLMCheckError(); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + GLMCheckError(); + } + else + { + SetVertexAttributes( NULL ); + } + + glDisable(GL_TEXTURE_2D); + GLMCheckError(); + + this->BindTexToTMU( NULL, 0 ); +} + + + +//=============================================================================== + +void GLMgrSelfTests( void ) +{ + return; // until such time as the tests are revised or axed + + // make a new context on renderer 0. + GLMContext *ctx = GLMgr::aGLMgr()->NewContext( 0 ); ////FIXME you can't make contexts this way any more. + if (!ctx) + { + Debugger(); // no go + return; + } + + // make a test object based on that context. + int alltests[] = {0,1,2,3, -1}; + int newtests[] = {3, -1}; + int notests[] = {-1}; + + int *testlist = notests; + + GLMTestParams params; + memset( ¶ms, 0, sizeof(params) ); + + params.m_ctx = ctx; + params.m_testList = testlist; + + params.m_glErrToDebugger = true; + params.m_glErrToConsole = true; + + params.m_intlErrToDebugger = true; + params.m_intlErrToConsole = true; + + params.m_frameCount = 1000; + + GLMTester testobj( ¶ms ); + + testobj.RunTests( ); + + GLMgr::aGLMgr()->DelContext( ctx ); +} + +void GLMContext::SetDefaultStates( void ) +{ + GLM_FUNC; + CheckCurrent(); + + m_AlphaTestEnable.Default(); + m_AlphaTestFunc.Default(); + + m_AlphaToCoverageEnable.Default(); + + m_CullFaceEnable.Default(); + m_CullFrontFace.Default(); + + m_PolygonMode.Default(); + m_DepthBias.Default(); + + m_ClipPlaneEnable.Default(); + m_ClipPlaneEquation.Default(); + + m_ScissorEnable.Default(); + m_ScissorBox.Default(); + + m_ViewportBox.Default(); + m_ViewportDepthRange.Default(); + + m_ColorMaskSingle.Default(); + m_ColorMaskMultiple.Default(); + + m_BlendEnable.Default(); + m_BlendFactor.Default(); + m_BlendEquation.Default(); + m_BlendColor.Default(); + //m_BlendEnableSRGB.Default(); // this isn't useful until there is an FBO bound - in fact it will trip a GL error. + + m_DepthTestEnable.Default(); + m_DepthFunc.Default(); + m_DepthMask.Default(); + + m_StencilTestEnable.Default(); + m_StencilFunc.Default(); + m_StencilOp.Default(); + m_StencilWriteMask.Default(); + + m_ClearColor.Default(); + m_ClearDepth.Default(); + m_ClearStencil.Default(); +} + +void GLMContext::FlushStates( bool noDefer ) +{ + GLM_FUNC; + CheckCurrent(); + + m_AlphaTestEnable.Flush( noDefer ); + m_AlphaTestFunc.Flush( noDefer ); + + m_AlphaToCoverageEnable.Flush( noDefer ); + + m_CullFaceEnable.Flush( noDefer ); + m_CullFrontFace.Flush( noDefer ); + + m_PolygonMode.Flush( noDefer ); + m_DepthBias.Flush( noDefer ); + + #if GLMDEBUG + m_ClipPlaneEnable.Flush( true ); // always push clip state + m_ClipPlaneEquation.Flush( true ); + #else + m_ClipPlaneEnable.Flush( noDefer ); + m_ClipPlaneEquation.Flush( noDefer ); + #endif + + + m_ScissorEnable.Flush( noDefer ); + m_ScissorBox.Flush( noDefer ); + + m_ViewportBox.Flush( noDefer ); + m_ViewportDepthRange.Flush( noDefer ); + + m_ColorMaskSingle.Flush( noDefer ); + m_ColorMaskMultiple.Flush( noDefer ); + + m_BlendEnable.Flush( noDefer ); + m_BlendFactor.Flush( noDefer ); + m_BlendEquation.Flush( noDefer ); + m_BlendColor.Flush( noDefer ); + + // the next call should not occur until we're sure the proper SRGB tex format is underneath the FBO. + // So, we're moving it up to FlushDrawStates so it can happen at just the right time. + //m_BlendEnableSRGB.Flush( noDefer ); + + m_DepthTestEnable.Flush( noDefer ); + m_DepthFunc.Flush( noDefer ); + m_DepthMask.Flush( noDefer ); + + m_StencilTestEnable.Flush( noDefer ); + m_StencilFunc.Flush( noDefer ); + m_StencilOp.Flush( noDefer ); + m_StencilWriteMask.Flush( noDefer ); + + m_ClearColor.Flush( noDefer ); + m_ClearDepth.Flush( noDefer ); + m_ClearStencil.Flush( noDefer ); + + GLMCheckError(); +} + +void GLMContext::VerifyStates ( void ) +{ + GLM_FUNC; + CheckCurrent(); + + // bare bones sanity check, head over to the debugger if our sense of the current context state is not correct + // we should only want to call this after a flush or the checks will flunk. + + if( m_AlphaTestEnable.Check() ) GLMStop(); + if( m_AlphaTestFunc.Check() ) GLMStop(); + + if( m_AlphaToCoverageEnable.Check() ) GLMStop(); + + if( m_CullFaceEnable.Check() ) GLMStop(); + if( m_CullFrontFace.Check() ) GLMStop(); + + if( m_PolygonMode.Check() ) GLMStop(); + if( m_DepthBias.Check() ) GLMStop(); + + if( m_ClipPlaneEnable.Check() ) GLMStop(); + //if( m_ClipPlaneEquation.Check() ) GLMStop(); + + if( m_ScissorEnable.Check() ) GLMStop(); + if( m_ScissorBox.Check() ) GLMStop(); + + + if( m_ViewportBox.Check() ) GLMStop(); + if( m_ViewportDepthRange.Check() ) GLMStop(); + + if( m_ColorMaskSingle.Check() ) GLMStop(); + if( m_ColorMaskMultiple.Check() ) GLMStop(); + + if( m_BlendEnable.Check() ) GLMStop(); + if( m_BlendFactor.Check() ) GLMStop(); + if( m_BlendEquation.Check() ) GLMStop(); + if( m_BlendColor.Check() ) GLMStop(); + + // only do this as caps permit + if (m_caps.m_hasGammaWrites) + { + if( m_BlendEnableSRGB.Check() ) GLMStop(); + } + + if( m_DepthTestEnable.Check() ) GLMStop(); + if( m_DepthFunc.Check() ) GLMStop(); + if( m_DepthMask.Check() ) GLMStop(); + + if( m_StencilTestEnable.Check() ) GLMStop(); + if( m_StencilFunc.Check() ) GLMStop(); + if( m_StencilOp.Check() ) GLMStop(); + if( m_StencilWriteMask.Check() ) GLMStop(); + + if( m_ClearColor.Check() ) GLMStop(); + if( m_ClearDepth.Check() ) GLMStop(); + if( m_ClearStencil.Check() ) GLMStop(); +} + +void GLMContext::WriteAlphaTestEnable( GLAlphaTestEnable_t *src ) +{ + m_AlphaTestEnable.Write( src ); +} + +void GLMContext::WriteAlphaTestFunc( GLAlphaTestFunc_t *src ) +{ + m_AlphaTestFunc.Write( src ); +} + +void GLMContext::WriteAlphaToCoverageEnable( GLAlphaToCoverageEnable_t *src ) +{ + m_AlphaToCoverageEnable.Write( src ); +} + +void GLMContext::WriteCullFaceEnable( GLCullFaceEnable_t *src ) +{ + m_CullFaceEnable.Write( src ); +} + +void GLMContext::WriteCullFrontFace( GLCullFrontFace_t *src ) +{ + m_CullFrontFace.Write( src ); +} + +void GLMContext::WritePolygonMode( GLPolygonMode_t *src ) +{ + m_PolygonMode.Write( src ); +} + +void GLMContext::WriteDepthBias( GLDepthBias_t *src ) +{ + m_DepthBias.Write( src ); +} + +void GLMContext::WriteClipPlaneEnable( GLClipPlaneEnable_t *src, int which ) +{ + m_ClipPlaneEnable.WriteIndex( src, which ); +} + +void GLMContext::WriteClipPlaneEquation( GLClipPlaneEquation_t *src, int which ) +{ + m_ClipPlaneEquation.WriteIndex( src, which ); +} + +void GLMContext::WriteScissorEnable( GLScissorEnable_t *src ) +{ + m_ScissorEnable.Write( src ); +} + +void GLMContext::WriteScissorBox( GLScissorBox_t *src ) +{ + m_ScissorBox.Write( src ); +} + +void GLMContext::WriteViewportBox( GLViewportBox_t *src ) +{ + m_ViewportBox.Write( src ); +} + +void GLMContext::WriteViewportDepthRange( GLViewportDepthRange_t *src ) +{ + m_ViewportDepthRange.Write( src ); +} + +void GLMContext::WriteColorMaskSingle( GLColorMaskSingle_t *src ) +{ + m_ColorMaskSingle.Write( src ); +} + +void GLMContext::WriteColorMaskMultiple( GLColorMaskMultiple_t *src, int which ) +{ + m_ColorMaskMultiple.WriteIndex( src, which ); +} + +void GLMContext::WriteBlendEnable( GLBlendEnable_t *src ) +{ + m_BlendEnable.Write( src ); +} + +void GLMContext::WriteBlendFactor( GLBlendFactor_t *src ) +{ + m_BlendFactor.Write( src ); +} + +void GLMContext::WriteBlendEquation( GLBlendEquation_t *src ) +{ + m_BlendEquation.Write( src ); +} + +void GLMContext::WriteBlendColor( GLBlendColor_t *src ) +{ + m_BlendColor.Write( src ); +} + +void GLMContext::WriteBlendEnableSRGB( GLBlendEnableSRGB_t *src ) +{ + if (m_caps.m_hasGammaWrites) // only if caps allow do we actually push it through to the extension + { + m_BlendEnableSRGB.Write( src ); + } + else + { + m_FakeBlendEnableSRGB = src->enable; + } + // note however that we're still tracking what this mode should be, so FlushDrawStates can look at it and adjust the pixel shader + // if fake SRGB mode is in place (m_caps.m_hasGammaWrites is false) +} + +void GLMContext::WriteDepthTestEnable( GLDepthTestEnable_t *src ) +{ + m_DepthTestEnable.Write( src ); +} + +void GLMContext::WriteDepthFunc( GLDepthFunc_t *src ) +{ + m_DepthFunc.Write( src ); +} + +void GLMContext::WriteDepthMask( GLDepthMask_t *src ) +{ + m_DepthMask.Write( src ); +} + +void GLMContext::WriteStencilTestEnable( GLStencilTestEnable_t *src ) +{ + m_StencilTestEnable.Write( src ); +} + +void GLMContext::WriteStencilFunc( GLStencilFunc_t *src ) +{ + m_StencilFunc.Write( src ); +} + +void GLMContext::WriteStencilOp( GLStencilOp_t *src, int which ) +{ + m_StencilOp.WriteIndex( src, which ); +} + +void GLMContext::WriteStencilWriteMask( GLStencilWriteMask_t *src ) +{ + m_StencilWriteMask.Write( src ); +} + +void GLMContext::WriteClearColor( GLClearColor_t *src ) +{ + m_ClearColor.Write( src ); +} + +void GLMContext::WriteClearDepth( GLClearDepth_t *src ) +{ + m_ClearDepth.Write( src ); +} + +void GLMContext::WriteClearStencil( GLClearStencil_t *src ) +{ + m_ClearStencil.Write( src ); +} + +//=============================================================================== +// template specializations for each type of state + + +// --- GLAlphaTestEnable --- +void GLContextSet( GLAlphaTestEnable_t *src ) +{ + glSetEnable( GL_ALPHA_TEST, src->enable ); +} + +void GLContextGet( GLAlphaTestEnable_t *dst ) +{ + dst->enable = glIsEnabled( GL_ALPHA_TEST ); +} + +void GLContextGetDefault( GLAlphaTestEnable_t *dst ) +{ + dst->enable = GL_FALSE; +} + +// --- GLAlphaTestFunc --- +void GLContextSet( GLAlphaTestFunc_t *src ) +{ + glAlphaFunc( src->func, src->ref ); +} + +void GLContextGet( GLAlphaTestFunc_t *dst ) +{ + glGetEnumv( GL_ALPHA_TEST_FUNC, &dst->func ); + glGetFloatv( GL_ALPHA_TEST_REF, &dst->ref ); +} + +void GLContextGetDefault( GLAlphaTestFunc_t *dst ) +{ + dst->func = GL_ALWAYS; + dst->ref = 0.0f; +} + +// --- GLAlphaToCoverageEnable --- +void GLContextSet( GLAlphaToCoverageEnable_t *src ) +{ + glSetEnable( GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, src->enable ); +} + +void GLContextGet( GLAlphaToCoverageEnable_t *dst ) +{ + dst->enable = glIsEnabled( GL_SAMPLE_ALPHA_TO_COVERAGE_ARB ); +} + +void GLContextGetDefault( GLAlphaToCoverageEnable_t *dst ) +{ + dst->enable = GL_FALSE; +} + +// --- GLCullFaceEnable --- +void GLContextSet( GLCullFaceEnable_t *src ) +{ + glSetEnable( GL_CULL_FACE, src->enable ); +} + +void GLContextGet( GLCullFaceEnable_t *dst ) +{ + dst->enable = glIsEnabled( GL_CULL_FACE ); +} + +void GLContextGetDefault( GLCullFaceEnable_t *dst ) +{ + dst->enable = GL_TRUE; +} + + +// --- GLCullFrontFace --- +void GLContextSet( GLCullFrontFace_t *src ) +{ + glFrontFace( src->value ); // legal values are GL_CW or GL_CCW +} + +void GLContextGet( GLCullFrontFace_t *dst ) +{ + glGetEnumv( GL_FRONT_FACE, &dst->value ); +} + +void GLContextGetDefault( GLCullFrontFace_t *dst ) +{ + dst->value = GL_CCW; +} + + +// --- GLPolygonMode --- +void GLContextSet( GLPolygonMode_t *src ) +{ + glPolygonMode( GL_FRONT, src->values[0] ); + glPolygonMode( GL_BACK, src->values[1] ); +} + +void GLContextGet( GLPolygonMode_t *dst ) +{ + glGetEnumv( GL_POLYGON_MODE, &dst->values[0] ); + +} + +void GLContextGetDefault( GLPolygonMode_t *dst ) +{ + dst->values[0] = dst->values[1] = GL_FILL; +} + + +// --- GLDepthBias --- +// note the implicit enable / disable. +// if you set non zero values, it is enabled, otherwise not. +void GLContextSet( GLDepthBias_t *src ) +{ + bool enable = (src->factor != 0.0f) || (src->units != 0.0f); + + glSetEnable( GL_POLYGON_OFFSET_FILL, enable ); + glPolygonOffset( src->factor, src->units ); +} + +void GLContextGet( GLDepthBias_t *dst ) +{ + glGetFloatv ( GL_POLYGON_OFFSET_FACTOR, &dst->factor ); + glGetFloatv ( GL_POLYGON_OFFSET_UNITS, &dst->units ); +} + +void GLContextGetDefault( GLDepthBias_t *dst ) +{ + dst->factor = 0.0; + dst->units = 0.0; +} + + +// --- GLScissorEnable --- +void GLContextSet( GLScissorEnable_t *src ) +{ + glSetEnable( GL_SCISSOR_TEST, src->enable ); +} + +void GLContextGet( GLScissorEnable_t *dst ) +{ + dst->enable = glIsEnabled( GL_SCISSOR_TEST ); +} + +void GLContextGetDefault( GLScissorEnable_t *dst ) +{ + dst->enable = GL_FALSE; +} + + +// --- GLScissorBox --- +void GLContextSet( GLScissorBox_t *src ) +{ + glScissor ( src->x, src->y, src->width, src->height ); +} + +void GLContextGet( GLScissorBox_t *dst ) +{ + glGetIntegerv ( GL_SCISSOR_BOX, &dst->x ); +} + +void GLContextGetDefault( GLScissorBox_t *dst ) +{ + // hmmmm, good question? we can't really know a good answer so we pick a silly one + // and the client better come back with a better answer later. + dst->x = dst->y = 0; + dst->width = dst->height = 16; +} + + +// --- GLViewportBox --- + +void GLContextSet( GLViewportBox_t *src ) +{ + glViewport (src->x, src->y, src->width, src->height ); +} + +void GLContextGet( GLViewportBox_t *dst ) +{ + glGetIntegerv ( GL_VIEWPORT, &dst->x ); +} + +void GLContextGetDefault( GLViewportBox_t *dst ) +{ + // as with the scissor box, we don't know yet, so pick a silly one and change it later + dst->x = dst->y = 0; + dst->width = dst->height = 16; +} + + +// --- GLViewportDepthRange --- +void GLContextSet( GLViewportDepthRange_t *src ) +{ + glDepthRange ( src->near, src->far ); +} + +void GLContextGet( GLViewportDepthRange_t *dst ) +{ + glGetDoublev ( GL_DEPTH_RANGE, &dst->near ); +} + +void GLContextGetDefault( GLViewportDepthRange_t *dst ) +{ + dst->near = 0.0; + dst->far = 1.0; +} + +// --- GLClipPlaneEnable --- +void GLContextSetIndexed( GLClipPlaneEnable_t *src, int index ) +{ + #if 0 // disabled for sample GLMDEBUG + if (0 /*CommandLine()->FindParm("-caps_noclipplanes")*/) + { + if (GLMKnob("caps-key",NULL) > 0.0) + { + // caps ON means NO clipping + src->enable = false; + } + } + #endif + glSetEnable( GL_CLIP_PLANE0 + index, src->enable ); + GLMCheckError(); +} + +void GLContextGetIndexed( GLClipPlaneEnable_t *dst, int index ) +{ + dst->enable = glIsEnabled( GL_CLIP_PLANE0 + index ); +} + +void GLContextGetDefaultIndexed( GLClipPlaneEnable_t *dst, int index ) +{ + dst->enable = 0; +} + + + +// --- GLClipPlaneEquation --- +void GLContextSetIndexed( GLClipPlaneEquation_t *src, int index ) +{ + // shove into glGlipPlane + GLdouble coeffs[4] = { src->x, src->y, src->z, src->w }; + + glClipPlane( GL_CLIP_PLANE0 + index, coeffs ); + GLMCheckError(); +} + +void GLContextGetIndexed( GLClipPlaneEquation_t *dst, int index ) +{ + Debugger(); // do this later +// glClipPlane( GL_CLIP_PLANE0 + index, coeffs ); +// GLdouble coeffs[4] = { src->x, src->y, src->z, src->w }; +} + +void GLContextGetDefaultIndexed( GLClipPlaneEquation_t *dst, int index ) +{ + dst->x = 1.0; + dst->y = 0.0; + dst->z = 0.0; + dst->w = 0.0; +} + + +// --- GLColorMaskSingle --- +void GLContextSet( GLColorMaskSingle_t *src ) +{ + glColorMask( src->r, src->g, src->b, src->a ); +} + +void GLContextGet( GLColorMaskSingle_t *dst ) +{ + glGetBooleanv( GL_COLOR_WRITEMASK, (GLboolean*)&dst->r); +} + +void GLContextGetDefault( GLColorMaskSingle_t *dst ) +{ + dst->r = dst->g = dst->b = dst->a = 1; +} + + +// --- GLColorMaskMultiple --- +void GLContextSetIndexed( GLColorMaskMultiple_t *src, int index ) +{ + // FIXME: this call is not in the Leopard headers. A runtime-lookup will be needed. + pfnglColorMaskIndexedEXT ( index, src->r, src->g, src->b, src->a ); +} + +void GLContextGetIndexed( GLColorMaskMultiple_t *dst, int index ) +{ + // FIXME: this call is not in the Leopard headers. A runtime-lookup will be needed. + glGetBooleanIndexedvEXT ( GL_COLOR_WRITEMASK, index, (GLboolean*)&dst->r ); +} + +void GLContextGetDefaultIndexed( GLColorMaskMultiple_t *dst, int index ) +{ + dst->r = dst->g = dst->b = dst->a = 1; +} + + +// --- GLBlendEnable --- +void GLContextSet( GLBlendEnable_t *src ) +{ + glSetEnable( GL_BLEND, src->enable ); +} + +void GLContextGet( GLBlendEnable_t *dst ) +{ + dst->enable = glIsEnabled( GL_BLEND ); +} + +void GLContextGetDefault( GLBlendEnable_t *dst ) +{ + dst->enable = GL_FALSE; +} + + +// --- GLBlendFactor --- +void GLContextSet( GLBlendFactor_t *src ) +{ + glBlendFunc ( src->srcfactor, src->dstfactor ); +} + +void GLContextGet( GLBlendFactor_t *dst ) +{ + glGetEnumv ( GL_BLEND_SRC, &dst->srcfactor ); + glGetEnumv ( GL_BLEND_DST, &dst->dstfactor ); +} + +void GLContextGetDefault( GLBlendFactor_t *dst ) +{ + dst->srcfactor = GL_ONE; + dst->dstfactor = GL_ZERO; +} + + +// --- GLBlendEquation --- +void GLContextSet( GLBlendEquation_t *src ) +{ + glBlendEquation ( src->equation ); +} + +void GLContextGet( GLBlendEquation_t *dst ) +{ + glGetEnumv ( GL_BLEND_EQUATION, &dst->equation ); +} + +void GLContextGetDefault( GLBlendEquation_t *dst ) +{ + dst->equation = GL_FUNC_ADD; +} + + +// --- GLBlendColor --- +void GLContextSet( GLBlendColor_t *src ) +{ + glBlendColor ( src->r, src->g, src->b, src->a ); +} + +void GLContextGet( GLBlendColor_t *dst ) +{ + glGetFloatv ( GL_BLEND_COLOR, &dst->r ); +} + +void GLContextGetDefault( GLBlendColor_t *dst ) +{ + //solid white + dst->r = dst->g = dst->b = dst->a = 1.0; +} + + +// --- GLBlendEnableSRGB --- + +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_COLOR_ATTACHMENT0 0x8CE0 + +void GLContextSet( GLBlendEnableSRGB_t *src ) +{ + #if GLMDEBUG + // just check in debug... this is too expensive to look at on MTGL + if (src->enable) + { + GLboolean srgb_capable = false; + glGetBooleanv( GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &srgb_capable); + + if (src->enable && !srgb_capable) + { + GLMPRINTF(("-Z- srgb-state-set FBO conflict: attempt to enable SRGB on non SRGB capable FBO config")); + } + } + #endif + // this query is not useful unless you have the ARB_framebuffer_srgb ext. + //GLint encoding = 0; + //pfnglGetFramebufferAttachmentParameteriv( GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &encoding ); + //GLMCheckError(); + + glSetEnable( GL_FRAMEBUFFER_SRGB_EXT, src->enable ); + GLMCheckError(); +} + +void GLContextGet( GLBlendEnableSRGB_t *dst ) +{ + //dst->enable = glIsEnabled( GL_FRAMEBUFFER_SRGB_EXT ); + dst->enable = true; // wtf ? +} + +void GLContextGetDefault( GLBlendEnableSRGB_t *dst ) +{ + dst->enable = GL_FALSE; +} + + +// --- GLDepthTestEnable --- +void GLContextSet( GLDepthTestEnable_t *src ) +{ + glSetEnable( GL_DEPTH_TEST, src->enable ); +} + +void GLContextGet( GLDepthTestEnable_t *dst ) +{ + dst->enable = glIsEnabled( GL_DEPTH_TEST ); +} + +void GLContextGetDefault( GLDepthTestEnable_t *dst ) +{ + dst->enable = GL_FALSE; +} + + +// --- GLDepthFunc --- +void GLContextSet( GLDepthFunc_t *src ) +{ + glDepthFunc ( src->func ); +} + +void GLContextGet( GLDepthFunc_t *dst ) +{ + glGetEnumv ( GL_DEPTH_FUNC, &dst->func ); +} + +void GLContextGetDefault( GLDepthFunc_t *dst ) +{ + dst->func = GL_GEQUAL; +} + + +// --- GLDepthMask --- +void GLContextSet( GLDepthMask_t *src ) +{ + glDepthMask ( src->mask ); +} + +void GLContextGet( GLDepthMask_t *dst ) +{ + glGetBooleanv ( GL_DEPTH_WRITEMASK, (GLboolean*)&dst->mask ); +} + +void GLContextGetDefault( GLDepthMask_t *dst ) +{ + dst->mask = GL_TRUE; +} + + +// --- GLStencilTestEnable --- +void GLContextSet( GLStencilTestEnable_t *src ) +{ + glSetEnable( GL_STENCIL_TEST, src->enable ); +} + +void GLContextGet( GLStencilTestEnable_t *dst ) +{ + dst->enable = glIsEnabled( GL_STENCIL_TEST ); +} + +void GLContextGetDefault( GLStencilTestEnable_t *dst ) +{ + dst->enable = GL_FALSE; +} + + +// --- GLStencilFunc --- +void GLContextSet( GLStencilFunc_t *src ) +{ + glStencilFuncSeparateATI( src->frontfunc, src->backfunc, src->ref, src->mask); +} + +void GLContextGet( GLStencilFunc_t *dst ) +{ + glGetEnumv ( GL_STENCIL_FUNC, &dst->frontfunc ); + glGetEnumv ( GL_STENCIL_BACK_FUNC_ATI, &dst->backfunc ); + glGetIntegerv ( GL_STENCIL_REF, &dst->ref ); + glGetIntegerv ( GL_STENCIL_VALUE_MASK, (GLint*)&dst->mask ); +} + +void GLContextGetDefault( GLStencilFunc_t *dst ) +{ + dst->frontfunc = GL_ALWAYS; + dst->backfunc = GL_ALWAYS; + dst->ref = 0; + dst->mask = 0xFFFFFFFF; +} + + +// --- GLStencilOp --- indexed 0=front, 1=back + +void GLContextSetIndexed( GLStencilOp_t *src, int index ) +{ + GLenum face = (index==0) ? GL_FRONT : GL_BACK; + + glStencilOpSeparateATI( face, src->sfail, src->dpfail, src->dppass ); +} + +void GLContextGetIndexed( GLStencilOp_t *dst, int index ) +{ + GLenum face = (index==0) ? GL_FRONT : GL_BACK; + + glGetEnumv ( (index==0) ? GL_STENCIL_FAIL : GL_STENCIL_BACK_FAIL_ATI, &dst->sfail ); + glGetEnumv ( (index==0) ? GL_STENCIL_PASS_DEPTH_FAIL : GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI, &dst->dpfail ); + glGetEnumv ( (index==0) ? GL_STENCIL_PASS_DEPTH_PASS : GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI, &dst->dppass ); +} + +void GLContextGetDefaultIndexed( GLStencilOp_t *dst, int index ) +{ + dst->sfail = dst->dpfail = dst->dppass = GL_KEEP; +} + + +// --- GLStencilWriteMask --- +void GLContextSet( GLStencilWriteMask_t *src ) +{ + glStencilMask( src->mask ); +} + +void GLContextGet( GLStencilWriteMask_t *dst ) +{ + glGetIntegerv ( GL_STENCIL_WRITEMASK, &dst->mask ); +} + +void GLContextGetDefault( GLStencilWriteMask_t *dst ) +{ + dst->mask = 0xFFFFFFFF; +} + + +// --- GLClearColor --- +void GLContextSet( GLClearColor_t *src ) +{ + glClearColor( src->r, src->g, src->b, src->a ); +} + +void GLContextGet( GLClearColor_t *dst ) +{ + glGetFloatv ( GL_COLOR_CLEAR_VALUE, &dst->r ); +} + +void GLContextGetDefault( GLClearColor_t *dst ) +{ + dst->r = dst->g = dst->b = 0.5; + dst->a = 1.0; +} + + +// --- GLClearDepth --- +void GLContextSet( GLClearDepth_t *src ) +{ + glClearDepth ( src->d ); +} + +void GLContextGet( GLClearDepth_t *dst ) +{ + glGetDoublev ( GL_DEPTH_CLEAR_VALUE, &dst->d ); +} + +void GLContextGetDefault( GLClearDepth_t *dst ) +{ + dst->d = 1.0; +} + + +// --- GLClearStencil --- +void GLContextSet( GLClearStencil_t *src ) +{ + glClearStencil( src->s ); +} + +void GLContextGet( GLClearStencil_t *dst ) +{ + glGetIntegerv ( GL_STENCIL_CLEAR_VALUE, &dst->s ); +} + +void GLContextGetDefault( GLClearStencil_t *dst ) +{ + dst->s = 0; +} + +//=============================================================================== + + +GLMTester::GLMTester(GLMTestParams *params) +{ + m_params = *params; + + m_drawFBO = NULL; + m_drawColorTex = NULL; + m_drawDepthTex = NULL; +} + +GLMTester::~GLMTester() +{ +} + +void GLMTester::StdSetup( void ) +{ + GLMContext *ctx = m_params.m_ctx; + + m_drawWidth = 1024; + m_drawHeight = 768; + + // make an FBO to draw into and activate it. no depth buffer yet + m_drawFBO = ctx->NewFBO(); + + // make color buffer texture + + GLMTexLayoutKey colorkey; + CGLMTex *colortex; + memset( &colorkey, 0, sizeof(colorkey) ); + + colorkey.m_texGLTarget = GL_TEXTURE_2D; + colorkey.m_xSize = m_drawWidth; + colorkey.m_ySize = m_drawHeight; + colorkey.m_zSize = 1; + + colorkey.m_texFormat = D3DFMT_A8R8G8B8; + colorkey.m_texFlags = kGLMTexRenderable; + + m_drawColorTex = ctx->NewTex( &colorkey ); + + // do not leave that texture bound on the TMU + ctx->BindTexToTMU(NULL, 0 ); + + + // attach color to FBO + GLMFBOTexAttachParams colorParams; + memset( &colorParams, 0, sizeof(colorParams) ); + + colorParams.m_tex = m_drawColorTex; + colorParams.m_face = 0; + colorParams.m_mip = 0; + colorParams.m_zslice= 0; // for clarity.. + + m_drawFBO->TexAttach( &colorParams, kAttColor0 ); + + // check it. + bool ready = m_drawFBO->IsReady(); + InternalError( !ready, "drawing FBO no go"); + + // bind it + ctx->BindFBOToCtx( m_drawFBO, GL_READ_FRAMEBUFFER_EXT ); + ctx->BindFBOToCtx( m_drawFBO, GL_DRAW_FRAMEBUFFER_EXT ); + + glViewport(0, 0, (GLsizei) m_drawWidth, (GLsizei) m_drawHeight ); + CheckGLError("stdsetup viewport"); + + glScissor( 0,0, (GLsizei) m_drawWidth, (GLsizei) m_drawHeight ); + CheckGLError("stdsetup scissor"); + + glOrtho( -1,1, -1,1, -1,1 ); + CheckGLError("stdsetup ortho"); + + // activate debug font + ctx->GenDebugFontTex(); +} + +void GLMTester::StdCleanup( void ) +{ + GLMContext *ctx = m_params.m_ctx; + + // unbind + ctx->BindFBOToCtx( NULL, GL_READ_FRAMEBUFFER_EXT ); + ctx->BindFBOToCtx( NULL, GL_DRAW_FRAMEBUFFER_EXT ); + + // del FBO + if (m_drawFBO) + { + ctx->DelFBO( m_drawFBO ); + m_drawFBO = NULL; + } + + // del tex + if (m_drawColorTex) + { + ctx->DelTex( m_drawColorTex ); + m_drawColorTex = NULL; + } + + if (m_drawDepthTex) + { + ctx->DelTex( m_drawDepthTex ); + m_drawDepthTex = NULL; + } +} + + +void GLMTester::Clear( void ) +{ + GLMContext *ctx = m_params.m_ctx; + ctx->MakeCurrent(); + + glViewport(0, 0, (GLsizei) m_drawWidth, (GLsizei) m_drawHeight ); + glScissor( 0,0, (GLsizei) m_drawWidth, (GLsizei) m_drawHeight ); + glOrtho( -1,1, -1,1, -1,1 ); + CheckGLError("clearing viewport"); + + // clear to black + GLfloat clear_color[4] = { 0.0f, 0.0f, 0.0, 1.0f }; + glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); + CheckGLError("clearing color"); + + glClear(GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT+GL_STENCIL_BUFFER_BIT); + CheckGLError("clearing"); + + //glFinish(); + //CheckGLError("clear finish"); +} + +void GLMTester::Present( int seed ) +{ + GLMContext *ctx = m_params.m_ctx; + ctx->Present( m_drawColorTex ); + +} + +void GLMTester::CheckGLError( const char *comment ) +{ + char errbuf[1024]; + + //borrowed from GLMCheckError.. slightly different + + if (!comment) + { + comment = ""; + } + + GLenum errorcode = (GLenum)glGetError(); + GLenum errorcode2 = 0; + if ( errorcode != GL_NO_ERROR ) + { + const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); + const char *decodedStr2 = ""; + + if ( errorcode == GL_INVALID_FRAMEBUFFER_OPERATION_EXT ) + { + // dig up the more detailed FBO status + errorcode2 = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ); + + decodedStr2 = GLMDecode( eGL_ERROR, errorcode2 ); + + sprintf( errbuf, "\n%s - GL Error %08x/%08x = '%s / %s'", comment, errorcode, errorcode2, decodedStr, decodedStr2 ); + } + else + { + sprintf( errbuf, "\n%s - GL Error %08x = '%s'", comment, errorcode, decodedStr ); + } + + if ( m_params.m_glErrToConsole ) + { + printf("%s", errbuf ); + } + + if ( m_params.m_glErrToDebugger ) + { + Debugger(); + } + } +} + +void GLMTester::InternalError( int errcode, const char *comment ) +{ + if (errcode) + { + if (m_params.m_intlErrToConsole) + { + printf("\%s - error %d", comment, errcode ); + } + + if (m_params.m_intlErrToDebugger) + { + Debugger(); + } + } +} + + +void GLMTester::RunTests( void ) +{ + int *testList = m_params.m_testList; + + while( (*testList >=0) && (*testList < 20) ) + { + RunOneTest( *testList++ ); + } +} + +void GLMTester::RunOneTest( int testindex ) +{ + // this might be better with 'ptmf' style + switch(testindex) + { + case 0: Test0(); break; + case 1: Test1(); break; + case 2: Test2(); break; + case 3: Test3(); break; + + default: + Debugger(); // unrecognized + } +} + +// ##################################################################################################################### + +// some fixed lists which may be useful to all tests + +D3DFORMAT g_drawTexFormatsGLMT[] = // -1 terminated +{ + D3DFMT_A8R8G8B8, + D3DFMT_A4R4G4B4, + D3DFMT_X8R8G8B8, + D3DFMT_X1R5G5B5, + D3DFMT_A1R5G5B5, + D3DFMT_L8, + D3DFMT_A8L8, + D3DFMT_R8G8B8, + D3DFMT_A8, + D3DFMT_R5G6B5, + D3DFMT_DXT1, + D3DFMT_DXT3, + D3DFMT_DXT5, + D3DFMT_A32B32G32R32F, + D3DFMT_A16B16G16R16, + + (D3DFORMAT)-1 +}; + +D3DFORMAT g_fboColorTexFormatsGLMT[] = // -1 terminated +{ + D3DFMT_A8R8G8B8, + //D3DFMT_A4R4G4B4, //unsupported + D3DFMT_X8R8G8B8, + D3DFMT_X1R5G5B5, + //D3DFMT_A1R5G5B5, //unsupported + D3DFMT_A16B16G16R16F, + D3DFMT_A32B32G32R32F, + D3DFMT_R5G6B5, + + (D3DFORMAT)-1 +}; + +D3DFORMAT g_fboDepthTexFormatsGLMT[] = // -1 terminated, but note 0 for "no depth" mode +{ + (D3DFORMAT)0, + D3DFMT_D16, + D3DFMT_D24X8, + D3DFMT_D24S8, + + (D3DFORMAT)-1 +}; + + +// ##################################################################################################################### + +void GLMTester::Test0( void ) +{ + // make and delete a bunch of textures. + // lock and unlock them. + // use various combos of - + + // √texel format + // √2D | 3D | cube map + // √mipped / not + // √POT / NPOT + // large / small / square / rect + // square / rect + + GLMContext *ctx = m_params.m_ctx; + ctx->MakeCurrent(); + + std::vector< CGLMTex* > testTextures; // will hold all the built textures + + // test stage loop + // 0 is creation + // 1 is lock/unlock + // 2 is deletion + + for( int teststage = 0; teststage < 3; teststage++) + { + int innerindex = 0; // increment at stage switch + // format loop + for( D3DFORMAT *fmtPtr = g_drawTexFormatsGLMT; *fmtPtr != ((D3DFORMAT)-1); fmtPtr++ ) + { + // form loop + GLenum forms[] = { GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP, (GLenum)-1 }; + + for( GLenum *formPtr = forms; *formPtr != ((GLenum)-1); formPtr++ ) + { + // mip loop + for( int mipped = 0; mipped < 2; mipped++ ) + { + // large / square / pot loop + // &4 == large &2 == square &1 == POT + // NOTE you *have to be square* for cube maps. + + for( int aspect = 0; aspect < 8; aspect++ ) + { + switch( teststage ) + { + case 0: + { + GLMTexLayoutKey key; + memset( &key, 0, sizeof(key) ); + + key.m_texGLTarget = *formPtr; + key.m_texFormat = *fmtPtr; + if (mipped) + key.m_texFlags |= kGLMTexMipped; + + // assume big, square, POT, and 3D, then adjust as needed + key.m_xSize = key.m_ySize = key.m_zSize = 256; + + if ( !(aspect&4) ) // big or little ? + { + // little + key.m_xSize >>= 2; + key.m_ySize >>= 2; + key.m_zSize >>= 2; + } + + if ( key.m_texGLTarget != GL_TEXTURE_CUBE_MAP ) + { + if ( !(aspect & 2) ) // square or rect? + { + // rect + key.m_ySize >>= 1; + key.m_zSize >>= 2; + } + } + + if ( !(aspect&1) ) // POT or NPOT? + { + // NPOT + key.m_xSize += 56; + key.m_ySize += 56; + key.m_zSize += 56; + } + + // 2D, 3D, cube map ? + if (key.m_texGLTarget!=GL_TEXTURE_3D) + { + // 2D or cube map: flatten Z extent to one texel + key.m_zSize = 1; + } + else + { + // 3D: knock down Z quite a bit so our test case does not run out of RAM + key.m_zSize >>= 3; + if (!key.m_zSize) + { + key.m_zSize = 1; + } + } + + CGLMTex *newtex = ctx->NewTex( &key ); + CheckGLError( "tex create test"); + InternalError( newtex==NULL, "tex create test" ); + + testTextures.push_back( newtex ); + printf("\n[%5d] created tex %s",innerindex,newtex->m_layout->m_layoutSummary ); + } + break; + + case 1: + { + CGLMTex *ptex = testTextures[innerindex]; + + for( int face=0; face m_layout->m_faceCount; face++) + { + for( int mip=0; mip m_layout->m_mipCount; mip++) + { + GLMTexLockParams lockreq; + + lockreq.m_tex = ptex; + lockreq.m_face = face; + lockreq.m_mip = mip; + + GLMTexLayoutSlice *slice = &ptex->m_layout->m_slices[ ptex->CalcSliceIndex( face, mip ) ]; + + lockreq.m_region.xmin = lockreq.m_region.ymin = lockreq.m_region.zmin = 0; + lockreq.m_region.xmax = slice->m_xSize; + lockreq.m_region.ymax = slice->m_ySize; + lockreq.m_region.zmax = slice->m_zSize; + + char *lockAddress; + int yStride; + int zStride; + + ptex->Lock( &lockreq, &lockAddress, &yStride, &zStride ); + CheckGLError( "tex lock test"); + InternalError( lockAddress==NULL, "null lock address"); + + // write some texels of this flavor: + // red 75% green 40% blue 15% alpha 80% + + GLMGenTexelParams gtp; + + gtp.m_format = ptex->m_layout->m_format->m_d3dFormat; + gtp.m_dest = lockAddress; + gtp.m_chunkCount = (slice->m_xSize * slice->m_ySize * slice->m_zSize) / (ptex->m_layout->m_format->m_chunkSize * ptex->m_layout->m_format->m_chunkSize); + gtp.m_byteCountLimit = slice->m_storageSize; + gtp.r = 0.75; + gtp.g = 0.40; + gtp.b = 0.15; + gtp.a = 0.80; + + GLMGenTexels( >p ); + + InternalError( gtp.m_bytesWritten != gtp.m_byteCountLimit, "byte count mismatch from GLMGenTexels" ); + } + } + + for( int face=0; face m_layout->m_faceCount; face++) + { + for( int mip=0; mip m_layout->m_mipCount; mip++) + { + GLMTexLockParams unlockreq; + + unlockreq.m_tex = ptex; + unlockreq.m_face = face; + unlockreq.m_mip = mip; + + // region need not matter for unlocks + unlockreq.m_region.xmin = unlockreq.m_region.ymin = unlockreq.m_region.zmin = 0; + unlockreq.m_region.xmax = unlockreq.m_region.ymax = unlockreq.m_region.zmax = 0; + + char *lockAddress; + int yStride; + int zStride; + + ptex->Unlock( &unlockreq ); + + CheckGLError( "tex unlock test"); + } + } + printf("\n[%5d] locked/wrote/unlocked tex %s",innerindex, ptex->m_layout->m_layoutSummary ); + } + break; + + case 2: + { + CGLMTex *dtex = testTextures[innerindex]; + + printf("\n[%5d] deleting tex %s",innerindex, dtex->m_layout->m_layoutSummary ); + ctx->DelTex( dtex ); + CheckGLError( "tex delete test"); + } + break; + } // end stage switch + innerindex++; + } // end aspect loop + } // end mip loop + } // end form loop + } // end format loop + } // end stage loop +} + +// ##################################################################################################################### +void GLMTester::Test1( void ) +{ + // FBO exercises + GLMContext *ctx = m_params.m_ctx; + ctx->MakeCurrent(); + + // FBO color format loop + for( D3DFORMAT *colorFmtPtr = g_fboColorTexFormatsGLMT; *colorFmtPtr != ((D3DFORMAT)-1); colorFmtPtr++ ) + { + // FBO depth format loop + for( D3DFORMAT *depthFmtPtr = g_fboDepthTexFormatsGLMT; *depthFmtPtr != ((D3DFORMAT)-1); depthFmtPtr++ ) + { + // mip loop + for( int mipped = 0; mipped < 2; mipped++ ) + { + GLenum forms[] = { GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP, (GLenum)-1 }; + + // form loop + for( GLenum *formPtr = forms; *formPtr != ((GLenum)-1); formPtr++ ) + { + //=============================================== make an FBO + CGLMFBO *fbo = ctx->NewFBO(); + + //=============================================== make a color texture + GLMTexLayoutKey colorkey; + memset( &colorkey, 0, sizeof(colorkey) ); + + switch(*formPtr) + { + case GL_TEXTURE_2D: + colorkey.m_texGLTarget = GL_TEXTURE_2D; + colorkey.m_xSize = 800; + colorkey.m_ySize = 600; + colorkey.m_zSize = 1; + break; + + case GL_TEXTURE_3D: + colorkey.m_texGLTarget = GL_TEXTURE_3D; + colorkey.m_xSize = 800; + colorkey.m_ySize = 600; + colorkey.m_zSize = 32; + break; + + case GL_TEXTURE_CUBE_MAP: + colorkey.m_texGLTarget = GL_TEXTURE_CUBE_MAP; + colorkey.m_xSize = 800; + colorkey.m_ySize = 800; // heh, cube maps have to have square sides... + colorkey.m_zSize = 1; + break; + } + + colorkey.m_texFormat = *colorFmtPtr; + colorkey.m_texFlags = kGLMTexRenderable; + // decide if we want mips + if (mipped) + { + colorkey.m_texFlags |= kGLMTexMipped; + } + + CGLMTex *colorTex = ctx->NewTex( &colorkey ); + // Note that GLM will notice the renderable flag, and force texels to be written + // so the FBO will be complete + + //=============================================== attach color + GLMFBOTexAttachParams colorParams; + memset( &colorParams, 0, sizeof(colorParams) ); + + colorParams.m_tex = colorTex; + colorParams.m_face = (colorkey.m_texGLTarget == GL_TEXTURE_CUBE_MAP) ? 2 : 0; // just steer to an alternate face as a test + + colorParams.m_mip = (colorkey.m_texFlags & kGLMTexMipped) ? 2 : 0; // pick non-base mip slice + + colorParams.m_zslice= (colorkey.m_texGLTarget == GL_TEXTURE_3D) ? 3 : 0; // just steer to an alternate slice as a test; + + fbo->TexAttach( &colorParams, kAttColor0 ); + + + //=============================================== optional depth tex + CGLMTex *depthTex = NULL; + + if (*depthFmtPtr > 0 ) + { + GLMTexLayoutKey depthkey; + memset( &depthkey, 0, sizeof(depthkey) ); + + depthkey.m_texGLTarget = GL_TEXTURE_2D; + depthkey.m_xSize = colorkey.m_xSize >> colorParams.m_mip; // scale depth tex to match color tex + depthkey.m_ySize = colorkey.m_ySize >> colorParams.m_mip; + depthkey.m_zSize = 1; + + depthkey.m_texFormat = *depthFmtPtr; + depthkey.m_texFlags = kGLMTexRenderable | kGLMTexIsDepth; // no mips. + if (depthkey.m_texFormat==D3DFMT_D24S8) + { + depthkey.m_texFlags |= kGLMTexIsStencil; + } + + depthTex = ctx->NewTex( &depthkey ); + + + //=============================================== attach depth + GLMFBOTexAttachParams depthParams; + memset( &depthParams, 0, sizeof(depthParams) ); + + depthParams.m_tex = depthTex; + depthParams.m_face = 0; + depthParams.m_mip = 0; + depthParams.m_zslice= 0; + + EGLMFBOAttachment depthAttachIndex = (depthkey.m_texFlags & kGLMTexIsStencil) ? kAttDepthStencil : kAttDepth; + fbo->TexAttach( &depthParams, depthAttachIndex ); + } + + printf("\n FBO:\n color tex %s\n depth tex %s", + colorTex->m_layout->m_layoutSummary, + depthTex ? depthTex->m_layout->m_layoutSummary : "none" + ); + + // see if FBO is happy + bool ready = fbo->IsReady(); + + printf("\n -> %s\n", ready ? "pass" : "fail" ); + + // unbind + ctx->BindFBOToCtx( NULL, GL_READ_FRAMEBUFFER_EXT ); + ctx->BindFBOToCtx( NULL, GL_DRAW_FRAMEBUFFER_EXT ); + + // del FBO + ctx->DelFBO(fbo); + + // del texes + ctx->DelTex( colorTex ); + if (depthTex) ctx->DelTex( depthTex ); + } // end form loop + } // end mip loop + } // end depth loop + } // end color loop +} + +// ##################################################################################################################### + +static int selftest2_seed = 0; // inc this every run to force main thread to teardown/reset display view +void GLMTester::Test2( void ) +{ + GLMContext *ctx = m_params.m_ctx; + ctx->MakeCurrent(); + + this->StdSetup(); // default test case drawing setup + + // draw stuff (loop...) + for( int i=0; iDrawDebugText( posx, posy, 0.0f, charwidth, charheight, text ); + } + glFinish(); + CheckGLError("test2 finish"); + + this->Present( selftest2_seed ); + } + + this->StdCleanup(); + + selftest2_seed++; +} + +// ##################################################################################################################### + +static char g_testVertexProgram01 [] = +{ + "!!ARBvp1.0 \n" + "TEMP vertexClip; \n" + "DP4 vertexClip.x, state.matrix.mvp.row[0], vertex.position; \n" + "DP4 vertexClip.y, state.matrix.mvp.row[1], vertex.position; \n" + "DP4 vertexClip.z, state.matrix.mvp.row[2], vertex.position; \n" + "DP4 vertexClip.w, state.matrix.mvp.row[3], vertex.position; \n" + "ADD vertexClip.y, vertexClip.x, vertexClip.y; \n" + "MOV result.position, vertexClip; \n" + "MOV result.color, vertex.color; \n" + "MOV result.texcoord[0], vertex.texcoord; \n" + "END \n" +}; + +static char g_testFragmentProgram01 [] = +{ + "!!ARBfp1.0 \n" + "TEMP color; \n" + "MUL color, fragment.texcoord[0].y, 2.0; \n" + "ADD color, 1.0, -color; \n" + "ABS color, color; \n" + "ADD result.color, 1.0, -color; \n" + "MOV result.color.a, 1.0; \n" + "END \n" +}; + + +// generic attrib versions.. + +static char g_testVertexProgram01_GA [] = +{ + "!!ARBvp1.0 \n" + "TEMP vertexClip; \n" + "DP4 vertexClip.x, state.matrix.mvp.row[0], vertex.attrib[0]; \n" + "DP4 vertexClip.y, state.matrix.mvp.row[1], vertex.attrib[0]; \n" + "DP4 vertexClip.z, state.matrix.mvp.row[2], vertex.attrib[0]; \n" + "DP4 vertexClip.w, state.matrix.mvp.row[3], vertex.attrib[0]; \n" + "ADD vertexClip.y, vertexClip.x, vertexClip.y; \n" + "MOV result.position, vertexClip; \n" + "MOV result.color, vertex.attrib[3]; \n" + "MOV result.texcoord[0], vertex.attrib[8]; \n" + "END \n" +}; + +static char g_testFragmentProgram01_GA [] = +{ + "!!ARBfp1.0 \n" + "TEMP color; \n" + "TEX color, fragment.texcoord[0], texture[0], 2D;" + //"MUL color, fragment.texcoord[0].y, 2.0; \n" + //"ADD color, 1.0, -color; \n" + //"ABS color, color; \n" + //"ADD result.color, 1.0, -color; \n" + //"MOV result.color.a, 1.0; \n" + "MOV result.color, color; \n" + "END \n" +}; + + +void GLMTester::Test3( void ) +{ + /************************** + XXXXXXXXXXXXXXXXXXXXXX stale test code until we revise the program interface + + GLMContext *ctx = m_params.m_ctx; + ctx->MakeCurrent(); + + this->StdSetup(); // default test case drawing setup + + // make vertex&pixel shader + CGLMProgram *vprog = ctx->NewProgram( kGLMVertexProgram, g_testVertexProgram01_GA ); + ctx->BindProgramToCtx( kGLMVertexProgram, vprog ); + + CGLMProgram *fprog = ctx->NewProgram( kGLMFragmentProgram, g_testFragmentProgram01_GA ); + ctx->BindProgramToCtx( kGLMFragmentProgram, fprog ); + + // draw stuff (loop...) + for( int i=0; iDrawDebugText( posx, posy, 0.0f, charwidth, charheight, text ); + } + glFinish(); + CheckGLError("test3 finish"); + + this->Present( 3333 ); + } + + this->StdCleanup(); + *****************************/ +} + + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgr.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgr.h new file mode 100644 index 0000000..f748a13 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgr.h @@ -0,0 +1,1032 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// glmgr.h +// singleton class, common basis for managing GL contexts +// responsible for tracking adapters and contexts +// +//=============================================================================== + +#ifndef GLMGR_H +#define GLMGR_H + +#pragma once + +#include "glmdebug.h" +#include "glmdisplay.h" +#include "glmgrext.h" +#include "glmgrbasics.h" +#include "cglmtex.h" +#include "cglmfbo.h" +#include "cglmprogram.h" +#include "cglmbuffer.h" +#include "cglmquery.h" + + + + +//=============================================================================== +// glue to call out to Obj-C land (these are in glmgrcocoa.mm) + +bool NewNSGLContext( unsigned long *attribs, PseudoNSGLContextPtr nsglShareCtx, PseudoNSGLContextPtr *nsglCtxOut, CGLContextObj *cglCtxOut ); +CGLContextObj GetCGLContextFromNSGL( PseudoNSGLContextPtr nsglCtx ); +void DelNSGLContext( PseudoNSGLContextPtr nsglCtx ); + + +//=============================================================================== + +// parrot the D3D present parameters, more or less... "adapter" translates into "active display index" per the m_activeDisplayCount below. +class GLMDisplayParams +{ + public: + + // presumption, these indices are in sync with the current display DB that GLMgr has handy + //int m_rendererIndex; // index of renderer (-1 if root context) + //int m_displayIndex; // index of display in renderer - for FS + //int m_modeIndex; // index of mode in display - for FS + + void *m_focusWindow; // (VD3DHWND aka WindowRef) - what window does this context display into + + bool m_fsEnable; // fullscreen on or not + bool m_vsyncEnable; // vsync on or not + + // height and width have to match the display mode info if full screen. + + uint m_backBufferWidth; // pixel width (aka screen h-resolution if full screen) + uint m_backBufferHeight; // pixel height (aka screen v-resolution if full screen) + D3DFORMAT m_backBufferFormat; // pixel format + uint m_multiSampleCount; // 0 means no MSAA, 2 means 2x MSAA, etc + // uint m_multiSampleQuality; // no MSAA quality control yet + + bool m_enableAutoDepthStencil; // generally set to 'TRUE' per CShaderDeviceDx8::SetPresentParameters + D3DFORMAT m_autoDepthStencilFormat; + + uint m_fsRefreshHz; // if full screen, this refresh rate (likely 0 for LCD's) + + //uint m_rootRendererID; // only used if m_rendererIndex is -1. + //uint m_rootDisplayMask; // only used if m_rendererIndex is -1. + + bool m_mtgl; // enable multi threaded GL driver +}; + +//=============================================================================== + +class GLMgr +{ +public: + + //=========================================================================== + // class methods - singleton + static void NewGLMgr( void ); // instantiate singleton.. + static GLMgr *aGLMgr( void ); // return singleton.. + static void DelGLMgr( void ); // tear down singleton.. + + //=========================================================================== + // plain methods + + #if 0 // turned all these off while new approach is coded + void RefreshDisplayDB( void ); // blow away old display DB, make a new one + GLMDisplayDB *GetDisplayDB( void ); // get a ptr to the one GLMgr keeps. only valid til next refresh. + + // eligible renderers will be ranked by desirability starting at index 0 within the db + // within each renderer, eligible displays will be ranked some kind of desirability (area? dist from menu bar?) + // within each display, eligible modes will be ranked by descending areas + + // calls supplying indices are implicitly making reference to the current DB + bool CaptureDisplay( int rendIndex, int displayIndex, bool captureAll ); // capture one display or all displays + void ReleaseDisplays( void ); // release all captures + + int GetDisplayMode( int rendIndex, int displayIndex ); // retrieve current display res (returns modeIndex) + void SetDisplayMode( GLMDisplayParams *params ); // set the display res (only useful for FS) + #endif + + GLMContext *NewContext( GLMDisplayParams *params ); // this will have to change + void DelContext( GLMContext *context ); + + // with usage of CGLMacro.h we could dispense with the "current context" thing + // and just declare a member variable of GLMContext, allowing each glXXX call to be routed directly + // to the correct context + void SetCurrentContext( GLMContext *context ); // make current in calling thread only + GLMContext *GetCurrentContext( void ); + +protected: + friend class GLMContext; + + GLMgr(); + ~GLMgr(); +}; + + +//===========================================================================// + +// helper function to do enable or disable in one step +inline void glSetEnable( GLenum which, bool enable ) +{ + if (enable) + glEnable(which); + else + glDisable(which); +} + +// helper function for int vs enum clarity +inline void glGetEnumv( GLenum which, GLenum *dst ) +{ + glGetIntegerv( which, (int*)dst ); +} + +//===========================================================================// +// +// types to support the GLMContext +// +//===========================================================================// + +// Each state set/get path we are providing caching for, needs its own struct and a comparison operator. +// we also provide an enum of how many such types there are, handy for building dirty masks etc. + +// shorthand macros +#define EQ(fff) ( (src.fff) == (fff) ) + +//rasterizer +struct GLAlphaTestEnable_t { GLint enable; bool operator==(const GLAlphaTestEnable_t& src) const { return EQ(enable); } }; +struct GLAlphaTestFunc_t { GLenum func; GLclampf ref; bool operator==(const GLAlphaTestFunc_t& src) const { return EQ(func) && EQ(ref); } }; +struct GLCullFaceEnable_t { GLint enable; bool operator==(const GLCullFaceEnable_t& src) const { return EQ(enable); } }; +struct GLCullFrontFace_t { GLenum value; bool operator==(const GLCullFrontFace_t& src) const { return EQ(value); } }; +struct GLPolygonMode_t { GLenum values[2]; bool operator==(const GLPolygonMode_t& src) const { return EQ(values[0]) && EQ(values[1]); } }; +struct GLDepthBias_t { GLfloat factor; GLfloat units; bool operator==(const GLDepthBias_t& src) const { return EQ(factor) && EQ(units); } }; +struct GLScissorEnable_t { GLint enable; bool operator==(const GLScissorEnable_t& src) const { return EQ(enable); } }; +struct GLScissorBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLScissorBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; +struct GLAlphaToCoverageEnable_t{ GLint enable; bool operator==(const GLAlphaToCoverageEnable_t& src) const { return EQ(enable); } }; +struct GLViewportBox_t { GLint x,y; GLsizei width, height; bool operator==(const GLViewportBox_t& src) const { return EQ(x) && EQ(y) && EQ(width) && EQ(height); } }; +struct GLViewportDepthRange_t { GLdouble near,far; bool operator==(const GLViewportDepthRange_t& src) const { return EQ(near) && EQ(far); } }; +struct GLClipPlaneEnable_t { GLint enable; bool operator==(const GLClipPlaneEnable_t& src) const { return EQ(enable); } }; +struct GLClipPlaneEquation_t { GLfloat x,y,z,w; bool operator==(const GLClipPlaneEquation_t& src) const { return EQ(x) && EQ(y) && EQ(z) && EQ(w); } }; + +//blend +struct GLColorMaskSingle_t { char r,g,b,a; bool operator==(const GLColorMaskSingle_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLColorMaskMultiple_t { char r,g,b,a; bool operator==(const GLColorMaskMultiple_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLBlendEnable_t { GLint enable; bool operator==(const GLBlendEnable_t& src) const { return EQ(enable); } }; +struct GLBlendFactor_t { GLenum srcfactor,dstfactor; bool operator==(const GLBlendFactor_t& src) const { return EQ(srcfactor) && EQ(dstfactor); } }; +struct GLBlendEquation_t { GLenum equation; bool operator==(const GLBlendEquation_t& src) const { return EQ(equation); } }; +struct GLBlendColor_t { GLfloat r,g,b,a; bool operator==(const GLBlendColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLBlendEnableSRGB_t { GLint enable; bool operator==(const GLBlendEnableSRGB_t& src) const { return EQ(enable); } }; + +//depth +struct GLDepthTestEnable_t { GLint enable; bool operator==(const GLDepthTestEnable_t& src) const { return EQ(enable); } }; +struct GLDepthFunc_t { GLenum func; bool operator==(const GLDepthFunc_t& src) const { return EQ(func); } }; +struct GLDepthMask_t { char mask; bool operator==(const GLDepthMask_t& src) const { return EQ(mask); } }; + +//stencil +struct GLStencilTestEnable_t { GLint enable; bool operator==(const GLStencilTestEnable_t& src) const { return EQ(enable); } }; +struct GLStencilFunc_t { GLenum frontfunc, backfunc; GLint ref; GLuint mask; bool operator==(const GLStencilFunc_t& src) const { return EQ(frontfunc) && EQ(backfunc) && EQ(ref) && EQ(mask); } }; +struct GLStencilOp_t { GLenum sfail; GLenum dpfail; GLenum dppass; bool operator==(const GLStencilOp_t& src) const { return EQ(sfail) && EQ(dpfail) && EQ(dppass); } }; +struct GLStencilWriteMask_t { GLint mask; bool operator==(const GLStencilWriteMask_t& src) const { return EQ(mask); } }; + +//clearing +struct GLClearColor_t { GLfloat r,g,b,a; bool operator==(const GLClearColor_t& src) const { return EQ(r) && EQ(g) && EQ(b) && EQ(a); } }; +struct GLClearDepth_t { GLdouble d; bool operator==(const GLClearDepth_t& src) const { return EQ(d); } }; +struct GLClearStencil_t { GLint s; bool operator==(const GLClearStencil_t& src) const { return EQ(s); } }; + +#undef EQ + +enum EGLMStateBlockType +{ + kGLAlphaTestEnable, + kGLAlphaTestFunc, + + kGLCullFaceEnable, + kGLCullFrontFace, + + kGLPolygonMode, + + kGLDepthBias, + + kGLScissorEnable, + kGLScissorBox, + + kGLViewportBox, + kGLViewportDepthRange, + + kGLClipPlaneEnable, + kGLClipPlaneEquation, + + kGLColorMaskSingle, + kGLColorMaskMultiple, + + kGLBlendEnable, + kGLBlendFactor, + kGLBlendEquation, + kGLBlendColor, + kGLBlendEnableSRGB, + + kGLDepthTestEnable, + kGLDepthFunc, + kGLDepthMask, + + kGLStencilTestEnable, + kGLStencilFunc, + kGLStencilOp, + kGLStencilWriteMask, + + kGLClearColor, + kGLClearDepth, + kGLClearStencil, + + kGLAlphaToCoverageEnable, + + kGLMStateBlockLimit +}; + +//===========================================================================// + +// templated functions representing GL R/W bottlenecks +// one set of set/get/getdefault is instantiated for each of the GL*** types above. + +// use these from the non array state objects +template void GLContextSet( T *src ); +template void GLContextGet( T *dst ); +template void GLContextGetDefault( T *dst ); + +// use these from the array state objects +template void GLContextSetIndexed( T *src, int index ); +template void GLContextGetIndexed( T *dst, int index ); +template void GLContextGetDefaultIndexed( T *dst, int index ); + +//===========================================================================// + +// caching state object template. One of these is instantiated in the context per unique struct type above +template class GLState +{ + public: + + GLState() + { + dirty = false; + memset( &data, 0, sizeof(data) ); + }; + + // write: client src into cache + // common case is both false. dirty is calculated, context write is deferred. + void Write( T *src, bool noCompare=false, bool noDefer=false ) + { + if (noCompare) + { + dirty = true; + } + else + { + // only == is implemented, so test for equal and negate + // note, you only set dirty if mismatch, you never clear it until flush + if ( !(data == *src) ) + { + dirty = true; + } + } + + data = *src; + + if (noDefer) + { + Flush( true ); // dirty becomes false + } + }; + + // write cache->context if dirty or forced. + void Flush( bool noDefer=false ) + { + if (dirty || noDefer) + { + GLContextSet( &data ); + GLMCheckError(); + // good place for some error checking here + dirty = false; + } + }; + + // default: write default value to cache, optionally write through + void Default( bool noDefer=false ) + { + GLContextGetDefault( &data ); // read default values directly to our cache copy + dirty = true; + Flush(noDefer); + }; + + // read: sel = 0 for cache, 1 for context + void Read( T *dst, int sel ) + { + if (sel==0) + { + *dst = data; + } + else + { + GLContextGet( dst ); + GLMCheckError(); + } + }; + + // check: verify that context equals cache, return true if mismatched or if illegal values seen + bool Check ( void ) + { + T temp; + bool result; + + GLContextGet( &temp ); + GLMCheckError(); + result = !(temp == data); + return result; + }; + + protected: + T data; + bool dirty; +}; + +// caching state object template - with multiple values behind it that are indexed +template class GLStateArray +{ + public: + + GLStateArray() + { + memset( &dirty, 0, sizeof(dirty) ); + memset( &data, 0, sizeof(data) ); + }; + + // write: client src into cache + // common case is both false. dirty is calculated, context write is deferred. + void WriteIndex( T *src, int index, bool noCompare=false, bool noDefer=false ) + { + if (noCompare) + { + dirty[index] = true; + } + else + { + // only == is implemented, so test for equal and negate + // note, you only set dirty if mismatch, you never clear it until flush + if (! (data[index] == *src) ) + { + dirty[index] = true; + } + } + + data[index] = *src; + + if (noDefer) + { + FlushIndex( index, true ); // dirty becomes false + } + }; + + // write cache->context if dirty or forced. + void FlushIndex( int index, bool noDefer=false ) + { + if (dirty[index] || noDefer) + { + GLContextSetIndexed( &data[index], index ); + GLMCheckError(); + dirty[index] = false; + } + }; + + // write all slots in the array + void Flush( bool noDefer=false ) + { + for( int i=0; i m_AlphaTestEnable; + + GLState m_AlphaTestFunc; + + GLState m_CullFaceEnable; + GLState m_CullFrontFace; + GLState m_PolygonMode; + + GLState m_DepthBias; + + GLStateArray m_ClipPlaneEnable; + GLStateArray m_ClipPlaneEquation; // dxabstract puts them directly into param slot 253(0) and 254(1) + + GLState m_ScissorEnable; + GLState m_ScissorBox; + + GLState m_AlphaToCoverageEnable; + + GLState m_ViewportBox; + GLState m_ViewportDepthRange; + + GLState m_ColorMaskSingle; + GLStateArray m_ColorMaskMultiple; // need an official constant for the color buffers limit + + GLState m_BlendEnable; + GLState m_BlendFactor; + GLState m_BlendEquation; + GLState m_BlendColor; + GLState m_BlendEnableSRGB; // write to this one to transmit intent to write SRGB encoded pixels to drawing FB + bool m_FakeBlendEnableSRGB; // writes to above will be shunted here if fake SRGB is in effect. + + GLState m_DepthTestEnable; + GLState m_DepthFunc; + GLState m_DepthMask; + + GLState m_StencilTestEnable; // global stencil test enable + GLState m_StencilFunc; // holds front and back stencil funcs + GLStateArray m_StencilOp; // indexed: 0=front 1=back + GLState m_StencilWriteMask; + + GLState m_ClearColor; + GLState m_ClearDepth; + GLState m_ClearStencil; + + // texture bindings and sampler setup + int m_activeTexture; // mirror for glActiveTexture + GLMTexSampler m_samplers[GLM_SAMPLER_COUNT]; + + // texture lock tracking - CGLMTex objects share usage of this + std::vector< GLMTexLockDesc > m_texLocks; + + // render target binding - check before draw + // similar to tex sampler mechanism, we track "bound" from "chosen for drawing" separately, + // so binding for creation/setup need not disrupt any notion of what will be used at draw time + + CGLMFBO *m_boundDrawFBO; // FBO on GL_DRAW_FRAMEBUFFER bind point + CGLMFBO *m_boundReadFBO; // FBO on GL_READ_FRAMEBUFFER bind point + // ^ both are set if you bind to GL_FRAMEBUFFER_EXT + + CGLMFBO *m_drawingFBO; // what FBO should be bound at draw time (to both read/draw bp's). + + CGLMFBO *m_blitReadFBO; + CGLMFBO *m_blitDrawFBO; // scratch FBO's for framebuffer blit + + CGLMFBO *m_scratchFBO[ kGLMScratchFBOCount ]; // general purpose FBO's for internal use + + std::vector< CGLMFBO* > m_fboTable; // each live FBO goes in the table + + // program bindings + EGLMProgramLang m_drawingLangAtFrameStart; // selector for start of frame (spills into m_drawingLang) + EGLMProgramLang m_drawingLang; // selector for which language we desire to draw with on the next batch + CGLMProgram *m_drawingProgram[ kGLMNumProgramTypes ]; + + GLMProgramParamsF m_programParamsF[ kGLMNumProgramTypes ]; + GLMProgramParamsB m_programParamsB[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used + GLMProgramParamsI m_programParamsI[ kGLMNumProgramTypes ]; // two banks, but only the vertex one is used + EGLMParamWriteMode m_paramWriteMode; + + CGLMProgram *m_nullFragmentProgram; // write opaque black. Activate when caller asks for null FP + + CGLMProgram *m_preloadTexVertexProgram; // programs to help preload textures (dummies) + CGLMProgram *m_preload2DTexFragmentProgram; + CGLMProgram *m_preload3DTexFragmentProgram; + CGLMProgram *m_preloadCubeTexFragmentProgram; + + CGLMProgram *m_boundProgram[ kGLMNumProgramTypes ]; + + CGLMShaderPairCache *m_pairCache; // GLSL only + CGLMShaderPair *m_boundPair; // GLSL only + uint m_boundPairRevision; // GLSL only + GLhandleARB m_boundPairProgram; // GLSL only + + // buffer bindings + CGLMBuffer *m_lastKnownBufferBinds[ kGLMNumBufferTypes ]; // tracked per bind point for dupe-bind-absorb + GLMVertexAttributeDesc m_lastKnownVertexAttribs[ kGLMVertexAttributeIndexMax ]; // tracked per attrib for dupe-set-absorb + uint m_lastKnownVertexAttribMask; // tracked for dupe-enable-absorb + + CGLMBuffer *m_drawIndexBuffer; // ... ? do we need dupe tracking for index buffer setup? ? + + GLMVertexSetup m_drawVertexSetup; + + EGLMAttribWriteMode m_attribWriteMode; + + bool m_slowCheckEnable; // turn this on or no native checking is done ("-glmassertslow" or "-glmsspewslow") + bool m_slowAssertEnable; // turn this on to assert on a non-native batch "-glmassertslow" + bool m_slowSpewEnable; // turn this on to log non-native batches to stdout "-glmspewslow" + + // debug font texture + CGLMTex *m_debugFontTex; // might be NULL unless you call GenDebugFontTex + CGLMBuffer *m_debugFontIndices; // up to 1024 indices (256 chars times 4) + CGLMBuffer *m_debugFontVertices; // up to 1024 verts + + // batch/frame debugging support + int m_debugFrameIndex; // init to -1. Increment at BeginFrame + int m_debugBatchIndex; // init to -1. Increment at any draw call + +#if GLMDEBUG + // interactive (DebugHook) debug support + + // using these you can implement frame advance, batch single step, and batch rewind (let it run til next frame and hold on prev batch #) + int m_holdFrameBegin; // -1 if no hold req'd, otherwise # of frame to hold at (at beginframe time) + int m_holdFrameEnd; // -1 if no hold req'd, otherwise # of frame to hold at (at endframe time) + + int m_holdBatch,m_holdBatchFrame; // -1 if no hold, else # of batch&frame to hold at (both must be set) + // these can be expired/cleared to -1 if the frame passes without a hit + // may be desirable to re-pause in that event, as user was expecting a hold to occur + + bool m_debugDelayEnable; // allow sleep delay + uint m_debugDelay; // sleep time per hook call in microseconds (for usleep()) + + // pre-draw global toggles / options + bool m_autoClearColor,m_autoClearDepth,m_autoClearStencil; + float m_autoClearColorValues[4]; + + // debug knobs + int m_selKnobIndex; + float m_selKnobMinValue,m_selKnobMaxValue,m_selKnobIncrement; +#endif + +}; + +struct GLMTestParams +{ + GLMContext *m_ctx; + int *m_testList; // -1 termed + + bool m_glErrToDebugger; + bool m_glErrToConsole; + + bool m_intlErrToDebugger; + bool m_intlErrToConsole; + + int m_frameCount; // how many frames to test. +}; + +class GLMTester +{ + public: + + GLMTester(GLMTestParams *params); + ~GLMTester(); + + + // optionally callable by test routines to get basic drawables wired up + void StdSetup( void ); + void StdCleanup( void ); + + // callable by test routines to clear the frame or present it + void Clear( void ); + void Present( int seed ); + + // error reporting + void CheckGLError( const char *comment ); // obey m_params setting for console / debugger response + void InternalError( int errcode, const char *comment ); // if errcode!=0, obey m_params setting for console / debugger response + + void RunTests(); + + void RunOneTest( int testindex ); + + // test routines themselves + void Test0(); + void Test1(); + void Test2(); + void Test3(); + + GLMTestParams m_params; // copy of caller's params, do not mutate... + + // std-setup stuff + int m_drawWidth, m_drawHeight; + CGLMFBO *m_drawFBO; + CGLMTex *m_drawColorTex; + CGLMTex *m_drawDepthTex; +}; + + +#endif diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrbasics.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrbasics.cpp new file mode 100644 index 0000000..4b898ed --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrbasics.cpp @@ -0,0 +1,4077 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// glmgrbasics.cpp +// +//=============================================================================== + +#include "glmgrbasics.h" +#include "dxabstract.h" + +#if __MAC_OS_X_VERSION_MAX_ALLOWED <= __MAC_10_6 +#include +#include +#else +#define kCGLCPComment ((CGLContextParameter)1232) +/* param is a pointer to a NULL-terminated C-style string. */ +/* Inserts a context-specific comment into the function trace stream. */ +/* Availability: set only, get is ignored. */ + +#define kCGLCPDumpState ((CGLContextParameter)1233) +/* param ignored. Dumps all the gl state. */ +/* Availability: set only, get is ignored. */ + +#define kCGLCPEnableForceFlush ((CGLContextParameter)1234) +/* param is GL_TRUE to enable "force flush" mode or GL_FALSE to disable. */ +/* Availability: set and get. */ + +#define kCGLGOComment ((CGLGlobalOption)1506) +/* param is a pointer to a NULL-terminated C-style string. */ +/* Inserts a comment in the trace steam that applies to all contexts. */ +/* Availability: set only, get is ignored. */ + +#define kCGLGOEnableFunctionTrace ((CGLGlobalOption)1507) +/* param is GL_TRUE or GL_FALSE */ +/* Turns GL function call tracing on and off */ +/* Availability: set and get */ + +#define kCGLGOResetFunctionTrace ((CGLGlobalOption)1509) +/* param is ignored */ +/* Erases current function trace and starts a new one */ +/* Availability: set only, get is ignored. */ + +#define kCGLGOEnableBreakpoint ((CGLGlobalOption)1514) +/* param is an array of 3 GLints: + param[0] is function ID (see CGLProfilerFunctionEnum.h) + param[1] is the logical OR of kCGLProfBreakBefore or kCGLProfBreakAfter, indicating how + you want the breakpoint to stop: before entering OpenGL, on return from OpenGL, or both. + param[2] is a boolean which turns the breakpoint on or off. + */ +/* Availability: set and get. */ + +#define kCGLProfBreakBefore 0x0001 +#define kCGLProfBreakAfter 0x0002 + +#define kCGLFEglColor4sv 98 + +#endif + +//=============================================================================== +#define TOLOWERC( x ) (( ( x >= 'A' ) && ( x <= 'Z' ) )?( x + 32 ) : x ) +int V_stricmp(const char *s1, const char *s2 ) +{ + uint8 const *pS1 = ( uint8 const * ) s1; + uint8 const *pS2 = ( uint8 const * ) s2; + for(;;) + { + int c1 = *( pS1++ ); + int c2 = *( pS2++ ); + if ( c1 == c2 ) + { + if ( !c1 ) return 0; + } + else + { + if ( ! c2 ) + { + return c1 - c2; + } + c1 = TOLOWERC( c1 ); + c2 = TOLOWERC( c2 ); + if ( c1 != c2 ) + { + return c1 - c2; + } + } + c1 = *( pS1++ ); + c2 = *( pS2++ ); + if ( c1 == c2 ) + { + if ( !c1 ) return 0; + } + else + { + if ( ! c2 ) + { + return c1 - c2; + } + c1 = TOLOWERC( c1 ); + c2 = TOLOWERC( c2 ); + if ( c1 != c2 ) + { + return c1 - c2; + } + } + } +} + +inline unsigned char tolower_fast(unsigned char c) +{ + if ( (c >= 'A') && (c <= 'Z') ) + return c + ('a' - 'A'); + return c; +} + +//----------------------------------------------------------------------------- +// Finds a string in another string with a case insensitive test +//----------------------------------------------------------------------------- +char const* V_stristr( char const* pStr, char const* pSearch ) +{ + //AssertValidStringPtr(pStr); + //AssertValidStringPtr(pSearch); + + if (!pStr || !pSearch) + return 0; + + char const* pLetter = pStr; + + // Check the entire string + while (*pLetter != 0) + { + // Skip over non-matches + if (tolower_fast((unsigned char)*pLetter) == tolower_fast((unsigned char)*pSearch)) + { + // Check for match + char const* pMatch = pLetter + 1; + char const* pTest = pSearch + 1; + while (*pTest != 0) + { + // We've run off the end; don't bother. + if (*pMatch == 0) + return 0; + + if (tolower_fast((unsigned char)*pMatch) != tolower_fast((unsigned char)*pTest)) + break; + + ++pMatch; + ++pTest; + } + + // Found a match! + if (*pTest == 0) + return pLetter; + } + + ++pLetter; + } + + return 0; +} + +char* V_stristr( char* pStr, char const* pSearch ) +{ + //AssertValidStringPtr( pStr ); + //AssertValidStringPtr( pSearch ); + + return (char*)V_stristr( (char const*)pStr, pSearch ); +} + +//=============================================================================== + +// convars for GLM + +//ConVar gl_errorcheckall ( "gl_errorcheckall", "0" ); +//ConVar gl_errorcheckqueries ( "gl_errorcheckqueries", "0" ); + +int gl_errorcheckall = 0; +int gl_errorcheckqueries = 0; + +// this one overrides the other two. +// i.e. you can set this one true, and no errors will be checked, period. +//ConVar gl_errorchecknone ( "gl_errorchecknone", "0" ); +int gl_errorchecknone = 0; + +// this decides whether the engine will try to use fast context mode on 10.6.3 or later. +// fast context mode means that a single GL context is used both for the window and the engine, saving on sync and flushes. +// it's only a suggestion; if the OS is below 10.6.2 it will be ignored. +//ConVar gl_singlecontext ( "gl_singlecontext", "1" ); +int gl_singlecontext = 1; + +//=============================================================================== +// decoding tables for debug + +typedef struct +{ + unsigned long value; + const char *name; +} GLMValueEntry_t; + +#define TERMVALUE 0x31415926 + // terminator for value tables + +#define VE( x ) { x, #x } + // "value entry" + +GLMValueEntry_t g_d3d_devtypes[] = +{ + VE( D3DDEVTYPE_HAL ), + VE( D3DDEVTYPE_REF ), + + VE( TERMVALUE ) +}; + +GLMValueEntry_t g_d3d_formats[] = +{ + VE( D3DFMT_INDEX16 ), + VE( D3DFMT_D16 ), + VE( D3DFMT_D24S8 ), + VE( D3DFMT_A8R8G8B8 ), + VE( D3DFMT_A4R4G4B4 ), + VE( D3DFMT_X8R8G8B8 ), + VE( D3DFMT_R5G6R5 ), + VE( D3DFMT_X1R5G5B5 ), + VE( D3DFMT_A1R5G5B5 ), + VE( D3DFMT_L8 ), + VE( D3DFMT_A8L8 ), + VE( D3DFMT_A ), + VE( D3DFMT_DXT1 ), + VE( D3DFMT_DXT3 ), + VE( D3DFMT_DXT5 ), + VE( D3DFMT_V8U8 ), + VE( D3DFMT_Q8W8V8U8 ), + VE( D3DFMT_X8L8V8U8 ), + VE( D3DFMT_A16B16G16R16F ), + VE( D3DFMT_A16B16G16R16 ), + VE( D3DFMT_R32F ), + VE( D3DFMT_A32B32G32R32F ), + VE( D3DFMT_R8G8B8 ), + VE( D3DFMT_D24X4S4 ), + VE( D3DFMT_A8 ), + VE( D3DFMT_R5G6B5 ), + VE( D3DFMT_D15S1 ), + VE( D3DFMT_D24X8 ), + VE( D3DFMT_VERTEXDATA ), + VE( D3DFMT_INDEX32 ), + + // vendor specific formats (fourcc's) + VE( D3DFMT_NV_INTZ ), + VE( D3DFMT_NV_RAWZ ), + VE( D3DFMT_NV_NULL ), + VE( D3DFMT_ATI_D16 ), + VE( D3DFMT_ATI_D24S8 ), + VE( D3DFMT_ATI_2N ), + VE( D3DFMT_ATI_1N ), + + VE( D3DFMT_UNKNOWN ), + + VE( TERMVALUE ) +}; + +GLMValueEntry_t g_d3d_rtypes[] = +{ + VE( D3DRTYPE_SURFACE ), + VE( D3DRTYPE_TEXTURE ), + VE( D3DRTYPE_VOLUMETEXTURE ), + VE( D3DRTYPE_CUBETEXTURE ), + VE( D3DRTYPE_VERTEXBUFFER ), + VE( D3DRTYPE_INDEXBUFFER ), + + VE( TERMVALUE ) +}; + +GLMValueEntry_t g_d3d_usages[] = +{ + VE( D3DUSAGE_RENDERTARGET ), + VE( D3DUSAGE_DEPTHSTENCIL ), + VE( D3DUSAGE_DYNAMIC ), + VE( D3DUSAGE_AUTOGENMIPMAP ), + //VE( D3DUSAGE_DMAP ), + //VE( D3DUSAGE_QUERY_LEGACYBUMPMAP ), + VE( D3DUSAGE_QUERY_SRGBREAD ), + VE( D3DUSAGE_QUERY_FILTER ), + VE( D3DUSAGE_QUERY_SRGBWRITE ), + VE( D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING ), + VE( D3DUSAGE_QUERY_VERTEXTEXTURE ), + //VE( D3DUSAGE_QUERY_WRAPANDMIP ), + VE( D3DUSAGE_WRITEONLY ), + VE( D3DUSAGE_SOFTWAREPROCESSING ), + VE( D3DUSAGE_DONOTCLIP ), + VE( D3DUSAGE_POINTS ), + VE( D3DUSAGE_RTPATCHES ), + VE( D3DUSAGE_NPATCHES ), + + VE( TERMVALUE ) +}; + +GLMValueEntry_t g_d3d_rstates[] = +{ + VE( D3DRS_ZENABLE ), + VE( D3DRS_FILLMODE ), + VE( D3DRS_SHADEMODE ), + VE( D3DRS_ZWRITEENABLE ), + VE( D3DRS_ALPHATESTENABLE ), + VE( D3DRS_LASTPIXEL ), + VE( D3DRS_SRCBLEND ), + VE( D3DRS_DESTBLEND ), + VE( D3DRS_CULLMODE ), + VE( D3DRS_ZFUNC ), + VE( D3DRS_ALPHAREF ), + VE( D3DRS_ALPHAFUNC ), + VE( D3DRS_DITHERENABLE ), + VE( D3DRS_ALPHABLENDENABLE ), + VE( D3DRS_FOGENABLE ), + VE( D3DRS_SPECULARENABLE ), + VE( D3DRS_FOGCOLOR ), + VE( D3DRS_FOGTABLEMODE ), + VE( D3DRS_FOGSTART ), + VE( D3DRS_FOGEND ), + VE( D3DRS_FOGDENSITY ), + VE( D3DRS_RANGEFOGENABLE ), + VE( D3DRS_STENCILENABLE ), + VE( D3DRS_STENCILFAIL ), + VE( D3DRS_STENCILZFAIL ), + VE( D3DRS_STENCILPASS ), + VE( D3DRS_STENCILFUNC ), + VE( D3DRS_STENCILREF ), + VE( D3DRS_STENCILMASK ), + VE( D3DRS_STENCILWRITEMASK ), + VE( D3DRS_TEXTUREFACTOR ), + VE( D3DRS_WRAP0 ), + VE( D3DRS_WRAP1 ), + VE( D3DRS_WRAP2 ), + VE( D3DRS_WRAP3 ), + VE( D3DRS_WRAP4 ), + VE( D3DRS_WRAP5 ), + VE( D3DRS_WRAP6 ), + VE( D3DRS_WRAP7 ), + VE( D3DRS_CLIPPING ), + VE( D3DRS_LIGHTING ), + VE( D3DRS_AMBIENT ), + VE( D3DRS_FOGVERTEXMODE ), + VE( D3DRS_COLORVERTEX ), + VE( D3DRS_LOCALVIEWER ), + VE( D3DRS_NORMALIZENORMALS ), + VE( D3DRS_DIFFUSEMATERIALSOURCE ), + VE( D3DRS_SPECULARMATERIALSOURCE ), + VE( D3DRS_AMBIENTMATERIALSOURCE ), + VE( D3DRS_EMISSIVEMATERIALSOURCE ), + VE( D3DRS_VERTEXBLEND ), + VE( D3DRS_CLIPPLANEENABLE ), + VE( D3DRS_POINTSIZE ), + VE( D3DRS_POINTSIZE_MIN ), + VE( D3DRS_POINTSPRITEENABLE ), + VE( D3DRS_POINTSCALEENABLE ), + VE( D3DRS_POINTSCALE_A ), + VE( D3DRS_POINTSCALE_B ), + VE( D3DRS_POINTSCALE_C ), + VE( D3DRS_MULTISAMPLEANTIALIAS ), + VE( D3DRS_MULTISAMPLEMASK ), + VE( D3DRS_PATCHEDGESTYLE ), + VE( D3DRS_DEBUGMONITORTOKEN ), + VE( D3DRS_POINTSIZE_MAX ), + VE( D3DRS_INDEXEDVERTEXBLENDENABLE ), + VE( D3DRS_COLORWRITEENABLE ), + VE( D3DRS_TWEENFACTOR ), + VE( D3DRS_BLENDOP ), + VE( D3DRS_POSITIONDEGREE ), + VE( D3DRS_NORMALDEGREE ), + VE( D3DRS_SCISSORTESTENABLE ), + VE( D3DRS_SLOPESCALEDEPTHBIAS ), + VE( D3DRS_ANTIALIASEDLINEENABLE ), + VE( D3DRS_MINTESSELLATIONLEVEL ), + VE( D3DRS_MAXTESSELLATIONLEVEL ), + VE( D3DRS_ADAPTIVETESS_X ), + VE( D3DRS_ADAPTIVETESS_Y ), + VE( D3DRS_ADAPTIVETESS_Z ), + VE( D3DRS_ADAPTIVETESS_W ), + VE( D3DRS_ENABLEADAPTIVETESSELLATION ), + VE( D3DRS_TWOSIDEDSTENCILMODE ), + VE( D3DRS_CCW_STENCILFAIL ), + VE( D3DRS_CCW_STENCILZFAIL ), + VE( D3DRS_CCW_STENCILPASS ), + VE( D3DRS_CCW_STENCILFUNC ), + VE( D3DRS_COLORWRITEENABLE1 ), + VE( D3DRS_COLORWRITEENABLE2 ), + VE( D3DRS_COLORWRITEENABLE3 ), + VE( D3DRS_BLENDFACTOR ), + VE( D3DRS_SRGBWRITEENABLE ), + VE( D3DRS_DEPTHBIAS ), + VE( D3DRS_WRAP8 ), + VE( D3DRS_WRAP9 ), + VE( D3DRS_WRAP10 ), + VE( D3DRS_WRAP11 ), + VE( D3DRS_WRAP12 ), + VE( D3DRS_WRAP13 ), + VE( D3DRS_WRAP14 ), + VE( D3DRS_WRAP15 ), + VE( D3DRS_SEPARATEALPHABLENDENABLE ), + VE( D3DRS_SRCBLENDALPHA ), + VE( D3DRS_DESTBLENDALPHA ), + VE( D3DRS_BLENDOPALPHA ), + + VE( TERMVALUE ) +}; + +GLMValueEntry_t g_d3d_opcodes[] = +{ + VE( D3DSIO_NOP ), + VE( D3DSIO_PHASE ), + VE( D3DSIO_RET ), + VE( D3DSIO_ELSE ), + VE( D3DSIO_ENDIF ), + VE( D3DSIO_ENDLOOP ), + VE( D3DSIO_ENDREP ), + VE( D3DSIO_BREAK ), + VE( D3DSIO_TEXDEPTH ), + VE( D3DSIO_TEXKILL ), + VE( D3DSIO_BEM ), + VE( D3DSIO_TEXBEM ), + VE( D3DSIO_TEXBEML ), + VE( D3DSIO_TEXDP3 ), + VE( D3DSIO_TEXDP3TEX ), + VE( D3DSIO_TEXM3x2DEPTH ), + VE( D3DSIO_TEXM3x2TEX ), + VE( D3DSIO_TEXM3x3 ), + VE( D3DSIO_TEXM3x3PAD ), + VE( D3DSIO_TEXM3x3TEX ), + VE( D3DSIO_TEXM3x3VSPEC ), + VE( D3DSIO_TEXREG2AR ), + VE( D3DSIO_TEXREG2GB ), + VE( D3DSIO_TEXREG2RGB ), + VE( D3DSIO_LABEL ), + VE( D3DSIO_CALL ), + VE( D3DSIO_IF ), + VE( D3DSIO_LOOP ), + VE( D3DSIO_REP ), + VE( D3DSIO_BREAKP ), + VE( D3DSIO_DSX ), + VE( D3DSIO_DSY ), + VE( D3DSIO_NRM ), + VE( D3DSIO_MOVA ), + VE( D3DSIO_MOV ), + VE( D3DSIO_RCP ), + VE( D3DSIO_RSQ ), + VE( D3DSIO_EXP ), + VE( D3DSIO_EXPP ), + VE( D3DSIO_LOG ), + VE( D3DSIO_LOGP ), + VE( D3DSIO_FRC ), + VE( D3DSIO_LIT ), + VE( D3DSIO_ABS ), + VE( D3DSIO_TEXM3x3SPEC ), + VE( D3DSIO_M4x4 ), + VE( D3DSIO_M4x3 ), + VE( D3DSIO_M3x4 ), + VE( D3DSIO_M3x3 ), + VE( D3DSIO_M3x2 ), + VE( D3DSIO_CALLNZ ), + VE( D3DSIO_IFC ), + VE( D3DSIO_BREAKC ), + VE( D3DSIO_SETP ), + VE( D3DSIO_TEXLDL ), + VE( D3DSIO_ADD ), + VE( D3DSIO_SUB ), + VE( D3DSIO_MUL ), + VE( D3DSIO_DP3 ), + VE( D3DSIO_DP4 ), + VE( D3DSIO_MIN ), + VE( D3DSIO_MAX ), + VE( D3DSIO_DST ), + VE( D3DSIO_SLT ), + VE( D3DSIO_SGE ), + VE( D3DSIO_CRS ), + VE( D3DSIO_POW ), + VE( D3DSIO_DP2ADD ), + VE( D3DSIO_LRP ), + VE( D3DSIO_SGN ), + VE( D3DSIO_CND ), + VE( D3DSIO_CMP ), + VE( D3DSIO_SINCOS ), + VE( D3DSIO_MAD ), + VE( D3DSIO_TEXLDD ), + VE( D3DSIO_TEXCOORD ), + VE( D3DSIO_TEX ), + VE( D3DSIO_DCL ), + VE( D3DSTT_UNKNOWN ), + VE( D3DSTT_2D ), + VE( D3DSTT_CUBE ), + VE( D3DSTT_VOLUME ), + VE( D3DSIO_DEFB ), + VE( D3DSIO_DEFI ), + VE( D3DSIO_DEF ), + VE( D3DSIO_COMMENT ), + VE( D3DSIO_END ), +}; + + +GLMValueEntry_t g_d3d_vtxdeclusages[] = +{ + { D3DDECLUSAGE_POSITION ,"POSN" }, // P + { D3DDECLUSAGE_BLENDWEIGHT ,"BLWT" }, // W + { D3DDECLUSAGE_BLENDINDICES ,"BLIX" }, // I + { D3DDECLUSAGE_NORMAL ,"NORM" }, // N + { D3DDECLUSAGE_PSIZE ,"PSIZ" }, // S + { D3DDECLUSAGE_TEXCOORD ,"TEXC" }, // T + { D3DDECLUSAGE_TANGENT ,"TANG" }, // G + { D3DDECLUSAGE_BINORMAL ,"BINO" }, // B + { D3DDECLUSAGE_TESSFACTOR ,"TESS" }, // S + { D3DDECLUSAGE_PLUGH ,"????" }, // ? + { D3DDECLUSAGE_COLOR ,"COLR" }, // C + { D3DDECLUSAGE_FOG ,"FOG " }, // F + { D3DDECLUSAGE_DEPTH ,"DEPT" }, // D + { D3DDECLUSAGE_SAMPLE ,"SAMP" } // M +}; + +GLMValueEntry_t g_d3d_vtxdeclusages_short[] = +{ + { D3DDECLUSAGE_POSITION ,"P" }, + { D3DDECLUSAGE_BLENDWEIGHT ,"W" }, + { D3DDECLUSAGE_BLENDINDICES ,"I" }, + { D3DDECLUSAGE_NORMAL ,"N" }, + { D3DDECLUSAGE_PSIZE ,"S" }, + { D3DDECLUSAGE_TEXCOORD ,"T" }, + { D3DDECLUSAGE_TANGENT ,"G" }, + { D3DDECLUSAGE_BINORMAL ,"B" }, + { D3DDECLUSAGE_TESSFACTOR ,"S" }, + { D3DDECLUSAGE_PLUGH ,"?" }, + { D3DDECLUSAGE_COLOR ,"C" }, + { D3DDECLUSAGE_FOG ,"F" }, + { D3DDECLUSAGE_DEPTH ,"D" }, + { D3DDECLUSAGE_SAMPLE ,"M" } +}; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +GLMValueEntry_t g_cgl_rendids[] = // need to mask with 0xFFFFFF00 to match on these (ex: 8800GT == 0x00022608 +{ + VE( kCGLRendererGenericID ), + VE( kCGLRendererGenericFloatID ), + VE( kCGLRendererAppleSWID ), + VE( kCGLRendererATIRage128ID ), + VE( kCGLRendererATIRadeonID ), + VE( kCGLRendererATIRageProID ), + VE( kCGLRendererATIRadeon8500ID ), + VE( kCGLRendererATIRadeon9700ID ), + VE( kCGLRendererATIRadeonX1000ID ), + VE( kCGLRendererATIRadeonX2000ID ), + VE( kCGLRendererGeForce2MXID ), + VE( kCGLRendererGeForce3ID ), + VE( kCGLRendererGeForceFXID ), // also for GF6 and GF7 + VE( kCGLRendererGeForce8xxxID ), + VE( kCGLRendererVTBladeXP2ID ), + VE( kCGLRendererIntel900ID ), + VE( kCGLRendererMesa3DFXID ), + + VE( TERMVALUE ) +}; +#pragma clang diagnostic pop + +GLMValueEntry_t g_gl_errors[] = +{ + VE( GL_INVALID_ENUM ), + VE( GL_INVALID_VALUE ), + VE( GL_INVALID_OPERATION ), + VE( GL_STACK_OVERFLOW ), + VE( GL_STACK_UNDERFLOW ), + VE( GL_OUT_OF_MEMORY ), + VE( GL_INVALID_FRAMEBUFFER_OPERATION_EXT ), + VE( GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT ), + VE( GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT ), + VE( GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT ), + VE( GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT ), + VE( GL_FRAMEBUFFER_UNSUPPORTED_EXT ), + VE( GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT ), + VE( GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT ) +}; + +// there are some ARB/EXT dupes in this table but that doesn't matter too much +GLMValueEntry_t g_gl_enums[] = +{ + { 0x0000, "GL_ZERO" }, + { 0x0001, "GL_ONE" }, + { 0x0004, "GL_TRIANGLES" }, + { 0x0005, "GL_TRIANGLE_STRIP" }, + { 0x0006, "GL_TRIANGLE_FAN" }, + { 0x0007, "GL_QUADS" }, + { 0x0008, "GL_QUAD_STRIP" }, + { 0x0009, "GL_POLYGON" }, + { 0x0200, "GL_NEVER" }, + { 0x0201, "GL_LESS" }, + { 0x0202, "GL_EQUAL" }, + { 0x0203, "GL_LEQUAL" }, + { 0x0204, "GL_GREATER" }, + { 0x0205, "GL_NOTEQUAL" }, + { 0x0206, "GL_GEQUAL" }, + { 0x0207, "GL_ALWAYS" }, + { 0x0300, "GL_SRC_COLOR" }, + { 0x0301, "GL_ONE_MINUS_SRC_COLOR" }, + { 0x0302, "GL_SRC_ALPHA" }, + { 0x0303, "GL_ONE_MINUS_SRC_ALPHA" }, + { 0x0304, "GL_DST_ALPHA" }, + { 0x0305, "GL_ONE_MINUS_DST_ALPHA" }, + { 0x0306, "GL_DST_COLOR" }, + { 0x0307, "GL_ONE_MINUS_DST_COLOR" }, + { 0x0308, "GL_SRC_ALPHA_SATURATE" }, + { 0x0400, "GL_FRONT_LEFT" }, + { 0x0401, "GL_FRONT_RIGHT" }, + { 0x0402, "GL_BACK_LEFT" }, + { 0x0403, "GL_BACK_RIGHT" }, + { 0x0404, "GL_FRONT" }, + { 0x0405, "GL_BACK" }, + { 0x0406, "GL_LEFT" }, + { 0x0407, "GL_RIGHT" }, + { 0x0408, "GL_FRONT_AND_BACK" }, + { 0x0409, "GL_AUX0" }, + { 0x040A, "GL_AUX1" }, + { 0x040B, "GL_AUX2" }, + { 0x040C, "GL_AUX3" }, + { 0x0500, "GL_INVALID_ENUM" }, + { 0x0501, "GL_INVALID_VALUE" }, + { 0x0502, "GL_INVALID_OPERATION" }, + { 0x0503, "GL_STACK_OVERFLOW" }, + { 0x0504, "GL_STACK_UNDERFLOW" }, + { 0x0505, "GL_OUT_OF_MEMORY" }, + { 0x0506, "GL_INVALID_FRAMEBUFFER_OPERATION" }, + { 0x0600, "GL_2D" }, + { 0x0601, "GL_3D" }, + { 0x0602, "GL_3D_COLOR" }, + { 0x0603, "GL_3D_COLOR_TEXTURE" }, + { 0x0604, "GL_4D_COLOR_TEXTURE" }, + { 0x0700, "GL_PASS_THROUGH_TOKEN" }, + { 0x0701, "GL_POINT_TOKEN" }, + { 0x0702, "GL_LINE_TOKEN" }, + { 0x0703, "GL_POLYGON_TOKEN" }, + { 0x0704, "GL_BITMAP_TOKEN" }, + { 0x0705, "GL_DRAW_PIXEL_TOKEN" }, + { 0x0706, "GL_COPY_PIXEL_TOKEN" }, + { 0x0707, "GL_LINE_RESET_TOKEN" }, + { 0x0800, "GL_EXP" }, + { 0x0801, "GL_EXP2" }, + { 0x0900, "GL_CW" }, + { 0x0901, "GL_CCW" }, + { 0x0A00, "GL_COEFF" }, + { 0x0A01, "GL_ORDER" }, + { 0x0A02, "GL_DOMAIN" }, + { 0x0B00, "GL_CURRENT_COLOR" }, + { 0x0B01, "GL_CURRENT_INDEX" }, + { 0x0B02, "GL_CURRENT_NORMAL" }, + { 0x0B03, "GL_CURRENT_TEXTURE_COORDS" }, + { 0x0B04, "GL_CURRENT_RASTER_COLOR" }, + { 0x0B05, "GL_CURRENT_RASTER_INDEX" }, + { 0x0B06, "GL_CURRENT_RASTER_TEXTURE_COORDS" }, + { 0x0B07, "GL_CURRENT_RASTER_POSITION" }, + { 0x0B08, "GL_CURRENT_RASTER_POSITION_VALID" }, + { 0x0B09, "GL_CURRENT_RASTER_DISTANCE" }, + { 0x0B10, "GL_POINT_SMOOTH" }, + { 0x0B11, "GL_POINT_SIZE" }, + { 0x0B12, "GL_POINT_SIZE_RANGE" }, + { 0x0B12, "GL_SMOOTH_POINT_SIZE_RANGE" }, + { 0x0B13, "GL_POINT_SIZE_GRANULARITY" }, + { 0x0B13, "GL_SMOOTH_POINT_SIZE_GRANULARITY" }, + { 0x0B20, "GL_LINE_SMOOTH" }, + { 0x0B21, "GL_LINE_WIDTH" }, + { 0x0B22, "GL_LINE_WIDTH_RANGE" }, + { 0x0B22, "GL_SMOOTH_LINE_WIDTH_RANGE" }, + { 0x0B23, "GL_LINE_WIDTH_GRANULARITY" }, + { 0x0B23, "GL_SMOOTH_LINE_WIDTH_GRANULARITY" }, + { 0x0B24, "GL_LINE_STIPPLE" }, + { 0x0B25, "GL_LINE_STIPPLE_PATTERN" }, + { 0x0B26, "GL_LINE_STIPPLE_REPEAT" }, + { 0x0B30, "GL_LIST_MODE" }, + { 0x0B31, "GL_MAX_LIST_NESTING" }, + { 0x0B32, "GL_LIST_BASE" }, + { 0x0B33, "GL_LIST_INDEX" }, + { 0x0B40, "GL_POLYGON_MODE" }, + { 0x0B41, "GL_POLYGON_SMOOTH" }, + { 0x0B42, "GL_POLYGON_STIPPLE" }, + { 0x0B43, "GL_EDGE_FLAG" }, + { 0x0B44, "GL_CULL_FACE" }, + { 0x0B45, "GL_CULL_FACE_MODE" }, + { 0x0B46, "GL_FRONT_FACE" }, + { 0x0B50, "GL_LIGHTING" }, + { 0x0B51, "GL_LIGHT_MODEL_LOCAL_VIEWER" }, + { 0x0B52, "GL_LIGHT_MODEL_TWO_SIDE" }, + { 0x0B53, "GL_LIGHT_MODEL_AMBIENT" }, + { 0x0B54, "GL_SHADE_MODEL" }, + { 0x0B55, "GL_COLOR_MATERIAL_FACE" }, + { 0x0B56, "GL_COLOR_MATERIAL_PARAMETER" }, + { 0x0B57, "GL_COLOR_MATERIAL" }, + { 0x0B60, "GL_FOG" }, + { 0x0B61, "GL_FOG_INDEX" }, + { 0x0B62, "GL_FOG_DENSITY" }, + { 0x0B63, "GL_FOG_START" }, + { 0x0B64, "GL_FOG_END" }, + { 0x0B65, "GL_FOG_MODE" }, + { 0x0B66, "GL_FOG_COLOR" }, + { 0x0B70, "GL_DEPTH_RANGE" }, + { 0x0B71, "GL_DEPTH_TEST" }, + { 0x0B72, "GL_DEPTH_WRITEMASK" }, + { 0x0B73, "GL_DEPTH_CLEAR_VALUE" }, + { 0x0B74, "GL_DEPTH_FUNC" }, + { 0x0B80, "GL_ACCUM_CLEAR_VALUE" }, + { 0x0B90, "GL_STENCIL_TEST" }, + { 0x0B91, "GL_STENCIL_CLEAR_VALUE" }, + { 0x0B92, "GL_STENCIL_FUNC" }, + { 0x0B93, "GL_STENCIL_VALUE_MASK" }, + { 0x0B94, "GL_STENCIL_FAIL" }, + { 0x0B95, "GL_STENCIL_PASS_DEPTH_FAIL" }, + { 0x0B96, "GL_STENCIL_PASS_DEPTH_PASS" }, + { 0x0B97, "GL_STENCIL_REF" }, + { 0x0B98, "GL_STENCIL_WRITEMASK" }, + { 0x0BA0, "GL_MATRIX_MODE" }, + { 0x0BA1, "GL_NORMALIZE" }, + { 0x0BA2, "GL_VIEWPORT" }, + { 0x0BA3, "GL_MODELVIEW_STACK_DEPTH" }, + { 0x0BA4, "GL_PROJECTION_STACK_DEPTH" }, + { 0x0BA5, "GL_TEXTURE_STACK_DEPTH" }, + { 0x0BA6, "GL_MODELVIEW_MATRIX" }, + { 0x0BA7, "GL_PROJECTION_MATRIX" }, + { 0x0BA8, "GL_TEXTURE_MATRIX" }, + { 0x0BB0, "GL_ATTRIB_STACK_DEPTH" }, + { 0x0BB1, "GL_CLIENT_ATTRIB_STACK_DEPTH" }, + { 0x0BC0, "GL_ALPHA_TEST" }, + { 0x0BC1, "GL_ALPHA_TEST_FUNC" }, + { 0x0BC2, "GL_ALPHA_TEST_REF" }, + { 0x0BD0, "GL_DITHER" }, + { 0x0BE0, "GL_BLEND_DST" }, + { 0x0BE1, "GL_BLEND_SRC" }, + { 0x0BE2, "GL_BLEND" }, + { 0x0BF0, "GL_LOGIC_OP_MODE" }, + { 0x0BF1, "GL_INDEX_LOGIC_OP" }, + { 0x0BF2, "GL_COLOR_LOGIC_OP" }, + { 0x0C00, "GL_AUX_BUFFERS" }, + { 0x0C01, "GL_DRAW_BUFFER" }, + { 0x0C02, "GL_READ_BUFFER" }, + { 0x0C10, "GL_SCISSOR_BOX" }, + { 0x0C11, "GL_SCISSOR_TEST" }, + { 0x0C20, "GL_INDEX_CLEAR_VALUE" }, + { 0x0C21, "GL_INDEX_WRITEMASK" }, + { 0x0C22, "GL_COLOR_CLEAR_VALUE" }, + { 0x0C23, "GL_COLOR_WRITEMASK" }, + { 0x0C30, "GL_INDEX_MODE" }, + { 0x0C31, "GL_RGBA_MODE" }, + { 0x0C32, "GL_DOUBLEBUFFER" }, + { 0x0C33, "GL_STEREO" }, + { 0x0C40, "GL_RENDER_MODE" }, + { 0x0C50, "GL_PERSPECTIVE_CORRECTION_HINT" }, + { 0x0C51, "GL_POINT_SMOOTH_HINT" }, + { 0x0C52, "GL_LINE_SMOOTH_HINT" }, + { 0x0C53, "GL_POLYGON_SMOOTH_HINT" }, + { 0x0C54, "GL_FOG_HINT" }, + { 0x0C60, "GL_TEXTURE_GEN_S" }, + { 0x0C61, "GL_TEXTURE_GEN_T" }, + { 0x0C62, "GL_TEXTURE_GEN_R" }, + { 0x0C63, "GL_TEXTURE_GEN_Q" }, + { 0x0C70, "GL_PIXEL_MAP_I_TO_I" }, + { 0x0C71, "GL_PIXEL_MAP_S_TO_S" }, + { 0x0C72, "GL_PIXEL_MAP_I_TO_R" }, + { 0x0C73, "GL_PIXEL_MAP_I_TO_G" }, + { 0x0C74, "GL_PIXEL_MAP_I_TO_B" }, + { 0x0C75, "GL_PIXEL_MAP_I_TO_A" }, + { 0x0C76, "GL_PIXEL_MAP_R_TO_R" }, + { 0x0C77, "GL_PIXEL_MAP_G_TO_G" }, + { 0x0C78, "GL_PIXEL_MAP_B_TO_B" }, + { 0x0C79, "GL_PIXEL_MAP_A_TO_A" }, + { 0x0CB0, "GL_PIXEL_MAP_I_TO_I_SIZE" }, + { 0x0CB1, "GL_PIXEL_MAP_S_TO_S_SIZE" }, + { 0x0CB2, "GL_PIXEL_MAP_I_TO_R_SIZE" }, + { 0x0CB3, "GL_PIXEL_MAP_I_TO_G_SIZE" }, + { 0x0CB4, "GL_PIXEL_MAP_I_TO_B_SIZE" }, + { 0x0CB5, "GL_PIXEL_MAP_I_TO_A_SIZE" }, + { 0x0CB6, "GL_PIXEL_MAP_R_TO_R_SIZE" }, + { 0x0CB7, "GL_PIXEL_MAP_G_TO_G_SIZE" }, + { 0x0CB8, "GL_PIXEL_MAP_B_TO_B_SIZE" }, + { 0x0CB9, "GL_PIXEL_MAP_A_TO_A_SIZE" }, + { 0x0CF0, "GL_UNPACK_SWAP_BYTES" }, + { 0x0CF1, "GL_UNPACK_LSB_FIRST" }, + { 0x0CF2, "GL_UNPACK_ROW_LENGTH" }, + { 0x0CF3, "GL_UNPACK_SKIP_ROWS" }, + { 0x0CF4, "GL_UNPACK_SKIP_PIXELS" }, + { 0x0CF5, "GL_UNPACK_ALIGNMENT" }, + { 0x0D00, "GL_PACK_SWAP_BYTES" }, + { 0x0D01, "GL_PACK_LSB_FIRST" }, + { 0x0D02, "GL_PACK_ROW_LENGTH" }, + { 0x0D03, "GL_PACK_SKIP_ROWS" }, + { 0x0D04, "GL_PACK_SKIP_PIXELS" }, + { 0x0D05, "GL_PACK_ALIGNMENT" }, + { 0x0D10, "GL_MAP_COLOR" }, + { 0x0D11, "GL_MAP_STENCIL" }, + { 0x0D12, "GL_INDEX_SHIFT" }, + { 0x0D13, "GL_INDEX_OFFSET" }, + { 0x0D14, "GL_RED_SCALE" }, + { 0x0D15, "GL_RED_BIAS" }, + { 0x0D16, "GL_ZOOM_X" }, + { 0x0D17, "GL_ZOOM_Y" }, + { 0x0D18, "GL_GREEN_SCALE" }, + { 0x0D19, "GL_GREEN_BIAS" }, + { 0x0D1A, "GL_BLUE_SCALE" }, + { 0x0D1B, "GL_BLUE_BIAS" }, + { 0x0D1C, "GL_ALPHA_SCALE" }, + { 0x0D1D, "GL_ALPHA_BIAS" }, + { 0x0D1E, "GL_DEPTH_SCALE" }, + { 0x0D1F, "GL_DEPTH_BIAS" }, + { 0x0D30, "GL_MAX_EVAL_ORDER" }, + { 0x0D31, "GL_MAX_LIGHTS" }, + { 0x0D32, "GL_MAX_CLIP_PLANES" }, + { 0x0D33, "GL_MAX_TEXTURE_SIZE" }, + { 0x0D34, "GL_MAX_PIXEL_MAP_TABLE" }, + { 0x0D35, "GL_MAX_ATTRIB_STACK_DEPTH" }, + { 0x0D36, "GL_MAX_MODELVIEW_STACK_DEPTH" }, + { 0x0D37, "GL_MAX_NAME_STACK_DEPTH" }, + { 0x0D38, "GL_MAX_PROJECTION_STACK_DEPTH" }, + { 0x0D39, "GL_MAX_TEXTURE_STACK_DEPTH" }, + { 0x0D3A, "GL_MAX_VIEWPORT_DIMS" }, + { 0x0D3B, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH" }, + { 0x0D50, "GL_SUBPIXEL_BITS" }, + { 0x0D51, "GL_INDEX_BITS" }, + { 0x0D52, "GL_RED_BITS" }, + { 0x0D53, "GL_GREEN_BITS" }, + { 0x0D54, "GL_BLUE_BITS" }, + { 0x0D55, "GL_ALPHA_BITS" }, + { 0x0D56, "GL_DEPTH_BITS" }, + { 0x0D57, "GL_STENCIL_BITS" }, + { 0x0D58, "GL_ACCUM_RED_BITS" }, + { 0x0D59, "GL_ACCUM_GREEN_BITS" }, + { 0x0D5A, "GL_ACCUM_BLUE_BITS" }, + { 0x0D5B, "GL_ACCUM_ALPHA_BITS" }, + { 0x0D70, "GL_NAME_STACK_DEPTH" }, + { 0x0D80, "GL_AUTO_NORMAL" }, + { 0x0D90, "GL_MAP1_COLOR_4" }, + { 0x0D91, "GL_MAP1_INDEX" }, + { 0x0D92, "GL_MAP1_NORMAL" }, + { 0x0D93, "GL_MAP1_TEXTURE_COORD_1" }, + { 0x0D94, "GL_MAP1_TEXTURE_COORD_2" }, + { 0x0D95, "GL_MAP1_TEXTURE_COORD_3" }, + { 0x0D96, "GL_MAP1_TEXTURE_COORD_4" }, + { 0x0D97, "GL_MAP1_VERTEX_3" }, + { 0x0D98, "GL_MAP1_VERTEX_4" }, + { 0x0DB0, "GL_MAP2_COLOR_4" }, + { 0x0DB1, "GL_MAP2_INDEX" }, + { 0x0DB2, "GL_MAP2_NORMAL" }, + { 0x0DB3, "GL_MAP2_TEXTURE_COORD_1" }, + { 0x0DB4, "GL_MAP2_TEXTURE_COORD_2" }, + { 0x0DB5, "GL_MAP2_TEXTURE_COORD_3" }, + { 0x0DB6, "GL_MAP2_TEXTURE_COORD_4" }, + { 0x0DB7, "GL_MAP2_VERTEX_3" }, + { 0x0DB8, "GL_MAP2_VERTEX_4" }, + { 0x0DD0, "GL_MAP1_GRID_DOMAIN" }, + { 0x0DD1, "GL_MAP1_GRID_SEGMENTS" }, + { 0x0DD2, "GL_MAP2_GRID_DOMAIN" }, + { 0x0DD3, "GL_MAP2_GRID_SEGMENTS" }, + { 0x0DE0, "GL_TEXTURE_1D" }, + { 0x0DE1, "GL_TEXTURE_2D" }, + { 0x0DF0, "GL_FEEDBACK_BUFFER_POINTER" }, + { 0x0DF1, "GL_FEEDBACK_BUFFER_SIZE" }, + { 0x0DF2, "GL_FEEDBACK_BUFFER_TYPE" }, + { 0x0DF3, "GL_SELECTION_BUFFER_POINTER" }, + { 0x0DF4, "GL_SELECTION_BUFFER_SIZE" }, + { 0x1000, "GL_TEXTURE_WIDTH" }, + { 0x1001, "GL_TEXTURE_HEIGHT" }, + { 0x1003, "GL_TEXTURE_INTERNAL_FORMAT" }, + { 0x1004, "GL_TEXTURE_BORDER_COLOR" }, + { 0x1005, "GL_TEXTURE_BORDER" }, + { 0x1100, "GL_DONT_CARE" }, + { 0x1101, "GL_FASTEST" }, + { 0x1102, "GL_NICEST" }, + { 0x1200, "GL_AMBIENT" }, + { 0x1201, "GL_DIFFUSE" }, + { 0x1202, "GL_SPECULAR" }, + { 0x1203, "GL_POSITION" }, + { 0x1204, "GL_SPOT_DIRECTION" }, + { 0x1205, "GL_SPOT_EXPONENT" }, + { 0x1206, "GL_SPOT_CUTOFF" }, + { 0x1207, "GL_CONSTANT_ATTENUATION" }, + { 0x1208, "GL_LINEAR_ATTENUATION" }, + { 0x1209, "GL_QUADRATIC_ATTENUATION" }, + { 0x1300, "GL_COMPILE" }, + { 0x1301, "GL_COMPILE_AND_EXECUTE" }, + { 0x1400, "GL_BYTE " }, + { 0x1401, "GL_UBYTE" }, + { 0x1402, "GL_SHORT" }, + { 0x1403, "GL_USHRT" }, + { 0x1404, "GL_INT " }, + { 0x1405, "GL_UINT " }, + { 0x1406, "GL_FLOAT" }, + { 0x1407, "GL_2_BYTES" }, + { 0x1408, "GL_3_BYTES" }, + { 0x1409, "GL_4_BYTES" }, + { 0x140A, "GL_DOUBLE" }, + { 0x140B, "GL_HALF_FLOAT" }, + { 0x1500, "GL_CLEAR" }, + { 0x1501, "GL_AND" }, + { 0x1502, "GL_AND_REVERSE" }, + { 0x1503, "GL_COPY" }, + { 0x1504, "GL_AND_INVERTED" }, + { 0x1505, "GL_NOOP" }, + { 0x1506, "GL_XOR" }, + { 0x1507, "GL_OR" }, + { 0x1508, "GL_NOR" }, + { 0x1509, "GL_EQUIV" }, + { 0x150A, "GL_INVERT" }, + { 0x150B, "GL_OR_REVERSE" }, + { 0x150C, "GL_COPY_INVERTED" }, + { 0x150D, "GL_OR_INVERTED" }, + { 0x150E, "GL_NAND" }, + { 0x150F, "GL_SET" }, + { 0x1600, "GL_EMISSION" }, + { 0x1601, "GL_SHININESS" }, + { 0x1602, "GL_AMBIENT_AND_DIFFUSE" }, + { 0x1603, "GL_COLOR_INDEXES" }, + { 0x1700, "GL_MODELVIEW" }, + { 0x1700, "GL_MODELVIEW0_ARB" }, + { 0x1701, "GL_PROJECTION" }, + { 0x1702, "GL_TEXTURE" }, + { 0x1800, "GL_COLOR" }, + { 0x1801, "GL_DEPTH" }, + { 0x1802, "GL_STENCIL" }, + { 0x1900, "GL_COLOR_INDEX" }, + { 0x1901, "GL_STENCIL_INDEX" }, + { 0x1902, "GL_DEPTH_COMPONENT" }, + { 0x1903, "GL_RED" }, + { 0x1904, "GL_GREEN" }, + { 0x1905, "GL_BLUE" }, + { 0x1906, "GL_ALPHA" }, + { 0x1907, "GL_RGB" }, + { 0x1908, "GL_RGBA" }, + { 0x1909, "GL_LUMINANCE" }, + { 0x190A, "GL_LUMINANCE_ALPHA" }, + { 0x1A00, "GL_BITMAP" }, + { 0x1B00, "GL_POINT" }, + { 0x1B01, "GL_LINE" }, + { 0x1B02, "GL_FILL" }, + { 0x1C00, "GL_RENDER" }, + { 0x1C01, "GL_FEEDBACK" }, + { 0x1C02, "GL_SELECT" }, + { 0x1D00, "GL_FLAT" }, + { 0x1D01, "GL_SMOOTH" }, + { 0x1E00, "GL_KEEP" }, + { 0x1E01, "GL_REPLACE" }, + { 0x1E02, "GL_INCR" }, + { 0x1E03, "GL_DECR" }, + { 0x1F00, "GL_VENDOR" }, + { 0x1F01, "GL_RENDERER" }, + { 0x1F02, "GL_VERSION" }, + { 0x1F03, "GL_EXTENSIONS" }, + { 0x2000, "GL_S" }, + { 0x2001, "GL_T" }, + { 0x2002, "GL_R" }, + { 0x2003, "GL_Q" }, + { 0x2100, "GL_MODULATE" }, + { 0x2101, "GL_DECAL" }, + { 0x2200, "GL_TEXTURE_ENV_MODE" }, + { 0x2201, "GL_TEXTURE_ENV_COLOR" }, + { 0x2300, "GL_TEXTURE_ENV" }, + { 0x2400, "GL_EYE_LINEAR" }, + { 0x2401, "GL_OBJECT_LINEAR" }, + { 0x2402, "GL_SPHERE_MAP" }, + { 0x2500, "GL_TEXTURE_GEN_MODE" }, + { 0x2501, "GL_OBJECT_PLANE" }, + { 0x2502, "GL_EYE_PLANE" }, + { 0x2600, "GL_NEAREST" }, + { 0x2601, "GL_LINEAR" }, + { 0x2700, "GL_NEAREST_MIPMAP_NEAREST" }, + { 0x2701, "GL_LINEAR_MIPMAP_NEAREST" }, + { 0x2702, "GL_NEAREST_MIPMAP_LINEAR" }, + { 0x2703, "GL_LINEAR_MIPMAP_LINEAR" }, + { 0x2800, "GL_TEXTURE_MAG_FILTER" }, + { 0x2801, "GL_TEXTURE_MIN_FILTER" }, + { 0x2802, "GL_TEXTURE_WRAP_S" }, + { 0x2803, "GL_TEXTURE_WRAP_T" }, + { 0x2900, "GL_CLAMP" }, + { 0x2901, "GL_REPEAT" }, + { 0x2A00, "GL_POLYGON_OFFSET_UNITS" }, + { 0x2A01, "GL_POLYGON_OFFSET_POINT" }, + { 0x2A02, "GL_POLYGON_OFFSET_LINE" }, + { 0x2A10, "GL_R3_G3_B2" }, + { 0x2A20, "GL_V2F" }, + { 0x2A21, "GL_V3F" }, + { 0x2A22, "GL_C4UB_V2F" }, + { 0x2A23, "GL_C4UB_V3F" }, + { 0x2A24, "GL_C3F_V3F" }, + { 0x2A25, "GL_N3F_V3F" }, + { 0x2A26, "GL_C4F_N3F_V3F" }, + { 0x2A27, "GL_T2F_V3F" }, + { 0x2A28, "GL_T4F_V4F" }, + { 0x2A29, "GL_T2F_C4UB_V3F" }, + { 0x2A2A, "GL_T2F_C3F_V3F" }, + { 0x2A2B, "GL_T2F_N3F_V3F" }, + { 0x2A2C, "GL_T2F_C4F_N3F_V3F" }, + { 0x2A2D, "GL_T4F_C4F_N3F_V4F" }, + { 0x3000, "GL_CLIP_PLANE0" }, + { 0x3001, "GL_CLIP_PLANE1" }, + { 0x3002, "GL_CLIP_PLANE2" }, + { 0x3003, "GL_CLIP_PLANE3" }, + { 0x3004, "GL_CLIP_PLANE4" }, + { 0x3005, "GL_CLIP_PLANE5" }, + { 0x4000, "GL_LIGHT0" }, + { 0x4001, "GL_LIGHT1" }, + { 0x4002, "GL_LIGHT2" }, + { 0x4003, "GL_LIGHT3" }, + { 0x4004, "GL_LIGHT4" }, + { 0x4005, "GL_LIGHT5" }, + { 0x4006, "GL_LIGHT6" }, + { 0x4007, "GL_LIGHT7" }, + { 0x8000, "GL_ABGR_EXT" }, + { 0x8001, "GL_CONSTANT_COLOR" }, + { 0x8002, "GL_ONE_MINUS_CONSTANT_COLOR" }, + { 0x8003, "GL_CONSTANT_ALPHA" }, + { 0x8004, "GL_ONE_MINUS_CONSTANT_ALPHA" }, + { 0x8005, "GL_BLEND_COLOR" }, + { 0x8006, "GL_FUNC_ADD" }, + { 0x8007, "GL_MIN" }, + { 0x8008, "GL_MAX" }, + { 0x8009, "GL_BLEND_EQUATION_RGB" }, + { 0x8009, "GL_BLEND_EQUATION" }, + { 0x800A, "GL_FUNC_SUBTRACT" }, + { 0x800B, "GL_FUNC_REVERSE_SUBTRACT" }, + { 0x8010, "GL_CONVOLUTION_1D" }, + { 0x8011, "GL_CONVOLUTION_2D" }, + { 0x8012, "GL_SEPARABLE_2D" }, + { 0x8013, "GL_CONVOLUTION_BORDER_MODE" }, + { 0x8014, "GL_CONVOLUTION_FILTER_SCALE" }, + { 0x8015, "GL_CONVOLUTION_FILTER_BIAS" }, + { 0x8016, "GL_REDUCE" }, + { 0x8017, "GL_CONVOLUTION_FORMAT" }, + { 0x8018, "GL_CONVOLUTION_WIDTH" }, + { 0x8019, "GL_CONVOLUTION_HEIGHT" }, + { 0x801A, "GL_MAX_CONVOLUTION_WIDTH" }, + { 0x801B, "GL_MAX_CONVOLUTION_HEIGHT" }, + { 0x801C, "GL_POST_CONVOLUTION_RED_SCALE" }, + { 0x801D, "GL_POST_CONVOLUTION_GREEN_SCALE" }, + { 0x801E, "GL_POST_CONVOLUTION_BLUE_SCALE" }, + { 0x801F, "GL_POST_CONVOLUTION_ALPHA_SCALE" }, + { 0x8020, "GL_POST_CONVOLUTION_RED_BIAS" }, + { 0x8021, "GL_POST_CONVOLUTION_GREEN_BIAS" }, + { 0x8022, "GL_POST_CONVOLUTION_BLUE_BIAS" }, + { 0x8023, "GL_POST_CONVOLUTION_ALPHA_BIAS" }, + { 0x8024, "GL_HISTOGRAM" }, + { 0x8025, "GL_PROXY_HISTOGRAM" }, + { 0x8026, "GL_HISTOGRAM_WIDTH" }, + { 0x8027, "GL_HISTOGRAM_FORMAT" }, + { 0x8028, "GL_HISTOGRAM_RED_SIZE" }, + { 0x8029, "GL_HISTOGRAM_GREEN_SIZE" }, + { 0x802A, "GL_HISTOGRAM_BLUE_SIZE" }, + { 0x802B, "GL_HISTOGRAM_ALPHA_SIZE" }, + { 0x802C, "GL_HISTOGRAM_LUMINANCE_SIZE" }, + { 0x802D, "GL_HISTOGRAM_SINK" }, + { 0x802E, "GL_MINMAX" }, + { 0x802F, "GL_MINMAX_FORMAT" }, + { 0x8030, "GL_MINMAX_SINK" }, + { 0x8031, "GL_TABLE_TOO_LARGE" }, + { 0x8032, "GL_UNSIGNED_BYTE_3_3_2" }, + { 0x8033, "GL_UNSIGNED_SHORT_4_4_4_4" }, + { 0x8034, "GL_UNSIGNED_SHORT_5_5_5_1" }, + { 0x8035, "GL_UNSIGNED_INT_8_8_8_8" }, + { 0x8036, "GL_UNSIGNED_INT_10_10_10_2" }, + { 0x8037, "GL_POLYGON_OFFSET_FILL" }, + { 0x8038, "GL_POLYGON_OFFSET_FACTOR" }, + { 0x803A, "GL_RESCALE_NORMAL" }, + { 0x803B, "GL_ALPHA4" }, + { 0x803C, "GL_ALPHA8" }, + { 0x803D, "GL_ALPHA12" }, + { 0x803E, "GL_ALPHA16" }, + { 0x803F, "GL_LUMINANCE4" }, + { 0x8040, "GL_LUMINANCE8" }, + { 0x8041, "GL_LUMINANCE12" }, + { 0x8042, "GL_LUMINANCE16" }, + { 0x8043, "GL_LUMINANCE4_ALPHA4" }, + { 0x8044, "GL_LUMINANCE6_ALPHA2" }, + { 0x8045, "GL_LUMINANCE8_ALPHA8" }, + { 0x8046, "GL_LUMINANCE12_ALPHA4" }, + { 0x8047, "GL_LUMINANCE12_ALPHA12" }, + { 0x8048, "GL_LUMINANCE16_ALPHA16" }, + { 0x8049, "GL_INTENSITY" }, + { 0x804A, "GL_INTENSITY4" }, + { 0x804B, "GL_INTENSITY8" }, + { 0x804C, "GL_INTENSITY12" }, + { 0x804D, "GL_INTENSITY16" }, + { 0x804F, "GL_RGB4" }, + { 0x8050, "GL_RGB5" }, + { 0x8051, "GL_RGB8" }, + { 0x8052, "GL_RGB10" }, + { 0x8053, "GL_RGB12" }, + { 0x8054, "GL_RGB16" }, + { 0x8055, "GL_RGBA2" }, + { 0x8056, "GL_RGBA4" }, + { 0x8057, "GL_RGB5_A1" }, + { 0x8058, "GL_RGBA8" }, + { 0x8059, "GL_RGB10_A2" }, + { 0x805A, "GL_RGBA12" }, + { 0x805B, "GL_RGBA16" }, + { 0x805C, "GL_TEXTURE_RED_SIZE" }, + { 0x805D, "GL_TEXTURE_GREEN_SIZE" }, + { 0x805E, "GL_TEXTURE_BLUE_SIZE" }, + { 0x805F, "GL_TEXTURE_ALPHA_SIZE" }, + { 0x8060, "GL_TEXTURE_LUMINANCE_SIZE" }, + { 0x8061, "GL_TEXTURE_INTENSITY_SIZE" }, + { 0x8063, "GL_PROXY_TEXTURE_1D" }, + { 0x8064, "GL_PROXY_TEXTURE_2D" }, + { 0x8066, "GL_TEXTURE_PRIORITY" }, + { 0x8067, "GL_TEXTURE_RESIDENT" }, + { 0x8068, "GL_TEXTURE_BINDING_1D" }, + { 0x8069, "GL_TEXTURE_BINDING_2D" }, + { 0x806A, "GL_TEXTURE_BINDING_3D" }, + { 0x806B, "GL_PACK_SKIP_IMAGES" }, + { 0x806C, "GL_PACK_IMAGE_HEIGHT" }, + { 0x806D, "GL_UNPACK_SKIP_IMAGES" }, + { 0x806E, "GL_UNPACK_IMAGE_HEIGHT" }, + { 0x806F, "GL_TEXTURE_3D" }, + { 0x8070, "GL_PROXY_TEXTURE_3D" }, + { 0x8071, "GL_TEXTURE_DEPTH" }, + { 0x8072, "GL_TEXTURE_WRAP_R" }, + { 0x8073, "GL_MAX_3D_TEXTURE_SIZE" }, + { 0x8074, "GL_VERTEX_ARRAY" }, + { 0x8075, "GL_NORMAL_ARRAY" }, + { 0x8076, "GL_COLOR_ARRAY" }, + { 0x8077, "GL_INDEX_ARRAY" }, + { 0x8078, "GL_TEXTURE_COORD_ARRAY" }, + { 0x8079, "GL_EDGE_FLAG_ARRAY" }, + { 0x807A, "GL_VERTEX_ARRAY_SIZE" }, + { 0x807B, "GL_VERTEX_ARRAY_TYPE" }, + { 0x807C, "GL_VERTEX_ARRAY_STRIDE" }, + { 0x807E, "GL_NORMAL_ARRAY_TYPE" }, + { 0x807F, "GL_NORMAL_ARRAY_STRIDE" }, + { 0x8081, "GL_COLOR_ARRAY_SIZE" }, + { 0x8082, "GL_COLOR_ARRAY_TYPE" }, + { 0x8083, "GL_COLOR_ARRAY_STRIDE" }, + { 0x8085, "GL_INDEX_ARRAY_TYPE" }, + { 0x8086, "GL_INDEX_ARRAY_STRIDE" }, + { 0x8088, "GL_TEXTURE_COORD_ARRAY_SIZE" }, + { 0x8089, "GL_TEXTURE_COORD_ARRAY_TYPE" }, + { 0x808A, "GL_TEXTURE_COORD_ARRAY_STRIDE" }, + { 0x808C, "GL_EDGE_FLAG_ARRAY_STRIDE" }, + { 0x808E, "GL_VERTEX_ARRAY_POINTER" }, + { 0x808F, "GL_NORMAL_ARRAY_POINTER" }, + { 0x8090, "GL_COLOR_ARRAY_POINTER" }, + { 0x8091, "GL_INDEX_ARRAY_POINTER" }, + { 0x8092, "GL_TEXTURE_COORD_ARRAY_POINTER" }, + { 0x8093, "GL_EDGE_FLAG_ARRAY_POINTER" }, + { 0x809D, "GL_MULTISAMPLE_ARB" }, + { 0x809D, "GL_MULTISAMPLE" }, + { 0x809E, "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB" }, + { 0x809E, "GL_SAMPLE_ALPHA_TO_COVERAGE" }, + { 0x809F, "GL_SAMPLE_ALPHA_TO_ONE_ARB" }, + { 0x809F, "GL_SAMPLE_ALPHA_TO_ONE" }, + { 0x80A0, "GL_SAMPLE_COVERAGE_ARB" }, + { 0x80A0, "GL_SAMPLE_COVERAGE" }, + { 0x80A0, "GL_SAMPLE_MASK_EXT" }, + { 0x80A1, "GL_1PASS_EXT" }, + { 0x80A2, "GL_2PASS_0_EXT" }, + { 0x80A3, "GL_2PASS_1_EXT" }, + { 0x80A4, "GL_4PASS_0_EXT" }, + { 0x80A5, "GL_4PASS_1_EXT" }, + { 0x80A6, "GL_4PASS_2_EXT" }, + { 0x80A7, "GL_4PASS_3_EXT" }, + { 0x80A8, "GL_SAMPLE_BUFFERS" }, + { 0x80A9, "GL_SAMPLES" }, + { 0x80AA, "GL_SAMPLE_COVERAGE_VALUE" }, + { 0x80AB, "GL_SAMPLE_COVERAGE_INVERT" }, + { 0x80AC, "GL_SAMPLE_PATTERN_EXT" }, + { 0x80B1, "GL_COLOR_MATRIX" }, + { 0x80B2, "GL_COLOR_MATRIX_STACK_DEPTH" }, + { 0x80B3, "GL_MAX_COLOR_MATRIX_STACK_DEPTH" }, + { 0x80B4, "GL_POST_COLOR_MATRIX_RED_SCALE" }, + { 0x80B5, "GL_POST_COLOR_MATRIX_GREEN_SCALE" }, + { 0x80B6, "GL_POST_COLOR_MATRIX_BLUE_SCALE" }, + { 0x80B7, "GL_POST_COLOR_MATRIX_ALPHA_SCALE" }, + { 0x80B8, "GL_POST_COLOR_MATRIX_RED_BIAS" }, + { 0x80B9, "GL_POST_COLOR_MATRIX_GREEN_BIAS" }, + { 0x80BA, "GL_POST_COLOR_MATRIX_BLUE_BIAS" }, + { 0x80BB, "GL_POST_COLOR_MATRIX_ALPHA_BIAS" }, + { 0x80BF, "GL_TEXTURE_COMPARE_FAIL_VALUE_ARB" }, + { 0x80C8, "GL_BLEND_DST_RGB" }, + { 0x80C9, "GL_BLEND_SRC_RGB" }, + { 0x80CA, "GL_BLEND_DST_ALPHA" }, + { 0x80CB, "GL_BLEND_SRC_ALPHA" }, + { 0x80CC, "GL_422_EXT" }, + { 0x80CD, "GL_422_REV_EXT" }, + { 0x80CE, "GL_422_AVERAGE_EXT" }, + { 0x80CF, "GL_422_REV_AVERAGE_EXT" }, + { 0x80D0, "GL_COLOR_TABLE" }, + { 0x80D1, "GL_POST_CONVOLUTION_COLOR_TABLE" }, + { 0x80D2, "GL_POST_COLOR_MATRIX_COLOR_TABLE" }, + { 0x80D3, "GL_PROXY_COLOR_TABLE" }, + { 0x80D4, "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE" }, + { 0x80D5, "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE" }, + { 0x80D6, "GL_COLOR_TABLE_SCALE" }, + { 0x80D7, "GL_COLOR_TABLE_BIAS" }, + { 0x80D8, "GL_COLOR_TABLE_FORMAT" }, + { 0x80D9, "GL_COLOR_TABLE_WIDTH" }, + { 0x80DA, "GL_COLOR_TABLE_RED_SIZE" }, + { 0x80DB, "GL_COLOR_TABLE_GREEN_SIZE" }, + { 0x80DC, "GL_COLOR_TABLE_BLUE_SIZE" }, + { 0x80DD, "GL_COLOR_TABLE_ALPHA_SIZE" }, + { 0x80DE, "GL_COLOR_TABLE_LUMINANCE_SIZE" }, + { 0x80DF, "GL_COLOR_TABLE_INTENSITY_SIZE" }, + { 0x80E0, "GL_BGR_EXT" }, + { 0x80E0, "GL_BGR" }, + { 0x80E1, "GL_BGRA_EXT" }, + { 0x80E1, "GL_BGRA" }, + { 0x80E1, "GL_BGRA" }, + { 0x80E2, "GL_COLOR_INDEX1_EXT" }, + { 0x80E3, "GL_COLOR_INDEX2_EXT" }, + { 0x80E4, "GL_COLOR_INDEX4_EXT" }, + { 0x80E5, "GL_COLOR_INDEX8_EXT" }, + { 0x80E6, "GL_COLOR_INDEX12_EXT" }, + { 0x80E7, "GL_COLOR_INDEX16_EXT" }, + { 0x80E8, "GL_MAX_ELEMENTS_VERTICES_EXT" }, + { 0x80E8, "GL_MAX_ELEMENTS_VERTICES" }, + { 0x80E9, "GL_MAX_ELEMENTS_INDICES_EXT" }, + { 0x80E9, "GL_MAX_ELEMENTS_INDICES" }, + { 0x80ED, "GL_TEXTURE_INDEX_SIZE_EXT" }, + { 0x80F0, "GL_CLIP_VOLUME_CLIPPING_HINT_EXT" }, + { 0x8126, "GL_POINT_SIZE_MIN_ARB" }, + { 0x8126, "GL_POINT_SIZE_MIN" }, + { 0x8127, "GL_POINT_SIZE_MAX_ARB" }, + { 0x8127, "GL_POINT_SIZE_MAX" }, + { 0x8128, "GL_POINT_FADE_THRESHOLD_SIZE_ARB" }, + { 0x8128, "GL_POINT_FADE_THRESHOLD_SIZE" }, + { 0x8129, "GL_POINT_DISTANCE_ATTENUATION_ARB" }, + { 0x8129, "GL_POINT_DISTANCE_ATTENUATION" }, + { 0x812D, "GL_CLAMP_TO_BORDER_ARB" }, + { 0x812D, "GL_CLAMP_TO_BORDER" }, + { 0x812F, "GL_CLAMP_TO_EDGE" }, + { 0x813A, "GL_TEXTURE_MIN_LOD" }, + { 0x813B, "GL_TEXTURE_MAX_LOD" }, + { 0x813C, "GL_TEXTURE_BASE_LEVEL" }, + { 0x813D, "GL_TEXTURE_MAX_LEVEL" }, + { 0x8151, "GL_CONSTANT_BORDER" }, + { 0x8153, "GL_REPLICATE_BORDER" }, + { 0x8154, "GL_CONVOLUTION_BORDER_COLOR" }, + { 0x8191, "GL_GENERATE_MIPMAP" }, + { 0x8192, "GL_GENERATE_MIPMAP_HINT" }, + { 0x81A5, "GL_DEPTH_COMPONENT16_ARB" }, + { 0x81A5, "GL_DEPTH_COMPONENT16" }, + { 0x81A6, "GL_DEPTH_COMPONENT24_ARB" }, + { 0x81A6, "GL_DEPTH_COMPONENT24" }, + { 0x81A7, "GL_DEPTH_COMPONENT32_ARB" }, + { 0x81A7, "GL_DEPTH_COMPONENT32" }, + { 0x81A8, "GL_ARRAY_ELEMENT_LOCK_FIRST_EXT" }, + { 0x81A9, "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT" }, + { 0x81AA, "GL_CULL_VERTEX_EXT" }, + { 0x81AB, "GL_CULL_VERTEX_EYE_POSITION_EXT" }, + { 0x81AC, "GL_CULL_VERTEX_OBJECT_POSITION_EXT" }, + { 0x81AD, "GL_IUI_V2F_EXT" }, + { 0x81AE, "GL_IUI_V3F_EXT" }, + { 0x81AF, "GL_IUI_N3F_V2F_EXT" }, + { 0x81B0, "GL_IUI_N3F_V3F_EXT" }, + { 0x81B1, "GL_T2F_IUI_V2F_EXT" }, + { 0x81B2, "GL_T2F_IUI_V3F_EXT" }, + { 0x81B3, "GL_T2F_IUI_N3F_V2F_EXT" }, + { 0x81B4, "GL_T2F_IUI_N3F_V3F_EXT" }, + { 0x81B5, "GL_INDEX_TEST_EXT" }, + { 0x81B6, "GL_INDEX_TEST_FUNC_EXT" }, + { 0x81B7, "GL_INDEX_TEST_REF_EXT" }, + { 0x81B8, "GL_INDEX_MATERIAL_EXT" }, + { 0x81B9, "GL_INDEX_MATERIAL_PARAMETER_EXT" }, + { 0x81BA, "GL_INDEX_MATERIAL_FACE_EXT" }, + { 0x81F8, "GL_LIGHT_MODEL_COLOR_CONTROL_EXT" }, + { 0x81F8, "GL_LIGHT_MODEL_COLOR_CONTROL" }, + { 0x81F9, "GL_SINGLE_COLOR_EXT" }, + { 0x81F9, "GL_SINGLE_COLOR" }, + { 0x81FA, "GL_SEPARATE_SPECULAR_COLOR_EXT" }, + { 0x81FA, "GL_SEPARATE_SPECULAR_COLOR" }, + { 0x81FB, "GL_SHARED_TEXTURE_PALETTE_EXT" }, + { 0x8210, "GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING" }, + { 0x8211, "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE" }, + { 0x8212, "GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE" }, + { 0x8213, "GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE" }, + { 0x8214, "GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE" }, + { 0x8215, "GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE" }, + { 0x8216, "GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE" }, + { 0x8217, "GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE" }, + { 0x8218, "GL_FRAMEBUFFER_DEFAULT" }, + { 0x8219, "GL_FRAMEBUFFER_UNDEFINED" }, + { 0x821A, "GL_DEPTH_STENCIL_ATTACHMENT" }, + { 0x8225, "GL_COMPRESSED_RED" }, + { 0x8226, "GL_COMPRESSED_RG" }, + { 0x8227, "GL_RG" }, + { 0x8228, "GL_RG_INTEGER" }, + { 0x8229, "GL_R8" }, + { 0x822A, "GL_R16" }, + { 0x822B, "GL_RG8" }, + { 0x822C, "GL_RG16" }, + { 0x822D, "GL_R16F" }, + { 0x822E, "GL_R32F" }, + { 0x822F, "GL_RG16F" }, + { 0x8230, "GL_RG32F" }, + { 0x8231, "GL_R8I" }, + { 0x8232, "GL_R8UI" }, + { 0x8233, "GL_R16I" }, + { 0x8234, "GL_R16UI" }, + { 0x8235, "GL_R32I" }, + { 0x8236, "GL_R32UI" }, + { 0x8237, "GL_RG8I" }, + { 0x8238, "GL_RG8UI" }, + { 0x8239, "GL_RG16I" }, + { 0x823A, "GL_RG16UI" }, + { 0x823B, "GL_RG32I" }, + { 0x823C, "GL_RG32UI" }, + { 0x8330, "GL_PIXEL_TRANSFORM_2D_EXT" }, + { 0x8331, "GL_PIXEL_MAG_FILTER_EXT" }, + { 0x8332, "GL_PIXEL_MIN_FILTER_EXT" }, + { 0x8333, "GL_PIXEL_CUBIC_WEIGHT_EXT" }, + { 0x8334, "GL_CUBIC_EXT" }, + { 0x8335, "GL_AVERAGE_EXT" }, + { 0x8336, "GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT" }, + { 0x8337, "GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT" }, + { 0x8338, "GL_PIXEL_TRANSFORM_2D_MATRIX_EXT" }, + { 0x8349, "GL_FRAGMENT_MATERIAL_EXT" }, + { 0x834A, "GL_FRAGMENT_NORMAL_EXT" }, + { 0x834C, "GL_FRAGMENT_COLOR_EXT" }, + { 0x834D, "GL_ATTENUATION_EXT" }, + { 0x834E, "GL_SHADOW_ATTENUATION_EXT" }, + { 0x834F, "GL_TEXTURE_APPLICATION_MODE_EXT" }, + { 0x8350, "GL_TEXTURE_LIGHT_EXT" }, + { 0x8351, "GL_TEXTURE_MATERIAL_FACE_EXT" }, + { 0x8352, "GL_TEXTURE_MATERIAL_PARAMETER_EXT" }, + { 0x8362, "GL_UNSIGNED_BYTE_2_3_3_REV" }, + { 0x8363, "GL_UNSIGNED_SHORT_5_6_5" }, + { 0x8364, "GL_UNSIGNED_SHORT_5_6_5_REV" }, + { 0x8365, "GL_UNSIGNED_SHORT_4_4_4_4_REV" }, + { 0x8366, "GL_UNSIGNED_SHORT_1_5_5_5_REV" }, + { 0x8367, "GL_UNSIGNED_INT_8_8_8_8_REV" }, + { 0x8368, "GL_UNSIGNED_INT_2_10_10_10_REV" }, + { 0x8370, "GL_MIRRORED_REPEAT_ARB" }, + { 0x8370, "GL_MIRRORED_REPEAT" }, + { 0x83F0, "GL_COMPRESSED_RGB_S3TC_DXT1_EXT" }, + { 0x83F1, "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" }, + { 0x83F2, "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT" }, + { 0x83F3, "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT" }, + { 0x8439, "GL_TANGENT_ARRAY_EXT" }, + { 0x843A, "GL_BINORMAL_ARRAY_EXT" }, + { 0x843B, "GL_CURRENT_TANGENT_EXT" }, + { 0x843C, "GL_CURRENT_BINORMAL_EXT" }, + { 0x843E, "GL_TANGENT_ARRAY_TYPE_EXT" }, + { 0x843F, "GL_TANGENT_ARRAY_STRIDE_EXT" }, + { 0x8440, "GL_BINORMAL_ARRAY_TYPE_EXT" }, + { 0x8441, "GL_BINORMAL_ARRAY_STRIDE_EXT" }, + { 0x8442, "GL_TANGENT_ARRAY_POINTER_EXT" }, + { 0x8443, "GL_BINORMAL_ARRAY_POINTER_EXT" }, + { 0x8444, "GL_MAP1_TANGENT_EXT" }, + { 0x8445, "GL_MAP2_TANGENT_EXT" }, + { 0x8446, "GL_MAP1_BINORMAL_EXT" }, + { 0x8447, "GL_MAP2_BINORMAL_EXT" }, + { 0x8450, "GL_FOG_COORD_SRC" }, + { 0x8450, "GL_FOG_COORDINATE_SOURCE_EXT" }, + { 0x8450, "GL_FOG_COORDINATE_SOURCE" }, + { 0x8451, "GL_FOG_COORD" }, + { 0x8451, "GL_FOG_COORDINATE_EXT" }, + { 0x8451, "GL_FOG_COORDINATE" }, + { 0x8452, "GL_FRAGMENT_DEPTH_EXT" }, + { 0x8452, "GL_FRAGMENT_DEPTH" }, + { 0x8453 , "GL_CURRENT_FOG_COORD" }, + { 0x8453 , "GL_CURRENT_FOG_COORDINATE" }, + { 0x8453, "GL_CURRENT_FOG_COORDINATE_EXT" }, + { 0x8454, "GL_FOG_COORD_ARRAY_TYPE" }, + { 0x8454, "GL_FOG_COORDINATE_ARRAY_TYPE_EXT" }, + { 0x8454, "GL_FOG_COORDINATE_ARRAY_TYPE" }, + { 0x8455, "GL_FOG_COORD_ARRAY_STRIDE" }, + { 0x8455, "GL_FOG_COORDINATE_ARRAY_STRIDE_EXT" }, + { 0x8455, "GL_FOG_COORDINATE_ARRAY_STRIDE" }, + { 0x8456, "GL_FOG_COORD_ARRAY_POINTER" }, + { 0x8456, "GL_FOG_COORDINATE_ARRAY_POINTER_EXT" }, + { 0x8456, "GL_FOG_COORDINATE_ARRAY_POINTER" }, + { 0x8457, "GL_FOG_COORD_ARRAY" }, + { 0x8457, "GL_FOG_COORDINATE_ARRAY_EXT" }, + { 0x8457, "GL_FOG_COORDINATE_ARRAY" }, + { 0x8458, "GL_COLOR_SUM_ARB" }, + { 0x8458, "GL_COLOR_SUM_EXT" }, + { 0x8458, "GL_COLOR_SUM" }, + { 0x8459, "GL_CURRENT_SECONDARY_COLOR_EXT" }, + { 0x8459, "GL_CURRENT_SECONDARY_COLOR" }, + { 0x845A, "GL_SECONDARY_COLOR_ARRAY_SIZE_EXT" }, + { 0x845A, "GL_SECONDARY_COLOR_ARRAY_SIZE" }, + { 0x845B, "GL_SECONDARY_COLOR_ARRAY_TYPE_EXT" }, + { 0x845B, "GL_SECONDARY_COLOR_ARRAY_TYPE" }, + { 0x845C, "GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT" }, + { 0x845C, "GL_SECONDARY_COLOR_ARRAY_STRIDE" }, + { 0x845D, "GL_SECONDARY_COLOR_ARRAY_POINTER_EXT" }, + { 0x845D, "GL_SECONDARY_COLOR_ARRAY_POINTER" }, + { 0x845E, "GL_SECONDARY_COLOR_ARRAY_EXT" }, + { 0x845E, "GL_SECONDARY_COLOR_ARRAY" }, + { 0x845F, "GL_CURRENT_RASTER_SECONDARY_COLOR" }, + { 0x846D, "GL_ALIASED_POINT_SIZE_RANGE" }, + { 0x846E, "GL_ALIASED_LINE_WIDTH_RANGE" }, + { 0x84C0, "GL_TEXTURE0" }, + { 0x84C1, "GL_TEXTURE1" }, + { 0x84C2, "GL_TEXTURE2" }, + { 0x84C3, "GL_TEXTURE3" }, + { 0x84C4, "GL_TEXTURE4" }, + { 0x84C5, "GL_TEXTURE5" }, + { 0x84C6, "GL_TEXTURE6" }, + { 0x84C7, "GL_TEXTURE7" }, + { 0x84C8, "GL_TEXTURE8" }, + { 0x84C9, "GL_TEXTURE9" }, + { 0x84CA, "GL_TEXTURE10" }, + { 0x84CB, "GL_TEXTURE11" }, + { 0x84CC, "GL_TEXTURE12" }, + { 0x84CD, "GL_TEXTURE13" }, + { 0x84CE, "GL_TEXTURE14" }, + { 0x84CF, "GL_TEXTURE15" }, + { 0x84D0, "GL_TEXTURE16" }, + { 0x84D1, "GL_TEXTURE17" }, + { 0x84D2, "GL_TEXTURE18" }, + { 0x84D3, "GL_TEXTURE19" }, + { 0x84D4, "GL_TEXTURE20" }, + { 0x84D5, "GL_TEXTURE21" }, + { 0x84D6, "GL_TEXTURE22" }, + { 0x84D7, "GL_TEXTURE23" }, + { 0x84D8, "GL_TEXTURE24" }, + { 0x84D9, "GL_TEXTURE25" }, + { 0x84DA, "GL_TEXTURE26" }, + { 0x84DB, "GL_TEXTURE27" }, + { 0x84DC, "GL_TEXTURE28" }, + { 0x84DD, "GL_TEXTURE29" }, + { 0x84DE, "GL_TEXTURE30" }, + { 0x84DF, "GL_TEXTURE31" }, + { 0x84E0, "GL_ACTIVE_TEXTURE" }, + { 0x84E1, "GL_CLIENT_ACTIVE_TEXTURE" }, + { 0x84E2, "GL_MAX_TEXTURE_UNITS" }, + { 0x84E3, "GL_TRANSPOSE_MODELVIEW_MATRIX" }, + { 0x84E4, "GL_TRANSPOSE_PROJECTION_MATRIX" }, + { 0x84E5, "GL_TRANSPOSE_TEXTURE_MATRIX" }, + { 0x84E6, "GL_TRANSPOSE_COLOR_MATRIX" }, + { 0x84E7, "GL_SUBTRACT" }, + { 0x84E8, "GL_MAX_RENDERBUFFER_SIZE" }, + { 0x84E9, "GL_COMPRESSED_ALPHA" }, + { 0x84EA, "GL_COMPRESSED_LUMINANCE" }, + { 0x84EB, "GL_COMPRESSED_LUMINANCE_ALPHA" }, + { 0x84EC, "GL_COMPRESSED_INTENSITY" }, + { 0x84ED, "GL_COMPRESSED_RGB" }, + { 0x84EE, "GL_COMPRESSED_RGBA" }, + { 0x84EF, "GL_TEXTURE_COMPRESSION_HINT" }, + { 0x84F5, "GL_TEXTURE_RECTANGLE_EXT" }, + { 0x84F6, "GL_TEXTURE_BINDING_RECTANGLE_EXT" }, + { 0x84F7, "GL_PROXY_TEXTURE_RECTANGLE_EXT" }, + { 0x84F8, "GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT" }, + { 0x84F9, "GL_DEPTH_STENCIL" }, + { 0x84FA, "GL_UNSIGNED_INT_24_8" }, + { 0x84FD, "GL_MAX_TEXTURE_LOD_BIAS" }, + { 0x84FE, "GL_TEXTURE_MAX_ANISOTROPY_EXT" }, + { 0x84FF, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT" }, + { 0x8500, "GL_TEXTURE_FILTER_CONTROL" }, + { 0x8501, "GL_TEXTURE_LOD_BIAS" }, + { 0x8502, "GL_MODELVIEW1_STACK_DEPTH_EXT" }, + { 0x8506, "GL_MODELVIEW_MATRIX1_EXT" }, + { 0x8507, "GL_INCR_WRAP" }, + { 0x8508, "GL_DECR_WRAP" }, + { 0x8509, "GL_VERTEX_WEIGHTING_EXT" }, + { 0x850A, "GL_MODELVIEW1_ARB" }, + { 0x850B, "GL_CURRENT_VERTEX_WEIGHT_EXT" }, + { 0x850C, "GL_VERTEX_WEIGHT_ARRAY_EXT" }, + { 0x850D, "GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT" }, + { 0x850E, "GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT" }, + { 0x850F, "GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT" }, + { 0x8510, "GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT" }, + { 0x8511, "GL_NORMAL_MAP_ARB" }, + { 0x8511, "GL_NORMAL_MAP_EXT" }, + { 0x8511, "GL_NORMAL_MAP" }, + { 0x8512, "GL_REFLECTION_MAP_ARB" }, + { 0x8512, "GL_REFLECTION_MAP_EXT" }, + { 0x8512, "GL_REFLECTION_MAP" }, + { 0x8513, "GL_TEXTURE_CUBE_MAP_ARB" }, + { 0x8513, "GL_TEXTURE_CUBE_MAP_EXT" }, + { 0x8513, "GL_TEXTURE_CUBE_MAP" }, + { 0x8514, "GL_TEXTURE_BINDING_CUBE_MAP_ARB" }, + { 0x8514, "GL_TEXTURE_BINDING_CUBE_MAP_EXT" }, + { 0x8514, "GL_TEXTURE_BINDING_CUBE_MAP" }, + { 0x8515, "GL_TEXTURE_CUBE_MAP_POSITIVE_X" }, + { 0x8516, "GL_TEXTURE_CUBE_MAP_NEGATIVE_X" }, + { 0x8517, "GL_TEXTURE_CUBE_MAP_POSITIVE_Y" }, + { 0x8518, "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y" }, + { 0x8519, "GL_TEXTURE_CUBE_MAP_POSITIVE_Z" }, + { 0x851A, "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z" }, + { 0x851B, "GL_PROXY_TEXTURE_CUBE_MAP" }, + { 0x851C, "GL_MAX_CUBE_MAP_TEXTURE_SIZE" }, + { 0x851D, "GL_VERTEX_ARRAY_RANGE_APPLE" }, + { 0x851E, "GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE" }, + { 0x851F, "GL_VERTEX_ARRAY_STORAGE_HINT_APPLE" }, + { 0x8520, "GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE" }, + { 0x8521, "GL_VERTEX_ARRAY_RANGE_POINTER_APPLE" }, + { 0x8570, "GL_COMBINE_ARB" }, + { 0x8570, "GL_COMBINE_EXT" }, + { 0x8570, "GL_COMBINE" }, + { 0x8571, "GL_COMBINE_RGB_ARB" }, + { 0x8571, "GL_COMBINE_RGB_EXT" }, + { 0x8571, "GL_COMBINE_RGB" }, + { 0x8572, "GL_COMBINE_ALPHA_ARB" }, + { 0x8572, "GL_COMBINE_ALPHA_EXT" }, + { 0x8572, "GL_COMBINE_ALPHA" }, + { 0x8573, "GL_RGB_SCALE_ARB" }, + { 0x8573, "GL_RGB_SCALE_EXT" }, + { 0x8573, "GL_RGB_SCALE" }, + { 0x8574, "GL_ADD_SIGNED_ARB" }, + { 0x8574, "GL_ADD_SIGNED_EXT" }, + { 0x8574, "GL_ADD_SIGNED" }, + { 0x8575, "GL_INTERPOLATE_ARB" }, + { 0x8575, "GL_INTERPOLATE_EXT" }, + { 0x8575, "GL_INTERPOLATE" }, + { 0x8576, "GL_CONSTANT_ARB" }, + { 0x8576, "GL_CONSTANT_EXT" }, + { 0x8576, "GL_CONSTANT" }, + { 0x8577, "GL_PRIMARY_COLOR_ARB" }, + { 0x8577, "GL_PRIMARY_COLOR_EXT" }, + { 0x8577, "GL_PRIMARY_COLOR" }, + { 0x8578, "GL_PREVIOUS_ARB" }, + { 0x8578, "GL_PREVIOUS_EXT" }, + { 0x8578, "GL_PREVIOUS" }, + { 0x8580, "GL_SOURCE0_RGB_ARB" }, + { 0x8580, "GL_SOURCE0_RGB_EXT" }, + { 0x8580, "GL_SOURCE0_RGB" }, + { 0x8580, "GL_SRC0_RGB" }, + { 0x8581, "GL_SOURCE1_RGB_ARB" }, + { 0x8581, "GL_SOURCE1_RGB_EXT" }, + { 0x8581, "GL_SOURCE1_RGB" }, + { 0x8581, "GL_SRC1_RGB" }, + { 0x8582, "GL_SOURCE2_RGB_ARB" }, + { 0x8582, "GL_SOURCE2_RGB_EXT" }, + { 0x8582, "GL_SOURCE2_RGB" }, + { 0x8582, "GL_SRC2_RGB" }, + { 0x8583, "GL_SOURCE3_RGB_ARB" }, + { 0x8583, "GL_SOURCE3_RGB_EXT" }, + { 0x8583, "GL_SOURCE3_RGB" }, + { 0x8583, "GL_SRC3_RGB" }, + { 0x8584, "GL_SOURCE4_RGB_ARB" }, + { 0x8584, "GL_SOURCE4_RGB_EXT" }, + { 0x8584, "GL_SOURCE4_RGB" }, + { 0x8584, "GL_SRC4_RGB" }, + { 0x8585, "GL_SOURCE5_RGB_ARB" }, + { 0x8585, "GL_SOURCE5_RGB_EXT" }, + { 0x8585, "GL_SOURCE5_RGB" }, + { 0x8585, "GL_SRC5_RGB" }, + { 0x8586, "GL_SOURCE6_RGB_ARB" }, + { 0x8586, "GL_SOURCE6_RGB_EXT" }, + { 0x8586, "GL_SOURCE6_RGB" }, + { 0x8586, "GL_SRC6_RGB" }, + { 0x8587, "GL_SOURCE7_RGB_ARB" }, + { 0x8587, "GL_SOURCE7_RGB_EXT" }, + { 0x8587, "GL_SOURCE7_RGB" }, + { 0x8587, "GL_SRC7_RGB" }, + { 0x8588, "GL_SOURCE0_ALPHA_ARB" }, + { 0x8588, "GL_SOURCE0_ALPHA_EXT" }, + { 0x8588, "GL_SOURCE0_ALPHA" }, + { 0x8588, "GL_SRC0_ALPHA" }, + { 0x8589, "GL_SOURCE1_ALPHA_ARB" }, + { 0x8589, "GL_SOURCE1_ALPHA_EXT" }, + { 0x8589, "GL_SOURCE1_ALPHA" }, + { 0x8589, "GL_SRC1_ALPHA" }, + { 0x858A, "GL_SOURCE2_ALPHA_ARB" }, + { 0x858A, "GL_SOURCE2_ALPHA_EXT" }, + { 0x858A, "GL_SOURCE2_ALPHA" }, + { 0x858A, "GL_SRC2_ALPHA" }, + { 0x858B, "GL_SOURCE3_ALPHA_ARB" }, + { 0x858B, "GL_SOURCE3_ALPHA_EXT" }, + { 0x858B, "GL_SOURCE3_ALPHA" }, + { 0x858B, "GL_SRC3_ALPHA" }, + { 0x858C, "GL_SOURCE4_ALPHA_ARB" }, + { 0x858C, "GL_SOURCE4_ALPHA_EXT" }, + { 0x858C, "GL_SOURCE4_ALPHA" }, + { 0x858C, "GL_SRC4_ALPHA" }, + { 0x858D, "GL_SOURCE5_ALPHA_ARB" }, + { 0x858D, "GL_SOURCE5_ALPHA_EXT" }, + { 0x858D, "GL_SOURCE5_ALPHA" }, + { 0x858D, "GL_SRC5_ALPHA" }, + { 0x858E, "GL_SOURCE6_ALPHA_ARB" }, + { 0x858E, "GL_SOURCE6_ALPHA_EXT" }, + { 0x858E, "GL_SOURCE6_ALPHA" }, + { 0x858E, "GL_SRC6_ALPHA" }, + { 0x858F, "GL_SOURCE7_ALPHA_ARB" }, + { 0x858F, "GL_SOURCE7_ALPHA_EXT" }, + { 0x858F, "GL_SOURCE7_ALPHA" }, + { 0x858F, "GL_SRC7_ALPHA" }, + { 0x8590, "GL_OPERAND0_RGB_ARB" }, + { 0x8590, "GL_OPERAND0_RGB_EXT" }, + { 0x8590, "GL_OPERAND0_RGB" }, + { 0x8591, "GL_OPERAND1_RGB_ARB" }, + { 0x8591, "GL_OPERAND1_RGB_EXT" }, + { 0x8591, "GL_OPERAND1_RGB" }, + { 0x8592, "GL_OPERAND2_RGB_ARB" }, + { 0x8592, "GL_OPERAND2_RGB_EXT" }, + { 0x8592, "GL_OPERAND2_RGB" }, + { 0x8593, "GL_OPERAND3_RGB_ARB" }, + { 0x8593, "GL_OPERAND3_RGB_EXT" }, + { 0x8593, "GL_OPERAND3_RGB" }, + { 0x8594, "GL_OPERAND4_RGB_ARB" }, + { 0x8594, "GL_OPERAND4_RGB_EXT" }, + { 0x8594, "GL_OPERAND4_RGB" }, + { 0x8595, "GL_OPERAND5_RGB_ARB" }, + { 0x8595, "GL_OPERAND5_RGB_EXT" }, + { 0x8595, "GL_OPERAND5_RGB" }, + { 0x8596, "GL_OPERAND6_RGB_ARB" }, + { 0x8596, "GL_OPERAND6_RGB_EXT" }, + { 0x8596, "GL_OPERAND6_RGB" }, + { 0x8597, "GL_OPERAND7_RGB_ARB" }, + { 0x8597, "GL_OPERAND7_RGB_EXT" }, + { 0x8597, "GL_OPERAND7_RGB" }, + { 0x8598, "GL_OPERAND0_ALPHA_ARB" }, + { 0x8598, "GL_OPERAND0_ALPHA_EXT" }, + { 0x8598, "GL_OPERAND0_ALPHA" }, + { 0x8599, "GL_OPERAND1_ALPHA_ARB" }, + { 0x8599, "GL_OPERAND1_ALPHA_EXT" }, + { 0x8599, "GL_OPERAND1_ALPHA" }, + { 0x859A, "GL_OPERAND2_ALPHA_ARB" }, + { 0x859A, "GL_OPERAND2_ALPHA_EXT" }, + { 0x859A, "GL_OPERAND2_ALPHA" }, + { 0x859B, "GL_OPERAND3_ALPHA_ARB" }, + { 0x859B, "GL_OPERAND3_ALPHA_EXT" }, + { 0x859B, "GL_OPERAND3_ALPHA" }, + { 0x859C, "GL_OPERAND4_ALPHA_ARB" }, + { 0x859C, "GL_OPERAND4_ALPHA_EXT" }, + { 0x859C, "GL_OPERAND4_ALPHA" }, + { 0x859D, "GL_OPERAND5_ALPHA_ARB" }, + { 0x859D, "GL_OPERAND5_ALPHA_EXT" }, + { 0x859D, "GL_OPERAND5_ALPHA" }, + { 0x859E, "GL_OPERAND6_ALPHA_ARB" }, + { 0x859E, "GL_OPERAND6_ALPHA_EXT" }, + { 0x859E, "GL_OPERAND6_ALPHA" }, + { 0x859F, "GL_OPERAND7_ALPHA_ARB" }, + { 0x859F, "GL_OPERAND7_ALPHA_EXT" }, + { 0x859F, "GL_OPERAND7_ALPHA" }, + { 0x85AE, "GL_PERTURB_EXT" }, + { 0x85AF, "GL_TEXTURE_NORMAL_EXT" }, + { 0x85B4, "GL_STORAGE_CLIENT_APPLE" }, + { 0x85B5, "GL_VERTEX_ARRAY_BINDING_APPLE" }, + { 0x85BD, "GL_STORAGE_PRIVATE_APPLE" }, + { 0x85BE, "GL_STORAGE_CACHED_APPLE" }, + { 0x85BF, "GL_STORAGE_SHARED_APPLE" }, + { 0x8620, "GL_VERTEX_PROGRAM_ARB" }, + { 0x8620, "GL_VERTEX_PROGRAM_NV" }, + { 0x8621, "GL_VERTEX_STATE_PROGRAM_NV" }, + { 0x8622, "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB" }, + { 0x8622, "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB" }, + { 0x8622, "GL_VERTEX_ATTRIB_ARRAY_ENABLED" }, + { 0x8623, "GL_ATTRIB_ARRAY_SIZE_NV" }, + { 0x8623, "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB" }, + { 0x8623, "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB" }, + { 0x8623, "GL_VERTEX_ATTRIB_ARRAY_SIZE" }, + { 0x8624, "GL_ATTRIB_ARRAY_STRIDE_NV" }, + { 0x8624, "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB" }, + { 0x8624, "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB" }, + { 0x8624, "GL_VERTEX_ATTRIB_ARRAY_STRIDE" }, + { 0x8625, "GL_ATTRIB_ARRAY_TYPE_NV" }, + { 0x8625, "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB" }, + { 0x8625, "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB" }, + { 0x8625, "GL_VERTEX_ATTRIB_ARRAY_TYPE" }, + { 0x8626, "GL_CURRENT_ATTRIB_NV" }, + { 0x8626, "GL_CURRENT_VERTEX_ATTRIB_ARB" }, + { 0x8626, "GL_CURRENT_VERTEX_ATTRIB_ARB" }, + { 0x8626, "GL_CURRENT_VERTEX_ATTRIB" }, + { 0x8627, "GL_PROGRAM_LENGTH_ARB" }, + { 0x8627, "GL_PROGRAM_LENGTH_NV" }, + { 0x8628, "GL_PROGRAM_STRING_ARB" }, + { 0x8628, "GL_PROGRAM_STRING_NV" }, + { 0x8629, "GL_MODELVIEW_PROJECTION_NV" }, + { 0x862A, "GL_IDENTITY_NV" }, + { 0x862B, "GL_INVERSE_NV" }, + { 0x862C, "GL_TRANSPOSE_NV" }, + { 0x862D, "GL_INVERSE_TRANSPOSE_NV" }, + { 0x862E, "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB" }, + { 0x862E, "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV" }, + { 0x862F, "GL_MAX_PROGRAM_MATRICES_ARB" }, + { 0x862F, "GL_MAX_TRACK_MATRICES_NV" }, + { 0x8630, "GL_MATRIX0_NV" }, + { 0x8631, "GL_MATRIX1_NV" }, + { 0x8632, "GL_MATRIX2_NV" }, + { 0x8633, "GL_MATRIX3_NV" }, + { 0x8634, "GL_MATRIX4_NV" }, + { 0x8635, "GL_MATRIX5_NV" }, + { 0x8636, "GL_MATRIX6_NV" }, + { 0x8637, "GL_MATRIX7_NV" }, + { 0x8640, "GL_CURRENT_MATRIX_STACK_DEPTH_ARB" }, + { 0x8640, "GL_CURRENT_MATRIX_STACK_DEPTH_NV" }, + { 0x8641, "GL_CURRENT_MATRIX_ARB" }, + { 0x8641, "GL_CURRENT_MATRIX_NV" }, + { 0x8642, "GL_PROGRAM_POINT_SIZE_EXT" }, + { 0x8642, "GL_VERTEX_PROGRAM_POINT_SIZE_ARB" }, + { 0x8642, "GL_VERTEX_PROGRAM_POINT_SIZE_ARB" }, + { 0x8642, "GL_VERTEX_PROGRAM_POINT_SIZE_NV" }, + { 0x8642, "GL_VERTEX_PROGRAM_POINT_SIZE" }, + { 0x8643, "GL_VERTEX_PROGRAM_TWO_SIDE_ARB" }, + { 0x8643, "GL_VERTEX_PROGRAM_TWO_SIDE_ARB" }, + { 0x8643, "GL_VERTEX_PROGRAM_TWO_SIDE_NV" }, + { 0x8643, "GL_VERTEX_PROGRAM_TWO_SIDE" }, + { 0x8644, "GL_PROGRAM_PARAMETER_NV" }, + { 0x8645, "GL_ATTRIB_ARRAY_POINTER_NV" }, + { 0x8645, "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB" }, + { 0x8645, "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB" }, + { 0x8645, "GL_VERTEX_ATTRIB_ARRAY_POINTER" }, + { 0x8646, "GL_PROGRAM_TARGET_NV" }, + { 0x8647, "GL_PROGRAM_RESIDENT_NV" }, + { 0x8648, "GL_TRACK_MATRIX_NV" }, + { 0x8649, "GL_TRACK_MATRIX_TRANSFORM_NV" }, + { 0x864A, "GL_VERTEX_PROGRAM_BINDING_NV" }, + { 0x864B, "GL_PROGRAM_ERROR_POSITION_ARB" }, + { 0x864B, "GL_PROGRAM_ERROR_POSITION_NV" }, + { 0x8650, "GL_VERTEX_ATTRIB_ARRAY0_NV" }, + { 0x8651, "GL_VERTEX_ATTRIB_ARRAY1_NV" }, + { 0x8652, "GL_VERTEX_ATTRIB_ARRAY2_NV" }, + { 0x8653, "GL_VERTEX_ATTRIB_ARRAY3_NV" }, + { 0x8654, "GL_VERTEX_ATTRIB_ARRAY4_NV" }, + { 0x8655, "GL_VERTEX_ATTRIB_ARRAY5_NV" }, + { 0x8656, "GL_VERTEX_ATTRIB_ARRAY6_NV" }, + { 0x8657, "GL_VERTEX_ATTRIB_ARRAY7_NV" }, + { 0x8658, "GL_VERTEX_ATTRIB_ARRAY8_NV" }, + { 0x8659, "GL_VERTEX_ATTRIB_ARRAY9_NV" }, + { 0x865A, "GL_VERTEX_ATTRIB_ARRAY10_NV" }, + { 0x865B, "GL_VERTEX_ATTRIB_ARRAY11_NV" }, + { 0x865C, "GL_VERTEX_ATTRIB_ARRAY12_NV" }, + { 0x865D, "GL_VERTEX_ATTRIB_ARRAY13_NV" }, + { 0x865E, "GL_VERTEX_ATTRIB_ARRAY14_NV" }, + { 0x865F, "GL_VERTEX_ATTRIB_ARRAY15_NV" }, + { 0x8660, "GL_MAP1_VERTEX_ATTRIB0_4_NV" }, + { 0x8661, "GL_MAP1_VERTEX_ATTRIB1_4_NV" }, + { 0x8662, "GL_MAP1_VERTEX_ATTRIB2_4_NV" }, + { 0x8663, "GL_MAP1_VERTEX_ATTRIB3_4_NV" }, + { 0x8664, "GL_MAP1_VERTEX_ATTRIB4_4_NV" }, + { 0x8665, "GL_MAP1_VERTEX_ATTRIB5_4_NV" }, + { 0x8666, "GL_MAP1_VERTEX_ATTRIB6_4_NV" }, + { 0x8667, "GL_MAP1_VERTEX_ATTRIB7_4_NV" }, + { 0x8668, "GL_MAP1_VERTEX_ATTRIB8_4_NV" }, + { 0x8669, "GL_MAP1_VERTEX_ATTRIB9_4_NV" }, + { 0x866A, "GL_MAP1_VERTEX_ATTRIB10_4_NV" }, + { 0x866B, "GL_MAP1_VERTEX_ATTRIB11_4_NV" }, + { 0x866C, "GL_MAP1_VERTEX_ATTRIB12_4_NV" }, + { 0x866D, "GL_MAP1_VERTEX_ATTRIB13_4_NV" }, + { 0x866E, "GL_MAP1_VERTEX_ATTRIB14_4_NV" }, + { 0x866F, "GL_MAP1_VERTEX_ATTRIB15_4_NV" }, + { 0x8670, "GL_MAP2_VERTEX_ATTRIB0_4_NV" }, + { 0x8671, "GL_MAP2_VERTEX_ATTRIB1_4_NV" }, + { 0x8672, "GL_MAP2_VERTEX_ATTRIB2_4_NV" }, + { 0x8673, "GL_MAP2_VERTEX_ATTRIB3_4_NV" }, + { 0x8674, "GL_MAP2_VERTEX_ATTRIB4_4_NV" }, + { 0x8675, "GL_MAP2_VERTEX_ATTRIB5_4_NV" }, + { 0x8676, "GL_MAP2_VERTEX_ATTRIB6_4_NV" }, + { 0x8677, "GL_MAP2_VERTEX_ATTRIB7_4_NV" }, + { 0x8677, "GL_PROGRAM_BINDING_ARB" }, + { 0x8677, "GL_PROGRAM_NAME_ARB" }, + { 0x8678, "GL_MAP2_VERTEX_ATTRIB8_4_NV" }, + { 0x8679, "GL_MAP2_VERTEX_ATTRIB9_4_NV" }, + { 0x867A, "GL_MAP2_VERTEX_ATTRIB10_4_NV" }, + { 0x867B, "GL_MAP2_VERTEX_ATTRIB11_4_NV" }, + { 0x867C, "GL_MAP2_VERTEX_ATTRIB12_4_NV" }, + { 0x867D, "GL_MAP2_VERTEX_ATTRIB13_4_NV" }, + { 0x867E, "GL_MAP2_VERTEX_ATTRIB14_4_NV" }, + { 0x867F, "GL_MAP2_VERTEX_ATTRIB15_4_NV" }, + { 0x86A0, "GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB" }, + { 0x86A0, "GL_TEXTURE_COMPRESSED_IMAGE_SIZE" }, + { 0x86A1, "GL_TEXTURE_COMPRESSED_ARB" }, + { 0x86A1, "GL_TEXTURE_COMPRESSED" }, + { 0x86A2, "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB" }, + { 0x86A2, "GL_NUM_COMPRESSED_TEXTURE_FORMATS" }, + { 0x86A3, "GL_COMPRESSED_TEXTURE_FORMATS_ARB" }, + { 0x86A3, "GL_COMPRESSED_TEXTURE_FORMATS" }, + { 0x86A4, "GL_MAX_VERTEX_UNITS_ARB" }, + { 0x86A5, "GL_ACTIVE_VERTEX_UNITS_ARB" }, + { 0x86A6, "GL_WEIGHT_SUM_UNITY_ARB" }, + { 0x86A7, "GL_VERTEX_BLEND_ARB" }, + { 0x86A8, "GL_CURRENT_WEIGHT_ARB" }, + { 0x86A9, "GL_WEIGHT_ARRAY_TYPE_ARB" }, + { 0x86AA, "GL_WEIGHT_ARRAY_STRIDE_ARB" }, + { 0x86AB, "GL_WEIGHT_ARRAY_SIZE_ARB" }, + { 0x86AC, "GL_WEIGHT_ARRAY_POINTER_ARB" }, + { 0x86AD, "GL_WEIGHT_ARRAY_ARB" }, + { 0x86AE, "GL_DOT3_RGB_ARB" }, + { 0x86AE, "GL_DOT3_RGB" }, + { 0x86AF, "GL_DOT3_RGBA_ARB" }, + { 0x86AF, "GL_DOT3_RGBA" }, + { 0x8722, "GL_MODELVIEW2_ARB" }, + { 0x8723, "GL_MODELVIEW3_ARB" }, + { 0x8724, "GL_MODELVIEW4_ARB" }, + { 0x8725, "GL_MODELVIEW5_ARB" }, + { 0x8726, "GL_MODELVIEW6_ARB" }, + { 0x8727, "GL_MODELVIEW7_ARB" }, + { 0x8728, "GL_MODELVIEW8_ARB" }, + { 0x8729, "GL_MODELVIEW9_ARB" }, + { 0x872A, "GL_MODELVIEW10_ARB" }, + { 0x872B, "GL_MODELVIEW11_ARB" }, + { 0x872C, "GL_MODELVIEW12_ARB" }, + { 0x872D, "GL_MODELVIEW13_ARB" }, + { 0x872E, "GL_MODELVIEW14_ARB" }, + { 0x872F, "GL_MODELVIEW15_ARB" }, + { 0x8730, "GL_MODELVIEW16_ARB" }, + { 0x8731, "GL_MODELVIEW17_ARB" }, + { 0x8732, "GL_MODELVIEW18_ARB" }, + { 0x8733, "GL_MODELVIEW19_ARB" }, + { 0x8734, "GL_MODELVIEW20_ARB" }, + { 0x8735, "GL_MODELVIEW21_ARB" }, + { 0x8736, "GL_MODELVIEW22_ARB" }, + { 0x8737, "GL_MODELVIEW23_ARB" }, + { 0x8738, "GL_MODELVIEW24_ARB" }, + { 0x8739, "GL_MODELVIEW25_ARB" }, + { 0x873A, "GL_MODELVIEW26_ARB" }, + { 0x873B, "GL_MODELVIEW27_ARB" }, + { 0x873C, "GL_MODELVIEW28_ARB" }, + { 0x873D, "GL_MODELVIEW29_ARB" }, + { 0x873E, "GL_MODELVIEW30_ARB" }, + { 0x873F, "GL_MODELVIEW31_ARB" }, + { 0x8742, "GL_MIRROR_CLAMP_EXT" }, + { 0x8743, "GL_MIRROR_CLAMP_TO_EDGE_EXT" }, + { 0x8764, "GL_BUFFER_SIZE_ARB" }, + { 0x8764, "GL_BUFFER_SIZE" }, + { 0x8765, "GL_BUFFER_USAGE_ARB" }, + { 0x8765, "GL_BUFFER_USAGE" }, + { 0x8780, "GL_VERTEX_SHADER_EXT" }, + { 0x8781, "GL_VERTEX_SHADER_BINDING_EXT" }, + { 0x8782, "GL_OP_INDEX_EXT" }, + { 0x8783, "GL_OP_NEGATE_EXT" }, + { 0x8784, "GL_OP_DOT3_EXT" }, + { 0x8785, "GL_OP_DOT4_EXT" }, + { 0x8786, "GL_OP_MUL_EXT" }, + { 0x8787, "GL_OP_ADD_EXT" }, + { 0x8788, "GL_OP_MADD_EXT" }, + { 0x8789, "GL_OP_FRAC_EXT" }, + { 0x878A, "GL_OP_MAX_EXT" }, + { 0x878B, "GL_OP_MIN_EXT" }, + { 0x878C, "GL_OP_SET_GE_EXT" }, + { 0x878D, "GL_OP_SET_LT_EXT" }, + { 0x878E, "GL_OP_CLAMP_EXT" }, + { 0x878F, "GL_OP_FLOOR_EXT" }, + { 0x8790, "GL_OP_ROUND_EXT" }, + { 0x8791, "GL_OP_EXP_BASE_2_EXT" }, + { 0x8792, "GL_OP_LOG_BASE_2_EXT" }, + { 0x8793, "GL_OP_POWER_EXT" }, + { 0x8794, "GL_OP_RECIP_EXT" }, + { 0x8795, "GL_OP_RECIP_SQRT_EXT" }, + { 0x8796, "GL_OP_SUB_EXT" }, + { 0x8797, "GL_OP_CROSS_PRODUCT_EXT" }, + { 0x8798, "GL_OP_MULTIPLY_MATRIX_EXT" }, + { 0x8799, "GL_OP_MOV_EXT" }, + { 0x879A, "GL_OUTPUT_VERTEX_EXT" }, + { 0x879B, "GL_OUTPUT_COLOR0_EXT" }, + { 0x879C, "GL_OUTPUT_COLOR1_EXT" }, + { 0x879D, "GL_OUTPUT_TEXTURE_COORD0_EXT" }, + { 0x879E, "GL_OUTPUT_TEXTURE_COORD1_EXT" }, + { 0x879F, "GL_OUTPUT_TEXTURE_COORD2_EXT" }, + { 0x87A0, "GL_OUTPUT_TEXTURE_COORD3_EXT" }, + { 0x87A1, "GL_OUTPUT_TEXTURE_COORD4_EXT" }, + { 0x87A2, "GL_OUTPUT_TEXTURE_COORD5_EXT" }, + { 0x87A3, "GL_OUTPUT_TEXTURE_COORD6_EXT" }, + { 0x87A4, "GL_OUTPUT_TEXTURE_COORD7_EXT" }, + { 0x87A5, "GL_OUTPUT_TEXTURE_COORD8_EXT" }, + { 0x87A6, "GL_OUTPUT_TEXTURE_COORD9_EXT" }, + { 0x87A7, "GL_OUTPUT_TEXTURE_COORD10_EXT" }, + { 0x87A8, "GL_OUTPUT_TEXTURE_COORD11_EXT" }, + { 0x87A9, "GL_OUTPUT_TEXTURE_COORD12_EXT" }, + { 0x87AA, "GL_OUTPUT_TEXTURE_COORD13_EXT" }, + { 0x87AB, "GL_OUTPUT_TEXTURE_COORD14_EXT" }, + { 0x87AC, "GL_OUTPUT_TEXTURE_COORD15_EXT" }, + { 0x87AD, "GL_OUTPUT_TEXTURE_COORD16_EXT" }, + { 0x87AE, "GL_OUTPUT_TEXTURE_COORD17_EXT" }, + { 0x87AF, "GL_OUTPUT_TEXTURE_COORD18_EXT" }, + { 0x87B0, "GL_OUTPUT_TEXTURE_COORD19_EXT" }, + { 0x87B1, "GL_OUTPUT_TEXTURE_COORD20_EXT" }, + { 0x87B2, "GL_OUTPUT_TEXTURE_COORD21_EXT" }, + { 0x87B3, "GL_OUTPUT_TEXTURE_COORD22_EXT" }, + { 0x87B4, "GL_OUTPUT_TEXTURE_COORD23_EXT" }, + { 0x87B5, "GL_OUTPUT_TEXTURE_COORD24_EXT" }, + { 0x87B6, "GL_OUTPUT_TEXTURE_COORD25_EXT" }, + { 0x87B7, "GL_OUTPUT_TEXTURE_COORD26_EXT" }, + { 0x87B8, "GL_OUTPUT_TEXTURE_COORD27_EXT" }, + { 0x87B9, "GL_OUTPUT_TEXTURE_COORD28_EXT" }, + { 0x87BA, "GL_OUTPUT_TEXTURE_COORD29_EXT" }, + { 0x87BB, "GL_OUTPUT_TEXTURE_COORD30_EXT" }, + { 0x87BC, "GL_OUTPUT_TEXTURE_COORD31_EXT" }, + { 0x87BD, "GL_OUTPUT_FOG_EXT" }, + { 0x87BE, "GL_SCALAR_EXT" }, + { 0x87BF, "GL_VECTOR_EXT" }, + { 0x87C0, "GL_MATRIX_EXT" }, + { 0x87C1, "GL_VARIANT_EXT" }, + { 0x87C2, "GL_INVARIANT_EXT" }, + { 0x87C3, "GL_LOCAL_CONSTANT_EXT" }, + { 0x87C4, "GL_LOCAL_EXT" }, + { 0x87C5, "GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT" }, + { 0x87C6, "GL_MAX_VERTEX_SHADER_VARIANTS_EXT" }, + { 0x87C7, "GL_MAX_VERTEX_SHADER_INVARIANTS_EXT" }, + { 0x87C8, "GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT" }, + { 0x87C9, "GL_MAX_VERTEX_SHADER_LOCALS_EXT" }, + { 0x87CA, "GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT" }, + { 0x87CB, "GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT" }, + { 0x87CC, "GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT" }, + { 0x87CD, "GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT" }, + { 0x87CE, "GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT" }, + { 0x87CF, "GL_VERTEX_SHADER_INSTRUCTIONS_EXT" }, + { 0x87D0, "GL_VERTEX_SHADER_VARIANTS_EXT" }, + { 0x87D1, "GL_VERTEX_SHADER_INVARIANTS_EXT" }, + { 0x87D2, "GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT" }, + { 0x87D3, "GL_VERTEX_SHADER_LOCALS_EXT" }, + { 0x87D4, "GL_VERTEX_SHADER_OPTIMIZED_EXT" }, + { 0x87D5, "GL_X_EXT" }, + { 0x87D6, "GL_Y_EXT" }, + { 0x87D7, "GL_Z_EXT" }, + { 0x87D8, "GL_W_EXT" }, + { 0x87D9, "GL_NEGATIVE_X_EXT" }, + { 0x87DA, "GL_NEGATIVE_Y_EXT" }, + { 0x87DB, "GL_NEGATIVE_Z_EXT" }, + { 0x87DC, "GL_NEGATIVE_W_EXT" }, + { 0x87DF, "GL_NEGATIVE_ONE_EXT" }, + { 0x87E0, "GL_NORMALIZED_RANGE_EXT" }, + { 0x87E1, "GL_FULL_RANGE_EXT" }, + { 0x87E2, "GL_CURRENT_VERTEX_EXT" }, + { 0x87E3, "GL_MVP_MATRIX_EXT" }, + { 0x87E4, "GL_VARIANT_VALUE_EXT" }, + { 0x87E5, "GL_VARIANT_DATATYPE_EXT" }, + { 0x87E6, "GL_VARIANT_ARRAY_STRIDE_EXT" }, + { 0x87E7, "GL_VARIANT_ARRAY_TYPE_EXT" }, + { 0x87E8, "GL_VARIANT_ARRAY_EXT" }, + { 0x87E9, "GL_VARIANT_ARRAY_POINTER_EXT" }, + { 0x87EA, "GL_INVARIANT_VALUE_EXT" }, + { 0x87EB, "GL_INVARIANT_DATATYPE_EXT" }, + { 0x87EC, "GL_LOCAL_CONSTANT_VALUE_EXT" }, + { 0x87Ed, "GL_LOCAL_CONSTANT_DATATYPE_EXT" }, + { 0x8800, "GL_STENCIL_BACK_FUNC_ATI" }, + { 0x8800, "GL_STENCIL_BACK_FUNC" }, + { 0x8801, "GL_STENCIL_BACK_FAIL_ATI" }, + { 0x8801, "GL_STENCIL_BACK_FAIL" }, + { 0x8802, "GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI" }, + { 0x8802, "GL_STENCIL_BACK_PASS_DEPTH_FAIL" }, + { 0x8803, "GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI" }, + { 0x8803, "GL_STENCIL_BACK_PASS_DEPTH_PASS" }, + { 0x8804, "GL_FRAGMENT_PROGRAM_ARB" }, + { 0x8805, "GL_PROGRAM_ALU_INSTRUCTIONS_ARB" }, + { 0x8806, "GL_PROGRAM_TEX_INSTRUCTIONS_ARB" }, + { 0x8807, "GL_PROGRAM_TEX_INDIRECTIONS_ARB" }, + { 0x8808, "GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" }, + { 0x8809, "GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" }, + { 0x880A, "GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" }, + { 0x880B, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" }, + { 0x880C, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" }, + { 0x880D, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" }, + { 0x880E, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" }, + { 0x880F, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" }, + { 0x8810, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" }, + { 0x8814, "GL_RGBA_FLOAT32_APPLE" }, + { 0x8814, "GL_RGBA_FLOAT32_ATI" }, + { 0x8814, "GL_RGBA32F_ARB" }, + { 0x8815, "GL_RGB_FLOAT32_APPLE" }, + { 0x8815, "GL_RGB_FLOAT32_ATI" }, + { 0x8815, "GL_RGB32F_ARB" }, + { 0x8816, "GL_ALPHA_FLOAT32_APPLE" }, + { 0x8816, "GL_ALPHA_FLOAT32_ATI" }, + { 0x8816, "GL_ALPHA32F_ARB" }, + { 0x8817, "GL_INTENSITY_FLOAT32_APPLE" }, + { 0x8817, "GL_INTENSITY_FLOAT32_ATI" }, + { 0x8817, "GL_INTENSITY32F_ARB" }, + { 0x8818, "GL_LUMINANCE_FLOAT32_APPLE" }, + { 0x8818, "GL_LUMINANCE_FLOAT32_ATI" }, + { 0x8818, "GL_LUMINANCE32F_ARB" }, + { 0x8819, "GL_LUMINANCE_ALPHA_FLOAT32_APPLE" }, + { 0x8819, "GL_LUMINANCE_ALPHA_FLOAT32_ATI" }, + { 0x8819, "GL_LUMINANCE_ALPHA32F_ARB" }, + { 0x881A, "GL_RGBA_FLOAT16_APPLE" }, + { 0x881A, "GL_RGBA_FLOAT16_ATI" }, + { 0x881A, "GL_RGBA16F_ARB" }, + { 0x881B, "GL_RGB_FLOAT16_APPLE" }, + { 0x881B, "GL_RGB_FLOAT16_ATI" }, + { 0x881B, "GL_RGB16F_ARB" }, + { 0x881C, "GL_ALPHA_FLOAT16_APPLE" }, + { 0x881C, "GL_ALPHA_FLOAT16_ATI" }, + { 0x881C, "GL_ALPHA16F_ARB" }, + { 0x881D, "GL_INTENSITY_FLOAT16_APPLE" }, + { 0x881D, "GL_INTENSITY_FLOAT16_ATI" }, + { 0x881D, "GL_INTENSITY16F_ARB" }, + { 0x881E, "GL_LUMINANCE_FLOAT16_APPLE" }, + { 0x881E, "GL_LUMINANCE_FLOAT16_ATI" }, + { 0x881E, "GL_LUMINANCE16F_ARB" }, + { 0x881F, "GL_LUMINANCE_ALPHA_FLOAT16_APPLE" }, + { 0x881F, "GL_LUMINANCE_ALPHA_FLOAT16_ATI" }, + { 0x881F, "GL_LUMINANCE_ALPHA16F_ARB" }, + { 0x8820, "GL_RGBA_FLOAT_MODE_ARB" }, + { 0x8824, "GL_MAX_DRAW_BUFFERS_ARB" }, + { 0x8824, "GL_MAX_DRAW_BUFFERS" }, + { 0x8825, "GL_DRAW_BUFFER0_ARB" }, + { 0x8825, "GL_DRAW_BUFFER0" }, + { 0x8826, "GL_DRAW_BUFFER1_ARB" }, + { 0x8826, "GL_DRAW_BUFFER1" }, + { 0x8827, "GL_DRAW_BUFFER2_ARB" }, + { 0x8827, "GL_DRAW_BUFFER2" }, + { 0x8828, "GL_DRAW_BUFFER3_ARB" }, + { 0x8828, "GL_DRAW_BUFFER3" }, + { 0x8829, "GL_DRAW_BUFFER4_ARB" }, + { 0x8829, "GL_DRAW_BUFFER4" }, + { 0x882A, "GL_DRAW_BUFFER5_ARB" }, + { 0x882A, "GL_DRAW_BUFFER5" }, + { 0x882B, "GL_DRAW_BUFFER6_ARB" }, + { 0x882B, "GL_DRAW_BUFFER6" }, + { 0x882C, "GL_DRAW_BUFFER7_ARB" }, + { 0x882C, "GL_DRAW_BUFFER7" }, + { 0x882D, "GL_DRAW_BUFFER8_ARB" }, + { 0x882D, "GL_DRAW_BUFFER8" }, + { 0x882E, "GL_DRAW_BUFFER9_ARB" }, + { 0x882E, "GL_DRAW_BUFFER9" }, + { 0x882F, "GL_DRAW_BUFFER10_ARB" }, + { 0x882F, "GL_DRAW_BUFFER10" }, + { 0x8830, "GL_DRAW_BUFFER11_ARB" }, + { 0x8830, "GL_DRAW_BUFFER11" }, + { 0x8831, "GL_DRAW_BUFFER12_ARB" }, + { 0x8831, "GL_DRAW_BUFFER12" }, + { 0x8832, "GL_DRAW_BUFFER13_ARB" }, + { 0x8832, "GL_DRAW_BUFFER13" }, + { 0x8833, "GL_DRAW_BUFFER14_ARB" }, + { 0x8833, "GL_DRAW_BUFFER14" }, + { 0x8834, "GL_DRAW_BUFFER15_ARB" }, + { 0x8834, "GL_DRAW_BUFFER15" }, + { 0x883D, "GL_ALPHA_BLEND_EQUATION_ATI" }, + { 0x883D, "GL_BLEND_EQUATION_ALPHA_EXT" }, + { 0x883D, "GL_BLEND_EQUATION_ALPHA" }, + { 0x884A, "GL_TEXTURE_DEPTH_SIZE_ARB" }, + { 0x884A, "GL_TEXTURE_DEPTH_SIZE" }, + { 0x884B, "GL_DEPTH_TEXTURE_MODE_ARB" }, + { 0x884B, "GL_DEPTH_TEXTURE_MODE" }, + { 0x884C, "GL_TEXTURE_COMPARE_MODE_ARB" }, + { 0x884C, "GL_TEXTURE_COMPARE_MODE" }, + { 0x884D, "GL_TEXTURE_COMPARE_FUNC_ARB" }, + { 0x884D, "GL_TEXTURE_COMPARE_FUNC" }, + { 0x884E, "GL_COMPARE_R_TO_TEXTURE_ARB" }, + { 0x884E, "GL_COMPARE_R_TO_TEXTURE" }, + { 0x884E, "GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT" }, + { 0x8861, "GL_POINT_SPRITE_ARB" }, + { 0x8861, "GL_POINT_SPRITE" }, + { 0x8862, "GL_COORD_REPLACE_ARB" }, + { 0x8862, "GL_COORD_REPLACE" }, + { 0x8864, "GL_QUERY_COUNTER_BITS_ARB" }, + { 0x8864, "GL_QUERY_COUNTER_BITS" }, + { 0x8865, "GL_CURRENT_QUERY_ARB" }, + { 0x8865, "GL_CURRENT_QUERY" }, + { 0x8866, "GL_QUERY_RESULT_ARB" }, + { 0x8866, "GL_QUERY_RESULT" }, + { 0x8867, "GL_QUERY_RESULT_AVAILABLE_ARB" }, + { 0x8867, "GL_QUERY_RESULT_AVAILABLE" }, + { 0x8869, "GL_MAX_VERTEX_ATTRIBS_ARB" }, + { 0x8869, "GL_MAX_VERTEX_ATTRIBS_ARB" }, + { 0x8869, "GL_MAX_VERTEX_ATTRIBS" }, + { 0x886A, "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB" }, + { 0x886A, "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB" }, + { 0x886A, "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED" }, + { 0x8871, "GL_MAX_TEXTURE_COORDS_ARB" }, + { 0x8871, "GL_MAX_TEXTURE_COORDS_ARB" }, + { 0x8871, "GL_MAX_TEXTURE_COORDS_ARB" }, + { 0x8871, "GL_MAX_TEXTURE_COORDS" }, + { 0x8872, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, + { 0x8872, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, + { 0x8872, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, + { 0x8872, "GL_MAX_TEXTURE_IMAGE_UNITS" }, + { 0x8874, "GL_PROGRAM_ERROR_STRING_ARB" }, + { 0x8875, "GL_PROGRAM_FORMAT_ASCII_ARB" }, + { 0x8876, "GL_PROGRAM_FORMAT_ARB" }, + { 0x8890, "GL_DEPTH_BOUNDS_TEST_EXT" }, + { 0x8891, "GL_DEPTH_BOUNDS_EXT" }, + { 0x8892, "GL_ARRAY_BUFFER_ARB" }, + { 0x8892, "GL_ARRAY_BUFFER" }, + { 0x8893, "GL_ELEMENT_ARRAY_BUFFER_ARB" }, + { 0x8893, "GL_ELEMENT_ARRAY_BUFFER" }, + { 0x8894, "GL_ARRAY_BUFFER_BINDING_ARB" }, + { 0x8894, "GL_ARRAY_BUFFER_BINDING" }, + { 0x8895, "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB" }, + { 0x8895, "GL_ELEMENT_ARRAY_BUFFER_BINDING" }, + { 0x8896, "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB" }, + { 0x8896, "GL_VERTEX_ARRAY_BUFFER_BINDING" }, + { 0x8897, "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB" }, + { 0x8897, "GL_NORMAL_ARRAY_BUFFER_BINDING" }, + { 0x8898, "GL_COLOR_ARRAY_BUFFER_BINDING_ARB" }, + { 0x8898, "GL_COLOR_ARRAY_BUFFER_BINDING" }, + { 0x8899, "GL_INDEX_ARRAY_BUFFER_BINDING_ARB" }, + { 0x8899, "GL_INDEX_ARRAY_BUFFER_BINDING" }, + { 0x889A, "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB" }, + { 0x889A, "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING" }, + { 0x889B, "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB" }, + { 0x889B, "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING" }, + { 0x889C, "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB" }, + { 0x889C, "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING" }, + { 0x889D, "GL_FOG_COORD_ARRAY_BUFFER_BINDING_ARB" }, + { 0x889D, "GL_FOG_COORD_ARRAY_BUFFER_BINDING" }, + { 0x889D, "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB" }, + { 0x889D, "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING" }, + { 0x889E, "GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB" }, + { 0x889E, "GL_WEIGHT_ARRAY_BUFFER_BINDING" }, + { 0x889F, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB" }, + { 0x889F, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING" }, + { 0x88A0, "GL_PROGRAM_INSTRUCTIONS_ARB" }, + { 0x88A1, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" }, + { 0x88A2, "GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB" }, + { 0x88A3, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" }, + { 0x88A4, "GL_PROGRAM_TEMPORARIES_ARB" }, + { 0x88A5, "GL_MAX_PROGRAM_TEMPORARIES_ARB" }, + { 0x88A6, "GL_PROGRAM_NATIVE_TEMPORARIES_ARB" }, + { 0x88A7, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" }, + { 0x88A8, "GL_PROGRAM_PARAMETERS_ARB" }, + { 0x88A9, "GL_MAX_PROGRAM_PARAMETERS_ARB" }, + { 0x88AA, "GL_PROGRAM_NATIVE_PARAMETERS_ARB" }, + { 0x88AB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" }, + { 0x88AC, "GL_PROGRAM_ATTRIBS_ARB" }, + { 0x88AD, "GL_MAX_PROGRAM_ATTRIBS_ARB" }, + { 0x88AE, "GL_PROGRAM_NATIVE_ATTRIBS_ARB" }, + { 0x88AF, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" }, + { 0x88B0, "GL_PROGRAM_ADDRESS_REGISTERS_ARB" }, + { 0x88B1, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" }, + { 0x88B2, "GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" }, + { 0x88B3, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" }, + { 0x88B4, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" }, + { 0x88B5, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" }, + { 0x88B6, "GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB" }, + { 0x88B7, "GL_TRANSPOSE_CURRENT_MATRIX_ARB" }, + { 0x88B8, "GL_READ_ONLY_ARB" }, + { 0x88B8, "GL_READ_ONLY" }, + { 0x88B9, "GL_WRITE_ONLY_ARB" }, + { 0x88B9, "GL_WRITE_ONLY" }, + { 0x88BA, "GL_READ_WRITE_ARB" }, + { 0x88BA, "GL_READ_WRITE" }, + { 0x88BB, "GL_BUFFER_ACCESS_ARB" }, + { 0x88BB, "GL_BUFFER_ACCESS" }, + { 0x88BC, "GL_BUFFER_MAPPED_ARB" }, + { 0x88BC, "GL_BUFFER_MAPPED" }, + { 0x88BD, "GL_BUFFER_MAP_POINTER_ARB" }, + { 0x88BD, "GL_BUFFER_MAP_POINTER" }, + { 0x88C0, "GL_MATRIX0_ARB" }, + { 0x88C1, "GL_MATRIX1_ARB" }, + { 0x88C2, "GL_MATRIX2_ARB" }, + { 0x88C3, "GL_MATRIX3_ARB" }, + { 0x88C4, "GL_MATRIX4_ARB" }, + { 0x88C5, "GL_MATRIX5_ARB" }, + { 0x88C6, "GL_MATRIX6_ARB" }, + { 0x88C7, "GL_MATRIX7_ARB" }, + { 0x88C8, "GL_MATRIX8_ARB" }, + { 0x88C9, "GL_MATRIX9_ARB" }, + { 0x88CA, "GL_MATRIX10_ARB" }, + { 0x88CB, "GL_MATRIX11_ARB" }, + { 0x88CC, "GL_MATRIX12_ARB" }, + { 0x88CD, "GL_MATRIX13_ARB" }, + { 0x88CE, "GL_MATRIX14_ARB" }, + { 0x88CF, "GL_MATRIX15_ARB" }, + { 0x88D0, "GL_MATRIX16_ARB" }, + { 0x88D1, "GL_MATRIX17_ARB" }, + { 0x88D2, "GL_MATRIX18_ARB" }, + { 0x88D3, "GL_MATRIX19_ARB" }, + { 0x88D4, "GL_MATRIX20_ARB" }, + { 0x88D5, "GL_MATRIX21_ARB" }, + { 0x88D6, "GL_MATRIX22_ARB" }, + { 0x88D7, "GL_MATRIX23_ARB" }, + { 0x88D8, "GL_MATRIX24_ARB" }, + { 0x88D9, "GL_MATRIX25_ARB" }, + { 0x88DA, "GL_MATRIX26_ARB" }, + { 0x88DB, "GL_MATRIX27_ARB" }, + { 0x88DC, "GL_MATRIX28_ARB" }, + { 0x88DD, "GL_MATRIX29_ARB" }, + { 0x88DE, "GL_MATRIX30_ARB" }, + { 0x88DF, "GL_MATRIX31_ARB" }, + { 0x88E0, "GL_STREAM_DRAW_ARB" }, + { 0x88E0, "GL_STREAM_DRAW" }, + { 0x88E1, "GL_STREAM_READ_ARB" }, + { 0x88E1, "GL_STREAM_READ" }, + { 0x88E2, "GL_STREAM_COPY_ARB" }, + { 0x88E2, "GL_STREAM_COPY" }, + { 0x88E4, "GL_STATIC_DRAW_ARB" }, + { 0x88E4, "GL_STATIC_DRAW" }, + { 0x88E5, "GL_STATIC_READ_ARB" }, + { 0x88E5, "GL_STATIC_READ" }, + { 0x88E6, "GL_STATIC_COPY_ARB" }, + { 0x88E6, "GL_STATIC_COPY" }, + { 0x88E8, "GL_DYNAMIC_DRAW_ARB" }, + { 0x88E8, "GL_DYNAMIC_DRAW" }, + { 0x88E9, "GL_DYNAMIC_READ_ARB" }, + { 0x88E9, "GL_DYNAMIC_READ" }, + { 0x88EA, "GL_DYNAMIC_COPY_ARB" }, + { 0x88EA, "GL_DYNAMIC_COPY" }, + { 0x88EB, "GL_PIXEL_PACK_BUFFER_ARB" }, + { 0x88EB, "GL_PIXEL_PACK_BUFFER" }, + { 0x88EC, "GL_PIXEL_UNPACK_BUFFER_ARB" }, + { 0x88EC, "GL_PIXEL_UNPACK_BUFFER" }, + { 0x88ED, "GL_PIXEL_PACK_BUFFER_BINDING_ARB" }, + { 0x88ED, "GL_PIXEL_PACK_BUFFER_BINDING" }, + { 0x88EF, "GL_PIXEL_UNPACK_BUFFER_BINDING_ARB" }, + { 0x88EF, "GL_PIXEL_UNPACK_BUFFER_BINDING" }, + { 0x88F0, "GL_DEPTH24_STENCIL8_EXT" }, + { 0x88F0, "GL_DEPTH24_STENCIL8" }, + { 0x88F1, "GL_TEXTURE_STENCIL_SIZE_EXT" }, + { 0x88F1, "GL_TEXTURE_STENCIL_SIZE" }, + { 0x88FD, "GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT" }, + { 0x88FE, "GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB" }, + { 0x88FF, "GL_MAX_ARRAY_TEXTURE_LAYERS_EXT" }, + { 0x8904, "GL_MIN_PROGRAM_TEXEL_OFFSET_EXT" }, + { 0x8905, "GL_MAX_PROGRAM_TEXEL_OFFSET_EXT" }, + { 0x8910, "GL_STENCIL_TEST_TWO_SIDE_EXT" }, + { 0x8911, "GL_ACTIVE_STENCIL_FACE_EXT" }, + { 0x8912, "GL_MIRROR_CLAMP_TO_BORDER_EXT" }, + { 0x8914, "GL_SAMPLES_PASSED_ARB" }, + { 0x8914, "GL_SAMPLES_PASSED" }, + { 0x891A, "GL_CLAMP_VERTEX_COLOR_ARB" }, + { 0x891B, "GL_CLAMP_FRAGMENT_COLOR_ARB" }, + { 0x891C, "GL_CLAMP_READ_COLOR_ARB" }, + { 0x891D, "GL_FIXED_ONLY_ARB" }, + { 0x8920, "GL_FRAGMENT_SHADER_EXT" }, + { 0x896D, "GL_SECONDARY_INTERPOLATOR_EXT" }, + { 0x896E, "GL_NUM_FRAGMENT_REGISTERS_EXT" }, + { 0x896F, "GL_NUM_FRAGMENT_CONSTANTS_EXT" }, + { 0x8A0C, "GL_ELEMENT_ARRAY_APPLE" }, + { 0x8A0D, "GL_ELEMENT_ARRAY_TYPE_APPLE" }, + { 0x8A0E, "GL_ELEMENT_ARRAY_POINTER_APPLE" }, + { 0x8A0F, "GL_COLOR_FLOAT_APPLE" }, + { 0x8A11, "GL_UNIFORM_BUFFER" }, + { 0x8A28, "GL_UNIFORM_BUFFER_BINDING" }, + { 0x8A29, "GL_UNIFORM_BUFFER_START" }, + { 0x8A2A, "GL_UNIFORM_BUFFER_SIZE" }, + { 0x8A2B, "GL_MAX_VERTEX_UNIFORM_BLOCKS" }, + { 0x8A2C, "GL_MAX_GEOMETRY_UNIFORM_BLOCKS" }, + { 0x8A2D, "GL_MAX_FRAGMENT_UNIFORM_BLOCKS" }, + { 0x8A2E, "GL_MAX_COMBINED_UNIFORM_BLOCKS" }, + { 0x8A2F, "GL_MAX_UNIFORM_BUFFER_BINDINGS" }, + { 0x8A30, "GL_MAX_UNIFORM_BLOCK_SIZE" }, + { 0x8A31, "GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS" }, + { 0x8A32, "GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS" }, + { 0x8A33, "GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS" }, + { 0x8A34, "GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT" }, + { 0x8A35, "GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH" }, + { 0x8A36, "GL_ACTIVE_UNIFORM_BLOCKS" }, + { 0x8A37, "GL_UNIFORM_TYPE" }, + { 0x8A38, "GL_UNIFORM_SIZE" }, + { 0x8A39, "GL_UNIFORM_NAME_LENGTH" }, + { 0x8A3A, "GL_UNIFORM_BLOCK_INDEX" }, + { 0x8A3B, "GL_UNIFORM_OFFSET" }, + { 0x8A3C, "GL_UNIFORM_ARRAY_STRIDE" }, + { 0x8A3D, "GL_UNIFORM_MATRIX_STRIDE" }, + { 0x8A3E, "GL_UNIFORM_IS_ROW_MAJOR" }, + { 0x8A3F, "GL_UNIFORM_BLOCK_BINDING" }, + { 0x8A40, "GL_UNIFORM_BLOCK_DATA_SIZE" }, + { 0x8A41, "GL_UNIFORM_BLOCK_NAME_LENGTH" }, + { 0x8A42, "GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS" }, + { 0x8A43, "GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES" }, + { 0x8A44, "GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER" }, + { 0x8A45, "GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER" }, + { 0x8A46, "GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER" }, + { 0x8B30, "GL_FRAGMENT_SHADER_ARB" }, + { 0x8B30, "GL_FRAGMENT_SHADER" }, + { 0x8B31, "GL_VERTEX_SHADER_ARB" }, + { 0x8B31, "GL_VERTEX_SHADER" }, + { 0x8B40, "GL_PROGRAM_OBJECT_ARB" }, + { 0x8B48, "GL_SHADER_OBJECT_ARB" }, + { 0x8B49, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" }, + { 0x8B49, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS" }, + { 0x8B4A, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" }, + { 0x8B4A, "GL_MAX_VERTEX_UNIFORM_COMPONENTS" }, + { 0x8B4B, "GL_MAX_VARYING_COMPONENTS_EXT" }, + { 0x8B4B, "GL_MAX_VARYING_FLOATS_ARB" }, + { 0x8B4B, "GL_MAX_VARYING_FLOATS" }, + { 0x8B4C, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" }, + { 0x8B4C, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS" }, + { 0x8B4D, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" }, + { 0x8B4D, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS" }, + { 0x8B4E, "GL_OBJECT_TYPE_ARB" }, + { 0x8B4F, "GL_OBJECT_SUBTYPE_ARB" }, + { 0x8B4F, "GL_SHADER_TYPE" }, + { 0x8B50, "GL_FLOAT_VEC2_ARB" }, + { 0x8B50, "GL_FLOAT_VEC2" }, + { 0x8B51, "GL_FLOAT_VEC3_ARB" }, + { 0x8B51, "GL_FLOAT_VEC3" }, + { 0x8B52, "GL_FLOAT_VEC4_ARB" }, + { 0x8B52, "GL_FLOAT_VEC4" }, + { 0x8B53, "GL_INT_VEC2_ARB" }, + { 0x8B53, "GL_INT_VEC2" }, + { 0x8B54, "GL_INT_VEC3_ARB" }, + { 0x8B54, "GL_INT_VEC3" }, + { 0x8B55, "GL_INT_VEC4_ARB" }, + { 0x8B55, "GL_INT_VEC4" }, + { 0x8B56, "GL_BOOL_ARB" }, + { 0x8B56, "GL_BOOL" }, + { 0x8B57, "GL_BOOL_VEC2_ARB" }, + { 0x8B57, "GL_BOOL_VEC2" }, + { 0x8B58, "GL_BOOL_VEC3_ARB" }, + { 0x8B58, "GL_BOOL_VEC3" }, + { 0x8B59, "GL_BOOL_VEC4_ARB" }, + { 0x8B59, "GL_BOOL_VEC4" }, + { 0x8B5A, "GL_FLOAT_MAT2_ARB" }, + { 0x8B5A, "GL_FLOAT_MAT2" }, + { 0x8B5B, "GL_FLOAT_MAT3_ARB" }, + { 0x8B5B, "GL_FLOAT_MAT3" }, + { 0x8B5C, "GL_FLOAT_MAT4_ARB" }, + { 0x8B5C, "GL_FLOAT_MAT4" }, + { 0x8B5D, "GL_SAMPLER_1D_ARB" }, + { 0x8B5D, "GL_SAMPLER_1D" }, + { 0x8B5E, "GL_SAMPLER_2D_ARB" }, + { 0x8B5E, "GL_SAMPLER_2D" }, + { 0x8B5F, "GL_SAMPLER_3D_ARB" }, + { 0x8B5F, "GL_SAMPLER_3D" }, + { 0x8B60, "GL_SAMPLER_CUBE_ARB" }, + { 0x8B60, "GL_SAMPLER_CUBE" }, + { 0x8B61, "GL_SAMPLER_1D_SHADOW_ARB" }, + { 0x8B61, "GL_SAMPLER_1D_SHADOW" }, + { 0x8B62, "GL_SAMPLER_2D_SHADOW_ARB" }, + { 0x8B62, "GL_SAMPLER_2D_SHADOW" }, + { 0x8B63, "GL_SAMPLER_2D_RECT_ARB" }, + { 0x8B64, "GL_SAMPLER_2D_RECT_SHADOW_ARB" }, + { 0x8B65, "GL_FLOAT_MAT2x3" }, + { 0x8B66, "GL_FLOAT_MAT2x4" }, + { 0x8B67, "GL_FLOAT_MAT3x2" }, + { 0x8B68, "GL_FLOAT_MAT3x4" }, + { 0x8B69, "GL_FLOAT_MAT4x2" }, + { 0x8B6A, "GL_FLOAT_MAT4x3" }, + { 0x8B80, "GL_DELETE_STATUS" }, + { 0x8B80, "GL_OBJECT_DELETE_STATUS_ARB" }, + { 0x8B81, "GL_COMPILE_STATUS" }, + { 0x8B81, "GL_OBJECT_COMPILE_STATUS_ARB" }, + { 0x8B82, "GL_LINK_STATUS" }, + { 0x8B82, "GL_OBJECT_LINK_STATUS_ARB" }, + { 0x8B83, "GL_OBJECT_VALIDATE_STATUS_ARB" }, + { 0x8B83, "GL_VALIDATE_STATUS" }, + { 0x8B84, "GL_INFO_LOG_LENGTH" }, + { 0x8B84, "GL_OBJECT_INFO_LOG_LENGTH_ARB" }, + { 0x8B85, "GL_ATTACHED_SHADERS" }, + { 0x8B85, "GL_OBJECT_ATTACHED_OBJECTS_ARB" }, + { 0x8B86, "GL_ACTIVE_UNIFORMS" }, + { 0x8B86, "GL_OBJECT_ACTIVE_UNIFORMS_ARB" }, + { 0x8B87, "GL_ACTIVE_UNIFORM_MAX_LENGTH" }, + { 0x8B87, "GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB" }, + { 0x8B88, "GL_OBJECT_SHADER_SOURCE_LENGTH_ARB" }, + { 0x8B88, "GL_SHADER_SOURCE_LENGTH" }, + { 0x8B89, "GL_ACTIVE_ATTRIBUTES" }, + { 0x8B89, "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB" }, + { 0x8B8A, "GL_ACTIVE_ATTRIBUTE_MAX_LENGTH" }, + { 0x8B8A, "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB" }, + { 0x8B8B, "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB" }, + { 0x8B8B, "GL_FRAGMENT_SHADER_DERIVATIVE_HINT" }, + { 0x8B8C, "GL_SHADING_LANGUAGE_VERSION_ARB" }, + { 0x8B8C, "GL_SHADING_LANGUAGE_VERSION" }, + { 0x8B8D, "GL_CURRENT_PROGRAM" }, + { 0x8C10, "GL_TEXTURE_RED_TYPE_ARB" }, + { 0x8C10, "GL_TEXTURE_RED_TYPE" }, + { 0x8C11, "GL_TEXTURE_GREEN_TYPE_ARB" }, + { 0x8C11, "GL_TEXTURE_GREEN_TYPE" }, + { 0x8C12, "GL_TEXTURE_BLUE_TYPE_ARB" }, + { 0x8C12, "GL_TEXTURE_BLUE_TYPE" }, + { 0x8C13, "GL_TEXTURE_ALPHA_TYPE_ARB" }, + { 0x8C13, "GL_TEXTURE_ALPHA_TYPE" }, + { 0x8C14, "GL_TEXTURE_LUMINANCE_TYPE_ARB" }, + { 0x8C15, "GL_TEXTURE_INTENSITY_TYPE_ARB" }, + { 0x8C16, "GL_TEXTURE_DEPTH_TYPE_ARB" }, + { 0x8C16, "GL_TEXTURE_DEPTH_TYPE" }, + { 0x8C17, "GL_UNSIGNED_NORMALIZED_ARB" }, + { 0x8C17, "GL_UNSIGNED_NORMALIZED" }, + { 0x8C18, "GL_TEXTURE_1D_ARRAY_EXT" }, + { 0x8C19, "GL_PROXY_TEXTURE_1D_ARRAY_EXT" }, + { 0x8C1A, "GL_TEXTURE_2D_ARRAY_EXT" }, + { 0x8C1B, "GL_PROXY_TEXTURE_2D_ARRAY_EXT" }, + { 0x8C1C, "GL_TEXTURE_BINDING_1D_ARRAY_EXT" }, + { 0x8C1D, "GL_TEXTURE_BINDING_2D_ARRAY_EXT" }, + { 0x8C29, "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT" }, + { 0x8C3A, "GL_R11F_G11F_B10F_EXT" }, + { 0x8C3B, "GL_UNSIGNED_INT_10F_11F_11F_REV_EXT" }, + { 0x8C3C, "GL_RGBA_SIGNED_COMPONENTS_EXT" }, + { 0x8C3D, "GL_RGB9_E5_EXT" }, + { 0x8C3E, "GL_UNSIGNED_INT_5_9_9_9_REV_EXT" }, + { 0x8C3F, "GL_TEXTURE_SHARED_SIZE_EXT" }, + { 0x8C40, "GL_SRGB_EXT" }, + { 0x8C40, "GL_SRGB" }, + { 0x8C41, "GL_SRGB8_EXT" }, + { 0x8C41, "GL_SRGB8" }, + { 0x8C42, "GL_SRGB_ALPHA_EXT" }, + { 0x8C42, "GL_SRGB_ALPHA" }, + { 0x8C43, "GL_SRGB8_ALPHA8_EXT" }, + { 0x8C43, "GL_SRGB8_ALPHA8" }, + { 0x8C44, "GL_SLUMINANCE_ALPHA_EXT" }, + { 0x8C44, "GL_SLUMINANCE_ALPHA" }, + { 0x8C45, "GL_SLUMINANCE8_ALPHA8_EXT" }, + { 0x8C45, "GL_SLUMINANCE8_ALPHA8" }, + { 0x8C46, "GL_SLUMINANCE_EXT" }, + { 0x8C46, "GL_SLUMINANCE" }, + { 0x8C47, "GL_SLUMINANCE8_EXT" }, + { 0x8C47, "GL_SLUMINANCE8" }, + { 0x8C48, "GL_COMPRESSED_SRGB_EXT" }, + { 0x8C48, "GL_COMPRESSED_SRGB" }, + { 0x8C49, "GL_COMPRESSED_SRGB_ALPHA_EXT" }, + { 0x8C49, "GL_COMPRESSED_SRGB_ALPHA" }, + { 0x8C4A, "GL_COMPRESSED_SLUMINANCE_EXT" }, + { 0x8C4A, "GL_COMPRESSED_SLUMINANCE" }, + { 0x8C4B, "GL_COMPRESSED_SLUMINANCE_ALPHA_EXT" }, + { 0x8C4B, "GL_COMPRESSED_SLUMINANCE_ALPHA" }, + { 0x8C4C, "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT" }, + { 0x8C4D, "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT" }, + { 0x8C4E, "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT" }, + { 0x8C4F, "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT" }, + { 0x8C76, "GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT" }, + { 0x8C7F, "GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT" }, + { 0x8C80, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT" }, + { 0x8C83, "GL_TRANSFORM_FEEDBACK_VARYINGS_EXT" }, + { 0x8C84, "GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT" }, + { 0x8C85, "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT" }, + { 0x8C87, "GL_PRIMITIVES_GENERATED_EXT" }, + { 0x8C88, "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT" }, + { 0x8C89, "GL_RASTERIZER_DISCARD_EXT" }, + { 0x8C8A, "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT" }, + { 0x8C8B, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT" }, + { 0x8C8C, "GL_INTERLEAVED_ATTRIBS_EXT" }, + { 0x8C8D, "GL_SEPARATE_ATTRIBS_EXT" }, + { 0x8C8E, "GL_TRANSFORM_FEEDBACK_BUFFER_EXT" }, + { 0x8C8F, "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT" }, + { 0x8CA0, "GL_POINT_SPRITE_COORD_ORIGIN" }, + { 0x8CA1, "GL_LOWER_LEFT" }, + { 0x8CA2, "GL_UPPER_LEFT" }, + { 0x8CA3, "GL_STENCIL_BACK_REF" }, + { 0x8CA4, "GL_STENCIL_BACK_VALUE_MASK" }, + { 0x8CA5, "GL_STENCIL_BACK_WRITEMASK" }, + { 0x8CA6, "GL_DRAW_FRAMEBUFFER_BINDING_EXT" }, + { 0x8CA6, "GL_FRAMEBUFFER_BINDING_EXT" }, + { 0x8CA6, "GL_FRAMEBUFFER_BINDING" }, + { 0x8CA7, "GL_RENDERBUFFER_BINDING_EXT" }, + { 0x8CA7, "GL_RENDERBUFFER_BINDING" }, + { 0x8CA8, "GL_READ_FRAMEBUFFER_EXT" }, + { 0x8CA8, "GL_READ_FRAMEBUFFER" }, + { 0x8CA9, "GL_DRAW_FRAMEBUFFER_EXT" }, + { 0x8CA9, "GL_DRAW_FRAMEBUFFER" }, + { 0x8CAA, "GL_READ_FRAMEBUFFER_BINDING_EXT" }, + { 0x8CAA, "GL_READ_FRAMEBUFFER_BINDING" }, + { 0x8CAB, "GL_RENDERBUFFER_SAMPLES_EXT" }, + { 0x8CAB, "GL_RENDERBUFFER_SAMPLES" }, + { 0x8CAC, "GL_DEPTH_COMPONENT32F" }, + { 0x8CAD, "GL_DEPTH32F_STENCIL8" }, + { 0x8CD0, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT" }, + { 0x8CD0, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE" }, + { 0x8CD1, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT" }, + { 0x8CD1, "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME" }, + { 0x8CD2, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT" }, + { 0x8CD2, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL" }, + { 0x8CD3, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT" }, + { 0x8CD3, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE" }, + { 0x8CD4, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT" }, + { 0x8CD4, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT" }, + { 0x8CD4, "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER" }, + { 0x8CD5, "GL_FRAMEBUFFER_COMPLETE_EXT" }, + { 0x8CD5, "GL_FRAMEBUFFER_COMPLETE" }, + { 0x8CD6, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT" }, + { 0x8CD6, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT" }, + { 0x8CD7, "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT" }, + { 0x8CD7, "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT" }, + { 0x8CD9, "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT" }, + { 0x8CDA, "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT" }, + { 0x8CDB, "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" }, + { 0x8CDB, "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER" }, + { 0x8CDC, "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" }, + { 0x8CDC, "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER" }, + { 0x8CDD, "GL_FRAMEBUFFER_UNSUPPORTED_EXT" }, + { 0x8CDD, "GL_FRAMEBUFFER_UNSUPPORTED" }, + { 0x8CDF, "GL_MAX_COLOR_ATTACHMENTS_EXT" }, + { 0x8CDF, "GL_MAX_COLOR_ATTACHMENTS" }, + { 0x8CE0, "GL_COLOR_ATTACHMENT0_EXT" }, + { 0x8CE0, "GL_COLOR_ATTACHMENT0" }, + { 0x8CE1, "GL_COLOR_ATTACHMENT1_EXT" }, + { 0x8CE1, "GL_COLOR_ATTACHMENT1" }, + { 0x8CE2, "GL_COLOR_ATTACHMENT2_EXT" }, + { 0x8CE2, "GL_COLOR_ATTACHMENT2" }, + { 0x8CE3, "GL_COLOR_ATTACHMENT3_EXT" }, + { 0x8CE3, "GL_COLOR_ATTACHMENT3" }, + { 0x8CE4, "GL_COLOR_ATTACHMENT4_EXT" }, + { 0x8CE4, "GL_COLOR_ATTACHMENT4" }, + { 0x8CE5, "GL_COLOR_ATTACHMENT5_EXT" }, + { 0x8CE5, "GL_COLOR_ATTACHMENT5" }, + { 0x8CE6, "GL_COLOR_ATTACHMENT6_EXT" }, + { 0x8CE6, "GL_COLOR_ATTACHMENT6" }, + { 0x8CE7, "GL_COLOR_ATTACHMENT7_EXT" }, + { 0x8CE7, "GL_COLOR_ATTACHMENT7" }, + { 0x8CE8, "GL_COLOR_ATTACHMENT8_EXT" }, + { 0x8CE8, "GL_COLOR_ATTACHMENT8" }, + { 0x8CE9, "GL_COLOR_ATTACHMENT9_EXT" }, + { 0x8CE9, "GL_COLOR_ATTACHMENT9" }, + { 0x8CEA, "GL_COLOR_ATTACHMENT10_EXT" }, + { 0x8CEA, "GL_COLOR_ATTACHMENT10" }, + { 0x8CEB, "GL_COLOR_ATTACHMENT11_EXT" }, + { 0x8CEB, "GL_COLOR_ATTACHMENT11" }, + { 0x8CEC, "GL_COLOR_ATTACHMENT12_EXT" }, + { 0x8CEC, "GL_COLOR_ATTACHMENT12" }, + { 0x8CED, "GL_COLOR_ATTACHMENT13_EXT" }, + { 0x8CED, "GL_COLOR_ATTACHMENT13" }, + { 0x8CEE, "GL_COLOR_ATTACHMENT14_EXT" }, + { 0x8CEE, "GL_COLOR_ATTACHMENT14" }, + { 0x8CEF, "GL_COLOR_ATTACHMENT15_EXT" }, + { 0x8CEF, "GL_COLOR_ATTACHMENT15" }, + { 0x8D00, "GL_DEPTH_ATTACHMENT_EXT" }, + { 0x8D00, "GL_DEPTH_ATTACHMENT" }, + { 0x8D20, "GL_STENCIL_ATTACHMENT_EXT" }, + { 0x8D20, "GL_STENCIL_ATTACHMENT" }, + { 0x8D40, "GL_FRAMEBUFFER_EXT" }, + { 0x8D40, "GL_FRAMEBUFFER" }, + { 0x8D41, "GL_RENDERBUFFER_EXT" }, + { 0x8D41, "GL_RENDERBUFFER" }, + { 0x8D42, "GL_RENDERBUFFER_WIDTH_EXT" }, + { 0x8D42, "GL_RENDERBUFFER_WIDTH" }, + { 0x8D43, "GL_RENDERBUFFER_HEIGHT_EXT" }, + { 0x8D43, "GL_RENDERBUFFER_HEIGHT" }, + { 0x8D44, "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT" }, + { 0x8D44, "GL_RENDERBUFFER_INTERNAL_FORMAT" }, + { 0x8D46, "GL_STENCIL_INDEX1_EXT" }, + { 0x8D46, "GL_STENCIL_INDEX1" }, + { 0x8D47, "GL_STENCIL_INDEX4_EXT" }, + { 0x8D47, "GL_STENCIL_INDEX4" }, + { 0x8D48, "GL_STENCIL_INDEX8_EXT" }, + { 0x8D48, "GL_STENCIL_INDEX8" }, + { 0x8D49, "GL_STENCIL_INDEX16_EXT" }, + { 0x8D49, "GL_STENCIL_INDEX16" }, + { 0x8D50, "GL_RENDERBUFFER_RED_SIZE_EXT" }, + { 0x8D50, "GL_RENDERBUFFER_RED_SIZE" }, + { 0x8D51, "GL_RENDERBUFFER_GREEN_SIZE_EXT" }, + { 0x8D51, "GL_RENDERBUFFER_GREEN_SIZE" }, + { 0x8D52, "GL_RENDERBUFFER_BLUE_SIZE_EXT" }, + { 0x8D52, "GL_RENDERBUFFER_BLUE_SIZE" }, + { 0x8D53, "GL_RENDERBUFFER_ALPHA_SIZE_EXT" }, + { 0x8D53, "GL_RENDERBUFFER_ALPHA_SIZE" }, + { 0x8D54, "GL_RENDERBUFFER_DEPTH_SIZE_EXT" }, + { 0x8D54, "GL_RENDERBUFFER_DEPTH_SIZE" }, + { 0x8D55, "GL_RENDERBUFFER_STENCIL_SIZE_EXT" }, + { 0x8D55, "GL_RENDERBUFFER_STENCIL_SIZE" }, + { 0x8D56, "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT" }, + { 0x8D56, "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE" }, + { 0x8D57, "GL_MAX_SAMPLES_EXT" }, + { 0x8D57, "GL_MAX_SAMPLES" }, + { 0x8D70, "GL_RGBA32UI_EXT" }, + { 0x8D71, "GL_RGB32UI_EXT" }, + { 0x8D72, "GL_ALPHA32UI_EXT" }, + { 0x8D73, "GL_INTENSITY32UI_EXT" }, + { 0x8D74, "GL_LUMINANCE32UI_EXT" }, + { 0x8D75, "GL_LUMINANCE_ALPHA32UI_EXT" }, + { 0x8D76, "GL_RGBA16UI_EXT" }, + { 0x8D77, "GL_RGB16UI_EXT" }, + { 0x8D78, "GL_ALPHA16UI_EXT" }, + { 0x8D79, "GL_INTENSITY16UI_EXT" }, + { 0x8D7A, "GL_LUMINANCE16UI_EXT" }, + { 0x8D7B, "GL_LUMINANCE_ALPHA16UI_EXT" }, + { 0x8D7C, "GL_RGBA8UI_EXT" }, + { 0x8D7D, "GL_RGB8UI_EXT" }, + { 0x8D7E, "GL_ALPHA8UI_EXT" }, + { 0x8D7F, "GL_INTENSITY8UI_EXT" }, + { 0x8D80, "GL_LUMINANCE8UI_EXT" }, + { 0x8D81, "GL_LUMINANCE_ALPHA8UI_EXT" }, + { 0x8D82, "GL_RGBA32I_EXT" }, + { 0x8D83, "GL_RGB32I_EXT" }, + { 0x8D84, "GL_ALPHA32I_EXT" }, + { 0x8D85, "GL_INTENSITY32I_EXT" }, + { 0x8D86, "GL_LUMINANCE32I_EXT" }, + { 0x8D87, "GL_LUMINANCE_ALPHA32I_EXT" }, + { 0x8D88, "GL_RGBA16I_EXT" }, + { 0x8D89, "GL_RGB16I_EXT" }, + { 0x8D8A, "GL_ALPHA16I_EXT" }, + { 0x8D8B, "GL_INTENSITY16I_EXT" }, + { 0x8D8C, "GL_LUMINANCE16I_EXT" }, + { 0x8D8D, "GL_LUMINANCE_ALPHA16I_EXT" }, + { 0x8D8E, "GL_RGBA8I_EXT" }, + { 0x8D8F, "GL_RGB8I_EXT" }, + { 0x8D90, "GL_ALPHA8I_EXT" }, + { 0x8D91, "GL_INTENSITY8I_EXT" }, + { 0x8D92, "GL_LUMINANCE8I_EXT" }, + { 0x8D93, "GL_LUMINANCE_ALPHA8I_EXT" }, + { 0x8D94, "GL_RED_INTEGER_EXT" }, + { 0x8D95, "GL_GREEN_INTEGER_EXT" }, + { 0x8D96, "GL_BLUE_INTEGER_EXT" }, + { 0x8D97, "GL_ALPHA_INTEGER_EXT" }, + { 0x8D98, "GL_RGB_INTEGER_EXT" }, + { 0x8D99, "GL_RGBA_INTEGER_EXT" }, + { 0x8D9A, "GL_BGR_INTEGER_EXT" }, + { 0x8D9B, "GL_BGRA_INTEGER_EXT" }, + { 0x8D9C, "GL_LUMINANCE_INTEGER_EXT" }, + { 0x8D9D, "GL_LUMINANCE_ALPHA_INTEGER_EXT" }, + { 0x8D9E, "GL_RGBA_INTEGER_MODE_EXT" }, + { 0x8DA7, "GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT" }, + { 0x8DA8, "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT" }, + { 0x8DA9, "GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT" }, + { 0x8DAD, "GL_FLOAT_32_UNSIGNED_INT_24_8_REV" }, + { 0x8DB9, "GL_FRAMEBUFFER_SRGB_EXT" }, + { 0x8DBA, "GL_FRAMEBUFFER_SRGB_CAPABLE_EXT" }, + { 0x8DBB, "GL_COMPRESSED_RED_RGTC1" }, + { 0x8DBC, "GL_COMPRESSED_SIGNED_RED_RGTC1" }, + { 0x8DBD, "GL_COMPRESSED_RG_RGTC2" }, + { 0x8DBE, "GL_COMPRESSED_SIGNED_RG_RGTC2" }, + { 0x8DC0, "GL_SAMPLER_1D_ARRAY_EXT" }, + { 0x8DC1, "GL_SAMPLER_2D_ARRAY_EXT" }, + { 0x8DC2, "GL_SAMPLER_BUFFER_EXT" }, + { 0x8DC3, "GL_SAMPLER_1D_ARRAY_SHADOW_EXT" }, + { 0x8DC4, "GL_SAMPLER_2D_ARRAY_SHADOW_EXT" }, + { 0x8DC5, "GL_SAMPLER_CUBE_SHADOW_EXT" }, + { 0x8DC6, "GL_UNSIGNED_INT_VEC2_EXT" }, + { 0x8DC7, "GL_UNSIGNED_INT_VEC3_EXT" }, + { 0x8DC8, "GL_UNSIGNED_INT_VEC4_EXT" }, + { 0x8DC9, "GL_INT_SAMPLER_1D_EXT" }, + { 0x8DCA, "GL_INT_SAMPLER_2D_EXT" }, + { 0x8DCB, "GL_INT_SAMPLER_3D_EXT" }, + { 0x8DCC, "GL_INT_SAMPLER_CUBE_EXT" }, + { 0x8DCD, "GL_INT_SAMPLER_2D_RECT_EXT" }, + { 0x8DCE, "GL_INT_SAMPLER_1D_ARRAY_EXT" }, + { 0x8DCF, "GL_INT_SAMPLER_2D_ARRAY_EXT" }, + { 0x8DD0, "GL_INT_SAMPLER_BUFFER_EXT" }, + { 0x8DD1, "GL_UNSIGNED_INT_SAMPLER_1D_EXT" }, + { 0x8DD2, "GL_UNSIGNED_INT_SAMPLER_2D_EXT" }, + { 0x8DD3, "GL_UNSIGNED_INT_SAMPLER_3D_EXT" }, + { 0x8DD4, "GL_UNSIGNED_INT_SAMPLER_CUBE_EXT" }, + { 0x8DD5, "GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT" }, + { 0x8DD6, "GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT" }, + { 0x8DD7, "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT" }, + { 0x8DD8, "GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT" }, + { 0x8DD9, "GL_GEOMETRY_SHADER_EXT" }, + { 0x8DDA, "GL_GEOMETRY_VERTICES_OUT_EXT" }, + { 0x8DDB, "GL_GEOMETRY_INPUT_TYPE_EXT" }, + { 0x8DDC, "GL_GEOMETRY_OUTPUT_TYPE_EXT" }, + { 0x8DDD, "GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT" }, + { 0x8DDE, "GL_MAX_VERTEX_VARYING_COMPONENTS_EXT" }, + { 0x8DDF, "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT" }, + { 0x8DE0, "GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT" }, + { 0x8DE1, "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT" }, + { 0x8DE2, "GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT" }, + { 0x8DE3, "GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT" }, + { 0x8DE4, "GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT" }, + { 0x8DED, "GL_MAX_BINDABLE_UNIFORM_SIZE_EXT" }, + { 0x8DEE, "GL_UNIFORM_BUFFER_EXT" }, + { 0x8DEF, "GL_UNIFORM_BUFFER_BINDING_EXT" }, + { 0x8E4C, "GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT" }, + { 0x8E4D, "GL_FIRST_VERTEX_CONVENTION_EXT" }, + { 0x8E4E, "GL_LAST_VERTEX_CONVENTION_EXT" }, + { 0x8E4F, "GL_PROVOKING_VERTEX_EXT" }, + + VE( TERMVALUE ) +}; + +GLMValueEntry_t g_gl_renderers[] = +{ + { 0x00020200, "Generic" }, + { 0x00020400, "GenericFloat" }, + { 0x00020600, "AppleSW" }, + { 0x00021000, "ATIRage128" }, + { 0x00021200, "ATIRadeon" }, + { 0x00021400, "ATIRagePro" }, + { 0x00021600, "ATIRadeon8500" }, + { 0x00021800, "ATIRadeon9700" }, + { 0x00021900, "ATIRadeonX1000" }, + { 0x00021A00, "ATIRadeonX2000" }, + { 0x00022000, "NVGeForce2MX" }, + { 0x00022200, "NVGeForce3" }, + { 0x00022400, "NVGeForceFX" }, + { 0x00022600, "NVGeForce8xxx" }, + { 0x00023000, "VTBladeXP2" }, + { 0x00024000, "Intel900" }, + { 0x00024200, "IntelX3100" }, + { 0x00040000, "Mesa3DFX" }, + + VE( TERMVALUE ) +}; + + +//=============================================================================== +// decode helper funcs + +char s_glmStrScratch[65536]; +int s_glmStrCursor = 0; + +const char * GLMDecode( GLMThing_t thingtype, unsigned long value ) +{ + GLMValueEntry_t *table = NULL; + char isflags = 0; + + switch( thingtype ) + { + case eD3D_DEVTYPE: table = g_d3d_devtypes; + break; + + case eD3D_FORMAT: table = g_d3d_formats; + break; + + case eD3D_RTYPE: table = g_d3d_rtypes; + break; + + case eD3D_USAGE: table = g_d3d_usages; + break; + + case eD3D_RSTATE: table = g_d3d_rstates; + break; + + case eD3D_SIO: table = g_d3d_opcodes; + break; + + case eD3D_VTXDECLUSAGE: table = g_d3d_vtxdeclusages; + break; + + case eCGL_RENDID: table = g_cgl_rendids; + break; + + case eGL_ERROR: table = g_gl_errors; + break; + + case eGL_ENUM: table = g_gl_enums; + break; + + case eGL_RENDERER: table = g_gl_renderers; + break; + + default: + GLMStop(); + return "UNKNOWNTYPE"; + break; + } + + if (table) + { + while( table->value != TERMVALUE ) + { + if (table->value == value) + { + return table->name; + } + table++; + } + } + return "UNKNOWN"; +} + +const char *GLMDecodeMask( GLMThing_t kind, unsigned long value ) +{ + // if cursor to scratch buffer is within 1K of EOB, rewind + // nobody is going to decode 63K of flag string values in a single call.. + + // this means that strings returned by this function have a short lifetime.. print them and do not save the pointer.. + + if ( (sizeof(s_glmStrScratch) - s_glmStrCursor) < 1000 ) + { + s_glmStrCursor = 0; + } + + char *start = &s_glmStrScratch[ s_glmStrCursor ]; + char *dest = start; + char first = 1; + + DWORD mask = (1L<<31); + while(mask) + { + if (mask & value) + { + sprintf(dest,"%s%s", (first) ? "" : "|", GLMDecode( kind, value&mask ) ); + first = 0; + + dest += strlen(dest); // leaves dest pointing at the end null + } + mask >>= 1; + } + s_glmStrCursor = (dest - s_glmStrScratch) + 1; // +1 so the next decoded flag set doesn't land on the ending null + return start; + +} + +#undef VE +#undef TERMVALUE + +//=============================================================================== + +bool GLMDetectOGLP( void ) +{ + bool result; + + GLint forceFlush; + CGLError error = CGLGetParameter(CGLGetCurrentContext(), kCGLCPEnableForceFlush, &forceFlush); + result = error == 0; + if (result) + { + // enable a breakpoint on color4sv + GLint oglp_bkpt[3] = { kCGLFEglColor4sv, kCGLProfBreakBefore, 1 }; + + CGLSetGlobalOption( kCGLGOEnableBreakpoint, oglp_bkpt ); + } + + return result; +} + + +// from http://blog.timac.org/?p=190 + +#include +#include +#include +#include + +// From Technical Q&A QA1361 +// Returns true if the current process +// is being debugged (either running +// under the debugger or has a debugger +// attached post facto). + +bool GLMDetectGDB( void ) // aka AmIBeingDebugged() +{ + bool result; + int junk; + int mib[4]; + struct kinfo_proc info; + size_t size; + + // Initialize the flags so that, + // if sysctl fails for some bizarre + // reason, we get a predictable result. + + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info + // we want, in this case we're looking for + // information about a specific process ID. + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + + size = sizeof(info); + junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); + + assert(junk == 0); + + // We're being debugged if the P_TRACED + // flag is set. + + result = ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + + return result; +} + + +static uint g_glmDebugChannelMask = 0; // which output channels are available (can be more than one) +static uint g_glmDebugFlavorMask = 0; // which message flavors are enabled for output (can be more than one) + +uint GLMDetectAvailableChannels( void ) +{ + uint result = 0; + + // printf is always available (except maybe in release... ?) + result |= (1 << ePrintf); + + // gdb + if (GLMDetectGDB()) + { + result |= (1 << eDebugger); + printf("\n############# GDB Detected"); + } + + // oglp + if (GLMDetectOGLP()) + { + result |= (1 << eGLProfiler); + printf("\n############# OGLP Detected"); + } + + return result; +} + + +static bool g_debugInitDone = false; + +#if GLMDEBUG + + // following funcs vanish if GLMDEBUG not set + +void GLMDebugInitialize( bool forceReinit ) +{ + if ( !g_debugInitDone || forceReinit ) + { + // detect channels + uint channelMask = GLMDetectAvailableChannels(); + + // finally, disable all of them if commandline did not say "enable spew" + if (0 /* !CommandLine()->FindParm("-glmspew") */) //FIXME change back to 1 later + { + channelMask = 0; + } + + // set the output channel mask + GLMDebugChannelMask( &channelMask ); + + // if any channels are enabled, enable some output + if ( channelMask ) + { + // start mostly quiet unless the -glmbootspew option is there + if ( 0 /*CommandLine()->FindParm( "-glmbootspew" )*/ ) + { + g_glmDebugFlavorMask = 0xFFFFFFFF; + } + else + { + g_glmDebugFlavorMask = + (1< < + // | (1<-M- and it will indent and be filterable + { + // comment + flavor = eComment; + } + else if (strnstr(str, "-D-", 4)) + { + // debug dump + flavor = eDebugDump; + } + else if (strnstr(str, "-M-", 4)) + { + // matrix data + flavor = eMatrixData; + } + else if (strnstr(str, "-S-", 4)) + { + // shader data + flavor = eShaderData; + } + else if (strnstr(str, "-F-", 4)) + { + // framebuf data + flavor = eFrameBufData; + } + else if (strnstr(str, "-X-", 4)) + { + // DirectX data + flavor = eDXStuff; + } + else if (strnstr(str, "-A-", 4)) + { + // allocation data + flavor = eAllocations; + } + else if (strnstr(str, "-Z-", 4)) + { + // allocation data + flavor = eSlowness; + } + else if (str[0] == '<' || str[0] == '>') + { + // entry/exit (aka tenure) + flavor = eTenure; + } + + return flavor; +} + +void GLMPrintfVA( const char *fmt, va_list vargs ) +{ + // if no channels open, return + uint channelMask = GLMDebugChannelMask(); + if (!channelMask) + return; + + // if "all flavors" is off, return + uint flavorMask = GLMDebugFlavorMask(); + if (! ( flavorMask & (1<' - raise indent level after print. + // if first char is a '<' - lower indent level before print. + + char buf[100000]; + + if (fmt[0] == '<') + { + GLMIncIndent( -1 ); + } + + memset( buf, '\t', g_glm_indent ); + vsprintf( buf+g_glm_indent, fmt, vargs ); + GLMStringOut( buf ); + + if (fmt[0] == '>') + { + GLMIncIndent( 1 ); + } +} + +void GLMPrintf( const char *fmt, ... ) +{ + // if no channels open, return + uint channelMask = GLMDebugChannelMask(); + if (!channelMask) + return; + + // if "all flavors" is off, return + uint flavorMask = GLMDebugFlavorMask(); + if (! ( flavorMask & (1<' - raise indent level after print. + // if first char is a '<' - lower indent level before print. + + char buf[64000]; + + if (str[0] == '<') + { + GLMIncIndent( -1 ); + } + + memset( buf, '\t', g_glm_indent ); + + if (strlen(str) < sizeof(buf)-g_glm_indent-1) + { + strcpy( buf + g_glm_indent, str ); + } + else + { + Debugger(); + } + + + GLMStringOut( buf ); // single string out with indenting + + if (str[0] == '>') + { + GLMIncIndent( 1 ); + } +} + + +void GLMPrintText( const char *str, EGLMDebugFlavor flavor, uint options ) +{ + // if no channels open, return + uint channelMask = GLMDebugChannelMask(); + if (!channelMask) + return; + + // if "all flavors" is off, return + uint flavorMask = GLMDebugFlavorMask(); + if (! ( flavorMask & (1<0) + { + if (g_glm_indent > g_glm_indent_max) + { + g_glm_indent = g_glm_indent_max; + } + } + else + { + if (g_glm_indent < 0) + { + g_glm_indent = 0; + } + } + return g_glm_indent; +} + +int GLMGetIndent( void ) +{ + return g_glm_indent; +} + +void GLMSetIndent( int indent ) +{ + g_glm_indent = indent; +} + +#endif + +// PIX tracking - you can call these outside of GLMDEBUG=true +char sg_pPIXName[128]; + +void GLMBeginPIXEvent( const char *str ) +{ + V_strncpy( sg_pPIXName, str, 128 ); + + /* + if (CommandLine()->FindParm("-glmpix2oglp")) + { + char temp[256]; + // route PIX event strings to OGLP + sprintf( temp,"> %s",sg_pPIXName ); + CGLSetOption( kCGLGOComment, (GLint)temp ); + } + */ +} + +void GLMEndPIXEvent( void ) +{ + /* + if (CommandLine()->FindParm("-glmpix2oglp")) + { + char temp[256]; + // route PIX event strings to OGLP + sprintf( temp,"< %s",sg_pPIXName ); + CGLSetOption( kCGLGOComment, (GLint)temp ); + } + */ + sg_pPIXName[0] = '\0'; +} + + + + +//=============================================================================== + +// helpers for CGLSetOption - no op if no profiler +void GLMProfilerClearTrace( void ) +{ + CGLSetOption( kCGLGOResetFunctionTrace, 0 ); +} + +void GLMProfilerEnableTrace( bool enable ) +{ + CGLSetOption( kCGLGOEnableFunctionTrace, enable ? GL_TRUE : GL_FALSE ); +} + +// helpers for CGLSetParameter - no op if no profiler +void GLMProfilerDumpState( void ) +{ + CGLContextObj curr = CGLGetCurrentContext(); + CGLSetParameter( curr, kCGLCPDumpState, (const GLint*)1 ); +} + + +//=============================================================================== + +CGLMFileMirror::CGLMFileMirror( char *fullpath ) +{ + m_path = strdup( fullpath ); + m_data = (char *)malloc(1); + m_size = 0; + UpdateStatInfo(); + if (m_exists) + { + ReadFile(); + } +} + +CGLMFileMirror::~CGLMFileMirror( ) +{ + if (m_path) + { + free (m_path); + m_path = NULL; + } + + if (m_data) + { + free (m_data); + m_data = NULL; + } +} + +bool CGLMFileMirror::HasData( void ) +{ + return (m_size != 0); +} + + +// return direct pointer to buffer. Will be invalidated if file is re-loaded or if data is written to +void CGLMFileMirror::GetData( char **dataPtr, uint *dataSizePtr ) +{ + *dataPtr = m_data; + *dataSizePtr = m_size; +} + + +void CGLMFileMirror::SetData( char *data, uint dataSize ) +{ + if (m_data) + { + free( m_data ); + m_data = NULL; + } + + m_size = dataSize; + + m_data = (char *)malloc( m_size +1 ); + m_data[ m_size ] = 0; // extra NULL terminator, no charge + + memcpy( m_data, data, m_size ); // copy data in + + WriteFile(); // keep disk copy sync'd +} + +static bool stat_diff( struct stat *a, struct stat *b ) +{ + if (a->st_size != b->st_size) + { + return true; + } + + if (memcmp( &a->st_mtimespec, &b->st_mtimespec, sizeof( struct timespec ) ) ) + { + return true; + } + + return false; +} + +bool CGLMFileMirror::PollForChanges( void ) +{ + // snapshot old stat + bool old_exists = m_exists; + struct stat old_stat = m_stat; + + UpdateStatInfo(); + + if (m_exists) + { + if ( stat_diff( &old_stat, &m_stat ) ) + { + // initial difference detected. continue to poll at 0.1s intervals until it stops changing, then read it. + int stablecount = 0; + do + { + usleep(100000); + + struct stat last_stat = m_stat; + UpdateStatInfo(); + + if (stat_diff( &last_stat, &m_stat )) + { + stablecount = 0; + } + else + { + stablecount++; + } + } while(stablecount<3); + + // changes have settled down, now re-read it + ReadFile(); + return true; + } + else + { + return false; // no change + } + } + else + { + // file does not exist. remake it. not considered to be a change. + WriteFile(); + return false; + } +} + + + +void CGLMFileMirror::UpdateStatInfo( void ) +{ + // stat the path + struct stat newstat; + memset (&newstat, 0, sizeof(newstat) ); + int result = stat( m_path, &newstat ); + + if (!result) + { + m_exists = true; + m_stat = newstat; + } + else + { + m_exists = false; + memset( &m_stat, 0, sizeof( m_stat ) ); + } +} + + +void CGLMFileMirror::ReadFile( void ) +{ + // unconditional - we discard any old buffer, make a new one, + UpdateStatInfo(); + + if (m_data) + { + free( m_data ); + m_data = NULL; + } + + if (m_exists) + { + FILE *infile = fopen( m_path, "rb" ); + if (infile) + { + // get size from stat + m_size = m_stat.st_size; + + m_data = (char *)malloc( m_size +1 ); + m_data[ m_size ] = 0; // extra NULL terminator, no charge + + fread( m_data, 1, m_size, infile ); + + fclose( infile ); + } + else + { + GLMDebugger(); // ouch + } + + } + else + { + // hmmmmmm + m_data = (char *)malloc(1); + m_data[0] = 0; + m_size = 0; + } +} + + +void CGLMFileMirror::WriteFile( void ) +{ + FILE *outfile = fopen( m_path, "wb" ); + + if (outfile) + { + fwrite( m_data, 1, m_size, outfile ); + fclose( outfile ); + + UpdateStatInfo(); // sets m_stat and m_exists + } + else + { + GLMDebugger(); // ouch + } +} + +void CGLMFileMirror::OpenInEditor( bool foreground ) +{ + char temp[64000]; + + // pass -b if no desire to bring editor to foreground + sprintf(temp,"/usr/bin/bbedit %s %s", foreground ? "" : "-b", m_path ); + system( temp ); +} + + + +CGLMEditableTextItem::CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix ) +{ + // clone input text (exact size copy) + m_origSize = size; + m_origText = (char *)malloc( m_origSize ); + memcpy( m_origText, text, m_origSize ); + + // null out munged form til we generate it + m_mungedSize = 0; + m_mungedText = NULL; + + // null out mirror until we create it + m_mirrorBaseName = NULL; + m_mirrorFullPath = NULL; + m_mirror = NULL; + + GenHashOfOrigText(); // will fill out m_origDigest + GenMungedText( false ); + GenBaseNameAndFullPath( prefix, suffix ); // figure out where the mirror will go + + if (!strcmp(m_mirrorBaseName, "96c7e9d2faf76b1148f7274afd684d4b.fsh")) + { + printf("\nhello there\n"); + } + + // make the mirror from the filename. + // see if there was any content on disk + // if so, honor that content *unless* the force-option is set. + m_mirror = new CGLMFileMirror( m_mirrorFullPath ); + + // the logic is simple. + // the only time we will choose the copy on disk, is if + // a - forceOverwrite is false + // AND b - the copy on disk is bigger than 10 bytes. + + bool replaceDiskCopy = true; + + char *mirrorData = NULL; + uint mirrorSize = 0; + + if (!forceOverwrite) + { + if (m_mirror->HasData()) + { + // peek at it, and use it if it is more than some minimum number of bytes. + m_mirror->GetData( &mirrorData, &mirrorSize ); + if (mirrorSize > 10) + { + replaceDiskCopy = false; + } + } + } + + if (replaceDiskCopy) + { + // push our generated data to the mirror - disk copy is overwritten + m_mirror->SetData( m_mungedText, m_mungedSize ); + } + else + { + GenMungedText( true ); + } + +} + +CGLMEditableTextItem::~CGLMEditableTextItem( ) +{ + if (m_origText) + { + free (m_origText); + } + + if (m_mungedText) + { + free (m_mungedText); + } + + if (m_mirrorBaseName) + { + free (m_mirrorBaseName); + } + + if (m_mirrorFullPath) + { + free (m_mirrorFullPath); + } + + if (m_mirror) + { + free( m_mirror ); + } +} + +bool CGLMEditableTextItem::HasData( void ) +{ + return m_mirror->HasData(); +} + +bool CGLMEditableTextItem::PollForChanges( void ) +{ + bool changed = m_mirror->PollForChanges(); + if (changed) + { + // re-gen munged text from mirror (means "copy") + GenMungedText( true ); + } + return changed; +} + +void CGLMEditableTextItem::GetCurrentText( char **textOut, uint *sizeOut ) +{ + if (!m_mungedText) GLMDebugger(); + + *textOut = m_mungedText; + *sizeOut = m_mungedSize; +} + +void CGLMEditableTextItem::OpenInEditor( bool foreground ) +{ + m_mirror->OpenInEditor( foreground ); +} + + +void CGLMEditableTextItem::GenHashOfOrigText( void ) +{ + // bring this code back if you need the live shader edit/debug mode. + #if 0 + MD5Context_t md5ctx; + MD5Init( &md5ctx ); + MD5Update( &md5ctx, (unsigned char*)m_origText, m_origSize ); + MD5Final( m_origDigest, &md5ctx ); + #endif +} + + +void CGLMEditableTextItem::GenBaseNameAndFullPath( char *prefix, char *suffix ) +{ + // base name is hash digest in hex, plus the suffix. + char temp[5000]; + + // bring this code back if you need the live shader edit/debug mode. + #if 0 + V_binarytohex( m_origDigest, sizeof(m_origDigest), temp, sizeof( temp ) ); + if (suffix) + { + strcat( temp, suffix ); + } + if (m_mirrorBaseName) free(m_mirrorBaseName); + m_mirrorBaseName = strdup( temp ); + + sprintf( temp, "%s%s", prefix, m_mirrorBaseName ); + if (m_mirrorFullPath) free(m_mirrorFullPath); + m_mirrorFullPath = strdup( temp ); + #endif +} + + +void CGLMEditableTextItem::GenMungedText( bool fromMirror ) +{ + if (fromMirror) + { + // just import the text as is from the mirror file. + + char *mirrorData = NULL; + uint mirrorSize = 0; + + if (m_mirror->HasData()) + { + // peek at it, and use it if it is more than some minimum number of bytes. + m_mirror->GetData( &mirrorData, &mirrorSize ); + + if (m_mungedText) + { + free( m_mungedText ); + m_mungedText = NULL; + } + + m_mungedText = (char *)malloc( mirrorSize+1 ); + m_mungedText[ mirrorSize ] = 0; + memcpy( m_mungedText, mirrorData, mirrorSize ); + + m_mungedSize = mirrorSize; + } + else + { + GLMDebugger(); + } + } + else + { + #if 1 + // we don't actually clone/munge any more. + if (m_mungedText) + { + free( m_mungedText ); + m_mungedText = NULL; + } + + m_mungedText = (char *)malloc( m_origSize+1 ); + m_mungedText[ m_origSize ] = 0; + memcpy( m_mungedText, m_origText, m_origSize ); + + m_mungedSize = m_origSize; + + #else + // take pure 'orig' text that came in from the engine, and clone it + // do not clone the first line + char temp[100000]; + char *dst = temp; + char *lim = &temp[ sizeof(temp) ]; + + // zero temp + memset( temp, 0, sizeof(temp) ); + + // write orig text to temp + if (m_origSize >= (sizeof(temp)/2) ) + { + GLMDebugger(); + } + + memcpy( dst, m_origText, m_origSize ); + dst += m_origSize; + + // add a newline if the last character wasn't + if ( (*(dst-1)) != '\n' ) + { + *dst++ = '\n'; + } + + // walk orig text again and copy it over, with these caveats + // don't copy the first line + // insert a # before all the other lines. + char *src = temp; + + // walk to end of first line + char *firstNewline = strchr( src, '\n' ); + if (!firstNewline) + { + GLMDebugger(); + } + else + { + // advance 'src' to that newline- we're not copying the !! line + src = firstNewline; + } + + + // now walk the rest - insert a # after each newline + while( (dst < lim) && ((src-temp) < m_origSize) ) + { + switch( *src ) + { + case '\n': + *dst++ = *src++; + *dst++ = '#'; + break; + + default: + *dst++ = *src++; + } + } + if (dst >= lim) + { + GLMDebugger(); + } + + // final newline + *dst++ = '\n'; + + // copyout + if (m_mungedText) + { + free( m_mungedText ); + m_mungedText = NULL; + } + + m_mungedSize = dst - temp; + m_mungedText = (char *)malloc( m_mungedSize ); + memcpy( m_mungedText, temp, m_mungedSize ); + #endif + } +} + +//=============================================================================== + +// class for cracking multi-part text blobs +// sections are demarcated by beginning-of-line markers submitted in a table by the caller +// typically +// asm flavors have first-line rules so we use those tags as is +// !!ARBvp (etc) +// !!ARBfp (etc) +// //!!GLSLF // slashes required +// //!GLSLV + +// maybe also introduce "present but disabled" markers like these +// -!!ARBvp (etc) +// -!!ARBfp (etc) +// -//!!GLSLF +// -//!GLSLV + +// resolved. there is no default section for text that doesn't have a marker in front of it. mark it or miss it. + +CGLMTextSectioner::CGLMTextSectioner( const char *text, int textLength, const char **markers ) +{ + // find lines + // for each line, see if it starts with a marker + // if so, open a new section based at that line + + GLMTextSection *curSection = NULL; // no current section until we see a marker + + const char *cursor = text; + const char *textLimit = text+textLength; + + int foundMarker; + const char **markerCursor; + while( cursor < textLimit ) + { + // top of loop. cursor points to start of a line. + // find the end of the line and keep that handy. + const char *eol = strchr( cursor, '\n' ); + int charsInLine = (eol) ? (eol-cursor)+1 : strlen(cursor); + + //see if any of the marker strings is located here. + foundMarker = -1; + markerCursor = markers; + + while( (foundMarker<0) && (*markerCursor!=NULL) ) + { + // see if the n'th marker is a hit + int markerLen = strlen(*markerCursor); + + if (!strncmp( cursor, *markerCursor, markerLen ) ) + { + // hit + foundMarker = markerCursor - markers; + } + markerCursor++; + } + + // outcome is either "marker spotted" or "no". + // if marker seen, open new section using that marker. + // else, grow active section if underway. + // then, move cursor to next line. + + if (foundMarker >= 0) + { + // found marker. start new section. + // no need to do anything special with prior section - it was up to date before seeing this marker. + GLMTextSection temp; + + temp.m_markerIndex = foundMarker; + temp.m_textOffset = cursor - text; // text includes the marker + temp.m_textLength = charsInLine; // this line goes in the tally, later lines add to it + + m_sectionTable.push_back( temp ); + + curSection = &m_sectionTable[ m_sectionTable.size() - 1 ]; + } + else + { + // add this line to current section if live + if (curSection) + { + curSection->m_textLength += charsInLine; + } + } + cursor += charsInLine; + } +} + +CGLMTextSectioner::~CGLMTextSectioner( ) +{ + // not much to do. +} + + +int CGLMTextSectioner::Count( void ) +{ + return m_sectionTable.size(); +} + +void CGLMTextSectioner::GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut ) +{ + Assert( index < m_sectionTable.Count() ); + + GLMTextSection *section = &m_sectionTable[ index ]; + + *offsetOut = section->m_textOffset; + *lengthOut = section->m_textLength; + *markerIndexOut = section->m_markerIndex; +} + +//=============================================================================== + +// how to make a compiled-in font: +// a. type in a matrix of characters in your fav editor +// b. take a screen shot of the characters (128x128 pixels in this case) +// c. export as TIFF raw. +// d. hex dump it +// e. column-copy just the hex data +// f. find and replace: chop out all the spaces and line feeds, change FFFFFF and 000000 to your marker chars of choice. +// g. wrap each line with quotes and a comma. + +unsigned char g_glmDebugFontMap[ 128 * 128 ] = +{ +" * " +" * * * * * " +" * * * * * *** * * ** * * * * * " +" * * * ***** * * * * * * * * * * * * * * * * " +" * * * * * * * * * * * * * *** * * " +" * ***** *** * * * * * * * ***** ***** * " +" * * * * * * * * * * * * * * * " +" * * * * * * * * * * * ** ** * " +" * *** * * ** * * * ** ** * " +" * * * * * " +" * " +" " +" " +" *** * *** *** * ***** *** ***** *** *** * * *** " +"* * ** * * * * ** * * * * * * * ** ** * * * * " +"* ** * * * * * **** **** * * * * * ** ** * ***** * * " +"* * * * * ** * * * * * * *** * * * * * " +"** * * * * ***** * * * * * * **** * ***** * * " +"* * * * * * * * * * * * * * * ** ** * * " +" *** * ***** *** * *** *** * *** *** ** ** * * * " +" * " +" * " +" " +" *** " +"* * *** **** *** **** ***** ***** *** * * * * * * * * * * * *** " +"* * * * * * * * * * * * * * * * * * * * * ** ** ** * * * " +"* * * * * * * * * * * * * * * * * * * * * * * * * * * * " +"*** * ***** **** * * * **** **** * ** ***** * * ** * * * * ** * * " +"* ** * * * * * * * * * * * * * * * * * * * * * * * * * " +"* * * * * * * * * * * * * * * * * * * * * * * * * * * " +"* * * * **** *** **** ***** * *** * * * *** * * ***** * * * * *** " +" *** " +" " +" * " +" ** * ** * " +"**** *** **** *** ***** * * * * * * * * * * ***** * * * * * " +"* * * * * * * * * * * * * * * * * * * * * * * * * " +"* * * * * * * * * * * * * * * * * * * * * " +"**** * * **** *** * * * * * * * * * * * * * * " +"* * * * * * * * * * * * * * * * * * * * " +"* * * * * * * * * * * ** ** * * * * * * * " +"* *** * * *** * *** * * * * * * ***** * * * ****** " +" * ** * ** " +" " +" " +" * " +" * * * ** * * * * * " +" * * * * * * * " +" **** **** *** **** *** *** **** **** * * * * * **** * ** *** " +" * * * * * * * * * * * * * * * * * * * * * * * ** * * * " +" * * * * * * * ***** * * * * * * * *** * * * * * * * * " +" * ** * * * * * * * * * * * * * * * * * * * * * * * " +" ** * **** **** **** **** * **** * * * * * * ** * * * * * *** " +" * * " +" *** ** " +" * " +" ** * ** " +" * * * * ** * " +" * * * * * ** *** " +"**** **** * ** **** **** * * * * * * * * * * * ***** * * * ***** " +"* * * * ** * * * * * * * * * * * * * * * ** * ** ***** " +"* * * * * *** * * * * * * * * * * * * * * * ***** " +"* * * * * * * * ** * * * * * * * * * * * * * *** " +"**** **** * **** ** ** * * * * * * **** ***** * * * " +"* * * ** * ** " +"* * *** * " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +}; + + + + + + + + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrbasics.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrbasics.h new file mode 100644 index 0000000..92b6e65 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrbasics.h @@ -0,0 +1,508 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// glmgrbasics.h +// types, common headers, forward declarations, utilities +// +//=============================================================================== + +#ifndef GLMBASICS_H +#define GLMBASICS_H + +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include + +#include "imageformat.h" +#include "glmdebug.h" + +#ifndef Assert +#define Assert(x) +#endif + +//=============================================================================== + +// some portability shims to eliminate dependencies on partcular segments of Valve code + +typedef int8_t int8; +typedef uint8_t uint8; +typedef int16_t int16; +typedef uint16_t uint16; +typedef int32_t int32; +typedef uint32_t uint32; +typedef int64_t int64; +typedef uint64_t uint64; + +class CUtlBuffer +{ +public: + enum BufferFlags_t + { + TEXT_BUFFER = 0x1, // Describes how get + put work (as strings, or binary) + //EXTERNAL_GROWABLE = 0x2, // This is used w/ external buffers and causes the utlbuf to switch to reallocatable memory if an overflow happens when Putting. + //CONTAINS_CRLF = 0x4, // For text buffers only, does this contain \n or \n\r? + //READ_ONLY = 0x8, // For external buffers; prevents null termination from happening. + //AUTO_TABS_DISABLED = 0x10, // Used to disable/enable push/pop tabs + }; + + CUtlBuffer( int growSize = 0, int initSize = 0, int nFlags = 0 ) + { + // grow size and init flags are ignored. + m_buf.reserve( initSize ); + }; + + CUtlBuffer( const void* pBuffer, int size, int nFlags = 0 ) + { + m_buf.reserve ( size ); + memcpy( &m_buf[0], pBuffer, size ); + } + + // This one isn't actually defined so that we catch contructors that are trying to pass a bool in as the third param. + CUtlBuffer( const void *pBuffer, int size, bool crap ); + + ~CUtlBuffer() + { + } + + char* Base( void ) + { + return &m_buf[0]; + } + + uint32 Size( void ) + { + return m_buf.size(); + } + + void EnsureCapacity( int num ) + { + m_buf.resize( num ); + } + + void AppendString( const char* pString ) + { + int appendlen = strlen( pString ); // count of characters, null terminator not included + if (Size()) + { + // append to non empty string + EnsureCapacity( Size() + appendlen + 1); + //printf("\n **(a) appending \n---\n%s\n---\n to \n---\n%s\n---\n", pString, Base() ); + strcat( Base(), pString ); // gets NULL terminated + } + else + { + EnsureCapacity( Size() + appendlen + 1); + //printf("\n **(b) appending \n---\n%s\n---\n to \n---\n%s\n---\n", pString, Base() ); + strcpy( Base(), pString ); + } + } + +private: + CUtlBuffer(); + + std::vector m_buf; +}; + +class CUtlString +{ +public: + CUtlString() + { + m_str = ""; + } + + CUtlString( const char *str ) + { + m_str = std::string( str ); + } + + ~CUtlString( ) + { + } + + const char* String( void ) + { + return m_str.c_str(); + } + + operator const char * () { return m_str.c_str(); } //conversion operator + +private: + + std::string m_str; +}; + +#undef ARRAYSIZE +#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) + +#define strcat_s(dst,lim,src) strcat(dst,src ) + +#define V_strcat(dst,lim,src) strcat(dst,src) +#define V_vsnprintf(a,b,c,d) vsprintf(a,c,d) // double check this +#define V_snprintf snprintf +#define V_strncpy strncpy +#define V_strcmp strcmp +#define V_strlen strlen +#define V_strstr strstr +#define __cdecl + +#define V_memset(dst,count,val) memset(dst,count,val) + +int V_stricmp(const char *s1, const char *s2 ); +char const* V_stristr( char const* pStr, char const* pSearch ); + +//=============================================================================== +// types + + // 3-d integer box (used for texture lock/unlock etc) +struct GLMRegion +{ + int xmin,xmax; + int ymin,ymax; + int zmin,zmax; +}; + +struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's +{ + int xmin; // left + int ymin; // bottom + int xmax; // right + int ymax; // top +}; + +// macros + +//#define GLMassert(x) assert(x) + +// forward decls +class GLMgr; // singleton +class GLMContext; // GL context +class CGLMContextTester; // testing class +class CGLMTex; +class CGLMFBO; +class CGLMProgram; +class CGLMBuffer; + + +// utilities + +typedef enum +{ + // D3D codes + eD3D_DEVTYPE, + eD3D_FORMAT, + eD3D_RTYPE, + eD3D_USAGE, + eD3D_RSTATE, // render state + eD3D_SIO, // D3D shader bytecode + eD3D_VTXDECLUSAGE, + + // CGL codes + eCGL_RENDID, + + // OpenGL error codes + eGL_ERROR, + + // OpenGL enums + eGL_ENUM, + eGL_RENDERER + +} GLMThing_t; + +const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const +const char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask + +void GLMStop( void ); // aka Debugger() +void GLMCheckError( bool noStop = false, bool noLog= false ); +void GLMEnableTrace( bool on ); + +//=============================================================================== +// debug channels + +enum EGLMDebugChannel +{ + ePrintf, + eDebugger, + eGLProfiler +}; + +#if GLMDEBUG + // make all these prototypes disappear in non GLMDEBUG + void GLMDebugInitialize( bool forceReinit=false ); + + bool GLMDetectOGLP( void ); + bool GLMDetectGDB( void ); + uint GLMDetectAvailableChannels( void ); + + uint GLMDebugChannelMask( uint *newValue = NULL ); + // note that GDB and OGLP can both come and go during run - forceCheck will allow that to be detected. + // mask returned is in form of 1< < + eComment, // 3 one off messages --- + eMatrixData, // 4 matrix data -M- + eShaderData, // 5 shader data (params) -S- + eFrameBufData, // 6 FBO data (attachments) -F- + eDXStuff, // 7 dxabstract spew -X- + eAllocations, // 8 tracking allocs and frees -A- + eSlowness, // 9 slow things happening (srgb flips..) -Z- + eDefaultFlavor, // not specified (no marker) + eFlavorCount +}; +uint GLMDebugFlavorMask( uint *newValue = NULL ); + +//=============================================================================== +// output functions + +// make all these prototypes disappear in non GLMDEBUG +#if GLMDEBUG + // these are unconditional outputs, they don't interrogate the string + void GLMStringOut( const char *string ); + void GLMStringOutIndented( const char *string, int indentColumns ); + + // these will look at the string to guess its flavor: <, >, ---, -M-, -S- + void GLMPrintfVA( const char *fmt, va_list vargs ); + void GLMPrintf( const char *fmt, ... ); + + // these take an explicit flavor with a default value + void GLMPrintStr( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor ); + + #define GLMPRINTTEXT_NUMBEREDLINES 0x80000000 + void GLMPrintText( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor, uint options=0 ); // indent each newline + + int GLMIncIndent( int indentDelta ); + int GLMGetIndent( void ); + void GLMSetIndent( int indent ); + +#endif + +// expose these in release now +// Mimic PIX events so we can decorate debug spew +void GLMBeginPIXEvent( const char *str ); +void GLMEndPIXEvent( void ); + +//=============================================================================== +// other stuff + +#if GLMDEBUG +inline void GLMDebugger( void ) +{ + if (GLMDebugChannelMask() & (1<%s", m_funcName ); + }; + + // more advanced version lets you pass args (i.e. called parameters or anything else of interest) + // no macro for this one, since no easy way to pass through the args as well as the funcname + GLMFuncLogger( const char *funcName, char *fmt, ... ) + { + m_funcName = funcName; + m_earlyOut = false; + + // this acts like GLMPrintf here + // all the indent policy is down in GLMPrintfVA + // which means we need to inject a ">" at the front of the format string to make this work... sigh. + + char modifiedFmt[2000]; + modifiedFmt[0] = '>'; + strcpy( modifiedFmt+1, fmt ); + + va_list vargs; + va_start(vargs, fmt); + GLMPrintfVA( modifiedFmt, vargs ); + va_end( vargs ); + } + + ~GLMFuncLogger( ) + { + if (m_earlyOut) + { + GLMPrintf( "<%s (early out)", m_funcName ); + } + else + { + GLMPrintf( "<%s", m_funcName ); + } + }; + + void EarlyOut( void ) + { + m_earlyOut = true; + }; + + const char *m_funcName; // set at construction time + bool m_earlyOut; +}; + +// handy macro to go with the function tracking class +#define GLM_FUNC GLMFuncLogger _logger_ ( __FUNCTION__ ) +#else +#define GLM_FUNC +#endif + + +// class to keep an in-memory mirror of a file which may be getting edited during run +class CGLMFileMirror +{ +public: + CGLMFileMirror( char *fullpath ); // just associates mirror with file. if file exists it will be read. + //if non existent it will be created with size zero + ~CGLMFileMirror( ); + + bool HasData( void ); // see if data avail + void GetData( char **dataPtr, uint *dataSizePtr ); // read it out + void SetData( char *data, uint dataSize ); // put data in (and write it to disk) + bool PollForChanges( void ); // check disk copy. If different, read it back in and return true. + + void UpdateStatInfo( void ); // make sure stat info is current for our file + void ReadFile( void ); + void WriteFile( void ); + + void OpenInEditor( bool foreground=false ); // pass TRUE if you would like the editor to pop to foreground + + /// how about a "wait for change" method.. + + char *m_path; // fullpath to file + bool m_exists; + struct stat m_stat; // stat results for the file (last time checked) + + char *m_data; // content of file + uint m_size; // length of content + +}; + +// class based on the file mirror, that makes it easy to edit them outside the app. + +// it receives an initial block of text from the engine, and hashes it. ("orig") +// it munges it by duplicating all the text after the "!!" line, and appending it in commented form. ("munged") +// a mirror file is activated, using a filename based on the hash from the orig text. +// if there is already content on disk matching that filename, use that content *unless* the 'blitz' parameter is set. +// (i.e. engine is instructing this subsystem to wipe out any old/modified variants of the text) + +#ifndef MD5_DIGEST_LENGTH +#define MD5_DIGEST_LENGTH 16 +#endif + +class CGLMEditableTextItem +{ +public: + CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix = NULL ); // create a text blob from text source, optional filename suffix + ~CGLMEditableTextItem( ); + + bool HasData( void ); + bool PollForChanges( void ); // return true if stale i.e. you need to get a new edition + void GetCurrentText( char **textOut, uint *sizeOut ); // query for read access to the active blob (could be the original, could be external edited copy) + void OpenInEditor( bool foreground=false ); // call user attention to this text + + // internal methods + void GenHashOfOrigText( void ); + void GenBaseNameAndFullPath( char *prefix, char *suffix ); + void GenMungedText( bool fromMirror ); + + // members + // orig + uint m_origSize; + char *m_origText; // what was submitted + unsigned char m_origDigest[MD5_DIGEST_LENGTH]; // digest of what was submitted + + // munged + uint m_mungedSize; + char *m_mungedText; // re-processed edition, initial content submission to the file mirror + + // mirror + char *m_mirrorBaseName; // generated from the hash of the orig text, plus the label / prefix + char *m_mirrorFullPath; // base name + CGLMFileMirror *m_mirror; // file mirror itself. holds "official" copy for GetCurrentText to return. +}; + + +// debug font +extern unsigned char g_glmDebugFontMap[16384]; + +// class for cracking multi-part text blobs +// sections are demarcated by beginning-of-line markers submitted in a table by the caller + +struct GLMTextSection +{ + int m_markerIndex; // based on table of markers passed in to constructor + uint m_textOffset; // where is the text - offset + int m_textLength; // how big is the section +}; + +class CGLMTextSectioner +{ +public: + CGLMTextSectioner( const char *text, int textSize, const char **markers ); // constructor finds all the sections + ~CGLMTextSectioner( ); + + int Count( void ); // how many sections found + void GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut ); + // find section, size, what marker + // note that more than one section can be marked similarly. + // so policy isn't made here, you walk the sections and decide what to do if there are dupes. + + //members + + //section table + std::vector< GLMTextSection > m_sectionTable; +}; + +#endif diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrcocoa.mm b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrcocoa.mm new file mode 100644 index 0000000..ca848df --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrcocoa.mm @@ -0,0 +1,1575 @@ +//========= Copyright 1996-2009, Valve Corporation, All rights reserved. ============// +// +// Purpose: provide some call-out glue to ObjC from the C++ GLMgr code +// +// $Revision: $ +// $NoKeywords: $ +//=============================================================================// + + +#include +#undef MIN +#undef MAX +#define DONT_DEFINE_BOOL // Don't define BOOL! +//#include "tier0/threadtools.h" +//#include "tier1/interface.h" +//#include "tier1/strtools.h" +//#include "tier1/utllinkedlist.h" +#include "glmgr.h" + + +//=============================================================================== + +void __checkgl__( void ) +{ +#if GLMDEBUG + GLenum errorcode = (GLenum)glGetError(); + if (errorcode != GL_NO_ERROR) + { + Debugger(); + printf("\nGL Error %d",errorcode); + } +#endif +} + + +void swap(GLMRendererInfo*& a, GLMRendererInfo*& b) +{ + GLMRendererInfo* temp = a; + a = b; + b = temp; +} + +void swap(GLMDisplayInfo*& a, GLMDisplayInfo*& b) +{ + GLMDisplayInfo* temp = a; + a = b; + b = temp; +} + +void swap(GLMDisplayMode*& a, GLMDisplayMode*& b) +{ + GLMDisplayMode* temp = a; + a = b; + b = temp; +} + +// ------------------------------------------------------------------------------------ // +// some helper functions + +// this one makes a new context +bool GLMDetectSLGU( void ); +bool GLMDetectSLGU( void ) +{ + CGLError cgl_error = (CGLError)0; + bool result = false; + + CGLContextObj oldctx = CGLGetCurrentContext(); + + static CGLPixelFormatAttribute attribs[] = + { + kCGLPFADoubleBuffer, + kCGLPFANoRecovery, + kCGLPFAAccelerated, + kCGLPFADepthSize, + (CGLPixelFormatAttribute)0, + kCGLPFAColorSize, + (CGLPixelFormatAttribute)32, + + (CGLPixelFormatAttribute)0 // list term + }; + + CGLPixelFormatObj pixfmtobj = NULL; + GLint npix; + + CGLContextObj ctxobj = NULL; + + cgl_error = CGLChoosePixelFormat( attribs, &pixfmtobj, &npix ); + if (!cgl_error) + { + // got pixel format, make a context + + cgl_error = CGLCreateContext( pixfmtobj, NULL, &ctxobj ); + if (!cgl_error) + { + CGLSetCurrentContext( ctxobj ); + + // now do the test + + _CGLContextParameter kCGLCPGCDMPEngine = ((_CGLContextParameter)1314); + + GLint dummyval = 0; + cgl_error = CGLGetParameter( CGLGetCurrentContext(), kCGLCPGCDMPEngine, &dummyval ); + + result = (!cgl_error); + + // all done, go back to old context, and destroy the temp one + CGLSetCurrentContext( oldctx ); + CGLDestroyContext( ctxobj ); + } + + // destroy the pixel format obj + CGLDestroyPixelFormat( pixfmtobj ); + } + + return result; +} + + +bool GLMDetectScaledResolveMode( uint osComboVersion, bool hasSLGU ); +bool GLMDetectScaledResolveMode( uint osComboVersion, bool hasSLGU ) +{ + bool result = false; + + // note this function assumes a current context on the renderer in question + // and that FB blit and SLGU are present.. + + if (!hasSLGU) + return false; + + if (osComboVersion <= 0x000A0604) // we know no one has it before 10.6.5 + return false; + + bool forceTrickyTest = true; // for debug + if ( (osComboVersion < 0x000A0606) || forceTrickyTest) + { + // make two FBO's + GLuint fbos[2]; + GLuint rbos[2]; + int extent = 64; + + // make two render buffers + + for( int fbi = 0; fbi < 2; fbi++ ) + { + glGenFramebuffersEXT( 1, &fbos[fbi] ); __checkgl__(); + glBindFramebufferEXT( fbi ? GL_DRAW_FRAMEBUFFER_EXT : GL_READ_FRAMEBUFFER_EXT , fbos[fbi] ); __checkgl__(); + + glGenRenderbuffersEXT( 1, &rbos[fbi] ); __checkgl__(); + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, rbos[fbi] ); __checkgl__(); + + // make it multisampled if 0 + if (!fbi) + { + glRenderbufferStorageMultisampleEXT( GL_RENDERBUFFER_EXT, 2, GL_RGBA8, extent,extent ); __checkgl__(); + } + else + { + glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_RGBA8, extent,extent ); __checkgl__(); + } + + // attach it + // #0 gets to be read and multisampled + // #1 gets to be draw and multisampled + glFramebufferRenderbufferEXT( fbi ? GL_DRAW_FRAMEBUFFER_EXT : GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, rbos[fbi] ); __checkgl__(); + } + // now test + while( glGetError() ) // clear error queue + { + ; + } + + // now do the dummy blit + glBlitFramebufferEXT( 0,0,extent,extent, 0,0,extent,extent, GL_COLOR_BUFFER_BIT, XGL_SCALED_RESOLVE_FASTEST_EXT ); + + // type of error we get back lets us know what the outcome is. + // invalid enum error -> unsupported + // no error or invalid op -> supported + + GLenum errorcode = (GLenum)glGetError(); + switch(errorcode) + { + // expected outcomes. + + // positive + case GL_NO_ERROR: + case GL_INVALID_OPERATION: + result = true; // new scaled resolve detected + break; + + default: + result = false; // no scaled resolve + break; + } + + // unbind and wipe stuff + + glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 ); __checkgl__(); + + for( int xfbi = 0; xfbi < 2; xfbi++ ) + { + // unbind FBO + glBindFramebufferEXT( xfbi ? GL_DRAW_FRAMEBUFFER_EXT : GL_READ_FRAMEBUFFER_EXT , 0 ); __checkgl__(); + + // del FBO and RBO + glDeleteFramebuffersEXT( 1, &fbos[xfbi] ); __checkgl__(); + glDeleteRenderbuffersEXT( 1, &rbos[xfbi] ); __checkgl__(); + } + } + else + { + // in 10.6.6 and later, just check for the ext string. + char *gl_ext_string = (char*)glGetString(GL_EXTENSIONS); + + result = strstr(gl_ext_string, "GL_EXT_framebuffer_multisample_blit_scaled") != NULL; + } + + return result; // no SLGU, no scaled resolve blit even possible +} + + +// ------------------------------------------------------------------------------------ // +// some glue to let GLMgr call into NS/ObjC classes. +// ------------------------------------------------------------------------------------ // + +bool NewNSGLContext( unsigned long *attribs, PseudoNSGLContextPtr nsglShareCtx, PseudoNSGLContextPtr *nsglCtxOut, CGLContextObj *cglCtxOut ) +{ + NSAutoreleasePool *tempPool = [[NSAutoreleasePool alloc] init ]; + NSOpenGLPixelFormat *pixFmt = NULL; + NSOpenGLContext *nsglCtx = NULL; + + bool result = true; // optimism + + if (result) + { + pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*)attribs]; + if (!pixFmt) + { + Debugger(); // bad news + result = false; + } + } + + if (result) + { + nsglCtx = [[NSOpenGLContext alloc] initWithFormat: pixFmt shareContext: (NSOpenGLContext*) nsglShareCtx ]; + if (!nsglCtx) + { + Debugger(); + result = false; + } + } + + if (result) + { + [nsglCtx makeCurrentContext]; + + *nsglCtxOut = nsglCtx; + *cglCtxOut = (CGLContextObj)[ (NSOpenGLContext*)nsglCtx CGLContextObj ]; + } + else + { + *nsglCtxOut = NULL; + *cglCtxOut = NULL; + } + + [tempPool release]; + + return result; +} + +CGLContextObj GetCGLContextFromNSGL( PseudoNSGLContextPtr nsglCtx ) +{ + return (CGLContextObj)[ (NSOpenGLContext*)nsglCtx CGLContextObj]; +} + +void DelNSGLContext( PseudoNSGLContextPtr nsglCtx ) +{ + [ (NSOpenGLContext*)nsglCtx release ]; +} + + + + +// ------------------------------------------------------------------------------------ // + +// GLMDisplayDB stuff hoisted from appframework (cocoamgr) + +//=============================================================================== +// GLMDisplayMode, GLMDisplayInfo, GLMRendererInfo, GLMDisplayDB methods + +GLMDisplayMode::GLMDisplayMode( uint width, uint height, uint refreshHz ) +{ + m_info.m_modePixelWidth = width; + m_info.m_modePixelHeight = height; + m_info.m_modeRefreshHz = refreshHz; +} + +GLMDisplayMode::~GLMDisplayMode() +{ + // empty +} + +void GLMDisplayMode::Dump( int which ) +{ + GLMPRINTF(("\n # %-2d width=%-4d height=%-4d refreshHz=%-2d", which, m_info.m_modePixelWidth, m_info.m_modePixelHeight, m_info.m_modeRefreshHz )); +} + + +//=============================================================================== + +GLMDisplayInfo::GLMDisplayInfo( CGDirectDisplayID displayID, CGOpenGLDisplayMask displayMask ) +{ + m_info.m_cgDisplayID = displayID; + m_info.m_glDisplayMask = displayMask; + + // extract info about this display such as pixel width and height + m_info.m_displayPixelWidth = (uint)CGDisplayPixelsWide( m_info.m_cgDisplayID ); + m_info.m_displayPixelHeight = (uint)CGDisplayPixelsHigh( m_info.m_cgDisplayID ); + + m_modes = NULL; +} + +GLMDisplayInfo::~GLMDisplayInfo( void ) +{ + if (m_modes) + { + // delete all the new'd display modes + for( std::vector< GLMDisplayMode * >::iterator p = m_modes->begin(); p != m_modes->end(); p++ ) + { + delete *p; + } + delete m_modes; + m_modes = NULL; + } +} + +struct DisplayModeLessThan +{ + bool operator ()(GLMDisplayMode *A, GLMDisplayMode *B) + { + bool bigger = false; + bool smaller = true; + + // check refreshrate - higher should win + if ( A->m_info.m_modeRefreshHz > B->m_info.m_modeRefreshHz ) + { + return bigger; + } + else if ( A->m_info.m_modeRefreshHz < B->m_info.m_modeRefreshHz ) + { + return smaller; + } + + // check area - larger mode should win + int areaa = A->m_info.m_modePixelWidth * A->m_info.m_modePixelHeight; + int areab = B->m_info.m_modePixelWidth * B->m_info.m_modePixelHeight; + + if ( areaa > areab ) + { + return bigger; + } + else if ( areaa < areab ) + { + return smaller; + } + + return false; // equal rank + } +}; + +void GLMDisplayInfo::PopulateModes( void ) +{ + Assert( !m_modes ); + m_modes = new std::vector< GLMDisplayMode* >; + + CFArrayRef modeList; +// CGDisplayErr cgderr; + CFDictionaryRef cgvidmode; + CFNumberRef number; + CFBooleanRef boolean; + + modeList = CGDisplayAvailableModes( m_info.m_cgDisplayID ); + if ( modeList != NULL ) + { + // examine each mode + CFIndex count = CFArrayGetCount( modeList ); + + for (CFIndex i = 0; i < count; i++) + { + long modeHeight = 0, modeWidth = 0; + long depth = 0; + long refreshrate = 0; + Boolean usable, stretched = false; + + // grab the mode dictionary + cgvidmode = (CFDictionaryRef)CFArrayGetValueAtIndex( modeList, i); + + // grab mode params we need + number = (CFNumberRef)CFDictionaryGetValue(cgvidmode, kCGDisplayBitsPerPixel); + CFNumberGetValue(number, kCFNumberLongType, &depth); + + boolean = (CFBooleanRef)CFDictionaryGetValue(cgvidmode, kCGDisplayModeUsableForDesktopGUI) ; + usable = CFBooleanGetValue(boolean); + + boolean = (CFBooleanRef)CFDictionaryGetValue(cgvidmode, kCGDisplayModeIsStretched); + if (NULL != boolean) + { + stretched = CFBooleanGetValue(boolean); + } + + if ( usable && (!stretched) && (depth==32) ) + { + // we're going to log this mode to the mode table. + + // get height of mode + number = (CFNumberRef)CFDictionaryGetValue( cgvidmode, kCGDisplayHeight ); + CFNumberGetValue(number, kCFNumberLongType, &modeHeight); + + // get width of mode + number = (CFNumberRef)CFDictionaryGetValue( cgvidmode, kCGDisplayWidth ); + CFNumberGetValue(number, kCFNumberLongType, &modeWidth); + + // get refresh rate of mode + number = (CFNumberRef)CFDictionaryGetValue( cgvidmode, kCGDisplayRefreshRate ); + double flrefreshrate = 0.0f; + CFNumberGetValue( number, kCFNumberDoubleType, &flrefreshrate ); + refreshrate = (int)flrefreshrate; + + // exclude silly small modes + if ( (modeHeight >= 384) && (modeWidth >= 512) ) + { + GLMDisplayMode *newmode = new GLMDisplayMode( modeWidth, modeHeight, refreshrate ); + m_modes->push_back( newmode ); + } + } + } + } + + // now sort the modes + // primary key is refresh rate + // secondary key is area + + sort( m_modes->begin(), m_modes->end(), DisplayModeLessThan() ); +} + + +void GLMDisplayInfo::Dump( int which ) +{ + GLMPRINTF(("\n #%d: GLMDisplayInfo @ %08x, cg-id=%p display-mask=%08x pixwidth=%d pixheight=%d", which, this, m_info.m_cgDisplayID, m_info.m_glDisplayMask, m_info.m_displayPixelWidth, m_info.m_displayPixelHeight )); + + int i=0; + for( std::vector< GLMDisplayMode * >::iterator p = m_modes->begin(); p != m_modes->end(); p++ ) + { + (*p)->Dump(i); + i++; + } +} + + +//=============================================================================== + +GLMRendererInfo::GLMRendererInfo( GLMRendererInfoFields *info ) +{ + NSAutoreleasePool *tempPool = [[NSAutoreleasePool alloc] init ]; + + // absorb info obtained so far by caller + m_info = *info; + m_displays = NULL; + + // gather more info using a dummy context + unsigned int attribs[] = + { + kCGLPFADoubleBuffer, kCGLPFANoRecovery, kCGLPFAAccelerated, + kCGLPFADepthSize, 0, + kCGLPFAColorSize, 32, + kCGLPFARendererID, static_cast(info->m_rendererID), + 0 + }; + + NSOpenGLPixelFormat *pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*)attribs]; + NSOpenGLContext *nsglCtx = [[NSOpenGLContext alloc] initWithFormat: pixFmt shareContext: NULL ]; + + [nsglCtx makeCurrentContext]; + + // run queries. + char *gl_ext_string = (char*)glGetString(GL_EXTENSIONS); + + uint vers = m_info.m_osComboVersion; + + //------------------------------------------------------------------- + // booleans + //------------------------------------------------------------------- + // gamma writes. + m_info.m_hasGammaWrites = true; + if ( vers < 0x000A0600 ) // pre 10.6.0, no SRGB write - see http://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1058.html + { + m_info.m_hasGammaWrites = false; + } + + if (m_info.m_atiR5xx) + { + m_info.m_hasGammaWrites = false; // it just don't, even post 10.6.3 + } + + // if CLI option for fake SRGB mode is enabled, turn off this cap, act like we do not have EXT FB SRGB + if (0 /* CommandLine()->FindParm("-glmenablefakesrgb") */) + { + m_info.m_hasGammaWrites = false; + } + + // extension string *could* be checked, but on 10.6.3 the ext string is not there, but the func *is* + + //------------------------------------------------------------------- + // mixed attach sizes for FBO + m_info.m_hasMixedAttachmentSizes = true; + if ( vers < 0x000A0603 ) // pre 10.6.3, no mixed attach sizes + { + m_info.m_hasMixedAttachmentSizes = false; + } + else + { + if (!strstr(gl_ext_string, "GL_ARB_framebuffer_object")) + { + // ARB_framebuffer_object not available + m_info.m_hasMixedAttachmentSizes = false; + } + } + // also check ext string + + //------------------------------------------------------------------- + // BGRA vert attribs + m_info.m_hasBGRA = true; + if ( vers < 0x000A0603 ) // pre 10.6.3, no BGRA attribs + { + m_info.m_hasBGRA = false; + } + else + { + if (!strstr(gl_ext_string, "EXT_vertex_array_bgra")) + { + // EXT_vertex_array_bgra not available + m_info.m_hasBGRA = false; + } + } + + //------------------------------------------------------------------- + m_info.m_hasNewFullscreenMode = true; + if ( vers < 0x000A0600 ) // pre 10.6.0, no clever window server full screen mode + { + m_info.m_hasNewFullscreenMode = false; + } + + //------------------------------------------------------------------- + m_info.m_hasNativeClipVertexMode = true; + // this one uses a heuristic, and allows overrides in case the heuristic is wrong + // or someone wants to try a beta driver or something. + + // known bad combinations get turned off here.. + + // any ATI hardware... + // TURNED OFF OS CHECK if (m_info.m_osComboVersion <= 0x000A0603) + // still believe to be broken in 10.6.4 + { + if (m_info.m_ati) + { + m_info.m_hasNativeClipVertexMode = false; + } + } + + // R500, forever.. + if (m_info.m_atiR5xx) + { + m_info.m_hasNativeClipVertexMode = false; + } + + // if user disabled them + if (0 /* CommandLine()->FindParm("-glmdisableclipplanes") */) + { + m_info.m_hasNativeClipVertexMode = false; + } + + // or maybe enabled them.. + if (0 /* CommandLine()->FindParm("-glmenableclipplanes") */) + { + m_info.m_hasNativeClipVertexMode = true; + } + + //------------------------------------------------------------------- + m_info.m_hasOcclusionQuery = true; + if (!strstr(gl_ext_string, "ARB_occlusion_query")) + { + m_info.m_hasOcclusionQuery = false; // you don't got it! + } + + //------------------------------------------------------------------- + m_info.m_hasFramebufferBlit = true; + if (!strstr(gl_ext_string, "EXT_framebuffer_blit")) + { + m_info.m_hasFramebufferBlit = false; // you know you don't got it! + } + + //------------------------------------------------------------------- + m_info.m_maxAniso = 4; //FIXME needs real query + + //------------------------------------------------------------------- + m_info.m_hasBindableUniforms = true; + if (!strstr(gl_ext_string, "EXT_bindable_uniform")) + { + m_info.m_hasBindableUniforms = false; + } + m_info.m_hasBindableUniforms = false; // hardwiring this path to false until we see how to accelerate it properly + + //------------------------------------------------------------------- + m_info.m_hasUniformBuffers = true; + if (!strstr(gl_ext_string, "ARB_uniform_buffer")) + { + m_info.m_hasUniformBuffers = false; + } + + //------------------------------------------------------------------- + // test for performance pack (10.6.4+) + + bool perfPackageDetected = GLMDetectSLGU(); + + if (perfPackageDetected) + { + m_info.m_hasPerfPackage1 = true; + } + + if (0 /* CommandLine()->FindParm("-glmenableperfpackage") */) // force it on + { + m_info.m_hasPerfPackage1 = true; + } + + if (0 /* CommandLine()->FindParm("-glmdisableperfpackage") */) // force it off + { + m_info.m_hasPerfPackage1 = false; + } + + + //------------------------------------------------------------------- + // runtime options that aren't negotiable once set + + m_info.m_hasDualShaders = 0; /*CommandLine()->FindParm("-glmdualshaders"); */ + + //------------------------------------------------------------------- + // "can'ts " + + m_info.m_cantBlitReliably = m_info.m_intel; //FIXME X3100&10.6.3 has problems blitting.. adjust this if bug fixed in 10.6.4 + if (0 /*CommandLine()->FindParm("-glmenabletrustblit") */) + { + m_info.m_cantBlitReliably = false; // we trust the blit, so set the cant-blit cap to false + } + if (0 /* CommandLine()->FindParm("-glmdisabletrustblit") */) + { + m_info.m_cantBlitReliably = true; // we do not trust the blit, so set the cant-blit cap to true + } + + //m_info.m_cantAttachSRGB = (m_info.m_nv && m_info.m_osComboVersion < 0x000A0600); //NV drivers won't accept SRGB tex on an FBO color target in 10.5.8 + //m_info.m_cantAttachSRGB = (m_info.m_ati && m_info.m_osComboVersion < 0x000A0600); //... does ATI have the same problem? + m_info.m_cantAttachSRGB = (m_info.m_osComboVersion < 0x000A0600); // across the board on 10.5.x actually.. + + // MSAA resolve issues + m_info.m_cantResolveFlipped = false; // initial stance + + if (m_info.m_nv) + { + // we're going to mark it 'broken' unless perf package 1 (10.6.4+) is present + if (!m_info.m_hasPerfPackage1) + { + m_info.m_cantResolveFlipped = true; + } + } + + // this is just the private assessment of whather scaled resolve is available. + // the activation of it will stay tied to the gl_minify_resolve_mode / gl_magnify_resolve_mode convars in glmgr + if ( 1 /* CommandLine()->FindParm("-gl_enable_scaled_resolve") */ ) + { + bool scaledResolveDetected = GLMDetectScaledResolveMode( m_info.m_osComboVersion, m_info.m_hasPerfPackage1 ); + m_info.m_cantResolveScaled = !scaledResolveDetected; + } + else + { + m_info.m_cantResolveScaled = true; + } + + // and you can force it to be "available" if you really want to.. + if ( 0 /* CommandLine()->FindParm("-gl_force_enable_scaled_resolve") */ ) + { + m_info.m_cantResolveScaled = false; + } + + // gamma decode impacting shader codegen + m_info.m_costlyGammaFlips = false; + if (m_info.m_osComboVersion < 0x000A0600) // if Leopard + m_info.m_costlyGammaFlips = true; + + if (m_info.m_atiR5xx) // or r5xx - always + m_info.m_costlyGammaFlips = true; + + if ( (m_info.m_atiR6xx) && (m_info.m_osComboVersion < 0x000A0605) ) // or r6xx prior to 10.6.5 + m_info.m_costlyGammaFlips = true; + + [nsglCtx release]; + [pixFmt release]; + + [tempPool release]; +} + +GLMRendererInfo::~GLMRendererInfo( void ) +{ + if (m_displays) + { + // delete all the new'd renderer infos that the table tracks + for( std::vector< GLMDisplayInfo * >::iterator p = m_displays->begin(); p != m_displays->end(); p++ ) + { + delete *p; + } + delete m_displays; + m_displays = NULL; + } +} + +struct DisplayInfoLessThan +{ + bool operator ()(GLMDisplayInfo *A, GLMDisplayInfo *B) + { + bool bigger = false; + bool smaller = true; + + // check main-ness - main should win + + uint maskOfMainDisplay = CGDisplayIDToOpenGLDisplayMask( CGMainDisplayID() ); + //Assert( maskOfMainDisplay==1 ); // just curious + + int mainscreena = (*A).m_info.m_glDisplayMask & maskOfMainDisplay; + int mainscreenb = (*B).m_info.m_glDisplayMask & maskOfMainDisplay; + + if ( mainscreena > mainscreenb ) + { + return bigger; + } + else if ( mainscreena < mainscreenb ) + { + return smaller; + } + + // check area - larger screen should win + int areaa = (*A).m_info.m_displayPixelWidth * (*A).m_info.m_displayPixelHeight; + int areab = (*B).m_info.m_displayPixelWidth * (*B).m_info.m_displayPixelHeight; + + if ( areaa > areab ) + { + return bigger; + } + else if ( areaa < areab ) + { + return smaller; + } + + return false; // equal rank + } +}; + +void GLMRendererInfo::PopulateDisplays( void ) +{ + Assert( !m_displays ); + m_displays = new std::vector< GLMDisplayInfo* >; + + for( int i=0; i<32; i++) + { + // check mask to see if the selected display intersects this renderer + CGOpenGLDisplayMask dspMask = (CGOpenGLDisplayMask)(1<= 512) && (CGDisplayPixelsHigh( cgid ) >= 384) ) + { + GLMDisplayInfo *newdisp = new GLMDisplayInfo( cgid, dspMask ); + m_displays->push_back( newdisp ); + } + } + } + + // now sort the table of displays. + sort( m_displays->begin(), m_displays->end(), DisplayInfoLessThan() ); + + // then go back and ask each display to populate its display mode table. + for( std::vector< GLMDisplayInfo * >::iterator p = m_displays->begin(); p != m_displays->end(); p++ ) + { + (*p)->PopulateModes(); + } +} + +const char *CheesyRendererDecode( uint value ) +{ + switch(value) + { + case 0x00020200 : return "Generic"; + case 0x00020400 : return "GenericFloat"; + case 0x00020600 : return "AppleSW"; + case 0x00021000 : return "ATIRage128"; + case 0x00021200 : return "ATIRadeon"; + case 0x00021400 : return "ATIRagePro"; + case 0x00021600 : return "ATIRadeon8500"; + case 0x00021800 : return "ATIRadeon9700"; + case 0x00021900 : return "ATIRadeonX1000"; + case 0x00021A00 : return "ATIRadeonX2000"; + case 0x00022000 : return "NVGeForce2MX"; + case 0x00022200 : return "NVGeForce3"; + case 0x00022400 : return "NVGeForceFX"; + case 0x00022600 : return "NVGeForce8xxx"; + case 0x00023000 : return "VTBladeXP2"; + case 0x00024000 : return "Intel900"; + case 0x00024200 : return "IntelX3100"; + case 0x00040000 : return "Mesa3DFX"; + + default: return "UNKNOWN"; + } +} + +extern const char *GLMDecode( GLMThing_t thingtype, unsigned long value ); + +void GLMRendererInfo::Dump( int which ) +{ + GLMPRINTF(("\n #%d: GLMRendererInfo @ %08x, renderer-id=%s(%08x) display-mask=%08x vram=%dMB", + which, this, + CheesyRendererDecode( m_info.m_rendererID & 0x00FFFF00 ), m_info.m_rendererID, + m_info.m_displayMask, + m_info.m_vidMemory >> 20 + )); + GLMPRINTF(("\n VendorID=%04x DeviceID=%04x Model=%s", + m_info.m_pciVendorID, + m_info.m_pciDeviceID, + m_info.m_pciModelString + )); + + int i=0; + for( std::vector< GLMDisplayInfo * >::iterator p = m_displays->begin(); p != m_displays->end(); p++ ) + { + (*p)->Dump(i); + i++; + } +} + + +//=============================================================================== + + +GLMDisplayDB::GLMDisplayDB ( void ) +{ + m_renderers = NULL; +} + +GLMDisplayDB::~GLMDisplayDB ( void ) +{ + if (m_renderers) + { + // delete all the new'd renderer infos that the table tracks + for( std::vector< GLMRendererInfo * >::iterator p = m_renderers->begin(); p != m_renderers->end(); p++ ) + { + delete (*p); + } + delete m_renderers; + m_renderers = NULL; + } +} + +struct RendererInfoLessThan +{ + bool operator ()(GLMRendererInfo *A, GLMRendererInfo *B) + { + bool bigger = false; + bool smaller = true; + + // check VRAM + if ( A->m_info.m_vidMemory > B->m_info.m_vidMemory ) + { + return bigger; + } + else if ( A->m_info.m_vidMemory < B->m_info.m_vidMemory ) + { + return smaller; + } + + // check MSAA limit + if ( A->m_info.m_maxSamples > B->m_info.m_maxSamples ) + { + return bigger; + } + else if ( A->m_info.m_maxSamples < B->m_info.m_maxSamples ) + { + return smaller; + } + + return false; // equal rank + } +}; + +void GLMDisplayDB::PopulateRenderers( void ) +{ + Assert( !m_renderers ); + m_renderers = new std::vector< GLMRendererInfo* >; + + // now walk the renderer list + // find the eligible ones and insert them into vector + // if more than one, sort the vector by desirability with favorite at 0 + // then ask each renderer object to populate its displays + + // turns out how you have to do this is to walk the display mask 1<: unknown error code: invalid display" + // we can fix that by getting the active display mask first. + if (!cgl_err) + { + // walk the renderers that can hit this display + // add to table if not already in table, and minimums met + + for( int j=0; jFindParm("-fakeleopard") */) + { + // lie + fields.m_osComboVersion = 0x000A0508; + } + + if (fields.m_osComboVersion < 0x000A0508) + { + // no support below 10.5.8 + // we'll wind up with no valid renderers and give up + selected = false; + } + } + + if (selected) + { + // gather more info from IOKit + // cribbed from http://developer.apple.com/mac/library/samplecode/VideoHardwareInfo/listing3.html + + CFTypeRef typeCode; + CFDataRef vendorID, deviceID, model; + io_registry_entry_t dspPort; + + // Get the I/O Kit service port for the display + dspPort = CGDisplayIOServicePort( cgid ); + + // Get the information for the device + // The vendor ID, device ID, and model are all available as properties of the hardware's I/O Kit service port + + vendorID = (CFDataRef)IORegistryEntrySearchCFProperty(dspPort,kIOServicePlane,CFSTR("vendor-id"), kCFAllocatorDefault,kIORegistryIterateRecursively | kIORegistryIterateParents); + deviceID = (CFDataRef)IORegistryEntrySearchCFProperty(dspPort,kIOServicePlane,CFSTR("device-id"), kCFAllocatorDefault,kIORegistryIterateRecursively | kIORegistryIterateParents); + model = (CFDataRef)IORegistryEntrySearchCFProperty(dspPort,kIOServicePlane,CFSTR("model"), kCFAllocatorDefault,kIORegistryIterateRecursively | kIORegistryIterateParents); + + // Send the appropriate data to the outputs checking to validate the data + if(vendorID) + { + fields.m_pciVendorID = *((UInt32*)CFDataGetBytePtr(vendorID)); + CFRelease( vendorID ); + vendorID = NULL; + } + else + { + fields.m_pciVendorID = 0; + } + + if(deviceID) + { + fields.m_pciDeviceID = *((UInt32*)CFDataGetBytePtr(deviceID)); + CFRelease( deviceID ); + deviceID = NULL; + } + else + { + fields.m_pciDeviceID = 0; + } + + if(model) + { + int length = CFDataGetLength(model); + char *data = (char*)CFDataGetBytePtr(model); + strncpy( fields.m_pciModelString, data, sizeof(fields.m_pciModelString) ); + CFRelease( model ); + model = NULL; + } + else + { + strncpy( fields.m_pciModelString, "UnknownModel", sizeof(fields.m_pciModelString) ); + } + + + // iterate through IOAccelerators til we find one that matches the vendorid and deviceid of this renderer (ugh!) + // this provides the driver version string which can in turn be used to uniquely identify bad drivers and special case for them + // first example to date - forcing vsync on 10.6.4 + NV + + { + io_iterator_t ioIterator = (io_iterator_t)0; + io_service_t ioAccelerator; + kern_return_t ioResult = 0; + bool ioDone = false; + + ioResult = IOServiceGetMatchingServices( kIOMasterPortDefault, IOServiceMatching("IOAccelerator"), &ioIterator ); + if( ioResult == KERN_SUCCESS ) + { + ioAccelerator = 0; + + while( ( !ioDone ) && ( ioAccelerator = IOIteratorNext( ioIterator ) ) ) + { + io_service_t ioDevice; + + ioDevice = 0; + ioResult = IORegistryEntryGetParentEntry( ioAccelerator, kIOServicePlane, &ioDevice); + + CFDataRef this_vendorID, this_deviceID; + + if(ioResult == KERN_SUCCESS) + { + this_vendorID = (CFDataRef)IORegistryEntryCreateCFProperty(ioDevice, CFSTR("vendor-id"), kCFAllocatorDefault, kNilOptions ); + this_deviceID = (CFDataRef)IORegistryEntryCreateCFProperty(ioDevice, CFSTR("device-id"), kCFAllocatorDefault, kNilOptions ); + + if (this_vendorID && this_deviceID) // null check.. + { + // see if it matches. if so, do our business (get the extended version string), set ioDone, call it a day + unsigned short this_vendorIDValue = *(unsigned short*)CFDataGetBytePtr(this_vendorID); + unsigned short this_deviceIDValue = *(unsigned short*)CFDataGetBytePtr(this_deviceID); + + if ( (fields.m_pciVendorID == this_vendorIDValue) && (fields.m_pciDeviceID == this_deviceIDValue) ) + { + // see if it matches. if so, do our business (get the extended version string), set ioDone, call it a day + unsigned short* this_vendorIDBytes = (unsigned short*)CFDataGetBytePtr( this_vendorID ); + unsigned short* this_deviceIDBytes = (unsigned short*)CFDataGetBytePtr( this_deviceID ); + + if (this_vendorIDBytes && this_deviceIDBytes) // null check... + { + unsigned short this_vendorIDValue = *this_vendorIDBytes; + unsigned short this_deviceIDValue = *this_deviceIDBytes; + + if ( (fields.m_pciVendorID == this_vendorIDValue) && (fields.m_pciDeviceID == this_deviceIDValue) ) + { + // match, stop looking + ioDone = true; + + // get extended info + CFStringRef this_ioglName = (CFStringRef)IORegistryEntryCreateCFProperty( ioAccelerator, CFSTR("IOGLBundleName"), kCFAllocatorDefault, kNilOptions ); + + NSString *bundlePath = [ NSString stringWithFormat:@"/System/Library/Extensions/%@.bundle", this_ioglName ]; + + NSDictionary* this_driverDict = [ [NSBundle bundleWithPath: bundlePath] infoDictionary ]; + if (this_driverDict) + { + NSString* this_driverInfo = [ this_driverDict objectForKey:@"CFBundleGetInfoString" ]; + if ( this_driverInfo ) + { + const char* theString = [ this_driverInfo UTF8String ]; + + strncpy(fields.m_driverInfoString, theString, sizeof( fields.m_driverInfoString ) ); + } + } + + // [bundlePath release]; + + CFRelease(this_ioglName); + } + } + + CFRelease(this_vendorID); + CFRelease(this_deviceID); + } + } + } + } + } + + IOObjectRelease(ioAccelerator); + IOObjectRelease(ioIterator); + } + + // generate shorthand bools + switch( fields.m_pciVendorID ) + { + case 0x1002: //ATI + { + fields.m_ati = true; + + // http://www.pcidatabase.com/search.php?device_search_str=radeon&device_search.x=0&device_search.y=0&device_search=search+devices + + // Mac-relevant ATI R5xx PCI device ID's lie in this range: 0x7100 - 0x72FF + // X1600, X1900, X1950 + if ( (fields.m_pciDeviceID >= 0x7100) && (fields.m_pciDeviceID <= 0x72ff) ) + { + fields.m_atiR5xx = true; + } + + // R6xx PCI device ID's lie in these ranges: + // 0x94C1 - 0x9515 ... also 0x9581 - 0x9713 + // 2400HD, 2600HD, 3870, et al + if ( + ( (fields.m_pciDeviceID >= 0x94C1) && (fields.m_pciDeviceID <= 0x9515) ) + || ( (fields.m_pciDeviceID >= 0x9581) && (fields.m_pciDeviceID <= 0x9713) ) + ) + { + fields.m_atiR6xx = true; + } + + // R7xx PCI device ID's lie in: 0x9440 - 0x9460, also 9480-94b5. + // why there is an HD5000 at 9462, I dunno. Don't think that's an R8xx part. + if ( + ( (fields.m_pciDeviceID >= 0x9440) && (fields.m_pciDeviceID <= 0x9460) ) + || ( (fields.m_pciDeviceID >= 0x9480) && (fields.m_pciDeviceID <= 0x94B5) ) + ) + { + fields.m_atiR7xx = true; + } + + // R8xx: 0x6898-0x68BE + if ( (fields.m_pciDeviceID >= 0x6898) && (fields.m_pciDeviceID <= 0x68Be) ) + { + fields.m_atiR8xx = true; + } + + #if 0 + // turned off, but we could use this for cross check. + // we could also use the bit encoding of the renderer ID to ferret out a geberation clue. + + // string-scan for each generation + // this could be a lot better if we got the precise PCI ID's used and/or cross-ref'd that against the driver name + if (strstr("X1600", fields.m_pciModelString) || strstr("X1900", fields.m_pciModelString) || strstr("X1950", fields.m_pciModelString) ) + { + fields.m_atiR5xx = true; + } + + if (strstr("2600", fields.m_pciModelString) || strstr("3870", fields.m_pciModelString) || strstr("X2000", fields.m_pciModelString) ) + { + fields.m_atiR6xx = true; + } + + if (strstr("4670", fields.m_pciModelString) || strstr("4650", fields.m_pciModelString) || strstr("4850", fields.m_pciModelString)|| strstr("4870", fields.m_pciModelString) ) + { + fields.m_atiR7xx = true; + } + #endif + } + break; + + case 0x8086: //INTC + { + fields.m_intel = true; + + switch( fields.m_pciDeviceID ) + { + case 0x27A6: fields.m_intel95x = true; break; // GMA 950 + case 0x2A02: fields.m_intel3100 = true; break; // X3100 + + default: + { + if (fields.m_pciDeviceID > 0x2A02) // assume ascending ID's for newer devices + { + fields.m_intelNewer = true; + } + } + } + } + break; + + case 0x10DE: //NV + { + fields.m_nv = true; + + // G7x: 0x0391 0x393 0x0395 (7300/7600 GT) 0x009D (Quadro FX) + if ( (fields.m_pciDeviceID == 0x0391) || (fields.m_pciDeviceID == 0x0393) || (fields.m_pciDeviceID == 0x0395) || (fields.m_pciDeviceID == 0x009D) ) + { + fields.m_nvG7x = true; + } + + // G8x: 0400-04ff, also 0x5E1 (GTX280) through 0x08FF + if ( + ( (fields.m_pciDeviceID >= 0x0400) && (fields.m_pciDeviceID <= 0x04ff) ) + || ( (fields.m_pciDeviceID >= 0x05E1) && (fields.m_pciDeviceID <= 0x08ff) ) + ) + { + fields.m_nvG8x = true; + } + + if ( fields.m_pciDeviceID > 0x0900 ) + { + fields.m_nvNewer = true; + } + + // detect the specific revision of NV driver in 10.6.4 that caused all the grief + if (strstr(fields.m_driverInfoString, "1.6.16.11 (19.5.8f01)")) + { + fields.m_badDriver1064NV = true; + } + } + break; + } + } + + if (selected) + { + // dupe check + for( std::vector< GLMRendererInfo * >::iterator p = m_renderers->begin(); p != m_renderers->end(); p++ ) + { + uint rendid = (*p)->m_info.m_rendererID; + + if ( rendid == fields.m_rendererID ) + { + // don't add to table, it's a dupe + selected = false; + } + } + } + + if (selected) + { + // criteria check + if (fields.m_fullscreen==0) + selected = false; + if (fields.m_accelerated==0) + selected = false; + if (fields.m_windowed==0) + selected = false; + } + + // we need something here that will exclude the renderer if it does not have any good displays attached. + + Assert( fields.m_displayMask != 0 ); + + if (selected) + { + // add to table + // note this constructor makes a dummy context just long enough to query remaining fields in the m_info. + GLMRendererInfo *newinfo = new GLMRendererInfo( &fields ); + m_renderers->push_back( newinfo ); + } + } + if (cgl_rend) + { + CGLDestroyRendererInfo( cgl_rend ); + } + } + } + } + + // now sort the table. + sort( m_renderers->begin(), m_renderers->end(), RendererInfoLessThan() ); + + // then go back and ask each renderer to populate its display info table. + for( std::vector< GLMRendererInfo * >::iterator p = m_renderers->begin(); p != m_renderers->end(); p++ ) + { + (*p)->PopulateDisplays(); + } +} + +void GLMDisplayDB::PopulateFakeAdapters( uint realRendererIndex ) // fake adapters = one real adapter times however many displays are on it +{ + // presumption is that renderers have been populated. + Assert( GetRendererCount() > 0 ); + Assert( realRendererIndex < GetRendererCount() ); + + m_fakeAdapters.clear(); + + // for( int r = 0; r < GetRendererCount(); r++ ) + int r = realRendererIndex; + { + for( int d = 0; d < GetDisplayCount( r ); d++ ) + { + GLMFakeAdapter temp; + + temp.m_rendererIndex = r; + temp.m_displayIndex = d; + + m_fakeAdapters.push_back( temp ); + } + } +} + +void GLMDisplayDB::Populate(void) +{ + this->PopulateRenderers(); + + // passing in zero here, constrains the set of fake adapters (GL renderer + a display) to the ones using the highest ranked renderer. + //FIXME introduce some kind of convar allowing selection of other GPU's in the system. + + int realRendererIndex = 0; + + /* + if (CommandLine()->FindParm("-glmrenderer0")) + realRendererIndex = 0; + if (CommandLine()->FindParm("-glmrenderer1")) + realRendererIndex = 1; + if (CommandLine()->FindParm("-glmrenderer2")) + realRendererIndex = 2; + if (CommandLine()->FindParm("-glmrenderer3")) + realRendererIndex = 3; + */ + + if (realRendererIndex >= GetRendererCount()) + { + // fall back to 0 + realRendererIndex = 0; + } + + this->PopulateFakeAdapters( 0 ); + + #if GLMDEBUG + this->Dump(); + #endif +} + + + +int GLMDisplayDB::GetFakeAdapterCount( void ) +{ + return m_fakeAdapters.size(); +} + +bool GLMDisplayDB::GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut ) +{ + if (fakeAdapterIndex >= GetFakeAdapterCount() ) + { + *rendererOut = 0; + *displayOut = 0; + return true; // fail + } + + *rendererOut = m_fakeAdapters[fakeAdapterIndex].m_rendererIndex; + *displayOut = m_fakeAdapters[fakeAdapterIndex].m_displayIndex; + + bool rendResult = GetRendererInfo( *rendererOut, rendererInfoOut ); + bool dispResult = GetDisplayInfo( *rendererOut, *displayOut, displayInfoOut ); + + return rendResult || dispResult; +} + + +int GLMDisplayDB::GetRendererCount( void ) +{ + return m_renderers->size(); +} + +bool GLMDisplayDB::GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut ) +{ + memset( infoOut, 0, sizeof( GLMRendererInfoFields ) ); + + if (rendererIndex >= GetRendererCount()) + return true; // fail + + GLMRendererInfo *rendInfo = (*m_renderers)[rendererIndex]; + *infoOut = rendInfo->m_info; + + return false; +} + +int GLMDisplayDB::GetDisplayCount( int rendererIndex ) +{ + if (rendererIndex >= GetRendererCount()) + return 0; // fail + + GLMRendererInfo *rendInfo = (*m_renderers)[rendererIndex]; + + return rendInfo->m_displays->size(); +} + +bool GLMDisplayDB::GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut ) +{ + memset( infoOut, 0, sizeof( GLMDisplayInfoFields ) ); + + if (rendererIndex >= GetRendererCount()) + return true; // fail + + if (displayIndex >= GetDisplayCount(rendererIndex)) + return true; // fail + + GLMDisplayInfo *displayInfo = (*(*m_renderers)[rendererIndex]->m_displays)[displayIndex]; + *infoOut = displayInfo->m_info; + + return false; +} + +int GLMDisplayDB::GetModeCount( int rendererIndex, int displayIndex ) +{ + if (rendererIndex >= GetRendererCount()) + return 0; // fail + + if (displayIndex >= GetDisplayCount(rendererIndex)) + return 0; // fail + + GLMDisplayInfo *displayInfo = (*(*m_renderers)[rendererIndex]->m_displays)[displayIndex]; + + return displayInfo->m_modes->size(); +} + +bool GLMDisplayDB::GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut ) +{ + memset( infoOut, 0, sizeof( GLMDisplayModeInfoFields ) ); + + if (rendererIndex >= GetRendererCount()) + return true; // fail + + if (displayIndex >= GetDisplayCount(rendererIndex)) + return true; // fail + + if (modeIndex >= GetModeCount(rendererIndex,displayIndex)) + return true; // fail + + if (modeIndex>=0) + { + GLMDisplayMode *displayModeInfo = (*(*(*m_renderers)[rendererIndex]->m_displays)[displayIndex]->m_modes)[ modeIndex ]; + *infoOut = displayModeInfo->m_info; + } + else + { + // passing modeIndex = -1 means "tell me about current mode".. + + GLMRendererInfo *rendInfo = (*m_renderers)[ rendererIndex ]; + GLMDisplayInfo *dispinfo = (*rendInfo ->m_displays)[displayIndex]; + CGDirectDisplayID cgid = dispinfo->m_info.m_cgDisplayID; + + CFDictionaryRef curModeDict = CGDisplayCurrentMode( cgid ); + CFNumberRef number; + CFBooleanRef boolean; + CFArrayRef modeList; + CGDisplayErr cgderr; + + // get the mode number from the mode dict (using system mode numbering, not our sorted numbering) + if (curModeDict) + { + int modeIndex=0; + number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayMode); + CFNumberGetValue(number, kCFNumberLongType, &modeIndex); + + // grab the width and height, I am unclear on whether this is the displayed FB width or the display device width. + int screenWidth=0; + int screenHeight=0; + int refreshHz=0; + + number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayWidth); + CFNumberGetValue(number, kCFNumberLongType, &screenWidth); + number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayHeight); + CFNumberGetValue(number, kCFNumberLongType, &screenHeight); + number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayRefreshRate); + CFNumberGetValue(number, kCFNumberLongType, &refreshHz); + + GLMPRINTF(( "-D- GLMDisplayDB::GetModeInfo sees mode-index=%d, width=%d, height=%d on CGID %08x (display index %d on rendererindex %d)", + modeIndex, + screenWidth, + screenHeight, + cgid, + displayIndex, + rendererIndex )); + + // now match + int foundIndex = -1; + int i=0; + for( std::vector< GLMDisplayMode * >::iterator p = (*dispinfo).m_modes->begin(); p != (*dispinfo).m_modes->end(); p++ ) + { + GLMDisplayMode *mode = (*p); + + if (mode->m_info.m_modePixelWidth == screenWidth) + { + if (mode->m_info.m_modePixelHeight == screenHeight) + { + if (mode->m_info.m_modeRefreshHz == refreshHz) + { + foundIndex = i; + *infoOut = mode->m_info; + return false; + } + } + } + i++; + } + } + + // if we get here, we could not find the mode + memset( infoOut, 0, sizeof( *infoOut ) ); + return true; // fail + } + return false; +} + + +void GLMDisplayDB::Dump( void ) +{ + GLMPRINTF(("\n GLMDisplayDB @ %08x ",this )); + + int i=0; + for( std::vector< GLMRendererInfo * >::iterator p = m_renderers->begin(); p != m_renderers->end(); p++ ) + { + (*p)->Dump(i); + i++; + } +} + + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrext.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrext.cpp new file mode 100644 index 0000000..c93a93b --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrext.cpp @@ -0,0 +1,107 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// glmgrext.h +// helper file for extension testing and runtime importing of entry points +// +//=============================================================================== + +#include +#include +#include +#include +#include +#include "glmgr.h" + +PFNglColorMaskIndexedEXT pfnglColorMaskIndexedEXT; +PFNglEnableIndexedEXT pfnglEnableIndexedEXT; +PFNglDisableIndexedEXT pfnglDisableIndexedEXT; +PFNglGetFramebufferAttachmentParameteriv pfnglGetFramebufferAttachmentParameteriv; +PFNglUniformBufferEXT pfnglUniformBufferEXT; + +// NSSymbol was deprecated in 10.5. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + +void * NSGLGetProcAddress (const char *name) +{ + NSSymbol symbol; + char *symbolName = (char *)malloc (strlen (name) + 2); + strcpy(symbolName + 1, name); + symbolName[0] = '_'; + symbol = NULL; + if (NSIsSymbolNameDefined (symbolName)) + symbol = NSLookupAndBindSymbol (symbolName); + free (symbolName); + return symbol ? NSAddressOfSymbol (symbol) : NULL; +} + +#pragma clang diagnostic pop + +void GLMSetupExtensions( void ) +{ + pfnglColorMaskIndexedEXT = (PFNglColorMaskIndexedEXT) NSGLGetProcAddress( "glColorMaskIndexedEXT" ); + pfnglEnableIndexedEXT = (PFNglEnableIndexedEXT) NSGLGetProcAddress( "glEnableIndexedEXT" ); + pfnglDisableIndexedEXT = (PFNglDisableIndexedEXT) NSGLGetProcAddress( "glDisableIndexedEXT" ); + + pfnglGetFramebufferAttachmentParameteriv = (PFNglGetFramebufferAttachmentParameteriv) NSGLGetProcAddress( "glGetFramebufferAttachmentParameteriv" ); + + pfnglUniformBufferEXT = (PFNglUniformBufferEXT) NSGLGetProcAddress( "glUniformBufferEXT" ); +} + +/* +#define INSTANTIATE_GL_IMPORTS +#include "glmgr.h" // will include glmgrext.h +#undef INSTANTIATE_GL_IMPORTS + + +// helper class for looking up function names +// see http://andrewtolbert.com/svn/personal/OpenGLSuperBible/shared/gltools.cpp +// also http://developer.apple.com/mac/library/DOCUMENTATION/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_entrypts/opengl_entrypts.html + +class CFunctionImporter +{ +public: + CFBundleRef m_bundle; + + CFunctionImporter( CFStringRef bundleID ) // for example CFSTR("com.apple.OpenGL") + { + m_bundle = CFBundleGetBundleWithIdentifier( bundleID ); + if ( m_bundle ) + CFRetain( m_bundle ); + } + + ~CFunctionImporter() + { + if( m_bundle ) + { + CFRelease(m_bundle); + m_bundle = NULL; + } + } + + void *FindFunctionByName(CFStringRef name) // ex CFSTR("glColorMaskedIndexedEXT") + { + void *result = NULL; + if (m_bundle) + { + result = CFBundleGetFunctionPointerForName(m_bundle, name); + } + return result; + } +}; + + +void GLMSetupExtensions( void ) +{ + CFunctionImporter importer( CFSTR("com.apple.OpenGL") ); + + #define DO_IMPORT(name) name = (name##FuncPtr)importer.FindFunctionByName( CFSTR(#name) ); + + #ifndef GL_EXT_draw_buffers2 + // FIXME we're not checking for the extension string yet, we're just grabbing func ptrs + DO_IMPORT(glColorMaskIndexedEXT); + DO_IMPORT(glEnableIndexedEXT); + DO_IMPORT(glDisableIndexedEXT); + #endif +} +*/ diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrext.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrext.h new file mode 100644 index 0000000..75cc9ad --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/glmgrext.h @@ -0,0 +1,101 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ +// +// glmgrext.h +// helper file for extension testing and runtime importing of entry points +// +//=============================================================================== + +#pragma once + +#include +#include + +// #define symbol INSTANTIATE_GL_IMPORTS controls whether the following macro "GL_IMPORT" writes externs or writes decls +// normally only glmgr.cpp sets that symbol and includes this file + +// to simplify usage, a function ptr type must exist for every entry point, following the name##FuncPtr convention. + +#ifdef INSTANTIATE_GL_IMPORTS + #define GL_IMPORT( name ) name##FuncPtr name = 0 +#else + #define GL_IMPORT( name ) extern name##FuncPtr name; +#endif + + +// before declaring each import, check to see if the EXT symbol is in effect, +// and if so, don't do it! + +#ifndef GL_EXT_draw_buffers2 + typedef void (* glColorMaskIndexedEXTFuncPtr) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + typedef void (* glEnableIndexedEXTFuncPtr) (GLenum target, GLuint index); + typedef void (* glDisableIndexedEXTFuncPtr) (GLenum target, GLuint index); + + GL_IMPORT(glColorMaskIndexedEXT); + GL_IMPORT(glEnableIndexedEXT); + GL_IMPORT(glDisableIndexedEXT); +#endif + +#ifndef GL_EXT_framebuffer_sRGB + #define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 + #define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef ARB_texture_rg + #define GL_COMPRESSED_RED 0x8225 + #define GL_COMPRESSED_RG 0x8226 + #define GL_RG 0x8227 + #define GL_RG_INTEGER 0x8228 + #define GL_R8 0x8229 + #define GL_R16 0x822A + #define GL_RG8 0x822B + #define GL_RG16 0x822C + #define GL_R16F 0x822D + #define GL_R32F 0x822E + #define GL_RG16F 0x822F + #define GL_RG32F 0x8230 + #define GL_R8I 0x8231 + #define GL_R8UI 0x8232 + #define GL_R16I 0x8233 + #define GL_R16UI 0x8234 + #define GL_R32I 0x8235 + #define GL_R32UI 0x8236 + #define GL_RG8I 0x8237 + #define GL_RG8UI 0x8238 + #define GL_RG16I 0x8239 + #define GL_RG16UI 0x823A + #define GL_RG32I 0x823B + #define GL_RG32UI 0x823C +#endif + +#ifndef GL_EXT_bindable_uniform + #define GL_UNIFORM_BUFFER_EXT 0x8DEE +#endif + +// unpublished extension enums (thus the "X") + +// from EXT_framebuffer_multisample_blit_scaled.. +#define XGL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define XGL_SCALED_RESOLVE_NICEST_EXT 0x90BB + + +void * NSGLGetProcAddress (const char *name); + +// call this to find all the entry points. +void GLMSetupExtensions( void ); + + + +typedef void (*PFNglColorMaskIndexedEXT)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (*PFNglEnableIndexedEXT)(GLenum target, GLuint index); +typedef void (*PFNglDisableIndexedEXT)(GLenum target, GLuint index); +typedef void (*PFNglUniformBufferEXT)(GLuint program, GLint location, GLuint buffer); + +extern PFNglColorMaskIndexedEXT pfnglColorMaskIndexedEXT; +extern PFNglEnableIndexedEXT pfnglEnableIndexedEXT; +extern PFNglDisableIndexedEXT pfnglDisableIndexedEXT; +extern PFNglUniformBufferEXT pfnglUniformBufferEXT; + + +typedef void (*PFNglGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint *params); +extern PFNglGetFramebufferAttachmentParameteriv pfnglGetFramebufferAttachmentParameteriv; + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/imageformat.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/imageformat.h new file mode 100644 index 0000000..6bf3b51 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/imageformat.h @@ -0,0 +1,523 @@ +//===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +//===========================================================================// + +#ifndef IMAGEFORMAT_H +#define IMAGEFORMAT_H + +#ifdef _WIN32 +#pragma once +#endif + +#include + +enum NormalDecodeMode_t +{ + NORMAL_DECODE_NONE = 0, + NORMAL_DECODE_ATI2N = 1, + NORMAL_DECODE_ATI2N_ALPHA = 2 +}; + +// Forward declaration +#ifdef _WIN32 +typedef enum _D3DFORMAT D3DFORMAT; +#endif + +//----------------------------------------------------------------------------- +// The various image format types +//----------------------------------------------------------------------------- + +// don't bitch that inline functions aren't used!!!! +#pragma warning(disable : 4514) + +enum ImageFormat +{ + IMAGE_FORMAT_UNKNOWN = -1, + IMAGE_FORMAT_RGBA8888 = 0, + IMAGE_FORMAT_ABGR8888, + IMAGE_FORMAT_RGB888, + IMAGE_FORMAT_BGR888, + IMAGE_FORMAT_RGB565, + IMAGE_FORMAT_I8, + IMAGE_FORMAT_IA88, + IMAGE_FORMAT_P8, + IMAGE_FORMAT_A8, + IMAGE_FORMAT_RGB888_BLUESCREEN, + IMAGE_FORMAT_BGR888_BLUESCREEN, + IMAGE_FORMAT_ARGB8888, + IMAGE_FORMAT_BGRA8888, + IMAGE_FORMAT_DXT1, + IMAGE_FORMAT_DXT3, + IMAGE_FORMAT_DXT5, + IMAGE_FORMAT_BGRX8888, + IMAGE_FORMAT_BGR565, + IMAGE_FORMAT_BGRX5551, + IMAGE_FORMAT_BGRA4444, + IMAGE_FORMAT_DXT1_ONEBITALPHA, + IMAGE_FORMAT_BGRA5551, + IMAGE_FORMAT_UV88, + IMAGE_FORMAT_UVWQ8888, + IMAGE_FORMAT_RGBA16161616F, + IMAGE_FORMAT_RGBA16161616, + IMAGE_FORMAT_UVLX8888, + IMAGE_FORMAT_R32F, // Single-channel 32-bit floating point + IMAGE_FORMAT_RGB323232F, + IMAGE_FORMAT_RGBA32323232F, + + // Depth-stencil texture formats for shadow depth mapping + IMAGE_FORMAT_NV_DST16, // + IMAGE_FORMAT_NV_DST24, // + IMAGE_FORMAT_NV_INTZ, // Vendor-specific depth-stencil texture + IMAGE_FORMAT_NV_RAWZ, // formats for shadow depth mapping + IMAGE_FORMAT_ATI_DST16, // + IMAGE_FORMAT_ATI_DST24, // + IMAGE_FORMAT_NV_NULL, // Dummy format which takes no video memory + + // Compressed normal map formats + IMAGE_FORMAT_ATI2N, // One-surface ATI2N / DXN format + IMAGE_FORMAT_ATI1N, // Two-surface ATI1N format + +#if defined( _X360 ) + // Depth-stencil texture formats + IMAGE_FORMAT_X360_DST16, + IMAGE_FORMAT_X360_DST24, + IMAGE_FORMAT_X360_DST24F, + // supporting these specific formats as non-tiled for procedural cpu access + IMAGE_FORMAT_LINEAR_BGRX8888, + IMAGE_FORMAT_LINEAR_RGBA8888, + IMAGE_FORMAT_LINEAR_ABGR8888, + IMAGE_FORMAT_LINEAR_ARGB8888, + IMAGE_FORMAT_LINEAR_BGRA8888, + IMAGE_FORMAT_LINEAR_RGB888, + IMAGE_FORMAT_LINEAR_BGR888, + IMAGE_FORMAT_LINEAR_BGRX5551, + IMAGE_FORMAT_LINEAR_I8, + IMAGE_FORMAT_LINEAR_RGBA16161616, + + IMAGE_FORMAT_LE_BGRX8888, + IMAGE_FORMAT_LE_BGRA8888, +#endif + + NUM_IMAGE_FORMATS +}; + +#if defined( POSIX ) || defined( DX_TO_GL_ABSTRACTION ) +typedef enum _D3DFORMAT + { + D3DFMT_INDEX16, + D3DFMT_D16, + D3DFMT_D24S8, + D3DFMT_A8R8G8B8, + D3DFMT_A4R4G4B4, + D3DFMT_X8R8G8B8, + D3DFMT_R5G6R5, + D3DFMT_X1R5G5B5, + D3DFMT_A1R5G5B5, + D3DFMT_L8, + D3DFMT_A8L8, + D3DFMT_A, + D3DFMT_DXT1, + D3DFMT_DXT3, + D3DFMT_DXT5, + D3DFMT_V8U8, + D3DFMT_Q8W8V8U8, + D3DFMT_X8L8V8U8, + D3DFMT_A16B16G16R16F, + D3DFMT_A16B16G16R16, + D3DFMT_R32F, + D3DFMT_A32B32G32R32F, + D3DFMT_R8G8B8, + D3DFMT_D24X4S4, + D3DFMT_A8, + D3DFMT_R5G6B5, + D3DFMT_D15S1, + D3DFMT_D24X8, + D3DFMT_VERTEXDATA, + D3DFMT_INDEX32, + + // adding fake D3D format names for the vendor specific ones (eases debugging/logging) + + // NV shadow depth tex + D3DFMT_NV_INTZ = 0x5a544e49, // MAKEFOURCC('I','N','T','Z') + D3DFMT_NV_RAWZ = 0x5a574152, // MAKEFOURCC('R','A','W','Z') + + // NV null tex + D3DFMT_NV_NULL = 0x4c4c554e, // MAKEFOURCC('N','U','L','L') + + // ATI shadow depth tex + D3DFMT_ATI_D16 = 0x36314644, // MAKEFOURCC('D','F','1','6') + D3DFMT_ATI_D24S8 = 0x34324644, // MAKEFOURCC('D','F','2','4') + + // ATI 1N and 2N compressed tex + D3DFMT_ATI_2N = 0x32495441, // MAKEFOURCC('A', 'T', 'I', '2') + D3DFMT_ATI_1N = 0x31495441, // MAKEFOURCC('A', 'T', 'I', '1') + + D3DFMT_UNKNOWN + } D3DFORMAT; +#endif + +//----------------------------------------------------------------------------- +// Color structures +//----------------------------------------------------------------------------- + +struct BGRA8888_t +{ + unsigned char b; // change the order of names to change the + unsigned char g; // order of the output ARGB or BGRA, etc... + unsigned char r; // Last one is MSB, 1st is LSB. + unsigned char a; + inline BGRA8888_t& operator=( const BGRA8888_t& in ) + { + *( unsigned int * )this = *( unsigned int * )∈ + return *this; + } +}; + +struct RGBA8888_t +{ + unsigned char r; // change the order of names to change the + unsigned char g; // order of the output ARGB or BGRA, etc... + unsigned char b; // Last one is MSB, 1st is LSB. + unsigned char a; + inline RGBA8888_t& operator=( const BGRA8888_t& in ) + { + r = in.r; + g = in.g; + b = in.b; + a = in.a; + return *this; + } +}; + +struct RGB888_t +{ + unsigned char r; + unsigned char g; + unsigned char b; + inline RGB888_t& operator=( const BGRA8888_t& in ) + { + r = in.r; + g = in.g; + b = in.b; + return *this; + } + inline bool operator==( const RGB888_t& in ) const + { + return ( r == in.r ) && ( g == in.g ) && ( b == in.b ); + } + inline bool operator!=( const RGB888_t& in ) const + { + return ( r != in.r ) || ( g != in.g ) || ( b != in.b ); + } +}; + +struct BGR888_t +{ + unsigned char b; + unsigned char g; + unsigned char r; + inline BGR888_t& operator=( const BGRA8888_t& in ) + { + r = in.r; + g = in.g; + b = in.b; + return *this; + } +}; + +// 360 uses this structure for x86 dxt decoding +#if defined( _X360 ) +#pragma bitfield_order( push, lsb_to_msb ) +#endif +struct BGR565_t +{ + unsigned short b : 5; // order of names changes + unsigned short g : 6; // byte order of output to 32 bit + unsigned short r : 5; + inline BGR565_t& operator=( const BGRA8888_t& in ) + { + r = in.r >> 3; + g = in.g >> 2; + b = in.b >> 3; + return *this; + } + inline BGR565_t &Set( int red, int green, int blue ) + { + r = red >> 3; + g = green >> 2; + b = blue >> 3; + return *this; + } +}; +#if defined( _X360 ) +#pragma bitfield_order( pop ) +#endif + +struct BGRA5551_t +{ + unsigned short b : 5; // order of names changes + unsigned short g : 5; // byte order of output to 32 bit + unsigned short r : 5; + unsigned short a : 1; + inline BGRA5551_t& operator=( const BGRA8888_t& in ) + { + r = in.r >> 3; + g = in.g >> 3; + b = in.b >> 3; + a = in.a >> 7; + return *this; + } +}; + +struct BGRA4444_t +{ + unsigned short b : 4; // order of names changes + unsigned short g : 4; // byte order of output to 32 bit + unsigned short r : 4; + unsigned short a : 4; + inline BGRA4444_t& operator=( const BGRA8888_t& in ) + { + r = in.r >> 4; + g = in.g >> 4; + b = in.b >> 4; + a = in.a >> 4; + return *this; + } +}; + +struct RGBX5551_t +{ + unsigned short r : 5; + unsigned short g : 5; + unsigned short b : 5; + unsigned short x : 1; + inline RGBX5551_t& operator=( const BGRA8888_t& in ) + { + r = in.r >> 3; + g = in.g >> 3; + b = in.b >> 3; + return *this; + } +}; + +//----------------------------------------------------------------------------- +// some important constants +//----------------------------------------------------------------------------- +#define ARTWORK_GAMMA ( 2.2f ) +#define IMAGE_MAX_DIM ( 2048 ) + + +//----------------------------------------------------------------------------- +// information about each image format +//----------------------------------------------------------------------------- +struct ImageFormatInfo_t +{ + char* m_pName; + int m_NumBytes; + int m_NumRedBits; + int m_NumGreeBits; + int m_NumBlueBits; + int m_NumAlphaBits; + bool m_IsCompressed:1; + bool m_IsFloat:1; +}; + + +//----------------------------------------------------------------------------- +// Various methods related to pixelmaps and color formats +//----------------------------------------------------------------------------- +namespace ImageLoader +{ + + bool GetInfo( const char *fileName, int *width, int *height, enum ImageFormat *imageFormat, float *sourceGamma ); + int GetMemRequired( int width, int height, int depth, ImageFormat imageFormat, bool mipmap ); + int GetMipMapLevelByteOffset( int width, int height, enum ImageFormat imageFormat, int skipMipLevels, int nDepth = 1 ); + void GetMipMapLevelDimensions( int *width, int *height, int skipMipLevels ); + int GetNumMipMapLevels( int width, int height, int depth = 1 ); + bool Load( unsigned char *imageData, const char *fileName, int width, int height, enum ImageFormat imageFormat, float targetGamma, bool mipmap ); + bool Load( unsigned char *imageData, FILE *fp, int width, int height, + enum ImageFormat imageFormat, float targetGamma, bool mipmap ); + + // convert from any image format to any other image format. + // return false if the conversion cannot be performed. + // Strides denote the number of bytes per each line, + // by default assumes width * # of bytes per pixel + bool ConvertImageFormat( const unsigned char *src, enum ImageFormat srcImageFormat, + unsigned char *dst, enum ImageFormat dstImageFormat, + int width, int height, int srcStride = 0, int dstStride = 0 ); + + // must be used in conjunction with ConvertImageFormat() to pre-swap and post-swap + void PreConvertSwapImageData( unsigned char *pImageData, int nImageSize, ImageFormat imageFormat, int width = 0, int stride = 0 ); + void PostConvertSwapImageData( unsigned char *pImageData, int nImageSize, ImageFormat imageFormat, int width = 0, int stride = 0 ); + void ByteSwapImageData( unsigned char *pImageData, int nImageSize, ImageFormat imageFormat, int width = 0, int stride = 0 ); + bool IsFormatValidForConversion( ImageFormat fmt ); + + //----------------------------------------------------------------------------- + // convert back and forth from D3D format to ImageFormat, regardless of + // whether it's supported or not + //----------------------------------------------------------------------------- + ImageFormat D3DFormatToImageFormat( D3DFORMAT format ); + D3DFORMAT ImageFormatToD3DFormat( ImageFormat format ); + + // Flags for ResampleRGBA8888 + enum + { + RESAMPLE_NORMALMAP = 0x1, + RESAMPLE_ALPHATEST = 0x2, + RESAMPLE_NICE_FILTER = 0x4, + RESAMPLE_CLAMPS = 0x8, + RESAMPLE_CLAMPT = 0x10, + RESAMPLE_CLAMPU = 0x20, + }; + + struct ResampleInfo_t + { + + ResampleInfo_t() : m_nFlags(0), m_flAlphaThreshhold(0.4f), m_flAlphaHiFreqThreshhold(0.4f), m_nSrcDepth(1), m_nDestDepth(1) + { + m_flColorScale[0] = 1.0f, m_flColorScale[1] = 1.0f, m_flColorScale[2] = 1.0f, m_flColorScale[3] = 1.0f; + m_flColorGoal[0] = 0.0f, m_flColorGoal[1] = 0.0f, m_flColorGoal[2] = 0.0f, m_flColorGoal[3] = 0.0f; + } + + unsigned char *m_pSrc; + unsigned char *m_pDest; + + int m_nSrcWidth; + int m_nSrcHeight; + int m_nSrcDepth; + + int m_nDestWidth; + int m_nDestHeight; + int m_nDestDepth; + + float m_flSrcGamma; + float m_flDestGamma; + + float m_flColorScale[4]; // Color scale factors RGBA + float m_flColorGoal[4]; // Color goal values RGBA DestColor = ColorGoal + scale * (SrcColor - ColorGoal) + + float m_flAlphaThreshhold; + float m_flAlphaHiFreqThreshhold; + + int m_nFlags; + }; + + bool ResampleRGBA8888( const ResampleInfo_t &info ); + bool ResampleRGBA16161616( const ResampleInfo_t &info ); + bool ResampleRGB323232F( const ResampleInfo_t &info ); + + void ConvertNormalMapRGBA8888ToDUDVMapUVLX8888( const unsigned char *src, int width, int height, unsigned char *dst_ ); + void ConvertNormalMapRGBA8888ToDUDVMapUVWQ8888( const unsigned char *src, int width, int height, unsigned char *dst_ ); + void ConvertNormalMapRGBA8888ToDUDVMapUV88( const unsigned char *src, int width, int height, unsigned char *dst_ ); + void ConvertNormalMapARGB8888ToDXT5GA( const unsigned char *src, unsigned char *dst, int width, int height ); + + void ConvertIA88ImageToNormalMapRGBA8888( const unsigned char *src, int width, + int height, unsigned char *dst, + float bumpScale ); + + void NormalizeNormalMapRGBA8888( unsigned char *src, int numTexels ); + + //----------------------------------------------------------------------------- + // Gamma correction + //----------------------------------------------------------------------------- + void GammaCorrectRGBA8888( unsigned char *src, unsigned char* dst, + int width, int height, int depth, float srcGamma, float dstGamma ); + + + //----------------------------------------------------------------------------- + // Makes a gamma table + //----------------------------------------------------------------------------- + void ConstructGammaTable( unsigned char* pTable, float srcGamma, float dstGamma ); + + + //----------------------------------------------------------------------------- + // Gamma corrects using a previously constructed gamma table + //----------------------------------------------------------------------------- + void GammaCorrectRGBA8888( unsigned char* pSrc, unsigned char* pDst, + int width, int height, int depth, unsigned char* pGammaTable ); + + + //----------------------------------------------------------------------------- + // Generates a number of mipmap levels + //----------------------------------------------------------------------------- + void GenerateMipmapLevels( unsigned char* pSrc, unsigned char* pDst, int width, + int height, int depth, ImageFormat imageFormat, float srcGamma, float dstGamma, + int numLevels = 0 ); + + + //----------------------------------------------------------------------------- + // operations on square images (src and dst can be the same) + //----------------------------------------------------------------------------- + bool RotateImageLeft( const unsigned char *src, unsigned char *dst, + int widthHeight, ImageFormat imageFormat ); + bool RotateImage180( const unsigned char *src, unsigned char *dst, + int widthHeight, ImageFormat imageFormat ); + bool FlipImageVertically( void *pSrc, void *pDst, int nWidth, int nHeight, ImageFormat imageFormat, int nDstStride = 0 ); + bool FlipImageHorizontally( void *pSrc, void *pDst, int nWidth, int nHeight, ImageFormat imageFormat, int nDstStride = 0 ); + bool SwapAxes( unsigned char *src, + int widthHeight, ImageFormat imageFormat ); + + + //----------------------------------------------------------------------------- + // Returns info about each image format + //----------------------------------------------------------------------------- + ImageFormatInfo_t const& ImageFormatInfo( ImageFormat fmt ); + + + //----------------------------------------------------------------------------- + // Gets the name of the image format + //----------------------------------------------------------------------------- + inline char const* GetName( ImageFormat fmt ) + { + return ImageFormatInfo(fmt).m_pName; + } + + + //----------------------------------------------------------------------------- + // Gets the size of the image format in bytes + //----------------------------------------------------------------------------- + inline int SizeInBytes( ImageFormat fmt ) + { + return ImageFormatInfo(fmt).m_NumBytes; + } + + //----------------------------------------------------------------------------- + // Does the image format support transparency? + //----------------------------------------------------------------------------- + inline bool IsTransparent( ImageFormat fmt ) + { + return ImageFormatInfo(fmt).m_NumAlphaBits > 0; + } + + + //----------------------------------------------------------------------------- + // Is the image format compressed? + //----------------------------------------------------------------------------- + inline bool IsCompressed( ImageFormat fmt ) + { + return ImageFormatInfo(fmt).m_IsCompressed; + } + + //----------------------------------------------------------------------------- + // Is any channel > 8 bits? + //----------------------------------------------------------------------------- + inline bool HasChannelLargerThan8Bits( ImageFormat fmt ) + { + ImageFormatInfo_t info = ImageFormatInfo(fmt); + return ( info.m_NumRedBits > 8 || info.m_NumGreeBits > 8 || info.m_NumBlueBits > 8 || info.m_NumAlphaBits > 8 ); + } + + inline bool IsFloatFormat( ImageFormat fmt ) + { + return ( fmt == IMAGE_FORMAT_RGBA16161616F ) || + ( fmt == IMAGE_FORMAT_R32F ) || + ( fmt == IMAGE_FORMAT_RGB323232F ) || + ( fmt == IMAGE_FORMAT_RGBA32323232F ); + } + +} // end namespace ImageLoader + + +#endif // IMAGEFORMAT_H diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/mathlite.cpp b/GameGuru Core/SDK/Steamworks SDK/glmgr/mathlite.cpp new file mode 100644 index 0000000..1ec0848 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/mathlite.cpp @@ -0,0 +1,1253 @@ +#include "mathlite.h" + +// ------------------------------------------------------------------------------------------- // +// Helper functions. +// ------------------------------------------------------------------------------------------- // + +const Vector vec3_origin(0,0,0); +const QAngle vec3_angle(0,0,0); +const Quaternion quat_identity(0,0,0,1); +const Vector vec3_invalid( FLT_MAX, FLT_MAX, FLT_MAX ); +const int nanmask = 255<<23; + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +VMatrix SetupMatrixIdentity() +{ + return VMatrix( + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f); +} + +VMatrix SetupMatrixTranslation(const Vector &vTranslation) +{ + return VMatrix( + 1.0f, 0.0f, 0.0f, vTranslation.x, + 0.0f, 1.0f, 0.0f, vTranslation.y, + 0.0f, 0.0f, 1.0f, vTranslation.z, + 0.0f, 0.0f, 0.0f, 1.0f + ); +} + +VMatrix SetupMatrixScale(const Vector &vScale) +{ + return VMatrix( + vScale.x, 0.0f, 0.0f, 0.0f, + 0.0f, vScale.y, 0.0f, 0.0f, + 0.0f, 0.0f, vScale.z, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + ); +} + +VMatrix SetupMatrixReflection(const VPlane &thePlane) +{ + VMatrix mReflect, mBack, mForward; + Vector vOrigin, N; + + N = thePlane.m_Normal; + + mReflect.Init( + -2.0f*N.x*N.x + 1.0f, -2.0f*N.x*N.y, -2.0f*N.x*N.z, 0.0f, + -2.0f*N.y*N.x, -2.0f*N.y*N.y + 1.0f, -2.0f*N.y*N.z, 0.0f, + -2.0f*N.z*N.x, -2.0f*N.z*N.y, -2.0f*N.z*N.z + 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + ); + + vOrigin = thePlane.GetPointOnPlane(); + + mBack.Identity(); + mBack.SetTranslation(-vOrigin); + + mForward.Identity(); + mForward.SetTranslation(vOrigin); + + // (multiplied in reverse order, so it translates to the origin point, + // reflects, and translates back). + return mForward * mReflect * mBack; +} + +VMatrix SetupMatrixProjection(const Vector &vOrigin, const VPlane &thePlane) +{ + vec_t dot; + VMatrix mRet; + + + #define PN thePlane.m_Normal + #define PD thePlane.m_Dist; + + dot = PN[0]*vOrigin.x + PN[1]*vOrigin.y + PN[2]*vOrigin.z - PD; + + mRet.m[0][0] = dot - vOrigin.x * PN[0]; + mRet.m[0][1] = -vOrigin.x * PN[1]; + mRet.m[0][2] = -vOrigin.x * PN[2]; + mRet.m[0][3] = -vOrigin.x * -PD; + + mRet.m[1][0] = -vOrigin.y * PN[0]; + mRet.m[1][1] = dot - vOrigin.y * PN[1]; + mRet.m[1][2] = -vOrigin.y * PN[2]; + mRet.m[1][3] = -vOrigin.y * -PD; + + mRet.m[2][0] = -vOrigin.z * PN[0]; + mRet.m[2][1] = -vOrigin.z * PN[1]; + mRet.m[2][2] = dot - vOrigin.z * PN[2]; + mRet.m[2][3] = -vOrigin.z * -PD; + + mRet.m[3][0] = -PN[0]; + mRet.m[3][1] = -PN[1]; + mRet.m[3][2] = -PN[2]; + mRet.m[3][3] = dot + PD; + + #undef PN + #undef PD + + return mRet; +} + +VMatrix SetupMatrixAxisRot(const Vector &vAxis, vec_t fDegrees) +{ + vec_t s, c, t; + vec_t tx, ty, tz; + vec_t sx, sy, sz; + vec_t fRadians; + + + fRadians = fDegrees * (M_PI / 180.0f); + + s = (vec_t)sin(fRadians); + c = (vec_t)cos(fRadians); + t = 1.0f - c; + + tx = t * vAxis.x; ty = t * vAxis.y; tz = t * vAxis.z; + sx = s * vAxis.x; sy = s * vAxis.y; sz = s * vAxis.z; + + return VMatrix( + tx*vAxis.x + c, tx*vAxis.y - sz, tx*vAxis.z + sy, 0.0f, + tx*vAxis.y + sz, ty*vAxis.y + c, ty*vAxis.z - sx, 0.0f, + tx*vAxis.z - sy, ty*vAxis.z + sx, tz*vAxis.z + c, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f); +} + +VMatrix SetupMatrixAngles(const QAngle &vAngles) +{ + VMatrix mRet; + MatrixFromAngles( vAngles, mRet ); + return mRet; +} + +VMatrix SetupMatrixOrgAngles(const Vector &origin, const QAngle &vAngles) +{ + VMatrix mRet; + mRet.SetupMatrixOrgAngles( origin, vAngles ); + return mRet; +} + +#endif // VECTOR_NO_SLOW_OPERATIONS + + +bool PlaneIntersection( const VPlane &vp1, const VPlane &vp2, const VPlane &vp3, Vector &vOut ) +{ + VMatrix mMat, mInverse; + + mMat.Init( + vp1.m_Normal.x, vp1.m_Normal.y, vp1.m_Normal.z, -vp1.m_Dist, + vp2.m_Normal.x, vp2.m_Normal.y, vp2.m_Normal.z, -vp2.m_Dist, + vp3.m_Normal.x, vp3.m_Normal.y, vp3.m_Normal.z, -vp3.m_Dist, + 0.0f, 0.0f, 0.0f, 1.0f + ); + + if(mMat.InverseGeneral(mInverse)) + { + //vOut = mInverse * Vector(0.0f, 0.0f, 0.0f); + mInverse.GetTranslation( vOut ); + return true; + } + else + { + return false; + } +} + + + +// ------------------------------------------------------------------------------------------- // +// VMatrix functions. +// ------------------------------------------------------------------------------------------- // + +VMatrix& VMatrix::operator=(const VMatrix &mOther) +{ + m[0][0] = mOther.m[0][0]; + m[0][1] = mOther.m[0][1]; + m[0][2] = mOther.m[0][2]; + m[0][3] = mOther.m[0][3]; + + m[1][0] = mOther.m[1][0]; + m[1][1] = mOther.m[1][1]; + m[1][2] = mOther.m[1][2]; + m[1][3] = mOther.m[1][3]; + + m[2][0] = mOther.m[2][0]; + m[2][1] = mOther.m[2][1]; + m[2][2] = mOther.m[2][2]; + m[2][3] = mOther.m[2][3]; + + m[3][0] = mOther.m[3][0]; + m[3][1] = mOther.m[3][1]; + m[3][2] = mOther.m[3][2]; + m[3][3] = mOther.m[3][3]; + + return *this; +} + +bool VMatrix::operator==( const VMatrix& src ) const +{ + return !memcmp( src.m, m, sizeof(m) ); +} + +void VMatrix::MatrixMul( const VMatrix &vm, VMatrix &out ) const +{ + out.Init( + m[0][0]*vm.m[0][0] + m[0][1]*vm.m[1][0] + m[0][2]*vm.m[2][0] + m[0][3]*vm.m[3][0], + m[0][0]*vm.m[0][1] + m[0][1]*vm.m[1][1] + m[0][2]*vm.m[2][1] + m[0][3]*vm.m[3][1], + m[0][0]*vm.m[0][2] + m[0][1]*vm.m[1][2] + m[0][2]*vm.m[2][2] + m[0][3]*vm.m[3][2], + m[0][0]*vm.m[0][3] + m[0][1]*vm.m[1][3] + m[0][2]*vm.m[2][3] + m[0][3]*vm.m[3][3], + + m[1][0]*vm.m[0][0] + m[1][1]*vm.m[1][0] + m[1][2]*vm.m[2][0] + m[1][3]*vm.m[3][0], + m[1][0]*vm.m[0][1] + m[1][1]*vm.m[1][1] + m[1][2]*vm.m[2][1] + m[1][3]*vm.m[3][1], + m[1][0]*vm.m[0][2] + m[1][1]*vm.m[1][2] + m[1][2]*vm.m[2][2] + m[1][3]*vm.m[3][2], + m[1][0]*vm.m[0][3] + m[1][1]*vm.m[1][3] + m[1][2]*vm.m[2][3] + m[1][3]*vm.m[3][3], + + m[2][0]*vm.m[0][0] + m[2][1]*vm.m[1][0] + m[2][2]*vm.m[2][0] + m[2][3]*vm.m[3][0], + m[2][0]*vm.m[0][1] + m[2][1]*vm.m[1][1] + m[2][2]*vm.m[2][1] + m[2][3]*vm.m[3][1], + m[2][0]*vm.m[0][2] + m[2][1]*vm.m[1][2] + m[2][2]*vm.m[2][2] + m[2][3]*vm.m[3][2], + m[2][0]*vm.m[0][3] + m[2][1]*vm.m[1][3] + m[2][2]*vm.m[2][3] + m[2][3]*vm.m[3][3], + + m[3][0]*vm.m[0][0] + m[3][1]*vm.m[1][0] + m[3][2]*vm.m[2][0] + m[3][3]*vm.m[3][0], + m[3][0]*vm.m[0][1] + m[3][1]*vm.m[1][1] + m[3][2]*vm.m[2][1] + m[3][3]*vm.m[3][1], + m[3][0]*vm.m[0][2] + m[3][1]*vm.m[1][2] + m[3][2]*vm.m[2][2] + m[3][3]*vm.m[3][2], + m[3][0]*vm.m[0][3] + m[3][1]*vm.m[1][3] + m[3][2]*vm.m[2][3] + m[3][3]*vm.m[3][3] + ); +} + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +VMatrix VMatrix::operator*(const VMatrix &vm) const +{ + VMatrix ret; + MatrixMul( vm, ret ); + return ret; +} + +#endif + +bool VMatrix::InverseGeneral(VMatrix &vInverse) const +{ + return MatrixInverseGeneral( *this, vInverse ); +} + + +bool MatrixInverseGeneral(const VMatrix& src, VMatrix& dst) +{ + int iRow, i, j, iTemp, iTest; + vec_t mul, fTest, fLargest; + vec_t mat[4][8]; + int rowMap[4], iLargest; + vec_t *pOut, *pRow, *pScaleRow; + + + // How it's done. + // AX = I + // A = this + // X = the matrix we're looking for + // I = identity + + // Setup AI + for(i=0; i < 4; i++) + { + const vec_t *pIn = src[i]; + pOut = mat[i]; + + for(j=0; j < 4; j++) + { + pOut[j] = pIn[j]; + } + + pOut[4] = 0.0f; + pOut[5] = 0.0f; + pOut[6] = 0.0f; + pOut[7] = 0.0f; + pOut[i+4] = 1.0f; + + rowMap[i] = i; + } + + // Use row operations to get to reduced row-echelon form using these rules: + // 1. Multiply or divide a row by a nonzero number. + // 2. Add a multiple of one row to another. + // 3. Interchange two rows. + + for(iRow=0; iRow < 4; iRow++) + { + // Find the row with the largest element in this column. + fLargest = 0.001f; + iLargest = -1; + for(iTest=iRow; iTest < 4; iTest++) + { + fTest = (vec_t)FloatMakePositive(mat[rowMap[iTest]][iRow]); + if(fTest > fLargest) + { + iLargest = iTest; + fLargest = fTest; + } + } + + // They're all too small.. sorry. + if(iLargest == -1) + { + return false; + } + + // Swap the rows. + iTemp = rowMap[iLargest]; + rowMap[iLargest] = rowMap[iRow]; + rowMap[iRow] = iTemp; + + pRow = mat[rowMap[iRow]]; + + // Divide this row by the element. + mul = 1.0f / pRow[iRow]; + for(j=0; j < 8; j++) + pRow[j] *= mul; + + pRow[iRow] = 1.0f; // Preserve accuracy... + + // Eliminate this element from the other rows using operation 2. + for(i=0; i < 4; i++) + { + if(i == iRow) + continue; + + pScaleRow = mat[rowMap[i]]; + + // Multiply this row by -(iRow*the element). + mul = -pScaleRow[iRow]; + for(j=0; j < 8; j++) + { + pScaleRow[j] += pRow[j] * mul; + } + + pScaleRow[iRow] = 0.0f; // Preserve accuracy... + } + } + + // The inverse is on the right side of AX now (the identity is on the left). + for(i=0; i < 4; i++) + { + const vec_t *pIn = mat[rowMap[i]] + 4; + pOut = dst.m[i]; + + for(j=0; j < 4; j++) + { + pOut[j] = pIn[j]; + } + } + + return true; +} + + +//----------------------------------------------------------------------------- +// Does a fast inverse, assuming the matrix only contains translation and rotation. +//----------------------------------------------------------------------------- +void MatrixInverseTR( const VMatrix& src, VMatrix &dst ) +{ + Vector vTrans, vNewTrans; + + // Transpose the upper 3x3. + dst.m[0][0] = src.m[0][0]; dst.m[0][1] = src.m[1][0]; dst.m[0][2] = src.m[2][0]; + dst.m[1][0] = src.m[0][1]; dst.m[1][1] = src.m[1][1]; dst.m[1][2] = src.m[2][1]; + dst.m[2][0] = src.m[0][2]; dst.m[2][1] = src.m[1][2]; dst.m[2][2] = src.m[2][2]; + + // Transform the translation. + vTrans.Init( -src.m[0][3], -src.m[1][3], -src.m[2][3] ); + Vector3DMultiply( dst, vTrans, vNewTrans ); + MatrixSetColumn( dst, 3, vNewTrans ); + + // Fill in the bottom row. + dst.m[3][0] = dst.m[3][1] = dst.m[3][2] = 0.0f; + dst.m[3][3] = 1.0f; +} + + +void VMatrix::InverseTR( VMatrix &ret ) const +{ + MatrixInverseTR( *this, ret ); +} + +void MatrixInverseTranspose( const VMatrix& src, VMatrix& dst ) +{ + src.InverseGeneral( dst ); + MatrixTranspose( dst, dst ); +} + +//----------------------------------------------------------------------------- +// Computes the inverse transpose +//----------------------------------------------------------------------------- +void MatrixInverseTranspose( const matrix3x4_t& src, matrix3x4_t& dst ) +{ + VMatrix tmp, out; + tmp.CopyFrom3x4( src ); + ::MatrixInverseTranspose( tmp, out ); + out.Set3x4( dst ); +} + + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +VMatrix VMatrix::InverseTR() const +{ + VMatrix ret; + MatrixInverseTR( *this, ret ); + return ret; +} + +Vector VMatrix::GetScale() const +{ + Vector vecs[3]; + + GetBasisVectors(vecs[0], vecs[1], vecs[2]); + + return Vector( + vecs[0].Length(), + vecs[1].Length(), + vecs[2].Length() + ); +} + +VMatrix VMatrix::Scale(const Vector &vScale) +{ + return VMatrix( + m[0][0]*vScale.x, m[0][1]*vScale.y, m[0][2]*vScale.z, m[0][3], + m[1][0]*vScale.x, m[1][1]*vScale.y, m[1][2]*vScale.z, m[1][3], + m[2][0]*vScale.x, m[2][1]*vScale.y, m[2][2]*vScale.z, m[2][3], + m[3][0]*vScale.x, m[3][1]*vScale.y, m[3][2]*vScale.z, 1.0f + ); +} + +#if 0 + VMatrix VMatrix::NormalizeBasisVectors() const + { + Vector vecs[3]; + VMatrix mRet; + + + GetBasisVectors(vecs[0], vecs[1], vecs[2]); + + VectorNormalize( vecs[0] ); + VectorNormalize( vecs[1] ); + VectorNormalize( vecs[2] ); + + mRet.SetBasisVectors(vecs[0], vecs[1], vecs[2]); + + // Set everything but basis vectors to identity. + mRet.m[3][0] = mRet.m[3][1] = mRet.m[3][2] = 0.0f; + mRet.m[3][3] = 1.0f; + + return mRet; + } +#endif + +VMatrix VMatrix::Transpose() const +{ + return VMatrix( + m[0][0], m[1][0], m[2][0], m[3][0], + m[0][1], m[1][1], m[2][1], m[3][1], + m[0][2], m[1][2], m[2][2], m[3][2], + m[0][3], m[1][3], m[2][3], m[3][3]); +} + +// Transpose upper-left 3x3. +VMatrix VMatrix::Transpose3x3() const +{ + return VMatrix( + m[0][0], m[1][0], m[2][0], m[0][3], + m[0][1], m[1][1], m[2][1], m[1][3], + m[0][2], m[1][2], m[2][2], m[2][3], + m[3][0], m[3][1], m[3][2], m[3][3]); +} + +#endif // VECTOR_NO_SLOW_OPERATIONS + + +bool VMatrix::IsRotationMatrix() const +{ + Vector &v1 = (Vector&)m[0][0]; + Vector &v2 = (Vector&)m[1][0]; + Vector &v3 = (Vector&)m[2][0]; + + return + FloatMakePositive( 1 - v1.Length() ) < 0.01f && + FloatMakePositive( 1 - v2.Length() ) < 0.01f && + FloatMakePositive( 1 - v3.Length() ) < 0.01f && + FloatMakePositive( v1.Dot(v2) ) < 0.01f && + FloatMakePositive( v1.Dot(v3) ) < 0.01f && + FloatMakePositive( v2.Dot(v3) ) < 0.01f; +} + +void VMatrix::SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ) +{ + float sr, sp, sy, cr, cp, cy; + + SinCos( DEG2RAD( vAngles[YAW] ), &sy, &cy ); + SinCos( DEG2RAD( vAngles[PITCH] ), &sp, &cp ); + SinCos( DEG2RAD( vAngles[ROLL] ), &sr, &cr ); + + // matrix = (YAW * PITCH) * ROLL + m[0][0] = cp*cy; + m[1][0] = cp*sy; + m[2][0] = -sp; + m[0][1] = sr*sp*cy+cr*-sy; + m[1][1] = sr*sp*sy+cr*cy; + m[2][1] = sr*cp; + m[0][2] = (cr*sp*cy+-sr*-sy); + m[1][2] = (cr*sp*sy+-sr*cy); + m[2][2] = cr*cp; + m[0][3] = 0.f; + m[1][3] = 0.f; + m[2][3] = 0.f; + + // Add translation + m[0][3] = origin.x; + m[1][3] = origin.y; + m[2][3] = origin.z; + m[3][0] = 0.0f; + m[3][1] = 0.0f; + m[3][2] = 0.0f; + m[3][3] = 1.0f; +} + + +//----------------------------------------------------------------------------- +// Sets matrix to identity +//----------------------------------------------------------------------------- +void MatrixSetIdentity( VMatrix &dst ) +{ + dst[0][0] = 1.0f; dst[0][1] = 0.0f; dst[0][2] = 0.0f; dst[0][3] = 0.0f; + dst[1][0] = 0.0f; dst[1][1] = 1.0f; dst[1][2] = 0.0f; dst[1][3] = 0.0f; + dst[2][0] = 0.0f; dst[2][1] = 0.0f; dst[2][2] = 1.0f; dst[2][3] = 0.0f; + dst[3][0] = 0.0f; dst[3][1] = 0.0f; dst[3][2] = 0.0f; dst[3][3] = 1.0f; +} + + +//----------------------------------------------------------------------------- +// Setup a matrix from euler angles. +//----------------------------------------------------------------------------- +void MatrixFromAngles( const QAngle& vAngles, VMatrix& dst ) +{ + dst.SetupMatrixOrgAngles( vec3_origin, vAngles ); +} + + +//----------------------------------------------------------------------------- +// Creates euler angles from a matrix +//----------------------------------------------------------------------------- +void MatrixToAngles( const VMatrix& src, QAngle& vAngles ) +{ + float forward[3]; + float left[3]; + float up[3]; + + // Extract the basis vectors from the matrix. Since we only need the Z + // component of the up vector, we don't get X and Y. + forward[0] = src[0][0]; + forward[1] = src[1][0]; + forward[2] = src[2][0]; + left[0] = src[0][1]; + left[1] = src[1][1]; + left[2] = src[2][1]; + up[2] = src[2][2]; + + float xyDist = sqrtf( forward[0] * forward[0] + forward[1] * forward[1] ); + + // enough here to get angles? + if ( xyDist > 0.001f ) + { + // (yaw) y = ATAN( forward.y, forward.x ); -- in our space, forward is the X axis + vAngles[1] = RAD2DEG( atan2f( forward[1], forward[0] ) ); + + // The engine does pitch inverted from this, but we always end up negating it in the DLL + // UNDONE: Fix the engine to make it consistent + // (pitch) x = ATAN( -forward.z, sqrt(forward.x*forward.x+forward.y*forward.y) ); + vAngles[0] = RAD2DEG( atan2f( -forward[2], xyDist ) ); + + // (roll) z = ATAN( left.z, up.z ); + vAngles[2] = RAD2DEG( atan2f( left[2], up[2] ) ); + } + else // forward is mostly Z, gimbal lock- + { + // (yaw) y = ATAN( -left.x, left.y ); -- forward is mostly z, so use right for yaw + vAngles[1] = RAD2DEG( atan2f( -left[0], left[1] ) ); + + // The engine does pitch inverted from this, but we always end up negating it in the DLL + // UNDONE: Fix the engine to make it consistent + // (pitch) x = ATAN( -forward.z, sqrt(forward.x*forward.x+forward.y*forward.y) ); + vAngles[0] = RAD2DEG( atan2f( -forward[2], xyDist ) ); + + // Assume no roll in this case as one degree of freedom has been lost (i.e. yaw == roll) + vAngles[2] = 0; + } +} + + +//----------------------------------------------------------------------------- +// Transpose +//----------------------------------------------------------------------------- +inline void Swap( float& a, float& b ) +{ + float tmp = a; + a = b; + b = tmp; +} + +void MatrixTranspose( const VMatrix& src, VMatrix& dst ) +{ + if (&src == &dst) + { + Swap( dst[0][1], dst[1][0] ); + Swap( dst[0][2], dst[2][0] ); + Swap( dst[0][3], dst[3][0] ); + Swap( dst[1][2], dst[2][1] ); + Swap( dst[1][3], dst[3][1] ); + Swap( dst[2][3], dst[3][2] ); + } + else + { + dst[0][0] = src[0][0]; dst[0][1] = src[1][0]; dst[0][2] = src[2][0]; dst[0][3] = src[3][0]; + dst[1][0] = src[0][1]; dst[1][1] = src[1][1]; dst[1][2] = src[2][1]; dst[1][3] = src[3][1]; + dst[2][0] = src[0][2]; dst[2][1] = src[1][2]; dst[2][2] = src[2][2]; dst[2][3] = src[3][2]; + dst[3][0] = src[0][3]; dst[3][1] = src[1][3]; dst[3][2] = src[2][3]; dst[3][3] = src[3][3]; + } +} + + +//----------------------------------------------------------------------------- +// Matrix copy +//----------------------------------------------------------------------------- + +void MatrixCopy( const VMatrix& src, VMatrix& dst ) +{ + if (&src != &dst) + { + memcpy( dst.m, src.m, 16 * sizeof(float) ); + } +} + +//----------------------------------------------------------------------------- +// Matrix multiply +//----------------------------------------------------------------------------- +typedef float VMatrixRaw_t[4]; + +void MatrixMultiply( const VMatrix& src1, const VMatrix& src2, VMatrix& dst ) +{ + // Make sure it works if src1 == dst or src2 == dst + VMatrix tmp1, tmp2; + const VMatrixRaw_t* s1 = (&src1 == &dst) ? tmp1.m : src1.m; + const VMatrixRaw_t* s2 = (&src2 == &dst) ? tmp2.m : src2.m; + + if (&src1 == &dst) + { + MatrixCopy( src1, tmp1 ); + } + if (&src2 == &dst) + { + MatrixCopy( src2, tmp2 ); + } + + dst[0][0] = s1[0][0] * s2[0][0] + s1[0][1] * s2[1][0] + s1[0][2] * s2[2][0] + s1[0][3] * s2[3][0]; + dst[0][1] = s1[0][0] * s2[0][1] + s1[0][1] * s2[1][1] + s1[0][2] * s2[2][1] + s1[0][3] * s2[3][1]; + dst[0][2] = s1[0][0] * s2[0][2] + s1[0][1] * s2[1][2] + s1[0][2] * s2[2][2] + s1[0][3] * s2[3][2]; + dst[0][3] = s1[0][0] * s2[0][3] + s1[0][1] * s2[1][3] + s1[0][2] * s2[2][3] + s1[0][3] * s2[3][3]; + + dst[1][0] = s1[1][0] * s2[0][0] + s1[1][1] * s2[1][0] + s1[1][2] * s2[2][0] + s1[1][3] * s2[3][0]; + dst[1][1] = s1[1][0] * s2[0][1] + s1[1][1] * s2[1][1] + s1[1][2] * s2[2][1] + s1[1][3] * s2[3][1]; + dst[1][2] = s1[1][0] * s2[0][2] + s1[1][1] * s2[1][2] + s1[1][2] * s2[2][2] + s1[1][3] * s2[3][2]; + dst[1][3] = s1[1][0] * s2[0][3] + s1[1][1] * s2[1][3] + s1[1][2] * s2[2][3] + s1[1][3] * s2[3][3]; + + dst[2][0] = s1[2][0] * s2[0][0] + s1[2][1] * s2[1][0] + s1[2][2] * s2[2][0] + s1[2][3] * s2[3][0]; + dst[2][1] = s1[2][0] * s2[0][1] + s1[2][1] * s2[1][1] + s1[2][2] * s2[2][1] + s1[2][3] * s2[3][1]; + dst[2][2] = s1[2][0] * s2[0][2] + s1[2][1] * s2[1][2] + s1[2][2] * s2[2][2] + s1[2][3] * s2[3][2]; + dst[2][3] = s1[2][0] * s2[0][3] + s1[2][1] * s2[1][3] + s1[2][2] * s2[2][3] + s1[2][3] * s2[3][3]; + + dst[3][0] = s1[3][0] * s2[0][0] + s1[3][1] * s2[1][0] + s1[3][2] * s2[2][0] + s1[3][3] * s2[3][0]; + dst[3][1] = s1[3][0] * s2[0][1] + s1[3][1] * s2[1][1] + s1[3][2] * s2[2][1] + s1[3][3] * s2[3][1]; + dst[3][2] = s1[3][0] * s2[0][2] + s1[3][1] * s2[1][2] + s1[3][2] * s2[2][2] + s1[3][3] * s2[3][2]; + dst[3][3] = s1[3][0] * s2[0][3] + s1[3][1] * s2[1][3] + s1[3][2] * s2[2][3] + s1[3][3] * s2[3][3]; +} + +//----------------------------------------------------------------------------- +// Matrix/vector multiply +//----------------------------------------------------------------------------- + +void Vector4DMultiply( const VMatrix& src1, Vector4D const& src2, Vector4D& dst ) +{ + // Make sure it works if src2 == dst + Vector4D tmp; + Vector4D const&v = (&src2 == &dst) ? tmp : src2; + + if (&src2 == &dst) + { + Vector4DCopy( src2, tmp ); + } + + dst[0] = src1[0][0] * v[0] + src1[0][1] * v[1] + src1[0][2] * v[2] + src1[0][3] * v[3]; + dst[1] = src1[1][0] * v[0] + src1[1][1] * v[1] + src1[1][2] * v[2] + src1[1][3] * v[3]; + dst[2] = src1[2][0] * v[0] + src1[2][1] * v[1] + src1[2][2] * v[2] + src1[2][3] * v[3]; + dst[3] = src1[3][0] * v[0] + src1[3][1] * v[1] + src1[3][2] * v[2] + src1[3][3] * v[3]; +} + +//----------------------------------------------------------------------------- +// Matrix/vector multiply +//----------------------------------------------------------------------------- + +void Vector4DMultiplyPosition( const VMatrix& src1, Vector const& src2, Vector4D& dst ) +{ + // Make sure it works if src2 == dst + Vector tmp; + Vector const&v = ( &src2 == &dst.AsVector3D() ) ? tmp : src2; + + if (&src2 == &dst.AsVector3D()) + { + VectorCopy( src2, tmp ); + } + + dst[0] = src1[0][0] * v[0] + src1[0][1] * v[1] + src1[0][2] * v[2] + src1[0][3]; + dst[1] = src1[1][0] * v[0] + src1[1][1] * v[1] + src1[1][2] * v[2] + src1[1][3]; + dst[2] = src1[2][0] * v[0] + src1[2][1] * v[1] + src1[2][2] * v[2] + src1[2][3]; + dst[3] = src1[3][0] * v[0] + src1[3][1] * v[1] + src1[3][2] * v[2] + src1[3][3]; +} + + + +//----------------------------------------------------------------------------- +// Matrix/vector multiply +//----------------------------------------------------------------------------- + +void Vector3DMultiply( const VMatrix &src1, const Vector &src2, Vector &dst ) +{ + // Make sure it works if src2 == dst + Vector tmp; + const Vector &v = (&src2 == &dst) ? tmp : src2; + + if( &src2 == &dst ) + { + VectorCopy( src2, tmp ); + } + + dst[0] = src1[0][0] * v[0] + src1[0][1] * v[1] + src1[0][2] * v[2]; + dst[1] = src1[1][0] * v[0] + src1[1][1] * v[1] + src1[1][2] * v[2]; + dst[2] = src1[2][0] * v[0] + src1[2][1] * v[1] + src1[2][2] * v[2]; +} + + +//----------------------------------------------------------------------------- +// Vector3DMultiplyPositionProjective treats src2 as if it's a point +// and does the perspective divide at the end +//----------------------------------------------------------------------------- +void Vector3DMultiplyPositionProjective( const VMatrix& src1, const Vector &src2, Vector& dst ) +{ + // Make sure it works if src2 == dst + Vector tmp; + const Vector &v = (&src2 == &dst) ? tmp: src2; + if( &src2 == &dst ) + { + VectorCopy( src2, tmp ); + } + + float w = src1[3][0] * v[0] + src1[3][1] * v[1] + src1[3][2] * v[2] + src1[3][3]; + if ( w != 0.0f ) + { + w = 1.0f / w; + } + + dst[0] = src1[0][0] * v[0] + src1[0][1] * v[1] + src1[0][2] * v[2] + src1[0][3]; + dst[1] = src1[1][0] * v[0] + src1[1][1] * v[1] + src1[1][2] * v[2] + src1[1][3]; + dst[2] = src1[2][0] * v[0] + src1[2][1] * v[1] + src1[2][2] * v[2] + src1[2][3]; + dst *= w; +} + + +//----------------------------------------------------------------------------- +// Vector3DMultiplyProjective treats src2 as if it's a direction +// and does the perspective divide at the end +//----------------------------------------------------------------------------- +void Vector3DMultiplyProjective( const VMatrix& src1, const Vector &src2, Vector& dst ) +{ + // Make sure it works if src2 == dst + Vector tmp; + const Vector &v = (&src2 == &dst) ? tmp : src2; + if( &src2 == &dst ) + { + VectorCopy( src2, tmp ); + } + + float w; + dst[0] = src1[0][0] * v[0] + src1[0][1] * v[1] + src1[0][2] * v[2]; + dst[1] = src1[1][0] * v[0] + src1[1][1] * v[1] + src1[1][2] * v[2]; + dst[2] = src1[2][0] * v[0] + src1[2][1] * v[1] + src1[2][2] * v[2]; + w = src1[3][0] * v[0] + src1[3][1] * v[1] + src1[3][2] * v[2]; + if (w != 0.0f) + { + dst /= w; + } + else + { + dst = vec3_origin; + } +} + + +//----------------------------------------------------------------------------- +// Multiplies the vector by the transpose of the matrix +//----------------------------------------------------------------------------- +void Vector4DMultiplyTranspose( const VMatrix& src1, Vector4D const& src2, Vector4D& dst ) +{ + // Make sure it works if src2 == dst + bool srcEqualsDst = (&src2 == &dst); + + Vector4D tmp; + Vector4D const&v = srcEqualsDst ? tmp : src2; + + if (srcEqualsDst) + { + Vector4DCopy( src2, tmp ); + } + + dst[0] = src1[0][0] * v[0] + src1[1][0] * v[1] + src1[2][0] * v[2] + src1[3][0] * v[3]; + dst[1] = src1[0][1] * v[0] + src1[1][1] * v[1] + src1[2][1] * v[2] + src1[3][1] * v[3]; + dst[2] = src1[0][2] * v[0] + src1[1][2] * v[1] + src1[2][2] * v[2] + src1[3][2] * v[3]; + dst[3] = src1[0][3] * v[0] + src1[1][3] * v[1] + src1[2][3] * v[2] + src1[3][3] * v[3]; +} + +//----------------------------------------------------------------------------- +// Multiplies the vector by the transpose of the matrix +//----------------------------------------------------------------------------- +void Vector3DMultiplyTranspose( const VMatrix& src1, const Vector& src2, Vector& dst ) +{ + // Make sure it works if src2 == dst + bool srcEqualsDst = (&src2 == &dst); + + Vector tmp; + const Vector&v = srcEqualsDst ? tmp : src2; + + if (srcEqualsDst) + { + VectorCopy( src2, tmp ); + } + + dst[0] = src1[0][0] * v[0] + src1[1][0] * v[1] + src1[2][0] * v[2]; + dst[1] = src1[0][1] * v[0] + src1[1][1] * v[1] + src1[2][1] * v[2]; + dst[2] = src1[0][2] * v[0] + src1[1][2] * v[1] + src1[2][2] * v[2]; +} + + +#if 0 +//----------------------------------------------------------------------------- +// Transform a plane +//----------------------------------------------------------------------------- +void MatrixTransformPlane( const VMatrix &src, const cplane_t &inPlane, cplane_t &outPlane ) +{ + // What we want to do is the following: + // 1) transform the normal into the new space. + // 2) Determine a point on the old plane given by plane dist * plane normal + // 3) Transform that point into the new space + // 4) Plane dist = DotProduct( new normal, new point ) + + // An optimized version, which works if the plane is orthogonal. + // 1) Transform the normal into the new space + // 2) Realize that transforming the old plane point into the new space + // is given by [ d * n'x + Tx, d * n'y + Ty, d * n'z + Tz ] + // where d = old plane dist, n' = transformed normal, Tn = translational component of transform + // 3) Compute the new plane dist using the dot product of the normal result of #2 + + // For a correct result, this should be an inverse-transpose matrix + // but that only matters if there are nonuniform scale or skew factors in this matrix. + Vector vTrans; + Vector3DMultiply( src, inPlane.normal, outPlane.normal ); + outPlane.dist = inPlane.dist * DotProduct( outPlane.normal, outPlane.normal ); + outPlane.dist += DotProduct( outPlane.normal, src.GetTranslation(vTrans) ); +} +#endif + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +VPlane VMatrix::operator*(const VPlane &thePlane) const +{ + VPlane ret; + TransformPlane( thePlane, ret ); + return ret; +} + +#endif + + +//----------------------------------------------------------------------------- +// Builds a rotation matrix that rotates one direction vector into another +//----------------------------------------------------------------------------- +void MatrixBuildTranslation( VMatrix& dst, float x, float y, float z ) +{ + MatrixSetIdentity( dst ); + dst[0][3] = x; + dst[1][3] = y; + dst[2][3] = z; +} + +void MatrixBuildTranslation( VMatrix& dst, const Vector &translation ) +{ + MatrixSetIdentity( dst ); + dst[0][3] = translation[0]; + dst[1][3] = translation[1]; + dst[2][3] = translation[2]; +} + + +//----------------------------------------------------------------------------- +// Purpose: Builds the matrix for a counterclockwise rotation about an arbitrary axis. +// +// | ax2 + (1 - ax2)cosQ axay(1 - cosQ) - azsinQ azax(1 - cosQ) + aysinQ | +// Ra(Q) = | axay(1 - cosQ) + azsinQ ay2 + (1 - ay2)cosQ ayaz(1 - cosQ) - axsinQ | +// | azax(1 - cosQ) - aysinQ ayaz(1 - cosQ) + axsinQ az2 + (1 - az2)cosQ | +// +// Input : mat - +// vAxisOrRot - +// angle - +//----------------------------------------------------------------------------- +#if 0 +void MatrixBuildRotationAboutAxis( VMatrix &dst, const Vector &vAxisOfRot, float angleDegrees ) +{ + MatrixBuildRotationAboutAxis( vAxisOfRot, angleDegrees, dst.As3x4() ); + dst[3][0] = 0; + dst[3][1] = 0; + dst[3][2] = 0; + dst[3][3] = 1; +} +#endif + + +#if 0 +//----------------------------------------------------------------------------- +// Builds a rotation matrix that rotates one direction vector into another +//----------------------------------------------------------------------------- +void MatrixBuildRotation( VMatrix &dst, const Vector& initialDirection, const Vector& finalDirection ) +{ + float angle = DotProduct( initialDirection, finalDirection ); + Assert( IsFinite(angle) ); + + Vector axis; + + // No rotation required + if (angle - 1.0 > -1e-3) + { + // parallel case + MatrixSetIdentity(dst); + return; + } + else if (angle + 1.0 < 1e-3) + { + // antiparallel case, pick any axis in the plane + // perpendicular to the final direction. Choose the direction (x,y,z) + // which has the minimum component of the final direction, use that + // as an initial guess, then subtract out the component which is + // parallel to the final direction + int idx = 0; + if (FloatMakePositive(finalDirection[1]) < FloatMakePositive(finalDirection[idx])) + idx = 1; + if (FloatMakePositive(finalDirection[2]) < FloatMakePositive(finalDirection[idx])) + idx = 2; + + axis.Init( 0, 0, 0 ); + axis[idx] = 1.0f; + VectorMA( axis, -DotProduct( axis, finalDirection ), finalDirection, axis ); + VectorNormalize(axis); + angle = 180.0f; + } + else + { + CrossProduct( initialDirection, finalDirection, axis ); + VectorNormalize( axis ); + angle = acos(angle) * 180 / M_PI; + } + + MatrixBuildRotationAboutAxis( dst, axis, angle ); + +#ifdef _DEBUG + Vector test; + Vector3DMultiply( dst, initialDirection, test ); + test -= finalDirection; + Assert( test.LengthSqr() < 1e-3 ); +#endif +} +#endif + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void MatrixBuildRotateZ( VMatrix &dst, float angleDegrees ) +{ + float radians = angleDegrees * ( M_PI / 180.0f ); + + float fSin = ( float )sin( radians ); + float fCos = ( float )cos( radians ); + + dst[0][0] = fCos; dst[0][1] = -fSin; dst[0][2] = 0.0f; dst[0][3] = 0.0f; + dst[1][0] = fSin; dst[1][1] = fCos; dst[1][2] = 0.0f; dst[1][3] = 0.0f; + dst[2][0] = 0.0f; dst[2][1] = 0.0f; dst[2][2] = 1.0f; dst[2][3] = 0.0f; + dst[3][0] = 0.0f; dst[3][1] = 0.0f; dst[3][2] = 0.0f; dst[3][3] = 1.0f; +} + +// Builds a scale matrix +void MatrixBuildScale( VMatrix &dst, float x, float y, float z ) +{ + dst[0][0] = x; dst[0][1] = 0.0f; dst[0][2] = 0.0f; dst[0][3] = 0.0f; + dst[1][0] = 0.0f; dst[1][1] = y; dst[1][2] = 0.0f; dst[1][3] = 0.0f; + dst[2][0] = 0.0f; dst[2][1] = 0.0f; dst[2][2] = z; dst[2][3] = 0.0f; + dst[3][0] = 0.0f; dst[3][1] = 0.0f; dst[3][2] = 0.0f; dst[3][3] = 1.0f; +} + +void MatrixBuildScale( VMatrix &dst, const Vector& scale ) +{ + MatrixBuildScale( dst, scale.x, scale.y, scale.z ); +} + +void MatrixBuildPerspective( VMatrix &dst, float fovX, float fovY, float zNear, float zFar ) +{ + // FIXME: collapse all of this into one matrix after we figure out what all should be in here. + float width = 2 * zNear * tan( fovX * ( M_PI/180.0f ) * 0.5f ); + float height = 2 * zNear * tan( fovY * ( M_PI/180.0f ) * 0.5f ); + + memset( dst.Base(), 0, sizeof( dst ) ); + dst[0][0] = 2.0F * zNear / width; + dst[1][1] = 2.0F * zNear / height; + dst[2][2] = -zFar / ( zNear - zFar ); + dst[3][2] = 1.0f; + dst[2][3] = zNear * zFar / ( zNear - zFar ); + + // negate X and Y so that X points right, and Y points up. + VMatrix negateXY; + negateXY.Identity(); + negateXY[0][0] = -1.0f; + negateXY[1][1] = -1.0f; + MatrixMultiply( negateXY, dst, dst ); + + VMatrix addW; + addW.Identity(); + addW[0][3] = 1.0f; + addW[1][3] = 1.0f; + addW[2][3] = 0.0f; + MatrixMultiply( addW, dst, dst ); + + VMatrix scaleHalf; + scaleHalf.Identity(); + scaleHalf[0][0] = 0.5f; + scaleHalf[1][1] = 0.5f; + MatrixMultiply( scaleHalf, dst, dst ); +} +#if 0 +static inline void CalculateAABBForNormalizedFrustum_Helper( float x, float y, float z, const VMatrix &volumeToWorld, Vector &mins, Vector &maxs ) +{ + Vector volumeSpacePos( x, y, z ); + + // Make sure it's been clipped + Assert( volumeSpacePos[0] >= -1e-3f ); + Assert( volumeSpacePos[0] - 1.0f <= 1e-3f ); + Assert( volumeSpacePos[1] >= -1e-3f ); + Assert( volumeSpacePos[1] - 1.0f <= 1e-3f ); + Assert( volumeSpacePos[2] >= -1e-3f ); + Assert( volumeSpacePos[2] - 1.0f <= 1e-3f ); + + Vector worldPos; + Vector3DMultiplyPositionProjective( volumeToWorld, volumeSpacePos, worldPos ); + AddPointToBounds( worldPos, mins, maxs ); +} +//----------------------------------------------------------------------------- +// Given an inverse projection matrix, take the extremes of the space in transformed into world space and +// get a bounding box. +//----------------------------------------------------------------------------- +void CalculateAABBFromProjectionMatrixInverse( const VMatrix &volumeToWorld, Vector *pMins, Vector *pMaxs ) +{ + // FIXME: Could maybe do better than the compile with all of these multiplies by 0 and 1. + ClearBounds( *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 0, 0, 0, volumeToWorld, *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 0, 0, 1, volumeToWorld, *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 0, 1, 0, volumeToWorld, *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 0, 1, 1, volumeToWorld, *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 1, 0, 0, volumeToWorld, *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 1, 0, 1, volumeToWorld, *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 1, 1, 0, volumeToWorld, *pMins, *pMaxs ); + CalculateAABBForNormalizedFrustum_Helper( 1, 1, 1, volumeToWorld, *pMins, *pMaxs ); +} + +void CalculateAABBFromProjectionMatrix( const VMatrix &worldToVolume, Vector *pMins, Vector *pMaxs ) +{ + VMatrix volumeToWorld; + MatrixInverseGeneral( worldToVolume, volumeToWorld ); + CalculateAABBFromProjectionMatrixInverse( volumeToWorld, pMins, pMaxs ); +} + +#endif + +#if 0 +//----------------------------------------------------------------------------- +// Given an inverse projection matrix, take the extremes of the space in transformed into world space and +// get a bounding sphere. +//----------------------------------------------------------------------------- +void CalculateSphereFromProjectionMatrixInverse( const VMatrix &volumeToWorld, Vector *pCenter, float *pflRadius ) +{ + // FIXME: Could maybe do better than the compile with all of these multiplies by 0 and 1. + + // Need 3 points: the endpoint of the line through the center of the near + far planes, + // and one point on the far plane. From that, we can derive a point somewhere on the center line + // which would produce the smallest bounding sphere. + Vector vecCenterNear, vecCenterFar, vecNearEdge, vecFarEdge; + Vector3DMultiplyPositionProjective( volumeToWorld, Vector( 0.5f, 0.5f, 0.0f ), vecCenterNear ); + Vector3DMultiplyPositionProjective( volumeToWorld, Vector( 0.5f, 0.5f, 1.0f ), vecCenterFar ); + Vector3DMultiplyPositionProjective( volumeToWorld, Vector( 0.0f, 0.0f, 0.0f ), vecNearEdge ); + Vector3DMultiplyPositionProjective( volumeToWorld, Vector( 0.0f, 0.0f, 1.0f ), vecFarEdge ); + + // Let the distance between the near + far center points = l + // Let the distance between the near center point + near edge point = h1 + // Let the distance between the far center point + far edge point = h2 + // Let the distance along the center line from the near point to the sphere center point = x + // Then let the distance between the sphere center point + near edge point == + // the distance between the sphere center point + far edge point == r == radius of sphere + // Then h1^2 + x^2 == r^2 == (l-x)^2 + h2^2 + // h1^x + x^2 = l^2 - 2 * l * x + x^2 + h2^2 + // 2 * l * x = l^2 + h2^2 - h1^2 + // x = (l^2 + h2^2 - h1^2) / (2 * l) + // r = sqrt( hl^1 + x^2 ) + Vector vecDelta; + VectorSubtract( vecCenterFar, vecCenterNear, vecDelta ); + float l = vecDelta.Length(); + float h1Sqr = vecCenterNear.DistToSqr( vecNearEdge ); + float h2Sqr = vecCenterFar.DistToSqr( vecFarEdge ); + float x = (l*l + h2Sqr - h1Sqr) / (2.0f * l); + VectorMA( vecCenterNear, (x / l), vecDelta, *pCenter ); + *pflRadius = sqrt( h1Sqr + x*x ); +} + +//----------------------------------------------------------------------------- +// Given a projection matrix, take the extremes of the space in transformed into world space and +// get a bounding sphere. +//----------------------------------------------------------------------------- +void CalculateSphereFromProjectionMatrix( const VMatrix &worldToVolume, Vector *pCenter, float *pflRadius ) +{ + VMatrix volumeToWorld; + MatrixInverseGeneral( worldToVolume, volumeToWorld ); + CalculateSphereFromProjectionMatrixInverse( volumeToWorld, pCenter, pflRadius ); +} + +#endif + +#if 0 +static inline void FrustumPlanesFromMatrixHelper( const VMatrix &shadowToWorld, const Vector &p1, const Vector &p2, const Vector &p3, VPlane &plane ) +{ + Vector world1, world2, world3; + Vector3DMultiplyPositionProjective( shadowToWorld, p1, world1 ); + Vector3DMultiplyPositionProjective( shadowToWorld, p2, world2 ); + Vector3DMultiplyPositionProjective( shadowToWorld, p3, world3 ); + + Vector v1, v2; + VectorSubtract( world2, world1, v1 ); + VectorSubtract( world3, world1, v2 ); + + CrossProduct( v1, v2, plane.m_Normal ); + VectorNormalize( plane.m_Normal ); + plane.m_Dist = DotProduct( plane.m_Normal, world1 ); +} + +void FrustumPlanesFromMatrix( const VMatrix &clipToWorld, Frustum_t &frustum ) +{ + VPlane planes[6]; + + FrustumPlanesFromMatrixHelper( clipToWorld, + Vector( 0.0f, 0.0f, 0.0f ), Vector( 1.0f, 0.0f, 0.0f ), Vector( 0.0f, 1.0f, 0.0f ), planes[FRUSTUM_NEARZ] ); + + FrustumPlanesFromMatrixHelper( clipToWorld, + Vector( 0.0f, 0.0f, 1.0f ), Vector( 0.0f, 1.0f, 1.0f ), Vector( 1.0f, 0.0f, 1.0f ), planes[FRUSTUM_FARZ] ); + + FrustumPlanesFromMatrixHelper( clipToWorld, + Vector( 1.0f, 0.0f, 0.0f ), Vector( 1.0f, 1.0f, 1.0f ), Vector( 1.0f, 1.0f, 0.0f ), planes[FRUSTUM_RIGHT] ); + + FrustumPlanesFromMatrixHelper( clipToWorld, + Vector( 0.0f, 0.0f, 0.0f ), Vector( 0.0f, 1.0f, 1.0f ), Vector( 0.0f, 0.0f, 1.0f ), planes[FRUSTUM_LEFT] ); + + FrustumPlanesFromMatrixHelper( clipToWorld, + Vector( 1.0f, 1.0f, 0.0f ), Vector( 1.0f, 1.0f, 1.0f ), Vector( 0.0f, 1.0f, 1.0f ), planes[FRUSTUM_TOP] ); + + FrustumPlanesFromMatrixHelper( clipToWorld, + Vector( 1.0f, 0.0f, 0.0f ), Vector( 0.0f, 0.0f, 1.0f ), Vector( 1.0f, 0.0f, 1.0f ), planes[FRUSTUM_BOTTOM] ); + + frustum.SetPlanes(planes); +} +#endif + +void MatrixBuildOrtho( VMatrix& dst, double left, double top, double right, double bottom, double zNear, double zFar ) +{ + // FIXME: This is being used incorrectly! Should read: + // D3DXMatrixOrthoOffCenterRH( &matrix, left, right, bottom, top, zNear, zFar ); + // Which is certainly why we need these extra -1 scales in y. Bleah + + // NOTE: The camera can be imagined as the following diagram: + // /z + // / + // /____ x Z is going into the screen + // | + // | + // |y + // + // (0,0,z) represents the upper-left corner of the screen. + // Our projection transform needs to transform from this space to a LH coordinate + // system that looks thusly: + // + // y| /z + // | / + // |/____ x Z is going into the screen + // + // Where x,y lies between -1 and 1, and z lies from 0 to 1 + // This is because the viewport transformation from projection space to pixels + // introduces a -1 scale in the y coordinates + // D3DXMatrixOrthoOffCenterRH( &matrix, left, right, top, bottom, zNear, zFar ); + + dst.Init( 2.0f / ( right - left ), 0.0f, 0.0f, ( left + right ) / ( left - right ), + 0.0f, 2.0f / ( bottom - top ), 0.0f, ( bottom + top ) / ( top - bottom ), + 0.0f, 0.0f, 1.0f / ( zNear - zFar ), zNear / ( zNear - zFar ), + 0.0f, 0.0f, 0.0f, 1.0f ); +} + +void MatrixBuildPerspectiveX( VMatrix& dst, double flFovX, double flAspect, double flZNear, double flZFar ) +{ + float flWidth = 2.0f * flZNear * tanf( flFovX * M_PI / 360.0f ); + float flHeight = flWidth / flAspect; + dst.Init( 2.0f * flZNear / flWidth, 0.0f, 0.0f, 0.0f, + 0.0f, 2.0f * flZNear/ flHeight, 0.0f, 0.0f, + 0.0f, 0.0f, flZFar / ( flZNear - flZFar ), flZNear * flZFar / ( flZNear - flZFar ), + 0.0f, 0.0f, -1.0f, 0.0f ); +} + +void MatrixBuildPerspectiveOffCenterX( VMatrix& dst, double flFovX, double flAspect, double flZNear, double flZFar, double bottom, double top, double left, double right ) +{ + float flWidth = 2.0f * flZNear * tanf( flFovX * M_PI / 360.0f ); + float flHeight = flWidth / flAspect; + + // bottom, top, left, right are 0..1 so convert to -/2../2 + float flLeft = -(flWidth/2.0f) * (1.0f - left) + left * (flWidth/2.0f); + float flRight = -(flWidth/2.0f) * (1.0f - right) + right * (flWidth/2.0f); + float flBottom = -(flHeight/2.0f) * (1.0f - bottom) + bottom * (flHeight/2.0f); + float flTop = -(flHeight/2.0f) * (1.0f - top) + top * (flHeight/2.0f); + + dst.Init( (2.0f * flZNear) / (flRight-flLeft), 0.0f, (flLeft+flRight)/(flRight-flLeft), 0.0f, + 0.0f, 2.0f*flZNear/(flTop-flBottom), (flTop+flBottom)/(flTop-flBottom), 0.0f, + 0.0f, 0.0f, flZFar/(flZNear-flZFar), flZNear*flZFar/(flZNear-flZFar), + 0.0f, 0.0f, -1.0f, 0.0f ); +} + + diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/mathlite.h b/GameGuru Core/SDK/Steamworks SDK/glmgr/mathlite.h new file mode 100644 index 0000000..33c6060 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/mathlite.h @@ -0,0 +1,4422 @@ +#ifndef MATHLITE_H +#define MATHLITE_H + +//----------------------------------------------------------------------------- +// includes + +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +// macros + +#define FLOAT32_NAN_BITS (unsigned long)0x7FC00000 // not a number! +#define FLOAT32_NAN BitsToFloat( FLOAT32_NAN_BITS ) +#define VEC_T_NAN FLOAT32_NAN + +#define FastSqrt(x) sqrt(x) + +#ifndef Assert +#define Assert(x) +#endif + +#ifndef RAD2DEG + #define RAD2DEG( x ) ( (float)(x) * (float)(180.f / M_PI_F) ) +#endif + +#ifndef DEG2RAD + #define DEG2RAD( x ) ( (float)(x) * (float)(M_PI_F / 180.f) ) +#endif + +#ifndef M_PI + #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h +#endif + +#define M_PI_F ((float)(M_PI)) // Shouldn't collide with anything. + + +//----------------------------------------------------------------------------- +// typedefs +typedef float vec_t; + +enum +{ + PITCH = 0, // up / down + YAW, // left / right + ROLL // fall over +}; + +//----------------------------------------------------------------------------- +// inlines + +inline float fpmin( float a, float b ) +{ + return ( a < b ) ? a : b; +} + +inline float fpmax( float a, float b ) +{ + return ( a > b ) ? a : b; +} + + +inline unsigned long& FloatBits( vec_t& f ) +{ + return *reinterpret_cast((char*)(&f)); +} + + +inline unsigned long const FloatBits( const vec_t &f ) +{ + union Convertor_t + { + vec_t f; + unsigned long ul; + }tmp; + tmp.f = f; + return tmp.ul; +} + + +inline vec_t BitsToFloat( unsigned long i ) +{ + union Convertor_t + { + vec_t f; + unsigned long ul; + }tmp; + tmp.ul = i; + return tmp.f; +} + +inline bool IsFinite( const vec_t &f ) +{ +#if _X360 + return f == f && fabs(f) <= FLT_MAX; +#else + return ((FloatBits(f) & 0x7F800000) != 0x7F800000); +#endif +} + +inline unsigned long FloatAbsBits( vec_t f ) +{ + return FloatBits(f) & 0x7FFFFFFF; +} + +inline float FloatMakeNegative( vec_t f ) +{ + return BitsToFloat( FloatBits(f) | 0x80000000 ); +} + +inline float FloatMakePositive( vec_t f ) +{ + return (float)fabs( f ); +} + +inline void SinCos( float radians, float *sine, float *cosine ) +{ + *sine = sin(radians); + *cosine = cos(radians); +} + +//----------------------------------------------------------------------------- +// The following are not declared as macros because they are often used in limiting situations, +// and sometimes the compiler simply refuses to inline them for some reason +inline float FastSqrt( float x ) +{ + __m128 root = _mm_sqrt_ss( _mm_load_ss( &x ) ); + return *( reinterpret_cast( &root ) ); +} + +inline float FastRSqrtFast( float x ) +{ + // use intrinsics + __m128 rroot = _mm_rsqrt_ss( _mm_load_ss( &x ) ); + return *( reinterpret_cast( &rroot ) ); +} +// Single iteration NewtonRaphson reciprocal square root: +// 0.5 * rsqrtps * (3 - x * rsqrtps(x) * rsqrtps(x)) +// Very low error, and fine to use in place of 1.f / sqrtf(x). +inline float FastRSqrt( float x ) +{ + float rroot = FastRSqrtFast( x ); + return (0.5f * rroot) * (3.f - (x * rroot) * rroot); +} + +//----------------------------------------------------------------------------- +// classes + +// Used to make certain code easier to read. +#define X_INDEX 0 +#define Y_INDEX 1 +#define Z_INDEX 2 + + +#ifdef VECTOR_PARANOIA +#define CHECK_VALID( _v) Assert( (_v).IsValid() ) +#else +#ifdef GNUC +#define CHECK_VALID( _v) +#else +#define CHECK_VALID( _v) 0 +#endif +#endif + +#define VecToString(v) (static_cast(CFmtStr("(%f, %f, %f)", (v).x, (v).y, (v).z))) // ** Note: this generates a temporary, don't hold reference! + +class VectorByValue; + +//========================================================= +// 3D Vector +//========================================================= +class Vector +{ +public: + // Members + vec_t x, y, z; + + // Construction/destruction: + Vector(void); + Vector(vec_t X, vec_t Y, vec_t Z); + + // Initialization + void Init(vec_t ix=0.0f, vec_t iy=0.0f, vec_t iz=0.0f); + // TODO (Ilya): Should there be an init that takes a single float for consistency? + + // Got any nasty NAN's? + bool IsValid() const; + void Invalidate(); + + // array access... + vec_t operator[](int i) const; + vec_t& operator[](int i); + + // Base address... + vec_t* Base(); + vec_t const* Base() const; + + // Cast to Vector2D... + //Vector2D& AsVector2D(); + //const Vector2D& AsVector2D() const; + + // Initialization methods + void Random( vec_t minVal, vec_t maxVal ); + inline void Zero(); ///< zero out a vector + + // equality + bool operator==(const Vector& v) const; + bool operator!=(const Vector& v) const; + + // arithmetic operations + inline Vector& operator+=(const Vector &v); + inline Vector& operator-=(const Vector &v); + inline Vector& operator*=(const Vector &v); + inline Vector& operator*=(float s); + inline Vector& operator/=(const Vector &v); + inline Vector& operator/=(float s); + inline Vector& operator+=(float fl) ; ///< broadcast add + inline Vector& operator-=(float fl) ; ///< broadcast sub + +// negate the vector components + void Negate(); + + // Get the vector's magnitude. + inline vec_t Length() const; + + // Get the vector's magnitude squared. + inline vec_t LengthSqr(void) const + { + CHECK_VALID(*this); + return (x*x + y*y + z*z); + } + + // return true if this vector is (0,0,0) within tolerance + bool IsZero( float tolerance = 0.01f ) const + { + return (x > -tolerance && x < tolerance && + y > -tolerance && y < tolerance && + z > -tolerance && z < tolerance); + } + + vec_t NormalizeInPlace(); + Vector Normalized() const; + bool IsLengthGreaterThan( float val ) const; + bool IsLengthLessThan( float val ) const; + + // check if a vector is within the box defined by two other vectors + inline bool WithinAABox( Vector const &boxmin, Vector const &boxmax); + + // Get the distance from this vector to the other one. + vec_t DistTo(const Vector &vOther) const; + + // Get the distance from this vector to the other one squared. + // NJS: note, VC wasn't inlining it correctly in several deeply nested inlines due to being an 'out of line' inline. + // may be able to tidy this up after switching to VC7 + inline vec_t DistToSqr(const Vector &vOther) const + { + Vector delta; + + delta.x = x - vOther.x; + delta.y = y - vOther.y; + delta.z = z - vOther.z; + + return delta.LengthSqr(); + } + + // Copy + void CopyToArray(float* rgfl) const; + + // Multiply, add, and assign to this (ie: *this = a + b * scalar). This + // is about 12% faster than the actual vector equation (because it's done per-component + // rather than per-vector). + void MulAdd(const Vector& a, const Vector& b, float scalar); + + // Dot product. + vec_t Dot(const Vector& vOther) const; + + // assignment + Vector& operator=(const Vector &vOther); + + // returns 0, 1, 2 corresponding to the component with the largest absolute value + inline int LargestComponent() const; + + // 2d + vec_t Length2D(void) const; + vec_t Length2DSqr(void) const; + + operator VectorByValue &() { return *((VectorByValue *)(this)); } + operator const VectorByValue &() const { return *((const VectorByValue *)(this)); } + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // copy constructors +// Vector(const Vector &vOther); + + // arithmetic operations + Vector operator-(void) const; + + Vector operator+(const Vector& v) const; + Vector operator-(const Vector& v) const; + Vector operator*(const Vector& v) const; + Vector operator/(const Vector& v) const; + Vector operator*(float fl) const; + Vector operator/(float fl) const; + + // Cross product between two vectors. + Vector Cross(const Vector &vOther) const; + + // Returns a vector with the min or max in X, Y, and Z. + Vector Min(const Vector &vOther) const; + Vector Max(const Vector &vOther) const; + +#else + +private: + // No copy constructors allowed if we're in optimal mode + Vector(const Vector& vOther); +#endif +}; + + + +#define USE_M64S ( ( !defined( _X360 ) ) ) + + + +//========================================================= +// 4D Short Vector (aligned on 8-byte boundary) +//========================================================= +#if 0 +class ALIGN8 ShortVector +{ +public: + + short x, y, z, w; + + // Initialization + void Init(short ix = 0, short iy = 0, short iz = 0, short iw = 0 ); + + +#if USE_M64S + __m64 &AsM64() { return *(__m64*)&x; } + const __m64 &AsM64() const { return *(const __m64*)&x; } +#endif + + // Setter + void Set( const ShortVector& vOther ); + void Set( const short ix, const short iy, const short iz, const short iw ); + + // array access... + short operator[](int i) const; + short& operator[](int i); + + // Base address... + short* Base(); + short const* Base() const; + + // equality + bool operator==(const ShortVector& v) const; + bool operator!=(const ShortVector& v) const; + + // Arithmetic operations + inline ShortVector& operator+=(const ShortVector &v); + inline ShortVector& operator-=(const ShortVector &v); + inline ShortVector& operator*=(const ShortVector &v); + inline ShortVector& operator*=(float s); + inline ShortVector& operator/=(const ShortVector &v); + inline ShortVector& operator/=(float s); + inline ShortVector operator*(float fl) const; + +private: + + // No copy constructors allowed if we're in optimal mode +// ShortVector(ShortVector const& vOther); + + // No assignment operators either... +// ShortVector& operator=( ShortVector const& src ); + +} ALIGN8_POST; +#endif + + + + +#if 0 +//========================================================= +// 4D Integer Vector +//========================================================= +class IntVector4D +{ +public: + + int x, y, z, w; + + // Initialization + void Init(int ix = 0, int iy = 0, int iz = 0, int iw = 0 ); + +#if USE_M64S + __m64 &AsM64() { return *(__m64*)&x; } + const __m64 &AsM64() const { return *(const __m64*)&x; } +#endif + + // Setter + void Set( const IntVector4D& vOther ); + void Set( const int ix, const int iy, const int iz, const int iw ); + + // array access... + int operator[](int i) const; + int& operator[](int i); + + // Base address... + int* Base(); + int const* Base() const; + + // equality + bool operator==(const IntVector4D& v) const; + bool operator!=(const IntVector4D& v) const; + + // Arithmetic operations + inline IntVector4D& operator+=(const IntVector4D &v); + inline IntVector4D& operator-=(const IntVector4D &v); + inline IntVector4D& operator*=(const IntVector4D &v); + inline IntVector4D& operator*=(float s); + inline IntVector4D& operator/=(const IntVector4D &v); + inline IntVector4D& operator/=(float s); + inline IntVector4D operator*(float fl) const; + +private: + + // No copy constructors allowed if we're in optimal mode + // IntVector4D(IntVector4D const& vOther); + + // No assignment operators either... + // IntVector4D& operator=( IntVector4D const& src ); + +}; + +#endif + +//----------------------------------------------------------------------------- +// Allows us to specifically pass the vector by value when we need to +//----------------------------------------------------------------------------- +class VectorByValue : public Vector +{ +public: + // Construction/destruction: + VectorByValue(void) : Vector() {} + VectorByValue(vec_t X, vec_t Y, vec_t Z) : Vector( X, Y, Z ) {} + VectorByValue(const VectorByValue& vOther) { *this = vOther; } +}; + + +//----------------------------------------------------------------------------- +// Utility to simplify table construction. No constructor means can use +// traditional C-style initialization +//----------------------------------------------------------------------------- +class TableVector +{ +public: + vec_t x, y, z; + + operator Vector &() { return *((Vector *)(this)); } + operator const Vector &() const { return *((const Vector *)(this)); } + + // array access... + inline vec_t& operator[](int i) + { + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; + } + + inline vec_t operator[](int i) const + { + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; + } +}; + + +//----------------------------------------------------------------------------- +// Here's where we add all those lovely SSE optimized routines +//----------------------------------------------------------------------------- + +#if 0 +class ALIGN16 VectorAligned : public Vector +{ +public: + inline VectorAligned(void) {}; + inline VectorAligned(vec_t X, vec_t Y, vec_t Z) + { + Init(X,Y,Z); + } + +#ifdef VECTOR_NO_SLOW_OPERATIONS + +private: + // No copy constructors allowed if we're in optimal mode + VectorAligned(const VectorAligned& vOther); + VectorAligned(const Vector &vOther); + +#else +public: + explicit VectorAligned(const Vector &vOther) + { + Init(vOther.x, vOther.y, vOther.z); + } + + VectorAligned& operator=(const Vector &vOther) + { + Init(vOther.x, vOther.y, vOther.z); + return *this; + } + + VectorAligned& operator=(const VectorAligned &vOther) + { + // we know we're aligned, so use simd + // we can't use the convenient abstract interface coz it gets declared later +#ifdef _X360 + XMStoreVector4A(Base(), XMLoadVector4A(vOther.Base())); +#elif _WIN32 + _mm_store_ps(Base(), _mm_load_ps( vOther.Base() )); +#else + Init(vOther.x, vOther.y, vOther.z); +#endif + return *this; + } + + +#endif + float w; // this space is used anyway + + void* operator new[] ( size_t nSize) + { + return MemAlloc_AllocAligned(nSize, 16); + } + + void* operator new[] ( size_t nSize, const char *pFileName, int nLine) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + + void* operator new[] ( size_t nSize, int /*nBlockUse*/, const char *pFileName, int nLine) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + + void operator delete[] ( void* p) + { + MemAlloc_FreeAligned(p,true); + } + + void operator delete[] ( void* p, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } + + void operator delete[] ( void* p, int /*nBlockUse*/, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } + + // please don't allocate a single quaternion... + void* operator new ( size_t nSize ) + { + return MemAlloc_AllocAligned(nSize, 16); + } + void* operator new ( size_t nSize, const char *pFileName, int nLine ) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + void* operator new ( size_t nSize, int /*nBlockUse*/, const char *pFileName, int nLine ) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + void operator delete ( void* p) + { + MemAlloc_FreeAligned(p,true); + } + + void operator delete ( void* p, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } + + void operator delete ( void* p, int /*nBlockUse*/, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } +} ALIGN16_POST; + +#endif + +//----------------------------------------------------------------------------- +// Vector related operations +//----------------------------------------------------------------------------- + +// Vector clear +inline void VectorClear( Vector& a ); + +// Copy +inline void VectorCopy( const Vector& src, Vector& dst ); + +// Vector arithmetic +inline void VectorAdd( const Vector& a, const Vector& b, Vector& result ); +inline void VectorSubtract( const Vector& a, const Vector& b, Vector& result ); +inline void VectorMultiply( const Vector& a, vec_t b, Vector& result ); +inline void VectorMultiply( const Vector& a, const Vector& b, Vector& result ); +inline void VectorDivide( const Vector& a, vec_t b, Vector& result ); +inline void VectorDivide( const Vector& a, const Vector& b, Vector& result ); + +// Vector equality with tolerance +bool VectorsAreEqual( const Vector& src1, const Vector& src2, float tolerance = 0.0f ); + +#define VectorExpand(v) (v).x, (v).y, (v).z + + +// Normalization +// FIXME: Can't use quite yet +//vec_t VectorNormalize( Vector& v ); + +// Length +inline vec_t VectorLength( const Vector& v ); + +// Dot Product +inline vec_t DotProduct(const Vector& a, const Vector& b); + +// Cross product +void CrossProduct(const Vector& a, const Vector& b, Vector& result ); + +// Store the min or max of each of x, y, and z into the result. +void VectorMin( const Vector &a, const Vector &b, Vector &result ); +void VectorMax( const Vector &a, const Vector &b, Vector &result ); + +// Linearly interpolate between two vectors +void VectorLerp(const Vector& src1, const Vector& src2, vec_t t, Vector& dest ); +Vector VectorLerp(const Vector& src1, const Vector& src2, vec_t t ); + +inline Vector ReplicateToVector( float x ) +{ + return Vector( x, x, x ); +} + +inline bool PointWithinViewAngle( Vector const &vecSrcPosition, + Vector const &vecTargetPosition, + Vector const &vecLookDirection, float flCosHalfFOV ) +{ + Vector vecDelta = vecTargetPosition - vecSrcPosition; + float cosDiff = DotProduct( vecLookDirection, vecDelta ); + + if ( flCosHalfFOV <= 0 ) // >180 + { + // signs are different, answer is implicit + if ( cosDiff > 0 ) + return true; + + // a/sqrt(b) > c == a^2 < b * c ^2 + // IFF left and right sides are <= 0 + float flLen2 = vecDelta.LengthSqr(); + return ( cosDiff * cosDiff <= flLen2 * flCosHalfFOV * flCosHalfFOV ); + } + else // flCosHalfFOV > 0 + { + // signs are different, answer is implicit + if ( cosDiff < 0 ) + return false; + + // a/sqrt(b) > c == a^2 > b * c ^2 + // IFF left and right sides are >= 0 + float flLen2 = vecDelta.LengthSqr(); + return ( cosDiff * cosDiff >= flLen2 * flCosHalfFOV * flCosHalfFOV ); + } +} + + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +// Cross product +Vector CrossProduct( const Vector& a, const Vector& b ); + +// Random vector creation +Vector RandomVector( vec_t minVal, vec_t maxVal ); + +#endif + +//float RandomVectorInUnitSphere( Vector *pVector ); +//float RandomVectorInUnitCircle( Vector2D *pVector ); + + +//----------------------------------------------------------------------------- +// +// Inlined Vector methods +// +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +// constructors +//----------------------------------------------------------------------------- +inline Vector::Vector(void) +{ +#ifdef _DEBUG +#ifdef VECTOR_PARANOIA + // Initialize to NAN to catch errors + x = y = z = VEC_T_NAN; +#endif +#endif +} + +inline Vector::Vector(vec_t X, vec_t Y, vec_t Z) +{ + x = X; y = Y; z = Z; + CHECK_VALID(*this); +} + +//inline Vector::Vector(const float *pFloat) +//{ +// Assert( pFloat ); +// x = pFloat[0]; y = pFloat[1]; z = pFloat[2]; +// CHECK_VALID(*this); +//} + +#if 0 +//----------------------------------------------------------------------------- +// copy constructor +//----------------------------------------------------------------------------- + +inline Vector::Vector(const Vector &vOther) +{ + CHECK_VALID(vOther); + x = vOther.x; y = vOther.y; z = vOther.z; +} +#endif + +//----------------------------------------------------------------------------- +// initialization +//----------------------------------------------------------------------------- + +inline void Vector::Init( vec_t ix, vec_t iy, vec_t iz ) +{ + x = ix; y = iy; z = iz; + CHECK_VALID(*this); +} + +/* +inline void Vector::Random( vec_t minVal, vec_t maxVal ) +{ + x = minVal + ((float)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + y = minVal + ((float)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + z = minVal + ((float)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + CHECK_VALID(*this); +} +*/ + +// This should really be a single opcode on the PowerPC (move r0 onto the vec reg) +inline void Vector::Zero() +{ + x = y = z = 0.0f; +} + +inline void VectorClear( Vector& a ) +{ + a.x = a.y = a.z = 0.0f; +} + +//----------------------------------------------------------------------------- +// assignment +//----------------------------------------------------------------------------- + +inline Vector& Vector::operator=(const Vector &vOther) +{ + CHECK_VALID(vOther); + x=vOther.x; y=vOther.y; z=vOther.z; + return *this; +} + + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- +inline vec_t& Vector::operator[](int i) +{ + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; +} + +inline vec_t Vector::operator[](int i) const +{ + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; +} + + +//----------------------------------------------------------------------------- +// Base address... +//----------------------------------------------------------------------------- +inline vec_t* Vector::Base() +{ + return (vec_t*)this; +} + +inline vec_t const* Vector::Base() const +{ + return (vec_t const*)this; +} + +//----------------------------------------------------------------------------- +// Cast to Vector2D... +//----------------------------------------------------------------------------- + +//inline Vector2D& Vector::AsVector2D() +//{ +// return *(Vector2D*)this; +//} + +//inline const Vector2D& Vector::AsVector2D() const +//{ +// return *(const Vector2D*)this; +//} + +//----------------------------------------------------------------------------- +// IsValid? +//----------------------------------------------------------------------------- + +inline bool Vector::IsValid() const +{ + return IsFinite(x) && IsFinite(y) && IsFinite(z); +} + +//----------------------------------------------------------------------------- +// Invalidate +//----------------------------------------------------------------------------- + +inline void Vector::Invalidate() +{ +//#ifdef _DEBUG +//#ifdef VECTOR_PARANOIA + x = y = z = VEC_T_NAN; +//#endif +//#endif +} + +//----------------------------------------------------------------------------- +// comparison +//----------------------------------------------------------------------------- + +inline bool Vector::operator==( const Vector& src ) const +{ + CHECK_VALID(src); + CHECK_VALID(*this); + return (src.x == x) && (src.y == y) && (src.z == z); +} + +inline bool Vector::operator!=( const Vector& src ) const +{ + CHECK_VALID(src); + CHECK_VALID(*this); + return (src.x != x) || (src.y != y) || (src.z != z); +} + + +//----------------------------------------------------------------------------- +// Copy +//----------------------------------------------------------------------------- + +inline void VectorCopy( const Vector& src, Vector& dst ) +{ + CHECK_VALID(src); + dst.x = src.x; + dst.y = src.y; + dst.z = src.z; +} + +inline void Vector::CopyToArray(float* rgfl) const +{ + Assert( rgfl ); + CHECK_VALID(*this); + rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; +} + +//----------------------------------------------------------------------------- +// standard math operations +//----------------------------------------------------------------------------- +// #pragma message("TODO: these should be SSE") + +inline void Vector::Negate() +{ + CHECK_VALID(*this); + x = -x; y = -y; z = -z; +} + +inline Vector& Vector::operator+=(const Vector& v) +{ + CHECK_VALID(*this); + CHECK_VALID(v); + x+=v.x; y+=v.y; z += v.z; + return *this; +} + +inline Vector& Vector::operator-=(const Vector& v) +{ + CHECK_VALID(*this); + CHECK_VALID(v); + x-=v.x; y-=v.y; z -= v.z; + return *this; +} + +inline Vector& Vector::operator*=(float fl) +{ + x *= fl; + y *= fl; + z *= fl; + CHECK_VALID(*this); + return *this; +} + +inline Vector& Vector::operator*=(const Vector& v) +{ + CHECK_VALID(v); + x *= v.x; + y *= v.y; + z *= v.z; + CHECK_VALID(*this); + return *this; +} + +// this ought to be an opcode. +inline Vector& Vector::operator+=(float fl) +{ + x += fl; + y += fl; + z += fl; + CHECK_VALID(*this); + return *this; +} + +inline Vector& Vector::operator-=(float fl) +{ + x -= fl; + y -= fl; + z -= fl; + CHECK_VALID(*this); + return *this; +} + + + +inline Vector& Vector::operator/=(float fl) +{ + Assert( fl != 0.0f ); + float oofl = 1.0f / fl; + x *= oofl; + y *= oofl; + z *= oofl; + CHECK_VALID(*this); + return *this; +} + +inline Vector& Vector::operator/=(const Vector& v) +{ + CHECK_VALID(v); + Assert( v.x != 0.0f && v.y != 0.0f && v.z != 0.0f ); + x /= v.x; + y /= v.y; + z /= v.z; + CHECK_VALID(*this); + return *this; +} + + +#if 0 +//----------------------------------------------------------------------------- +// +// Inlined Short Vector methods +// +//----------------------------------------------------------------------------- + + +inline void ShortVector::Init( short ix, short iy, short iz, short iw ) +{ + x = ix; y = iy; z = iz; w = iw; +} + +inline void ShortVector::Set( const ShortVector& vOther ) +{ + x = vOther.x; + y = vOther.y; + z = vOther.z; + w = vOther.w; +} + +inline void ShortVector::Set( const short ix, const short iy, const short iz, const short iw ) +{ + x = ix; + y = iy; + z = iz; + w = iw; +} + + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- +inline short ShortVector::operator[](int i) const +{ + Assert( (i >= 0) && (i < 4) ); + return ((short*)this)[i]; +} + +inline short& ShortVector::operator[](int i) +{ + Assert( (i >= 0) && (i < 4) ); + return ((short*)this)[i]; +} + +//----------------------------------------------------------------------------- +// Base address... +//----------------------------------------------------------------------------- +inline short* ShortVector::Base() +{ + return (short*)this; +} + +inline short const* ShortVector::Base() const +{ + return (short const*)this; +} + + +//----------------------------------------------------------------------------- +// comparison +//----------------------------------------------------------------------------- + +inline bool ShortVector::operator==( const ShortVector& src ) const +{ + return (src.x == x) && (src.y == y) && (src.z == z) && (src.w == w); +} + +inline bool ShortVector::operator!=( const ShortVector& src ) const +{ + return (src.x != x) || (src.y != y) || (src.z != z) || (src.w != w); +} + + + +//----------------------------------------------------------------------------- +// standard math operations +//----------------------------------------------------------------------------- + +inline ShortVector& ShortVector::operator+=(const ShortVector& v) +{ + x+=v.x; y+=v.y; z += v.z; w += v.w; + return *this; +} + +inline ShortVector& ShortVector::operator-=(const ShortVector& v) +{ + x-=v.x; y-=v.y; z -= v.z; w -= v.w; + return *this; +} + +inline ShortVector& ShortVector::operator*=(float fl) +{ + x = (short)(x * fl); + y = (short)(y * fl); + z = (short)(z * fl); + w = (short)(w * fl); + return *this; +} + +inline ShortVector& ShortVector::operator*=(const ShortVector& v) +{ + x = (short)(x * v.x); + y = (short)(y * v.y); + z = (short)(z * v.z); + w = (short)(w * v.w); + return *this; +} + +inline ShortVector& ShortVector::operator/=(float fl) +{ + Assert( fl != 0.0f ); + float oofl = 1.0f / fl; + x = (short)(x * oofl); + y = (short)(y * oofl); + z = (short)(z * oofl); + w = (short)(w * oofl); + return *this; +} + +inline ShortVector& ShortVector::operator/=(const ShortVector& v) +{ + Assert( v.x != 0 && v.y != 0 && v.z != 0 && v.w != 0 ); + x = (short)(x / v.x); + y = (short)(y / v.y); + z = (short)(z / v.z); + w = (short)(w / v.w); + return *this; +} + +inline void ShortVectorMultiply( const ShortVector& src, float fl, ShortVector& res ) +{ + Assert( IsFinite(fl) ); + res.x = (short)(src.x * fl); + res.y = (short)(src.y * fl); + res.z = (short)(src.z * fl); + res.w = (short)(src.w * fl); +} + +inline ShortVector ShortVector::operator*(float fl) const +{ + ShortVector res; + ShortVectorMultiply( *this, fl, res ); + return res; +} + +#endif + + + +#if 0 +//----------------------------------------------------------------------------- +// +// Inlined Integer Vector methods +// +//----------------------------------------------------------------------------- + + +inline void IntVector4D::Init( int ix, int iy, int iz, int iw ) +{ + x = ix; y = iy; z = iz; w = iw; +} + +inline void IntVector4D::Set( const IntVector4D& vOther ) +{ + x = vOther.x; + y = vOther.y; + z = vOther.z; + w = vOther.w; +} + +inline void IntVector4D::Set( const int ix, const int iy, const int iz, const int iw ) +{ + x = ix; + y = iy; + z = iz; + w = iw; +} + + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- +inline int IntVector4D::operator[](int i) const +{ + Assert( (i >= 0) && (i < 4) ); + return ((int*)this)[i]; +} + +inline int& IntVector4D::operator[](int i) +{ + Assert( (i >= 0) && (i < 4) ); + return ((int*)this)[i]; +} + +//----------------------------------------------------------------------------- +// Base address... +//----------------------------------------------------------------------------- +inline int* IntVector4D::Base() +{ + return (int*)this; +} + +inline int const* IntVector4D::Base() const +{ + return (int const*)this; +} + + +//----------------------------------------------------------------------------- +// comparison +//----------------------------------------------------------------------------- + +inline bool IntVector4D::operator==( const IntVector4D& src ) const +{ + return (src.x == x) && (src.y == y) && (src.z == z) && (src.w == w); +} + +inline bool IntVector4D::operator!=( const IntVector4D& src ) const +{ + return (src.x != x) || (src.y != y) || (src.z != z) || (src.w != w); +} + + + +//----------------------------------------------------------------------------- +// standard math operations +//----------------------------------------------------------------------------- + +inline IntVector4D& IntVector4D::operator+=(const IntVector4D& v) +{ + x+=v.x; y+=v.y; z += v.z; w += v.w; + return *this; +} + +inline IntVector4D& IntVector4D::operator-=(const IntVector4D& v) +{ + x-=v.x; y-=v.y; z -= v.z; w -= v.w; + return *this; +} + +inline IntVector4D& IntVector4D::operator*=(float fl) +{ + x = (int)(x * fl); + y = (int)(y * fl); + z = (int)(z * fl); + w = (int)(w * fl); + return *this; +} + +inline IntVector4D& IntVector4D::operator*=(const IntVector4D& v) +{ + x = (int)(x * v.x); + y = (int)(y * v.y); + z = (int)(z * v.z); + w = (int)(w * v.w); + return *this; +} + +inline IntVector4D& IntVector4D::operator/=(float fl) +{ + Assert( fl != 0.0f ); + float oofl = 1.0f / fl; + x = (int)(x * oofl); + y = (int)(y * oofl); + z = (int)(z * oofl); + w = (int)(w * oofl); + return *this; +} + +inline IntVector4D& IntVector4D::operator/=(const IntVector4D& v) +{ + Assert( v.x != 0 && v.y != 0 && v.z != 0 && v.w != 0 ); + x = (int)(x / v.x); + y = (int)(y / v.y); + z = (int)(z / v.z); + w = (int)(w / v.w); + return *this; +} + +inline void IntVector4DMultiply( const IntVector4D& src, float fl, IntVector4D& res ) +{ + Assert( IsFinite(fl) ); + res.x = (int)(src.x * fl); + res.y = (int)(src.y * fl); + res.z = (int)(src.z * fl); + res.w = (int)(src.w * fl); +} + +inline IntVector4D IntVector4D::operator*(float fl) const +{ + IntVector4D res; + IntVector4DMultiply( *this, fl, res ); + return res; +} + +#endif + +// ======================= + + +inline void VectorAdd( const Vector& a, const Vector& b, Vector& c ) +{ + CHECK_VALID(a); + CHECK_VALID(b); + c.x = a.x + b.x; + c.y = a.y + b.y; + c.z = a.z + b.z; +} + +inline void VectorSubtract( const Vector& a, const Vector& b, Vector& c ) +{ + CHECK_VALID(a); + CHECK_VALID(b); + c.x = a.x - b.x; + c.y = a.y - b.y; + c.z = a.z - b.z; +} + +inline void VectorMultiply( const Vector& a, vec_t b, Vector& c ) +{ + CHECK_VALID(a); + Assert( IsFinite(b) ); + c.x = a.x * b; + c.y = a.y * b; + c.z = a.z * b; +} + +inline void VectorMultiply( const Vector& a, const Vector& b, Vector& c ) +{ + CHECK_VALID(a); + CHECK_VALID(b); + c.x = a.x * b.x; + c.y = a.y * b.y; + c.z = a.z * b.z; +} + +inline void VectorDivide( const Vector& a, vec_t b, Vector& c ) +{ + CHECK_VALID(a); + Assert( b != 0.0f ); + vec_t oob = 1.0f / b; + c.x = a.x * oob; + c.y = a.y * oob; + c.z = a.z * oob; +} + +inline void VectorDivide( const Vector& a, const Vector& b, Vector& c ) +{ + CHECK_VALID(a); + CHECK_VALID(b); + Assert( (b.x != 0.0f) && (b.y != 0.0f) && (b.z != 0.0f) ); + c.x = a.x / b.x; + c.y = a.y / b.y; + c.z = a.z / b.z; +} + +// FIXME: Remove +// For backwards compatability +inline void Vector::MulAdd(const Vector& a, const Vector& b, float scalar) +{ + CHECK_VALID(a); + CHECK_VALID(b); + x = a.x + b.x * scalar; + y = a.y + b.y * scalar; + z = a.z + b.z * scalar; +} + +inline void VectorLerp(const Vector& src1, const Vector& src2, vec_t t, Vector& dest ) +{ + CHECK_VALID(src1); + CHECK_VALID(src2); + dest.x = src1.x + (src2.x - src1.x) * t; + dest.y = src1.y + (src2.y - src1.y) * t; + dest.z = src1.z + (src2.z - src1.z) * t; +} + +inline Vector VectorLerp(const Vector& src1, const Vector& src2, vec_t t ) +{ + Vector result; + VectorLerp( src1, src2, t, result ); + return result; +} + +#if 0 +//----------------------------------------------------------------------------- +// Temporary storage for vector results so const Vector& results can be returned +//----------------------------------------------------------------------------- +inline Vector &AllocTempVector() +{ + static Vector s_vecTemp[128]; + static CInterlockedInt s_nIndex; + + int nIndex; + for (;;) + { + int nOldIndex = s_nIndex; + nIndex = ( (nOldIndex + 0x10001) & 0x7F ); + + if ( s_nIndex.AssignIf( nOldIndex, nIndex ) ) + { + break; + } + ThreadPause(); + } + return s_vecTemp[nIndex & 0xffff]; +} +#endif + + + +//----------------------------------------------------------------------------- +// dot, cross +//----------------------------------------------------------------------------- +inline vec_t DotProduct(const Vector& a, const Vector& b) +{ + CHECK_VALID(a); + CHECK_VALID(b); + return( a.x*b.x + a.y*b.y + a.z*b.z ); +} + +// for backwards compatability +inline vec_t Vector::Dot( const Vector& vOther ) const +{ + CHECK_VALID(vOther); + return DotProduct( *this, vOther ); +} + +inline int Vector::LargestComponent() const +{ + float flAbsx = fabs(x); + float flAbsy = fabs(y); + float flAbsz = fabs(z); + if ( flAbsx > flAbsy ) + { + if ( flAbsx > flAbsz ) + return X_INDEX; + return Z_INDEX; + } + if ( flAbsy > flAbsz ) + return Y_INDEX; + return Z_INDEX; +} + +inline void CrossProduct(const Vector& a, const Vector& b, Vector& result ) +{ + CHECK_VALID(a); + CHECK_VALID(b); + Assert( &a != &result ); + Assert( &b != &result ); + result.x = a.y*b.z - a.z*b.y; + result.y = a.z*b.x - a.x*b.z; + result.z = a.x*b.y - a.y*b.x; +} + +inline vec_t DotProductAbs( const Vector &v0, const Vector &v1 ) +{ + CHECK_VALID(v0); + CHECK_VALID(v1); + return FloatMakePositive(v0.x*v1.x) + FloatMakePositive(v0.y*v1.y) + FloatMakePositive(v0.z*v1.z); +} + +inline vec_t DotProductAbs( const Vector &v0, const float *v1 ) +{ + return FloatMakePositive(v0.x * v1[0]) + FloatMakePositive(v0.y * v1[1]) + FloatMakePositive(v0.z * v1[2]); +} + +//----------------------------------------------------------------------------- +// length +//----------------------------------------------------------------------------- + +inline vec_t VectorLength( const Vector& v ) +{ + CHECK_VALID(v); + return (vec_t)FastSqrt(v.x*v.x + v.y*v.y + v.z*v.z); +} + + +inline vec_t Vector::Length(void) const +{ + CHECK_VALID(*this); + return VectorLength( *this ); +} + + +//----------------------------------------------------------------------------- +// Normalization +//----------------------------------------------------------------------------- + +/* +// FIXME: Can't use until we're un-macroed in mathlib.h +inline vec_t VectorNormalize( Vector& v ) +{ + Assert( v.IsValid() ); + vec_t l = v.Length(); + if (l != 0.0f) + { + v /= l; + } + else + { + // FIXME: + // Just copying the existing implemenation; shouldn't res.z == 0? + v.x = v.y = 0.0f; v.z = 1.0f; + } + return l; +} +*/ + + +// check a point against a box +bool Vector::WithinAABox( Vector const &boxmin, Vector const &boxmax) +{ + return ( + ( x >= boxmin.x ) && ( x <= boxmax.x) && + ( y >= boxmin.y ) && ( y <= boxmax.y) && + ( z >= boxmin.z ) && ( z <= boxmax.z) + ); +} + +//----------------------------------------------------------------------------- +// Get the distance from this vector to the other one +//----------------------------------------------------------------------------- +inline vec_t Vector::DistTo(const Vector &vOther) const +{ + Vector delta; + VectorSubtract( *this, vOther, delta ); + return delta.Length(); +} + + +//----------------------------------------------------------------------------- +// Vector equality with tolerance +//----------------------------------------------------------------------------- +inline bool VectorsAreEqual( const Vector& src1, const Vector& src2, float tolerance ) +{ + if (FloatMakePositive(src1.x - src2.x) > tolerance) + return false; + if (FloatMakePositive(src1.y - src2.y) > tolerance) + return false; + return (FloatMakePositive(src1.z - src2.z) <= tolerance); +} + + +//----------------------------------------------------------------------------- +// Computes the closest point to vecTarget no farther than flMaxDist from vecStart +//----------------------------------------------------------------------------- +inline void ComputeClosestPoint( const Vector& vecStart, float flMaxDist, const Vector& vecTarget, Vector *pResult ) +{ + Vector vecDelta; + VectorSubtract( vecTarget, vecStart, vecDelta ); + float flDistSqr = vecDelta.LengthSqr(); + if ( flDistSqr <= flMaxDist * flMaxDist ) + { + *pResult = vecTarget; + } + else + { + vecDelta /= FastSqrt( flDistSqr ); + vecDelta *= flMaxDist; + VectorAdd( vecStart, vecDelta, *pResult ); + } +} + + +//----------------------------------------------------------------------------- +// Takes the absolute value of a vector +//----------------------------------------------------------------------------- +inline void VectorAbs( const Vector& src, Vector& dst ) +{ + dst.x = FloatMakePositive(src.x); + dst.y = FloatMakePositive(src.y); + dst.z = FloatMakePositive(src.z); +} + + +//----------------------------------------------------------------------------- +// +// Slow methods +// +//----------------------------------------------------------------------------- + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +//----------------------------------------------------------------------------- +// Returns a vector with the min or max in X, Y, and Z. +//----------------------------------------------------------------------------- +inline Vector Vector::Min(const Vector &vOther) const +{ + return Vector(x < vOther.x ? x : vOther.x, + y < vOther.y ? y : vOther.y, + z < vOther.z ? z : vOther.z); +} + +inline Vector Vector::Max(const Vector &vOther) const +{ + return Vector(x > vOther.x ? x : vOther.x, + y > vOther.y ? y : vOther.y, + z > vOther.z ? z : vOther.z); +} + + +//----------------------------------------------------------------------------- +// arithmetic operations +//----------------------------------------------------------------------------- + +inline Vector Vector::operator-(void) const +{ + return Vector(-x,-y,-z); +} + +inline Vector Vector::operator+(const Vector& v) const +{ + Vector res; + VectorAdd( *this, v, res ); + return res; +} + +inline Vector Vector::operator-(const Vector& v) const +{ + Vector res; + VectorSubtract( *this, v, res ); + return res; +} + +inline Vector Vector::operator*(float fl) const +{ + Vector res; + VectorMultiply( *this, fl, res ); + return res; +} + +inline Vector Vector::operator*(const Vector& v) const +{ + Vector res; + VectorMultiply( *this, v, res ); + return res; +} + +inline Vector Vector::operator/(float fl) const +{ + Vector res; + VectorDivide( *this, fl, res ); + return res; +} + +inline Vector Vector::operator/(const Vector& v) const +{ + Vector res; + VectorDivide( *this, v, res ); + return res; +} + +inline Vector operator*(float fl, const Vector& v) +{ + return v * fl; +} + +//----------------------------------------------------------------------------- +// cross product +//----------------------------------------------------------------------------- + +inline Vector Vector::Cross(const Vector& vOther) const +{ + Vector res; + CrossProduct( *this, vOther, res ); + return res; +} + +//----------------------------------------------------------------------------- +// 2D +//----------------------------------------------------------------------------- + +inline vec_t Vector::Length2D(void) const +{ + return (vec_t)FastSqrt(x*x + y*y); +} + +inline vec_t Vector::Length2DSqr(void) const +{ + return (x*x + y*y); +} + +inline Vector CrossProduct(const Vector& a, const Vector& b) +{ + return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); +} + +inline void VectorMin( const Vector &a, const Vector &b, Vector &result ) +{ + result.x = fpmin(a.x, b.x); + result.y = fpmin(a.y, b.y); + result.z = fpmin(a.z, b.z); +} + +inline void VectorMax( const Vector &a, const Vector &b, Vector &result ) +{ + result.x = fpmax(a.x, b.x); + result.y = fpmax(a.y, b.y); + result.z = fpmax(a.z, b.z); +} + +inline float ComputeVolume( const Vector &vecMins, const Vector &vecMaxs ) +{ + Vector vecDelta; + VectorSubtract( vecMaxs, vecMins, vecDelta ); + return DotProduct( vecDelta, vecDelta ); +} + +// Get a random vector. +inline Vector RandomVector( float minVal, float maxVal ) +{ + Vector random; + random.Random( minVal, maxVal ); + return random; +} + +#endif //slow + +//----------------------------------------------------------------------------- +// Helper debugging stuff.... +//----------------------------------------------------------------------------- + +inline bool operator==( float const* f, const Vector& v ) +{ + // AIIIEEEE!!!! + Assert(0); + return false; +} + +inline bool operator==( const Vector& v, float const* f ) +{ + // AIIIEEEE!!!! + Assert(0); + return false; +} + +inline bool operator!=( float const* f, const Vector& v ) +{ + // AIIIEEEE!!!! + Assert(0); + return false; +} + +inline bool operator!=( const Vector& v, float const* f ) +{ + // AIIIEEEE!!!! + Assert(0); + return false; +} + + +// return a vector perpendicular to another, with smooth variation. The difference between this and +// something like VectorVectors is that there are now discontinuities. _unlike_ VectorVectors, +// you won't get an "u +void VectorPerpendicularToVector( Vector const &in, Vector *pvecOut ); + +//----------------------------------------------------------------------------- +// AngularImpulse +//----------------------------------------------------------------------------- +// AngularImpulse are exponetial maps (an axis scaled by a "twist" angle in degrees) +typedef Vector AngularImpulse; + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline AngularImpulse RandomAngularImpulse( float minVal, float maxVal ) +{ + AngularImpulse angImp; + angImp.Random( minVal, maxVal ); + return angImp; +} + +#endif + + +//----------------------------------------------------------------------------- +// Quaternion +//----------------------------------------------------------------------------- + +class RadianEuler; + +class Quaternion // same data-layout as engine's vec4_t, +{ // which is a vec_t[4] +public: + inline Quaternion(void) { + + // Initialize to NAN to catch errors +#ifdef _DEBUG +#ifdef VECTOR_PARANOIA + x = y = z = w = VEC_T_NAN; +#endif +#endif + } + inline Quaternion(vec_t ix, vec_t iy, vec_t iz, vec_t iw) : x(ix), y(iy), z(iz), w(iw) { } + inline Quaternion(RadianEuler const &angle); // evil auto type promotion!!! + + inline void Init(vec_t ix=0.0f, vec_t iy=0.0f, vec_t iz=0.0f, vec_t iw=0.0f) { x = ix; y = iy; z = iz; w = iw; } + + bool IsValid() const; + void Invalidate(); + + bool operator==( const Quaternion &src ) const; + bool operator!=( const Quaternion &src ) const; + + vec_t* Base() { return (vec_t*)this; } + const vec_t* Base() const { return (vec_t*)this; } + + // array access... + vec_t operator[](int i) const; + vec_t& operator[](int i); + + vec_t x, y, z, w; +}; + + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- +inline vec_t& Quaternion::operator[](int i) +{ + Assert( (i >= 0) && (i < 4) ); + return ((vec_t*)this)[i]; +} + +inline vec_t Quaternion::operator[](int i) const +{ + Assert( (i >= 0) && (i < 4) ); + return ((vec_t*)this)[i]; +} + + +//----------------------------------------------------------------------------- +// Equality test +//----------------------------------------------------------------------------- +inline bool Quaternion::operator==( const Quaternion &src ) const +{ + return ( x == src.x ) && ( y == src.y ) && ( z == src.z ) && ( w == src.w ); +} + +inline bool Quaternion::operator!=( const Quaternion &src ) const +{ + return !operator==( src ); +} + + +//----------------------------------------------------------------------------- +// Quaternion equality with tolerance +//----------------------------------------------------------------------------- +inline bool QuaternionsAreEqual( const Quaternion& src1, const Quaternion& src2, float tolerance ) +{ + if (FloatMakePositive(src1.x - src2.x) > tolerance) + return false; + if (FloatMakePositive(src1.y - src2.y) > tolerance) + return false; + if (FloatMakePositive(src1.z - src2.z) > tolerance) + return false; + return (FloatMakePositive(src1.w - src2.w) <= tolerance); +} + + +#if 0 +//----------------------------------------------------------------------------- +// Here's where we add all those lovely SSE optimized routines +//----------------------------------------------------------------------------- +class ALIGN16 QuaternionAligned : public Quaternion +{ +public: + inline QuaternionAligned(void) {}; + inline QuaternionAligned(vec_t X, vec_t Y, vec_t Z, vec_t W) + { + Init(X,Y,Z,W); + } + + operator Quaternion * () { return this; } + operator const Quaternion * () { return this; } + +#ifdef VECTOR_NO_SLOW_OPERATIONS + +private: + // No copy constructors allowed if we're in optimal mode + QuaternionAligned(const QuaternionAligned& vOther); + QuaternionAligned(const Quaternion &vOther); + +#else +public: + explicit QuaternionAligned(const Quaternion &vOther) + { + Init(vOther.x, vOther.y, vOther.z, vOther.w); + } + + QuaternionAligned& operator=(const Quaternion &vOther) + { + Init(vOther.x, vOther.y, vOther.z, vOther.w); + return *this; + } + + QuaternionAligned& operator=(const QuaternionAligned &vOther) + { + // we know we're aligned, so use simd + // we can't use the convenient abstract interface coz it gets declared later +#ifdef _X360 + XMStoreVector4A(Base(), XMLoadVector4A(vOther.Base())); +#elif _WIN32 + _mm_store_ps(Base(), _mm_load_ps( vOther.Base() )); +#else + Init(vOther.x, vOther.y, vOther.z, vOther.w); +#endif + return *this; + } + +#endif + + void* operator new[] ( size_t nSize) + { + return MemAlloc_AllocAligned(nSize, 16); + } + + void* operator new[] ( size_t nSize, const char *pFileName, int nLine) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + + void* operator new[] ( size_t nSize, int /*nBlockUse*/, const char *pFileName, int nLine) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + + void operator delete[] ( void* p) + { + MemAlloc_FreeAligned(p,true); + } + + void operator delete[] ( void* p, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } + + void operator delete[] ( void* p, int /*nBlockUse*/, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } + + // please don't allocate a single quaternion... + void* operator new ( size_t nSize ) + { + return MemAlloc_AllocAligned(nSize, 16); + } + void* operator new ( size_t nSize, const char *pFileName, int nLine ) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + void* operator new ( size_t nSize, int /*nBlockUse*/, const char *pFileName, int nLine ) + { + return MemAlloc_AllocAligned(nSize, 16); + //return MemAlloc_AllocAlignedFileLine(nSize, 16, pFileName, nLine); + } + void operator delete ( void* p) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p); + } + + void operator delete ( void* p, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } + + void operator delete ( void* p, int /*nBlockUse*/, const char *pFileName, int nLine) + { + MemAlloc_FreeAligned(p,true); + //MemAlloc_FreeAligned(p, pFileName, nLine); + } +} ALIGN16_POST; + +#endif + +//----------------------------------------------------------------------------- +// Radian Euler angle aligned to axis (NOT ROLL/PITCH/YAW) +//----------------------------------------------------------------------------- +class QAngle; +class RadianEuler +{ +public: + inline RadianEuler(void) { } + inline RadianEuler(vec_t X, vec_t Y, vec_t Z) { x = X; y = Y; z = Z; } + inline RadianEuler(Quaternion const &q); // evil auto type promotion!!! + inline RadianEuler(QAngle const &angles); // evil auto type promotion!!! + + // Initialization + inline void Init(vec_t ix=0.0f, vec_t iy=0.0f, vec_t iz=0.0f) { x = ix; y = iy; z = iz; } + + // conversion to qangle + QAngle ToQAngle( void ) const; + bool IsValid() const; + void Invalidate(); + + // array access... + vec_t operator[](int i) const; + vec_t& operator[](int i); + + vec_t x, y, z; +}; + + +extern void AngleQuaternion( RadianEuler const &angles, Quaternion &qt ); +extern void QuaternionAngles( Quaternion const &q, RadianEuler &angles ); +inline Quaternion::Quaternion(RadianEuler const &angle) +{ + AngleQuaternion( angle, *this ); +} + +inline bool Quaternion::IsValid() const +{ + return IsFinite(x) && IsFinite(y) && IsFinite(z) && IsFinite(w); +} + +inline void Quaternion::Invalidate() +{ +//#ifdef _DEBUG +//#ifdef VECTOR_PARANOIA + x = y = z = w = VEC_T_NAN; +//#endif +//#endif +} + +inline RadianEuler::RadianEuler(Quaternion const &q) +{ + QuaternionAngles( q, *this ); +} + +inline void VectorCopy( RadianEuler const& src, RadianEuler &dst ) +{ + CHECK_VALID(src); + dst.x = src.x; + dst.y = src.y; + dst.z = src.z; +} + +inline bool RadianEuler::IsValid() const +{ + return IsFinite(x) && IsFinite(y) && IsFinite(z); +} + +inline void RadianEuler::Invalidate() +{ +//#ifdef _DEBUG +//#ifdef VECTOR_PARANOIA + x = y = z = VEC_T_NAN; +//#endif +//#endif +} + + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- +inline vec_t& RadianEuler::operator[](int i) +{ + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; +} + +inline vec_t RadianEuler::operator[](int i) const +{ + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; +} + + +//----------------------------------------------------------------------------- +// Degree Euler QAngle pitch, yaw, roll +//----------------------------------------------------------------------------- +class QAngleByValue; + +class QAngle +{ +public: + // Members + vec_t x, y, z; + + // Construction/destruction + QAngle(void); + QAngle(vec_t X, vec_t Y, vec_t Z); +// QAngle(RadianEuler const &angles); // evil auto type promotion!!! + + // Allow pass-by-value + operator QAngleByValue &() { return *((QAngleByValue *)(this)); } + operator const QAngleByValue &() const { return *((const QAngleByValue *)(this)); } + + // Initialization + void Init(vec_t ix=0.0f, vec_t iy=0.0f, vec_t iz=0.0f); + void Random( vec_t minVal, vec_t maxVal ); + + // Got any nasty NAN's? + bool IsValid() const; + void Invalidate(); + + // array access... + vec_t operator[](int i) const; + vec_t& operator[](int i); + + // Base address... + vec_t* Base(); + vec_t const* Base() const; + + // equality + bool operator==(const QAngle& v) const; + bool operator!=(const QAngle& v) const; + + // arithmetic operations + QAngle& operator+=(const QAngle &v); + QAngle& operator-=(const QAngle &v); + QAngle& operator*=(float s); + QAngle& operator/=(float s); + + // Get the vector's magnitude. + vec_t Length() const; + vec_t LengthSqr() const; + + // negate the QAngle components + //void Negate(); + + // No assignment operators either... + QAngle& operator=( const QAngle& src ); + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // copy constructors + + // arithmetic operations + QAngle operator-(void) const; + + QAngle operator+(const QAngle& v) const; + QAngle operator-(const QAngle& v) const; + QAngle operator*(float fl) const; + QAngle operator/(float fl) const; +#else + +private: + // No copy constructors allowed if we're in optimal mode + QAngle(const QAngle& vOther); + +#endif +}; + +//----------------------------------------------------------------------------- +// Allows us to specifically pass the vector by value when we need to +//----------------------------------------------------------------------------- +class QAngleByValue : public QAngle +{ +public: + // Construction/destruction: + QAngleByValue(void) : QAngle() {} + QAngleByValue(vec_t X, vec_t Y, vec_t Z) : QAngle( X, Y, Z ) {} + QAngleByValue(const QAngleByValue& vOther) { *this = vOther; } +}; + + +inline void VectorAdd( const QAngle& a, const QAngle& b, QAngle& result ) +{ + CHECK_VALID(a); + CHECK_VALID(b); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; +} + +inline void VectorMA( const QAngle &start, float scale, const QAngle &direction, QAngle &dest ) +{ + CHECK_VALID(start); + CHECK_VALID(direction); + dest.x = start.x + scale * direction.x; + dest.y = start.y + scale * direction.y; + dest.z = start.z + scale * direction.z; +} + + +//----------------------------------------------------------------------------- +// constructors +//----------------------------------------------------------------------------- +inline QAngle::QAngle(void) +{ +#ifdef _DEBUG +#ifdef VECTOR_PARANOIA + // Initialize to NAN to catch errors + x = y = z = VEC_T_NAN; +#endif +#endif +} + +inline QAngle::QAngle(vec_t X, vec_t Y, vec_t Z) +{ + x = X; y = Y; z = Z; + CHECK_VALID(*this); +} + + +//----------------------------------------------------------------------------- +// initialization +//----------------------------------------------------------------------------- +inline void QAngle::Init( vec_t ix, vec_t iy, vec_t iz ) +{ + x = ix; y = iy; z = iz; + CHECK_VALID(*this); +} + +/* +inline void QAngle::Random( vec_t minVal, vec_t maxVal ) +{ + x = minVal + ((float)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + y = minVal + ((float)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + z = minVal + ((float)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + CHECK_VALID(*this); +} +*/ + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline QAngle RandomAngle( float minVal, float maxVal ) +{ + Vector random; + random.Random( minVal, maxVal ); + QAngle ret( random.x, random.y, random.z ); + return ret; +} + +#endif + + +inline RadianEuler::RadianEuler(QAngle const &angles) +{ + Init( + angles.z * 3.14159265358979323846f / 180.f, + angles.x * 3.14159265358979323846f / 180.f, + angles.y * 3.14159265358979323846f / 180.f ); +} + + + + +inline QAngle RadianEuler::ToQAngle( void) const +{ + return QAngle( + y * 180.f / 3.14159265358979323846f, + z * 180.f / 3.14159265358979323846f, + x * 180.f / 3.14159265358979323846f ); +} + + +//----------------------------------------------------------------------------- +// assignment +//----------------------------------------------------------------------------- +inline QAngle& QAngle::operator=(const QAngle &vOther) +{ + CHECK_VALID(vOther); + x=vOther.x; y=vOther.y; z=vOther.z; + return *this; +} + + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- +inline vec_t& QAngle::operator[](int i) +{ + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; +} + +inline vec_t QAngle::operator[](int i) const +{ + Assert( (i >= 0) && (i < 3) ); + return ((vec_t*)this)[i]; +} + + +//----------------------------------------------------------------------------- +// Base address... +//----------------------------------------------------------------------------- +inline vec_t* QAngle::Base() +{ + return (vec_t*)this; +} + +inline vec_t const* QAngle::Base() const +{ + return (vec_t const*)this; +} + + +//----------------------------------------------------------------------------- +// IsValid? +//----------------------------------------------------------------------------- +inline bool QAngle::IsValid() const +{ + return IsFinite(x) && IsFinite(y) && IsFinite(z); +} + +//----------------------------------------------------------------------------- +// Invalidate +//----------------------------------------------------------------------------- + +inline void QAngle::Invalidate() +{ +//#ifdef _DEBUG +//#ifdef VECTOR_PARANOIA + x = y = z = VEC_T_NAN; +//#endif +//#endif +} + +//----------------------------------------------------------------------------- +// comparison +//----------------------------------------------------------------------------- +inline bool QAngle::operator==( const QAngle& src ) const +{ + CHECK_VALID(src); + CHECK_VALID(*this); + return (src.x == x) && (src.y == y) && (src.z == z); +} + +inline bool QAngle::operator!=( const QAngle& src ) const +{ + CHECK_VALID(src); + CHECK_VALID(*this); + return (src.x != x) || (src.y != y) || (src.z != z); +} + + +//----------------------------------------------------------------------------- +// Copy +//----------------------------------------------------------------------------- +inline void VectorCopy( const QAngle& src, QAngle& dst ) +{ + CHECK_VALID(src); + dst.x = src.x; + dst.y = src.y; + dst.z = src.z; +} + + +//----------------------------------------------------------------------------- +// standard math operations +//----------------------------------------------------------------------------- +inline QAngle& QAngle::operator+=(const QAngle& v) +{ + CHECK_VALID(*this); + CHECK_VALID(v); + x+=v.x; y+=v.y; z += v.z; + return *this; +} + +inline QAngle& QAngle::operator-=(const QAngle& v) +{ + CHECK_VALID(*this); + CHECK_VALID(v); + x-=v.x; y-=v.y; z -= v.z; + return *this; +} + +inline QAngle& QAngle::operator*=(float fl) +{ + x *= fl; + y *= fl; + z *= fl; + CHECK_VALID(*this); + return *this; +} + +inline QAngle& QAngle::operator/=(float fl) +{ + Assert( fl != 0.0f ); + float oofl = 1.0f / fl; + x *= oofl; + y *= oofl; + z *= oofl; + CHECK_VALID(*this); + return *this; +} + + +//----------------------------------------------------------------------------- +// length +//----------------------------------------------------------------------------- +inline vec_t QAngle::Length( ) const +{ + CHECK_VALID(*this); + return (vec_t)FastSqrt( LengthSqr( ) ); +} + + +inline vec_t QAngle::LengthSqr( ) const +{ + CHECK_VALID(*this); + return x * x + y * y + z * z; +} + + +//----------------------------------------------------------------------------- +// Vector equality with tolerance +//----------------------------------------------------------------------------- +inline bool QAnglesAreEqual( const QAngle& src1, const QAngle& src2, float tolerance = 0.0f ) +{ + if (FloatMakePositive(src1.x - src2.x) > tolerance) + return false; + if (FloatMakePositive(src1.y - src2.y) > tolerance) + return false; + return (FloatMakePositive(src1.z - src2.z) <= tolerance); +} + + +//----------------------------------------------------------------------------- +// arithmetic operations (SLOW!!) +//----------------------------------------------------------------------------- +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline QAngle QAngle::operator-(void) const +{ + QAngle ret(-x,-y,-z); + return ret; +} + +inline QAngle QAngle::operator+(const QAngle& v) const +{ + QAngle res; + res.x = x + v.x; + res.y = y + v.y; + res.z = z + v.z; + return res; +} + +inline QAngle QAngle::operator-(const QAngle& v) const +{ + QAngle res; + res.x = x - v.x; + res.y = y - v.y; + res.z = z - v.z; + return res; +} + +inline QAngle QAngle::operator*(float fl) const +{ + QAngle res; + res.x = x * fl; + res.y = y * fl; + res.z = z * fl; + return res; +} + +inline QAngle QAngle::operator/(float fl) const +{ + QAngle res; + res.x = x / fl; + res.y = y / fl; + res.z = z / fl; + return res; +} + +inline QAngle operator*(float fl, const QAngle& v) +{ + QAngle ret( v * fl ); + return ret; +} + +#endif // VECTOR_NO_SLOW_OPERATIONS + + +//----------------------------------------------------------------------------- +// NOTE: These are not completely correct. The representations are not equivalent +// unless the QAngle represents a rotational impulse along a coordinate axis (x,y,z) +inline void QAngleToAngularImpulse( const QAngle &angles, AngularImpulse &impulse ) +{ + impulse.x = angles.z; + impulse.y = angles.x; + impulse.z = angles.y; +} + +inline void AngularImpulseToQAngle( const AngularImpulse &impulse, QAngle &angles ) +{ + angles.x = impulse.y; + angles.y = impulse.z; + angles.z = impulse.x; +} + +#if !defined( _X360 ) + +inline vec_t InvRSquared( const float* v ) +{ + return 1.0 / fpmax( (float)1.0, (float)(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) ); +} + +inline vec_t InvRSquared( const Vector &v ) +{ + return InvRSquared( v.Base() ); +} + +#else + +// call directly +inline float _VMX_InvRSquared( const Vector &v ) +{ + XMVECTOR xmV = XMVector3ReciprocalLength( XMLoadVector3( v.Base() ) ); + xmV = XMVector3Dot( xmV, xmV ); + return xmV.x; +} + +#define InvRSquared(x) _VMX_InvRSquared(x) + +#endif // _X360 + +#if !defined( _X360 ) + +// FIXME: Change this back to a #define once we get rid of the vec_t version +float VectorNormalize( Vector& v ); + +// FIXME: Obsolete version of VectorNormalize, once we remove all the friggin float*s +inline float VectorNormalize( float * v ) +{ + return VectorNormalize(*(reinterpret_cast(v))); +} + +#else + +// call directly +inline float _VMX_VectorNormalize( Vector &vec ) +{ + float mag = XMVector3Length( XMLoadVector3( vec.Base() ) ).x; + float den = 1.f / (mag + FLT_EPSILON ); + vec.x *= den; + vec.y *= den; + vec.z *= den; + return mag; +} +// FIXME: Change this back to a #define once we get rid of the vec_t version +inline float VectorNormalize( Vector& v ) +{ + return _VMX_VectorNormalize( v ); +} +// FIXME: Obsolete version of VectorNormalize, once we remove all the friggin float*s +inline float VectorNormalize( float *pV ) +{ + return _VMX_VectorNormalize(*(reinterpret_cast(pV))); +} + +#endif // _X360 + +#if !defined( _X360 ) +inline void VectorNormalizeFast (Vector& vec) +{ + float ool = FastRSqrt( FLT_EPSILON + vec.x * vec.x + vec.y * vec.y + vec.z * vec.z ); + + vec.x *= ool; + vec.y *= ool; + vec.z *= ool; +} +#else + +// call directly +inline void VectorNormalizeFast( Vector &vec ) +{ + XMVECTOR xmV = XMVector3LengthEst( XMLoadVector3( vec.Base() ) ); + float den = 1.f / (xmV.x + FLT_EPSILON); + vec.x *= den; + vec.y *= den; + vec.z *= den; +} + +#endif // _X360 + +inline vec_t Vector::NormalizeInPlace() +{ + return VectorNormalize( *this ); +} + +inline Vector Vector::Normalized() const +{ + Vector norm = *this; + VectorNormalize( norm ); + return norm; +} + +inline bool Vector::IsLengthGreaterThan( float val ) const +{ + return LengthSqr() > val*val; +} + +inline bool Vector::IsLengthLessThan( float val ) const +{ + return LengthSqr() < val*val; +} + + +//-------------------------------------------------------------------------------------------------- + +// forward declarations +class Vector; +// class Vector2D; + +//========================================================= +// 4D Vector4D +//========================================================= + +class Vector4D +{ +public: + // Members + vec_t x, y, z, w; + + // Construction/destruction + Vector4D(void); + Vector4D(vec_t X, vec_t Y, vec_t Z, vec_t W); + Vector4D(const float *pFloat); + + // Initialization + void Init(vec_t ix=0.0f, vec_t iy=0.0f, vec_t iz=0.0f, vec_t iw=0.0f); + void Init( const Vector& src, vec_t iw=0.0f ); + + // Got any nasty NAN's? + bool IsValid() const; + + // array access... + vec_t operator[](int i) const; + vec_t& operator[](int i); + + // Base address... + inline vec_t* Base(); + inline vec_t const* Base() const; + + // Cast to Vector and Vector2D... + Vector& AsVector3D(); + Vector const& AsVector3D() const; + + //Vector2D& AsVector2D(); + //Vector2D const& AsVector2D() const; + + // Initialization methods + void Random( vec_t minVal, vec_t maxVal ); + + // equality + bool operator==(const Vector4D& v) const; + bool operator!=(const Vector4D& v) const; + + // arithmetic operations + Vector4D& operator+=(const Vector4D &v); + Vector4D& operator-=(const Vector4D &v); + Vector4D& operator*=(const Vector4D &v); + Vector4D& operator*=(float s); + Vector4D& operator/=(const Vector4D &v); + Vector4D& operator/=(float s); + + Vector4D operator-( void ) const; + Vector4D operator*( float fl ) const; + Vector4D operator/( float fl ) const; + Vector4D operator*( const Vector4D& v ) const; + Vector4D operator+( const Vector4D& v ) const; + Vector4D operator-( const Vector4D& v ) const; + + // negate the Vector4D components + void Negate(); + + // Get the Vector4D's magnitude. + vec_t Length() const; + + // Get the Vector4D's magnitude squared. + vec_t LengthSqr(void) const; + + // return true if this vector is (0,0,0,0) within tolerance + bool IsZero( float tolerance = 0.01f ) const + { + return (x > -tolerance && x < tolerance && + y > -tolerance && y < tolerance && + z > -tolerance && z < tolerance && + w > -tolerance && w < tolerance); + } + + // Get the distance from this Vector4D to the other one. + vec_t DistTo(const Vector4D &vOther) const; + + // Get the distance from this Vector4D to the other one squared. + vec_t DistToSqr(const Vector4D &vOther) const; + + // Copy + void CopyToArray(float* rgfl) const; + + // Multiply, add, and assign to this (ie: *this = a + b * scalar). This + // is about 12% faster than the actual Vector4D equation (because it's done per-component + // rather than per-Vector4D). + void MulAdd(Vector4D const& a, Vector4D const& b, float scalar); + + // Dot product. + vec_t Dot(Vector4D const& vOther) const; + + // No copy constructors allowed if we're in optimal mode +#ifdef VECTOR_NO_SLOW_OPERATIONS +private: +#else +public: +#endif + Vector4D(Vector4D const& vOther); + + // No assignment operators either... + Vector4D& operator=( Vector4D const& src ); +}; + +const Vector4D vec4_origin( 0.0f, 0.0f, 0.0f, 0.0f ); +const Vector4D vec4_invalid( FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX ); + +#if 0 +//----------------------------------------------------------------------------- +// SSE optimized routines +//----------------------------------------------------------------------------- + +class ALIGN16 Vector4DAligned : public Vector4D +{ +public: + Vector4DAligned(void) {} + Vector4DAligned( vec_t X, vec_t Y, vec_t Z, vec_t W ); + + inline void Set( vec_t X, vec_t Y, vec_t Z, vec_t W ); + inline void InitZero( void ); + + inline __m128 &AsM128() { return *(__m128*)&x; } + inline const __m128 &AsM128() const { return *(const __m128*)&x; } + +private: + // No copy constructors allowed if we're in optimal mode + Vector4DAligned( Vector4DAligned const& vOther ); + + // No assignment operators either... + Vector4DAligned& operator=( Vector4DAligned const& src ); +} ALIGN16_POST; + +#endif + +//----------------------------------------------------------------------------- +// Vector4D related operations +//----------------------------------------------------------------------------- + +// Vector4D clear +void Vector4DClear( Vector4D& a ); + +// Copy +void Vector4DCopy( Vector4D const& src, Vector4D& dst ); + +// Vector4D arithmetic +void Vector4DAdd( Vector4D const& a, Vector4D const& b, Vector4D& result ); +void Vector4DSubtract( Vector4D const& a, Vector4D const& b, Vector4D& result ); +void Vector4DMultiply( Vector4D const& a, vec_t b, Vector4D& result ); +void Vector4DMultiply( Vector4D const& a, Vector4D const& b, Vector4D& result ); +void Vector4DDivide( Vector4D const& a, vec_t b, Vector4D& result ); +void Vector4DDivide( Vector4D const& a, Vector4D const& b, Vector4D& result ); +void Vector4DMA( Vector4D const& start, float s, Vector4D const& dir, Vector4D& result ); + +// Vector4DAligned arithmetic +//void Vector4DMultiplyAligned( Vector4DAligned const& a, vec_t b, Vector4DAligned& result ); + + +#define Vector4DExpand( v ) (v).x, (v).y, (v).z, (v).w + +// Normalization +vec_t Vector4DNormalize( Vector4D& v ); + +// Length +vec_t Vector4DLength( Vector4D const& v ); + +// Dot Product +vec_t DotProduct4D(Vector4D const& a, Vector4D const& b); + +// Linearly interpolate between two vectors +void Vector4DLerp(Vector4D const& src1, Vector4D const& src2, vec_t t, Vector4D& dest ); + + +//----------------------------------------------------------------------------- +// +// Inlined Vector4D methods +// +//----------------------------------------------------------------------------- + + +//----------------------------------------------------------------------------- +// constructors +//----------------------------------------------------------------------------- + +inline Vector4D::Vector4D(void) +{ +#ifdef _DEBUG + // Initialize to NAN to catch errors + x = y = z = w = VEC_T_NAN; +#endif +} + +inline Vector4D::Vector4D(vec_t X, vec_t Y, vec_t Z, vec_t W ) +{ + x = X; y = Y; z = Z; w = W; + Assert( IsValid() ); +} + +inline Vector4D::Vector4D(const float *pFloat) +{ + Assert( pFloat ); + x = pFloat[0]; y = pFloat[1]; z = pFloat[2]; w = pFloat[3]; + Assert( IsValid() ); +} + + +//----------------------------------------------------------------------------- +// copy constructor +//----------------------------------------------------------------------------- + +inline Vector4D::Vector4D(const Vector4D &vOther) +{ + Assert( vOther.IsValid() ); + x = vOther.x; y = vOther.y; z = vOther.z; w = vOther.w; +} + +//----------------------------------------------------------------------------- +// initialization +//----------------------------------------------------------------------------- +inline void Vector4D::Init( vec_t ix, vec_t iy, vec_t iz, vec_t iw ) +{ + x = ix; y = iy; z = iz; w = iw; + Assert( IsValid() ); +} + +inline void Vector4D::Init( const Vector& src, vec_t iw ) +{ + x = src.x; y = src.y; z = src.z; w = iw; + Assert( IsValid() ); +} + + +/* +inline void Vector4D::Random( vec_t minVal, vec_t maxVal ) +{ + x = minVal + ((vec_t)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + y = minVal + ((vec_t)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + z = minVal + ((vec_t)rand() / VALVE_RAND_MAX) * (maxVal - minVal); + w = minVal + ((vec_t)rand() / VALVE_RAND_MAX) * (maxVal - minVal); +} +*/ + +inline void Vector4DClear( Vector4D& a ) +{ + a.x = a.y = a.z = a.w = 0.0f; +} + +//----------------------------------------------------------------------------- +// assignment +//----------------------------------------------------------------------------- + +inline Vector4D& Vector4D::operator=(const Vector4D &vOther) +{ + Assert( vOther.IsValid() ); + x=vOther.x; y=vOther.y; z=vOther.z; w=vOther.w; + return *this; +} + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- + +inline vec_t& Vector4D::operator[](int i) +{ + Assert( (i >= 0) && (i < 4) ); + return ((vec_t*)this)[i]; +} + +inline vec_t Vector4D::operator[](int i) const +{ + Assert( (i >= 0) && (i < 4) ); + return ((vec_t*)this)[i]; +} + +//----------------------------------------------------------------------------- +// Cast to Vector and Vector2D... +//----------------------------------------------------------------------------- + +inline Vector& Vector4D::AsVector3D() +{ + return *(Vector*)this; +} + +inline Vector const& Vector4D::AsVector3D() const +{ + return *(Vector const*)this; +} + +//inline Vector2D& Vector4D::AsVector2D() +//{ +// return *(Vector2D*)this; +//} +// +//inline Vector2D const& Vector4D::AsVector2D() const +//{ +// return *(Vector2D const*)this; +//} + +//----------------------------------------------------------------------------- +// Base address... +//----------------------------------------------------------------------------- + +inline vec_t* Vector4D::Base() +{ + return (vec_t*)this; +} + +inline vec_t const* Vector4D::Base() const +{ + return (vec_t const*)this; +} + +//----------------------------------------------------------------------------- +// IsValid? +//----------------------------------------------------------------------------- + +inline bool Vector4D::IsValid() const +{ + return IsFinite(x) && IsFinite(y) && IsFinite(z) && IsFinite(w); +} + +//----------------------------------------------------------------------------- +// comparison +//----------------------------------------------------------------------------- + +inline bool Vector4D::operator==( Vector4D const& src ) const +{ + Assert( src.IsValid() && IsValid() ); + return (src.x == x) && (src.y == y) && (src.z == z) && (src.w == w); +} + +inline bool Vector4D::operator!=( Vector4D const& src ) const +{ + Assert( src.IsValid() && IsValid() ); + return (src.x != x) || (src.y != y) || (src.z != z) || (src.w != w); +} + + +//----------------------------------------------------------------------------- +// Copy +//----------------------------------------------------------------------------- + +inline void Vector4DCopy( Vector4D const& src, Vector4D& dst ) +{ + Assert( src.IsValid() ); + dst.x = src.x; + dst.y = src.y; + dst.z = src.z; + dst.w = src.w; +} + +inline void Vector4D::CopyToArray(float* rgfl) const +{ + Assert( IsValid() ); + Assert( rgfl ); + rgfl[0] = x; rgfl[1] = y; rgfl[2] = z; rgfl[3] = w; +} + +//----------------------------------------------------------------------------- +// standard math operations +//----------------------------------------------------------------------------- + +inline void Vector4D::Negate() +{ + Assert( IsValid() ); + x = -x; y = -y; z = -z; w = -w; +} + +inline Vector4D& Vector4D::operator+=(const Vector4D& v) +{ + Assert( IsValid() && v.IsValid() ); + x+=v.x; y+=v.y; z += v.z; w += v.w; + return *this; +} + +inline Vector4D& Vector4D::operator-=(const Vector4D& v) +{ + Assert( IsValid() && v.IsValid() ); + x-=v.x; y-=v.y; z -= v.z; w -= v.w; + return *this; +} + +inline Vector4D& Vector4D::operator*=(float fl) +{ + x *= fl; + y *= fl; + z *= fl; + w *= fl; + Assert( IsValid() ); + return *this; +} + +inline Vector4D& Vector4D::operator*=(Vector4D const& v) +{ + x *= v.x; + y *= v.y; + z *= v.z; + w *= v.w; + Assert( IsValid() ); + return *this; +} + +inline Vector4D Vector4D::operator-(void) const +{ + return Vector4D(-x,-y,-z,-w); +} + +inline Vector4D Vector4D::operator+(const Vector4D& v) const +{ + Vector4D res; + Vector4DAdd( *this, v, res ); + return res; +} + +inline Vector4D Vector4D::operator-(const Vector4D& v) const +{ + Vector4D res; + Vector4DSubtract( *this, v, res ); + return res; +} + + +inline Vector4D Vector4D::operator*(float fl) const +{ + Vector4D res; + Vector4DMultiply( *this, fl, res ); + return res; +} + +inline Vector4D Vector4D::operator*(const Vector4D& v) const +{ + Vector4D res; + Vector4DMultiply( *this, v, res ); + return res; +} + +inline Vector4D Vector4D::operator/(float fl) const +{ + Vector4D res; + Vector4DDivide( *this, fl, res ); + return res; +} + +inline Vector4D operator*( float fl, const Vector4D& v ) +{ + return v * fl; +} + +inline Vector4D& Vector4D::operator/=(float fl) +{ + Assert( fl != 0.0f ); + float oofl = 1.0f / fl; + x *= oofl; + y *= oofl; + z *= oofl; + w *= oofl; + Assert( IsValid() ); + return *this; +} + +inline Vector4D& Vector4D::operator/=(Vector4D const& v) +{ + Assert( v.x != 0.0f && v.y != 0.0f && v.z != 0.0f && v.w != 0.0f ); + x /= v.x; + y /= v.y; + z /= v.z; + w /= v.w; + Assert( IsValid() ); + return *this; +} + +inline void Vector4DAdd( Vector4D const& a, Vector4D const& b, Vector4D& c ) +{ + Assert( a.IsValid() && b.IsValid() ); + c.x = a.x + b.x; + c.y = a.y + b.y; + c.z = a.z + b.z; + c.w = a.w + b.w; +} + +inline void Vector4DSubtract( Vector4D const& a, Vector4D const& b, Vector4D& c ) +{ + Assert( a.IsValid() && b.IsValid() ); + c.x = a.x - b.x; + c.y = a.y - b.y; + c.z = a.z - b.z; + c.w = a.w - b.w; +} + +inline void Vector4DMultiply( Vector4D const& a, vec_t b, Vector4D& c ) +{ + Assert( a.IsValid() && IsFinite(b) ); + c.x = a.x * b; + c.y = a.y * b; + c.z = a.z * b; + c.w = a.w * b; +} + +inline void Vector4DMultiply( Vector4D const& a, Vector4D const& b, Vector4D& c ) +{ + Assert( a.IsValid() && b.IsValid() ); + c.x = a.x * b.x; + c.y = a.y * b.y; + c.z = a.z * b.z; + c.w = a.w * b.w; +} + +inline void Vector4DDivide( Vector4D const& a, vec_t b, Vector4D& c ) +{ + Assert( a.IsValid() ); + Assert( b != 0.0f ); + vec_t oob = 1.0f / b; + c.x = a.x * oob; + c.y = a.y * oob; + c.z = a.z * oob; + c.w = a.w * oob; +} + +inline void Vector4DDivide( Vector4D const& a, Vector4D const& b, Vector4D& c ) +{ + Assert( a.IsValid() ); + Assert( (b.x != 0.0f) && (b.y != 0.0f) && (b.z != 0.0f) && (b.w != 0.0f) ); + c.x = a.x / b.x; + c.y = a.y / b.y; + c.z = a.z / b.z; + c.w = a.w / b.w; +} + +inline void Vector4DMA( Vector4D const& start, float s, Vector4D const& dir, Vector4D& result ) +{ + Assert( start.IsValid() && IsFinite(s) && dir.IsValid() ); + result.x = start.x + s*dir.x; + result.y = start.y + s*dir.y; + result.z = start.z + s*dir.z; + result.w = start.w + s*dir.w; +} + +// FIXME: Remove +// For backwards compatability +inline void Vector4D::MulAdd(Vector4D const& a, Vector4D const& b, float scalar) +{ + x = a.x + b.x * scalar; + y = a.y + b.y * scalar; + z = a.z + b.z * scalar; + w = a.w + b.w * scalar; +} + +inline void Vector4DLerp(const Vector4D& src1, const Vector4D& src2, vec_t t, Vector4D& dest ) +{ + dest[0] = src1[0] + (src2[0] - src1[0]) * t; + dest[1] = src1[1] + (src2[1] - src1[1]) * t; + dest[2] = src1[2] + (src2[2] - src1[2]) * t; + dest[3] = src1[3] + (src2[3] - src1[3]) * t; +} + +//----------------------------------------------------------------------------- +// dot, cross +//----------------------------------------------------------------------------- + +inline vec_t DotProduct4D(const Vector4D& a, const Vector4D& b) +{ + Assert( a.IsValid() && b.IsValid() ); + return( a.x*b.x + a.y*b.y + a.z*b.z + a.w*b.w ); +} + +// for backwards compatability +inline vec_t Vector4D::Dot( Vector4D const& vOther ) const +{ + return DotProduct4D( *this, vOther ); +} + + +//----------------------------------------------------------------------------- +// length +//----------------------------------------------------------------------------- + +inline vec_t Vector4DLength( Vector4D const& v ) +{ + Assert( v.IsValid() ); + return (vec_t)FastSqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w); +} + +inline vec_t Vector4D::LengthSqr(void) const +{ + Assert( IsValid() ); + return (x*x + y*y + z*z + w*w); +} + +inline vec_t Vector4D::Length(void) const +{ + return Vector4DLength( *this ); +} + + +//----------------------------------------------------------------------------- +// Normalization +//----------------------------------------------------------------------------- + +// FIXME: Can't use until we're un-macroed in mathlib.h +inline vec_t Vector4DNormalize( Vector4D& v ) +{ + Assert( v.IsValid() ); + vec_t l = v.Length(); + if (l != 0.0f) + { + v /= l; + } + else + { + v.x = v.y = v.z = v.w = 0.0f; + } + return l; +} + +//----------------------------------------------------------------------------- +// Get the distance from this Vector4D to the other one +//----------------------------------------------------------------------------- + +inline vec_t Vector4D::DistTo(const Vector4D &vOther) const +{ + Vector4D delta; + Vector4DSubtract( *this, vOther, delta ); + return delta.Length(); +} + +inline vec_t Vector4D::DistToSqr(const Vector4D &vOther) const +{ + Vector4D delta; + Vector4DSubtract( *this, vOther, delta ); + return delta.LengthSqr(); +} + + +#if 0 +//----------------------------------------------------------------------------- +// Vector4DAligned routines +//----------------------------------------------------------------------------- + +inline Vector4DAligned::Vector4DAligned( vec_t X, vec_t Y, vec_t Z, vec_t W ) +{ + x = X; y = Y; z = Z; w = W; + Assert( IsValid() ); +} + +inline void Vector4DAligned::Set( vec_t X, vec_t Y, vec_t Z, vec_t W ) +{ + x = X; y = Y; z = Z; w = W; + Assert( IsValid() ); +} + +inline void Vector4DAligned::InitZero( void ) +{ +#if !defined( _X360 ) + this->AsM128() = _mm_set1_ps( 0.0f ); +#else + this->AsM128() = __vspltisw( 0 ); +#endif + Assert( IsValid() ); +} + +inline void Vector4DMultiplyAligned( Vector4DAligned const& a, Vector4DAligned const& b, Vector4DAligned& c ) +{ + Assert( a.IsValid() && b.IsValid() ); +#if !defined( _X360 ) + c.x = a.x * b.x; + c.y = a.y * b.y; + c.z = a.z * b.z; + c.w = a.w * b.w; +#else + c.AsM128() = __vmulfp( a.AsM128(), b.AsM128() ); +#endif +} + +inline void Vector4DWeightMAD( vec_t w, Vector4DAligned const& vInA, Vector4DAligned& vOutA, Vector4DAligned const& vInB, Vector4DAligned& vOutB ) +{ + Assert( vInA.IsValid() && vInB.IsValid() && IsFinite(w) ); + +#if !defined( _X360 ) + vOutA.x += vInA.x * w; + vOutA.y += vInA.y * w; + vOutA.z += vInA.z * w; + vOutA.w += vInA.w * w; + + vOutB.x += vInB.x * w; + vOutB.y += vInB.y * w; + vOutB.z += vInB.z * w; + vOutB.w += vInB.w * w; +#else + __vector4 temp; + + temp = __lvlx( &w, 0 ); + temp = __vspltw( temp, 0 ); + + vOutA.AsM128() = __vmaddfp( vInA.AsM128(), temp, vOutA.AsM128() ); + vOutB.AsM128() = __vmaddfp( vInB.AsM128(), temp, vOutB.AsM128() ); +#endif +} + +inline void Vector4DWeightMADSSE( vec_t w, Vector4DAligned const& vInA, Vector4DAligned& vOutA, Vector4DAligned const& vInB, Vector4DAligned& vOutB ) +{ + Assert( vInA.IsValid() && vInB.IsValid() && IsFinite(w) ); + +#if !defined( _X360 ) + // Replicate scalar float out to 4 components + __m128 packed = _mm_set1_ps( w ); + + // 4D SSE Vector MAD + vOutA.AsM128() = _mm_add_ps( vOutA.AsM128(), _mm_mul_ps( vInA.AsM128(), packed ) ); + vOutB.AsM128() = _mm_add_ps( vOutB.AsM128(), _mm_mul_ps( vInB.AsM128(), packed ) ); +#else + __vector4 temp; + + temp = __lvlx( &w, 0 ); + temp = __vspltw( temp, 0 ); + + vOutA.AsM128() = __vmaddfp( vInA.AsM128(), temp, vOutA.AsM128() ); + vOutB.AsM128() = __vmaddfp( vInB.AsM128(), temp, vOutB.AsM128() ); +#endif +} + +#endif + +//-------------------------------------------------------------------------------------------------- + +typedef int SideType; + +// Used to represent sides of things like planes. +#define SIDE_FRONT 0 +#define SIDE_BACK 1 +#define SIDE_ON 2 + +#define VP_EPSILON 0.01f + + +class VPlane +{ +public: + VPlane(); + VPlane(const Vector &vNormal, vec_t dist); + + void Init(const Vector &vNormal, vec_t dist); + + // Return the distance from the point to the plane. + vec_t DistTo(const Vector &vVec) const; + + // Copy. + VPlane& operator=(const VPlane &thePlane); + + // Returns SIDE_ON, SIDE_FRONT, or SIDE_BACK. + // The epsilon for SIDE_ON can be passed in. + SideType GetPointSide(const Vector &vPoint, vec_t sideEpsilon=VP_EPSILON) const; + + // Returns SIDE_FRONT or SIDE_BACK. + SideType GetPointSideExact(const Vector &vPoint) const; + + // Classify the box with respect to the plane. + // Returns SIDE_ON, SIDE_FRONT, or SIDE_BACK + SideType BoxOnPlaneSide(const Vector &vMin, const Vector &vMax) const; + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // Flip the plane. + VPlane Flip(); + + // Get a point on the plane (normal*dist). + Vector GetPointOnPlane() const; + + // Snap the specified point to the plane (along the plane's normal). + Vector SnapPointToPlane(const Vector &vPoint) const; +#endif + +public: + Vector m_Normal; + vec_t m_Dist; + +#ifdef VECTOR_NO_SLOW_OPERATIONS +private: + // No copy constructors allowed if we're in optimal mode + VPlane(const VPlane& vOther); +#endif +}; + + +//----------------------------------------------------------------------------- +// Inlines. +//----------------------------------------------------------------------------- +inline VPlane::VPlane() +{ +} + +inline VPlane::VPlane(const Vector &vNormal, vec_t dist) +{ + m_Normal = vNormal; + m_Dist = dist; +} + +inline void VPlane::Init(const Vector &vNormal, vec_t dist) +{ + m_Normal = vNormal; + m_Dist = dist; +} + +inline vec_t VPlane::DistTo(const Vector &vVec) const +{ + return vVec.Dot(m_Normal) - m_Dist; +} + +inline VPlane& VPlane::operator=(const VPlane &thePlane) +{ + m_Normal = thePlane.m_Normal; + m_Dist = thePlane.m_Dist; + return *this; +} + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline VPlane VPlane::Flip() +{ + return VPlane(-m_Normal, -m_Dist); +} + +inline Vector VPlane::GetPointOnPlane() const +{ + return m_Normal * m_Dist; +} + +inline Vector VPlane::SnapPointToPlane(const Vector &vPoint) const +{ + return vPoint - m_Normal * DistTo(vPoint); +} + +#endif + +inline SideType VPlane::GetPointSide(const Vector &vPoint, vec_t sideEpsilon) const +{ + vec_t fDist; + + fDist = DistTo(vPoint); + if(fDist >= sideEpsilon) + return SIDE_FRONT; + else if(fDist <= -sideEpsilon) + return SIDE_BACK; + else + return SIDE_ON; +} + +inline SideType VPlane::GetPointSideExact(const Vector &vPoint) const +{ + return DistTo(vPoint) > 0.0f ? SIDE_FRONT : SIDE_BACK; +} + + +// BUGBUG: This should either simply use the implementation in mathlib or cease to exist. +// mathlib implementation is much more efficient. Check to see that VPlane isn't used in +// performance critical code. +inline SideType VPlane::BoxOnPlaneSide(const Vector &vMin, const Vector &vMax) const +{ + int i, firstSide, side; + TableVector vPoints[8] = + { + { vMin.x, vMin.y, vMin.z }, + { vMin.x, vMin.y, vMax.z }, + { vMin.x, vMax.y, vMax.z }, + { vMin.x, vMax.y, vMin.z }, + + { vMax.x, vMin.y, vMin.z }, + { vMax.x, vMin.y, vMax.z }, + { vMax.x, vMax.y, vMax.z }, + { vMax.x, vMax.y, vMin.z }, + }; + + firstSide = GetPointSideExact(vPoints[0]); + for(i=1; i < 8; i++) + { + side = GetPointSideExact(vPoints[i]); + + // Does the box cross the plane? + if(side != firstSide) + return SIDE_ON; + } + + // Ok, they're all on the same side, return that. + return firstSide; +} + +//-------------------------------------------------------------------------------------------------- + + +//struct cplane_t; + +struct matrix3x4_t +{ + matrix3x4_t() {} + matrix3x4_t( + float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23 ) + { + m_flMatVal[0][0] = m00; m_flMatVal[0][1] = m01; m_flMatVal[0][2] = m02; m_flMatVal[0][3] = m03; + m_flMatVal[1][0] = m10; m_flMatVal[1][1] = m11; m_flMatVal[1][2] = m12; m_flMatVal[1][3] = m13; + m_flMatVal[2][0] = m20; m_flMatVal[2][1] = m21; m_flMatVal[2][2] = m22; m_flMatVal[2][3] = m23; + } + + //----------------------------------------------------------------------------- + // Creates a matrix where the X axis = forward + // the Y axis = left, and the Z axis = up + //----------------------------------------------------------------------------- + void Init( const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin ) + { + m_flMatVal[0][0] = xAxis.x; m_flMatVal[0][1] = yAxis.x; m_flMatVal[0][2] = zAxis.x; m_flMatVal[0][3] = vecOrigin.x; + m_flMatVal[1][0] = xAxis.y; m_flMatVal[1][1] = yAxis.y; m_flMatVal[1][2] = zAxis.y; m_flMatVal[1][3] = vecOrigin.y; + m_flMatVal[2][0] = xAxis.z; m_flMatVal[2][1] = yAxis.z; m_flMatVal[2][2] = zAxis.z; m_flMatVal[2][3] = vecOrigin.z; + } + + //----------------------------------------------------------------------------- + // Creates a matrix where the X axis = forward + // the Y axis = left, and the Z axis = up + //----------------------------------------------------------------------------- + matrix3x4_t( const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin ) + { + Init( xAxis, yAxis, zAxis, vecOrigin ); + } + + inline void Invalidate( void ) + { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 4; j++) + { + m_flMatVal[i][j] = VEC_T_NAN; + } + } + } + + float *operator[]( int i ) { Assert(( i >= 0 ) && ( i < 3 )); return m_flMatVal[i]; } + const float *operator[]( int i ) const { Assert(( i >= 0 ) && ( i < 3 )); return m_flMatVal[i]; } + float *Base() { return &m_flMatVal[0][0]; } + const float *Base() const { return &m_flMatVal[0][0]; } + + float m_flMatVal[3][4]; +}; + + + +class VMatrix +{ +public: + + VMatrix(); + VMatrix( + vec_t m00, vec_t m01, vec_t m02, vec_t m03, + vec_t m10, vec_t m11, vec_t m12, vec_t m13, + vec_t m20, vec_t m21, vec_t m22, vec_t m23, + vec_t m30, vec_t m31, vec_t m32, vec_t m33 + ); + + // Creates a matrix where the X axis = forward + // the Y axis = left, and the Z axis = up + VMatrix( const Vector& forward, const Vector& left, const Vector& up ); + + // Construct from a 3x4 matrix + VMatrix( const matrix3x4_t& matrix3x4 ); + + // Set the values in the matrix. + void Init( + vec_t m00, vec_t m01, vec_t m02, vec_t m03, + vec_t m10, vec_t m11, vec_t m12, vec_t m13, + vec_t m20, vec_t m21, vec_t m22, vec_t m23, + vec_t m30, vec_t m31, vec_t m32, vec_t m33 + ); + + + // Initialize from a 3x4 + void Init( const matrix3x4_t& matrix3x4 ); + + // array access + inline float* operator[](int i) + { + return m[i]; + } + + inline const float* operator[](int i) const + { + return m[i]; + } + + // Get a pointer to m[0][0] + inline float *Base() + { + return &m[0][0]; + } + + inline const float *Base() const + { + return &m[0][0]; + } + + void SetLeft(const Vector &vLeft); + void SetUp(const Vector &vUp); + void SetForward(const Vector &vForward); + + void GetBasisVectors(Vector &vForward, Vector &vLeft, Vector &vUp) const; + void SetBasisVectors(const Vector &vForward, const Vector &vLeft, const Vector &vUp); + + // Get/set the translation. + Vector & GetTranslation( Vector &vTrans ) const; + void SetTranslation(const Vector &vTrans); + + void PreTranslate(const Vector &vTrans); + void PostTranslate(const Vector &vTrans); + + matrix3x4_t& As3x4(); + const matrix3x4_t& As3x4() const; + void CopyFrom3x4( const matrix3x4_t &m3x4 ); + void Set3x4( matrix3x4_t& matrix3x4 ) const; + + bool operator==( const VMatrix& src ) const; + bool operator!=( const VMatrix& src ) const { return !( *this == src ); } + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // Access the basis vectors. + Vector GetLeft() const; + Vector GetUp() const; + Vector GetForward() const; + Vector GetTranslation() const; +#endif + + +// Matrix->vector operations. +public: + // Multiply by a 3D vector (same as operator*). + void V3Mul(const Vector &vIn, Vector &vOut) const; + + // Multiply by a 4D vector. + void V4Mul(const Vector4D &vIn, Vector4D &vOut) const; + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // Applies the rotation (ignores translation in the matrix). (This just calls VMul3x3). + Vector ApplyRotation(const Vector &vVec) const; + + // Multiply by a vector (divides by w, assumes input w is 1). + Vector operator*(const Vector &vVec) const; + + // Multiply by the upper 3x3 part of the matrix (ie: only apply rotation). + Vector VMul3x3(const Vector &vVec) const; + + // Apply the inverse (transposed) rotation (only works on pure rotation matrix) + Vector VMul3x3Transpose(const Vector &vVec) const; + + // Multiply by the upper 3 rows. + Vector VMul4x3(const Vector &vVec) const; + + // Apply the inverse (transposed) transformation (only works on pure rotation/translation) + Vector VMul4x3Transpose(const Vector &vVec) const; +#endif + + +// Matrix->plane operations. +public: + // Transform the plane. The matrix can only contain translation and rotation. + void TransformPlane( const VPlane &inPlane, VPlane &outPlane ) const; + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // Just calls TransformPlane and returns the result. + VPlane operator*(const VPlane &thePlane) const; +#endif + +// Matrix->matrix operations. +public: + + VMatrix& operator=(const VMatrix &mOther); + + // Multiply two matrices (out = this * vm). + void MatrixMul( const VMatrix &vm, VMatrix &out ) const; + + // Add two matrices. + const VMatrix& operator+=(const VMatrix &other); + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // Just calls MatrixMul and returns the result. + VMatrix operator*(const VMatrix &mOther) const; + + // Add/Subtract two matrices. + VMatrix operator+(const VMatrix &other) const; + VMatrix operator-(const VMatrix &other) const; + + // Negation. + VMatrix operator-() const; + + // Return inverse matrix. Be careful because the results are undefined + // if the matrix doesn't have an inverse (ie: InverseGeneral returns false). + VMatrix operator~() const; +#endif + +// Matrix operations. +public: + // Set to identity. + void Identity(); + + bool IsIdentity() const; + + // Setup a matrix for origin and angles. + void SetupMatrixOrgAngles( const Vector &origin, const QAngle &vAngles ); + + // General inverse. This may fail so check the return! + bool InverseGeneral(VMatrix &vInverse) const; + + // Does a fast inverse, assuming the matrix only contains translation and rotation. + void InverseTR( VMatrix &mRet ) const; + + // Usually used for debug checks. Returns true if the upper 3x3 contains + // unit vectors and they are all orthogonal. + bool IsRotationMatrix() const; + +#ifndef VECTOR_NO_SLOW_OPERATIONS + // This calls the other InverseTR and returns the result. + VMatrix InverseTR() const; + + // Get the scale of the matrix's basis vectors. + Vector GetScale() const; + + // (Fast) multiply by a scaling matrix setup from vScale. + VMatrix Scale(const Vector &vScale); + + // Normalize the basis vectors. + VMatrix NormalizeBasisVectors() const; + + // Transpose. + VMatrix Transpose() const; + + // Transpose upper-left 3x3. + VMatrix Transpose3x3() const; +#endif + +public: + // The matrix. + vec_t m[4][4]; +}; + + + +//----------------------------------------------------------------------------- +// Helper functions. +//----------------------------------------------------------------------------- + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +// Setup an identity matrix. +VMatrix SetupMatrixIdentity(); + +// Setup as a scaling matrix. +VMatrix SetupMatrixScale(const Vector &vScale); + +// Setup a translation matrix. +VMatrix SetupMatrixTranslation(const Vector &vTranslation); + +// Setup a matrix to reflect around the plane. +VMatrix SetupMatrixReflection(const VPlane &thePlane); + +// Setup a matrix to project from vOrigin onto thePlane. +VMatrix SetupMatrixProjection(const Vector &vOrigin, const VPlane &thePlane); + +// Setup a matrix to rotate the specified amount around the specified axis. +VMatrix SetupMatrixAxisRot(const Vector &vAxis, vec_t fDegrees); + +// Setup a matrix from euler angles. Just sets identity and calls MatrixAngles. +VMatrix SetupMatrixAngles(const QAngle &vAngles); + +// Setup a matrix for origin and angles. +VMatrix SetupMatrixOrgAngles(const Vector &origin, const QAngle &vAngles); + +#endif + +#define VMatToString(mat) (static_cast(CFmtStr("[ (%f, %f, %f), (%f, %f, %f), (%f, %f, %f), (%f, %f, %f) ]", mat.m[0][0], mat.m[0][1], mat.m[0][2], mat.m[0][3], mat.m[1][0], mat.m[1][1], mat.m[1][2], mat.m[1][3], mat.m[2][0], mat.m[2][1], mat.m[2][2], mat.m[2][3], mat.m[3][0], mat.m[3][1], mat.m[3][2], mat.m[3][3] ))) // ** Note: this generates a temporary, don't hold reference! + +//----------------------------------------------------------------------------- +// Returns the point at the intersection on the 3 planes. +// Returns false if it can't be solved (2 or more planes are parallel). +//----------------------------------------------------------------------------- +bool PlaneIntersection( const VPlane &vp1, const VPlane &vp2, const VPlane &vp3, Vector &vOut ); + + +//----------------------------------------------------------------------------- +// These methods are faster. Use them if you want faster code +//----------------------------------------------------------------------------- +void MatrixSetIdentity( VMatrix &dst ); +void MatrixTranspose( const VMatrix& src, VMatrix& dst ); +void MatrixCopy( const VMatrix& src, VMatrix& dst ); +void MatrixMultiply( const VMatrix& src1, const VMatrix& src2, VMatrix& dst ); + +// Accessors +void MatrixGetColumn( const VMatrix &src, int nCol, Vector *pColumn ); +void MatrixSetColumn( VMatrix &src, int nCol, const Vector &column ); +void MatrixGetRow( const VMatrix &src, int nCol, Vector *pColumn ); +void MatrixSetRow( VMatrix &src, int nCol, const Vector &column ); + +// Vector3DMultiply treats src2 as if it's a direction vector +void Vector3DMultiply( const VMatrix& src1, const Vector& src2, Vector& dst ); + +// Vector3DMultiplyPosition treats src2 as if it's a point (adds the translation) +inline void Vector3DMultiplyPosition( const VMatrix& src1, const VectorByValue src2, Vector& dst ); + +// Vector3DMultiplyPositionProjective treats src2 as if it's a point +// and does the perspective divide at the end +void Vector3DMultiplyPositionProjective( const VMatrix& src1, const Vector &src2, Vector& dst ); + +// Vector3DMultiplyPosition treats src2 as if it's a direction +// and does the perspective divide at the end +// NOTE: src1 had better be an inverse transpose to use this correctly +void Vector3DMultiplyProjective( const VMatrix& src1, const Vector &src2, Vector& dst ); + +void Vector4DMultiply( const VMatrix& src1, const Vector4D& src2, Vector4D& dst ); + +// Same as Vector4DMultiply except that src2 has an implicit W of 1 +void Vector4DMultiplyPosition( const VMatrix& src1, const Vector &src2, Vector4D& dst ); + +// Multiplies the vector by the transpose of the matrix +void Vector3DMultiplyTranspose( const VMatrix& src1, const Vector& src2, Vector& dst ); +void Vector4DMultiplyTranspose( const VMatrix& src1, const Vector4D& src2, Vector4D& dst ); + +// Transform a plane +// void MatrixTransformPlane( const VMatrix &src, const cplane_t &inPlane, cplane_t &outPlane ); + +// Transform a plane that has an axis-aligned normal +// void MatrixTransformAxisAlignedPlane( const VMatrix &src, int nDim, float flSign, float flDist, cplane_t &outPlane ); + +void MatrixBuildTranslation( VMatrix& dst, float x, float y, float z ); +void MatrixBuildTranslation( VMatrix& dst, const Vector &translation ); + +inline void MatrixTranslate( VMatrix& dst, const Vector &translation ) +{ + VMatrix matTranslation, temp; + MatrixBuildTranslation( matTranslation, translation ); + MatrixMultiply( dst, matTranslation, temp ); + dst = temp; +} + + +void MatrixBuildRotationAboutAxis( VMatrix& dst, const Vector& vAxisOfRot, float angleDegrees ); +void MatrixBuildRotateZ( VMatrix& dst, float angleDegrees ); + +inline void MatrixRotate( VMatrix& dst, const Vector& vAxisOfRot, float angleDegrees ) +{ + VMatrix rotation, temp; + MatrixBuildRotationAboutAxis( rotation, vAxisOfRot, angleDegrees ); + MatrixMultiply( dst, rotation, temp ); + dst = temp; +} + +// Builds a rotation matrix that rotates one direction vector into another +void MatrixBuildRotation( VMatrix &dst, const Vector& initialDirection, const Vector& finalDirection ); + +// Builds a scale matrix +void MatrixBuildScale( VMatrix &dst, float x, float y, float z ); +void MatrixBuildScale( VMatrix &dst, const Vector& scale ); + +// Build a perspective matrix. +// zNear and zFar are assumed to be positive. +// You end up looking down positive Z, X is to the right, Y is up. +// X range: [0..1] +// Y range: [0..1] +// Z range: [0..1] +void MatrixBuildPerspective( VMatrix &dst, float fovX, float fovY, float zNear, float zFar ); + +//----------------------------------------------------------------------------- +// Given a projection matrix, take the extremes of the space in transformed into world space and +// get a bounding box. +//----------------------------------------------------------------------------- +void CalculateAABBFromProjectionMatrix( const VMatrix &worldToVolume, Vector *pMins, Vector *pMaxs ); + +//----------------------------------------------------------------------------- +// Given a projection matrix, take the extremes of the space in transformed into world space and +// get a bounding sphere. +//----------------------------------------------------------------------------- +void CalculateSphereFromProjectionMatrix( const VMatrix &worldToVolume, Vector *pCenter, float *pflRadius ); + +//----------------------------------------------------------------------------- +// Given an inverse projection matrix, take the extremes of the space in transformed into world space and +// get a bounding box. +//----------------------------------------------------------------------------- +void CalculateAABBFromProjectionMatrixInverse( const VMatrix &volumeToWorld, Vector *pMins, Vector *pMaxs ); + +//----------------------------------------------------------------------------- +// Given an inverse projection matrix, take the extremes of the space in transformed into world space and +// get a bounding sphere. +//----------------------------------------------------------------------------- +void CalculateSphereFromProjectionMatrixInverse( const VMatrix &volumeToWorld, Vector *pCenter, float *pflRadius ); + +//----------------------------------------------------------------------------- +// Calculate frustum planes given a clip->world space transform. +//----------------------------------------------------------------------------- +// void FrustumPlanesFromMatrix( const VMatrix &clipToWorld, Frustum_t &frustum ); + +//----------------------------------------------------------------------------- +// Setup a matrix from euler angles. +//----------------------------------------------------------------------------- +void MatrixFromAngles( const QAngle& vAngles, VMatrix& dst ); + +//----------------------------------------------------------------------------- +// Creates euler angles from a matrix +//----------------------------------------------------------------------------- +void MatrixToAngles( const VMatrix& src, QAngle& vAngles ); + +//----------------------------------------------------------------------------- +// Does a fast inverse, assuming the matrix only contains translation and rotation. +//----------------------------------------------------------------------------- +void MatrixInverseTR( const VMatrix& src, VMatrix &dst ); + +//----------------------------------------------------------------------------- +// Inverts any matrix at all +//----------------------------------------------------------------------------- +bool MatrixInverseGeneral(const VMatrix& src, VMatrix& dst); + +//----------------------------------------------------------------------------- +// Computes the inverse transpose +//----------------------------------------------------------------------------- +void MatrixInverseTranspose( const VMatrix& src, VMatrix& dst ); + + + +//----------------------------------------------------------------------------- +// VMatrix inlines. +//----------------------------------------------------------------------------- +inline VMatrix::VMatrix() +{ +} + +inline VMatrix::VMatrix( + vec_t m00, vec_t m01, vec_t m02, vec_t m03, + vec_t m10, vec_t m11, vec_t m12, vec_t m13, + vec_t m20, vec_t m21, vec_t m22, vec_t m23, + vec_t m30, vec_t m31, vec_t m32, vec_t m33) +{ + Init( + m00, m01, m02, m03, + m10, m11, m12, m13, + m20, m21, m22, m23, + m30, m31, m32, m33 + ); +} + + +inline VMatrix::VMatrix( const matrix3x4_t& matrix3x4 ) +{ + Init( matrix3x4 ); +} + + +//----------------------------------------------------------------------------- +// Creates a matrix where the X axis = forward +// the Y axis = left, and the Z axis = up +//----------------------------------------------------------------------------- +inline VMatrix::VMatrix( const Vector& xAxis, const Vector& yAxis, const Vector& zAxis ) +{ + Init( + xAxis.x, yAxis.x, zAxis.x, 0.0f, + xAxis.y, yAxis.y, zAxis.y, 0.0f, + xAxis.z, yAxis.z, zAxis.z, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f + ); +} + + +inline void VMatrix::Init( + vec_t m00, vec_t m01, vec_t m02, vec_t m03, + vec_t m10, vec_t m11, vec_t m12, vec_t m13, + vec_t m20, vec_t m21, vec_t m22, vec_t m23, + vec_t m30, vec_t m31, vec_t m32, vec_t m33 + ) +{ + m[0][0] = m00; + m[0][1] = m01; + m[0][2] = m02; + m[0][3] = m03; + + m[1][0] = m10; + m[1][1] = m11; + m[1][2] = m12; + m[1][3] = m13; + + m[2][0] = m20; + m[2][1] = m21; + m[2][2] = m22; + m[2][3] = m23; + + m[3][0] = m30; + m[3][1] = m31; + m[3][2] = m32; + m[3][3] = m33; +} + + +//----------------------------------------------------------------------------- +// Initialize from a 3x4 +//----------------------------------------------------------------------------- +inline void VMatrix::Init( const matrix3x4_t& matrix3x4 ) +{ + memcpy(m, matrix3x4.Base(), sizeof( matrix3x4_t ) ); + + m[3][0] = 0.0f; + m[3][1] = 0.0f; + m[3][2] = 0.0f; + m[3][3] = 1.0f; +} + + +//----------------------------------------------------------------------------- +// Methods related to the basis vectors of the matrix +//----------------------------------------------------------------------------- + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline Vector VMatrix::GetForward() const +{ + return Vector(m[0][0], m[1][0], m[2][0]); +} + +inline Vector VMatrix::GetLeft() const +{ + return Vector(m[0][1], m[1][1], m[2][1]); +} + +inline Vector VMatrix::GetUp() const +{ + return Vector(m[0][2], m[1][2], m[2][2]); +} + +#endif + +inline void VMatrix::SetForward(const Vector &vForward) +{ + m[0][0] = vForward.x; + m[1][0] = vForward.y; + m[2][0] = vForward.z; +} + +inline void VMatrix::SetLeft(const Vector &vLeft) +{ + m[0][1] = vLeft.x; + m[1][1] = vLeft.y; + m[2][1] = vLeft.z; +} + +inline void VMatrix::SetUp(const Vector &vUp) +{ + m[0][2] = vUp.x; + m[1][2] = vUp.y; + m[2][2] = vUp.z; +} + +inline void VMatrix::GetBasisVectors(Vector &vForward, Vector &vLeft, Vector &vUp) const +{ + vForward.Init( m[0][0], m[1][0], m[2][0] ); + vLeft.Init( m[0][1], m[1][1], m[2][1] ); + vUp.Init( m[0][2], m[1][2], m[2][2] ); +} + +inline void VMatrix::SetBasisVectors(const Vector &vForward, const Vector &vLeft, const Vector &vUp) +{ + SetForward(vForward); + SetLeft(vLeft); + SetUp(vUp); +} + + +//----------------------------------------------------------------------------- +// Methods related to the translation component of the matrix +//----------------------------------------------------------------------------- +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline Vector VMatrix::GetTranslation() const +{ + return Vector(m[0][3], m[1][3], m[2][3]); +} + +#endif + +inline Vector& VMatrix::GetTranslation( Vector &vTrans ) const +{ + vTrans.x = m[0][3]; + vTrans.y = m[1][3]; + vTrans.z = m[2][3]; + return vTrans; +} + +inline void VMatrix::SetTranslation(const Vector &vTrans) +{ + m[0][3] = vTrans.x; + m[1][3] = vTrans.y; + m[2][3] = vTrans.z; +} + + +//----------------------------------------------------------------------------- +// appply translation to this matrix in the input space +//----------------------------------------------------------------------------- +inline void VMatrix::PreTranslate(const Vector &vTrans) +{ + Vector tmp; + Vector3DMultiplyPosition( *this, vTrans, tmp ); + m[0][3] = tmp.x; + m[1][3] = tmp.y; + m[2][3] = tmp.z; +} + + +//----------------------------------------------------------------------------- +// appply translation to this matrix in the output space +//----------------------------------------------------------------------------- +inline void VMatrix::PostTranslate(const Vector &vTrans) +{ + m[0][3] += vTrans.x; + m[1][3] += vTrans.y; + m[2][3] += vTrans.z; +} + +inline const matrix3x4_t& VMatrix::As3x4() const +{ + return *((const matrix3x4_t*)this); +} + +inline matrix3x4_t& VMatrix::As3x4() +{ + return *((matrix3x4_t*)this); +} + +inline void VMatrix::CopyFrom3x4( const matrix3x4_t &m3x4 ) +{ + memcpy( m, m3x4.Base(), sizeof( matrix3x4_t ) ); + m[3][0] = m[3][1] = m[3][2] = 0; + m[3][3] = 1; +} + +inline void VMatrix::Set3x4( matrix3x4_t& matrix3x4 ) const +{ + memcpy(matrix3x4.Base(), m, sizeof( matrix3x4_t ) ); +} + + +//----------------------------------------------------------------------------- +// Matrix math operations +//----------------------------------------------------------------------------- +inline const VMatrix& VMatrix::operator+=(const VMatrix &other) +{ + for(int i=0; i < 4; i++) + { + for(int j=0; j < 4; j++) + { + m[i][j] += other.m[i][j]; + } + } + + return *this; +} + + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline VMatrix VMatrix::operator+(const VMatrix &other) const +{ + VMatrix ret; + for(int i=0; i < 16; i++) + { + ((float*)ret.m)[i] = ((float*)m)[i] + ((float*)other.m)[i]; + } + return ret; +} + +inline VMatrix VMatrix::operator-(const VMatrix &other) const +{ + VMatrix ret; + + for(int i=0; i < 4; i++) + { + for(int j=0; j < 4; j++) + { + ret.m[i][j] = m[i][j] - other.m[i][j]; + } + } + + return ret; +} + +inline VMatrix VMatrix::operator-() const +{ + VMatrix ret; + for( int i=0; i < 16; i++ ) + { + ((float*)ret.m)[i] = ((float*)m)[i]; + } + return ret; +} + +#endif // VECTOR_NO_SLOW_OPERATIONS + + +//----------------------------------------------------------------------------- +// Vector transformation +//----------------------------------------------------------------------------- + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline Vector VMatrix::operator*(const Vector &vVec) const +{ + Vector vRet; + vRet.x = m[0][0]*vVec.x + m[0][1]*vVec.y + m[0][2]*vVec.z + m[0][3]; + vRet.y = m[1][0]*vVec.x + m[1][1]*vVec.y + m[1][2]*vVec.z + m[1][3]; + vRet.z = m[2][0]*vVec.x + m[2][1]*vVec.y + m[2][2]*vVec.z + m[2][3]; + + return vRet; +} + +inline Vector VMatrix::VMul4x3(const Vector &vVec) const +{ + Vector vResult; + Vector3DMultiplyPosition( *this, vVec, vResult ); + return vResult; +} + + +inline Vector VMatrix::VMul4x3Transpose(const Vector &vVec) const +{ + Vector tmp = vVec; + tmp.x -= m[0][3]; + tmp.y -= m[1][3]; + tmp.z -= m[2][3]; + + return Vector( + m[0][0]*tmp.x + m[1][0]*tmp.y + m[2][0]*tmp.z, + m[0][1]*tmp.x + m[1][1]*tmp.y + m[2][1]*tmp.z, + m[0][2]*tmp.x + m[1][2]*tmp.y + m[2][2]*tmp.z + ); +} + +inline Vector VMatrix::VMul3x3(const Vector &vVec) const +{ + return Vector( + m[0][0]*vVec.x + m[0][1]*vVec.y + m[0][2]*vVec.z, + m[1][0]*vVec.x + m[1][1]*vVec.y + m[1][2]*vVec.z, + m[2][0]*vVec.x + m[2][1]*vVec.y + m[2][2]*vVec.z + ); +} + +inline Vector VMatrix::VMul3x3Transpose(const Vector &vVec) const +{ + return Vector( + m[0][0]*vVec.x + m[1][0]*vVec.y + m[2][0]*vVec.z, + m[0][1]*vVec.x + m[1][1]*vVec.y + m[2][1]*vVec.z, + m[0][2]*vVec.x + m[1][2]*vVec.y + m[2][2]*vVec.z + ); +} + +#endif // VECTOR_NO_SLOW_OPERATIONS + + +inline void VMatrix::V3Mul(const Vector &vIn, Vector &vOut) const +{ + vec_t rw; + + rw = 1.0f / (m[3][0]*vIn.x + m[3][1]*vIn.y + m[3][2]*vIn.z + m[3][3]); + vOut.x = (m[0][0]*vIn.x + m[0][1]*vIn.y + m[0][2]*vIn.z + m[0][3]) * rw; + vOut.y = (m[1][0]*vIn.x + m[1][1]*vIn.y + m[1][2]*vIn.z + m[1][3]) * rw; + vOut.z = (m[2][0]*vIn.x + m[2][1]*vIn.y + m[2][2]*vIn.z + m[2][3]) * rw; +} + +inline void VMatrix::V4Mul(const Vector4D &vIn, Vector4D &vOut) const +{ + vOut[0] = m[0][0]*vIn[0] + m[0][1]*vIn[1] + m[0][2]*vIn[2] + m[0][3]*vIn[3]; + vOut[1] = m[1][0]*vIn[0] + m[1][1]*vIn[1] + m[1][2]*vIn[2] + m[1][3]*vIn[3]; + vOut[2] = m[2][0]*vIn[0] + m[2][1]*vIn[1] + m[2][2]*vIn[2] + m[2][3]*vIn[3]; + vOut[3] = m[3][0]*vIn[0] + m[3][1]*vIn[1] + m[3][2]*vIn[2] + m[3][3]*vIn[3]; +} + + +//----------------------------------------------------------------------------- +// Plane transformation +//----------------------------------------------------------------------------- +inline void VMatrix::TransformPlane( const VPlane &inPlane, VPlane &outPlane ) const +{ + Vector vTrans; + Vector3DMultiply( *this, inPlane.m_Normal, outPlane.m_Normal ); + outPlane.m_Dist = inPlane.m_Dist * DotProduct( outPlane.m_Normal, outPlane.m_Normal ); + outPlane.m_Dist += DotProduct( outPlane.m_Normal, GetTranslation( vTrans ) ); +} + + +//----------------------------------------------------------------------------- +// Other random stuff +//----------------------------------------------------------------------------- +inline void VMatrix::Identity() +{ + MatrixSetIdentity( *this ); +} + + +inline bool VMatrix::IsIdentity() const +{ + return + m[0][0] == 1.0f && m[0][1] == 0.0f && m[0][2] == 0.0f && m[0][3] == 0.0f && + m[1][0] == 0.0f && m[1][1] == 1.0f && m[1][2] == 0.0f && m[1][3] == 0.0f && + m[2][0] == 0.0f && m[2][1] == 0.0f && m[2][2] == 1.0f && m[2][3] == 0.0f && + m[3][0] == 0.0f && m[3][1] == 0.0f && m[3][2] == 0.0f && m[3][3] == 1.0f; +} + +#ifndef VECTOR_NO_SLOW_OPERATIONS + +inline Vector VMatrix::ApplyRotation(const Vector &vVec) const +{ + return VMul3x3(vVec); +} + +inline VMatrix VMatrix::operator~() const +{ + VMatrix mRet; + InverseGeneral(mRet); + return mRet; +} + +#endif + + +//----------------------------------------------------------------------------- +// Accessors +//----------------------------------------------------------------------------- +inline void MatrixGetColumn( const VMatrix &src, int nCol, Vector *pColumn ) +{ + Assert( (nCol >= 0) && (nCol <= 3) ); + + pColumn->x = src[0][nCol]; + pColumn->y = src[1][nCol]; + pColumn->z = src[2][nCol]; +} + +inline void MatrixSetColumn( VMatrix &src, int nCol, const Vector &column ) +{ + Assert( (nCol >= 0) && (nCol <= 3) ); + + src.m[0][nCol] = column.x; + src.m[1][nCol] = column.y; + src.m[2][nCol] = column.z; +} + +inline void MatrixGetRow( const VMatrix &src, int nRow, Vector *pRow ) +{ + Assert( (nRow >= 0) && (nRow <= 3) ); + *pRow = *(Vector*)src[nRow]; +} + +inline void MatrixSetRow( VMatrix &dst, int nRow, const Vector &row ) +{ + Assert( (nRow >= 0) && (nRow <= 3) ); + *(Vector*)dst[nRow] = row; +} + + +//----------------------------------------------------------------------------- +// Vector3DMultiplyPosition treats src2 as if it's a point (adds the translation) +//----------------------------------------------------------------------------- +// NJS: src2 is passed in as a full vector rather than a reference to prevent the need +// for 2 branches and a potential copy in the body. (ie, handling the case when the src2 +// reference is the same as the dst reference ). +inline void Vector3DMultiplyPosition( const VMatrix& src1, const VectorByValue src2, Vector& dst ) +{ + dst[0] = src1[0][0] * src2.x + src1[0][1] * src2.y + src1[0][2] * src2.z + src1[0][3]; + dst[1] = src1[1][0] * src2.x + src1[1][1] * src2.y + src1[1][2] * src2.z + src1[1][3]; + dst[2] = src1[2][0] * src2.x + src1[2][1] * src2.y + src1[2][2] * src2.z + src1[2][3]; +} + + +#if 0 +//----------------------------------------------------------------------------- +// Transform a plane that has an axis-aligned normal +//----------------------------------------------------------------------------- +inline void MatrixTransformAxisAlignedPlane( const VMatrix &src, int nDim, float flSign, float flDist, cplane_t &outPlane ) +{ + // See MatrixTransformPlane in the .cpp file for an explanation of the algorithm. + MatrixGetColumn( src, nDim, &outPlane.normal ); + outPlane.normal *= flSign; + outPlane.dist = flDist * DotProduct( outPlane.normal, outPlane.normal ); + + // NOTE: Writing this out by hand because it doesn't inline (inline depth isn't large enough) + // This should read outPlane.dist += DotProduct( outPlane.normal, src.GetTranslation ); + outPlane.dist += outPlane.normal.x * src.m[0][3] + outPlane.normal.y * src.m[1][3] + outPlane.normal.z * src.m[2][3]; +} +#endif + + +//----------------------------------------------------------------------------- +// Matrix equality test +//----------------------------------------------------------------------------- +inline bool MatricesAreEqual( const VMatrix &src1, const VMatrix &src2, float flTolerance ) +{ + for ( int i = 0; i < 3; ++i ) + { + for ( int j = 0; j < 3; ++j ) + { + if ( fabs( src1[i][j] - src2[i][j] ) > flTolerance ) + return false; + } + } + return true; +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +void MatrixBuildOrtho( VMatrix& dst, double left, double top, double right, double bottom, double zNear, double zFar ); +void MatrixBuildPerspectiveX( VMatrix& dst, double flFovX, double flAspect, double flZNear, double flZFar ); +void MatrixBuildPerspectiveOffCenterX( VMatrix& dst, double flFovX, double flAspect, double flZNear, double flZFar, double bottom, double top, double left, double right ); + +inline void MatrixOrtho( VMatrix& dst, double left, double top, double right, double bottom, double zNear, double zFar ) +{ + VMatrix mat; + MatrixBuildOrtho( mat, left, top, right, bottom, zNear, zFar ); + + VMatrix temp; + MatrixMultiply( dst, mat, temp ); + dst = temp; +} + +inline void MatrixPerspectiveX( VMatrix& dst, double flFovX, double flAspect, double flZNear, double flZFar ) +{ + VMatrix mat; + MatrixBuildPerspectiveX( mat, flFovX, flAspect, flZNear, flZFar ); + + VMatrix temp; + MatrixMultiply( dst, mat, temp ); + dst = temp; +} + +inline void MatrixPerspectiveOffCenterX( VMatrix& dst, double flFovX, double flAspect, double flZNear, double flZFar, double bottom, double top, double left, double right ) +{ + VMatrix mat; + MatrixBuildPerspectiveOffCenterX( mat, flFovX, flAspect, flZNear, flZFar, bottom, top, left, right ); + + VMatrix temp; + MatrixMultiply( dst, mat, temp ); + dst = temp; +} + +#endif // MATHLITE_H diff --git a/GameGuru Core/SDK/Steamworks SDK/glmgr/readme.txt b/GameGuru Core/SDK/Steamworks SDK/glmgr/readme.txt new file mode 100644 index 0000000..55902b5 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/glmgr/readme.txt @@ -0,0 +1,11 @@ +================================================================ + +Copyright © 1996-2011, Valve Corporation, All rights reserved. + +================================================================ + +OSX DirectX to OpenGL Conversion Library + +Contains all support files required to assist in converting DirectX applications to OpenGL on OSX. For reference, +this library can be enabled in the Steamworks Example by building with the compile time flag DX9MODE=1. + diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamapplist.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamapplist.h new file mode 100644 index 0000000..e6726c1 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamapplist.h @@ -0,0 +1,63 @@ +//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to app data in Steam +// +//============================================================================= + +#ifndef ISTEAMAPPLIST_H +#define ISTEAMAPPLIST_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" +#include "steamtypes.h" + +//----------------------------------------------------------------------------- +// Purpose: This is a restricted interface that can only be used by previously approved apps, +// contact your Steam Account Manager if you believe you need access to this API. +// This interface lets you detect installed apps for the local Steam client, useful for debugging tools +// to offer lists of apps to debug via Steam. +//----------------------------------------------------------------------------- +class ISteamAppList +{ +public: + virtual uint32 GetNumInstalledApps() = 0; + virtual uint32 GetInstalledApps( AppId_t *pvecAppID, uint32 unMaxAppIDs ) = 0; + + virtual int GetAppName( AppId_t nAppID, char *pchName, int cchNameMax ) = 0; // returns -1 if no name was found + virtual int GetAppInstallDir( AppId_t nAppID, char *pchDirectory, int cchNameMax ) = 0; // returns -1 if no dir was found + + virtual int GetAppBuildId( AppId_t nAppID ) = 0; // return the buildid of this app, may change at any time based on backend updates to the game +}; + +#define STEAMAPPLIST_INTERFACE_VERSION "STEAMAPPLIST_INTERFACE_VERSION001" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + +//--------------------------------------------------------------------------------- +// Purpose: Sent when a new app is installed +//--------------------------------------------------------------------------------- +DEFINE_CALLBACK( SteamAppInstalled_t, k_iSteamAppListCallbacks + 1 ); + CALLBACK_MEMBER( 0, AppId_t, m_nAppID ) // ID of the app that installs +END_DEFINE_CALLBACK_1() + + +//--------------------------------------------------------------------------------- +// Purpose: Sent when an app is uninstalled +//--------------------------------------------------------------------------------- +DEFINE_CALLBACK( SteamAppUninstalled_t, k_iSteamAppListCallbacks + 2 ); + CALLBACK_MEMBER( 0, AppId_t, m_nAppID ) // ID of the app that installs +END_DEFINE_CALLBACK_1() + + +#pragma pack( pop ) +#endif // ISTEAMAPPLIST_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamapps.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamapps.h new file mode 100644 index 0000000..0700583 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamapps.h @@ -0,0 +1,154 @@ +//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to app data in Steam +// +//============================================================================= + +#ifndef ISTEAMAPPS_H +#define ISTEAMAPPS_H +#ifdef _WIN32 +#pragma once +#endif + +const int k_cubAppProofOfPurchaseKeyMax = 64; // max bytes of a legacy cd key we support + + +//----------------------------------------------------------------------------- +// Purpose: interface to app data +//----------------------------------------------------------------------------- +class ISteamApps +{ +public: + virtual bool BIsSubscribed() = 0; + virtual bool BIsLowViolence() = 0; + virtual bool BIsCybercafe() = 0; + virtual bool BIsVACBanned() = 0; + virtual const char *GetCurrentGameLanguage() = 0; + virtual const char *GetAvailableGameLanguages() = 0; + + // only use this member if you need to check ownership of another game related to yours, a demo for example + virtual bool BIsSubscribedApp( AppId_t appID ) = 0; + + // Takes AppID of DLC and checks if the user owns the DLC & if the DLC is installed + virtual bool BIsDlcInstalled( AppId_t appID ) = 0; + + // returns the Unix time of the purchase of the app + virtual uint32 GetEarliestPurchaseUnixTime( AppId_t nAppID ) = 0; + + // Checks if the user is subscribed to the current app through a free weekend + // This function will return false for users who have a retail or other type of license + // Before using, please ask your Valve technical contact how to package and secure your free weekened + virtual bool BIsSubscribedFromFreeWeekend() = 0; + + // Returns the number of DLC pieces for the running app + virtual int GetDLCCount() = 0; + + // Returns metadata for DLC by index, of range [0, GetDLCCount()] + virtual bool BGetDLCDataByIndex( int iDLC, AppId_t *pAppID, bool *pbAvailable, char *pchName, int cchNameBufferSize ) = 0; + + // Install/Uninstall control for optional DLC + virtual void InstallDLC( AppId_t nAppID ) = 0; + virtual void UninstallDLC( AppId_t nAppID ) = 0; + + // Request cd-key for yourself or owned DLC. If you are interested in this + // data then make sure you provide us with a list of valid keys to be distributed + // to users when they purchase the game, before the game ships. + // You'll receive an AppProofOfPurchaseKeyResponse_t callback when + // the key is available (which may be immediately). + virtual void RequestAppProofOfPurchaseKey( AppId_t nAppID ) = 0; + + virtual bool GetCurrentBetaName( char *pchName, int cchNameBufferSize ) = 0; // returns current beta branch name, 'public' is the default branch + virtual bool MarkContentCorrupt( bool bMissingFilesOnly ) = 0; // signal Steam that game files seems corrupt or missing + virtual uint32 GetInstalledDepots( AppId_t appID, DepotId_t *pvecDepots, uint32 cMaxDepots ) = 0; // return installed depots in mount order + + // returns current app install folder for AppID, returns folder name length + virtual uint32 GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchFolderBufferSize ) = 0; + virtual bool BIsAppInstalled( AppId_t appID ) = 0; // returns true if that app is installed (not necessarily owned) + + virtual CSteamID GetAppOwner() = 0; // returns the SteamID of the original owner. If different from current user, it's borrowed + + // Returns the associated launch param if the game is run via steam://run///?param1=value1;param2=value2;param3=value3 etc. + // Parameter names starting with the character '@' are reserved for internal use and will always return and empty string. + // Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game, + // but it is advised that you not param names beginning with an underscore for your own features. + virtual const char *GetLaunchQueryParam( const char *pchKey ) = 0; + + // get download progress for optional DLC + virtual bool GetDlcDownloadProgress( AppId_t nAppID, uint64 *punBytesDownloaded, uint64 *punBytesTotal ) = 0; + + // return the buildid of this app, may change at any time based on backend updates to the game + virtual int GetAppBuildId() = 0; +#ifdef _PS3 + // Result returned in a RegisterActivationCodeResponse_t callresult + virtual SteamAPICall_t RegisterActivationCode( const char *pchActivationCode ) = 0; +#endif +}; + +#define STEAMAPPS_INTERFACE_VERSION "STEAMAPPS_INTERFACE_VERSION007" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif +//----------------------------------------------------------------------------- +// Purpose: posted after the user gains ownership of DLC & that DLC is installed +//----------------------------------------------------------------------------- +struct DlcInstalled_t +{ + enum { k_iCallback = k_iSteamAppsCallbacks + 5 }; + AppId_t m_nAppID; // AppID of the DLC +}; + + +//----------------------------------------------------------------------------- +// Purpose: possible results when registering an activation code +//----------------------------------------------------------------------------- +enum ERegisterActivationCodeResult +{ + k_ERegisterActivationCodeResultOK = 0, + k_ERegisterActivationCodeResultFail = 1, + k_ERegisterActivationCodeResultAlreadyRegistered = 2, + k_ERegisterActivationCodeResultTimeout = 3, + k_ERegisterActivationCodeAlreadyOwned = 4, +}; + + +//----------------------------------------------------------------------------- +// Purpose: response to RegisterActivationCode() +//----------------------------------------------------------------------------- +struct RegisterActivationCodeResponse_t +{ + enum { k_iCallback = k_iSteamAppsCallbacks + 8 }; + ERegisterActivationCodeResult m_eResult; + uint32 m_unPackageRegistered; // package that was registered. Only set on success +}; + +//----------------------------------------------------------------------------- +// Purpose: response to RegisterActivationCode() +//----------------------------------------------------------------------------- +struct AppProofOfPurchaseKeyResponse_t +{ + enum { k_iCallback = k_iSteamAppsCallbacks + 13 }; + EResult m_eResult; + uint32 m_nAppID; + char m_rgchKey[ k_cubAppProofOfPurchaseKeyMax ]; +}; + +//--------------------------------------------------------------------------------- +// Purpose: posted after the user gains executes a steam url with query parameters +// such as steam://run///?param1=value1;param2=value2;param3=value3; etc +// while the game is already running. The new params can be queried +// with GetLaunchQueryParam. +//--------------------------------------------------------------------------------- +struct NewLaunchQueryParameters_t +{ + enum { k_iCallback = k_iSteamAppsCallbacks + 14 }; +}; + + +#pragma pack( pop ) +#endif // ISTEAMAPPS_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamappticket.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamappticket.h new file mode 100644 index 0000000..21fb9e1 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamappticket.h @@ -0,0 +1,28 @@ +//====== Copyright 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: a private, but well versioned, interface to get at critical bits +// of a steam3 appticket - consumed by the simple drm wrapper to let it +// ask about ownership with greater confidence. +// +//============================================================================= + +#ifndef ISTEAMAPPTICKET_H +#define ISTEAMAPPTICKET_H +#pragma once + +//----------------------------------------------------------------------------- +// Purpose: hand out a reasonable "future proof" view of an app ownership ticket +// the raw (signed) buffer, and indices into that buffer where the appid and +// steamid are located. the sizes of the appid and steamid are implicit in +// (each version of) the interface - currently uin32 appid and uint64 steamid +//----------------------------------------------------------------------------- +class ISteamAppTicket +{ +public: + virtual uint32 GetAppOwnershipTicketData( uint32 nAppID, void *pvBuffer, uint32 cbBufferLength, uint32 *piAppId, uint32 *piSteamId, uint32 *piSignature, uint32 *pcbSignature ) = 0; +}; + +#define STEAMAPPTICKET_INTERFACE_VERSION "STEAMAPPTICKET_INTERFACE_VERSION001" + + +#endif // ISTEAMAPPTICKET_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamclient.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamclient.h new file mode 100644 index 0000000..796d72d --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamclient.h @@ -0,0 +1,503 @@ +//====== Copyright � 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: Main interface for loading and accessing Steamworks API's from the +// Steam client. +// For most uses, this code is wrapped inside of SteamAPI_Init() +//============================================================================= + +#ifndef ISTEAMCLIENT_H +#define ISTEAMCLIENT_H +#ifdef _WIN32 +#pragma once +#endif + +#include "steamtypes.h" +#include "steamclientpublic.h" + +// Define compile time assert macros to let us validate the structure sizes. +#define VALVE_COMPILE_TIME_ASSERT( pred ) typedef char compile_time_assert_type[(pred) ? 1 : -1]; + +#ifndef REFERENCE +#define REFERENCE(arg) ((void)arg) +#endif + +#if defined(__linux__) || defined(__APPLE__) +// The 32-bit version of gcc has the alignment requirement for uint64 and double set to +// 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. +// The 64-bit version of gcc has the alignment requirement for these types set to +// 8 meaning that unless we use #pragma pack(4) our structures will get bigger. +// The 64-bit structure packing has to match the 32-bit structure packing for each platform. +#define VALVE_CALLBACK_PACK_SMALL +#else +#define VALVE_CALLBACK_PACK_LARGE +#endif + +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error ??? +#endif + +typedef struct ValvePackingSentinel_t +{ + uint32 m_u32; + uint64 m_u64; + uint16 m_u16; + double m_d; +} ValvePackingSentinel_t; + +#pragma pack( pop ) + + +#if defined(VALVE_CALLBACK_PACK_SMALL) +VALVE_COMPILE_TIME_ASSERT( sizeof(ValvePackingSentinel_t) == 24 ) +#elif defined(VALVE_CALLBACK_PACK_LARGE) +VALVE_COMPILE_TIME_ASSERT( sizeof(ValvePackingSentinel_t) == 32 ) +#else +#error ??? +#endif + + +// handle to a communication pipe to the Steam client +typedef int32 HSteamPipe; +// handle to single instance of a steam user +typedef int32 HSteamUser; +// function prototype +#if defined( POSIX ) +#define __cdecl +#endif +extern "C" typedef void (__cdecl *SteamAPIWarningMessageHook_t)(int, const char *); +extern "C" typedef void( *SteamAPI_PostAPIResultInProcess_t )(SteamAPICall_t callHandle, void *, uint32 unCallbackSize, int iCallbackNum); +extern "C" typedef uint32 ( *SteamAPI_CheckCallbackRegistered_t )( int iCallbackNum ); +#if defined( __SNC__ ) + #pragma diag_suppress=1700 // warning 1700: class "%s" has virtual functions but non-virtual destructor +#endif + +// interface predec +class ISteamUser; +class ISteamGameServer; +class ISteamFriends; +class ISteamUtils; +class ISteamMatchmaking; +class ISteamContentServer; +class ISteamMatchmakingServers; +class ISteamUserStats; +class ISteamApps; +class ISteamNetworking; +class ISteamRemoteStorage; +class ISteamScreenshots; +class ISteamMusic; +class ISteamMusicRemote; +class ISteamGameServerStats; +class ISteamPS3OverlayRender; +class ISteamHTTP; +class ISteamUnifiedMessages; +class ISteamController; +class ISteamUGC; +class ISteamAppList; +class ISteamHTMLSurface; +class ISteamInventory; +class ISteamVideo; + +//----------------------------------------------------------------------------- +// Purpose: Interface to creating a new steam instance, or to +// connect to an existing steam instance, whether it's in a +// different process or is local. +// +// For most scenarios this is all handled automatically via SteamAPI_Init(). +// You'll only need to use these interfaces if you have a more complex versioning scheme, +// where you want to get different versions of the same interface in different dll's in your project. +//----------------------------------------------------------------------------- +class ISteamClient +{ +public: + // Creates a communication pipe to the Steam client + virtual HSteamPipe CreateSteamPipe() = 0; + + // Releases a previously created communications pipe + virtual bool BReleaseSteamPipe( HSteamPipe hSteamPipe ) = 0; + + // connects to an existing global user, failing if none exists + // used by the game to coordinate with the steamUI + virtual HSteamUser ConnectToGlobalUser( HSteamPipe hSteamPipe ) = 0; + + // used by game servers, create a steam user that won't be shared with anyone else + virtual HSteamUser CreateLocalUser( HSteamPipe *phSteamPipe, EAccountType eAccountType ) = 0; + + // removes an allocated user + virtual void ReleaseUser( HSteamPipe hSteamPipe, HSteamUser hUser ) = 0; + + // retrieves the ISteamUser interface associated with the handle + virtual ISteamUser *GetISteamUser( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // retrieves the ISteamGameServer interface associated with the handle + virtual ISteamGameServer *GetISteamGameServer( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // set the local IP and Port to bind to + // this must be set before CreateLocalUser() + virtual void SetLocalIPBinding( uint32 unIP, uint16 usPort ) = 0; + + // returns the ISteamFriends interface + virtual ISteamFriends *GetISteamFriends( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns the ISteamUtils interface + virtual ISteamUtils *GetISteamUtils( HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns the ISteamMatchmaking interface + virtual ISteamMatchmaking *GetISteamMatchmaking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns the ISteamMatchmakingServers interface + virtual ISteamMatchmakingServers *GetISteamMatchmakingServers( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns the a generic interface + virtual void *GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns the ISteamUserStats interface + virtual ISteamUserStats *GetISteamUserStats( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns the ISteamGameServerStats interface + virtual ISteamGameServerStats *GetISteamGameServerStats( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns apps interface + virtual ISteamApps *GetISteamApps( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // networking + virtual ISteamNetworking *GetISteamNetworking( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // remote storage + virtual ISteamRemoteStorage *GetISteamRemoteStorage( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // user screenshots + virtual ISteamScreenshots *GetISteamScreenshots( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // this needs to be called every frame to process matchmaking results + // redundant if you're already calling SteamAPI_RunCallbacks() + virtual void RunFrame() = 0; + + // returns the number of IPC calls made since the last time this function was called + // Used for perf debugging so you can understand how many IPC calls your game makes per frame + // Every IPC call is at minimum a thread context switch if not a process one so you want to rate + // control how often you do them. + virtual uint32 GetIPCCallCount() = 0; + + // API warning handling + // 'int' is the severity; 0 for msg, 1 for warning + // 'const char *' is the text of the message + // callbacks will occur directly after the API function is called that generated the warning or message + virtual void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) = 0; + + // Trigger global shutdown for the DLL + virtual bool BShutdownIfAllPipesClosed() = 0; + +#ifdef _PS3 + virtual ISteamPS3OverlayRender *GetISteamPS3OverlayRender() = 0; +#endif + + // Expose HTTP interface + virtual ISteamHTTP *GetISteamHTTP( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // Exposes the ISteamUnifiedMessages interface + virtual ISteamUnifiedMessages *GetISteamUnifiedMessages( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // Exposes the ISteamController interface + virtual ISteamController *GetISteamController( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // Exposes the ISteamUGC interface + virtual ISteamUGC *GetISteamUGC( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // returns app list interface, only available on specially registered apps + virtual ISteamAppList *GetISteamAppList( HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // Music Player + virtual ISteamMusic *GetISteamMusic( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // Music Player Remote + virtual ISteamMusicRemote *GetISteamMusicRemote(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion) = 0; + + // html page display + virtual ISteamHTMLSurface *GetISteamHTMLSurface(HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion) = 0; + + // Helper functions for internal Steam usage + virtual void Set_SteamAPI_CPostAPIResultInProcess( SteamAPI_PostAPIResultInProcess_t func ) = 0; + virtual void Remove_SteamAPI_CPostAPIResultInProcess( SteamAPI_PostAPIResultInProcess_t func ) = 0; + virtual void Set_SteamAPI_CCheckCallbackRegisteredInProcess( SteamAPI_CheckCallbackRegistered_t func ) = 0; + + // inventory + virtual ISteamInventory *GetISteamInventory( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; + + // Video + virtual ISteamVideo *GetISteamVideo( HSteamUser hSteamuser, HSteamPipe hSteamPipe, const char *pchVersion ) = 0; +}; + + +#define STEAMCLIENT_INTERFACE_VERSION "SteamClient017" + +//----------------------------------------------------------------------------- +// Purpose: Base values for callback identifiers, each callback must +// have a unique ID. +//----------------------------------------------------------------------------- +enum { k_iSteamUserCallbacks = 100 }; +enum { k_iSteamGameServerCallbacks = 200 }; +enum { k_iSteamFriendsCallbacks = 300 }; +enum { k_iSteamBillingCallbacks = 400 }; +enum { k_iSteamMatchmakingCallbacks = 500 }; +enum { k_iSteamContentServerCallbacks = 600 }; +enum { k_iSteamUtilsCallbacks = 700 }; +enum { k_iClientFriendsCallbacks = 800 }; +enum { k_iClientUserCallbacks = 900 }; +enum { k_iSteamAppsCallbacks = 1000 }; +enum { k_iSteamUserStatsCallbacks = 1100 }; +enum { k_iSteamNetworkingCallbacks = 1200 }; +enum { k_iClientRemoteStorageCallbacks = 1300 }; +enum { k_iClientDepotBuilderCallbacks = 1400 }; +enum { k_iSteamGameServerItemsCallbacks = 1500 }; +enum { k_iClientUtilsCallbacks = 1600 }; +enum { k_iSteamGameCoordinatorCallbacks = 1700 }; +enum { k_iSteamGameServerStatsCallbacks = 1800 }; +enum { k_iSteam2AsyncCallbacks = 1900 }; +enum { k_iSteamGameStatsCallbacks = 2000 }; +enum { k_iClientHTTPCallbacks = 2100 }; +enum { k_iClientScreenshotsCallbacks = 2200 }; +enum { k_iSteamScreenshotsCallbacks = 2300 }; +enum { k_iClientAudioCallbacks = 2400 }; +enum { k_iClientUnifiedMessagesCallbacks = 2500 }; +enum { k_iSteamStreamLauncherCallbacks = 2600 }; +enum { k_iClientControllerCallbacks = 2700 }; +enum { k_iSteamControllerCallbacks = 2800 }; +enum { k_iClientParentalSettingsCallbacks = 2900 }; +enum { k_iClientDeviceAuthCallbacks = 3000 }; +enum { k_iClientNetworkDeviceManagerCallbacks = 3100 }; +enum { k_iClientMusicCallbacks = 3200 }; +enum { k_iClientRemoteClientManagerCallbacks = 3300 }; +enum { k_iClientUGCCallbacks = 3400 }; +enum { k_iSteamStreamClientCallbacks = 3500 }; +enum { k_IClientProductBuilderCallbacks = 3600 }; +enum { k_iClientShortcutsCallbacks = 3700 }; +enum { k_iClientRemoteControlManagerCallbacks = 3800 }; +enum { k_iSteamAppListCallbacks = 3900 }; +enum { k_iSteamMusicCallbacks = 4000 }; +enum { k_iSteamMusicRemoteCallbacks = 4100 }; +enum { k_iClientVRCallbacks = 4200 }; +enum { k_iClientReservedCallbacks = 4300 }; +enum { k_iSteamReservedCallbacks = 4400 }; +enum { k_iSteamHTMLSurfaceCallbacks = 4500 }; +enum { k_iClientVideoCallbacks = 4600 }; +enum { k_iClientInventoryCallbacks = 4700 }; + +//----------------------------------------------------------------------------- +// The CALLBACK macros are for client side callback logging enabled with +// log_callback +// Do not change any of these. +//----------------------------------------------------------------------------- + +struct SteamCallback_t +{ +public: + SteamCallback_t() {} +}; + +#define DEFINE_CALLBACK( callbackname, callbackid ) \ +struct callbackname : SteamCallback_t { \ + enum { k_iCallback = callbackid }; \ + static callbackname *GetNullPointer() { return 0; } \ + static const char *GetCallbackName() { return #callbackname; } \ + static uint32 GetCallbackID() { return callbackname::k_iCallback; } + +#define CALLBACK_MEMBER( varidx, vartype, varname ) \ + public: vartype varname ; \ + static void GetMemberVar_##varidx( unsigned int &varOffset, unsigned int &varSize, uint32 &varCount, const char **pszName, const char **pszType ) { \ + varOffset = (unsigned int)(size_t)&GetNullPointer()->varname; \ + varSize = sizeof( vartype ); \ + varCount = 1; \ + *pszName = #varname; *pszType = #vartype; } + +#define CALLBACK_ARRAY( varidx, vartype, varname, varcount ) \ + public: vartype varname [ varcount ]; \ + static void GetMemberVar_##varidx( unsigned int &varOffset, unsigned int &varSize, uint32 &varCount, const char **pszName, const char **pszType ) { \ + varOffset = (unsigned int)(size_t)&GetNullPointer()->varname[0]; \ + varSize = sizeof( vartype ); \ + varCount = varcount; \ + *pszName = #varname; *pszType = #vartype; } + + +#define END_CALLBACK_INTERNAL_BEGIN( numvars ) \ + static uint32 GetNumMemberVariables() { return numvars; } \ + static bool GetMemberVariable( uint32 index, uint32 &varOffset, uint32 &varSize, uint32 &varCount, const char **pszName, const char **pszType ) { \ + switch ( index ) { default : return false; + + +#define END_CALLBACK_INTERNAL_SWITCH( varidx ) case varidx : GetMemberVar_##varidx( varOffset, varSize, varCount, pszName, pszType ); return true; + +#define END_CALLBACK_INTERNAL_END() }; } }; + +#define END_DEFINE_CALLBACK_0() \ + static uint32 GetNumMemberVariables() { return 0; } \ + static bool GetMemberVariable( uint32 index, uint32 &varOffset, uint32 &varSize, uint32 &varCount, const char **pszName, const char **pszType ) { REFERENCE( pszType ); REFERENCE( pszName ); REFERENCE( varCount ); REFERENCE( varSize ); REFERENCE( varOffset ); REFERENCE( index ); return false; } \ + }; + + +#define END_DEFINE_CALLBACK_1() \ + END_CALLBACK_INTERNAL_BEGIN( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_2() \ + END_CALLBACK_INTERNAL_BEGIN( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_3() \ + END_CALLBACK_INTERNAL_BEGIN( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_4() \ + END_CALLBACK_INTERNAL_BEGIN( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_5() \ + END_CALLBACK_INTERNAL_BEGIN( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_END() + + +#define END_DEFINE_CALLBACK_6() \ + END_CALLBACK_INTERNAL_BEGIN( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_7() \ + END_CALLBACK_INTERNAL_BEGIN( 7 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_8() \ + END_CALLBACK_INTERNAL_BEGIN( 8 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 7 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_9() \ + END_CALLBACK_INTERNAL_BEGIN( 9 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 7 ) \ + END_CALLBACK_INTERNAL_SWITCH( 8 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_10() \ + END_CALLBACK_INTERNAL_BEGIN( 10 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 7 ) \ + END_CALLBACK_INTERNAL_SWITCH( 8 ) \ + END_CALLBACK_INTERNAL_SWITCH( 9 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_11() \ + END_CALLBACK_INTERNAL_BEGIN( 11 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 7 ) \ + END_CALLBACK_INTERNAL_SWITCH( 8 ) \ + END_CALLBACK_INTERNAL_SWITCH( 9 ) \ + END_CALLBACK_INTERNAL_SWITCH( 10 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_12() \ + END_CALLBACK_INTERNAL_BEGIN( 12 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 7 ) \ + END_CALLBACK_INTERNAL_SWITCH( 8 ) \ + END_CALLBACK_INTERNAL_SWITCH( 9 ) \ + END_CALLBACK_INTERNAL_SWITCH( 10 ) \ + END_CALLBACK_INTERNAL_SWITCH( 11 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_13() \ + END_CALLBACK_INTERNAL_BEGIN( 13 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 7 ) \ + END_CALLBACK_INTERNAL_SWITCH( 8 ) \ + END_CALLBACK_INTERNAL_SWITCH( 9 ) \ + END_CALLBACK_INTERNAL_SWITCH( 10 ) \ + END_CALLBACK_INTERNAL_SWITCH( 11 ) \ + END_CALLBACK_INTERNAL_SWITCH( 12 ) \ + END_CALLBACK_INTERNAL_END() + +#define END_DEFINE_CALLBACK_14() \ + END_CALLBACK_INTERNAL_BEGIN( 14 ) \ + END_CALLBACK_INTERNAL_SWITCH( 0 ) \ + END_CALLBACK_INTERNAL_SWITCH( 1 ) \ + END_CALLBACK_INTERNAL_SWITCH( 2 ) \ + END_CALLBACK_INTERNAL_SWITCH( 3 ) \ + END_CALLBACK_INTERNAL_SWITCH( 4 ) \ + END_CALLBACK_INTERNAL_SWITCH( 5 ) \ + END_CALLBACK_INTERNAL_SWITCH( 6 ) \ + END_CALLBACK_INTERNAL_SWITCH( 7 ) \ + END_CALLBACK_INTERNAL_SWITCH( 8 ) \ + END_CALLBACK_INTERNAL_SWITCH( 9 ) \ + END_CALLBACK_INTERNAL_SWITCH( 10 ) \ + END_CALLBACK_INTERNAL_SWITCH( 11 ) \ + END_CALLBACK_INTERNAL_SWITCH( 12 ) \ + END_CALLBACK_INTERNAL_SWITCH( 13 ) \ + END_CALLBACK_INTERNAL_END() + +#endif // ISTEAMCLIENT_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamcontroller.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamcontroller.h new file mode 100644 index 0000000..a973696 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamcontroller.h @@ -0,0 +1,210 @@ +//====== Copyright 1996-2013, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to valve controller +// +//============================================================================= + +#ifndef ISTEAMCONTROLLER_H +#define ISTEAMCONTROLLER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +#define STEAM_CONTROLLER_MAX_COUNT 16 + +#define STEAM_CONTROLLER_MAX_ANALOG_ACTIONS 16 + +#define STEAM_CONTROLLER_MAX_DIGITAL_ACTIONS 32 + +#define STEAM_CONTROLLER_MAX_ORIGINS 8 + +// When sending an option to a specific controller handle, you can send to all controllers via this command +#define STEAM_CONTROLLER_HANDLE_ALL_CONTROLLERS UINT64_MAX + +#define STEAM_CONTROLLER_MIN_ANALOG_ACTION_DATA -1.0f +#define STEAM_CONTROLLER_MAX_ANALOG_ACTION_DATA 1.0f + +enum ESteamControllerPad +{ + k_ESteamControllerPad_Left, + k_ESteamControllerPad_Right +}; + +enum EControllerSource +{ + k_EControllerSource_None, + k_EControllerSource_LeftTrackpad, + k_EControllerSource_RightTrackpad, + k_EControllerSource_Joystick, + k_EControllerSource_ABXY, + k_EControllerSource_Switch, + k_EControllerSource_LeftTrigger, + k_EControllerSource_RightTrigger, + k_EControllerSource_Gyro +}; + +enum EControllerSourceMode +{ + k_EControllerSourceMode_None, + k_EControllerSourceMode_Dpad, + k_EControllerSourceMode_Buttons, + k_EControllerSourceMode_FourButtons, + k_EControllerSourceMode_AbsoluteMouse, + k_EControllerSourceMode_RelativeMouse, + k_EControllerSourceMode_JoystickMove, + k_EControllerSourceMode_JoystickCamera, + k_EControllerSourceMode_ScrollWheel, + k_EControllerSourceMode_Trigger, + k_EControllerSourceMode_TouchMenu +}; + +enum EControllerActionOrigin +{ + k_EControllerActionOrigin_None, + k_EControllerActionOrigin_A, + k_EControllerActionOrigin_B, + k_EControllerActionOrigin_X, + k_EControllerActionOrigin_Y, + k_EControllerActionOrigin_LeftBumper, + k_EControllerActionOrigin_RightBumper, + k_EControllerActionOrigin_LeftGrip, + k_EControllerActionOrigin_RightGrip, + k_EControllerActionOrigin_Start, + k_EControllerActionOrigin_Back, + k_EControllerActionOrigin_LeftPad_Touch, + k_EControllerActionOrigin_LeftPad_Swipe, + k_EControllerActionOrigin_LeftPad_Click, + k_EControllerActionOrigin_LeftPad_DPadNorth, + k_EControllerActionOrigin_LeftPad_DPadSouth, + k_EControllerActionOrigin_LeftPad_DPadWest, + k_EControllerActionOrigin_LeftPad_DPadEast, + k_EControllerActionOrigin_RightPad_Touch, + k_EControllerActionOrigin_RightPad_Swipe, + k_EControllerActionOrigin_RightPad_Click, + k_EControllerActionOrigin_RightPad_DPadNorth, + k_EControllerActionOrigin_RightPad_DPadSouth, + k_EControllerActionOrigin_RightPad_DPadWest, + k_EControllerActionOrigin_RightPad_DPadEast, + k_EControllerActionOrigin_LeftTrigger_Pull, + k_EControllerActionOrigin_LeftTrigger_Click, + k_EControllerActionOrigin_RightTrigger_Pull, + k_EControllerActionOrigin_RightTrigger_Click, + k_EControllerActionOrigin_LeftStick_Move, + k_EControllerActionOrigin_LeftStick_Click, + k_EControllerActionOrigin_LeftStick_DPadNorth, + k_EControllerActionOrigin_LeftStick_DPadSouth, + k_EControllerActionOrigin_LeftStick_DPadWest, + k_EControllerActionOrigin_LeftStick_DPadEast, + k_EControllerActionOrigin_Gyro_Move, + k_EControllerActionOrigin_Gyro_Pitch, + k_EControllerActionOrigin_Gyro_Yaw, + k_EControllerActionOrigin_Gyro_Roll, + + k_EControllerActionOrigin_Count +}; + +// ControllerHandle_t is used to refer to a specific controller. +// This handle will consistently identify a controller, even if it is disconnected and re-connected +typedef uint64 ControllerHandle_t; + + +// These handles are used to refer to a specific in-game action or action set +// All action handles should be queried during initialization for performance reasons +typedef uint64 ControllerActionSetHandle_t; +typedef uint64 ControllerDigitalActionHandle_t; +typedef uint64 ControllerAnalogActionHandle_t; + +#pragma pack( push, 1 ) + +struct ControllerAnalogActionData_t +{ + // Type of data coming from this action, this will match what got specified in the action set + EControllerSourceMode eMode; + + // The current state of this action; will be delta updates for mouse actions + float x, y; + + // Whether or not this action is currently available to be bound in the active action set + bool bActive; +}; + +struct ControllerDigitalActionData_t +{ + // The current state of this action; will be true if currently pressed + bool bState; + + // Whether or not this action is currently available to be bound in the active action set + bool bActive; +}; + +#pragma pack( pop ) + + +//----------------------------------------------------------------------------- +// Purpose: Native Steam controller support API +//----------------------------------------------------------------------------- +class ISteamController +{ +public: + + // Init and Shutdown must be called when starting/ending use of this interface + virtual bool Init() = 0; + virtual bool Shutdown() = 0; + + // Pump callback/callresult events + // Note: SteamAPI_RunCallbacks will do this for you, so you should never need to call this directly. + virtual void RunFrame() = 0; + + // Enumerate currently connected controllers + // handlesOut should point to a STEAM_CONTROLLER_MAX_COUNT sized array of ControllerHandle_t handles + // Returns the number of handles written to handlesOut + virtual int GetConnectedControllers( ControllerHandle_t *handlesOut ) = 0; + + // Invokes the Steam overlay and brings up the binding screen + // Returns false is overlay is disabled / unavailable, or the user is not in Big Picture mode + virtual bool ShowBindingPanel( ControllerHandle_t controllerHandle ) = 0; + + // ACTION SETS + // Lookup the handle for an Action Set. Best to do this once on startup, and store the handles for all future API calls. + virtual ControllerActionSetHandle_t GetActionSetHandle( const char *pszActionSetName ) = 0; + + // Reconfigure the controller to use the specified action set (ie 'Menu', 'Walk' or 'Drive') + // This is cheap, and can be safely called repeatedly. It's often easier to repeatedly call it in + // your state loops, instead of trying to place it in all of your state transitions. + virtual void ActivateActionSet( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle ) = 0; + virtual ControllerActionSetHandle_t GetCurrentActionSet( ControllerHandle_t controllerHandle ) = 0; + + // ACTIONS + // Lookup the handle for a digital action. Best to do this once on startup, and store the handles for all future API calls. + virtual ControllerDigitalActionHandle_t GetDigitalActionHandle( const char *pszActionName ) = 0; + + // Returns the current state of the supplied digital game action + virtual ControllerDigitalActionData_t GetDigitalActionData( ControllerHandle_t controllerHandle, ControllerDigitalActionHandle_t digitalActionHandle ) = 0; + + // Get the origin(s) for a digital action within an action set. Returns the number of origins supplied in originsOut. Use this to display the appropriate on-screen prompt for the action. + // originsOut should point to a STEAM_CONTROLLER_MAX_ORIGINS sized array of EControllerActionOrigin handles + virtual int GetDigitalActionOrigins( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerDigitalActionHandle_t digitalActionHandle, EControllerActionOrigin *originsOut ) = 0; + + // Lookup the handle for an analog action. Best to do this once on startup, and store the handles for all future API calls. + virtual ControllerAnalogActionHandle_t GetAnalogActionHandle( const char *pszActionName ) = 0; + + // Returns the current state of these supplied analog game action + virtual ControllerAnalogActionData_t GetAnalogActionData( ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t analogActionHandle ) = 0; + + // Get the origin(s) for an analog action within an action set. Returns the number of origins supplied in originsOut. Use this to display the appropriate on-screen prompt for the action. + // originsOut should point to a STEAM_CONTROLLER_MAX_ORIGINS sized array of EControllerActionOrigin handles + virtual int GetAnalogActionOrigins( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerAnalogActionHandle_t analogActionHandle, EControllerActionOrigin *originsOut ) = 0; + + + + virtual void StopAnalogActionMomentum( ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t eAction ) = 0; + + // Trigger a haptic pulse on a controller + virtual void TriggerHapticPulse( ControllerHandle_t controllerHandle, ESteamControllerPad eTargetPad, unsigned short usDurationMicroSec ) = 0; +}; + +#define STEAMCONTROLLER_INTERFACE_VERSION "SteamController003" + +#endif // ISTEAMCONTROLLER_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamfriends.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamfriends.h new file mode 100644 index 0000000..60526ed --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamfriends.h @@ -0,0 +1,629 @@ +//====== Copyright (C) 1996-2008, Valve Corporation, All rights reserved. ===== +// +// Purpose: interface to both friends list data and general information about users +// +//============================================================================= + +#ifndef ISTEAMFRIENDS_H +#define ISTEAMFRIENDS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" +#include "steamclientpublic.h" + + +//----------------------------------------------------------------------------- +// Purpose: set of relationships to other users +//----------------------------------------------------------------------------- +enum EFriendRelationship +{ + k_EFriendRelationshipNone = 0, + k_EFriendRelationshipBlocked = 1, // this doesn't get stored; the user has just done an Ignore on an friendship invite + k_EFriendRelationshipRequestRecipient = 2, + k_EFriendRelationshipFriend = 3, + k_EFriendRelationshipRequestInitiator = 4, + k_EFriendRelationshipIgnored = 5, // this is stored; the user has explicit blocked this other user from comments/chat/etc + k_EFriendRelationshipIgnoredFriend = 6, + k_EFriendRelationshipSuggested = 7, + + // keep this updated + k_EFriendRelationshipMax = 8, +}; + +// maximum length of friend group name (not including terminating nul!) +const int k_cchMaxFriendsGroupName = 64; + +// maximum number of groups a single user is allowed +const int k_cFriendsGroupLimit = 100; + +// friends group identifier type +typedef int16 FriendsGroupID_t; + +// invalid friends group identifier constant +const FriendsGroupID_t k_FriendsGroupID_Invalid = -1; + +const int k_cEnumerateFollowersMax = 50; + + +//----------------------------------------------------------------------------- +// Purpose: list of states a friend can be in +//----------------------------------------------------------------------------- +enum EPersonaState +{ + k_EPersonaStateOffline = 0, // friend is not currently logged on + k_EPersonaStateOnline = 1, // friend is logged on + k_EPersonaStateBusy = 2, // user is on, but busy + k_EPersonaStateAway = 3, // auto-away feature + k_EPersonaStateSnooze = 4, // auto-away for a long time + k_EPersonaStateLookingToTrade = 5, // Online, trading + k_EPersonaStateLookingToPlay = 6, // Online, wanting to play + k_EPersonaStateMax, +}; + + +//----------------------------------------------------------------------------- +// Purpose: flags for enumerating friends list, or quickly checking a the relationship between users +//----------------------------------------------------------------------------- +enum EFriendFlags +{ + k_EFriendFlagNone = 0x00, + k_EFriendFlagBlocked = 0x01, + k_EFriendFlagFriendshipRequested = 0x02, + k_EFriendFlagImmediate = 0x04, // "regular" friend + k_EFriendFlagClanMember = 0x08, + k_EFriendFlagOnGameServer = 0x10, + // k_EFriendFlagHasPlayedWith = 0x20, // not currently used + // k_EFriendFlagFriendOfFriend = 0x40, // not currently used + k_EFriendFlagRequestingFriendship = 0x80, + k_EFriendFlagRequestingInfo = 0x100, + k_EFriendFlagIgnored = 0x200, + k_EFriendFlagIgnoredFriend = 0x400, + k_EFriendFlagSuggested = 0x800, + k_EFriendFlagAll = 0xFFFF, +}; + + +// friend game played information +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif +struct FriendGameInfo_t +{ + CGameID m_gameID; + uint32 m_unGameIP; + uint16 m_usGamePort; + uint16 m_usQueryPort; + CSteamID m_steamIDLobby; +}; +#pragma pack( pop ) + +// maximum number of characters in a user's name. Two flavors; one for UTF-8 and one for UTF-16. +// The UTF-8 version has to be very generous to accomodate characters that get large when encoded +// in UTF-8. +enum +{ + k_cchPersonaNameMax = 128, + k_cwchPersonaNameMax = 32, +}; + +//----------------------------------------------------------------------------- +// Purpose: user restriction flags +//----------------------------------------------------------------------------- +enum EUserRestriction +{ + k_nUserRestrictionNone = 0, // no known chat/content restriction + k_nUserRestrictionUnknown = 1, // we don't know yet (user offline) + k_nUserRestrictionAnyChat = 2, // user is not allowed to (or can't) send/recv any chat + k_nUserRestrictionVoiceChat = 4, // user is not allowed to (or can't) send/recv voice chat + k_nUserRestrictionGroupChat = 8, // user is not allowed to (or can't) send/recv group chat + k_nUserRestrictionRating = 16, // user is too young according to rating in current region + k_nUserRestrictionGameInvites = 32, // user cannot send or recv game invites (e.g. mobile) + k_nUserRestrictionTrading = 64, // user cannot participate in trading (console, mobile) +}; + +//----------------------------------------------------------------------------- +// Purpose: information about user sessions +//----------------------------------------------------------------------------- +struct FriendSessionStateInfo_t +{ + uint32 m_uiOnlineSessionInstances; + uint8 m_uiPublishedToFriendsSessionInstance; +}; + + + +// size limit on chat room or member metadata +const uint32 k_cubChatMetadataMax = 8192; + +// size limits on Rich Presence data +enum { k_cchMaxRichPresenceKeys = 20 }; +enum { k_cchMaxRichPresenceKeyLength = 64 }; +enum { k_cchMaxRichPresenceValueLength = 256 }; + +// These values are passed as parameters to the store +enum EOverlayToStoreFlag +{ + k_EOverlayToStoreFlag_None = 0, + k_EOverlayToStoreFlag_AddToCart = 1, + k_EOverlayToStoreFlag_AddToCartAndShow = 2, +}; + +//----------------------------------------------------------------------------- +// Purpose: interface to accessing information about individual users, +// that can be a friend, in a group, on a game server or in a lobby with the local user +//----------------------------------------------------------------------------- +class ISteamFriends +{ +public: + // returns the local players name - guaranteed to not be NULL. + // this is the same name as on the users community profile page + // this is stored in UTF-8 format + // like all the other interface functions that return a char *, it's important that this pointer is not saved + // off; it will eventually be free'd or re-allocated + virtual const char *GetPersonaName() = 0; + + // Sets the player name, stores it on the server and publishes the changes to all friends who are online. + // Changes take place locally immediately, and a PersonaStateChange_t is posted, presuming success. + // + // The final results are available through the return value SteamAPICall_t, using SetPersonaNameResponse_t. + // + // If the name change fails to happen on the server, then an additional global PersonaStateChange_t will be posted + // to change the name back, in addition to the SetPersonaNameResponse_t callback. + virtual SteamAPICall_t SetPersonaName( const char *pchPersonaName ) = 0; + + // gets the status of the current user + virtual EPersonaState GetPersonaState() = 0; + + // friend iteration + // takes a set of k_EFriendFlags, and returns the number of users the client knows about who meet that criteria + // then GetFriendByIndex() can then be used to return the id's of each of those users + virtual int GetFriendCount( int iFriendFlags ) = 0; + + // returns the steamID of a user + // iFriend is a index of range [0, GetFriendCount()) + // iFriendsFlags must be the same value as used in GetFriendCount() + // the returned CSteamID can then be used by all the functions below to access details about the user + virtual CSteamID GetFriendByIndex( int iFriend, int iFriendFlags ) = 0; + + // returns a relationship to a user + virtual EFriendRelationship GetFriendRelationship( CSteamID steamIDFriend ) = 0; + + // returns the current status of the specified user + // this will only be known by the local user if steamIDFriend is in their friends list; on the same game server; in a chat room or lobby; or in a small group with the local user + virtual EPersonaState GetFriendPersonaState( CSteamID steamIDFriend ) = 0; + + // returns the name another user - guaranteed to not be NULL. + // same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user + // note that on first joining a lobby, chat room or game server the local user will not known the name of the other users automatically; that information will arrive asyncronously + // + virtual const char *GetFriendPersonaName( CSteamID steamIDFriend ) = 0; + + // returns true if the friend is actually in a game, and fills in pFriendGameInfo with an extra details + virtual bool GetFriendGamePlayed( CSteamID steamIDFriend, OUT_STRUCT() FriendGameInfo_t *pFriendGameInfo ) = 0; + // accesses old friends names - returns an empty string when their are no more items in the history + virtual const char *GetFriendPersonaNameHistory( CSteamID steamIDFriend, int iPersonaName ) = 0; + // friends steam level + virtual int GetFriendSteamLevel( CSteamID steamIDFriend ) = 0; + + // Returns nickname the current user has set for the specified player. Returns NULL if the no nickname has been set for that player. + virtual const char *GetPlayerNickname( CSteamID steamIDPlayer ) = 0; + + // friend grouping (tag) apis + // returns the number of friends groups + virtual int GetFriendsGroupCount() = 0; + // returns the friends group ID for the given index (invalid indices return k_FriendsGroupID_Invalid) + virtual FriendsGroupID_t GetFriendsGroupIDByIndex( int iFG ) = 0; + // returns the name for the given friends group (NULL in the case of invalid friends group IDs) + virtual const char *GetFriendsGroupName( FriendsGroupID_t friendsGroupID ) = 0; + // returns the number of members in a given friends group + virtual int GetFriendsGroupMembersCount( FriendsGroupID_t friendsGroupID ) = 0; + // gets up to nMembersCount members of the given friends group, if fewer exist than requested those positions' SteamIDs will be invalid + virtual void GetFriendsGroupMembersList( FriendsGroupID_t friendsGroupID, OUT_ARRAY_CALL(nMembersCount, GetFriendsGroupMembersCount, friendsGroupID ) CSteamID *pOutSteamIDMembers, int nMembersCount ) = 0; + + // returns true if the specified user meets any of the criteria specified in iFriendFlags + // iFriendFlags can be the union (binary or, |) of one or more k_EFriendFlags values + virtual bool HasFriend( CSteamID steamIDFriend, int iFriendFlags ) = 0; + + // clan (group) iteration and access functions + virtual int GetClanCount() = 0; + virtual CSteamID GetClanByIndex( int iClan ) = 0; + virtual const char *GetClanName( CSteamID steamIDClan ) = 0; + virtual const char *GetClanTag( CSteamID steamIDClan ) = 0; + // returns the most recent information we have about what's happening in a clan + virtual bool GetClanActivityCounts( CSteamID steamIDClan, int *pnOnline, int *pnInGame, int *pnChatting ) = 0; + // for clans a user is a member of, they will have reasonably up-to-date information, but for others you'll have to download the info to have the latest + virtual SteamAPICall_t DownloadClanActivityCounts( ARRAY_COUNT(cClansToRequest) CSteamID *psteamIDClans, int cClansToRequest ) = 0; + + // iterators for getting users in a chat room, lobby, game server or clan + // note that large clans that cannot be iterated by the local user + // note that the current user must be in a lobby to retrieve CSteamIDs of other users in that lobby + // steamIDSource can be the steamID of a group, game server, lobby or chat room + virtual int GetFriendCountFromSource( CSteamID steamIDSource ) = 0; + virtual CSteamID GetFriendFromSourceByIndex( CSteamID steamIDSource, int iFriend ) = 0; + + // returns true if the local user can see that steamIDUser is a member or in steamIDSource + virtual bool IsUserInSource( CSteamID steamIDUser, CSteamID steamIDSource ) = 0; + + // User is in a game pressing the talk button (will suppress the microphone for all voice comms from the Steam friends UI) + virtual void SetInGameVoiceSpeaking( CSteamID steamIDUser, bool bSpeaking ) = 0; + + // activates the game overlay, with an optional dialog to open + // valid options are "Friends", "Community", "Players", "Settings", "OfficialGameGroup", "Stats", "Achievements" + virtual void ActivateGameOverlay( const char *pchDialog ) = 0; + + // activates game overlay to a specific place + // valid options are + // "steamid" - opens the overlay web browser to the specified user or groups profile + // "chat" - opens a chat window to the specified user, or joins the group chat + // "jointrade" - opens a window to a Steam Trading session that was started with the ISteamEconomy/StartTrade Web API + // "stats" - opens the overlay web browser to the specified user's stats + // "achievements" - opens the overlay web browser to the specified user's achievements + // "friendadd" - opens the overlay in minimal mode prompting the user to add the target user as a friend + // "friendremove" - opens the overlay in minimal mode prompting the user to remove the target friend + // "friendrequestaccept" - opens the overlay in minimal mode prompting the user to accept an incoming friend invite + // "friendrequestignore" - opens the overlay in minimal mode prompting the user to ignore an incoming friend invite + virtual void ActivateGameOverlayToUser( const char *pchDialog, CSteamID steamID ) = 0; + + // activates game overlay web browser directly to the specified URL + // full address with protocol type is required, e.g. http://www.steamgames.com/ + virtual void ActivateGameOverlayToWebPage( const char *pchURL ) = 0; + + // activates game overlay to store page for app + virtual void ActivateGameOverlayToStore( AppId_t nAppID, EOverlayToStoreFlag eFlag ) = 0; + + // Mark a target user as 'played with'. This is a client-side only feature that requires that the calling user is + // in game + virtual void SetPlayedWith( CSteamID steamIDUserPlayedWith ) = 0; + + // activates game overlay to open the invite dialog. Invitations will be sent for the provided lobby. + virtual void ActivateGameOverlayInviteDialog( CSteamID steamIDLobby ) = 0; + + // gets the small (32x32) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set + virtual int GetSmallFriendAvatar( CSteamID steamIDFriend ) = 0; + + // gets the medium (64x64) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set + virtual int GetMediumFriendAvatar( CSteamID steamIDFriend ) = 0; + + // gets the large (184x184) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set + // returns -1 if this image has yet to be loaded, in this case wait for a AvatarImageLoaded_t callback and then call this again + virtual int GetLargeFriendAvatar( CSteamID steamIDFriend ) = 0; + + // requests information about a user - persona name & avatar + // if bRequireNameOnly is set, then the avatar of a user isn't downloaded + // - it's a lot slower to download avatars and churns the local cache, so if you don't need avatars, don't request them + // if returns true, it means that data is being requested, and a PersonaStateChanged_t callback will be posted when it's retrieved + // if returns false, it means that we already have all the details about that user, and functions can be called immediately + virtual bool RequestUserInformation( CSteamID steamIDUser, bool bRequireNameOnly ) = 0; + + // requests information about a clan officer list + // when complete, data is returned in ClanOfficerListResponse_t call result + // this makes available the calls below + // you can only ask about clans that a user is a member of + // note that this won't download avatars automatically; if you get an officer, + // and no avatar image is available, call RequestUserInformation( steamID, false ) to download the avatar + virtual SteamAPICall_t RequestClanOfficerList( CSteamID steamIDClan ) = 0; + + // iteration of clan officers - can only be done when a RequestClanOfficerList() call has completed + + // returns the steamID of the clan owner + virtual CSteamID GetClanOwner( CSteamID steamIDClan ) = 0; + // returns the number of officers in a clan (including the owner) + virtual int GetClanOfficerCount( CSteamID steamIDClan ) = 0; + // returns the steamID of a clan officer, by index, of range [0,GetClanOfficerCount) + virtual CSteamID GetClanOfficerByIndex( CSteamID steamIDClan, int iOfficer ) = 0; + // if current user is chat restricted, he can't send or receive any text/voice chat messages. + // the user can't see custom avatars. But the user can be online and send/recv game invites. + // a chat restricted user can't add friends or join any groups. + virtual uint32 GetUserRestrictions() = 0; + + // Rich Presence data is automatically shared between friends who are in the same game + // Each user has a set of Key/Value pairs + // Up to 20 different keys can be set + // There are two magic keys: + // "status" - a UTF-8 string that will show up in the 'view game info' dialog in the Steam friends list + // "connect" - a UTF-8 string that contains the command-line for how a friend can connect to a game + // GetFriendRichPresence() returns an empty string "" if no value is set + // SetRichPresence() to a NULL or an empty string deletes the key + // You can iterate the current set of keys for a friend with GetFriendRichPresenceKeyCount() + // and GetFriendRichPresenceKeyByIndex() (typically only used for debugging) + virtual bool SetRichPresence( const char *pchKey, const char *pchValue ) = 0; + virtual void ClearRichPresence() = 0; + virtual const char *GetFriendRichPresence( CSteamID steamIDFriend, const char *pchKey ) = 0; + virtual int GetFriendRichPresenceKeyCount( CSteamID steamIDFriend ) = 0; + virtual const char *GetFriendRichPresenceKeyByIndex( CSteamID steamIDFriend, int iKey ) = 0; + // Requests rich presence for a specific user. + virtual void RequestFriendRichPresence( CSteamID steamIDFriend ) = 0; + + // rich invite support + // if the target accepts the invite, the pchConnectString gets added to the command-line for launching the game + // if the game is already running, a GameRichPresenceJoinRequested_t callback is posted containing the connect string + // invites can only be sent to friends + virtual bool InviteUserToGame( CSteamID steamIDFriend, const char *pchConnectString ) = 0; + + // recently-played-with friends iteration + // this iterates the entire list of users recently played with, across games + // GetFriendCoplayTime() returns as a unix time + virtual int GetCoplayFriendCount() = 0; + virtual CSteamID GetCoplayFriend( int iCoplayFriend ) = 0; + virtual int GetFriendCoplayTime( CSteamID steamIDFriend ) = 0; + virtual AppId_t GetFriendCoplayGame( CSteamID steamIDFriend ) = 0; + + // chat interface for games + // this allows in-game access to group (clan) chats from in the game + // the behavior is somewhat sophisticated, because the user may or may not be already in the group chat from outside the game or in the overlay + // use ActivateGameOverlayToUser( "chat", steamIDClan ) to open the in-game overlay version of the chat + virtual SteamAPICall_t JoinClanChatRoom( CSteamID steamIDClan ) = 0; + virtual bool LeaveClanChatRoom( CSteamID steamIDClan ) = 0; + virtual int GetClanChatMemberCount( CSteamID steamIDClan ) = 0; + virtual CSteamID GetChatMemberByIndex( CSteamID steamIDClan, int iUser ) = 0; + virtual bool SendClanChatMessage( CSteamID steamIDClanChat, const char *pchText ) = 0; + virtual int GetClanChatMessage( CSteamID steamIDClanChat, int iMessage, void *prgchText, int cchTextMax, EChatEntryType *peChatEntryType, OUT_STRUCT() CSteamID *psteamidChatter ) = 0; + virtual bool IsClanChatAdmin( CSteamID steamIDClanChat, CSteamID steamIDUser ) = 0; + + // interact with the Steam (game overlay / desktop) + virtual bool IsClanChatWindowOpenInSteam( CSteamID steamIDClanChat ) = 0; + virtual bool OpenClanChatWindowInSteam( CSteamID steamIDClanChat ) = 0; + virtual bool CloseClanChatWindowInSteam( CSteamID steamIDClanChat ) = 0; + + // peer-to-peer chat interception + // this is so you can show P2P chats inline in the game + virtual bool SetListenForFriendsMessages( bool bInterceptEnabled ) = 0; + virtual bool ReplyToFriendMessage( CSteamID steamIDFriend, const char *pchMsgToSend ) = 0; + virtual int GetFriendMessage( CSteamID steamIDFriend, int iMessageID, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0; + + // following apis + virtual SteamAPICall_t GetFollowerCount( CSteamID steamID ) = 0; + virtual SteamAPICall_t IsFollowing( CSteamID steamID ) = 0; + virtual SteamAPICall_t EnumerateFollowingList( uint32 unStartIndex ) = 0; +}; + +#define STEAMFRIENDS_INTERFACE_VERSION "SteamFriends015" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +//----------------------------------------------------------------------------- +// Purpose: called when a friends' status changes +//----------------------------------------------------------------------------- +struct PersonaStateChange_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 4 }; + + uint64 m_ulSteamID; // steamID of the friend who changed + int m_nChangeFlags; // what's changed +}; + + +// used in PersonaStateChange_t::m_nChangeFlags to describe what's changed about a user +// these flags describe what the client has learned has changed recently, so on startup you'll see a name, avatar & relationship change for every friend +enum EPersonaChange +{ + k_EPersonaChangeName = 0x0001, + k_EPersonaChangeStatus = 0x0002, + k_EPersonaChangeComeOnline = 0x0004, + k_EPersonaChangeGoneOffline = 0x0008, + k_EPersonaChangeGamePlayed = 0x0010, + k_EPersonaChangeGameServer = 0x0020, + k_EPersonaChangeAvatar = 0x0040, + k_EPersonaChangeJoinedSource= 0x0080, + k_EPersonaChangeLeftSource = 0x0100, + k_EPersonaChangeRelationshipChanged = 0x0200, + k_EPersonaChangeNameFirstSet = 0x0400, + k_EPersonaChangeFacebookInfo = 0x0800, + k_EPersonaChangeNickname = 0x1000, + k_EPersonaChangeSteamLevel = 0x2000, +}; + + +//----------------------------------------------------------------------------- +// Purpose: posted when game overlay activates or deactivates +// the game can use this to be pause or resume single player games +//----------------------------------------------------------------------------- +struct GameOverlayActivated_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 31 }; + uint8 m_bActive; // true if it's just been activated, false otherwise +}; + + +//----------------------------------------------------------------------------- +// Purpose: called when the user tries to join a different game server from their friends list +// game client should attempt to connect to specified server when this is received +//----------------------------------------------------------------------------- +struct GameServerChangeRequested_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 32 }; + char m_rgchServer[64]; // server address ("127.0.0.1:27015", "tf2.valvesoftware.com") + char m_rgchPassword[64]; // server password, if any +}; + + +//----------------------------------------------------------------------------- +// Purpose: called when the user tries to join a lobby from their friends list +// game client should attempt to connect to specified lobby when this is received +//----------------------------------------------------------------------------- +struct GameLobbyJoinRequested_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 33 }; + CSteamID m_steamIDLobby; + + // The friend they did the join via (will be invalid if not directly via a friend) + // + // On PS3, the friend will be invalid if this was triggered by a PSN invite via the XMB, but + // the account type will be console user so you can tell at least that this was from a PSN friend + // rather than a Steam friend. + CSteamID m_steamIDFriend; +}; + + +//----------------------------------------------------------------------------- +// Purpose: called when an avatar is loaded in from a previous GetLargeFriendAvatar() call +// if the image wasn't already available +//----------------------------------------------------------------------------- +struct AvatarImageLoaded_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 34 }; + CSteamID m_steamID; // steamid the avatar has been loaded for + int m_iImage; // the image index of the now loaded image + int m_iWide; // width of the loaded image + int m_iTall; // height of the loaded image +}; + + +//----------------------------------------------------------------------------- +// Purpose: marks the return of a request officer list call +//----------------------------------------------------------------------------- +struct ClanOfficerListResponse_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 35 }; + CSteamID m_steamIDClan; + int m_cOfficers; + uint8 m_bSuccess; +}; + + +//----------------------------------------------------------------------------- +// Purpose: callback indicating updated data about friends rich presence information +//----------------------------------------------------------------------------- +struct FriendRichPresenceUpdate_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 36 }; + CSteamID m_steamIDFriend; // friend who's rich presence has changed + AppId_t m_nAppID; // the appID of the game (should always be the current game) +}; + + +//----------------------------------------------------------------------------- +// Purpose: called when the user tries to join a game from their friends list +// rich presence will have been set with the "connect" key which is set here +//----------------------------------------------------------------------------- +struct GameRichPresenceJoinRequested_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 37 }; + CSteamID m_steamIDFriend; // the friend they did the join via (will be invalid if not directly via a friend) + char m_rgchConnect[k_cchMaxRichPresenceValueLength]; +}; + + +//----------------------------------------------------------------------------- +// Purpose: a chat message has been received for a clan chat the game has joined +//----------------------------------------------------------------------------- +struct GameConnectedClanChatMsg_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 38 }; + CSteamID m_steamIDClanChat; + CSteamID m_steamIDUser; + int m_iMessageID; +}; + + +//----------------------------------------------------------------------------- +// Purpose: a user has joined a clan chat +//----------------------------------------------------------------------------- +struct GameConnectedChatJoin_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 39 }; + CSteamID m_steamIDClanChat; + CSteamID m_steamIDUser; +}; + + +//----------------------------------------------------------------------------- +// Purpose: a user has left the chat we're in +//----------------------------------------------------------------------------- +struct GameConnectedChatLeave_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 40 }; + CSteamID m_steamIDClanChat; + CSteamID m_steamIDUser; + bool m_bKicked; // true if admin kicked + bool m_bDropped; // true if Steam connection dropped +}; + + +//----------------------------------------------------------------------------- +// Purpose: a DownloadClanActivityCounts() call has finished +//----------------------------------------------------------------------------- +struct DownloadClanActivityCountsResult_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 41 }; + bool m_bSuccess; +}; + + +//----------------------------------------------------------------------------- +// Purpose: a JoinClanChatRoom() call has finished +//----------------------------------------------------------------------------- +struct JoinClanChatRoomCompletionResult_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 42 }; + CSteamID m_steamIDClanChat; + EChatRoomEnterResponse m_eChatRoomEnterResponse; +}; + +//----------------------------------------------------------------------------- +// Purpose: a chat message has been received from a user +//----------------------------------------------------------------------------- +struct GameConnectedFriendChatMsg_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 43 }; + CSteamID m_steamIDUser; + int m_iMessageID; +}; + + +struct FriendsGetFollowerCount_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 44 }; + EResult m_eResult; + CSteamID m_steamID; + int m_nCount; +}; + + +struct FriendsIsFollowing_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 45 }; + EResult m_eResult; + CSteamID m_steamID; + bool m_bIsFollowing; +}; + + +struct FriendsEnumerateFollowingList_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 46 }; + EResult m_eResult; + CSteamID m_rgSteamID[ k_cEnumerateFollowersMax ]; + int32 m_nResultsReturned; + int32 m_nTotalResultCount; +}; + +//----------------------------------------------------------------------------- +// Purpose: reports the result of an attempt to change the user's persona name +//----------------------------------------------------------------------------- +struct SetPersonaNameResponse_t +{ + enum { k_iCallback = k_iSteamFriendsCallbacks + 47 }; + + bool m_bSuccess; // true if name change succeeded completely. + bool m_bLocalSuccess; // true if name change was retained locally. (We might not have been able to communicate with Steam) + EResult m_result; // detailed result code +}; + + +#pragma pack( pop ) + +#endif // ISTEAMFRIENDS_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgamecoordinator.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgamecoordinator.h new file mode 100644 index 0000000..5ab0637 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgamecoordinator.h @@ -0,0 +1,75 @@ +//====== Copyright ©, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to the game coordinator for this application +// +//============================================================================= + +#ifndef ISTEAMGAMECOORDINATOR +#define ISTEAMGAMECOORDINATOR +#ifdef _WIN32 +#pragma once +#endif + +#include "steamtypes.h" +#include "steamclientpublic.h" + + +// list of possible return values from the ISteamGameCoordinator API +enum EGCResults +{ + k_EGCResultOK = 0, + k_EGCResultNoMessage = 1, // There is no message in the queue + k_EGCResultBufferTooSmall = 2, // The buffer is too small for the requested message + k_EGCResultNotLoggedOn = 3, // The client is not logged onto Steam + k_EGCResultInvalidMessage = 4, // Something was wrong with the message being sent with SendMessage +}; + + +//----------------------------------------------------------------------------- +// Purpose: Functions for sending and receiving messages from the Game Coordinator +// for this application +//----------------------------------------------------------------------------- +class ISteamGameCoordinator +{ +public: + + // sends a message to the Game Coordinator + virtual EGCResults SendMessage( uint32 unMsgType, const void *pubData, uint32 cubData ) = 0; + + // returns true if there is a message waiting from the game coordinator + virtual bool IsMessageAvailable( uint32 *pcubMsgSize ) = 0; + + // fills the provided buffer with the first message in the queue and returns k_EGCResultOK or + // returns k_EGCResultNoMessage if there is no message waiting. pcubMsgSize is filled with the message size. + // If the provided buffer is not large enough to fit the entire message, k_EGCResultBufferTooSmall is returned + // and the message remains at the head of the queue. + virtual EGCResults RetrieveMessage( uint32 *punMsgType, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize ) = 0; + +}; +#define STEAMGAMECOORDINATOR_INTERFACE_VERSION "SteamGameCoordinator001" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +// callback notification - A new message is available for reading from the message queue +struct GCMessageAvailable_t +{ + enum { k_iCallback = k_iSteamGameCoordinatorCallbacks + 1 }; + uint32 m_nMessageSize; +}; + +// callback notification - A message failed to make it to the GC. It may be down temporarily +struct GCMessageFailed_t +{ + enum { k_iCallback = k_iSteamGameCoordinatorCallbacks + 2 }; +}; + +#pragma pack( pop ) + +#endif // ISTEAMGAMECOORDINATOR diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgameserver.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgameserver.h new file mode 100644 index 0000000..cc10998 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgameserver.h @@ -0,0 +1,384 @@ +//====== Copyright (c) 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to steam for game servers +// +//============================================================================= + +#ifndef ISTEAMGAMESERVER_H +#define ISTEAMGAMESERVER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +#define MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE ((uint16)-1) + +//----------------------------------------------------------------------------- +// Purpose: Functions for authenticating users via Steam to play on a game server +//----------------------------------------------------------------------------- +class ISteamGameServer +{ +public: + +// +// Basic server data. These properties, if set, must be set before before calling LogOn. They +// may not be changed after logged in. +// + + /// This is called by SteamGameServer_Init, and you will usually not need to call it directly + virtual bool InitGameServer( uint32 unIP, uint16 usGamePort, uint16 usQueryPort, uint32 unFlags, AppId_t nGameAppId, const char *pchVersionString ) = 0; + + /// Game product identifier. This is currently used by the master server for version checking purposes. + /// It's a required field, but will eventually will go away, and the AppID will be used for this purpose. + virtual void SetProduct( const char *pszProduct ) = 0; + + /// Description of the game. This is a required field and is displayed in the steam server browser....for now. + /// This is a required field, but it will go away eventually, as the data should be determined from the AppID. + virtual void SetGameDescription( const char *pszGameDescription ) = 0; + + /// If your game is a "mod," pass the string that identifies it. The default is an empty string, meaning + /// this application is the original game, not a mod. + /// + /// @see k_cbMaxGameServerGameDir + virtual void SetModDir( const char *pszModDir ) = 0; + + /// Is this is a dedicated server? The default value is false. + virtual void SetDedicatedServer( bool bDedicated ) = 0; + +// +// Login +// + + /// Begin process to login to a persistent game server account + /// + /// You need to register for callbacks to determine the result of this operation. + /// @see SteamServersConnected_t + /// @see SteamServerConnectFailure_t + /// @see SteamServersDisconnected_t + virtual void LogOn( const char *pszToken ) = 0; + + /// Login to a generic, anonymous account. + /// + /// Note: in previous versions of the SDK, this was automatically called within SteamGameServer_Init, + /// but this is no longer the case. + virtual void LogOnAnonymous() = 0; + + /// Begin process of logging game server out of steam + virtual void LogOff() = 0; + + // status functions + virtual bool BLoggedOn() = 0; + virtual bool BSecure() = 0; + virtual CSteamID GetSteamID() = 0; + + /// Returns true if the master server has requested a restart. + /// Only returns true once per request. + virtual bool WasRestartRequested() = 0; + +// +// Server state. These properties may be changed at any time. +// + + /// Max player count that will be reported to server browser and client queries + virtual void SetMaxPlayerCount( int cPlayersMax ) = 0; + + /// Number of bots. Default value is zero + virtual void SetBotPlayerCount( int cBotplayers ) = 0; + + /// Set the name of server as it will appear in the server browser + /// + /// @see k_cbMaxGameServerName + virtual void SetServerName( const char *pszServerName ) = 0; + + /// Set name of map to report in the server browser + /// + /// @see k_cbMaxGameServerName + virtual void SetMapName( const char *pszMapName ) = 0; + + /// Let people know if your server will require a password + virtual void SetPasswordProtected( bool bPasswordProtected ) = 0; + + /// Spectator server. The default value is zero, meaning the service + /// is not used. + virtual void SetSpectatorPort( uint16 unSpectatorPort ) = 0; + + /// Name of the spectator server. (Only used if spectator port is nonzero.) + /// + /// @see k_cbMaxGameServerMapName + virtual void SetSpectatorServerName( const char *pszSpectatorServerName ) = 0; + + /// Call this to clear the whole list of key/values that are sent in rules queries. + virtual void ClearAllKeyValues() = 0; + + /// Call this to add/update a key/value pair. + virtual void SetKeyValue( const char *pKey, const char *pValue ) = 0; + + /// Sets a string defining the "gametags" for this server, this is optional, but if it is set + /// it allows users to filter in the matchmaking/server-browser interfaces based on the value + /// + /// @see k_cbMaxGameServerTags + virtual void SetGameTags( const char *pchGameTags ) = 0; + + /// Sets a string defining the "gamedata" for this server, this is optional, but if it is set + /// it allows users to filter in the matchmaking/server-browser interfaces based on the value + /// don't set this unless it actually changes, its only uploaded to the master once (when + /// acknowledged) + /// + /// @see k_cbMaxGameServerGameData + virtual void SetGameData( const char *pchGameData ) = 0; + + /// Region identifier. This is an optional field, the default value is empty, meaning the "world" region + virtual void SetRegion( const char *pszRegion ) = 0; + +// +// Player list management / authentication +// + + // Handles receiving a new connection from a Steam user. This call will ask the Steam + // servers to validate the users identity, app ownership, and VAC status. If the Steam servers + // are off-line, then it will validate the cached ticket itself which will validate app ownership + // and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection() + // and must then be sent up to the game server for authentication. + // + // Return Value: returns true if the users ticket passes basic checks. pSteamIDUser will contain the Steam ID of this user. pSteamIDUser must NOT be NULL + // If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication + // for the user has succeeded or failed (the steamid in the callback will match the one returned by this call) + virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0; + + // Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation. + // + // Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect() + // when this user leaves the server just like you would for a real user. + virtual CSteamID CreateUnauthenticatedUserConnection() = 0; + + // Should be called whenever a user leaves our game server, this lets Steam internally + // track which users are currently on which servers for the purposes of preventing a single + // account being logged into multiple servers, showing who is currently on a server, etc. + virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0; + + // Update the data to be displayed in the server browser and matchmaking interfaces for a user + // currently connected to the server. For regular users you must call this after you receive a + // GSUserValidationSuccess callback. + // + // Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player) + virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0; + + // New auth system APIs - do not mix with the old auth system APIs. + // ---------------------------------------------------------------- + + // Retrieve ticket to be sent to the entity who wishes to authenticate you ( using BeginAuthSession API ). + // pcbTicket retrieves the length of the actual ticket. + virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0; + + // Authenticate ticket ( from GetAuthSessionTicket ) from entity steamID to be sure it is valid and isnt reused + // Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse ) + virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0; + + // Stop tracking started by BeginAuthSession - called when no longer playing game with this entity + virtual void EndAuthSession( CSteamID steamID ) = 0; + + // Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to + virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0; + + // After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function + // to determine if the user owns downloadable content specified by the provided AppID. + virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0; + + // Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t + // returns false if we're not connected to the steam servers and thus cannot ask + virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0; + + + // these two functions s are deprecated, and will not return results + // they will be removed in a future version of the SDK + virtual void GetGameplayStats( ) = 0; + virtual SteamAPICall_t GetServerReputation( ) = 0; + + // Returns the public IP of the server according to Steam, useful when the server is + // behind NAT and you want to advertise its IP in a lobby for other clients to directly + // connect to + virtual uint32 GetPublicIP() = 0; + +// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own +// socket to talk to the master server on, it lets the game use its socket to forward messages +// back and forth. This prevents us from requiring server ops to open up yet another port +// in their firewalls. +// +// the IP address and port should be in host order, i.e 127.0.0.1 == 0x7f000001 + + // These are used when you've elected to multiplex the game server's UDP socket + // rather than having the master server updater use its own sockets. + // + // Source games use this to simplify the job of the server admins, so they + // don't have to open up more ports on their firewalls. + + // Call this when a packet that starts with 0xFFFFFFFF comes in. That means + // it's for us. + virtual bool HandleIncomingPacket( const void *pData, int cbData, uint32 srcIP, uint16 srcPort ) = 0; + + // AFTER calling HandleIncomingPacket for any packets that came in that frame, call this. + // This gets a packet that the master server updater needs to send out on UDP. + // It returns the length of the packet it wants to send, or 0 if there are no more packets to send. + // Call this each frame until it returns 0. + virtual int GetNextOutgoingPacket( void *pOut, int cbMaxOut, uint32 *pNetAdr, uint16 *pPort ) = 0; + +// +// Control heartbeats / advertisement with master server +// + + // Call this as often as you like to tell the master server updater whether or not + // you want it to be active (default: off). + virtual void EnableHeartbeats( bool bActive ) = 0; + + // You usually don't need to modify this. + // Pass -1 to use the default value for iHeartbeatInterval. + // Some mods change this. + virtual void SetHeartbeatInterval( int iHeartbeatInterval ) = 0; + + // Force a heartbeat to steam at the next opportunity + virtual void ForceHeartbeat() = 0; + + // associate this game server with this clan for the purposes of computing player compat + virtual SteamAPICall_t AssociateWithClan( CSteamID steamIDClan ) = 0; + + // ask if any of the current players dont want to play with this new player - or vice versa + virtual SteamAPICall_t ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer ) = 0; + +}; + +#define STEAMGAMESERVER_INTERFACE_VERSION "SteamGameServer012" + +// game server flags +const uint32 k_unServerFlagNone = 0x00; +const uint32 k_unServerFlagActive = 0x01; // server has users playing +const uint32 k_unServerFlagSecure = 0x02; // server wants to be secure +const uint32 k_unServerFlagDedicated = 0x04; // server is dedicated +const uint32 k_unServerFlagLinux = 0x08; // linux build +const uint32 k_unServerFlagPassworded = 0x10; // password protected +const uint32 k_unServerFlagPrivate = 0x20; // server shouldn't list on master server and + // won't enforce authentication of users that connect to the server. + // Useful when you run a server where the clients may not + // be connected to the internet but you want them to play (i.e LANs) + + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + +// client has been approved to connect to this game server +struct GSClientApprove_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 1 }; + CSteamID m_SteamID; // SteamID of approved player + CSteamID m_OwnerSteamID; // SteamID of original owner for game license +}; + + +// client has been denied to connection to this game server +struct GSClientDeny_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 2 }; + CSteamID m_SteamID; + EDenyReason m_eDenyReason; + char m_rgchOptionalText[128]; +}; + + +// request the game server should kick the user +struct GSClientKick_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 3 }; + CSteamID m_SteamID; + EDenyReason m_eDenyReason; +}; + +// NOTE: callback values 4 and 5 are skipped because they are used for old deprecated callbacks, +// do not reuse them here. + + +// client achievement info +struct GSClientAchievementStatus_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 6 }; + uint64 m_SteamID; + char m_pchAchievement[128]; + bool m_bUnlocked; +}; + +// received when the game server requests to be displayed as secure (VAC protected) +// m_bSecure is true if the game server should display itself as secure to users, false otherwise +struct GSPolicyResponse_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 15 }; + uint8 m_bSecure; +}; + +// GS gameplay stats info +struct GSGameplayStats_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 7 }; + EResult m_eResult; // Result of the call + int32 m_nRank; // Overall rank of the server (0-based) + uint32 m_unTotalConnects; // Total number of clients who have ever connected to the server + uint32 m_unTotalMinutesPlayed; // Total number of minutes ever played on the server +}; + +// send as a reply to RequestUserGroupStatus() +struct GSClientGroupStatus_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 8 }; + CSteamID m_SteamIDUser; + CSteamID m_SteamIDGroup; + bool m_bMember; + bool m_bOfficer; +}; + +// Sent as a reply to GetServerReputation() +struct GSReputation_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 9 }; + EResult m_eResult; // Result of the call; + uint32 m_unReputationScore; // The reputation score for the game server + bool m_bBanned; // True if the server is banned from the Steam + // master servers + + // The following members are only filled out if m_bBanned is true. They will all + // be set to zero otherwise. Master server bans are by IP so it is possible to be + // banned even when the score is good high if there is a bad server on another port. + // This information can be used to determine which server is bad. + + uint32 m_unBannedIP; // The IP of the banned server + uint16 m_usBannedPort; // The port of the banned server + uint64 m_ulBannedGameID; // The game ID the banned server is serving + uint32 m_unBanExpires; // Time the ban expires, expressed in the Unix epoch (seconds since 1/1/1970) +}; + +// Sent as a reply to AssociateWithClan() +struct AssociateWithClanResult_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 10 }; + EResult m_eResult; // Result of the call; +}; + +// Sent as a reply to ComputeNewPlayerCompatibility() +struct ComputeNewPlayerCompatibilityResult_t +{ + enum { k_iCallback = k_iSteamGameServerCallbacks + 11 }; + EResult m_eResult; // Result of the call; + int m_cPlayersThatDontLikeCandidate; + int m_cPlayersThatCandidateDoesntLike; + int m_cClanPlayersThatDontLikeCandidate; + CSteamID m_SteamIDCandidate; +}; + + +#pragma pack( pop ) + +#endif // ISTEAMGAMESERVER_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgameserverstats.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgameserverstats.h new file mode 100644 index 0000000..0facf43 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamgameserverstats.h @@ -0,0 +1,99 @@ +//====== Copyright © Valve Corporation, All rights reserved. ======= +// +// Purpose: interface for game servers to steam stats and achievements +// +//============================================================================= + +#ifndef ISTEAMGAMESERVERSTATS_H +#define ISTEAMGAMESERVERSTATS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +//----------------------------------------------------------------------------- +// Purpose: Functions for authenticating users via Steam to play on a game server +//----------------------------------------------------------------------------- +class ISteamGameServerStats +{ +public: + // downloads stats for the user + // returns a GSStatsReceived_t callback when completed + // if the user has no stats, GSStatsReceived_t.m_eResult will be set to k_EResultFail + // these stats will only be auto-updated for clients playing on the server. For other + // users you'll need to call RequestUserStats() again to refresh any data + virtual SteamAPICall_t RequestUserStats( CSteamID steamIDUser ) = 0; + + // requests stat information for a user, usable after a successful call to RequestUserStats() + virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData ) = 0; + virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData ) = 0; + virtual bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved ) = 0; + + // Set / update stats and achievements. + // Note: These updates will work only on stats game servers are allowed to edit and only for + // game servers that have been declared as officially controlled by the game creators. + // Set the IP range of your official servers on the Steamworks page + virtual bool SetUserStat( CSteamID steamIDUser, const char *pchName, int32 nData ) = 0; + virtual bool SetUserStat( CSteamID steamIDUser, const char *pchName, float fData ) = 0; + virtual bool UpdateUserAvgRateStat( CSteamID steamIDUser, const char *pchName, float flCountThisSession, double dSessionLength ) = 0; + + virtual bool SetUserAchievement( CSteamID steamIDUser, const char *pchName ) = 0; + virtual bool ClearUserAchievement( CSteamID steamIDUser, const char *pchName ) = 0; + + // Store the current data on the server, will get a GSStatsStored_t callback when set. + // + // If the callback has a result of k_EResultInvalidParam, one or more stats + // uploaded has been rejected, either because they broke constraints + // or were out of date. In this case the server sends back updated values. + // The stats should be re-iterated to keep in sync. + virtual SteamAPICall_t StoreUserStats( CSteamID steamIDUser ) = 0; +}; + +#define STEAMGAMESERVERSTATS_INTERFACE_VERSION "SteamGameServerStats001" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +//----------------------------------------------------------------------------- +// Purpose: called when the latests stats and achievements have been received +// from the server +//----------------------------------------------------------------------------- +struct GSStatsReceived_t +{ + enum { k_iCallback = k_iSteamGameServerStatsCallbacks }; + EResult m_eResult; // Success / error fetching the stats + CSteamID m_steamIDUser; // The user for whom the stats are retrieved for +}; + + +//----------------------------------------------------------------------------- +// Purpose: result of a request to store the user stats for a game +//----------------------------------------------------------------------------- +struct GSStatsStored_t +{ + enum { k_iCallback = k_iSteamGameServerStatsCallbacks + 1 }; + EResult m_eResult; // success / error + CSteamID m_steamIDUser; // The user for whom the stats were stored +}; + +//----------------------------------------------------------------------------- +// Purpose: Callback indicating that a user's stats have been unloaded. +// Call RequestUserStats again to access stats for this user +//----------------------------------------------------------------------------- +struct GSStatsUnloaded_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 8 }; + CSteamID m_steamIDUser; // User whose stats have been unloaded +}; + +#pragma pack( pop ) + + +#endif // ISTEAMGAMESERVERSTATS_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamhtmlsurface.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamhtmlsurface.h new file mode 100644 index 0000000..c257164 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamhtmlsurface.h @@ -0,0 +1,444 @@ +//====== Copyright 1996-2013, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to display html pages in a texture +// +//============================================================================= + +#ifndef ISTEAMHTMLSURFACE_H +#define ISTEAMHTMLSURFACE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +typedef uint32 HHTMLBrowser; +const uint32 INVALID_HTMLBROWSER = 0; + +//----------------------------------------------------------------------------- +// Purpose: Functions for displaying HTML pages and interacting with them +//----------------------------------------------------------------------------- +class ISteamHTMLSurface +{ +public: + virtual ~ISteamHTMLSurface() {} + + // Must call init and shutdown when starting/ending use of the interface + virtual bool Init() = 0; + virtual bool Shutdown() = 0; + + // Create a browser object for display of a html page, when creation is complete the call handle + // will return a HTML_BrowserReady_t callback for the HHTMLBrowser of your new browser. + // The user agent string is a substring to be added to the general user agent string so you can + // identify your client on web servers. + // The userCSS string lets you apply a CSS style sheet to every displayed page, leave null if + // you do not require this functionality. + virtual SteamAPICall_t CreateBrowser( const char *pchUserAgent, const char *pchUserCSS ) = 0; + + // Call this when you are done with a html surface, this lets us free the resources being used by it + virtual void RemoveBrowser( HHTMLBrowser unBrowserHandle ) = 0; + + // Navigate to this URL, results in a HTML_StartRequest_t as the request commences + virtual void LoadURL( HHTMLBrowser unBrowserHandle, const char *pchURL, const char *pchPostData ) = 0; + + // Tells the surface the size in pixels to display the surface + virtual void SetSize( HHTMLBrowser unBrowserHandle, uint32 unWidth, uint32 unHeight ) = 0; + + // Stop the load of the current html page + virtual void StopLoad( HHTMLBrowser unBrowserHandle ) = 0; + // Reload (most likely from local cache) the current page + virtual void Reload( HHTMLBrowser unBrowserHandle ) = 0; + // navigate back in the page history + virtual void GoBack( HHTMLBrowser unBrowserHandle ) = 0; + // navigate forward in the page history + virtual void GoForward( HHTMLBrowser unBrowserHandle ) = 0; + + // add this header to any url requests from this browser + virtual void AddHeader( HHTMLBrowser unBrowserHandle, const char *pchKey, const char *pchValue ) = 0; + // run this javascript script in the currently loaded page + virtual void ExecuteJavascript( HHTMLBrowser unBrowserHandle, const char *pchScript ) = 0; + + enum EHTMLMouseButton + { + eHTMLMouseButton_Left = 0, + eHTMLMouseButton_Right = 1, + eHTMLMouseButton_Middle = 2, + }; + + // Mouse click and mouse movement commands + virtual void MouseUp( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0; + virtual void MouseDown( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0; + virtual void MouseDoubleClick( HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton ) = 0; + // x and y are relative to the HTML bounds + virtual void MouseMove( HHTMLBrowser unBrowserHandle, int x, int y ) = 0; + // nDelta is pixels of scroll + virtual void MouseWheel( HHTMLBrowser unBrowserHandle, int32 nDelta ) = 0; + + enum EMouseCursor + { + dc_user = 0, + dc_none, + dc_arrow, + dc_ibeam, + dc_hourglass, + dc_waitarrow, + dc_crosshair, + dc_up, + dc_sizenw, + dc_sizese, + dc_sizene, + dc_sizesw, + dc_sizew, + dc_sizee, + dc_sizen, + dc_sizes, + dc_sizewe, + dc_sizens, + dc_sizeall, + dc_no, + dc_hand, + dc_blank, // don't show any custom cursor, just use your default + dc_middle_pan, + dc_north_pan, + dc_north_east_pan, + dc_east_pan, + dc_south_east_pan, + dc_south_pan, + dc_south_west_pan, + dc_west_pan, + dc_north_west_pan, + dc_alias, + dc_cell, + dc_colresize, + dc_copycur, + dc_verticaltext, + dc_rowresize, + dc_zoomin, + dc_zoomout, + dc_help, + dc_custom, + + dc_last, // custom cursors start from this value and up + }; + + enum EHTMLKeyModifiers + { + k_eHTMLKeyModifier_None = 0, + k_eHTMLKeyModifier_AltDown = 1 << 0, + k_eHTMLKeyModifier_CtrlDown = 1 << 1, + k_eHTMLKeyModifier_ShiftDown = 1 << 2, + }; + + // keyboard interactions, native keycode is the virtual key code value from your OS + virtual void KeyDown( HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0; + virtual void KeyUp( HHTMLBrowser unBrowserHandle, uint32 nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0; + // cUnicodeChar is the unicode character point for this keypress (and potentially multiple chars per press) + virtual void KeyChar( HHTMLBrowser unBrowserHandle, uint32 cUnicodeChar, EHTMLKeyModifiers eHTMLKeyModifiers ) = 0; + + // programmatically scroll this many pixels on the page + virtual void SetHorizontalScroll( HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll ) = 0; + virtual void SetVerticalScroll( HHTMLBrowser unBrowserHandle, uint32 nAbsolutePixelScroll ) = 0; + + // tell the html control if it has key focus currently, controls showing the I-beam cursor in text controls amongst other things + virtual void SetKeyFocus( HHTMLBrowser unBrowserHandle, bool bHasKeyFocus ) = 0; + + // open the current pages html code in the local editor of choice, used for debugging + virtual void ViewSource( HHTMLBrowser unBrowserHandle ) = 0; + // copy the currently selected text on the html page to the local clipboard + virtual void CopyToClipboard( HHTMLBrowser unBrowserHandle ) = 0; + // paste from the local clipboard to the current html page + virtual void PasteFromClipboard( HHTMLBrowser unBrowserHandle ) = 0; + + // find this string in the browser, if bCurrentlyInFind is true then instead cycle to the next matching element + virtual void Find( HHTMLBrowser unBrowserHandle, const char *pchSearchStr, bool bCurrentlyInFind, bool bReverse ) = 0; + // cancel a currently running find + virtual void StopFind( HHTMLBrowser unBrowserHandle ) = 0; + + // return details about the link at position x,y on the current page + virtual void GetLinkAtPosition( HHTMLBrowser unBrowserHandle, int x, int y ) = 0; + + // set a webcookie for the hostname in question + virtual void SetCookie( const char *pchHostname, const char *pchKey, const char *pchValue, const char *pchPath = "/", RTime32 nExpires = 0, bool bSecure = false, bool bHTTPOnly = false ) = 0; + + // Zoom the current page by flZoom ( from 0.0 to 2.0, so to zoom to 120% use 1.2 ), zooming around point X,Y in the page (use 0,0 if you don't care) + virtual void SetPageScaleFactor( HHTMLBrowser unBrowserHandle, float flZoom, int nPointX, int nPointY ) = 0; + + // Enable/disable low-resource background mode, where javascript and repaint timers are throttled, resources are + // more aggressively purged from memory, and audio/video elements are paused. When background mode is enabled, + // all HTML5 video and audio objects will execute ".pause()" and gain the property "._steam_background_paused = 1". + // When background mode is disabled, any video or audio objects with that property will resume with ".play()". + virtual void SetBackgroundMode( HHTMLBrowser unBrowserHandle, bool bBackgroundMode ) = 0; + + // CALLBACKS + // + // These set of functions are used as responses to callback requests + // + + // You MUST call this in response to a HTML_StartRequest_t callback + // Set bAllowed to true to allow this navigation, false to cancel it and stay + // on the current page. You can use this feature to limit the valid pages + // allowed in your HTML surface. + virtual void AllowStartRequest( HHTMLBrowser unBrowserHandle, bool bAllowed ) = 0; + + // You MUST call this in response to a HTML_JSAlert_t or HTML_JSConfirm_t callback + // Set bResult to true for the OK option of a confirm, use false otherwise + virtual void JSDialogResponse( HHTMLBrowser unBrowserHandle, bool bResult ) = 0; + + // You MUST call this in response to a HTML_FileOpenDialog_t callback + virtual void FileLoadDialogResponse( HHTMLBrowser unBrowserHandle, const char **pchSelectedFiles ) = 0; +}; + +#define STEAMHTMLSURFACE_INTERFACE_VERSION "STEAMHTMLSURFACE_INTERFACE_VERSION_003" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + +//----------------------------------------------------------------------------- +// Purpose: The browser is ready for use +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_BrowserReady_t, k_iSteamHTMLSurfaceCallbacks + 1 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // this browser is now fully created and ready to navigate to pages +END_DEFINE_CALLBACK_1() + + +//----------------------------------------------------------------------------- +// Purpose: the browser has a pending paint +//----------------------------------------------------------------------------- +DEFINE_CALLBACK(HTML_NeedsPaint_t, k_iSteamHTMLSurfaceCallbacks + 2) +CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the browser that needs the paint +CALLBACK_MEMBER(1, const char *, pBGRA ) // a pointer to the B8G8R8A8 data for this surface, valid until SteamAPI_RunCallbacks is next called +CALLBACK_MEMBER(2, uint32, unWide) // the total width of the pBGRA texture +CALLBACK_MEMBER(3, uint32, unTall) // the total height of the pBGRA texture +CALLBACK_MEMBER(4, uint32, unUpdateX) // the offset in X for the damage rect for this update +CALLBACK_MEMBER(5, uint32, unUpdateY) // the offset in Y for the damage rect for this update +CALLBACK_MEMBER(6, uint32, unUpdateWide) // the width of the damage rect for this update +CALLBACK_MEMBER(7, uint32, unUpdateTall) // the height of the damage rect for this update +CALLBACK_MEMBER(8, uint32, unScrollX) // the page scroll the browser was at when this texture was rendered +CALLBACK_MEMBER(9, uint32, unScrollY) // the page scroll the browser was at when this texture was rendered +CALLBACK_MEMBER(10, float, flPageScale) // the page scale factor on this page when rendered +CALLBACK_MEMBER(11, uint32, unPageSerial) // incremented on each new page load, you can use this to reject draws while navigating to new pages +END_DEFINE_CALLBACK_12() + + +//----------------------------------------------------------------------------- +// Purpose: The browser wanted to navigate to a new page +// NOTE - you MUST call AllowStartRequest in response to this callback +//----------------------------------------------------------------------------- +DEFINE_CALLBACK(HTML_StartRequest_t, k_iSteamHTMLSurfaceCallbacks + 3) +CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface navigating +CALLBACK_MEMBER(1, const char *, pchURL) // the url they wish to navigate to +CALLBACK_MEMBER(2, const char *, pchTarget) // the html link target type (i.e _blank, _self, _parent, _top ) +CALLBACK_MEMBER(3, const char *, pchPostData ) // any posted data for the request +CALLBACK_MEMBER(4, bool, bIsRedirect) // true if this was a http/html redirect from the last load request +END_DEFINE_CALLBACK_5() + + +//----------------------------------------------------------------------------- +// Purpose: The browser has been requested to close due to user interaction (usually from a javascript window.close() call) +//----------------------------------------------------------------------------- +DEFINE_CALLBACK(HTML_CloseBrowser_t, k_iSteamHTMLSurfaceCallbacks + 4) +CALLBACK_MEMBER(0, HHTMLBrowser, unBrowserHandle) // the handle of the surface +END_DEFINE_CALLBACK_1() + + +//----------------------------------------------------------------------------- +// Purpose: the browser is navigating to a new url +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_URLChanged_t, k_iSteamHTMLSurfaceCallbacks + 5 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface navigating +CALLBACK_MEMBER( 1, const char *, pchURL ) // the url they wish to navigate to +CALLBACK_MEMBER( 2, const char *, pchPostData ) // any posted data for the request +CALLBACK_MEMBER( 3, bool, bIsRedirect ) // true if this was a http/html redirect from the last load request +CALLBACK_MEMBER( 4, const char *, pchPageTitle ) // the title of the page +CALLBACK_MEMBER( 5, bool, bNewNavigation ) // true if this was from a fresh tab and not a click on an existing page +END_DEFINE_CALLBACK_6() + + +//----------------------------------------------------------------------------- +// Purpose: A page is finished loading +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_FinishedRequest_t, k_iSteamHTMLSurfaceCallbacks + 6 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchURL ) // +CALLBACK_MEMBER( 2, const char *, pchPageTitle ) // +END_DEFINE_CALLBACK_3() + + +//----------------------------------------------------------------------------- +// Purpose: a request to load this url in a new tab +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_OpenLinkInNewTab_t, k_iSteamHTMLSurfaceCallbacks + 7 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchURL ) // +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: the page has a new title now +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_ChangedTitle_t, k_iSteamHTMLSurfaceCallbacks + 8 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchTitle ) // +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: results from a search +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_SearchResults_t, k_iSteamHTMLSurfaceCallbacks + 9 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, uint32, unResults ) // +CALLBACK_MEMBER( 2, uint32, unCurrentMatch ) // +END_DEFINE_CALLBACK_3() + + +//----------------------------------------------------------------------------- +// Purpose: page history status changed on the ability to go backwards and forward +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_CanGoBackAndForward_t, k_iSteamHTMLSurfaceCallbacks + 10 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, bool, bCanGoBack ) // +CALLBACK_MEMBER( 2, bool, bCanGoForward ) // +END_DEFINE_CALLBACK_3() + + +//----------------------------------------------------------------------------- +// Purpose: details on the visibility and size of the horizontal scrollbar +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_HorizontalScroll_t, k_iSteamHTMLSurfaceCallbacks + 11 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, uint32, unScrollMax ) // +CALLBACK_MEMBER( 2, uint32, unScrollCurrent ) // +CALLBACK_MEMBER( 3, float, flPageScale ) // +CALLBACK_MEMBER( 4, bool , bVisible ) // +CALLBACK_MEMBER( 5, uint32, unPageSize ) // +END_DEFINE_CALLBACK_6() + + +//----------------------------------------------------------------------------- +// Purpose: details on the visibility and size of the vertical scrollbar +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_VerticalScroll_t, k_iSteamHTMLSurfaceCallbacks + 12 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, uint32, unScrollMax ) // +CALLBACK_MEMBER( 2, uint32, unScrollCurrent ) // +CALLBACK_MEMBER( 3, float, flPageScale ) // +CALLBACK_MEMBER( 4, bool, bVisible ) // +CALLBACK_MEMBER( 5, uint32, unPageSize ) // +END_DEFINE_CALLBACK_6() + + +//----------------------------------------------------------------------------- +// Purpose: response to GetLinkAtPosition call +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_LinkAtPosition_t, k_iSteamHTMLSurfaceCallbacks + 13 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, uint32, x ) // NOTE - Not currently set +CALLBACK_MEMBER( 2, uint32, y ) // NOTE - Not currently set +CALLBACK_MEMBER( 3, const char *, pchURL ) // +CALLBACK_MEMBER( 4, bool, bInput ) // +CALLBACK_MEMBER( 5, bool, bLiveLink ) // +END_DEFINE_CALLBACK_6() + + + +//----------------------------------------------------------------------------- +// Purpose: show a Javascript alert dialog, call JSDialogResponse +// when the user dismisses this dialog (or right away to ignore it) +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_JSAlert_t, k_iSteamHTMLSurfaceCallbacks + 14 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchMessage ) // +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: show a Javascript confirmation dialog, call JSDialogResponse +// when the user dismisses this dialog (or right away to ignore it) +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_JSConfirm_t, k_iSteamHTMLSurfaceCallbacks + 15 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchMessage ) // +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: when received show a file open dialog +// then call FileLoadDialogResponse with the file(s) the user selected. +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_FileOpenDialog_t, k_iSteamHTMLSurfaceCallbacks + 16 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchTitle ) // +CALLBACK_MEMBER( 2, const char *, pchInitialFile ) // +END_DEFINE_CALLBACK_3() + + +//----------------------------------------------------------------------------- +// Purpose: a new html window has been created +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_NewWindow_t, k_iSteamHTMLSurfaceCallbacks + 21 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the current surface +CALLBACK_MEMBER( 1, const char *, pchURL ) // the page to load +CALLBACK_MEMBER( 2, uint32, unX ) // the x pos into the page to display the popup +CALLBACK_MEMBER( 3, uint32, unY ) // the y pos into the page to display the popup +CALLBACK_MEMBER( 4, uint32, unWide ) // the total width of the pBGRA texture +CALLBACK_MEMBER( 5, uint32, unTall ) // the total height of the pBGRA texture +CALLBACK_MEMBER( 6, HHTMLBrowser, unNewWindow_BrowserHandle ) // the handle of the new window surface +END_DEFINE_CALLBACK_7() + + +//----------------------------------------------------------------------------- +// Purpose: change the cursor to display +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_SetCursor_t, k_iSteamHTMLSurfaceCallbacks + 22 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, uint32, eMouseCursor ) // the EMouseCursor to display +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: informational message from the browser +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_StatusText_t, k_iSteamHTMLSurfaceCallbacks + 23 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: show a tooltip +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_ShowToolTip_t, k_iSteamHTMLSurfaceCallbacks + 24 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: update the text of an existing tooltip +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_UpdateToolTip_t, k_iSteamHTMLSurfaceCallbacks + 25 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +CALLBACK_MEMBER( 1, const char *, pchMsg ) // the EMouseCursor to display +END_DEFINE_CALLBACK_2() + + +//----------------------------------------------------------------------------- +// Purpose: hide the tooltip you are showing +//----------------------------------------------------------------------------- +DEFINE_CALLBACK( HTML_HideToolTip_t, k_iSteamHTMLSurfaceCallbacks + 26 ) +CALLBACK_MEMBER( 0, HHTMLBrowser, unBrowserHandle ) // the handle of the surface +END_DEFINE_CALLBACK_1() + + +#pragma pack( pop ) + + +#endif // ISTEAMHTMLSURFACE_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamhttp.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamhttp.h new file mode 100644 index 0000000..8fab537 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamhttp.h @@ -0,0 +1,210 @@ +//====== Copyright © 1996-2009, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to http client +// +//============================================================================= + +#ifndef ISTEAMHTTP_H +#define ISTEAMHTTP_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" +#include "steamhttpenums.h" + +// Handle to a HTTP Request handle +typedef uint32 HTTPRequestHandle; +#define INVALID_HTTPREQUEST_HANDLE 0 + +typedef uint32 HTTPCookieContainerHandle; +#define INVALID_HTTPCOOKIE_HANDLE 0 + +//----------------------------------------------------------------------------- +// Purpose: interface to http client +//----------------------------------------------------------------------------- +class ISteamHTTP +{ +public: + + // Initializes a new HTTP request, returning a handle to use in further operations on it. Requires + // the method (GET or POST) and the absolute URL for the request. Both http and https are supported, + // so this string must start with http:// or https:// and should look like http://store.steampowered.com/app/250/ + // or such. + virtual HTTPRequestHandle CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod, const char *pchAbsoluteURL ) = 0; + + // Set a context value for the request, which will be returned in the HTTPRequestCompleted_t callback after + // sending the request. This is just so the caller can easily keep track of which callbacks go with which request data. + virtual bool SetHTTPRequestContextValue( HTTPRequestHandle hRequest, uint64 ulContextValue ) = 0; + + // Set a timeout in seconds for the HTTP request, must be called prior to sending the request. Default + // timeout is 60 seconds if you don't call this. Returns false if the handle is invalid, or the request + // has already been sent. + virtual bool SetHTTPRequestNetworkActivityTimeout( HTTPRequestHandle hRequest, uint32 unTimeoutSeconds ) = 0; + + // Set a request header value for the request, must be called prior to sending the request. Will + // return false if the handle is invalid or the request is already sent. + virtual bool SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, const char *pchHeaderValue ) = 0; + + // Set a GET or POST parameter value on the request, which is set will depend on the EHTTPMethod specified + // when creating the request. Must be called prior to sending the request. Will return false if the + // handle is invalid or the request is already sent. + virtual bool SetHTTPRequestGetOrPostParameter( HTTPRequestHandle hRequest, const char *pchParamName, const char *pchParamValue ) = 0; + + // Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on + // asynchronous response via callback. + // + // Note: If the user is in offline mode in Steam, then this will add a only-if-cached cache-control + // header and only do a local cache lookup rather than sending any actual remote request. + virtual bool SendHTTPRequest( HTTPRequestHandle hRequest, SteamAPICall_t *pCallHandle ) = 0; + + // Sends the HTTP request, will return false on a bad handle, otherwise use SteamCallHandle to wait on + // asynchronous response via callback for completion, and listen for HTTPRequestHeadersReceived_t and + // HTTPRequestDataReceived_t callbacks while streaming. + virtual bool SendHTTPRequestAndStreamResponse( HTTPRequestHandle hRequest, SteamAPICall_t *pCallHandle ) = 0; + + // Defers a request you have sent, the actual HTTP client code may have many requests queued, and this will move + // the specified request to the tail of the queue. Returns false on invalid handle, or if the request is not yet sent. + virtual bool DeferHTTPRequest( HTTPRequestHandle hRequest ) = 0; + + // Prioritizes a request you have sent, the actual HTTP client code may have many requests queued, and this will move + // the specified request to the head of the queue. Returns false on invalid handle, or if the request is not yet sent. + virtual bool PrioritizeHTTPRequest( HTTPRequestHandle hRequest ) = 0; + + // Checks if a response header is present in a HTTP response given a handle from HTTPRequestCompleted_t, also + // returns the size of the header value if present so the caller and allocate a correctly sized buffer for + // GetHTTPResponseHeaderValue. + virtual bool GetHTTPResponseHeaderSize( HTTPRequestHandle hRequest, const char *pchHeaderName, uint32 *unResponseHeaderSize ) = 0; + + // Gets header values from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the + // header is not present or if your buffer is too small to contain it's value. You should first call + // BGetHTTPResponseHeaderSize to check for the presence of the header and to find out the size buffer needed. + virtual bool GetHTTPResponseHeaderValue( HTTPRequestHandle hRequest, const char *pchHeaderName, uint8 *pHeaderValueBuffer, uint32 unBufferSize ) = 0; + + // Gets the size of the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the + // handle is invalid. + virtual bool GetHTTPResponseBodySize( HTTPRequestHandle hRequest, uint32 *unBodySize ) = 0; + + // Gets the body data from a HTTP response given a handle from HTTPRequestCompleted_t, will return false if the + // handle is invalid or is to a streaming response, or if the provided buffer is not the correct size. Use BGetHTTPResponseBodySize first to find out + // the correct buffer size to use. + virtual bool GetHTTPResponseBodyData( HTTPRequestHandle hRequest, uint8 *pBodyDataBuffer, uint32 unBufferSize ) = 0; + + // Gets the body data from a streaming HTTP response given a handle from HTTPRequestDataReceived_t. Will return false if the + // handle is invalid or is to a non-streaming response (meaning it wasn't sent with SendHTTPRequestAndStreamResponse), or if the buffer size and offset + // do not match the size and offset sent in HTTPRequestDataReceived_t. + virtual bool GetHTTPStreamingResponseBodyData( HTTPRequestHandle hRequest, uint32 cOffset, uint8 *pBodyDataBuffer, uint32 unBufferSize ) = 0; + + // Releases an HTTP response handle, should always be called to free resources after receiving a HTTPRequestCompleted_t + // callback and finishing using the response. + virtual bool ReleaseHTTPRequest( HTTPRequestHandle hRequest ) = 0; + + // Gets progress on downloading the body for the request. This will be zero unless a response header has already been + // received which included a content-length field. For responses that contain no content-length it will report + // zero for the duration of the request as the size is unknown until the connection closes. + virtual bool GetHTTPDownloadProgressPct( HTTPRequestHandle hRequest, float *pflPercentOut ) = 0; + + // Sets the body for an HTTP Post request. Will fail and return false on a GET request, and will fail if POST params + // have already been set for the request. Setting this raw body makes it the only contents for the post, the pchContentType + // parameter will set the content-type header for the request so the server may know how to interpret the body. + virtual bool SetHTTPRequestRawPostBody( HTTPRequestHandle hRequest, const char *pchContentType, uint8 *pubBody, uint32 unBodyLen ) = 0; + + // Creates a cookie container handle which you must later free with ReleaseCookieContainer(). If bAllowResponsesToModify=true + // than any response to your requests using this cookie container may add new cookies which may be transmitted with + // future requests. If bAllowResponsesToModify=false than only cookies you explicitly set will be sent. This API is just for + // during process lifetime, after steam restarts no cookies are persisted and you have no way to access the cookie container across + // repeat executions of your process. + virtual HTTPCookieContainerHandle CreateCookieContainer( bool bAllowResponsesToModify ) = 0; + + // Release a cookie container you are finished using, freeing it's memory + virtual bool ReleaseCookieContainer( HTTPCookieContainerHandle hCookieContainer ) = 0; + + // Adds a cookie to the specified cookie container that will be used with future requests. + virtual bool SetCookie( HTTPCookieContainerHandle hCookieContainer, const char *pchHost, const char *pchUrl, const char *pchCookie ) = 0; + + // Set the cookie container to use for a HTTP request + virtual bool SetHTTPRequestCookieContainer( HTTPRequestHandle hRequest, HTTPCookieContainerHandle hCookieContainer ) = 0; + + // Set the extra user agent info for a request, this doesn't clobber the normal user agent, it just adds the extra info on the end + virtual bool SetHTTPRequestUserAgentInfo( HTTPRequestHandle hRequest, const char *pchUserAgentInfo ) = 0; + + // Set that https request should require verified SSL certificate via machines certificate trust store + virtual bool SetHTTPRequestRequiresVerifiedCertificate( HTTPRequestHandle hRequest, bool bRequireVerifiedCertificate ) = 0; + + // Set an absolute timeout on the HTTP request, this is just a total time timeout different than the network activity timeout + // which can bump everytime we get more data + virtual bool SetHTTPRequestAbsoluteTimeoutMS( HTTPRequestHandle hRequest, uint32 unMilliseconds ) = 0; + + // Check if the reason the request failed was because we timed it out (rather than some harder failure) + virtual bool GetHTTPRequestWasTimedOut( HTTPRequestHandle hRequest, bool *pbWasTimedOut ) = 0; +}; + +#define STEAMHTTP_INTERFACE_VERSION "STEAMHTTP_INTERFACE_VERSION002" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +struct HTTPRequestCompleted_t +{ + enum { k_iCallback = k_iClientHTTPCallbacks + 1 }; + + // Handle value for the request that has completed. + HTTPRequestHandle m_hRequest; + + // Context value that the user defined on the request that this callback is associated with, 0 if + // no context value was set. + uint64 m_ulContextValue; + + // This will be true if we actually got any sort of response from the server (even an error). + // It will be false if we failed due to an internal error or client side network failure. + bool m_bRequestSuccessful; + + // Will be the HTTP status code value returned by the server, k_EHTTPStatusCode200OK is the normal + // OK response, if you get something else you probably need to treat it as a failure. + EHTTPStatusCode m_eStatusCode; + + uint32 m_unBodySize; // Same as GetHTTPResponseBodySize() +}; + + +struct HTTPRequestHeadersReceived_t +{ + enum { k_iCallback = k_iClientHTTPCallbacks + 2 }; + + // Handle value for the request that has received headers. + HTTPRequestHandle m_hRequest; + + // Context value that the user defined on the request that this callback is associated with, 0 if + // no context value was set. + uint64 m_ulContextValue; +}; + +struct HTTPRequestDataReceived_t +{ + enum { k_iCallback = k_iClientHTTPCallbacks + 3 }; + + // Handle value for the request that has received data. + HTTPRequestHandle m_hRequest; + + // Context value that the user defined on the request that this callback is associated with, 0 if + // no context value was set. + uint64 m_ulContextValue; + + + // Offset to provide to GetHTTPStreamingResponseBodyData to get this chunk of data + uint32 m_cOffset; + + // Size to provide to GetHTTPStreamingResponseBodyData to get this chunk of data + uint32 m_cBytesReceived; +}; + + +#pragma pack( pop ) + +#endif // ISTEAMHTTP_H \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteaminventory.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteaminventory.h new file mode 100644 index 0000000..3802daf --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteaminventory.h @@ -0,0 +1,354 @@ +//====== Copyright © 1996-2014 Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to Steam Inventory +// +//============================================================================= + +#ifndef ISTEAMINVENTORY_H +#define ISTEAMINVENTORY_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + +// Every individual instance of an item has a globally-unique ItemInstanceID. +// This ID is unique to the combination of (player, specific item instance) +// and will not be transferred to another player or re-used for another item. +typedef uint64 SteamItemInstanceID_t; + +static const SteamItemInstanceID_t k_SteamItemInstanceIDInvalid = ~(SteamItemInstanceID_t)0; + +// Types of items in your game are identified by a 32-bit "item definition number". +// Valid definition numbers are between 1 and 999999999; numbers less than or equal to +// zero are invalid, and numbers greater than or equal to one billion (1x10^9) are +// reserved for internal Steam use. +typedef int32 SteamItemDef_t; + + +enum ESteamItemFlags +{ + // Item status flags - these flags are permanently attached to specific item instances + k_ESteamItemNoTrade = 1 << 0, // This item is account-locked and cannot be traded or given away. + + // Action confirmation flags - these flags are set one time only, as part of a result set + k_ESteamItemRemoved = 1 << 8, // The item has been destroyed, traded away, expired, or otherwise invalidated + k_ESteamItemConsumed = 1 << 9, // The item quantity has been decreased by 1 via ConsumeItem API. + + // All other flag bits are currently reserved for internal Steam use at this time. + // Do not assume anything about the state of other flags which are not defined here. +}; + +struct SteamItemDetails_t +{ + SteamItemInstanceID_t m_itemId; + SteamItemDef_t m_iDefinition; + uint16 m_unQuantity; + uint16 m_unFlags; // see ESteamItemFlags +}; + +typedef int32 SteamInventoryResult_t; + +static const SteamInventoryResult_t k_SteamInventoryResultInvalid = -1; + + +//----------------------------------------------------------------------------- +// Purpose: Steam Inventory query and manipulation API +//----------------------------------------------------------------------------- +class ISteamInventory +{ +public: + + // INVENTORY ASYNC RESULT MANAGEMENT + // + // Asynchronous inventory queries always output a result handle which can be used with + // GetResultStatus, GetResultItems, etc. A SteamInventoryResultReady_t callback will + // be triggered when the asynchronous result becomes ready (or fails). + // + + // Find out the status of an asynchronous inventory result handle. Possible values: + // k_EResultPending - still in progress + // k_EResultOK - done, result ready + // k_EResultExpired - done, result ready, maybe out of date (see DeserializeResult) + // k_EResultInvalidParam - ERROR: invalid API call parameters + // k_EResultServiceUnavailable - ERROR: service temporarily down, you may retry later + // k_EResultLimitExceeded - ERROR: operation would exceed per-user inventory limits + // k_EResultFail - ERROR: unknown / generic error + METHOD_DESC(Find out the status of an asynchronous inventory result handle.) + virtual EResult GetResultStatus( SteamInventoryResult_t resultHandle ) = 0; + + // Copies the contents of a result set into a flat array. The specific + // contents of the result set depend on which query which was used. + METHOD_DESC(Copies the contents of a result set into a flat array. The specific contents of the result set depend on which query which was used.) + virtual bool GetResultItems( SteamInventoryResult_t resultHandle, + OUT_ARRAY_COUNT( punOutItemsArraySize,Output array) SteamItemDetails_t *pOutItemsArray, + uint32 *punOutItemsArraySize ) = 0; + + // Returns the server time at which the result was generated. Compare against + // the value of IClientUtils::GetServerRealTime() to determine age. + METHOD_DESC(Returns the server time at which the result was generated. Compare against the value of IClientUtils::GetServerRealTime() to determine age.) + virtual uint32 GetResultTimestamp( SteamInventoryResult_t resultHandle ) = 0; + + // Returns true if the result belongs to the target steam ID, false if the + // result does not. This is important when using DeserializeResult, to verify + // that a remote player is not pretending to have a different user's inventory. + METHOD_DESC(Returns true if the result belongs to the target steam ID or false if the result does not. This is important when using DeserializeResult to verify that a remote player is not pretending to have a different users inventory.) + virtual bool CheckResultSteamID( SteamInventoryResult_t resultHandle, CSteamID steamIDExpected ) = 0; + + // Destroys a result handle and frees all associated memory. + METHOD_DESC(Destroys a result handle and frees all associated memory.) + virtual void DestroyResult( SteamInventoryResult_t resultHandle ) = 0; + + + // INVENTORY ASYNC QUERY + // + + // Captures the entire state of the current user's Steam inventory. + // You must call DestroyResult on this handle when you are done with it. + // Returns false and sets *pResultHandle to zero if inventory is unavailable. + // Note: calls to this function are subject to rate limits and may return + // cached results if called too frequently. It is suggested that you call + // this function only when you are about to display the user's full inventory, + // or if you expect that the inventory may have changed. + METHOD_DESC(Captures the entire state of the current users Steam inventory.) + virtual bool GetAllItems( SteamInventoryResult_t *pResultHandle ) = 0; + + + // Captures the state of a subset of the current user's Steam inventory, + // identified by an array of item instance IDs. The results from this call + // can be serialized and passed to other players to "prove" that the current + // user owns specific items, without exposing the user's entire inventory. + // For example, you could call GetItemsByID with the IDs of the user's + // currently equipped cosmetic items and serialize this to a buffer, and + // then transmit this buffer to other players upon joining a game. + METHOD_DESC(Captures the state of a subset of the current users Steam inventory identified by an array of item instance IDs.) + virtual bool GetItemsByID( SteamInventoryResult_t *pResultHandle, ARRAY_COUNT( unCountInstanceIDs ) const SteamItemInstanceID_t *pInstanceIDs, uint32 unCountInstanceIDs ) = 0; + + + // RESULT SERIALIZATION AND AUTHENTICATION + // + // Serialized result sets contain a short signature which can't be forged + // or replayed across different game sessions. A result set can be serialized + // on the local client, transmitted to other players via your game networking, + // and deserialized by the remote players. This is a secure way of preventing + // hackers from lying about posessing rare/high-value items. + + // Serializes a result set with signature bytes to an output buffer. Pass + // NULL as an output buffer to get the required size via punOutBufferSize. + // The size of a serialized result depends on the number items which are being + // serialized. When securely transmitting items to other players, it is + // recommended to use "GetItemsByID" first to create a minimal result set. + // Results have a built-in timestamp which will be considered "expired" after + // an hour has elapsed. See DeserializeResult for expiration handling. + virtual bool SerializeResult( SteamInventoryResult_t resultHandle, OUT_BUFFER_COUNT(punOutBufferSize) void *pOutBuffer, uint32 *punOutBufferSize ) = 0; + + // Deserializes a result set and verifies the signature bytes. Returns false + // if bRequireFullOnlineVerify is set but Steam is running in Offline mode. + // Otherwise returns true and then delivers error codes via GetResultStatus. + // + // The bRESERVED_MUST_BE_FALSE flag is reserved for future use and should not + // be set to true by your game at this time. + // + // DeserializeResult has a potential soft-failure mode where the handle status + // is set to k_EResultExpired. GetResultItems() still succeeds in this mode. + // The "expired" result could indicate that the data may be out of date - not + // just due to timed expiration (one hour), but also because one of the items + // in the result set may have been traded or consumed since the result set was + // generated. You could compare the timestamp from GetResultTimestamp() to + // ISteamUtils::GetServerRealTime() to determine how old the data is. You could + // simply ignore the "expired" result code and continue as normal, or you + // could challenge the player with expired data to send an updated result set. + virtual bool DeserializeResult( SteamInventoryResult_t *pOutResultHandle, BUFFER_COUNT(punOutBufferSize) const void *pBuffer, uint32 unBufferSize, bool bRESERVED_MUST_BE_FALSE = false ) = 0; + + + // INVENTORY ASYNC MODIFICATION + // + + // GenerateItems() creates one or more items and then generates a SteamInventoryCallback_t + // notification with a matching nCallbackContext parameter. This API is insecure, and could + // be abused by hacked clients. It is, however, very useful as a development cheat or as + // a means of prototyping item-related features for your game. The use of GenerateItems can + // be restricted to certain item definitions or fully blocked via the Steamworks website. + // If punArrayQuantity is not NULL, it should be the same length as pArrayItems and should + // describe the quantity of each item to generate. + virtual bool GenerateItems( SteamInventoryResult_t *pResultHandle, ARRAY_COUNT(unArrayLength) const SteamItemDef_t *pArrayItemDefs, ARRAY_COUNT(unArrayLength) const uint32 *punArrayQuantity, uint32 unArrayLength ) = 0; + + // GrantPromoItems() checks the list of promotional items for which the user may be eligible + // and grants the items (one time only). On success, the result set will include items which + // were granted, if any. If no items were granted because the user isn't eligible for any + // promotions, this is still considered a success. + METHOD_DESC(GrantPromoItems() checks the list of promotional items for which the user may be eligible and grants the items (one time only).) + virtual bool GrantPromoItems( SteamInventoryResult_t *pResultHandle ) = 0; + + // AddPromoItem() / AddPromoItems() are restricted versions of GrantPromoItems(). Instead of + // scanning for all eligible promotional items, the check is restricted to a single item + // definition or set of item definitions. This can be useful if your game has custom UI for + // showing a specific promo item to the user. + virtual bool AddPromoItem( SteamInventoryResult_t *pResultHandle, SteamItemDef_t itemDef ) = 0; + virtual bool AddPromoItems( SteamInventoryResult_t *pResultHandle, ARRAY_COUNT(unArrayLength) const SteamItemDef_t *pArrayItemDefs, uint32 unArrayLength ) = 0; + + // ConsumeItem() removes items from the inventory, permanently. They cannot be recovered. + // Not for the faint of heart - if your game implements item removal at all, a high-friction + // UI confirmation process is highly recommended. Similar to GenerateItems, punArrayQuantity + // can be NULL or else an array of the same length as pArrayItems which describe the quantity + // of each item to destroy. ConsumeItem can be restricted to certain item definitions or + // fully blocked via the Steamworks website to minimize support/abuse issues such as the + // clasic "my brother borrowed my laptop and deleted all of my rare items". + METHOD_DESC(ConsumeItem() removes items from the inventory permanently.) + virtual bool ConsumeItem( SteamInventoryResult_t *pResultHandle, SteamItemInstanceID_t itemConsume, uint32 unQuantity ) = 0; + + // ExchangeItems() is an atomic combination of GenerateItems and DestroyItems. It can be + // used to implement crafting recipes or transmutations, or items which unpack themselves + // into other items. Like GenerateItems, this is a flexible and dangerous API which is + // meant for rapid prototyping. You can configure restrictions on ExchangeItems via the + // Steamworks website, such as limiting it to a whitelist of input/output combinations + // corresponding to recipes. + // (Note: although GenerateItems may be hard or impossible to use securely in your game, + // ExchangeItems is perfectly reasonable to use once the whitelists are set accordingly.) + virtual bool ExchangeItems( SteamInventoryResult_t *pResultHandle, + ARRAY_COUNT(unArrayGenerateLength) const SteamItemDef_t *pArrayGenerate, ARRAY_COUNT(unArrayGenerateLength) const uint32 *punArrayGenerateQuantity, uint32 unArrayGenerateLength, + ARRAY_COUNT(unArrayDestroyLength) const SteamItemInstanceID_t *pArrayDestroy, ARRAY_COUNT(unArrayDestroyLength) const uint32 *punArrayDestroyQuantity, uint32 unArrayDestroyLength ) = 0; + + + // TransferItemQuantity() is intended for use with items which are "stackable" (can have + // quantity greater than one). It can be used to split a stack into two, or to transfer + // quantity from one stack into another stack of identical items. To split one stack into + // two, pass k_SteamItemInstanceIDInvalid for itemIdDest and a new item will be generated. + virtual bool TransferItemQuantity( SteamInventoryResult_t *pResultHandle, SteamItemInstanceID_t itemIdSource, uint32 unQuantity, SteamItemInstanceID_t itemIdDest ) = 0; + + + // TIMED DROPS AND PLAYTIME CREDIT + // + + // Applications which use timed-drop mechanics should call SendItemDropHeartbeat() when + // active gameplay begins, and at least once every two minutes afterwards. The backend + // performs its own time calculations, so the precise timing of the heartbeat is not + // critical as long as you send at least one heartbeat every two minutes. Calling the + // function more often than that is not harmful, it will simply have no effect. Note: + // players may be able to spoof this message by hacking their client, so you should not + // attempt to use this as a mechanism to restrict playtime credits. It is simply meant + // to distinguish between being in any kind of gameplay situation vs the main menu or + // a pre-game launcher window. (If you are stingy with handing out playtime credit, it + // will only encourage players to run bots or use mouse/kb event simulators.) + // + // Playtime credit accumulation can be capped on a daily or weekly basis through your + // Steamworks configuration. + // + METHOD_DESC(Applications which use timed-drop mechanics should call SendItemDropHeartbeat() when active gameplay begins and at least once every two minutes afterwards.) + virtual void SendItemDropHeartbeat() = 0; + + // Playtime credit must be consumed and turned into item drops by your game. Only item + // definitions which are marked as "playtime item generators" can be spawned. The call + // will return an empty result set if there is not enough playtime credit for a drop. + // Your game should call TriggerItemDrop at an appropriate time for the user to receive + // new items, such as between rounds or while the player is dead. Note that players who + // hack their clients could modify the value of "dropListDefinition", so do not use it + // to directly control rarity. It is primarily useful during testing and development, + // where you may wish to perform experiments with different types of drops. + METHOD_DESC(Playtime credit must be consumed and turned into item drops by your game.) + virtual bool TriggerItemDrop( SteamInventoryResult_t *pResultHandle, SteamItemDef_t dropListDefinition ) = 0; + + + // IN-GAME TRADING + // + // TradeItems() implements limited in-game trading of items, if you prefer not to use + // the overlay or an in-game web browser to perform Steam Trading through the website. + // You should implement a UI where both players can see and agree to a trade, and then + // each client should call TradeItems simultaneously (+/- 5 seconds) with matching + // (but reversed) parameters. The result is the same as if both players performed a + // Steam Trading transaction through the web. Each player will get an inventory result + // confirming the removal or quantity changes of the items given away, and the new + // item instance id numbers and quantities of the received items. + // (Note: new item instance IDs are generated whenever an item changes ownership.) + virtual bool TradeItems( SteamInventoryResult_t *pResultHandle, CSteamID steamIDTradePartner, + ARRAY_COUNT(nArrayGiveLength) const SteamItemInstanceID_t *pArrayGive, ARRAY_COUNT(nArrayGiveLength) const uint32 *pArrayGiveQuantity, uint32 nArrayGiveLength, + ARRAY_COUNT(nArrayGetLength) const SteamItemInstanceID_t *pArrayGet, ARRAY_COUNT(nArrayGetLength) const uint32 *pArrayGetQuantity, uint32 nArrayGetLength ) = 0; + + + // ITEM DEFINITIONS + // + // Item definitions are a mapping of "definition IDs" (integers between 1 and 1000000) + // to a set of string properties. Some of these properties are required to display items + // on the Steam community web site. Other properties can be defined by applications. + // Use of these functions is optional; there is no reason to call LoadItemDefinitions + // if your game hardcodes the numeric definition IDs (eg, purple face mask = 20, blue + // weapon mod = 55) and does not allow for adding new item types without a client patch. + // + + // LoadItemDefinitions triggers the automatic load and refresh of item definitions. + // Every time new item definitions are available (eg, from the dynamic addition of new + // item types while players are still in-game), a SteamInventoryDefinitionUpdate_t + // callback will be fired. + METHOD_DESC(LoadItemDefinitions triggers the automatic load and refresh of item definitions.) + virtual bool LoadItemDefinitions() = 0; + + // GetItemDefinitionIDs returns the set of all defined item definition IDs (which are + // defined via Steamworks configuration, and not necessarily contiguous integers). + // If pItemDefIDs is null, the call will return true and *punItemDefIDsArraySize will + // contain the total size necessary for a subsequent call. Otherwise, the call will + // return false if and only if there is not enough space in the output array. + virtual bool GetItemDefinitionIDs( + OUT_ARRAY_COUNT(punItemDefIDsArraySize,List of item definition IDs) SteamItemDef_t *pItemDefIDs, + DESC(Size of array is passed in and actual size used is returned in this param) uint32 *punItemDefIDsArraySize ) = 0; + + // GetItemDefinitionProperty returns a string property from a given item definition. + // Note that some properties (for example, "name") may be localized and will depend + // on the current Steam language settings (see ISteamApps::GetCurrentGameLanguage). + // Property names are always composed of ASCII letters, numbers, and/or underscores. + // Pass a NULL pointer for pchPropertyName to get a comma - separated list of available + // property names. + virtual bool GetItemDefinitionProperty( SteamItemDef_t iDefinition, const char *pchPropertyName, + OUT_STRING_COUNT(punValueBufferSize) char *pchValueBuffer, uint32 *punValueBufferSize ) = 0; +}; + +#define STEAMINVENTORY_INTERFACE_VERSION "STEAMINVENTORY_INTERFACE_V001" + + +// SteamInventoryResultReady_t callbacks are fired whenever asynchronous +// results transition from "Pending" to "OK" or an error state. There will +// always be exactly one callback per handle. +struct SteamInventoryResultReady_t +{ + enum { k_iCallback = k_iClientInventoryCallbacks + 0 }; + SteamInventoryResult_t m_handle; + EResult m_result; +}; + + +// SteamInventoryFullUpdate_t callbacks are triggered when GetAllItems +// successfully returns a result which is newer / fresher than the last +// known result. (It will not trigger if the inventory hasn't changed, +// or if results from two overlapping calls are reversed in flight and +// the earlier result is already known to be stale/out-of-date.) +// The normal ResultReady callback will still be triggered immediately +// afterwards; this is an additional notification for your convenience. +struct SteamInventoryFullUpdate_t +{ + enum { k_iCallback = k_iClientInventoryCallbacks + 1 }; + SteamInventoryResult_t m_handle; +}; + + +// A SteamInventoryDefinitionUpdate_t callback is triggered whenever +// item definitions have been updated, which could be in response to +// LoadItemDefinitions() or any other async request which required +// a definition update in order to process results from the server. +struct SteamInventoryDefinitionUpdate_t +{ + enum { k_iCallback = k_iClientInventoryCallbacks + 2 }; +}; + +#pragma pack( pop ) + + +#endif // ISTEAMCONTROLLER_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammasterserverupdater.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammasterserverupdater.h new file mode 100644 index 0000000..4be0ca5 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammasterserverupdater.h @@ -0,0 +1 @@ +#error "This file isn't used any more" diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammatchmaking.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammatchmaking.h new file mode 100644 index 0000000..e3be340 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammatchmaking.h @@ -0,0 +1,747 @@ +//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to steam managing game server/client match making +// +//============================================================================= + +#ifndef ISTEAMMATCHMAKING +#define ISTEAMMATCHMAKING +#ifdef _WIN32 +#pragma once +#endif + +#include "steamtypes.h" +#include "steamclientpublic.h" +#include "matchmakingtypes.h" +#include "isteamclient.h" +#include "isteamfriends.h" + +// lobby type description +enum ELobbyType +{ + k_ELobbyTypePrivate = 0, // only way to join the lobby is to invite to someone else + k_ELobbyTypeFriendsOnly = 1, // shows for friends or invitees, but not in lobby list + k_ELobbyTypePublic = 2, // visible for friends and in lobby list + k_ELobbyTypeInvisible = 3, // returned by search, but not visible to other friends + // useful if you want a user in two lobbies, for example matching groups together + // a user can be in only one regular lobby, and up to two invisible lobbies +}; + +// lobby search filter tools +enum ELobbyComparison +{ + k_ELobbyComparisonEqualToOrLessThan = -2, + k_ELobbyComparisonLessThan = -1, + k_ELobbyComparisonEqual = 0, + k_ELobbyComparisonGreaterThan = 1, + k_ELobbyComparisonEqualToOrGreaterThan = 2, + k_ELobbyComparisonNotEqual = 3, +}; + +// lobby search distance. Lobby results are sorted from closest to farthest. +enum ELobbyDistanceFilter +{ + k_ELobbyDistanceFilterClose, // only lobbies in the same immediate region will be returned + k_ELobbyDistanceFilterDefault, // only lobbies in the same region or near by regions + k_ELobbyDistanceFilterFar, // for games that don't have many latency requirements, will return lobbies about half-way around the globe + k_ELobbyDistanceFilterWorldwide, // no filtering, will match lobbies as far as India to NY (not recommended, expect multiple seconds of latency between the clients) +}; + +// maximum number of characters a lobby metadata key can be +#define k_nMaxLobbyKeyLength 255 + +//----------------------------------------------------------------------------- +// Purpose: Functions for match making services for clients to get to favorites +// and to operate on game lobbies. +//----------------------------------------------------------------------------- +class ISteamMatchmaking +{ +public: + // game server favorites storage + // saves basic details about a multiplayer game server locally + + // returns the number of favorites servers the user has stored + virtual int GetFavoriteGameCount() = 0; + + // returns the details of the game server + // iGame is of range [0,GetFavoriteGameCount()) + // *pnIP, *pnConnPort are filled in the with IP:port of the game server + // *punFlags specify whether the game server was stored as an explicit favorite or in the history of connections + // *pRTime32LastPlayedOnServer is filled in the with the Unix time the favorite was added + virtual bool GetFavoriteGame( int iGame, AppId_t *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) = 0; + + // adds the game server to the local list; updates the time played of the server if it already exists in the list + virtual int AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) = 0; + + // removes the game server from the local storage; returns true if one was removed + virtual bool RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ) = 0; + + /////// + // Game lobby functions + + // Get a list of relevant lobbies + // this is an asynchronous request + // results will be returned by LobbyMatchList_t callback & call result, with the number of lobbies found + // this will never return lobbies that are full + // to add more filter, the filter calls below need to be call before each and every RequestLobbyList() call + // use the CCallResult<> object in steam_api.h to match the SteamAPICall_t call result to a function in an object, e.g. + /* + class CMyLobbyListManager + { + CCallResult m_CallResultLobbyMatchList; + void FindLobbies() + { + // SteamMatchmaking()->AddRequestLobbyListFilter*() functions would be called here, before RequestLobbyList() + SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList(); + m_CallResultLobbyMatchList.Set( hSteamAPICall, this, &CMyLobbyListManager::OnLobbyMatchList ); + } + + void OnLobbyMatchList( LobbyMatchList_t *pLobbyMatchList, bool bIOFailure ) + { + // lobby list has be retrieved from Steam back-end, use results + } + } + */ + // + virtual SteamAPICall_t RequestLobbyList() = 0; + // filters for lobbies + // this needs to be called before RequestLobbyList() to take effect + // these are cleared on each call to RequestLobbyList() + virtual void AddRequestLobbyListStringFilter( const char *pchKeyToMatch, const char *pchValueToMatch, ELobbyComparison eComparisonType ) = 0; + // numerical comparison + virtual void AddRequestLobbyListNumericalFilter( const char *pchKeyToMatch, int nValueToMatch, ELobbyComparison eComparisonType ) = 0; + // returns results closest to the specified value. Multiple near filters can be added, with early filters taking precedence + virtual void AddRequestLobbyListNearValueFilter( const char *pchKeyToMatch, int nValueToBeCloseTo ) = 0; + // returns only lobbies with the specified number of slots available + virtual void AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable ) = 0; + // sets the distance for which we should search for lobbies (based on users IP address to location map on the Steam backed) + virtual void AddRequestLobbyListDistanceFilter( ELobbyDistanceFilter eLobbyDistanceFilter ) = 0; + // sets how many results to return, the lower the count the faster it is to download the lobby results & details to the client + virtual void AddRequestLobbyListResultCountFilter( int cMaxResults ) = 0; + + virtual void AddRequestLobbyListCompatibleMembersFilter( CSteamID steamIDLobby ) = 0; + + // returns the CSteamID of a lobby, as retrieved by a RequestLobbyList call + // should only be called after a LobbyMatchList_t callback is received + // iLobby is of the range [0, LobbyMatchList_t::m_nLobbiesMatching) + // the returned CSteamID::IsValid() will be false if iLobby is out of range + virtual CSteamID GetLobbyByIndex( int iLobby ) = 0; + + // Create a lobby on the Steam servers. + // If private, then the lobby will not be returned by any RequestLobbyList() call; the CSteamID + // of the lobby will need to be communicated via game channels or via InviteUserToLobby() + // this is an asynchronous request + // results will be returned by LobbyCreated_t callback and call result; lobby is joined & ready to use at this point + // a LobbyEnter_t callback will also be received (since the local user is joining their own lobby) + virtual SteamAPICall_t CreateLobby( ELobbyType eLobbyType, int cMaxMembers ) = 0; + + // Joins an existing lobby + // this is an asynchronous request + // results will be returned by LobbyEnter_t callback & call result, check m_EChatRoomEnterResponse to see if was successful + // lobby metadata is available to use immediately on this call completing + virtual SteamAPICall_t JoinLobby( CSteamID steamIDLobby ) = 0; + + // Leave a lobby; this will take effect immediately on the client side + // other users in the lobby will be notified by a LobbyChatUpdate_t callback + virtual void LeaveLobby( CSteamID steamIDLobby ) = 0; + + // Invite another user to the lobby + // the target user will receive a LobbyInvite_t callback + // will return true if the invite is successfully sent, whether or not the target responds + // returns false if the local user is not connected to the Steam servers + // if the other user clicks the join link, a GameLobbyJoinRequested_t will be posted if the user is in-game, + // or if the game isn't running yet the game will be launched with the parameter +connect_lobby <64-bit lobby id> + virtual bool InviteUserToLobby( CSteamID steamIDLobby, CSteamID steamIDInvitee ) = 0; + + // Lobby iteration, for viewing details of users in a lobby + // only accessible if the lobby user is a member of the specified lobby + // persona information for other lobby members (name, avatar, etc.) will be asynchronously received + // and accessible via ISteamFriends interface + + // returns the number of users in the specified lobby + virtual int GetNumLobbyMembers( CSteamID steamIDLobby ) = 0; + // returns the CSteamID of a user in the lobby + // iMember is of range [0,GetNumLobbyMembers()) + // note that the current user must be in a lobby to retrieve CSteamIDs of other users in that lobby + virtual CSteamID GetLobbyMemberByIndex( CSteamID steamIDLobby, int iMember ) = 0; + + // Get data associated with this lobby + // takes a simple key, and returns the string associated with it + // "" will be returned if no value is set, or if steamIDLobby is invalid + virtual const char *GetLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0; + // Sets a key/value pair in the lobby metadata + // each user in the lobby will be broadcast this new value, and any new users joining will receive any existing data + // this can be used to set lobby names, map, etc. + // to reset a key, just set it to "" + // other users in the lobby will receive notification of the lobby data change via a LobbyDataUpdate_t callback + virtual bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0; + + // returns the number of metadata keys set on the specified lobby + virtual int GetLobbyDataCount( CSteamID steamIDLobby ) = 0; + + // returns a lobby metadata key/values pair by index, of range [0, GetLobbyDataCount()) + virtual bool GetLobbyDataByIndex( CSteamID steamIDLobby, int iLobbyData, char *pchKey, int cchKeyBufferSize, char *pchValue, int cchValueBufferSize ) = 0; + + // removes a metadata key from the lobby + virtual bool DeleteLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0; + + // Gets per-user metadata for someone in this lobby + virtual const char *GetLobbyMemberData( CSteamID steamIDLobby, CSteamID steamIDUser, const char *pchKey ) = 0; + // Sets per-user metadata (for the local user implicitly) + virtual void SetLobbyMemberData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0; + + // Broadcasts a chat message to the all the users in the lobby + // users in the lobby (including the local user) will receive a LobbyChatMsg_t callback + // returns true if the message is successfully sent + // pvMsgBody can be binary or text data, up to 4k + // if pvMsgBody is text, cubMsgBody should be strlen( text ) + 1, to include the null terminator + virtual bool SendLobbyChatMsg( CSteamID steamIDLobby, const void *pvMsgBody, int cubMsgBody ) = 0; + // Get a chat message as specified in a LobbyChatMsg_t callback + // iChatID is the LobbyChatMsg_t::m_iChatID value in the callback + // *pSteamIDUser is filled in with the CSteamID of the member + // *pvData is filled in with the message itself + // return value is the number of bytes written into the buffer + virtual int GetLobbyChatEntry( CSteamID steamIDLobby, int iChatID, OUT_STRUCT() CSteamID *pSteamIDUser, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0; + + // Refreshes metadata for a lobby you're not necessarily in right now + // you never do this for lobbies you're a member of, only if your + // this will send down all the metadata associated with a lobby + // this is an asynchronous call + // returns false if the local user is not connected to the Steam servers + // results will be returned by a LobbyDataUpdate_t callback + // if the specified lobby doesn't exist, LobbyDataUpdate_t::m_bSuccess will be set to false + virtual bool RequestLobbyData( CSteamID steamIDLobby ) = 0; + + // sets the game server associated with the lobby + // usually at this point, the users will join the specified game server + // either the IP/Port or the steamID of the game server has to be valid, depending on how you want the clients to be able to connect + virtual void SetLobbyGameServer( CSteamID steamIDLobby, uint32 unGameServerIP, uint16 unGameServerPort, CSteamID steamIDGameServer ) = 0; + // returns the details of a game server set in a lobby - returns false if there is no game server set, or that lobby doesn't exist + virtual bool GetLobbyGameServer( CSteamID steamIDLobby, uint32 *punGameServerIP, uint16 *punGameServerPort, OUT_STRUCT() CSteamID *psteamIDGameServer ) = 0; + + // set the limit on the # of users who can join the lobby + virtual bool SetLobbyMemberLimit( CSteamID steamIDLobby, int cMaxMembers ) = 0; + // returns the current limit on the # of users who can join the lobby; returns 0 if no limit is defined + virtual int GetLobbyMemberLimit( CSteamID steamIDLobby ) = 0; + + // updates which type of lobby it is + // only lobbies that are k_ELobbyTypePublic or k_ELobbyTypeInvisible, and are set to joinable, will be returned by RequestLobbyList() calls + virtual bool SetLobbyType( CSteamID steamIDLobby, ELobbyType eLobbyType ) = 0; + + // sets whether or not a lobby is joinable - defaults to true for a new lobby + // if set to false, no user can join, even if they are a friend or have been invited + virtual bool SetLobbyJoinable( CSteamID steamIDLobby, bool bLobbyJoinable ) = 0; + + // returns the current lobby owner + // you must be a member of the lobby to access this + // there always one lobby owner - if the current owner leaves, another user will become the owner + // it is possible (bur rare) to join a lobby just as the owner is leaving, thus entering a lobby with self as the owner + virtual CSteamID GetLobbyOwner( CSteamID steamIDLobby ) = 0; + + // changes who the lobby owner is + // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby + // after completion, the local user will no longer be the owner + virtual bool SetLobbyOwner( CSteamID steamIDLobby, CSteamID steamIDNewOwner ) = 0; + + // link two lobbies for the purposes of checking player compatibility + // you must be the lobby owner of both lobbies + virtual bool SetLinkedLobby( CSteamID steamIDLobby, CSteamID steamIDLobbyDependent ) = 0; + +#ifdef _PS3 + // changes who the lobby owner is + // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby + // after completion, the local user will no longer be the owner + virtual void CheckForPSNGameBootInvite( unsigned int iGameBootAttributes ) = 0; +#endif +}; +#define STEAMMATCHMAKING_INTERFACE_VERSION "SteamMatchMaking009" + + +//----------------------------------------------------------------------------- +// Callback interfaces for server list functions (see ISteamMatchmakingServers below) +// +// The idea here is that your game code implements objects that implement these +// interfaces to receive callback notifications after calling asynchronous functions +// inside the ISteamMatchmakingServers() interface below. +// +// This is different than normal Steam callback handling due to the potentially +// large size of server lists. +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// Typedef for handle type you will receive when requesting server list. +//----------------------------------------------------------------------------- +typedef void* HServerListRequest; + +//----------------------------------------------------------------------------- +// Purpose: Callback interface for receiving responses after a server list refresh +// or an individual server update. +// +// Since you get these callbacks after requesting full list refreshes you will +// usually implement this interface inside an object like CServerBrowser. If that +// object is getting destructed you should use ISteamMatchMakingServers()->CancelQuery() +// to cancel any in-progress queries so you don't get a callback into the destructed +// object and crash. +//----------------------------------------------------------------------------- +class ISteamMatchmakingServerListResponse +{ +public: + // Server has responded ok with updated data + virtual void ServerResponded( HServerListRequest hRequest, int iServer ) = 0; + + // Server has failed to respond + virtual void ServerFailedToRespond( HServerListRequest hRequest, int iServer ) = 0; + + // A list refresh you had initiated is now 100% completed + virtual void RefreshComplete( HServerListRequest hRequest, EMatchMakingServerResponse response ) = 0; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Callback interface for receiving responses after pinging an individual server +// +// These callbacks all occur in response to querying an individual server +// via the ISteamMatchmakingServers()->PingServer() call below. If you are +// destructing an object that implements this interface then you should call +// ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query +// which is in progress. Failure to cancel in progress queries when destructing +// a callback handler may result in a crash when a callback later occurs. +//----------------------------------------------------------------------------- +class ISteamMatchmakingPingResponse +{ +public: + // Server has responded successfully and has updated data + virtual void ServerResponded( gameserveritem_t &server ) = 0; + + // Server failed to respond to the ping request + virtual void ServerFailedToRespond() = 0; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Callback interface for receiving responses after requesting details on +// who is playing on a particular server. +// +// These callbacks all occur in response to querying an individual server +// via the ISteamMatchmakingServers()->PlayerDetails() call below. If you are +// destructing an object that implements this interface then you should call +// ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query +// which is in progress. Failure to cancel in progress queries when destructing +// a callback handler may result in a crash when a callback later occurs. +//----------------------------------------------------------------------------- +class ISteamMatchmakingPlayersResponse +{ +public: + // Got data on a new player on the server -- you'll get this callback once per player + // on the server which you have requested player data on. + virtual void AddPlayerToList( const char *pchName, int nScore, float flTimePlayed ) = 0; + + // The server failed to respond to the request for player details + virtual void PlayersFailedToRespond() = 0; + + // The server has finished responding to the player details request + // (ie, you won't get anymore AddPlayerToList callbacks) + virtual void PlayersRefreshComplete() = 0; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Callback interface for receiving responses after requesting rules +// details on a particular server. +// +// These callbacks all occur in response to querying an individual server +// via the ISteamMatchmakingServers()->ServerRules() call below. If you are +// destructing an object that implements this interface then you should call +// ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query +// which is in progress. Failure to cancel in progress queries when destructing +// a callback handler may result in a crash when a callback later occurs. +//----------------------------------------------------------------------------- +class ISteamMatchmakingRulesResponse +{ +public: + // Got data on a rule on the server -- you'll get one of these per rule defined on + // the server you are querying + virtual void RulesResponded( const char *pchRule, const char *pchValue ) = 0; + + // The server failed to respond to the request for rule details + virtual void RulesFailedToRespond() = 0; + + // The server has finished responding to the rule details request + // (ie, you won't get anymore RulesResponded callbacks) + virtual void RulesRefreshComplete() = 0; +}; + + +//----------------------------------------------------------------------------- +// Typedef for handle type you will receive when querying details on an individual server. +//----------------------------------------------------------------------------- +typedef int HServerQuery; +const int HSERVERQUERY_INVALID = 0xffffffff; + +//----------------------------------------------------------------------------- +// Purpose: Functions for match making services for clients to get to game lists and details +//----------------------------------------------------------------------------- +class ISteamMatchmakingServers +{ +public: + // Request a new list of servers of a particular type. These calls each correspond to one of the EMatchMakingType values. + // Each call allocates a new asynchronous request object. + // Request object must be released by calling ReleaseRequest( hServerListRequest ) + virtual HServerListRequest RequestInternetServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0; + virtual HServerListRequest RequestLANServerList( AppId_t iApp, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0; + virtual HServerListRequest RequestFriendsServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0; + virtual HServerListRequest RequestFavoritesServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0; + virtual HServerListRequest RequestHistoryServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0; + virtual HServerListRequest RequestSpectatorServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0; + + // Releases the asynchronous request object and cancels any pending query on it if there's a pending query in progress. + // RefreshComplete callback is not posted when request is released. + virtual void ReleaseRequest( HServerListRequest hServerListRequest ) = 0; + + /* the filter operation codes that go in the key part of MatchMakingKeyValuePair_t should be one of these: + + "map" + - Server passes the filter if the server is playing the specified map. + "gamedataand" + - Server passes the filter if the server's game data (ISteamGameServer::SetGameData) contains all of the + specified strings. The value field is a comma-delimited list of strings to match. + "gamedataor" + - Server passes the filter if the server's game data (ISteamGameServer::SetGameData) contains at least one of the + specified strings. The value field is a comma-delimited list of strings to match. + "gamedatanor" + - Server passes the filter if the server's game data (ISteamGameServer::SetGameData) does not contain any + of the specified strings. The value field is a comma-delimited list of strings to check. + "gametagsand" + - Server passes the filter if the server's game tags (ISteamGameServer::SetGameTags) contains all + of the specified strings. The value field is a comma-delimited list of strings to check. + "gametagsnor" + - Server passes the filter if the server's game tags (ISteamGameServer::SetGameTags) does not contain any + of the specified strings. The value field is a comma-delimited list of strings to check. + "and" (x1 && x2 && ... && xn) + "or" (x1 || x2 || ... || xn) + "nand" !(x1 && x2 && ... && xn) + "nor" !(x1 || x2 || ... || xn) + - Performs Boolean operation on the following filters. The operand to this filter specifies + the "size" of the Boolean inputs to the operation, in Key/value pairs. (The keyvalue + pairs must immediately follow, i.e. this is a prefix logical operator notation.) + In the simplest case where Boolean expressions are not nested, this is simply + the number of operands. + + For example, to match servers on a particular map or with a particular tag, would would + use these filters. + + ( server.map == "cp_dustbowl" || server.gametags.contains("payload") ) + "or", "2" + "map", "cp_dustbowl" + "gametagsand", "payload" + + If logical inputs are nested, then the operand specifies the size of the entire + "length" of its operands, not the number of immediate children. + + ( server.map == "cp_dustbowl" || ( server.gametags.contains("payload") && !server.gametags.contains("payloadrace") ) ) + "or", "4" + "map", "cp_dustbowl" + "and", "2" + "gametagsand", "payload" + "gametagsnor", "payloadrace" + + Unary NOT can be achieved using either "nand" or "nor" with a single operand. + + "addr" + - Server passes the filter if the server's query address matches the specified IP or IP:port. + "gameaddr" + - Server passes the filter if the server's game address matches the specified IP or IP:port. + + The following filter operations ignore the "value" part of MatchMakingKeyValuePair_t + + "dedicated" + - Server passes the filter if it passed true to SetDedicatedServer. + "secure" + - Server passes the filter if the server is VAC-enabled. + "notfull" + - Server passes the filter if the player count is less than the reported max player count. + "hasplayers" + - Server passes the filter if the player count is greater than zero. + "noplayers" + - Server passes the filter if it doesn't have any players. + "linux" + - Server passes the filter if it's a linux server + */ + + // Get details on a given server in the list, you can get the valid range of index + // values by calling GetServerCount(). You will also receive index values in + // ISteamMatchmakingServerListResponse::ServerResponded() callbacks + virtual gameserveritem_t *GetServerDetails( HServerListRequest hRequest, int iServer ) = 0; + + // Cancel an request which is operation on the given list type. You should call this to cancel + // any in-progress requests before destructing a callback object that may have been passed + // to one of the above list request calls. Not doing so may result in a crash when a callback + // occurs on the destructed object. + // Canceling a query does not release the allocated request handle. + // The request handle must be released using ReleaseRequest( hRequest ) + virtual void CancelQuery( HServerListRequest hRequest ) = 0; + + // Ping every server in your list again but don't update the list of servers + // Query callback installed when the server list was requested will be used + // again to post notifications and RefreshComplete, so the callback must remain + // valid until another RefreshComplete is called on it or the request + // is released with ReleaseRequest( hRequest ) + virtual void RefreshQuery( HServerListRequest hRequest ) = 0; + + // Returns true if the list is currently refreshing its server list + virtual bool IsRefreshing( HServerListRequest hRequest ) = 0; + + // How many servers in the given list, GetServerDetails above takes 0... GetServerCount() - 1 + virtual int GetServerCount( HServerListRequest hRequest ) = 0; + + // Refresh a single server inside of a query (rather than all the servers ) + virtual void RefreshServer( HServerListRequest hRequest, int iServer ) = 0; + + + //----------------------------------------------------------------------------- + // Queries to individual servers directly via IP/Port + //----------------------------------------------------------------------------- + + // Request updated ping time and other details from a single server + virtual HServerQuery PingServer( uint32 unIP, uint16 usPort, ISteamMatchmakingPingResponse *pRequestServersResponse ) = 0; + + // Request the list of players currently playing on a server + virtual HServerQuery PlayerDetails( uint32 unIP, uint16 usPort, ISteamMatchmakingPlayersResponse *pRequestServersResponse ) = 0; + + // Request the list of rules that the server is running (See ISteamGameServer::SetKeyValue() to set the rules server side) + virtual HServerQuery ServerRules( uint32 unIP, uint16 usPort, ISteamMatchmakingRulesResponse *pRequestServersResponse ) = 0; + + // Cancel an outstanding Ping/Players/Rules query from above. You should call this to cancel + // any in-progress requests before destructing a callback object that may have been passed + // to one of the above calls to avoid crashing when callbacks occur. + virtual void CancelServerQuery( HServerQuery hServerQuery ) = 0; +}; +#define STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION "SteamMatchMakingServers002" + +// game server flags +const uint32 k_unFavoriteFlagNone = 0x00; +const uint32 k_unFavoriteFlagFavorite = 0x01; // this game favorite entry is for the favorites list +const uint32 k_unFavoriteFlagHistory = 0x02; // this game favorite entry is for the history list + + +//----------------------------------------------------------------------------- +// Purpose: Used in ChatInfo messages - fields specific to a chat member - must fit in a uint32 +//----------------------------------------------------------------------------- +enum EChatMemberStateChange +{ + // Specific to joining / leaving the chatroom + k_EChatMemberStateChangeEntered = 0x0001, // This user has joined or is joining the chat room + k_EChatMemberStateChangeLeft = 0x0002, // This user has left or is leaving the chat room + k_EChatMemberStateChangeDisconnected = 0x0004, // User disconnected without leaving the chat first + k_EChatMemberStateChangeKicked = 0x0008, // User kicked + k_EChatMemberStateChangeBanned = 0x0010, // User kicked and banned +}; + +// returns true of the flags indicate that a user has been removed from the chat +#define BChatMemberStateChangeRemoved( rgfChatMemberStateChangeFlags ) ( rgfChatMemberStateChangeFlags & ( k_EChatMemberStateChangeDisconnected | k_EChatMemberStateChangeLeft | k_EChatMemberStateChangeKicked | k_EChatMemberStateChangeBanned ) ) + + +//----------------------------------------------------------------------------- +// Callbacks for ISteamMatchmaking (which go through the regular Steam callback registration system) +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +//----------------------------------------------------------------------------- +// Purpose: a server was added/removed from the favorites list, you should refresh now +//----------------------------------------------------------------------------- +struct FavoritesListChanged_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 2 }; + uint32 m_nIP; // an IP of 0 means reload the whole list, any other value means just one server + uint32 m_nQueryPort; + uint32 m_nConnPort; + uint32 m_nAppID; + uint32 m_nFlags; + bool m_bAdd; // true if this is adding the entry, otherwise it is a remove + AccountID_t m_unAccountId; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Someone has invited you to join a Lobby +// normally you don't need to do anything with this, since +// the Steam UI will also display a ' has invited you to the lobby, join?' dialog +// +// if the user outside a game chooses to join, your game will be launched with the parameter "+connect_lobby <64-bit lobby id>", +// or with the callback GameLobbyJoinRequested_t if they're already in-game +//----------------------------------------------------------------------------- +struct LobbyInvite_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 3 }; + + uint64 m_ulSteamIDUser; // Steam ID of the person making the invite + uint64 m_ulSteamIDLobby; // Steam ID of the Lobby + uint64 m_ulGameID; // GameID of the Lobby +}; + + +//----------------------------------------------------------------------------- +// Purpose: Sent on entering a lobby, or on failing to enter +// m_EChatRoomEnterResponse will be set to k_EChatRoomEnterResponseSuccess on success, +// or a higher value on failure (see enum EChatRoomEnterResponse) +//----------------------------------------------------------------------------- +struct LobbyEnter_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 4 }; + + uint64 m_ulSteamIDLobby; // SteamID of the Lobby you have entered + uint32 m_rgfChatPermissions; // Permissions of the current user + bool m_bLocked; // If true, then only invited users may join + uint32 m_EChatRoomEnterResponse; // EChatRoomEnterResponse +}; + + +//----------------------------------------------------------------------------- +// Purpose: The lobby metadata has changed +// if m_ulSteamIDMember is the steamID of a lobby member, use GetLobbyMemberData() to access per-user details +// if m_ulSteamIDMember == m_ulSteamIDLobby, use GetLobbyData() to access lobby metadata +//----------------------------------------------------------------------------- +struct LobbyDataUpdate_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 5 }; + + uint64 m_ulSteamIDLobby; // steamID of the Lobby + uint64 m_ulSteamIDMember; // steamID of the member whose data changed, or the room itself + uint8 m_bSuccess; // true if we lobby data was successfully changed; + // will only be false if RequestLobbyData() was called on a lobby that no longer exists +}; + + +//----------------------------------------------------------------------------- +// Purpose: The lobby chat room state has changed +// this is usually sent when a user has joined or left the lobby +//----------------------------------------------------------------------------- +struct LobbyChatUpdate_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 6 }; + + uint64 m_ulSteamIDLobby; // Lobby ID + uint64 m_ulSteamIDUserChanged; // user who's status in the lobby just changed - can be recipient + uint64 m_ulSteamIDMakingChange; // Chat member who made the change (different from SteamIDUserChange if kicking, muting, etc.) + // for example, if one user kicks another from the lobby, this will be set to the id of the user who initiated the kick + uint32 m_rgfChatMemberStateChange; // bitfield of EChatMemberStateChange values +}; + + +//----------------------------------------------------------------------------- +// Purpose: A chat message for this lobby has been sent +// use GetLobbyChatEntry( m_iChatID ) to retrieve the contents of this message +//----------------------------------------------------------------------------- +struct LobbyChatMsg_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 7 }; + + uint64 m_ulSteamIDLobby; // the lobby id this is in + uint64 m_ulSteamIDUser; // steamID of the user who has sent this message + uint8 m_eChatEntryType; // type of message + uint32 m_iChatID; // index of the chat entry to lookup +}; + + +//----------------------------------------------------------------------------- +// Purpose: A game created a game for all the members of the lobby to join, +// as triggered by a SetLobbyGameServer() +// it's up to the individual clients to take action on this; the usual +// game behavior is to leave the lobby and connect to the specified game server +//----------------------------------------------------------------------------- +struct LobbyGameCreated_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 9 }; + + uint64 m_ulSteamIDLobby; // the lobby we were in + uint64 m_ulSteamIDGameServer; // the new game server that has been created or found for the lobby members + uint32 m_unIP; // IP & Port of the game server (if any) + uint16 m_usPort; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Number of matching lobbies found +// iterate the returned lobbies with GetLobbyByIndex(), from values 0 to m_nLobbiesMatching-1 +//----------------------------------------------------------------------------- +struct LobbyMatchList_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 10 }; + uint32 m_nLobbiesMatching; // Number of lobbies that matched search criteria and we have SteamIDs for +}; + + +//----------------------------------------------------------------------------- +// Purpose: posted if a user is forcefully removed from a lobby +// can occur if a user loses connection to Steam +//----------------------------------------------------------------------------- +struct LobbyKicked_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 12 }; + uint64 m_ulSteamIDLobby; // Lobby + uint64 m_ulSteamIDAdmin; // User who kicked you - possibly the ID of the lobby itself + uint8 m_bKickedDueToDisconnect; // true if you were kicked from the lobby due to the user losing connection to Steam (currently always true) +}; + + +//----------------------------------------------------------------------------- +// Purpose: Result of our request to create a Lobby +// m_eResult == k_EResultOK on success +// at this point, the lobby has been joined and is ready for use +// a LobbyEnter_t callback will also be received (since the local user is joining their own lobby) +//----------------------------------------------------------------------------- +struct LobbyCreated_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 13 }; + + EResult m_eResult; // k_EResultOK - the lobby was successfully created + // k_EResultNoConnection - your Steam client doesn't have a connection to the back-end + // k_EResultTimeout - you the message to the Steam servers, but it didn't respond + // k_EResultFail - the server responded, but with an unknown internal error + // k_EResultAccessDenied - your game isn't set to allow lobbies, or your client does haven't rights to play the game + // k_EResultLimitExceeded - your game client has created too many lobbies + + uint64 m_ulSteamIDLobby; // chat room, zero if failed +}; + +// used by now obsolete RequestFriendsLobbiesResponse_t +// enum { k_iCallback = k_iSteamMatchmakingCallbacks + 14 }; + + +//----------------------------------------------------------------------------- +// Purpose: Result of CheckForPSNGameBootInvite +// m_eResult == k_EResultOK on success +// at this point, the local user may not have finishing joining this lobby; +// game code should wait until the subsequent LobbyEnter_t callback is received +//----------------------------------------------------------------------------- +struct PSNGameBootInviteResult_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 15 }; + + bool m_bGameBootInviteExists; + CSteamID m_steamIDLobby; // Should be valid if m_bGameBootInviteExists == true +}; + + +//----------------------------------------------------------------------------- +// Purpose: Result of our request to create a Lobby +// m_eResult == k_EResultOK on success +// at this point, the lobby has been joined and is ready for use +// a LobbyEnter_t callback will also be received (since the local user is joining their own lobby) +//----------------------------------------------------------------------------- +struct FavoritesListAccountsUpdated_t +{ + enum { k_iCallback = k_iSteamMatchmakingCallbacks + 16 }; + + EResult m_eResult; +}; + +#pragma pack( pop ) + + +#endif // ISTEAMMATCHMAKING diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammusic.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammusic.h new file mode 100644 index 0000000..779a4c2 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammusic.h @@ -0,0 +1,67 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ + +#ifndef ISTEAMMUSIC_H +#define ISTEAMMUSIC_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +enum AudioPlayback_Status +{ + AudioPlayback_Undefined = 0, + AudioPlayback_Playing = 1, + AudioPlayback_Paused = 2, + AudioPlayback_Idle = 3 +}; + + +//----------------------------------------------------------------------------- +// Purpose: Functions to control music playback in the steam client +//----------------------------------------------------------------------------- +class ISteamMusic +{ +public: + virtual bool BIsEnabled() = 0; + virtual bool BIsPlaying() = 0; + + virtual AudioPlayback_Status GetPlaybackStatus() = 0; + + virtual void Play() = 0; + virtual void Pause() = 0; + virtual void PlayPrevious() = 0; + virtual void PlayNext() = 0; + + // volume is between 0.0 and 1.0 + virtual void SetVolume( float flVolume ) = 0; + virtual float GetVolume() = 0; + +}; + +#define STEAMMUSIC_INTERFACE_VERSION "STEAMMUSIC_INTERFACE_VERSION001" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + +DEFINE_CALLBACK( PlaybackStatusHasChanged_t, k_iSteamMusicCallbacks + 1 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( VolumeHasChanged_t, k_iSteamMusicCallbacks + 2 ) + CALLBACK_MEMBER( 0, float, m_flNewVolume ) +END_DEFINE_CALLBACK_1() + +#pragma pack( pop ) + + +#endif // #define ISTEAMMUSIC_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammusicremote.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammusicremote.h new file mode 100644 index 0000000..ea29a7d --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteammusicremote.h @@ -0,0 +1,129 @@ +//============ Copyright (c) Valve Corporation, All rights reserved. ============ + +#ifndef ISTEAMMUSICREMOTE_H +#define ISTEAMMUSICREMOTE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" +#include "isteammusic.h" + +#define k_SteamMusicNameMaxLength 255 +#define k_SteamMusicPNGMaxLength 65535 + + +class ISteamMusicRemote +{ +public: + // Service Definition + virtual bool RegisterSteamMusicRemote( const char *pchName ) = 0; + virtual bool DeregisterSteamMusicRemote() = 0; + virtual bool BIsCurrentMusicRemote() = 0; + virtual bool BActivationSuccess( bool bValue ) = 0; + + virtual bool SetDisplayName( const char *pchDisplayName ) = 0; + virtual bool SetPNGIcon_64x64( void *pvBuffer, uint32 cbBufferLength ) = 0; + + // Abilities for the user interface + virtual bool EnablePlayPrevious(bool bValue) = 0; + virtual bool EnablePlayNext( bool bValue ) = 0; + virtual bool EnableShuffled( bool bValue ) = 0; + virtual bool EnableLooped( bool bValue ) = 0; + virtual bool EnableQueue( bool bValue ) = 0; + virtual bool EnablePlaylists( bool bValue ) = 0; + + // Status + virtual bool UpdatePlaybackStatus( AudioPlayback_Status nStatus ) = 0; + virtual bool UpdateShuffled( bool bValue ) = 0; + virtual bool UpdateLooped( bool bValue ) = 0; + virtual bool UpdateVolume( float flValue ) = 0; // volume is between 0.0 and 1.0 + + // Current Entry + virtual bool CurrentEntryWillChange() = 0; + virtual bool CurrentEntryIsAvailable( bool bAvailable ) = 0; + virtual bool UpdateCurrentEntryText( const char *pchText ) = 0; + virtual bool UpdateCurrentEntryElapsedSeconds( int nValue ) = 0; + virtual bool UpdateCurrentEntryCoverArt( void *pvBuffer, uint32 cbBufferLength ) = 0; + virtual bool CurrentEntryDidChange() = 0; + + // Queue + virtual bool QueueWillChange() = 0; + virtual bool ResetQueueEntries() = 0; + virtual bool SetQueueEntry( int nID, int nPosition, const char *pchEntryText ) = 0; + virtual bool SetCurrentQueueEntry( int nID ) = 0; + virtual bool QueueDidChange() = 0; + + // Playlist + virtual bool PlaylistWillChange() = 0; + virtual bool ResetPlaylistEntries() = 0; + virtual bool SetPlaylistEntry( int nID, int nPosition, const char *pchEntryText ) = 0; + virtual bool SetCurrentPlaylistEntry( int nID ) = 0; + virtual bool PlaylistDidChange() = 0; +}; + +#define STEAMMUSICREMOTE_INTERFACE_VERSION "STEAMMUSICREMOTE_INTERFACE_VERSION001" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + +DEFINE_CALLBACK( MusicPlayerRemoteWillActivate_t, k_iSteamMusicRemoteCallbacks + 1) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerRemoteWillDeactivate_t, k_iSteamMusicRemoteCallbacks + 2 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerRemoteToFront_t, k_iSteamMusicRemoteCallbacks + 3 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerWillQuit_t, k_iSteamMusicRemoteCallbacks + 4 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerWantsPlay_t, k_iSteamMusicRemoteCallbacks + 5 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerWantsPause_t, k_iSteamMusicRemoteCallbacks + 6 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerWantsPlayPrevious_t, k_iSteamMusicRemoteCallbacks + 7 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerWantsPlayNext_t, k_iSteamMusicRemoteCallbacks + 8 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( MusicPlayerWantsShuffled_t, k_iSteamMusicRemoteCallbacks + 9 ) + CALLBACK_MEMBER( 0, bool, m_bShuffled ) +END_DEFINE_CALLBACK_1() + +DEFINE_CALLBACK( MusicPlayerWantsLooped_t, k_iSteamMusicRemoteCallbacks + 10 ) + CALLBACK_MEMBER(0, bool, m_bLooped ) +END_DEFINE_CALLBACK_1() + +DEFINE_CALLBACK( MusicPlayerWantsVolume_t, k_iSteamMusicCallbacks + 11 ) + CALLBACK_MEMBER(0, float, m_flNewVolume) +END_DEFINE_CALLBACK_1() + +DEFINE_CALLBACK( MusicPlayerSelectsQueueEntry_t, k_iSteamMusicCallbacks + 12 ) + CALLBACK_MEMBER(0, int, nID ) +END_DEFINE_CALLBACK_1() + +DEFINE_CALLBACK( MusicPlayerSelectsPlaylistEntry_t, k_iSteamMusicCallbacks + 13 ) + CALLBACK_MEMBER(0, int, nID ) +END_DEFINE_CALLBACK_1() + +DEFINE_CALLBACK( MusicPlayerWantsPlayingRepeatStatus_t, k_iSteamMusicRemoteCallbacks + 14 ) + CALLBACK_MEMBER(0, int, m_nPlayingRepeatStatus ) +END_DEFINE_CALLBACK_1() + +#pragma pack( pop ) + + + +#endif // #define ISTEAMMUSICREMOTE_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamnetworking.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamnetworking.h new file mode 100644 index 0000000..8f70819 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamnetworking.h @@ -0,0 +1,306 @@ +//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to steam managing network connections between game clients & servers +// +//============================================================================= + +#ifndef ISTEAMNETWORKING +#define ISTEAMNETWORKING +#ifdef _WIN32 +#pragma once +#endif + +#include "steamtypes.h" +#include "steamclientpublic.h" + + +// list of possible errors returned by SendP2PPacket() API +// these will be posted in the P2PSessionConnectFail_t callback +enum EP2PSessionError +{ + k_EP2PSessionErrorNone = 0, + k_EP2PSessionErrorNotRunningApp = 1, // target is not running the same game + k_EP2PSessionErrorNoRightsToApp = 2, // local user doesn't own the app that is running + k_EP2PSessionErrorDestinationNotLoggedIn = 3, // target user isn't connected to Steam + k_EP2PSessionErrorTimeout = 4, // target isn't responding, perhaps not calling AcceptP2PSessionWithUser() + // corporate firewalls can also block this (NAT traversal is not firewall traversal) + // make sure that UDP ports 3478, 4379, and 4380 are open in an outbound direction + k_EP2PSessionErrorMax = 5 +}; + +// SendP2PPacket() send types +// Typically k_EP2PSendUnreliable is what you want for UDP-like packets, k_EP2PSendReliable for TCP-like packets +enum EP2PSend +{ + // Basic UDP send. Packets can't be bigger than 1200 bytes (your typical MTU size). Can be lost, or arrive out of order (rare). + // The sending API does have some knowledge of the underlying connection, so if there is no NAT-traversal accomplished or + // there is a recognized adjustment happening on the connection, the packet will be batched until the connection is open again. + k_EP2PSendUnreliable = 0, + + // As above, but if the underlying p2p connection isn't yet established the packet will just be thrown away. Using this on the first + // packet sent to a remote host almost guarantees the packet will be dropped. + // This is only really useful for kinds of data that should never buffer up, i.e. voice payload packets + k_EP2PSendUnreliableNoDelay = 1, + + // Reliable message send. Can send up to 1MB of data in a single message. + // Does fragmentation/re-assembly of messages under the hood, as well as a sliding window for efficient sends of large chunks of data. + k_EP2PSendReliable = 2, + + // As above, but applies the Nagle algorithm to the send - sends will accumulate + // until the current MTU size (typically ~1200 bytes, but can change) or ~200ms has passed (Nagle algorithm). + // Useful if you want to send a set of smaller messages but have the coalesced into a single packet + // Since the reliable stream is all ordered, you can do several small message sends with k_EP2PSendReliableWithBuffering and then + // do a normal k_EP2PSendReliable to force all the buffered data to be sent. + k_EP2PSendReliableWithBuffering = 3, + +}; + + +// connection state to a specified user, returned by GetP2PSessionState() +// this is under-the-hood info about what's going on with a SendP2PPacket(), shouldn't be needed except for debuggin +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif +struct P2PSessionState_t +{ + uint8 m_bConnectionActive; // true if we've got an active open connection + uint8 m_bConnecting; // true if we're currently trying to establish a connection + uint8 m_eP2PSessionError; // last error recorded (see enum above) + uint8 m_bUsingRelay; // true if it's going through a relay server (TURN) + int32 m_nBytesQueuedForSend; + int32 m_nPacketsQueuedForSend; + uint32 m_nRemoteIP; // potential IP:Port of remote host. Could be TURN server. + uint16 m_nRemotePort; // Only exists for compatibility with older authentication api's +}; +#pragma pack( pop ) + + +// handle to a socket +typedef uint32 SNetSocket_t; // CreateP2PConnectionSocket() +typedef uint32 SNetListenSocket_t; // CreateListenSocket() + +// connection progress indicators, used by CreateP2PConnectionSocket() +enum ESNetSocketState +{ + k_ESNetSocketStateInvalid = 0, + + // communication is valid + k_ESNetSocketStateConnected = 1, + + // states while establishing a connection + k_ESNetSocketStateInitiated = 10, // the connection state machine has started + + // p2p connections + k_ESNetSocketStateLocalCandidatesFound = 11, // we've found our local IP info + k_ESNetSocketStateReceivedRemoteCandidates = 12,// we've received information from the remote machine, via the Steam back-end, about their IP info + + // direct connections + k_ESNetSocketStateChallengeHandshake = 15, // we've received a challenge packet from the server + + // failure states + k_ESNetSocketStateDisconnecting = 21, // the API shut it down, and we're in the process of telling the other end + k_ESNetSocketStateLocalDisconnect = 22, // the API shut it down, and we've completed shutdown + k_ESNetSocketStateTimeoutDuringConnect = 23, // we timed out while trying to creating the connection + k_ESNetSocketStateRemoteEndDisconnected = 24, // the remote end has disconnected from us + k_ESNetSocketStateConnectionBroken = 25, // connection has been broken; either the other end has disappeared or our local network connection has broke + +}; + +// describes how the socket is currently connected +enum ESNetSocketConnectionType +{ + k_ESNetSocketConnectionTypeNotConnected = 0, + k_ESNetSocketConnectionTypeUDP = 1, + k_ESNetSocketConnectionTypeUDPRelay = 2, +}; + + +//----------------------------------------------------------------------------- +// Purpose: Functions for making connections and sending data between clients, +// traversing NAT's where possible +//----------------------------------------------------------------------------- +class ISteamNetworking +{ +public: + //////////////////////////////////////////////////////////////////////////////////////////// + // Session-less connection functions + // automatically establishes NAT-traversing or Relay server connections + + // Sends a P2P packet to the specified user + // UDP-like, unreliable and a max packet size of 1200 bytes + // the first packet send may be delayed as the NAT-traversal code runs + // if we can't get through to the user, an error will be posted via the callback P2PSessionConnectFail_t + // see EP2PSend enum above for the descriptions of the different ways of sending packets + // + // nChannel is a routing number you can use to help route message to different systems - you'll have to call ReadP2PPacket() + // with the same channel number in order to retrieve the data on the other end + // using different channels to talk to the same user will still use the same underlying p2p connection, saving on resources + virtual bool SendP2PPacket( CSteamID steamIDRemote, const void *pubData, uint32 cubData, EP2PSend eP2PSendType, int nChannel = 0 ) = 0; + + // returns true if any data is available for read, and the amount of data that will need to be read + virtual bool IsP2PPacketAvailable( uint32 *pcubMsgSize, int nChannel = 0 ) = 0; + + // reads in a packet that has been sent from another user via SendP2PPacket() + // returns the size of the message and the steamID of the user who sent it in the last two parameters + // if the buffer passed in is too small, the message will be truncated + // this call is not blocking, and will return false if no data is available + virtual bool ReadP2PPacket( void *pubDest, uint32 cubDest, uint32 *pcubMsgSize, CSteamID *psteamIDRemote, int nChannel = 0 ) = 0; + + // AcceptP2PSessionWithUser() should only be called in response to a P2PSessionRequest_t callback + // P2PSessionRequest_t will be posted if another user tries to send you a packet that you haven't talked to yet + // if you don't want to talk to the user, just ignore the request + // if the user continues to send you packets, another P2PSessionRequest_t will be posted periodically + // this may be called multiple times for a single user + // (if you've called SendP2PPacket() on the other user, this implicitly accepts the session request) + virtual bool AcceptP2PSessionWithUser( CSteamID steamIDRemote ) = 0; + + // call CloseP2PSessionWithUser() when you're done talking to a user, will free up resources under-the-hood + // if the remote user tries to send data to you again, another P2PSessionRequest_t callback will be posted + virtual bool CloseP2PSessionWithUser( CSteamID steamIDRemote ) = 0; + + // call CloseP2PChannelWithUser() when you're done talking to a user on a specific channel. Once all channels + // open channels to a user have been closed, the open session to the user will be closed and new data from this + // user will trigger a P2PSessionRequest_t callback + virtual bool CloseP2PChannelWithUser( CSteamID steamIDRemote, int nChannel ) = 0; + + // fills out P2PSessionState_t structure with details about the underlying connection to the user + // should only needed for debugging purposes + // returns false if no connection exists to the specified user + virtual bool GetP2PSessionState( CSteamID steamIDRemote, P2PSessionState_t *pConnectionState ) = 0; + + // Allow P2P connections to fall back to being relayed through the Steam servers if a direct connection + // or NAT-traversal cannot be established. Only applies to connections created after setting this value, + // or to existing connections that need to automatically reconnect after this value is set. + // + // P2P packet relay is allowed by default + virtual bool AllowP2PPacketRelay( bool bAllow ) = 0; + + + //////////////////////////////////////////////////////////////////////////////////////////// + // LISTEN / CONNECT style interface functions + // + // This is an older set of functions designed around the Berkeley TCP sockets model + // it's preferential that you use the above P2P functions, they're more robust + // and these older functions will be removed eventually + // + //////////////////////////////////////////////////////////////////////////////////////////// + + + // creates a socket and listens others to connect + // will trigger a SocketStatusCallback_t callback on another client connecting + // nVirtualP2PPort is the unique ID that the client will connect to, in case you have multiple ports + // this can usually just be 0 unless you want multiple sets of connections + // unIP is the local IP address to bind to + // pass in 0 if you just want the default local IP + // unPort is the port to use + // pass in 0 if you don't want users to be able to connect via IP/Port, but expect to be always peer-to-peer connections only + virtual SNetListenSocket_t CreateListenSocket( int nVirtualP2PPort, uint32 nIP, uint16 nPort, bool bAllowUseOfPacketRelay ) = 0; + + // creates a socket and begin connection to a remote destination + // can connect via a known steamID (client or game server), or directly to an IP + // on success will trigger a SocketStatusCallback_t callback + // on failure or timeout will trigger a SocketStatusCallback_t callback with a failure code in m_eSNetSocketState + virtual SNetSocket_t CreateP2PConnectionSocket( CSteamID steamIDTarget, int nVirtualPort, int nTimeoutSec, bool bAllowUseOfPacketRelay ) = 0; + virtual SNetSocket_t CreateConnectionSocket( uint32 nIP, uint16 nPort, int nTimeoutSec ) = 0; + + // disconnects the connection to the socket, if any, and invalidates the handle + // any unread data on the socket will be thrown away + // if bNotifyRemoteEnd is set, socket will not be completely destroyed until the remote end acknowledges the disconnect + virtual bool DestroySocket( SNetSocket_t hSocket, bool bNotifyRemoteEnd ) = 0; + // destroying a listen socket will automatically kill all the regular sockets generated from it + virtual bool DestroyListenSocket( SNetListenSocket_t hSocket, bool bNotifyRemoteEnd ) = 0; + + // sending data + // must be a handle to a connected socket + // data is all sent via UDP, and thus send sizes are limited to 1200 bytes; after this, many routers will start dropping packets + // use the reliable flag with caution; although the resend rate is pretty aggressive, + // it can still cause stalls in receiving data (like TCP) + virtual bool SendDataOnSocket( SNetSocket_t hSocket, void *pubData, uint32 cubData, bool bReliable ) = 0; + + // receiving data + // returns false if there is no data remaining + // fills out *pcubMsgSize with the size of the next message, in bytes + virtual bool IsDataAvailableOnSocket( SNetSocket_t hSocket, uint32 *pcubMsgSize ) = 0; + + // fills in pubDest with the contents of the message + // messages are always complete, of the same size as was sent (i.e. packetized, not streaming) + // if *pcubMsgSize < cubDest, only partial data is written + // returns false if no data is available + virtual bool RetrieveDataFromSocket( SNetSocket_t hSocket, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize ) = 0; + + // checks for data from any socket that has been connected off this listen socket + // returns false if there is no data remaining + // fills out *pcubMsgSize with the size of the next message, in bytes + // fills out *phSocket with the socket that data is available on + virtual bool IsDataAvailable( SNetListenSocket_t hListenSocket, uint32 *pcubMsgSize, SNetSocket_t *phSocket ) = 0; + + // retrieves data from any socket that has been connected off this listen socket + // fills in pubDest with the contents of the message + // messages are always complete, of the same size as was sent (i.e. packetized, not streaming) + // if *pcubMsgSize < cubDest, only partial data is written + // returns false if no data is available + // fills out *phSocket with the socket that data is available on + virtual bool RetrieveData( SNetListenSocket_t hListenSocket, void *pubDest, uint32 cubDest, uint32 *pcubMsgSize, SNetSocket_t *phSocket ) = 0; + + // returns information about the specified socket, filling out the contents of the pointers + virtual bool GetSocketInfo( SNetSocket_t hSocket, CSteamID *pSteamIDRemote, int *peSocketStatus, uint32 *punIPRemote, uint16 *punPortRemote ) = 0; + + // returns which local port the listen socket is bound to + // *pnIP and *pnPort will be 0 if the socket is set to listen for P2P connections only + virtual bool GetListenSocketInfo( SNetListenSocket_t hListenSocket, uint32 *pnIP, uint16 *pnPort ) = 0; + + // returns true to describe how the socket ended up connecting + virtual ESNetSocketConnectionType GetSocketConnectionType( SNetSocket_t hSocket ) = 0; + + // max packet size, in bytes + virtual int GetMaxPacketSize( SNetSocket_t hSocket ) = 0; +}; +#define STEAMNETWORKING_INTERFACE_VERSION "SteamNetworking005" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +// callback notification - a user wants to talk to us over the P2P channel via the SendP2PPacket() API +// in response, a call to AcceptP2PPacketsFromUser() needs to be made, if you want to talk with them +struct P2PSessionRequest_t +{ + enum { k_iCallback = k_iSteamNetworkingCallbacks + 2 }; + CSteamID m_steamIDRemote; // user who wants to talk to us +}; + + +// callback notification - packets can't get through to the specified user via the SendP2PPacket() API +// all packets queued packets unsent at this point will be dropped +// further attempts to send will retry making the connection (but will be dropped if we fail again) +struct P2PSessionConnectFail_t +{ + enum { k_iCallback = k_iSteamNetworkingCallbacks + 3 }; + CSteamID m_steamIDRemote; // user we were sending packets to + uint8 m_eP2PSessionError; // EP2PSessionError indicating why we're having trouble +}; + + +// callback notification - status of a socket has changed +// used as part of the CreateListenSocket() / CreateP2PConnectionSocket() +struct SocketStatusCallback_t +{ + enum { k_iCallback = k_iSteamNetworkingCallbacks + 1 }; + SNetSocket_t m_hSocket; // the socket used to send/receive data to the remote host + SNetListenSocket_t m_hListenSocket; // this is the server socket that we were listening on; NULL if this was an outgoing connection + CSteamID m_steamIDRemote; // remote steamID we have connected to, if it has one + int m_eSNetSocketState; // socket state, ESNetSocketState +}; + +#pragma pack( pop ) + +#endif // ISTEAMNETWORKING diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamps3overlayrenderer.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamps3overlayrenderer.h new file mode 100644 index 0000000..4e07d4a --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamps3overlayrenderer.h @@ -0,0 +1,91 @@ +//====== Copyright © 1996-2010, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface the game must provide Steam with on PS3 in order for the +// Steam overlay to render. +// +//============================================================================= + +#ifndef ISTEAMPS3OVERLAYRENDERER_H +#define ISTEAMPS3OVERLAYRENDERER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "cell/pad.h" + +//----------------------------------------------------------------------------- +// Purpose: Enum for supported gradient directions +//----------------------------------------------------------------------------- +enum EOverlayGradientDirection +{ + k_EOverlayGradientHorizontal = 1, + k_EOverlayGradientVertical = 2, + k_EOverlayGradientNone = 3, +}; + +// Helpers for fetching individual color components from ARGB packed DWORD colors Steam PS3 overlay renderer uses. +#define STEAM_COLOR_RED( color ) \ + (int)(((color)>>16)&0xff) + +#define STEAM_COLOR_GREEN( color ) \ + (int)(((color)>>8)&0xff) + +#define STEAM_COLOR_BLUE( color ) \ + (int)((color)&0xff) + +#define STEAM_COLOR_ALPHA( color ) \ + (int)(((color)>>24)&0xff) + + +//----------------------------------------------------------------------------- +// Purpose: Interface the game must expose to Steam for rendering +//----------------------------------------------------------------------------- +class ISteamPS3OverlayRenderHost +{ +public: + + // Interface for game engine to implement which Steam requires to render. + + // Draw a textured rect. This may use only part of the texture and will pass texture coords, it will also possibly request a gradient and will specify colors for vertexes. + virtual void DrawTexturedRect( int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection ) = 0; + + // Load a RGBA texture for Steam, or update a previously loaded one. Updates may be partial. You must not evict or remove this texture once Steam has uploaded it. + virtual void LoadOrUpdateTexture( int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char *pData ) = 0; + + // Delete a texture Steam previously uploaded + virtual void DeleteTexture( int32 iTextureID ) = 0; + + // Delete all previously uploaded textures + virtual void DeleteAllTextures() = 0; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Interface Steam exposes for the game to tell it when to render, etc. +//----------------------------------------------------------------------------- +class ISteamPS3OverlayRender +{ +public: + + // Call once at startup to initialize the Steam overlay and pass it your host interface ptr + virtual bool BHostInitialize( uint32 unScreenWidth, uint32 unScreenHeight, uint32 unRefreshRate, ISteamPS3OverlayRenderHost *pRenderHost, void *CellFontLib ) = 0; + + // Call this once a frame when you are ready for the Steam overlay to render (ie, right before flipping buffers, after all your rendering) + virtual void Render() = 0; + + // Call this everytime you read input on PS3. + // + // If this returns true, then the overlay is active and has consumed the input, your game + // should then ignore all the input until BHandleCellPadData once again returns false, which + // will mean the overlay is deactivated. + virtual bool BHandleCellPadData( const CellPadData &padData ) = 0; + + // Call this if you detect no controllers connected or that the XMB is intercepting input + // + // This is important to clear input state for the overlay, so keys left down during XMB activation + // are not continued to be processed. + virtual bool BResetInputState() = 0; +}; + + +#endif // ISTEAMPS3OVERLAYRENDERER_H \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamremotestorage.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamremotestorage.h new file mode 100644 index 0000000..cce39df --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamremotestorage.h @@ -0,0 +1,675 @@ +//====== Copyright � 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: public interface to user remote file storage in Steam +// +//============================================================================= + +#ifndef ISTEAMREMOTESTORAGE_H +#define ISTEAMREMOTESTORAGE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + + +//----------------------------------------------------------------------------- +// Purpose: Defines the largest allowed file size. Cloud files cannot be written +// in a single chunk over 100MB (and cannot be over 200MB total.) +//----------------------------------------------------------------------------- +const uint32 k_unMaxCloudFileChunkSize = 100 * 1024 * 1024; + + +//----------------------------------------------------------------------------- +// Purpose: Structure that contains an array of const char * strings and the number of those strings +//----------------------------------------------------------------------------- +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif +struct SteamParamStringArray_t +{ + const char ** m_ppStrings; + int32 m_nNumStrings; +}; +#pragma pack( pop ) + +// A handle to a piece of user generated content +typedef uint64 UGCHandle_t; +typedef uint64 PublishedFileUpdateHandle_t; +typedef uint64 PublishedFileId_t; +const PublishedFileId_t k_PublishedFileIdInvalid = 0; +const UGCHandle_t k_UGCHandleInvalid = 0xffffffffffffffffull; +const PublishedFileUpdateHandle_t k_PublishedFileUpdateHandleInvalid = 0xffffffffffffffffull; + +// Handle for writing to Steam Cloud +typedef uint64 UGCFileWriteStreamHandle_t; +const UGCFileWriteStreamHandle_t k_UGCFileStreamHandleInvalid = 0xffffffffffffffffull; + +const uint32 k_cchPublishedDocumentTitleMax = 128 + 1; +const uint32 k_cchPublishedDocumentDescriptionMax = 8000; +const uint32 k_cchPublishedDocumentChangeDescriptionMax = 8000; +const uint32 k_unEnumeratePublishedFilesMaxResults = 50; +const uint32 k_cchTagListMax = 1024 + 1; +const uint32 k_cchFilenameMax = 260; +const uint32 k_cchPublishedFileURLMax = 256; + +// Ways to handle a synchronization conflict +enum EResolveConflict +{ + k_EResolveConflictKeepClient = 1, // The local version of each file will be used to overwrite the server version + k_EResolveConflictKeepServer = 2, // The server version of each file will be used to overwrite the local version +}; + +enum ERemoteStoragePlatform +{ + k_ERemoteStoragePlatformNone = 0, + k_ERemoteStoragePlatformWindows = (1 << 0), + k_ERemoteStoragePlatformOSX = (1 << 1), + k_ERemoteStoragePlatformPS3 = (1 << 2), + k_ERemoteStoragePlatformLinux = (1 << 3), + k_ERemoteStoragePlatformReserved2 = (1 << 4), + + k_ERemoteStoragePlatformAll = 0xffffffff +}; + +enum ERemoteStoragePublishedFileVisibility +{ + k_ERemoteStoragePublishedFileVisibilityPublic = 0, + k_ERemoteStoragePublishedFileVisibilityFriendsOnly = 1, + k_ERemoteStoragePublishedFileVisibilityPrivate = 2, +}; + + +enum EWorkshopFileType +{ + k_EWorkshopFileTypeFirst = 0, + + k_EWorkshopFileTypeCommunity = 0, // normal Workshop item that can be subscribed to + k_EWorkshopFileTypeMicrotransaction = 1, // Workshop item that is meant to be voted on for the purpose of selling in-game + k_EWorkshopFileTypeCollection = 2, // a collection of Workshop or Greenlight items + k_EWorkshopFileTypeArt = 3, // artwork + k_EWorkshopFileTypeVideo = 4, // external video + k_EWorkshopFileTypeScreenshot = 5, // screenshot + k_EWorkshopFileTypeGame = 6, // Greenlight game entry + k_EWorkshopFileTypeSoftware = 7, // Greenlight software entry + k_EWorkshopFileTypeConcept = 8, // Greenlight concept + k_EWorkshopFileTypeWebGuide = 9, // Steam web guide + k_EWorkshopFileTypeIntegratedGuide = 10, // application integrated guide + k_EWorkshopFileTypeMerch = 11, // Workshop merchandise meant to be voted on for the purpose of being sold + k_EWorkshopFileTypeControllerBinding = 12, // Steam Controller bindings + k_EWorkshopFileTypeSteamworksAccessInvite = 13, // internal + k_EWorkshopFileTypeSteamVideo = 14, // Steam video + k_EWorkshopFileTypeGameManagedItem = 15, // managed completely by the game, not the user, and not shown on the web + + // Update k_EWorkshopFileTypeMax if you add values. + k_EWorkshopFileTypeMax = 16 + +}; + +enum EWorkshopVote +{ + k_EWorkshopVoteUnvoted = 0, + k_EWorkshopVoteFor = 1, + k_EWorkshopVoteAgainst = 2, + k_EWorkshopVoteLater = 3, +}; + +enum EWorkshopFileAction +{ + k_EWorkshopFileActionPlayed = 0, + k_EWorkshopFileActionCompleted = 1, +}; + +enum EWorkshopEnumerationType +{ + k_EWorkshopEnumerationTypeRankedByVote = 0, + k_EWorkshopEnumerationTypeRecent = 1, + k_EWorkshopEnumerationTypeTrending = 2, + k_EWorkshopEnumerationTypeFavoritesOfFriends = 3, + k_EWorkshopEnumerationTypeVotedByFriends = 4, + k_EWorkshopEnumerationTypeContentByFriends = 5, + k_EWorkshopEnumerationTypeRecentFromFollowedUsers = 6, +}; + +enum EWorkshopVideoProvider +{ + k_EWorkshopVideoProviderNone = 0, + k_EWorkshopVideoProviderYoutube = 1 +}; + + +enum EUGCReadAction +{ + // Keeps the file handle open unless the last byte is read. You can use this when reading large files (over 100MB) in sequential chunks. + // If the last byte is read, this will behave the same as k_EUGCRead_Close. Otherwise, it behaves the same as k_EUGCRead_ContinueReading. + // This value maintains the same behavior as before the EUGCReadAction parameter was introduced. + k_EUGCRead_ContinueReadingUntilFinished = 0, + + // Keeps the file handle open. Use this when using UGCRead to seek to different parts of the file. + // When you are done seeking around the file, make a final call with k_EUGCRead_Close to close it. + k_EUGCRead_ContinueReading = 1, + + // Frees the file handle. Use this when you're done reading the content. + // To read the file from Steam again you will need to call UGCDownload again. + k_EUGCRead_Close = 2, +}; + + +//----------------------------------------------------------------------------- +// Purpose: Functions for accessing, reading and writing files stored remotely +// and cached locally +//----------------------------------------------------------------------------- +class ISteamRemoteStorage +{ + public: + // NOTE + // + // Filenames are case-insensitive, and will be converted to lowercase automatically. + // So "foo.bar" and "Foo.bar" are the same file, and if you write "Foo.bar" then + // iterate the files, the filename returned will be "foo.bar". + // + + // file operations + virtual bool FileWrite( const char *pchFile, const void *pvData, int32 cubData ) = 0; + virtual int32 FileRead( const char *pchFile, void *pvData, int32 cubDataToRead ) = 0; + + virtual SteamAPICall_t FileWriteAsync( const char *pchFile, const void *pvData, uint32 cubData ) = 0; + + virtual SteamAPICall_t FileReadAsync( const char *pchFile, uint32 nOffset, uint32 cubToRead ) = 0; + virtual bool FileReadAsyncComplete( SteamAPICall_t hReadCall, void *pvBuffer, uint32 cubToRead ) = 0; + + virtual bool FileForget( const char *pchFile ) = 0; + virtual bool FileDelete( const char *pchFile ) = 0; + virtual SteamAPICall_t FileShare( const char *pchFile ) = 0; + virtual bool SetSyncPlatforms( const char *pchFile, ERemoteStoragePlatform eRemoteStoragePlatform ) = 0; + + // file operations that cause network IO + virtual UGCFileWriteStreamHandle_t FileWriteStreamOpen( const char *pchFile ) = 0; + virtual bool FileWriteStreamWriteChunk( UGCFileWriteStreamHandle_t writeHandle, const void *pvData, int32 cubData ) = 0; + virtual bool FileWriteStreamClose( UGCFileWriteStreamHandle_t writeHandle ) = 0; + virtual bool FileWriteStreamCancel( UGCFileWriteStreamHandle_t writeHandle ) = 0; + + // file information + virtual bool FileExists( const char *pchFile ) = 0; + virtual bool FilePersisted( const char *pchFile ) = 0; + virtual int32 GetFileSize( const char *pchFile ) = 0; + virtual int64 GetFileTimestamp( const char *pchFile ) = 0; + virtual ERemoteStoragePlatform GetSyncPlatforms( const char *pchFile ) = 0; + + // iteration + virtual int32 GetFileCount() = 0; + virtual const char *GetFileNameAndSize( int iFile, int32 *pnFileSizeInBytes ) = 0; + + // configuration management + virtual bool GetQuota( int32 *pnTotalBytes, int32 *puAvailableBytes ) = 0; + virtual bool IsCloudEnabledForAccount() = 0; + virtual bool IsCloudEnabledForApp() = 0; + virtual void SetCloudEnabledForApp( bool bEnabled ) = 0; + + // user generated content + + // Downloads a UGC file. A priority value of 0 will download the file immediately, + // otherwise it will wait to download the file until all downloads with a lower priority + // value are completed. Downloads with equal priority will occur simultaneously. + virtual SteamAPICall_t UGCDownload( UGCHandle_t hContent, uint32 unPriority ) = 0; + + // Gets the amount of data downloaded so far for a piece of content. pnBytesExpected can be 0 if function returns false + // or if the transfer hasn't started yet, so be careful to check for that before dividing to get a percentage + virtual bool GetUGCDownloadProgress( UGCHandle_t hContent, int32 *pnBytesDownloaded, int32 *pnBytesExpected ) = 0; + + // Gets metadata for a file after it has been downloaded. This is the same metadata given in the RemoteStorageDownloadUGCResult_t call result + virtual bool GetUGCDetails( UGCHandle_t hContent, AppId_t *pnAppID, char **ppchName, int32 *pnFileSizeInBytes, OUT_STRUCT() CSteamID *pSteamIDOwner ) = 0; + + // After download, gets the content of the file. + // Small files can be read all at once by calling this function with an offset of 0 and cubDataToRead equal to the size of the file. + // Larger files can be read in chunks to reduce memory usage (since both sides of the IPC client and the game itself must allocate + // enough memory for each chunk). Once the last byte is read, the file is implicitly closed and further calls to UGCRead will fail + // unless UGCDownload is called again. + // For especially large files (anything over 100MB) it is a requirement that the file is read in chunks. + virtual int32 UGCRead( UGCHandle_t hContent, void *pvData, int32 cubDataToRead, uint32 cOffset, EUGCReadAction eAction ) = 0; + + // Functions to iterate through UGC that has finished downloading but has not yet been read via UGCRead() + virtual int32 GetCachedUGCCount() = 0; + virtual UGCHandle_t GetCachedUGCHandle( int32 iCachedContent ) = 0; + + // The following functions are only necessary on the Playstation 3. On PC & Mac, the Steam client will handle these operations for you + // On Playstation 3, the game controls which files are stored in the cloud, via FilePersist, FileFetch, and FileForget. + +#if defined(_PS3) || defined(_SERVER) + // Connect to Steam and get a list of files in the Cloud - results in a RemoteStorageAppSyncStatusCheck_t callback + virtual void GetFileListFromServer() = 0; + // Indicate this file should be downloaded in the next sync + virtual bool FileFetch( const char *pchFile ) = 0; + // Indicate this file should be persisted in the next sync + virtual bool FilePersist( const char *pchFile ) = 0; + // Pull any requested files down from the Cloud - results in a RemoteStorageAppSyncedClient_t callback + virtual bool SynchronizeToClient() = 0; + // Upload any requested files to the Cloud - results in a RemoteStorageAppSyncedServer_t callback + virtual bool SynchronizeToServer() = 0; + // Reset any fetch/persist/etc requests + virtual bool ResetFileRequestState() = 0; +#endif + + // publishing UGC + virtual SteamAPICall_t PublishWorkshopFile( const char *pchFile, const char *pchPreviewFile, AppId_t nConsumerAppId, const char *pchTitle, const char *pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, SteamParamStringArray_t *pTags, EWorkshopFileType eWorkshopFileType ) = 0; + virtual PublishedFileUpdateHandle_t CreatePublishedFileUpdateRequest( PublishedFileId_t unPublishedFileId ) = 0; + virtual bool UpdatePublishedFileFile( PublishedFileUpdateHandle_t updateHandle, const char *pchFile ) = 0; + virtual bool UpdatePublishedFilePreviewFile( PublishedFileUpdateHandle_t updateHandle, const char *pchPreviewFile ) = 0; + virtual bool UpdatePublishedFileTitle( PublishedFileUpdateHandle_t updateHandle, const char *pchTitle ) = 0; + virtual bool UpdatePublishedFileDescription( PublishedFileUpdateHandle_t updateHandle, const char *pchDescription ) = 0; + virtual bool UpdatePublishedFileVisibility( PublishedFileUpdateHandle_t updateHandle, ERemoteStoragePublishedFileVisibility eVisibility ) = 0; + virtual bool UpdatePublishedFileTags( PublishedFileUpdateHandle_t updateHandle, SteamParamStringArray_t *pTags ) = 0; + virtual SteamAPICall_t CommitPublishedFileUpdate( PublishedFileUpdateHandle_t updateHandle ) = 0; + // Gets published file details for the given publishedfileid. If unMaxSecondsOld is greater than 0, + // cached data may be returned, depending on how long ago it was cached. A value of 0 will force a refresh. + // A value of k_WorkshopForceLoadPublishedFileDetailsFromCache will use cached data if it exists, no matter how old it is. + virtual SteamAPICall_t GetPublishedFileDetails( PublishedFileId_t unPublishedFileId, uint32 unMaxSecondsOld ) = 0; + virtual SteamAPICall_t DeletePublishedFile( PublishedFileId_t unPublishedFileId ) = 0; + // enumerate the files that the current user published with this app + virtual SteamAPICall_t EnumerateUserPublishedFiles( uint32 unStartIndex ) = 0; + virtual SteamAPICall_t SubscribePublishedFile( PublishedFileId_t unPublishedFileId ) = 0; + virtual SteamAPICall_t EnumerateUserSubscribedFiles( uint32 unStartIndex ) = 0; + virtual SteamAPICall_t UnsubscribePublishedFile( PublishedFileId_t unPublishedFileId ) = 0; + virtual bool UpdatePublishedFileSetChangeDescription( PublishedFileUpdateHandle_t updateHandle, const char *pchChangeDescription ) = 0; + virtual SteamAPICall_t GetPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId ) = 0; + virtual SteamAPICall_t UpdateUserPublishedItemVote( PublishedFileId_t unPublishedFileId, bool bVoteUp ) = 0; + virtual SteamAPICall_t GetUserPublishedItemVoteDetails( PublishedFileId_t unPublishedFileId ) = 0; + virtual SteamAPICall_t EnumerateUserSharedWorkshopFiles( CSteamID steamId, uint32 unStartIndex, SteamParamStringArray_t *pRequiredTags, SteamParamStringArray_t *pExcludedTags ) = 0; + virtual SteamAPICall_t PublishVideo( EWorkshopVideoProvider eVideoProvider, const char *pchVideoAccount, const char *pchVideoIdentifier, const char *pchPreviewFile, AppId_t nConsumerAppId, const char *pchTitle, const char *pchDescription, ERemoteStoragePublishedFileVisibility eVisibility, SteamParamStringArray_t *pTags ) = 0; + virtual SteamAPICall_t SetUserPublishedFileAction( PublishedFileId_t unPublishedFileId, EWorkshopFileAction eAction ) = 0; + virtual SteamAPICall_t EnumeratePublishedFilesByUserAction( EWorkshopFileAction eAction, uint32 unStartIndex ) = 0; + // this method enumerates the public view of workshop files + virtual SteamAPICall_t EnumeratePublishedWorkshopFiles( EWorkshopEnumerationType eEnumerationType, uint32 unStartIndex, uint32 unCount, uint32 unDays, SteamParamStringArray_t *pTags, SteamParamStringArray_t *pUserTags ) = 0; + + virtual SteamAPICall_t UGCDownloadToLocation( UGCHandle_t hContent, const char *pchLocation, uint32 unPriority ) = 0; +}; + +#define STEAMREMOTESTORAGE_INTERFACE_VERSION "STEAMREMOTESTORAGE_INTERFACE_VERSION013" + + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +//----------------------------------------------------------------------------- +// Purpose: sent when the local file cache is fully synced with the server for an app +// That means that an application can be started and has all latest files +//----------------------------------------------------------------------------- +struct RemoteStorageAppSyncedClient_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 1 }; + AppId_t m_nAppID; + EResult m_eResult; + int m_unNumDownloads; +}; + +//----------------------------------------------------------------------------- +// Purpose: sent when the server is fully synced with the local file cache for an app +// That means that we can shutdown Steam and our data is stored on the server +//----------------------------------------------------------------------------- +struct RemoteStorageAppSyncedServer_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 2 }; + AppId_t m_nAppID; + EResult m_eResult; + int m_unNumUploads; +}; + +//----------------------------------------------------------------------------- +// Purpose: Status of up and downloads during a sync session +// +//----------------------------------------------------------------------------- +struct RemoteStorageAppSyncProgress_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 3 }; + char m_rgchCurrentFile[k_cchFilenameMax]; // Current file being transferred + AppId_t m_nAppID; // App this info relates to + uint32 m_uBytesTransferredThisChunk; // Bytes transferred this chunk + double m_dAppPercentComplete; // Percent complete that this app's transfers are + bool m_bUploading; // if false, downloading +}; + +// +// IMPORTANT! k_iClientRemoteStorageCallbacks + 4 is used, see iclientremotestorage.h +// + + +//----------------------------------------------------------------------------- +// Purpose: Sent after we've determined the list of files that are out of sync +// with the server. +//----------------------------------------------------------------------------- +struct RemoteStorageAppSyncStatusCheck_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 5 }; + AppId_t m_nAppID; + EResult m_eResult; +}; + +//----------------------------------------------------------------------------- +// Purpose: Sent after a conflict resolution attempt. +//----------------------------------------------------------------------------- +struct RemoteStorageConflictResolution_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 6 }; + AppId_t m_nAppID; + EResult m_eResult; +}; + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to FileShare() +//----------------------------------------------------------------------------- +struct RemoteStorageFileShareResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 7 }; + EResult m_eResult; // The result of the operation + UGCHandle_t m_hFile; // The handle that can be shared with users and features + char m_rgchFilename[k_cchFilenameMax]; // The name of the file that was shared +}; + + +// k_iClientRemoteStorageCallbacks + 8 is deprecated! Do not reuse + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to PublishFile() +//----------------------------------------------------------------------------- +struct RemoteStoragePublishFileResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 9 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; + bool m_bUserNeedsToAcceptWorkshopLegalAgreement; +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to DeletePublishedFile() +//----------------------------------------------------------------------------- +struct RemoteStorageDeletePublishedFileResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 11 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to EnumerateUserPublishedFiles() +//----------------------------------------------------------------------------- +struct RemoteStorageEnumerateUserPublishedFilesResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 12 }; + EResult m_eResult; // The result of the operation. + int32 m_nResultsReturned; + int32 m_nTotalResultCount; + PublishedFileId_t m_rgPublishedFileId[ k_unEnumeratePublishedFilesMaxResults ]; +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to SubscribePublishedFile() +//----------------------------------------------------------------------------- +struct RemoteStorageSubscribePublishedFileResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 13 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to EnumerateSubscribePublishedFiles() +//----------------------------------------------------------------------------- +struct RemoteStorageEnumerateUserSubscribedFilesResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 14 }; + EResult m_eResult; // The result of the operation. + int32 m_nResultsReturned; + int32 m_nTotalResultCount; + PublishedFileId_t m_rgPublishedFileId[ k_unEnumeratePublishedFilesMaxResults ]; + uint32 m_rgRTimeSubscribed[ k_unEnumeratePublishedFilesMaxResults ]; +}; + +#if defined(VALVE_CALLBACK_PACK_SMALL) + VALVE_COMPILE_TIME_ASSERT( sizeof( RemoteStorageEnumerateUserSubscribedFilesResult_t ) == (1 + 1 + 1 + 50 + 100) * 4 ); +#elif defined(VALVE_CALLBACK_PACK_LARGE) + VALVE_COMPILE_TIME_ASSERT( sizeof( RemoteStorageEnumerateUserSubscribedFilesResult_t ) == (1 + 1 + 1 + 50 + 100) * 4 + 4 ); +#else +#warning You must first include isteamclient.h +#endif + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to UnsubscribePublishedFile() +//----------------------------------------------------------------------------- +struct RemoteStorageUnsubscribePublishedFileResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 15 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to CommitPublishedFileUpdate() +//----------------------------------------------------------------------------- +struct RemoteStorageUpdatePublishedFileResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 16 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; + bool m_bUserNeedsToAcceptWorkshopLegalAgreement; +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to UGCDownload() +//----------------------------------------------------------------------------- +struct RemoteStorageDownloadUGCResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 17 }; + EResult m_eResult; // The result of the operation. + UGCHandle_t m_hFile; // The handle to the file that was attempted to be downloaded. + AppId_t m_nAppID; // ID of the app that created this file. + int32 m_nSizeInBytes; // The size of the file that was downloaded, in bytes. + char m_pchFileName[k_cchFilenameMax]; // The name of the file that was downloaded. + uint64 m_ulSteamIDOwner; // Steam ID of the user who created this content. +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to GetPublishedFileDetails() +//----------------------------------------------------------------------------- +struct RemoteStorageGetPublishedFileDetailsResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 18 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; + AppId_t m_nCreatorAppID; // ID of the app that created this file. + AppId_t m_nConsumerAppID; // ID of the app that will consume this file. + char m_rgchTitle[k_cchPublishedDocumentTitleMax]; // title of document + char m_rgchDescription[k_cchPublishedDocumentDescriptionMax]; // description of document + UGCHandle_t m_hFile; // The handle of the primary file + UGCHandle_t m_hPreviewFile; // The handle of the preview file + uint64 m_ulSteamIDOwner; // Steam ID of the user who created this content. + uint32 m_rtimeCreated; // time when the published file was created + uint32 m_rtimeUpdated; // time when the published file was last updated + ERemoteStoragePublishedFileVisibility m_eVisibility; + bool m_bBanned; + char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file + bool m_bTagsTruncated; // whether the list of tags was too long to be returned in the provided buffer + char m_pchFileName[k_cchFilenameMax]; // The name of the primary file + int32 m_nFileSize; // Size of the primary file + int32 m_nPreviewFileSize; // Size of the preview file + char m_rgchURL[k_cchPublishedFileURLMax]; // URL (for a video or a website) + EWorkshopFileType m_eFileType; // Type of the file + bool m_bAcceptedForUse; // developer has specifically flagged this item as accepted in the Workshop +}; + + +struct RemoteStorageEnumerateWorkshopFilesResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 19 }; + EResult m_eResult; + int32 m_nResultsReturned; + int32 m_nTotalResultCount; + PublishedFileId_t m_rgPublishedFileId[ k_unEnumeratePublishedFilesMaxResults ]; + float m_rgScore[ k_unEnumeratePublishedFilesMaxResults ]; + AppId_t m_nAppId; + uint32 m_unStartIndex; +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of GetPublishedItemVoteDetails +//----------------------------------------------------------------------------- +struct RemoteStorageGetPublishedItemVoteDetailsResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 20 }; + EResult m_eResult; + PublishedFileId_t m_unPublishedFileId; + int32 m_nVotesFor; + int32 m_nVotesAgainst; + int32 m_nReports; + float m_fScore; +}; + + +//----------------------------------------------------------------------------- +// Purpose: User subscribed to a file for the app (from within the app or on the web) +//----------------------------------------------------------------------------- +struct RemoteStoragePublishedFileSubscribed_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 21 }; + PublishedFileId_t m_nPublishedFileId; // The published file id + AppId_t m_nAppID; // ID of the app that will consume this file. +}; + +//----------------------------------------------------------------------------- +// Purpose: User unsubscribed from a file for the app (from within the app or on the web) +//----------------------------------------------------------------------------- +struct RemoteStoragePublishedFileUnsubscribed_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 22 }; + PublishedFileId_t m_nPublishedFileId; // The published file id + AppId_t m_nAppID; // ID of the app that will consume this file. +}; + + +//----------------------------------------------------------------------------- +// Purpose: Published file that a user owns was deleted (from within the app or the web) +//----------------------------------------------------------------------------- +struct RemoteStoragePublishedFileDeleted_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 23 }; + PublishedFileId_t m_nPublishedFileId; // The published file id + AppId_t m_nAppID; // ID of the app that will consume this file. +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to UpdateUserPublishedItemVote() +//----------------------------------------------------------------------------- +struct RemoteStorageUpdateUserPublishedItemVoteResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 24 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; // The published file id +}; + + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to GetUserPublishedItemVoteDetails() +//----------------------------------------------------------------------------- +struct RemoteStorageUserVoteDetails_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 25 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; // The published file id + EWorkshopVote m_eVote; // what the user voted +}; + +struct RemoteStorageEnumerateUserSharedWorkshopFilesResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 26 }; + EResult m_eResult; // The result of the operation. + int32 m_nResultsReturned; + int32 m_nTotalResultCount; + PublishedFileId_t m_rgPublishedFileId[ k_unEnumeratePublishedFilesMaxResults ]; +}; + +struct RemoteStorageSetUserPublishedFileActionResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 27 }; + EResult m_eResult; // The result of the operation. + PublishedFileId_t m_nPublishedFileId; // The published file id + EWorkshopFileAction m_eAction; // the action that was attempted +}; + +struct RemoteStorageEnumeratePublishedFilesByUserActionResult_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 28 }; + EResult m_eResult; // The result of the operation. + EWorkshopFileAction m_eAction; // the action that was filtered on + int32 m_nResultsReturned; + int32 m_nTotalResultCount; + PublishedFileId_t m_rgPublishedFileId[ k_unEnumeratePublishedFilesMaxResults ]; + uint32 m_rgRTimeUpdated[ k_unEnumeratePublishedFilesMaxResults ]; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Called periodically while a PublishWorkshopFile is in progress +//----------------------------------------------------------------------------- +struct RemoteStoragePublishFileProgress_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 29 }; + double m_dPercentFile; + bool m_bPreview; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Called when the content for a published file is updated +//----------------------------------------------------------------------------- +struct RemoteStoragePublishedFileUpdated_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 30 }; + PublishedFileId_t m_nPublishedFileId; // The published file id + AppId_t m_nAppID; // ID of the app that will consume this file. + UGCHandle_t m_hFile; // The new content +}; + +//----------------------------------------------------------------------------- +// Purpose: Called when a FileWriteAsync completes +//----------------------------------------------------------------------------- +struct RemoteStorageFileWriteAsyncComplete_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 31 }; + EResult m_eResult; // result +}; + +//----------------------------------------------------------------------------- +// Purpose: Called when a FileReadAsync completes +//----------------------------------------------------------------------------- +struct RemoteStorageFileReadAsyncComplete_t +{ + enum { k_iCallback = k_iClientRemoteStorageCallbacks + 32 }; + SteamAPICall_t m_hFileReadAsync; // call handle of the async read which was made + EResult m_eResult; // result + uint32 m_nOffset; // offset in the file this read was at + uint32 m_cubRead; // amount read - will the <= the amount requested +}; + +#pragma pack( pop ) + + +#endif // ISTEAMREMOTESTORAGE_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamscreenshots.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamscreenshots.h new file mode 100644 index 0000000..cfa7211 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamscreenshots.h @@ -0,0 +1,96 @@ +//====== Copyright � 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: public interface to user remote file storage in Steam +// +//============================================================================= + +#ifndef ISTEAMSCREENSHOTS_H +#define ISTEAMSCREENSHOTS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +const uint32 k_nScreenshotMaxTaggedUsers = 32; +const uint32 k_nScreenshotMaxTaggedPublishedFiles = 32; +const int k_cubUFSTagTypeMax = 255; +const int k_cubUFSTagValueMax = 255; + +// Required with of a thumbnail provided to AddScreenshotToLibrary. If you do not provide a thumbnail +// one will be generated. +const int k_ScreenshotThumbWidth = 200; + +// Handle is valid for the lifetime of your process and no longer +typedef uint32 ScreenshotHandle; +#define INVALID_SCREENSHOT_HANDLE 0 + +//----------------------------------------------------------------------------- +// Purpose: Functions for adding screenshots to the user's screenshot library +//----------------------------------------------------------------------------- +class ISteamScreenshots +{ +public: + // Writes a screenshot to the user's screenshot library given the raw image data, which must be in RGB format. + // The return value is a handle that is valid for the duration of the game process and can be used to apply tags. + virtual ScreenshotHandle WriteScreenshot( void *pubRGB, uint32 cubRGB, int nWidth, int nHeight ) = 0; + + // Adds a screenshot to the user's screenshot library from disk. If a thumbnail is provided, it must be 200 pixels wide and the same aspect ratio + // as the screenshot, otherwise a thumbnail will be generated if the user uploads the screenshot. The screenshots must be in either JPEG or TGA format. + // The return value is a handle that is valid for the duration of the game process and can be used to apply tags. + // JPEG, TGA, and PNG formats are supported. + virtual ScreenshotHandle AddScreenshotToLibrary( const char *pchFilename, const char *pchThumbnailFilename, int nWidth, int nHeight ) = 0; + + // Causes the Steam overlay to take a screenshot. If screenshots are being hooked by the game then a ScreenshotRequested_t callback is sent back to the game instead. + virtual void TriggerScreenshot() = 0; + + // Toggles whether the overlay handles screenshots when the user presses the screenshot hotkey, or the game handles them. If the game is hooking screenshots, + // then the ScreenshotRequested_t callback will be sent if the user presses the hotkey, and the game is expected to call WriteScreenshot or AddScreenshotToLibrary + // in response. + virtual void HookScreenshots( bool bHook ) = 0; + + // Sets metadata about a screenshot's location (for example, the name of the map) + virtual bool SetLocation( ScreenshotHandle hScreenshot, const char *pchLocation ) = 0; + + // Tags a user as being visible in the screenshot + virtual bool TagUser( ScreenshotHandle hScreenshot, CSteamID steamID ) = 0; + + // Tags a published file as being visible in the screenshot + virtual bool TagPublishedFile( ScreenshotHandle hScreenshot, PublishedFileId_t unPublishedFileID ) = 0; +}; + +#define STEAMSCREENSHOTS_INTERFACE_VERSION "STEAMSCREENSHOTS_INTERFACE_VERSION002" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif +//----------------------------------------------------------------------------- +// Purpose: Screenshot successfully written or otherwise added to the library +// and can now be tagged +//----------------------------------------------------------------------------- +struct ScreenshotReady_t +{ + enum { k_iCallback = k_iSteamScreenshotsCallbacks + 1 }; + ScreenshotHandle m_hLocal; + EResult m_eResult; +}; + +//----------------------------------------------------------------------------- +// Purpose: Screenshot has been requested by the user. Only sent if +// HookScreenshots() has been called, in which case Steam will not take +// the screenshot itself. +//----------------------------------------------------------------------------- +struct ScreenshotRequested_t +{ + enum { k_iCallback = k_iSteamScreenshotsCallbacks + 2 }; +}; + +#pragma pack( pop ) + + +#endif // ISTEAMSCREENSHOTS_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamugc.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamugc.h new file mode 100644 index 0000000..c574bf5 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamugc.h @@ -0,0 +1,385 @@ +//====== Copyright 1996-2013, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to steam ugc +// +//============================================================================= + +#ifndef ISTEAMUGC_H +#define ISTEAMUGC_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + +typedef uint64 UGCQueryHandle_t; +typedef uint64 UGCUpdateHandle_t; + + +const UGCQueryHandle_t k_UGCQueryHandleInvalid = 0xffffffffffffffffull; +const UGCUpdateHandle_t k_UGCUpdateHandleInvalid = 0xffffffffffffffffull; + + +// Matching UGC types for queries +enum EUGCMatchingUGCType +{ + k_EUGCMatchingUGCType_Items = 0, // both mtx items and ready-to-use items + k_EUGCMatchingUGCType_Items_Mtx = 1, + k_EUGCMatchingUGCType_Items_ReadyToUse = 2, + k_EUGCMatchingUGCType_Collections = 3, + k_EUGCMatchingUGCType_Artwork = 4, + k_EUGCMatchingUGCType_Videos = 5, + k_EUGCMatchingUGCType_Screenshots = 6, + k_EUGCMatchingUGCType_AllGuides = 7, // both web guides and integrated guides + k_EUGCMatchingUGCType_WebGuides = 8, + k_EUGCMatchingUGCType_IntegratedGuides = 9, + k_EUGCMatchingUGCType_UsableInGame = 10, // ready-to-use items and integrated guides + k_EUGCMatchingUGCType_ControllerBindings = 11, + k_EUGCMatchingUGCType_GameManagedItems = 12, // game managed items (not managed by users) + k_EUGCMatchingUGCType_All = ~0, // return everything +}; + +// Different lists of published UGC for a user. +// If the current logged in user is different than the specified user, then some options may not be allowed. +enum EUserUGCList +{ + k_EUserUGCList_Published, + k_EUserUGCList_VotedOn, + k_EUserUGCList_VotedUp, + k_EUserUGCList_VotedDown, + k_EUserUGCList_WillVoteLater, + k_EUserUGCList_Favorited, + k_EUserUGCList_Subscribed, + k_EUserUGCList_UsedOrPlayed, + k_EUserUGCList_Followed, +}; + +// Sort order for user published UGC lists (defaults to creation order descending) +enum EUserUGCListSortOrder +{ + k_EUserUGCListSortOrder_CreationOrderDesc, + k_EUserUGCListSortOrder_CreationOrderAsc, + k_EUserUGCListSortOrder_TitleAsc, + k_EUserUGCListSortOrder_LastUpdatedDesc, + k_EUserUGCListSortOrder_SubscriptionDateDesc, + k_EUserUGCListSortOrder_VoteScoreDesc, + k_EUserUGCListSortOrder_ForModeration, +}; + +// Combination of sorting and filtering for queries across all UGC +enum EUGCQuery +{ + k_EUGCQuery_RankedByVote = 0, + k_EUGCQuery_RankedByPublicationDate = 1, + k_EUGCQuery_AcceptedForGameRankedByAcceptanceDate = 2, + k_EUGCQuery_RankedByTrend = 3, + k_EUGCQuery_FavoritedByFriendsRankedByPublicationDate = 4, + k_EUGCQuery_CreatedByFriendsRankedByPublicationDate = 5, + k_EUGCQuery_RankedByNumTimesReported = 6, + k_EUGCQuery_CreatedByFollowedUsersRankedByPublicationDate = 7, + k_EUGCQuery_NotYetRated = 8, + k_EUGCQuery_RankedByTotalVotesAsc = 9, + k_EUGCQuery_RankedByVotesUp = 10, + k_EUGCQuery_RankedByTextSearch = 11, + k_EUGCQuery_RankedByTotalUniqueSubscriptions = 12, +}; + +enum EItemUpdateStatus +{ + k_EItemUpdateStatusInvalid = 0, // The item update handle was invalid, job might be finished, listen too SubmitItemUpdateResult_t + k_EItemUpdateStatusPreparingConfig = 1, // The item update is processing configuration data + k_EItemUpdateStatusPreparingContent = 2, // The item update is reading and processing content files + k_EItemUpdateStatusUploadingContent = 3, // The item update is uploading content changes to Steam + k_EItemUpdateStatusUploadingPreviewFile = 4, // The item update is uploading new preview file image + k_EItemUpdateStatusCommittingChanges = 5 // The item update is committing all changes +}; + +enum EItemState +{ + k_EItemStateNone = 0, // item not tracked on client + k_EItemStateSubscribed = 1, // current user is subscribed to this item. Not just cached. + k_EItemStateLegacyItem = 2, // item was created with ISteamRemoteStorage + k_EItemStateInstalled = 4, // item is installed and usable (but maybe out of date) + k_EItemStateNeedsUpdate = 8, // items needs an update. Either because it's not installed yet or creator updated content + k_EItemStateDownloading = 16, // item update is currently downloading + k_EItemStateDownloadPending = 32, // DownloadItem() was called for this item, content isn't available until DownloadItemResult_t is fired +}; + +enum EItemStatistic +{ + k_EItemStatistic_NumSubscriptions = 0, + k_EItemStatistic_NumFavorites = 1, + k_EItemStatistic_NumFollowers = 2, + k_EItemStatistic_NumUniqueSubscriptions = 3, + k_EItemStatistic_NumUniqueFavorites = 4, + k_EItemStatistic_NumUniqueFollowers = 5, + k_EItemStatistic_NumUniqueWebsiteViews = 6, + k_EItemStatistic_ReportScore = 7, +}; + +const uint32 kNumUGCResultsPerPage = 50; +const uint32 k_cchDeveloperMetadataMax = 5000; + +// Details for a single published file/UGC +struct SteamUGCDetails_t +{ + PublishedFileId_t m_nPublishedFileId; + EResult m_eResult; // The result of the operation. + EWorkshopFileType m_eFileType; // Type of the file + AppId_t m_nCreatorAppID; // ID of the app that created this file. + AppId_t m_nConsumerAppID; // ID of the app that will consume this file. + char m_rgchTitle[k_cchPublishedDocumentTitleMax]; // title of document + char m_rgchDescription[k_cchPublishedDocumentDescriptionMax]; // description of document + uint64 m_ulSteamIDOwner; // Steam ID of the user who created this content. + uint32 m_rtimeCreated; // time when the published file was created + uint32 m_rtimeUpdated; // time when the published file was last updated + uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable) + ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility + bool m_bBanned; // whether the file was banned + bool m_bAcceptedForUse; // developer has specifically flagged this item as accepted in the Workshop + bool m_bTagsTruncated; // whether the list of tags was too long to be returned in the provided buffer + char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file + // file/url information + UGCHandle_t m_hFile; // The handle of the primary file + UGCHandle_t m_hPreviewFile; // The handle of the preview file + char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file + int32 m_nFileSize; // Size of the primary file + int32 m_nPreviewFileSize; // Size of the preview file + char m_rgchURL[k_cchPublishedFileURLMax]; // URL (for a video or a website) + // voting information + uint32 m_unVotesUp; // number of votes up + uint32 m_unVotesDown; // number of votes down + float m_flScore; // calculated score + // collection details + uint32 m_unNumChildren; +}; + +//----------------------------------------------------------------------------- +// Purpose: Steam UGC support API +//----------------------------------------------------------------------------- +class ISteamUGC +{ +public: + + // Query UGC associated with a user. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1. + virtual UGCQueryHandle_t CreateQueryUserUGCRequest( AccountID_t unAccountID, EUserUGCList eListType, EUGCMatchingUGCType eMatchingUGCType, EUserUGCListSortOrder eSortOrder, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage ) = 0; + + // Query for all matching UGC. Creator app id or consumer app id must be valid and be set to the current running app. unPage should start at 1. + virtual UGCQueryHandle_t CreateQueryAllUGCRequest( EUGCQuery eQueryType, EUGCMatchingUGCType eMatchingeMatchingUGCTypeFileType, AppId_t nCreatorAppID, AppId_t nConsumerAppID, uint32 unPage ) = 0; + + // Query for the details of the given published file ids (the RequestUGCDetails call is deprecated and replaced with this) + virtual UGCQueryHandle_t CreateQueryUGCDetailsRequest( PublishedFileId_t *pvecPublishedFileID, uint32 unNumPublishedFileIDs ) = 0; + + // Send the query to Steam + virtual SteamAPICall_t SendQueryUGCRequest( UGCQueryHandle_t handle ) = 0; + + // Retrieve an individual result after receiving the callback for querying UGC + virtual bool GetQueryUGCResult( UGCQueryHandle_t handle, uint32 index, SteamUGCDetails_t *pDetails ) = 0; + virtual bool GetQueryUGCPreviewURL( UGCQueryHandle_t handle, uint32 index, char *pchURL, uint32 cchURLSize ) = 0; + virtual bool GetQueryUGCMetadata( UGCQueryHandle_t handle, uint32 index, char *pchMetadata, uint32 cchMetadatasize ) = 0; + virtual bool GetQueryUGCChildren( UGCQueryHandle_t handle, uint32 index, PublishedFileId_t* pvecPublishedFileID, uint32 cMaxEntries ) = 0; + virtual bool GetQueryUGCStatistic( UGCQueryHandle_t handle, uint32 index, EItemStatistic eStatType, uint32 *pStatValue ) = 0; + virtual uint32 GetQueryUGCNumAdditionalPreviews( UGCQueryHandle_t handle, uint32 index ) = 0; + virtual bool GetQueryUGCAdditionalPreview( UGCQueryHandle_t handle, uint32 index, uint32 previewIndex, char *pchURLOrVideoID, uint32 cchURLSize, bool *pbIsImage ) = 0; + virtual uint32 GetQueryUGCNumKeyValueTags( UGCQueryHandle_t handle, uint32 index ) = 0; + virtual bool GetQueryUGCKeyValueTag( UGCQueryHandle_t handle, uint32 index, uint32 keyValueTagIndex, char *pchKey, uint32 cchKeySize, char *pchValue, uint32 cchValueSize ) = 0; + + // Release the request to free up memory, after retrieving results + virtual bool ReleaseQueryUGCRequest( UGCQueryHandle_t handle ) = 0; + + // Options to set for querying UGC + virtual bool AddRequiredTag( UGCQueryHandle_t handle, const char *pTagName ) = 0; + virtual bool AddExcludedTag( UGCQueryHandle_t handle, const char *pTagName ) = 0; + virtual bool SetReturnKeyValueTags( UGCQueryHandle_t handle, bool bReturnKeyValueTags ) = 0; + virtual bool SetReturnLongDescription( UGCQueryHandle_t handle, bool bReturnLongDescription ) = 0; + virtual bool SetReturnMetadata( UGCQueryHandle_t handle, bool bReturnMetadata ) = 0; + virtual bool SetReturnChildren( UGCQueryHandle_t handle, bool bReturnChildren ) = 0; + virtual bool SetReturnAdditionalPreviews( UGCQueryHandle_t handle, bool bReturnAdditionalPreviews ) = 0; + virtual bool SetReturnTotalOnly( UGCQueryHandle_t handle, bool bReturnTotalOnly ) = 0; + virtual bool SetLanguage( UGCQueryHandle_t handle, const char *pchLanguage ) = 0; + virtual bool SetAllowCachedResponse( UGCQueryHandle_t handle, uint32 unMaxAgeSeconds ) = 0; + + // Options only for querying user UGC + virtual bool SetCloudFileNameFilter( UGCQueryHandle_t handle, const char *pMatchCloudFileName ) = 0; + + // Options only for querying all UGC + virtual bool SetMatchAnyTag( UGCQueryHandle_t handle, bool bMatchAnyTag ) = 0; + virtual bool SetSearchText( UGCQueryHandle_t handle, const char *pSearchText ) = 0; + virtual bool SetRankedByTrendDays( UGCQueryHandle_t handle, uint32 unDays ) = 0; + virtual bool AddRequiredKeyValueTag( UGCQueryHandle_t handle, const char *pKey, const char *pValue ) = 0; + + // DEPRECATED - Use CreateQueryUGCDetailsRequest call above instead! + virtual SteamAPICall_t RequestUGCDetails( PublishedFileId_t nPublishedFileID, uint32 unMaxAgeSeconds ) = 0; + + // Steam Workshop Creator API + virtual SteamAPICall_t CreateItem( AppId_t nConsumerAppId, EWorkshopFileType eFileType ) = 0; // create new item for this app with no content attached yet + + virtual UGCUpdateHandle_t StartItemUpdate( AppId_t nConsumerAppId, PublishedFileId_t nPublishedFileID ) = 0; // start an UGC item update. Set changed properties before commiting update with CommitItemUpdate() + + virtual bool SetItemTitle( UGCUpdateHandle_t handle, const char *pchTitle ) = 0; // change the title of an UGC item + virtual bool SetItemDescription( UGCUpdateHandle_t handle, const char *pchDescription ) = 0; // change the description of an UGC item + virtual bool SetItemUpdateLanguage( UGCUpdateHandle_t handle, const char *pchLanguage ) = 0; // specify the language of the title or description that will be set + virtual bool SetItemMetadata( UGCUpdateHandle_t handle, const char *pchMetaData ) = 0; // change the metadata of an UGC item (max = k_cchDeveloperMetadataMax) + virtual bool SetItemVisibility( UGCUpdateHandle_t handle, ERemoteStoragePublishedFileVisibility eVisibility ) = 0; // change the visibility of an UGC item + virtual bool SetItemTags( UGCUpdateHandle_t updateHandle, const SteamParamStringArray_t *pTags ) = 0; // change the tags of an UGC item + virtual bool SetItemContent( UGCUpdateHandle_t handle, const char *pszContentFolder ) = 0; // update item content from this local folder + virtual bool SetItemPreview( UGCUpdateHandle_t handle, const char *pszPreviewFile ) = 0; // change preview image file for this item. pszPreviewFile points to local image file, which must be under 1MB in size + virtual bool RemoveItemKeyValueTags( UGCUpdateHandle_t handle, const char *pchKey ) = 0; // remove any existing key-value tags with the specified key + virtual bool AddItemKeyValueTag( UGCUpdateHandle_t handle, const char *pchKey, const char *pchValue ) = 0; // add new key-value tags for the item. Note that there can be multiple values for a tag. + + virtual SteamAPICall_t SubmitItemUpdate( UGCUpdateHandle_t handle, const char *pchChangeNote ) = 0; // commit update process started with StartItemUpdate() + virtual EItemUpdateStatus GetItemUpdateProgress( UGCUpdateHandle_t handle, uint64 *punBytesProcessed, uint64* punBytesTotal ) = 0; + + // Steam Workshop Consumer API + virtual SteamAPICall_t SetUserItemVote( PublishedFileId_t nPublishedFileID, bool bVoteUp ) = 0; + virtual SteamAPICall_t GetUserItemVote( PublishedFileId_t nPublishedFileID ) = 0; + virtual SteamAPICall_t AddItemToFavorites( AppId_t nAppId, PublishedFileId_t nPublishedFileID ) = 0; + virtual SteamAPICall_t RemoveItemFromFavorites( AppId_t nAppId, PublishedFileId_t nPublishedFileID ) = 0; + virtual SteamAPICall_t SubscribeItem( PublishedFileId_t nPublishedFileID ) = 0; // subscribe to this item, will be installed ASAP + virtual SteamAPICall_t UnsubscribeItem( PublishedFileId_t nPublishedFileID ) = 0; // unsubscribe from this item, will be uninstalled after game quits + virtual uint32 GetNumSubscribedItems() = 0; // number of subscribed items + virtual uint32 GetSubscribedItems( PublishedFileId_t* pvecPublishedFileID, uint32 cMaxEntries ) = 0; // all subscribed item PublishFileIDs + + // get EItemState flags about item on this client + virtual uint32 GetItemState( PublishedFileId_t nPublishedFileID ) = 0; + + // get info about currently installed content on disc for items that have k_EItemStateInstalled set + // if k_EItemStateLegacyItem is set, pchFolder contains the path to the legacy file itself (not a folder) + virtual bool GetItemInstallInfo( PublishedFileId_t nPublishedFileID, uint64 *punSizeOnDisk, char *pchFolder, uint32 cchFolderSize, uint32 *punTimeStamp ) = 0; + + // get info about pending update for items that have k_EItemStateNeedsUpdate set. punBytesTotal will be valid after download started once + virtual bool GetItemDownloadInfo( PublishedFileId_t nPublishedFileID, uint64 *punBytesDownloaded, uint64 *punBytesTotal ) = 0; + + // download new or update already installed item. If function returns true, wait for DownloadItemResult_t. If the item is already installed, + // then files on disk should not be used until callback received. If item is not subscribed to, it will be cached for some time. + // If bHighPriority is set, any other item download will be suspended and this item downloaded ASAP. + virtual bool DownloadItem( PublishedFileId_t nPublishedFileID, bool bHighPriority ) = 0; + + // game servers can set a specific workshop folder before issuing any UGC commands. + // This is helpful if you want to support multiple game servers running out of the same install folder + virtual bool BInitWorkshopForGameServer( DepotId_t unWorkshopDepotID, const char *pszFolder ) = 0; + + // SuspendDownloads( true ) will suspend all workshop downloads until SuspendDownloads( false ) is called or the game ends + virtual void SuspendDownloads( bool bSuspend ) = 0; +}; + +#define STEAMUGC_INTERFACE_VERSION "STEAMUGC_INTERFACE_VERSION007" + +//----------------------------------------------------------------------------- +// Purpose: Callback for querying UGC +//----------------------------------------------------------------------------- +struct SteamUGCQueryCompleted_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 1 }; + UGCQueryHandle_t m_handle; + EResult m_eResult; + uint32 m_unNumResultsReturned; + uint32 m_unTotalMatchingResults; + bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache +}; + + +//----------------------------------------------------------------------------- +// Purpose: Callback for requesting details on one piece of UGC +//----------------------------------------------------------------------------- +struct SteamUGCRequestUGCDetailsResult_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 2 }; + SteamUGCDetails_t m_details; + bool m_bCachedData; // indicates whether this data was retrieved from the local on-disk cache +}; + + +//----------------------------------------------------------------------------- +// Purpose: result for ISteamUGC::CreateItem() +//----------------------------------------------------------------------------- +struct CreateItemResult_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 3 }; + EResult m_eResult; + PublishedFileId_t m_nPublishedFileId; // new item got this UGC PublishFileID + bool m_bUserNeedsToAcceptWorkshopLegalAgreement; +}; + + +//----------------------------------------------------------------------------- +// Purpose: result for ISteamUGC::SubmitItemUpdate() +//----------------------------------------------------------------------------- +struct SubmitItemUpdateResult_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 4 }; + EResult m_eResult; + bool m_bUserNeedsToAcceptWorkshopLegalAgreement; +}; + + +//----------------------------------------------------------------------------- +// Purpose: a Workshop item has been installed or updated +//----------------------------------------------------------------------------- +struct ItemInstalled_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 5 }; + AppId_t m_unAppID; + PublishedFileId_t m_nPublishedFileId; +}; + + +//----------------------------------------------------------------------------- +// Purpose: result of DownloadItem(), existing item files can be accessed again +//----------------------------------------------------------------------------- +struct DownloadItemResult_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 6 }; + AppId_t m_unAppID; + PublishedFileId_t m_nPublishedFileId; + EResult m_eResult; +}; + +//----------------------------------------------------------------------------- +// Purpose: result of AddItemToFavorites() or RemoveItemFromFavorites() +//----------------------------------------------------------------------------- +struct UserFavoriteItemsListChanged_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 7 }; + PublishedFileId_t m_nPublishedFileId; + EResult m_eResult; + bool m_bWasAddRequest; +}; + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to SetUserItemVote() +//----------------------------------------------------------------------------- +struct SetUserItemVoteResult_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 8 }; + PublishedFileId_t m_nPublishedFileId; + EResult m_eResult; + bool m_bVoteUp; +}; + +//----------------------------------------------------------------------------- +// Purpose: The result of a call to GetUserItemVote() +//----------------------------------------------------------------------------- +struct GetUserItemVoteResult_t +{ + enum { k_iCallback = k_iClientUGCCallbacks + 9 }; + PublishedFileId_t m_nPublishedFileId; + EResult m_eResult; + bool m_bVotedUp; + bool m_bVotedDown; + bool m_bVoteSkipped; +}; + +#pragma pack( pop ) + +#endif // ISTEAMUGC_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamunifiedmessages.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamunifiedmessages.h new file mode 100644 index 0000000..684f4e8 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamunifiedmessages.h @@ -0,0 +1,63 @@ +//====== Copyright � 1996-2007, Valve Corporation, All rights reserved. ======= +// +// Purpose: Interface to unified messages client +// +// You should not need to use this interface except if your product is using a language other than C++. +// Contact your Steam Tech contact for more details. +// +//============================================================================= + +#ifndef ISTEAMUNIFIEDMESSAGES_H +#define ISTEAMUNIFIEDMESSAGES_H +#ifdef _WIN32 +#pragma once +#endif + +typedef uint64 ClientUnifiedMessageHandle; + +class ISteamUnifiedMessages +{ +public: + static const ClientUnifiedMessageHandle k_InvalidUnifiedMessageHandle = 0; + + // Sends a service method (in binary serialized form) using the Steam Client. + // Returns a unified message handle (k_InvalidUnifiedMessageHandle if could not send the message). + virtual ClientUnifiedMessageHandle SendMethod( const char *pchServiceMethod, const void *pRequestBuffer, uint32 unRequestBufferSize, uint64 unContext ) = 0; + + // Gets the size of the response and the EResult. Returns false if the response is not ready yet. + virtual bool GetMethodResponseInfo( ClientUnifiedMessageHandle hHandle, uint32 *punResponseSize, EResult *peResult ) = 0; + + // Gets a response in binary serialized form (and optionally release the corresponding allocated memory). + virtual bool GetMethodResponseData( ClientUnifiedMessageHandle hHandle, void *pResponseBuffer, uint32 unResponseBufferSize, bool bAutoRelease ) = 0; + + // Releases the message and its corresponding allocated memory. + virtual bool ReleaseMethod( ClientUnifiedMessageHandle hHandle ) = 0; + + // Sends a service notification (in binary serialized form) using the Steam Client. + // Returns true if the notification was sent successfully. + virtual bool SendNotification( const char *pchServiceNotification, const void *pNotificationBuffer, uint32 unNotificationBufferSize ) = 0; +}; + +#define STEAMUNIFIEDMESSAGES_INTERFACE_VERSION "STEAMUNIFIEDMESSAGES_INTERFACE_VERSION001" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +struct SteamUnifiedMessagesSendMethodResult_t +{ + enum { k_iCallback = k_iClientUnifiedMessagesCallbacks + 1 }; + ClientUnifiedMessageHandle m_hHandle; // The handle returned by SendMethod(). + uint64 m_unContext; // Context provided when calling SendMethod(). + EResult m_eResult; // The result of the method call. + uint32 m_unResponseSize; // The size of the response. +}; + +#pragma pack( pop ) + +#endif // ISTEAMUNIFIEDMESSAGES_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamuser.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamuser.h new file mode 100644 index 0000000..5af937d --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamuser.h @@ -0,0 +1,380 @@ +//====== Copyright (c) 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to user account information in Steam +// +//============================================================================= + +#ifndef ISTEAMUSER_H +#define ISTEAMUSER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +// structure that contains client callback data +// see callbacks documentation for more details +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif +struct CallbackMsg_t +{ + HSteamUser m_hSteamUser; + int m_iCallback; + uint8 *m_pubParam; + int m_cubParam; +}; +#pragma pack( pop ) + +// reference to a steam call, to filter results by +typedef int32 HSteamCall; + +//----------------------------------------------------------------------------- +// Purpose: Functions for accessing and manipulating a steam account +// associated with one client instance +//----------------------------------------------------------------------------- +class ISteamUser +{ +public: + // returns the HSteamUser this interface represents + // this is only used internally by the API, and by a few select interfaces that support multi-user + virtual HSteamUser GetHSteamUser() = 0; + + // returns true if the Steam client current has a live connection to the Steam servers. + // If false, it means there is no active connection due to either a networking issue on the local machine, or the Steam server is down/busy. + // The Steam client will automatically be trying to recreate the connection as often as possible. + virtual bool BLoggedOn() = 0; + + // returns the CSteamID of the account currently logged into the Steam client + // a CSteamID is a unique identifier for an account, and used to differentiate users in all parts of the Steamworks API + virtual CSteamID GetSteamID() = 0; + + // Multiplayer Authentication functions + + // InitiateGameConnection() starts the state machine for authenticating the game client with the game server + // It is the client portion of a three-way handshake between the client, the game server, and the steam servers + // + // Parameters: + // void *pAuthBlob - a pointer to empty memory that will be filled in with the authentication token. + // int cbMaxAuthBlob - the number of bytes of allocated memory in pBlob. Should be at least 2048 bytes. + // CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client + // CGameID gameID - the ID of the current game. For games without mods, this is just CGameID( ) + // uint32 unIPServer, uint16 usPortServer - the IP address of the game server + // bool bSecure - whether or not the client thinks that the game server is reporting itself as secure (i.e. VAC is running) + // + // return value - returns the number of bytes written to pBlob. If the return is 0, then the buffer passed in was too small, and the call has failed + // The contents of pBlob should then be sent to the game server, for it to use to complete the authentication process. + virtual int InitiateGameConnection( void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure ) = 0; + + // notify of disconnect + // needs to occur when the game client leaves the specified game server, needs to match with the InitiateGameConnection() call + virtual void TerminateGameConnection( uint32 unIPServer, uint16 usPortServer ) = 0; + + // Legacy functions + + // used by only a few games to track usage events + virtual void TrackAppUsageEvent( CGameID gameID, int eAppUsageEvent, const char *pchExtraInfo = "" ) = 0; + + // get the local storage folder for current Steam account to write application data, e.g. save games, configs etc. + // this will usually be something like "C:\Progam Files\Steam\userdata\\\local" + virtual bool GetUserDataFolder( char *pchBuffer, int cubBuffer ) = 0; + + // Starts voice recording. Once started, use GetVoice() to get the data + virtual void StartVoiceRecording( ) = 0; + + // Stops voice recording. Because people often release push-to-talk keys early, the system will keep recording for + // a little bit after this function is called. GetVoice() should continue to be called until it returns + // k_eVoiceResultNotRecording + virtual void StopVoiceRecording( ) = 0; + + // Determine the amount of captured audio data that is available in bytes. + // This provides both the compressed and uncompressed data. Please note that the uncompressed + // data is not the raw feed from the microphone: data may only be available if audible + // levels of speech are detected. + // nUncompressedVoiceDesiredSampleRate is necessary to know the number of bytes to return in pcbUncompressed - can be set to 0 if you don't need uncompressed (the usual case) + // If you're upgrading from an older Steamworks API, you'll want to pass in 11025 to nUncompressedVoiceDesiredSampleRate + virtual EVoiceResult GetAvailableVoice( uint32 *pcbCompressed, uint32 *pcbUncompressed, uint32 nUncompressedVoiceDesiredSampleRate ) = 0; + + // Gets the latest voice data from the microphone. Compressed data is an arbitrary format, and is meant to be handed back to + // DecompressVoice() for playback later as a binary blob. Uncompressed data is 16-bit, signed integer, 11025Hz PCM format. + // Please note that the uncompressed data is not the raw feed from the microphone: data may only be available if audible + // levels of speech are detected, and may have passed through denoising filters, etc. + // This function should be called as often as possible once recording has started; once per frame at least. + // nBytesWritten is set to the number of bytes written to pDestBuffer. + // nUncompressedBytesWritten is set to the number of bytes written to pUncompressedDestBuffer. + // You must grab both compressed and uncompressed here at the same time, if you want both. + // Matching data that is not read during this call will be thrown away. + // GetAvailableVoice() can be used to determine how much data is actually available. + // If you're upgrading from an older Steamworks API, you'll want to pass in 11025 to nUncompressedVoiceDesiredSampleRate + virtual EVoiceResult GetVoice( bool bWantCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, bool bWantUncompressed, void *pUncompressedDestBuffer, uint32 cbUncompressedDestBufferSize, uint32 *nUncompressBytesWritten, uint32 nUncompressedVoiceDesiredSampleRate ) = 0; + + // Decompresses a chunk of compressed data produced by GetVoice(). + // nBytesWritten is set to the number of bytes written to pDestBuffer unless the return value is k_EVoiceResultBufferTooSmall. + // In that case, nBytesWritten is set to the size of the buffer required to decompress the given + // data. The suggested buffer size for the destination buffer is 22 kilobytes. + // The output format of the data is 16-bit signed at the requested samples per second. + // If you're upgrading from an older Steamworks API, you'll want to pass in 11025 to nDesiredSampleRate + virtual EVoiceResult DecompressVoice( const void *pCompressed, uint32 cbCompressed, void *pDestBuffer, uint32 cbDestBufferSize, uint32 *nBytesWritten, uint32 nDesiredSampleRate ) = 0; + + // This returns the frequency of the voice data as it's stored internally; calling DecompressVoice() with this size will yield the best results + virtual uint32 GetVoiceOptimalSampleRate() = 0; + + // Retrieve ticket to be sent to the entity who wishes to authenticate you. + // pcbTicket retrieves the length of the actual ticket. + virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0; + + // Authenticate ticket from entity steamID to be sure it is valid and isnt reused + // Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse ) + virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0; + + // Stop tracking started by BeginAuthSession - called when no longer playing game with this entity + virtual void EndAuthSession( CSteamID steamID ) = 0; + + // Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to + virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0; + + // After receiving a user's authentication data, and passing it to BeginAuthSession, use this function + // to determine if the user owns downloadable content specified by the provided AppID. + virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0; + + // returns true if this users looks like they are behind a NAT device. Only valid once the user has connected to steam + // (i.e a SteamServersConnected_t has been issued) and may not catch all forms of NAT. + virtual bool BIsBehindNAT() = 0; + + // set data to be replicated to friends so that they can join your game + // CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client + // uint32 unIPServer, uint16 usPortServer - the IP address of the game server + virtual void AdvertiseGame( CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer ) = 0; + + // Requests a ticket encrypted with an app specific shared key + // pDataToInclude, cbDataToInclude will be encrypted into the ticket + // ( This is asynchronous, you must wait for the ticket to be completed by the server ) + virtual SteamAPICall_t RequestEncryptedAppTicket( void *pDataToInclude, int cbDataToInclude ) = 0; + + // retrieve a finished ticket + virtual bool GetEncryptedAppTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0; + + // Trading Card badges data access + // if you only have one set of cards, the series will be 1 + // the user has can have two different badges for a series; the regular (max level 5) and the foil (max level 1) + virtual int GetGameBadgeLevel( int nSeries, bool bFoil ) = 0; + + // gets the Steam Level of the user, as shown on their profile + virtual int GetPlayerSteamLevel() = 0; + + // Requests a URL which authenticates an in-game browser for store check-out, + // and then redirects to the specified URL. As long as the in-game browser + // accepts and handles session cookies, Steam microtransaction checkout pages + // will automatically recognize the user instead of presenting a login page. + // The result of this API call will be a StoreAuthURLResponse_t callback. + // NOTE: The URL has a very short lifetime to prevent history-snooping attacks, + // so you should only call this API when you are about to launch the browser, + // or else immediately navigate to the result URL using a hidden browser window. + // NOTE 2: The resulting authorization cookie has an expiration time of one day, + // so it would be a good idea to request and visit a new auth URL every 12 hours. + virtual SteamAPICall_t RequestStoreAuthURL( const char *pchRedirectURL ) = 0; + +#ifdef _PS3 + // Initiates PS3 Logon request using just PSN ticket. + // + // PARAMS: bInteractive - If set tells Steam to go ahead and show the PS3 NetStart dialog if needed to + // prompt the user for network setup/PSN logon before initiating the Steam side of the logon. + // + // Listen for SteamServersConnected_t or SteamServerConnectFailure_t for status. SteamServerConnectFailure_t + // may return with EResult k_EResultExternalAccountUnlinked if the PSN account is unknown to Steam. You should + // then call LogOnAndLinkSteamAccountToPSN() after prompting the user for credentials to establish a link. + // Future calls to LogOn() after the one time link call should succeed as long as the user is connected to PSN. + virtual void LogOn( bool bInteractive ) = 0; + + // Initiates a request to logon with a specific steam username/password and create a PSN account link at + // the same time. Should call this only if LogOn() has failed and indicated the PSN account is unlinked. + // + // PARAMS: bInteractive - If set tells Steam to go ahead and show the PS3 NetStart dialog if needed to + // prompt the user for network setup/PSN logon before initiating the Steam side of the logon. pchUserName + // should be the users Steam username, and pchPassword should be the users Steam password. + // + // Listen for SteamServersConnected_t or SteamServerConnectFailure_t for status. SteamServerConnectFailure_t + // may return with EResult k_EResultOtherAccountAlreadyLinked if already linked to another account. + virtual void LogOnAndLinkSteamAccountToPSN( bool bInteractive, const char *pchUserName, const char *pchPassword ) = 0; + + // Final logon option for PS3, this logs into an existing account if already linked, but if not already linked + // creates a new account using the info in the PSN ticket to generate a unique account name. The new account is + // then linked to the PSN ticket. This is the faster option for new users who don't have an existing Steam account + // to get into multiplayer. + // + // PARAMS: bInteractive - If set tells Steam to go ahead and show the PS3 NetStart dialog if needed to + // prompt the user for network setup/PSN logon before initiating the Steam side of the logon. + virtual void LogOnAndCreateNewSteamAccountIfNeeded( bool bInteractive ) = 0; + + // Returns a special SteamID that represents the user's PSN information. Can be used to query the user's PSN avatar, + // online name, etc. through the standard Steamworks interfaces. + virtual CSteamID GetConsoleSteamID() = 0; +#endif + +}; + +#define STEAMUSER_INTERFACE_VERSION "SteamUser018" + + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +//----------------------------------------------------------------------------- +// Purpose: called when a connections to the Steam back-end has been established +// this means the Steam client now has a working connection to the Steam servers +// usually this will have occurred before the game has launched, and should +// only be seen if the user has dropped connection due to a networking issue +// or a Steam server update +//----------------------------------------------------------------------------- +struct SteamServersConnected_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 1 }; +}; + +//----------------------------------------------------------------------------- +// Purpose: called when a connection attempt has failed +// this will occur periodically if the Steam client is not connected, +// and has failed in it's retry to establish a connection +//----------------------------------------------------------------------------- +struct SteamServerConnectFailure_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 2 }; + EResult m_eResult; + bool m_bStillRetrying; +}; + + +//----------------------------------------------------------------------------- +// Purpose: called if the client has lost connection to the Steam servers +// real-time services will be disabled until a matching SteamServersConnected_t has been posted +//----------------------------------------------------------------------------- +struct SteamServersDisconnected_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 3 }; + EResult m_eResult; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Sent by the Steam server to the client telling it to disconnect from the specified game server, +// which it may be in the process of or already connected to. +// The game client should immediately disconnect upon receiving this message. +// This can usually occur if the user doesn't have rights to play on the game server. +//----------------------------------------------------------------------------- +struct ClientGameServerDeny_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 13 }; + + uint32 m_uAppID; + uint32 m_unGameServerIP; + uint16 m_usGameServerPort; + uint16 m_bSecure; + uint32 m_uReason; +}; + + +//----------------------------------------------------------------------------- +// Purpose: called when the callback system for this client is in an error state (and has flushed pending callbacks) +// When getting this message the client should disconnect from Steam, reset any stored Steam state and reconnect. +// This usually occurs in the rare event the Steam client has some kind of fatal error. +//----------------------------------------------------------------------------- +struct IPCFailure_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 17 }; + enum EFailureType + { + k_EFailureFlushedCallbackQueue, + k_EFailurePipeFail, + }; + uint8 m_eFailureType; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Signaled whenever licenses change +//----------------------------------------------------------------------------- +struct LicensesUpdated_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 25 }; +}; + + +//----------------------------------------------------------------------------- +// callback for BeginAuthSession +//----------------------------------------------------------------------------- +struct ValidateAuthTicketResponse_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 43 }; + CSteamID m_SteamID; + EAuthSessionResponse m_eAuthSessionResponse; + CSteamID m_OwnerSteamID; // different from m_SteamID if borrowed +}; + + +//----------------------------------------------------------------------------- +// Purpose: called when a user has responded to a microtransaction authorization request +//----------------------------------------------------------------------------- +struct MicroTxnAuthorizationResponse_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 52 }; + + uint32 m_unAppID; // AppID for this microtransaction + uint64 m_ulOrderID; // OrderID provided for the microtransaction + uint8 m_bAuthorized; // if user authorized transaction +}; + + +//----------------------------------------------------------------------------- +// Purpose: Result from RequestEncryptedAppTicket +//----------------------------------------------------------------------------- +struct EncryptedAppTicketResponse_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 54 }; + + EResult m_eResult; +}; + +//----------------------------------------------------------------------------- +// callback for GetAuthSessionTicket +//----------------------------------------------------------------------------- +struct GetAuthSessionTicketResponse_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 63 }; + HAuthTicket m_hAuthTicket; + EResult m_eResult; +}; + + +//----------------------------------------------------------------------------- +// Purpose: sent to your game in response to a steam://gamewebcallback/ command +//----------------------------------------------------------------------------- +struct GameWebCallback_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 64 }; + char m_szURL[256]; +}; + +//----------------------------------------------------------------------------- +// Purpose: sent to your game in response to ISteamUser::RequestStoreAuthURL +//----------------------------------------------------------------------------- +struct StoreAuthURLResponse_t +{ + enum { k_iCallback = k_iSteamUserCallbacks + 65 }; + char m_szURL[512]; +}; + + + +#pragma pack( pop ) + +#endif // ISTEAMUSER_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamuserstats.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamuserstats.h new file mode 100644 index 0000000..3a65691 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamuserstats.h @@ -0,0 +1,465 @@ +//====== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to stats, achievements, and leaderboards +// +//============================================================================= + +#ifndef ISTEAMUSERSTATS_H +#define ISTEAMUSERSTATS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" +#include "isteamremotestorage.h" + +// size limit on stat or achievement name (UTF-8 encoded) +enum { k_cchStatNameMax = 128 }; + +// maximum number of bytes for a leaderboard name (UTF-8 encoded) +enum { k_cchLeaderboardNameMax = 128 }; + +// maximum number of details int32's storable for a single leaderboard entry +enum { k_cLeaderboardDetailsMax = 64 }; + +// handle to a single leaderboard +typedef uint64 SteamLeaderboard_t; + +// handle to a set of downloaded entries in a leaderboard +typedef uint64 SteamLeaderboardEntries_t; + +// type of data request, when downloading leaderboard entries +enum ELeaderboardDataRequest +{ + k_ELeaderboardDataRequestGlobal = 0, + k_ELeaderboardDataRequestGlobalAroundUser = 1, + k_ELeaderboardDataRequestFriends = 2, + k_ELeaderboardDataRequestUsers = 3 +}; + +// the sort order of a leaderboard +enum ELeaderboardSortMethod +{ + k_ELeaderboardSortMethodNone = 0, + k_ELeaderboardSortMethodAscending = 1, // top-score is lowest number + k_ELeaderboardSortMethodDescending = 2, // top-score is highest number +}; + +// the display type (used by the Steam Community web site) for a leaderboard +enum ELeaderboardDisplayType +{ + k_ELeaderboardDisplayTypeNone = 0, + k_ELeaderboardDisplayTypeNumeric = 1, // simple numerical score + k_ELeaderboardDisplayTypeTimeSeconds = 2, // the score represents a time, in seconds + k_ELeaderboardDisplayTypeTimeMilliSeconds = 3, // the score represents a time, in milliseconds +}; + +enum ELeaderboardUploadScoreMethod +{ + k_ELeaderboardUploadScoreMethodNone = 0, + k_ELeaderboardUploadScoreMethodKeepBest = 1, // Leaderboard will keep user's best score + k_ELeaderboardUploadScoreMethodForceUpdate = 2, // Leaderboard will always replace score with specified +}; + +// a single entry in a leaderboard, as returned by GetDownloadedLeaderboardEntry() +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +struct LeaderboardEntry_t +{ + CSteamID m_steamIDUser; // user with the entry - use SteamFriends()->GetFriendPersonaName() & SteamFriends()->GetFriendAvatar() to get more info + int32 m_nGlobalRank; // [1..N], where N is the number of users with an entry in the leaderboard + int32 m_nScore; // score as set in the leaderboard + int32 m_cDetails; // number of int32 details available for this entry + UGCHandle_t m_hUGC; // handle for UGC attached to the entry +}; + +#pragma pack( pop ) + + +//----------------------------------------------------------------------------- +// Purpose: Functions for accessing stats, achievements, and leaderboard information +//----------------------------------------------------------------------------- +class ISteamUserStats +{ +public: + // Ask the server to send down this user's data and achievements for this game + virtual bool RequestCurrentStats() = 0; + + // Data accessors + virtual bool GetStat( const char *pchName, int32 *pData ) = 0; + virtual bool GetStat( const char *pchName, float *pData ) = 0; + + // Set / update data + virtual bool SetStat( const char *pchName, int32 nData ) = 0; + virtual bool SetStat( const char *pchName, float fData ) = 0; + virtual bool UpdateAvgRateStat( const char *pchName, float flCountThisSession, double dSessionLength ) = 0; + + // Achievement flag accessors + virtual bool GetAchievement( const char *pchName, bool *pbAchieved ) = 0; + virtual bool SetAchievement( const char *pchName ) = 0; + virtual bool ClearAchievement( const char *pchName ) = 0; + + // Get the achievement status, and the time it was unlocked if unlocked. + // If the return value is true, but the unlock time is zero, that means it was unlocked before Steam + // began tracking achievement unlock times (December 2009). Time is seconds since January 1, 1970. + virtual bool GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32 *punUnlockTime ) = 0; + + // Store the current data on the server, will get a callback when set + // And one callback for every new achievement + // + // If the callback has a result of k_EResultInvalidParam, one or more stats + // uploaded has been rejected, either because they broke constraints + // or were out of date. In this case the server sends back updated values. + // The stats should be re-iterated to keep in sync. + virtual bool StoreStats() = 0; + + // Achievement / GroupAchievement metadata + + // Gets the icon of the achievement, which is a handle to be used in ISteamUtils::GetImageRGBA(), or 0 if none set. + // A return value of 0 may indicate we are still fetching data, and you can wait for the UserAchievementIconFetched_t callback + // which will notify you when the bits are ready. If the callback still returns zero, then there is no image set for the + // specified achievement. + virtual int GetAchievementIcon( const char *pchName ) = 0; + + // Get general attributes for an achievement. Accepts the following keys: + // - "name" and "desc" for retrieving the localized achievement name and description (returned in UTF8) + // - "hidden" for retrieving if an achievement is hidden (returns "0" when not hidden, "1" when hidden) + virtual const char *GetAchievementDisplayAttribute( const char *pchName, const char *pchKey ) = 0; + + // Achievement progress - triggers an AchievementProgress callback, that is all. + // Calling this w/ N out of N progress will NOT set the achievement, the game must still do that. + virtual bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint32 nMaxProgress ) = 0; + + // Used for iterating achievements. In general games should not need these functions because they should have a + // list of existing achievements compiled into them + virtual uint32 GetNumAchievements() = 0; + // Get achievement name iAchievement in [0,GetNumAchievements) + virtual const char *GetAchievementName( uint32 iAchievement ) = 0; + + // Friends stats & achievements + + // downloads stats for the user + // returns a UserStatsReceived_t received when completed + // if the other user has no stats, UserStatsReceived_t.m_eResult will be set to k_EResultFail + // these stats won't be auto-updated; you'll need to call RequestUserStats() again to refresh any data + virtual SteamAPICall_t RequestUserStats( CSteamID steamIDUser ) = 0; + + // requests stat information for a user, usable after a successful call to RequestUserStats() + virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData ) = 0; + virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData ) = 0; + virtual bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved ) = 0; + // See notes for GetAchievementAndUnlockTime above + virtual bool GetUserAchievementAndUnlockTime( CSteamID steamIDUser, const char *pchName, bool *pbAchieved, uint32 *punUnlockTime ) = 0; + + // Reset stats + virtual bool ResetAllStats( bool bAchievementsToo ) = 0; + + // Leaderboard functions + + // asks the Steam back-end for a leaderboard by name, and will create it if it's not yet + // This call is asynchronous, with the result returned in LeaderboardFindResult_t + virtual SteamAPICall_t FindOrCreateLeaderboard( const char *pchLeaderboardName, ELeaderboardSortMethod eLeaderboardSortMethod, ELeaderboardDisplayType eLeaderboardDisplayType ) = 0; + + // as above, but won't create the leaderboard if it's not found + // This call is asynchronous, with the result returned in LeaderboardFindResult_t + virtual SteamAPICall_t FindLeaderboard( const char *pchLeaderboardName ) = 0; + + // returns the name of a leaderboard + virtual const char *GetLeaderboardName( SteamLeaderboard_t hSteamLeaderboard ) = 0; + + // returns the total number of entries in a leaderboard, as of the last request + virtual int GetLeaderboardEntryCount( SteamLeaderboard_t hSteamLeaderboard ) = 0; + + // returns the sort method of the leaderboard + virtual ELeaderboardSortMethod GetLeaderboardSortMethod( SteamLeaderboard_t hSteamLeaderboard ) = 0; + + // returns the display type of the leaderboard + virtual ELeaderboardDisplayType GetLeaderboardDisplayType( SteamLeaderboard_t hSteamLeaderboard ) = 0; + + // Asks the Steam back-end for a set of rows in the leaderboard. + // This call is asynchronous, with the result returned in LeaderboardScoresDownloaded_t + // LeaderboardScoresDownloaded_t will contain a handle to pull the results from GetDownloadedLeaderboardEntries() (below) + // You can ask for more entries than exist, and it will return as many as do exist. + // k_ELeaderboardDataRequestGlobal requests rows in the leaderboard from the full table, with nRangeStart & nRangeEnd in the range [1, TotalEntries] + // k_ELeaderboardDataRequestGlobalAroundUser requests rows around the current user, nRangeStart being negate + // e.g. DownloadLeaderboardEntries( hLeaderboard, k_ELeaderboardDataRequestGlobalAroundUser, -3, 3 ) will return 7 rows, 3 before the user, 3 after + // k_ELeaderboardDataRequestFriends requests all the rows for friends of the current user + virtual SteamAPICall_t DownloadLeaderboardEntries( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardDataRequest eLeaderboardDataRequest, int nRangeStart, int nRangeEnd ) = 0; + // as above, but downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers + // if a user doesn't have a leaderboard entry, they won't be included in the result + // a max of 100 users can be downloaded at a time, with only one outstanding call at a time + METHOD_DESC(Downloads leaderboard entries for an arbitrary set of users - ELeaderboardDataRequest is k_ELeaderboardDataRequestUsers) + virtual SteamAPICall_t DownloadLeaderboardEntriesForUsers( SteamLeaderboard_t hSteamLeaderboard, + ARRAY_COUNT_D(cUsers, Array of users to retrieve) CSteamID *prgUsers, int cUsers ) = 0; + + // Returns data about a single leaderboard entry + // use a for loop from 0 to LeaderboardScoresDownloaded_t::m_cEntryCount to get all the downloaded entries + // e.g. + // void OnLeaderboardScoresDownloaded( LeaderboardScoresDownloaded_t *pLeaderboardScoresDownloaded ) + // { + // for ( int index = 0; index < pLeaderboardScoresDownloaded->m_cEntryCount; index++ ) + // { + // LeaderboardEntry_t leaderboardEntry; + // int32 details[3]; // we know this is how many we've stored previously + // GetDownloadedLeaderboardEntry( pLeaderboardScoresDownloaded->m_hSteamLeaderboardEntries, index, &leaderboardEntry, details, 3 ); + // assert( leaderboardEntry.m_cDetails == 3 ); + // ... + // } + // once you've accessed all the entries, the data will be free'd, and the SteamLeaderboardEntries_t handle will become invalid + virtual bool GetDownloadedLeaderboardEntry( SteamLeaderboardEntries_t hSteamLeaderboardEntries, int index, LeaderboardEntry_t *pLeaderboardEntry, int32 *pDetails, int cDetailsMax ) = 0; + + // Uploads a user score to the Steam back-end. + // This call is asynchronous, with the result returned in LeaderboardScoreUploaded_t + // Details are extra game-defined information regarding how the user got that score + // pScoreDetails points to an array of int32's, cScoreDetailsCount is the number of int32's in the list + virtual SteamAPICall_t UploadLeaderboardScore( SteamLeaderboard_t hSteamLeaderboard, ELeaderboardUploadScoreMethod eLeaderboardUploadScoreMethod, int32 nScore, const int32 *pScoreDetails, int cScoreDetailsCount ) = 0; + + // Attaches a piece of user generated content the user's entry on a leaderboard. + // hContent is a handle to a piece of user generated content that was shared using ISteamUserRemoteStorage::FileShare(). + // This call is asynchronous, with the result returned in LeaderboardUGCSet_t. + virtual SteamAPICall_t AttachLeaderboardUGC( SteamLeaderboard_t hSteamLeaderboard, UGCHandle_t hUGC ) = 0; + + // Retrieves the number of players currently playing your game (online + offline) + // This call is asynchronous, with the result returned in NumberOfCurrentPlayers_t + virtual SteamAPICall_t GetNumberOfCurrentPlayers() = 0; + + // Requests that Steam fetch data on the percentage of players who have received each achievement + // for the game globally. + // This call is asynchronous, with the result returned in GlobalAchievementPercentagesReady_t. + virtual SteamAPICall_t RequestGlobalAchievementPercentages() = 0; + + // Get the info on the most achieved achievement for the game, returns an iterator index you can use to fetch + // the next most achieved afterwards. Will return -1 if there is no data on achievement + // percentages (ie, you haven't called RequestGlobalAchievementPercentages and waited on the callback). + virtual int GetMostAchievedAchievementInfo( char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved ) = 0; + + // Get the info on the next most achieved achievement for the game. Call this after GetMostAchievedAchievementInfo or another + // GetNextMostAchievedAchievementInfo call passing the iterator from the previous call. Returns -1 after the last + // achievement has been iterated. + virtual int GetNextMostAchievedAchievementInfo( int iIteratorPrevious, char *pchName, uint32 unNameBufLen, float *pflPercent, bool *pbAchieved ) = 0; + + // Returns the percentage of users who have achieved the specified achievement. + virtual bool GetAchievementAchievedPercent( const char *pchName, float *pflPercent ) = 0; + + // Requests global stats data, which is available for stats marked as "aggregated". + // This call is asynchronous, with the results returned in GlobalStatsReceived_t. + // nHistoryDays specifies how many days of day-by-day history to retrieve in addition + // to the overall totals. The limit is 60. + virtual SteamAPICall_t RequestGlobalStats( int nHistoryDays ) = 0; + + // Gets the lifetime totals for an aggregated stat + virtual bool GetGlobalStat( const char *pchStatName, int64 *pData ) = 0; + virtual bool GetGlobalStat( const char *pchStatName, double *pData ) = 0; + + // Gets history for an aggregated stat. pData will be filled with daily values, starting with today. + // So when called, pData[0] will be today, pData[1] will be yesterday, and pData[2] will be two days ago, + // etc. cubData is the size in bytes of the pubData buffer. Returns the number of + // elements actually set. + virtual int32 GetGlobalStatHistory( const char *pchStatName, ARRAY_COUNT(cubData) int64 *pData, uint32 cubData ) = 0; + virtual int32 GetGlobalStatHistory( const char *pchStatName, ARRAY_COUNT(cubData) double *pData, uint32 cubData ) = 0; + +#ifdef _PS3 + // Call to kick off installation of the PS3 trophies. This call is asynchronous, and the results will be returned in a PS3TrophiesInstalled_t + // callback. + virtual bool InstallPS3Trophies() = 0; + + // Returns the amount of space required at boot to install trophies. This value can be used when comparing the amount of space needed + // by the game to the available space value passed to the game at boot. The value is set during InstallPS3Trophies(). + virtual uint64 GetTrophySpaceRequiredBeforeInstall() = 0; + + // On PS3, user stats & achievement progress through Steam must be stored with the user's saved game data. + // At startup, before calling RequestCurrentStats(), you must pass the user's stats data to Steam via this method. + // If you do not have any user data, call this function with pvData = NULL and cubData = 0 + virtual bool SetUserStatsData( const void *pvData, uint32 cubData ) = 0; + + // Call to get the user's current stats data. You should retrieve this data after receiving successful UserStatsReceived_t & UserStatsStored_t + // callbacks, and store the data with the user's save game data. You can call this method with pvData = NULL and cubData = 0 to get the required + // buffer size. + virtual bool GetUserStatsData( void *pvData, uint32 cubData, uint32 *pcubWritten ) = 0; +#endif +}; + +#define STEAMUSERSTATS_INTERFACE_VERSION "STEAMUSERSTATS_INTERFACE_VERSION011" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +//----------------------------------------------------------------------------- +// Purpose: called when the latests stats and achievements have been received +// from the server +//----------------------------------------------------------------------------- +struct UserStatsReceived_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 1 }; + uint64 m_nGameID; // Game these stats are for + EResult m_eResult; // Success / error fetching the stats + CSteamID m_steamIDUser; // The user for whom the stats are retrieved for +}; + + +//----------------------------------------------------------------------------- +// Purpose: result of a request to store the user stats for a game +//----------------------------------------------------------------------------- +struct UserStatsStored_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 2 }; + uint64 m_nGameID; // Game these stats are for + EResult m_eResult; // success / error +}; + + +//----------------------------------------------------------------------------- +// Purpose: result of a request to store the achievements for a game, or an +// "indicate progress" call. If both m_nCurProgress and m_nMaxProgress +// are zero, that means the achievement has been fully unlocked. +//----------------------------------------------------------------------------- +struct UserAchievementStored_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 3 }; + + uint64 m_nGameID; // Game this is for + bool m_bGroupAchievement; // if this is a "group" achievement + char m_rgchAchievementName[k_cchStatNameMax]; // name of the achievement + uint32 m_nCurProgress; // current progress towards the achievement + uint32 m_nMaxProgress; // "out of" this many +}; + + +//----------------------------------------------------------------------------- +// Purpose: call result for finding a leaderboard, returned as a result of FindOrCreateLeaderboard() or FindLeaderboard() +// use CCallResult<> to map this async result to a member function +//----------------------------------------------------------------------------- +struct LeaderboardFindResult_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 4 }; + SteamLeaderboard_t m_hSteamLeaderboard; // handle to the leaderboard serarched for, 0 if no leaderboard found + uint8 m_bLeaderboardFound; // 0 if no leaderboard found +}; + + +//----------------------------------------------------------------------------- +// Purpose: call result indicating scores for a leaderboard have been downloaded and are ready to be retrieved, returned as a result of DownloadLeaderboardEntries() +// use CCallResult<> to map this async result to a member function +//----------------------------------------------------------------------------- +struct LeaderboardScoresDownloaded_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 5 }; + SteamLeaderboard_t m_hSteamLeaderboard; + SteamLeaderboardEntries_t m_hSteamLeaderboardEntries; // the handle to pass into GetDownloadedLeaderboardEntries() + int m_cEntryCount; // the number of entries downloaded +}; + + +//----------------------------------------------------------------------------- +// Purpose: call result indicating scores has been uploaded, returned as a result of UploadLeaderboardScore() +// use CCallResult<> to map this async result to a member function +//----------------------------------------------------------------------------- +struct LeaderboardScoreUploaded_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 6 }; + uint8 m_bSuccess; // 1 if the call was successful + SteamLeaderboard_t m_hSteamLeaderboard; // the leaderboard handle that was + int32 m_nScore; // the score that was attempted to set + uint8 m_bScoreChanged; // true if the score in the leaderboard change, false if the existing score was better + int m_nGlobalRankNew; // the new global rank of the user in this leaderboard + int m_nGlobalRankPrevious; // the previous global rank of the user in this leaderboard; 0 if the user had no existing entry in the leaderboard +}; + +struct NumberOfCurrentPlayers_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 7 }; + uint8 m_bSuccess; // 1 if the call was successful + int32 m_cPlayers; // Number of players currently playing +}; + + + +//----------------------------------------------------------------------------- +// Purpose: Callback indicating that a user's stats have been unloaded. +// Call RequestUserStats again to access stats for this user +//----------------------------------------------------------------------------- +struct UserStatsUnloaded_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 8 }; + CSteamID m_steamIDUser; // User whose stats have been unloaded +}; + + + +//----------------------------------------------------------------------------- +// Purpose: Callback indicating that an achievement icon has been fetched +//----------------------------------------------------------------------------- +struct UserAchievementIconFetched_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 9 }; + + CGameID m_nGameID; // Game this is for + char m_rgchAchievementName[k_cchStatNameMax]; // name of the achievement + bool m_bAchieved; // Is the icon for the achieved or not achieved version? + int m_nIconHandle; // Handle to the image, which can be used in SteamUtils()->GetImageRGBA(), 0 means no image is set for the achievement +}; + + +//----------------------------------------------------------------------------- +// Purpose: Callback indicating that global achievement percentages are fetched +//----------------------------------------------------------------------------- +struct GlobalAchievementPercentagesReady_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 10 }; + + uint64 m_nGameID; // Game this is for + EResult m_eResult; // Result of the operation +}; + + +//----------------------------------------------------------------------------- +// Purpose: call result indicating UGC has been uploaded, returned as a result of SetLeaderboardUGC() +//----------------------------------------------------------------------------- +struct LeaderboardUGCSet_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 11 }; + EResult m_eResult; // The result of the operation + SteamLeaderboard_t m_hSteamLeaderboard; // the leaderboard handle that was +}; + + +//----------------------------------------------------------------------------- +// Purpose: callback indicating that PS3 trophies have been installed +//----------------------------------------------------------------------------- +struct PS3TrophiesInstalled_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 }; + uint64 m_nGameID; // Game these stats are for + EResult m_eResult; // The result of the operation + uint64 m_ulRequiredDiskSpace; // If m_eResult is k_EResultDiskFull, will contain the amount of space needed to install trophies + +}; + + +//----------------------------------------------------------------------------- +// Purpose: callback indicating global stats have been received. +// Returned as a result of RequestGlobalStats() +//----------------------------------------------------------------------------- +struct GlobalStatsReceived_t +{ + enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 }; + uint64 m_nGameID; // Game global stats were requested for + EResult m_eResult; // The result of the request +}; + +#pragma pack( pop ) + + +#endif // ISTEAMUSER_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamutils.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamutils.h new file mode 100644 index 0000000..54777d3 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamutils.h @@ -0,0 +1,310 @@ +//====== Copyright � 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to utility functions in Steam +// +//============================================================================= + +#ifndef ISTEAMUTILS_H +#define ISTEAMUTILS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + + +// Steam API call failure results +enum ESteamAPICallFailure +{ + k_ESteamAPICallFailureNone = -1, // no failure + k_ESteamAPICallFailureSteamGone = 0, // the local Steam process has gone away + k_ESteamAPICallFailureNetworkFailure = 1, // the network connection to Steam has been broken, or was already broken + // SteamServersDisconnected_t callback will be sent around the same time + // SteamServersConnected_t will be sent when the client is able to talk to the Steam servers again + k_ESteamAPICallFailureInvalidHandle = 2, // the SteamAPICall_t handle passed in no longer exists + k_ESteamAPICallFailureMismatchedCallback = 3,// GetAPICallResult() was called with the wrong callback type for this API call +}; + + +// Input modes for the Big Picture gamepad text entry +enum EGamepadTextInputMode +{ + k_EGamepadTextInputModeNormal = 0, + k_EGamepadTextInputModePassword = 1 +}; + + +// Controls number of allowed lines for the Big Picture gamepad text entry +enum EGamepadTextInputLineMode +{ + k_EGamepadTextInputLineModeSingleLine = 0, + k_EGamepadTextInputLineModeMultipleLines = 1 +}; + + +// function prototype for warning message hook +#if defined( POSIX ) +#define __cdecl +#endif +extern "C" typedef void (__cdecl *SteamAPIWarningMessageHook_t)(int, const char *); + +//----------------------------------------------------------------------------- +// Purpose: interface to user independent utility functions +//----------------------------------------------------------------------------- +class ISteamUtils +{ +public: + // return the number of seconds since the user + virtual uint32 GetSecondsSinceAppActive() = 0; + virtual uint32 GetSecondsSinceComputerActive() = 0; + + // the universe this client is connecting to + virtual EUniverse GetConnectedUniverse() = 0; + + // Steam server time - in PST, number of seconds since January 1, 1970 (i.e unix time) + virtual uint32 GetServerRealTime() = 0; + + // returns the 2 digit ISO 3166-1-alpha-2 format country code this client is running in (as looked up via an IP-to-location database) + // e.g "US" or "UK". + virtual const char *GetIPCountry() = 0; + + // returns true if the image exists, and valid sizes were filled out + virtual bool GetImageSize( int iImage, uint32 *pnWidth, uint32 *pnHeight ) = 0; + + // returns true if the image exists, and the buffer was successfully filled out + // results are returned in RGBA format + // the destination buffer size should be 4 * height * width * sizeof(char) + virtual bool GetImageRGBA( int iImage, uint8 *pubDest, int nDestBufferSize ) = 0; + + // returns the IP of the reporting server for valve - currently only used in Source engine games + virtual bool GetCSERIPPort( uint32 *unIP, uint16 *usPort ) = 0; + + // return the amount of battery power left in the current system in % [0..100], 255 for being on AC power + virtual uint8 GetCurrentBatteryPower() = 0; + + // returns the appID of the current process + virtual uint32 GetAppID() = 0; + + // Sets the position where the overlay instance for the currently calling game should show notifications. + // This position is per-game and if this function is called from outside of a game context it will do nothing. + virtual void SetOverlayNotificationPosition( ENotificationPosition eNotificationPosition ) = 0; + + // API asynchronous call results + // can be used directly, but more commonly used via the callback dispatch API (see steam_api.h) + virtual bool IsAPICallCompleted( SteamAPICall_t hSteamAPICall, bool *pbFailed ) = 0; + virtual ESteamAPICallFailure GetAPICallFailureReason( SteamAPICall_t hSteamAPICall ) = 0; + virtual bool GetAPICallResult( SteamAPICall_t hSteamAPICall, void *pCallback, int cubCallback, int iCallbackExpected, bool *pbFailed ) = 0; + + // this needs to be called every frame to process matchmaking results + // redundant if you're already calling SteamAPI_RunCallbacks() + virtual void RunFrame() = 0; + + // returns the number of IPC calls made since the last time this function was called + // Used for perf debugging so you can understand how many IPC calls your game makes per frame + // Every IPC call is at minimum a thread context switch if not a process one so you want to rate + // control how often you do them. + virtual uint32 GetIPCCallCount() = 0; + + // API warning handling + // 'int' is the severity; 0 for msg, 1 for warning + // 'const char *' is the text of the message + // callbacks will occur directly after the API function is called that generated the warning or message + virtual void SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction ) = 0; + + // Returns true if the overlay is running & the user can access it. The overlay process could take a few seconds to + // start & hook the game process, so this function will initially return false while the overlay is loading. + virtual bool IsOverlayEnabled() = 0; + + // Normally this call is unneeded if your game has a constantly running frame loop that calls the + // D3D Present API, or OGL SwapBuffers API every frame. + // + // However, if you have a game that only refreshes the screen on an event driven basis then that can break + // the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also + // need to Present() to the screen any time an even needing a notification happens or when the overlay is + // brought up over the game by a user. You can use this API to ask the overlay if it currently need a present + // in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you + // refresh the screen with Present or SwapBuffers to allow the overlay to do it's work. + virtual bool BOverlayNeedsPresent() = 0; + +#ifndef _PS3 + // Asynchronous call to check if an executable file has been signed using the public key set on the signing tab + // of the partner site, for example to refuse to load modified executable files. + // The result is returned in CheckFileSignature_t. + // k_ECheckFileSignatureNoSignaturesFoundForThisApp - This app has not been configured on the signing tab of the partner site to enable this function. + // k_ECheckFileSignatureNoSignaturesFoundForThisFile - This file is not listed on the signing tab for the partner site. + // k_ECheckFileSignatureFileNotFound - The file does not exist on disk. + // k_ECheckFileSignatureInvalidSignature - The file exists, and the signing tab has been set for this file, but the file is either not signed or the signature does not match. + // k_ECheckFileSignatureValidSignature - The file is signed and the signature is valid. + virtual SteamAPICall_t CheckFileSignature( const char *szFileName ) = 0; +#endif + +#ifdef _PS3 + virtual void PostPS3SysutilCallback( uint64_t status, uint64_t param, void* userdata ) = 0; + virtual bool BIsReadyToShutdown() = 0; + virtual bool BIsPSNOnline() = 0; + + // Call this with localized strings for the language the game is running in, otherwise default english + // strings will be used by Steam. + virtual void SetPSNGameBootInviteStrings( const char *pchSubject, const char *pchBody ) = 0; +#endif + + // Activates the Big Picture text input dialog which only supports gamepad input + virtual bool ShowGamepadTextInput( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32 unCharMax, const char *pchExistingText ) = 0; + + // Returns previously entered text & length + virtual uint32 GetEnteredGamepadTextLength() = 0; + virtual bool GetEnteredGamepadTextInput( char *pchText, uint32 cchText ) = 0; + + // returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases + virtual const char *GetSteamUILanguage() = 0; + + // returns true if Steam itself is running in VR mode + virtual bool IsSteamRunningInVR() = 0; + + // Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition. + virtual void SetOverlayNotificationInset( int nHorizontalInset, int nVerticalInset ) = 0; +}; + +#define STEAMUTILS_INTERFACE_VERSION "SteamUtils007" + + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + +//----------------------------------------------------------------------------- +// Purpose: The country of the user changed +//----------------------------------------------------------------------------- +struct IPCountry_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 1 }; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Fired when running on a laptop and less than 10 minutes of battery is left, fires then every minute +//----------------------------------------------------------------------------- +struct LowBatteryPower_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 2 }; + uint8 m_nMinutesBatteryLeft; +}; + + +//----------------------------------------------------------------------------- +// Purpose: called when a SteamAsyncCall_t has completed (or failed) +//----------------------------------------------------------------------------- +struct SteamAPICallCompleted_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 3 }; + SteamAPICall_t m_hAsyncCall; +}; + + +//----------------------------------------------------------------------------- +// called when Steam wants to shutdown +//----------------------------------------------------------------------------- +struct SteamShutdown_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 4 }; +}; + +//----------------------------------------------------------------------------- +// results for CheckFileSignature +//----------------------------------------------------------------------------- +enum ECheckFileSignature +{ + k_ECheckFileSignatureInvalidSignature = 0, + k_ECheckFileSignatureValidSignature = 1, + k_ECheckFileSignatureFileNotFound = 2, + k_ECheckFileSignatureNoSignaturesFoundForThisApp = 3, + k_ECheckFileSignatureNoSignaturesFoundForThisFile = 4, +}; + +//----------------------------------------------------------------------------- +// callback for CheckFileSignature +//----------------------------------------------------------------------------- +struct CheckFileSignature_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 5 }; + ECheckFileSignature m_eCheckFileSignature; +}; + +#ifdef _PS3 +//----------------------------------------------------------------------------- +// callback for NetCtlNetStartDialog finishing on PS3 +//----------------------------------------------------------------------------- +struct NetStartDialogFinished_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 6 }; +}; + +//----------------------------------------------------------------------------- +// callback for NetCtlNetStartDialog unloaded on PS3 +//----------------------------------------------------------------------------- +struct NetStartDialogUnloaded_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 7 }; +}; + +//----------------------------------------------------------------------------- +// callback for system menu closing on PS3 - should trigger resyncronizing friends list, etc. +//----------------------------------------------------------------------------- +struct PS3SystemMenuClosed_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 8 }; +}; + +//----------------------------------------------------------------------------- +// callback for NP message being selected by user on PS3 - should trigger handling of message if it's a lobby invite, etc. +//----------------------------------------------------------------------------- +struct PS3NPMessageSelected_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 9 }; + uint32 dataid; +}; + +//----------------------------------------------------------------------------- +// callback for when the PS3 keyboard dialog closes +//----------------------------------------------------------------------------- +struct PS3KeyboardDialogFinished_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 10 }; +}; + +// k_iSteamUtilsCallbacks + 11 is taken + +//----------------------------------------------------------------------------- +// callback for PSN status changing on PS3 +//----------------------------------------------------------------------------- +struct PS3PSNStatusChange_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 12 }; + bool m_bPSNOnline; +}; + +#endif + +// k_iSteamUtilsCallbacks + 13 is taken + + +//----------------------------------------------------------------------------- +// Big Picture gamepad text input has been closed +//----------------------------------------------------------------------------- +struct GamepadTextInputDismissed_t +{ + enum { k_iCallback = k_iSteamUtilsCallbacks + 14 }; + bool m_bSubmitted; // true if user entered & accepted text (Call ISteamUtils::GetEnteredGamepadTextInput() for text), false if canceled input + uint32 m_unSubmittedText; +}; + +// k_iSteamUtilsCallbacks + 15 is taken + +#pragma pack( pop ) + +#endif // ISTEAMUTILS_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamvideo.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamvideo.h new file mode 100644 index 0000000..6893f0b --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/isteamvideo.h @@ -0,0 +1,60 @@ +//====== Copyright © 1996-2014 Valve Corporation, All rights reserved. ======= +// +// Purpose: interface to Steam Video +// +//============================================================================= + +#ifndef ISTEAMVIDEO_H +#define ISTEAMVIDEO_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" + +// callbacks +#if defined( VALVE_CALLBACK_PACK_SMALL ) +#pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) +#pragma pack( push, 8 ) +#else +#error isteamclient.h must be included +#endif + + + + +//----------------------------------------------------------------------------- +// Purpose: Steam Video API +//----------------------------------------------------------------------------- +class ISteamVideo +{ +public: + + // Get a URL suitable for streaming the given Video app ID's video + virtual void GetVideoURL( AppId_t unVideoAppID ) = 0; + + // returns true if user is uploading a live broadcast + virtual bool IsBroadcasting( int *pnNumViewers ) = 0; +}; + +#define STEAMVIDEO_INTERFACE_VERSION "STEAMVIDEO_INTERFACE_V001" + +DEFINE_CALLBACK( BroadcastUploadStart_t, k_iClientVideoCallbacks + 4 ) +END_DEFINE_CALLBACK_0() + +DEFINE_CALLBACK( BroadcastUploadStop_t, k_iClientVideoCallbacks + 5 ) + CALLBACK_MEMBER( 0, EBroadcastUploadResult, m_eResult ) +END_DEFINE_CALLBACK_1() + +DEFINE_CALLBACK( GetVideoURLResult_t, k_iClientVideoCallbacks + 11 ) + CALLBACK_MEMBER( 0, EResult, m_eResult ) + CALLBACK_MEMBER( 1, AppId_t, m_unVideoAppID ) + CALLBACK_MEMBER( 2, char, m_rgchURL[256] ) +END_DEFINE_CALLBACK_1() + + +#pragma pack( pop ) + + +#endif // ISTEAMVIDEO_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/osx32/libsdkencryptedappticket.dylib b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/osx32/libsdkencryptedappticket.dylib new file mode 100644 index 0000000..7c5c2f3 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/osx32/libsdkencryptedappticket.dylib differ diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win32/sdkencryptedappticket.dll b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win32/sdkencryptedappticket.dll new file mode 100644 index 0000000..f855f9f Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win32/sdkencryptedappticket.dll differ diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win32/sdkencryptedappticket.lib b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win32/sdkencryptedappticket.lib new file mode 100644 index 0000000..67a8b41 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win32/sdkencryptedappticket.lib differ diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win64/sdkencryptedappticket64.dll b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win64/sdkencryptedappticket64.dll new file mode 100644 index 0000000..c58fea3 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win64/sdkencryptedappticket64.dll differ diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win64/sdkencryptedappticket64.lib b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win64/sdkencryptedappticket64.lib new file mode 100644 index 0000000..3829361 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/public/steam/lib/win64/sdkencryptedappticket64.lib differ diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/matchmakingtypes.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/matchmakingtypes.h new file mode 100644 index 0000000..e52cfc6 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/matchmakingtypes.h @@ -0,0 +1,251 @@ +//========= Copyright � 1996-2008, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef MATCHMAKINGTYPES_H +#define MATCHMAKINGTYPES_H + +#ifdef _WIN32 +#pragma once +#endif + +#ifdef POSIX +#ifndef _snprintf +#define _snprintf snprintf +#endif +#endif + +#include +#include + +// +// Max size (in bytes of UTF-8 data, not in characters) of server fields, including null terminator. +// WARNING: These cannot be changed easily, without breaking clients using old interfaces. +// +const int k_cbMaxGameServerGameDir = 32; +const int k_cbMaxGameServerMapName = 32; +const int k_cbMaxGameServerGameDescription = 64; +const int k_cbMaxGameServerName = 64; +const int k_cbMaxGameServerTags = 128; +const int k_cbMaxGameServerGameData = 2048; + +/// Store key/value pair used in matchmaking queries. +/// +/// Actually, the name Key/Value is a bit misleading. The "key" is better +/// understood as "filter operation code" and the "value" is the operand to this +/// filter operation. The meaning of the operand depends upon the filter. +struct MatchMakingKeyValuePair_t +{ + MatchMakingKeyValuePair_t() { m_szKey[0] = m_szValue[0] = 0; } + MatchMakingKeyValuePair_t( const char *pchKey, const char *pchValue ) + { + strncpy( m_szKey, pchKey, sizeof(m_szKey) ); // this is a public header, use basic c library string funcs only! + m_szKey[ sizeof( m_szKey ) - 1 ] = '\0'; + strncpy( m_szValue, pchValue, sizeof(m_szValue) ); + m_szValue[ sizeof( m_szValue ) - 1 ] = '\0'; + } + char m_szKey[ 256 ]; + char m_szValue[ 256 ]; +}; + + +enum EMatchMakingServerResponse +{ + eServerResponded = 0, + eServerFailedToRespond, + eNoServersListedOnMasterServer // for the Internet query type, returned in response callback if no servers of this type match +}; + +// servernetadr_t is all the addressing info the serverbrowser needs to know about a game server, +// namely: its IP, its connection port, and its query port. +class servernetadr_t +{ +public: + + servernetadr_t() : m_usConnectionPort( 0 ), m_usQueryPort( 0 ), m_unIP( 0 ) {} + + void Init( unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort ); +#ifdef NETADR_H + netadr_t GetIPAndQueryPort(); +#endif + + // Access the query port. + uint16 GetQueryPort() const; + void SetQueryPort( uint16 usPort ); + + // Access the connection port. + uint16 GetConnectionPort() const; + void SetConnectionPort( uint16 usPort ); + + // Access the IP + uint32 GetIP() const; + void SetIP( uint32 ); + + // This gets the 'a.b.c.d:port' string with the connection port (instead of the query port). + const char *GetConnectionAddressString() const; + const char *GetQueryAddressString() const; + + // Comparison operators and functions. + bool operator<(const servernetadr_t &netadr) const; + void operator=( const servernetadr_t &that ) + { + m_usConnectionPort = that.m_usConnectionPort; + m_usQueryPort = that.m_usQueryPort; + m_unIP = that.m_unIP; + } + + +private: + const char *ToString( uint32 unIP, uint16 usPort ) const; + uint16 m_usConnectionPort; // (in HOST byte order) + uint16 m_usQueryPort; + uint32 m_unIP; +}; + + +inline void servernetadr_t::Init( unsigned int ip, uint16 usQueryPort, uint16 usConnectionPort ) +{ + m_unIP = ip; + m_usQueryPort = usQueryPort; + m_usConnectionPort = usConnectionPort; +} + +#ifdef NETADR_H +inline netadr_t servernetadr_t::GetIPAndQueryPort() +{ + return netadr_t( m_unIP, m_usQueryPort ); +} +#endif + +inline uint16 servernetadr_t::GetQueryPort() const +{ + return m_usQueryPort; +} + +inline void servernetadr_t::SetQueryPort( uint16 usPort ) +{ + m_usQueryPort = usPort; +} + +inline uint16 servernetadr_t::GetConnectionPort() const +{ + return m_usConnectionPort; +} + +inline void servernetadr_t::SetConnectionPort( uint16 usPort ) +{ + m_usConnectionPort = usPort; +} + +inline uint32 servernetadr_t::GetIP() const +{ + return m_unIP; +} + +inline void servernetadr_t::SetIP( uint32 unIP ) +{ + m_unIP = unIP; +} + +inline const char *servernetadr_t::ToString( uint32 unIP, uint16 usPort ) const +{ + static char s[4][64]; + static int nBuf = 0; + unsigned char *ipByte = (unsigned char *)&unIP; +#ifdef VALVE_BIG_ENDIAN + _snprintf (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[0]), (int)(ipByte[1]), (int)(ipByte[2]), (int)(ipByte[3]), usPort ); +#else + _snprintf (s[nBuf], sizeof( s[nBuf] ), "%u.%u.%u.%u:%i", (int)(ipByte[3]), (int)(ipByte[2]), (int)(ipByte[1]), (int)(ipByte[0]), usPort ); +#endif + const char *pchRet = s[nBuf]; + ++nBuf; + nBuf %= ( (sizeof(s)/sizeof(s[0])) ); + return pchRet; +} + +inline const char* servernetadr_t::GetConnectionAddressString() const +{ + return ToString( m_unIP, m_usConnectionPort ); +} + +inline const char* servernetadr_t::GetQueryAddressString() const +{ + return ToString( m_unIP, m_usQueryPort ); +} + +inline bool servernetadr_t::operator<(const servernetadr_t &netadr) const +{ + return ( m_unIP < netadr.m_unIP ) || ( m_unIP == netadr.m_unIP && m_usQueryPort < netadr.m_usQueryPort ); +} + +//----------------------------------------------------------------------------- +// Purpose: Data describing a single server +//----------------------------------------------------------------------------- +class gameserveritem_t +{ +public: + gameserveritem_t(); + + const char* GetName() const; + void SetName( const char *pName ); + +public: + servernetadr_t m_NetAdr; ///< IP/Query Port/Connection Port for this server + int m_nPing; ///< current ping time in milliseconds + bool m_bHadSuccessfulResponse; ///< server has responded successfully in the past + bool m_bDoNotRefresh; ///< server is marked as not responding and should no longer be refreshed + char m_szGameDir[k_cbMaxGameServerGameDir]; ///< current game directory + char m_szMap[k_cbMaxGameServerMapName]; ///< current map + char m_szGameDescription[k_cbMaxGameServerGameDescription]; ///< game description + uint32 m_nAppID; ///< Steam App ID of this server + int m_nPlayers; ///< total number of players currently on the server. INCLUDES BOTS!! + int m_nMaxPlayers; ///< Maximum players that can join this server + int m_nBotPlayers; ///< Number of bots (i.e simulated players) on this server + bool m_bPassword; ///< true if this server needs a password to join + bool m_bSecure; ///< Is this server protected by VAC + uint32 m_ulTimeLastPlayed; ///< time (in unix time) when this server was last played on (for favorite/history servers) + int m_nServerVersion; ///< server version as reported to Steam + +private: + + /// Game server name + char m_szServerName[k_cbMaxGameServerName]; + + // For data added after SteamMatchMaking001 add it here +public: + /// the tags this server exposes + char m_szGameTags[k_cbMaxGameServerTags]; + + /// steamID of the game server - invalid if it's doesn't have one (old server, or not connected to Steam) + CSteamID m_steamID; +}; + + +inline gameserveritem_t::gameserveritem_t() +{ + m_szGameDir[0] = m_szMap[0] = m_szGameDescription[0] = m_szServerName[0] = 0; + m_bHadSuccessfulResponse = m_bDoNotRefresh = m_bPassword = m_bSecure = false; + m_nPing = m_nAppID = m_nPlayers = m_nMaxPlayers = m_nBotPlayers = m_ulTimeLastPlayed = m_nServerVersion = 0; + m_szGameTags[0] = 0; +} + +inline const char* gameserveritem_t::GetName() const +{ + // Use the IP address as the name if nothing is set yet. + if ( m_szServerName[0] == 0 ) + return m_NetAdr.GetConnectionAddressString(); + else + return m_szServerName; +} + +inline void gameserveritem_t::SetName( const char *pName ) +{ + strncpy( m_szServerName, pName, sizeof( m_szServerName ) ); + m_szServerName[ sizeof( m_szServerName ) - 1 ] = '\0'; +} + + +#endif // MATCHMAKINGTYPES_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steam_api.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steam_api.h new file mode 100644 index 0000000..f387250 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steam_api.h @@ -0,0 +1,650 @@ +//====== Copyright 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +#ifndef STEAM_API_H +#define STEAM_API_H +#ifdef _WIN32 +#pragma once +#endif + +#include "isteamclient.h" +#include "isteamuser.h" +#include "isteamfriends.h" +#include "isteamutils.h" +#include "isteammatchmaking.h" +#include "isteamuserstats.h" +#include "isteamapps.h" +#include "isteamnetworking.h" +#include "isteamremotestorage.h" +#include "isteamscreenshots.h" +#include "isteammusic.h" +#include "isteammusicremote.h" +#include "isteamhttp.h" +#include "isteamunifiedmessages.h" +#include "isteamcontroller.h" +#include "isteamugc.h" +#include "isteamapplist.h" +#include "isteamhtmlsurface.h" +#include "isteaminventory.h" +#include "isteamvideo.h" + +#if defined( _PS3 ) +#include "steamps3params.h" +#endif + +// Steam API export macro +#if defined( _WIN32 ) && !defined( _X360 ) + #if defined( STEAM_API_EXPORTS ) + #define S_API extern "C" __declspec( dllexport ) + #elif defined( STEAM_API_NODLL ) + #define S_API extern "C" + #else + #define S_API extern "C" __declspec( dllimport ) + #endif // STEAM_API_EXPORTS +#elif defined( GNUC ) + #if defined( STEAM_API_EXPORTS ) + #define S_API extern "C" __attribute__ ((visibility("default"))) + #else + #define S_API extern "C" + #endif // STEAM_API_EXPORTS +#else // !WIN32 + #if defined( STEAM_API_EXPORTS ) + #define S_API extern "C" + #else + #define S_API extern "C" + #endif // STEAM_API_EXPORTS +#endif + +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// Steam API setup & shutdown +// +// These functions manage loading, initializing and shutdown of the steamclient.dll +// +//----------------------------------------------------------------------------------------------------------------------------------------------------------// + +// S_API void SteamAPI_Init(); (see below) +S_API void S_CALLTYPE SteamAPI_Shutdown(); + +// checks if a local Steam client is running +S_API bool S_CALLTYPE SteamAPI_IsSteamRunning(); + +// Detects if your executable was launched through the Steam client, and restarts your game through +// the client if necessary. The Steam client will be started if it is not running. +// +// Returns: true if your executable was NOT launched through the Steam client. This function will +// then start your application through the client. Your current process should exit. +// +// false if your executable was started through the Steam client or a steam_appid.txt file +// is present in your game's directory (for development). Your current process should continue. +// +// NOTE: This function should be used only if you are using CEG or not using Steam's DRM. Once applied +// to your executable, Steam's DRM will handle restarting through Steam if necessary. +S_API bool S_CALLTYPE SteamAPI_RestartAppIfNecessary( uint32 unOwnAppID ); + +// crash dump recording functions +S_API void S_CALLTYPE SteamAPI_WriteMiniDump( uint32 uStructuredExceptionCode, void* pvExceptionInfo, uint32 uBuildID ); +S_API void S_CALLTYPE SteamAPI_SetMiniDumpComment( const char *pchMsg ); + +// interface pointers, configured by SteamAPI_Init() +S_API ISteamClient *S_CALLTYPE SteamClient(); + + +// +// VERSION_SAFE_STEAM_API_INTERFACES is usually not necessary, but it provides safety against releasing +// new steam_api.dll's without recompiling/rereleasing modules that use it. +// +// If you use VERSION_SAFE_STEAM_API_INTERFACES, then you should call SteamAPI_InitSafe(). Also, to get the +// Steam interfaces, you must create and Init() a CSteamAPIContext (below) and use the interfaces in there. +// +// If you don't use VERSION_SAFE_STEAM_API_INTERFACES, then you can use SteamAPI_Init() and the SteamXXXX() +// functions below to get at the Steam interfaces. +// +#ifdef VERSION_SAFE_STEAM_API_INTERFACES +S_API bool S_CALLTYPE SteamAPI_InitSafe(); +#else + +#if defined(_PS3) +S_API bool S_CALLTYPE SteamAPI_Init( SteamPS3Params_t *pParams ); +#else +S_API bool S_CALLTYPE SteamAPI_Init(); +#endif + +S_API ISteamUser *S_CALLTYPE SteamUser(); +S_API ISteamFriends *S_CALLTYPE SteamFriends(); +S_API ISteamUtils *S_CALLTYPE SteamUtils(); +S_API ISteamMatchmaking *S_CALLTYPE SteamMatchmaking(); +S_API ISteamUserStats *S_CALLTYPE SteamUserStats(); +S_API ISteamApps *S_CALLTYPE SteamApps(); +S_API ISteamNetworking *S_CALLTYPE SteamNetworking(); +S_API ISteamMatchmakingServers *S_CALLTYPE SteamMatchmakingServers(); +S_API ISteamRemoteStorage *S_CALLTYPE SteamRemoteStorage(); +S_API ISteamScreenshots *S_CALLTYPE SteamScreenshots(); +S_API ISteamHTTP *S_CALLTYPE SteamHTTP(); +S_API ISteamUnifiedMessages *S_CALLTYPE SteamUnifiedMessages(); +S_API ISteamController *S_CALLTYPE SteamController(); +S_API ISteamUGC *S_CALLTYPE SteamUGC(); +S_API ISteamAppList *S_CALLTYPE SteamAppList(); +S_API ISteamMusic *S_CALLTYPE SteamMusic(); +S_API ISteamMusicRemote *S_CALLTYPE SteamMusicRemote(); +S_API ISteamHTMLSurface *S_CALLTYPE SteamHTMLSurface(); +S_API ISteamInventory *S_CALLTYPE SteamInventory(); +S_API ISteamVideo *S_CALLTYPE SteamVideo(); +#ifdef _PS3 +S_API ISteamPS3OverlayRender *S_CALLTYPE SteamPS3OverlayRender(); +#endif +#endif // VERSION_SAFE_STEAM_API_INTERFACES + + +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// steam callback and call-result helpers +// +// The following macros and classes are used to register your application for +// callbacks and call-results, which are delivered in a predictable manner. +// +// STEAM_CALLBACK macros are meant for use inside of a C++ class definition. +// They map a Steam notification callback directly to a class member function +// which is automatically prototyped as "void func( callback_type *pParam )". +// +// CCallResult is used with specific Steam APIs that return "result handles". +// The handle can be passed to a CCallResult object's Set function, along with +// an object pointer and member-function pointer. The member function will +// be executed once the results of the Steam API call are available. +// +// CCallback and CCallbackManual classes can be used instead of STEAM_CALLBACK +// macros if you require finer control over registration and unregistration. +// +// Callbacks and call-results are queued automatically and are only +// delivered/executed when your application calls SteamAPI_RunCallbacks(). +//----------------------------------------------------------------------------------------------------------------------------------------------------------// + +S_API void S_CALLTYPE SteamAPI_RunCallbacks(); + + + +// Declares a callback member function plus a helper member variable which +// registers the callback on object creation and unregisters on destruction. +// The optional fourth 'var' param exists only for backwards-compatibility +// and can be ignored. +#define STEAM_CALLBACK( thisclass, func, .../*callback_type, [deprecated] var*/ ) \ + _STEAM_CALLBACK_SELECT( ( __VA_ARGS__, 4, 3 ), ( /**/, thisclass, func, __VA_ARGS__ ) ) + +// Declares a callback function and a named CCallbackManual variable which +// has Register and Unregister functions instead of automatic registration. +#define STEAM_CALLBACK_MANUAL( thisclass, func, callback_type, var ) \ + CCallbackManual< thisclass, callback_type > var; void func( callback_type *pParam ) + + +// Internal functions used by the utility CCallback objects to receive callbacks +S_API void S_CALLTYPE SteamAPI_RegisterCallback( class CCallbackBase *pCallback, int iCallback ); +S_API void S_CALLTYPE SteamAPI_UnregisterCallback( class CCallbackBase *pCallback ); +// Internal functions used by the utility CCallResult objects to receive async call results +S_API void S_CALLTYPE SteamAPI_RegisterCallResult( class CCallbackBase *pCallback, SteamAPICall_t hAPICall ); +S_API void S_CALLTYPE SteamAPI_UnregisterCallResult( class CCallbackBase *pCallback, SteamAPICall_t hAPICall ); + + +//----------------------------------------------------------------------------- +// Purpose: base for callbacks and call results - internal implementation detail +//----------------------------------------------------------------------------- +class CCallbackBase +{ +public: + CCallbackBase() { m_nCallbackFlags = 0; m_iCallback = 0; } + // don't add a virtual destructor because we export this binary interface across dll's + virtual void Run( void *pvParam ) = 0; + virtual void Run( void *pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall ) = 0; + int GetICallback() { return m_iCallback; } + virtual int GetCallbackSizeBytes() = 0; + +protected: + enum { k_ECallbackFlagsRegistered = 0x01, k_ECallbackFlagsGameServer = 0x02 }; + uint8 m_nCallbackFlags; + int m_iCallback; + friend class CCallbackMgr; + +private: + CCallbackBase( const CCallbackBase& ); + CCallbackBase& operator=( const CCallbackBase& ); +}; + +//----------------------------------------------------------------------------- +// Purpose: templated base for callbacks - internal implementation detail +//----------------------------------------------------------------------------- +template< int sizeof_P > +class CCallbackImpl : protected CCallbackBase +{ +public: + ~CCallbackImpl() { if ( m_nCallbackFlags & k_ECallbackFlagsRegistered ) SteamAPI_UnregisterCallback( this ); } + void SetGameserverFlag() { m_nCallbackFlags |= k_ECallbackFlagsGameServer; } + +protected: + virtual void Run( void *pvParam ) = 0; + virtual void Run( void *pvParam, bool /*bIOFailure*/, SteamAPICall_t /*hSteamAPICall*/ ) { Run( pvParam ); } + virtual int GetCallbackSizeBytes() { return sizeof_P; } +}; + + +//----------------------------------------------------------------------------- +// Purpose: maps a steam async call result to a class member function +// template params: T = local class, P = parameter struct +//----------------------------------------------------------------------------- +template< class T, class P > +class CCallResult : private CCallbackBase +{ +public: + typedef void (T::*func_t)( P*, bool ); + + CCallResult() + { + m_hAPICall = k_uAPICallInvalid; + m_pObj = NULL; + m_Func = NULL; + m_iCallback = P::k_iCallback; + } + + void Set( SteamAPICall_t hAPICall, T *p, func_t func ) + { + if ( m_hAPICall ) + SteamAPI_UnregisterCallResult( this, m_hAPICall ); + + m_hAPICall = hAPICall; + m_pObj = p; + m_Func = func; + + if ( hAPICall ) + SteamAPI_RegisterCallResult( this, hAPICall ); + } + + bool IsActive() const + { + return ( m_hAPICall != k_uAPICallInvalid ); + } + + void Cancel() + { + if ( m_hAPICall != k_uAPICallInvalid ) + { + SteamAPI_UnregisterCallResult( this, m_hAPICall ); + m_hAPICall = k_uAPICallInvalid; + } + + } + + ~CCallResult() + { + Cancel(); + } + + void SetGameserverFlag() { m_nCallbackFlags |= k_ECallbackFlagsGameServer; } +private: + virtual void Run( void *pvParam ) + { + m_hAPICall = k_uAPICallInvalid; // caller unregisters for us + (m_pObj->*m_Func)( (P *)pvParam, false ); + } + virtual void Run( void *pvParam, bool bIOFailure, SteamAPICall_t hSteamAPICall ) + { + if ( hSteamAPICall == m_hAPICall ) + { + m_hAPICall = k_uAPICallInvalid; // caller unregisters for us + (m_pObj->*m_Func)( (P *)pvParam, bIOFailure ); + } + } + virtual int GetCallbackSizeBytes() + { + return sizeof( P ); + } + + SteamAPICall_t m_hAPICall; + T *m_pObj; + func_t m_Func; +}; + + + +//----------------------------------------------------------------------------- +// Purpose: maps a steam callback to a class member function +// template params: T = local class, P = parameter struct, +// bGameserver = listen for gameserver callbacks instead of client callbacks +//----------------------------------------------------------------------------- +template< class T, class P, bool bGameserver = false > +class CCallback : public CCallbackImpl< sizeof( P ) > +{ +public: + typedef void (T::*func_t)(P*); + + // NOTE: If you can't provide the correct parameters at construction time, you should + // use the CCallbackManual callback object (STEAM_CALLBACK_MANUAL macro) instead. + CCallback( T *pObj, func_t func ) : m_pObj( NULL ), m_Func( NULL ) + { + if ( bGameserver ) + { + this->SetGameserverFlag(); + } + Register( pObj, func ); + } + + // manual registration of the callback + void Register( T *pObj, func_t func ) + { + if ( !pObj || !func ) + return; + + if ( this->m_nCallbackFlags & CCallbackBase::k_ECallbackFlagsRegistered ) + Unregister(); + + m_pObj = pObj; + m_Func = func; + // SteamAPI_RegisterCallback sets k_ECallbackFlagsRegistered + SteamAPI_RegisterCallback( this, P::k_iCallback ); + } + + void Unregister() + { + // SteamAPI_UnregisterCallback removes k_ECallbackFlagsRegistered + SteamAPI_UnregisterCallback( this ); + } + +protected: + virtual void Run( void *pvParam ) + { + (m_pObj->*m_Func)( (P *)pvParam ); + } + + T *m_pObj; + func_t m_Func; +}; + + +//----------------------------------------------------------------------------- +// Purpose: subclass of CCallback which allows default-construction in +// an unregistered state; you must call Register manually +//----------------------------------------------------------------------------- +template< class T, class P, bool bGameServer = false > +class CCallbackManual : public CCallback< T, P, bGameServer > +{ +public: + CCallbackManual() : CCallback< T, P, bGameServer >( NULL, NULL ) {} + + // Inherits public Register and Unregister functions from base class +}; + + + +//----------------------------------------------------------------------------- +// The following macros are implementation details, not intended for public use +//----------------------------------------------------------------------------- +#define _STEAM_CALLBACK_AUTO_HOOK( thisclass, func, param ) +#define _STEAM_CALLBACK_HELPER( _1, _2, SELECTED, ... ) _STEAM_CALLBACK_##SELECTED +#define _STEAM_CALLBACK_SELECT( X, Y ) _STEAM_CALLBACK_HELPER X Y +#define _STEAM_CALLBACK_3( extra_code, thisclass, func, param ) \ + struct CCallbackInternal_ ## func : private CCallbackImpl< sizeof( param ) > { \ + CCallbackInternal_ ## func () { extra_code SteamAPI_RegisterCallback( this, param::k_iCallback ); } \ + CCallbackInternal_ ## func ( const CCallbackInternal_ ## func & ) { extra_code SteamAPI_RegisterCallback( this, param::k_iCallback ); } \ + CCallbackInternal_ ## func & operator=( const CCallbackInternal_ ## func & ) { return *this; } \ + private: virtual void Run( void *pvParam ) { _STEAM_CALLBACK_AUTO_HOOK( thisclass, func, param ) \ + thisclass *pOuter = reinterpret_cast( reinterpret_cast(this) - offsetof( thisclass, m_steamcallback_ ## func ) ); \ + pOuter->func( reinterpret_cast( pvParam ) ); \ + } \ + } m_steamcallback_ ## func ; void func( param *pParam ) +#define _STEAM_CALLBACK_4( _, thisclass, func, param, var ) \ + CCallback< thisclass, param > var; void func( param *pParam ) + + +#ifdef _WIN32 +// disable this warning; this pattern need for steam callback registration +#pragma warning( disable: 4355 ) // 'this' : used in base member initializer list +#endif + + +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// steamclient.dll private wrapper functions +// +// The following functions are part of abstracting API access to the steamclient.dll, but should only be used in very specific cases +//----------------------------------------------------------------------------------------------------------------------------------------------------------// + +// pumps out all the steam messages, calling the register callback +S_API void Steam_RunCallbacks( HSteamPipe hSteamPipe, bool bGameServerCallbacks ); + +// register the callback funcs to use to interact with the steam dll +S_API void Steam_RegisterInterfaceFuncs( void *hModule ); + +// returns the HSteamUser of the last user to dispatch a callback +S_API HSteamUser Steam_GetHSteamUserCurrent(); + +// returns the filename path of the current running Steam process, used if you need to load an explicit steam dll by name +S_API const char *SteamAPI_GetSteamInstallPath(); + +// returns the pipe we are communicating to Steam with +S_API HSteamPipe SteamAPI_GetHSteamPipe(); + +// sets whether or not Steam_RunCallbacks() should do a try {} catch (...) {} around calls to issuing callbacks +S_API void SteamAPI_SetTryCatchCallbacks( bool bTryCatchCallbacks ); + +// backwards compat export, passes through to SteamAPI_ variants +S_API HSteamPipe GetHSteamPipe(); +S_API HSteamUser GetHSteamUser(); + +#ifdef VERSION_SAFE_STEAM_API_INTERFACES +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// VERSION_SAFE_STEAM_API_INTERFACES uses CSteamAPIContext to provide interfaces to each module in a way that +// lets them each specify the interface versions they are compiled with. +// +// It's important that these stay inlined in the header so the calling module specifies the interface versions +// for whatever Steam API version it has. +//----------------------------------------------------------------------------------------------------------------------------------------------------------// + +S_API HSteamUser SteamAPI_GetHSteamUser(); + +class CSteamAPIContext +{ +public: + CSteamAPIContext(); + void Clear(); + + bool Init(); + + ISteamUser* SteamUser() { return m_pSteamUser; } + ISteamFriends* SteamFriends() { return m_pSteamFriends; } + ISteamUtils* SteamUtils() { return m_pSteamUtils; } + ISteamMatchmaking* SteamMatchmaking() { return m_pSteamMatchmaking; } + ISteamUserStats* SteamUserStats() { return m_pSteamUserStats; } + ISteamApps* SteamApps() { return m_pSteamApps; } + ISteamMatchmakingServers* SteamMatchmakingServers() { return m_pSteamMatchmakingServers; } + ISteamNetworking* SteamNetworking() { return m_pSteamNetworking; } + ISteamRemoteStorage* SteamRemoteStorage() { return m_pSteamRemoteStorage; } + ISteamScreenshots* SteamScreenshots() { return m_pSteamScreenshots; } + ISteamHTTP* SteamHTTP() { return m_pSteamHTTP; } + ISteamUnifiedMessages* SteamUnifiedMessages() { return m_pSteamUnifiedMessages; } + ISteamController* SteamController() { return m_pController; } + ISteamUGC* SteamUGC() { return m_pSteamUGC; } + ISteamAppList* SteamAppList() { return m_pSteamAppList; } + ISteamMusic* SteamMusic() { return m_pSteamMusic; } + ISteamMusicRemote* SteamMusicRemote() { return m_pSteamMusicRemote; } + ISteamHTMLSurface* SteamHTMLSurface() { return m_pSteamHTMLSurface; } + ISteamInventory* SteamInventory() { return m_pSteamInventory; } + ISteamVideo* SteamVideo() { return m_pSteamVideo; } +#ifdef _PS3 + ISteamPS3OverlayRender* SteamPS3OverlayRender() { return m_pSteamPS3OverlayRender; } +#endif + +private: + ISteamUser *m_pSteamUser; + ISteamFriends *m_pSteamFriends; + ISteamUtils *m_pSteamUtils; + ISteamMatchmaking *m_pSteamMatchmaking; + ISteamUserStats *m_pSteamUserStats; + ISteamApps *m_pSteamApps; + ISteamMatchmakingServers *m_pSteamMatchmakingServers; + ISteamNetworking *m_pSteamNetworking; + ISteamRemoteStorage *m_pSteamRemoteStorage; + ISteamScreenshots *m_pSteamScreenshots; + ISteamHTTP *m_pSteamHTTP; + ISteamUnifiedMessages*m_pSteamUnifiedMessages; + ISteamController *m_pController; + ISteamUGC *m_pSteamUGC; + ISteamAppList *m_pSteamAppList; + ISteamMusic *m_pSteamMusic; + ISteamMusicRemote *m_pSteamMusicRemote; + ISteamHTMLSurface *m_pSteamHTMLSurface; + ISteamInventory *m_pSteamInventory; + ISteamVideo *m_pSteamVideo; +#ifdef _PS3 + ISteamPS3OverlayRender *m_pSteamPS3OverlayRender; +#endif +}; + +inline CSteamAPIContext::CSteamAPIContext() +{ + Clear(); +} + +inline void CSteamAPIContext::Clear() +{ + m_pSteamUser = NULL; + m_pSteamFriends = NULL; + m_pSteamUtils = NULL; + m_pSteamMatchmaking = NULL; + m_pSteamUserStats = NULL; + m_pSteamApps = NULL; + m_pSteamMatchmakingServers = NULL; + m_pSteamNetworking = NULL; + m_pSteamRemoteStorage = NULL; + m_pSteamHTTP = NULL; + m_pSteamScreenshots = NULL; + m_pSteamMusic = NULL; + m_pSteamUnifiedMessages = NULL; + m_pController = NULL; + m_pSteamUGC = NULL; + m_pSteamAppList = NULL; + m_pSteamMusic = NULL; + m_pSteamMusicRemote= NULL; + m_pSteamHTMLSurface = NULL; + m_pSteamInventory = NULL; +#ifdef _PS3 + m_pSteamPS3OverlayRender = NULL; +#endif +} + +// This function must be inlined so the module using steam_api.dll gets the version names they want. +inline bool CSteamAPIContext::Init() +{ + if ( !SteamClient() ) + return false; + + HSteamUser hSteamUser = SteamAPI_GetHSteamUser(); + HSteamPipe hSteamPipe = SteamAPI_GetHSteamPipe(); + + m_pSteamUser = SteamClient()->GetISteamUser( hSteamUser, hSteamPipe, STEAMUSER_INTERFACE_VERSION ); + if ( !m_pSteamUser ) + return false; + + m_pSteamFriends = SteamClient()->GetISteamFriends( hSteamUser, hSteamPipe, STEAMFRIENDS_INTERFACE_VERSION ); + if ( !m_pSteamFriends ) + return false; + + m_pSteamUtils = SteamClient()->GetISteamUtils( hSteamPipe, STEAMUTILS_INTERFACE_VERSION ); + if ( !m_pSteamUtils ) + return false; + + m_pSteamMatchmaking = SteamClient()->GetISteamMatchmaking( hSteamUser, hSteamPipe, STEAMMATCHMAKING_INTERFACE_VERSION ); + if ( !m_pSteamMatchmaking ) + return false; + + m_pSteamMatchmakingServers = SteamClient()->GetISteamMatchmakingServers( hSteamUser, hSteamPipe, STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION ); + if ( !m_pSteamMatchmakingServers ) + return false; + + m_pSteamUserStats = SteamClient()->GetISteamUserStats( hSteamUser, hSteamPipe, STEAMUSERSTATS_INTERFACE_VERSION ); + if ( !m_pSteamUserStats ) + return false; + + m_pSteamApps = SteamClient()->GetISteamApps( hSteamUser, hSteamPipe, STEAMAPPS_INTERFACE_VERSION ); + if ( !m_pSteamApps ) + return false; + + m_pSteamNetworking = SteamClient()->GetISteamNetworking( hSteamUser, hSteamPipe, STEAMNETWORKING_INTERFACE_VERSION ); + if ( !m_pSteamNetworking ) + return false; + + m_pSteamRemoteStorage = SteamClient()->GetISteamRemoteStorage( hSteamUser, hSteamPipe, STEAMREMOTESTORAGE_INTERFACE_VERSION ); + if ( !m_pSteamRemoteStorage ) + return false; + + m_pSteamScreenshots = SteamClient()->GetISteamScreenshots( hSteamUser, hSteamPipe, STEAMSCREENSHOTS_INTERFACE_VERSION ); + if ( !m_pSteamScreenshots ) + return false; + + m_pSteamHTTP = SteamClient()->GetISteamHTTP( hSteamUser, hSteamPipe, STEAMHTTP_INTERFACE_VERSION ); + if ( !m_pSteamHTTP ) + return false; + + m_pSteamUnifiedMessages = SteamClient()->GetISteamUnifiedMessages( hSteamUser, hSteamPipe, STEAMUNIFIEDMESSAGES_INTERFACE_VERSION ); + if ( !m_pSteamUnifiedMessages ) + return false; + + m_pController = SteamClient()->GetISteamController( hSteamUser, hSteamPipe, STEAMCONTROLLER_INTERFACE_VERSION ); + if ( !m_pController ) + return false; + + m_pSteamUGC = SteamClient()->GetISteamUGC( hSteamUser, hSteamPipe, STEAMUGC_INTERFACE_VERSION ); + if ( !m_pSteamUGC ) + return false; + + m_pSteamAppList = SteamClient()->GetISteamAppList( hSteamUser, hSteamPipe, STEAMAPPLIST_INTERFACE_VERSION ); + if ( !m_pSteamAppList ) + return false; + + m_pSteamMusic = SteamClient()->GetISteamMusic( hSteamUser, hSteamPipe, STEAMMUSIC_INTERFACE_VERSION ); + if ( !m_pSteamMusic ) + { + return false; + } + + m_pSteamMusicRemote = SteamClient()->GetISteamMusicRemote( hSteamUser, hSteamPipe, STEAMMUSICREMOTE_INTERFACE_VERSION ); + if ( !m_pSteamMusicRemote ) + { + return false; + } + + m_pSteamHTMLSurface = SteamClient()->GetISteamHTMLSurface( hSteamUser, hSteamPipe, STEAMHTMLSURFACE_INTERFACE_VERSION ); + if ( !m_pSteamHTMLSurface ) + { + return false; + } + + m_pSteamInventory = SteamClient()->GetISteamInventory( hSteamUser, hSteamPipe, STEAMINVENTORY_INTERFACE_VERSION ); + if ( !m_pSteamInventory ) + { + return false; + } + + m_pSteamVideo = SteamClient()->GetISteamVideo( hSteamUser, hSteamPipe, STEAMVIDEO_INTERFACE_VERSION ); + if ( !m_pSteamVideo ) + { + return false; + } + +#ifdef _PS3 + m_pSteamPS3OverlayRender = SteamClient()->GetISteamPS3OverlayRender(); +#endif + + return true; +} + +#endif // VERSION_SAFE_STEAM_API_INTERFACES + +#if defined(USE_BREAKPAD_HANDLER) || defined(STEAM_API_EXPORTS) +// this should be called before the game initialized the steam APIs +// pchDate should be of the format "Mmm dd yyyy" (such as from the __DATE__ macro ) +// pchTime should be of the format "hh:mm:ss" (such as from the __TIME__ macro ) +// bFullMemoryDumps (Win32 only) -- writes out a uuid-full.dmp in the client/dumps folder +// pvContext-- can be NULL, will be the void * context passed into m_pfnPreMinidumpCallback +// PFNPreMinidumpCallback m_pfnPreMinidumpCallback -- optional callback which occurs just before a .dmp file is written during a crash. Applications can hook this to allow adding additional information into the .dmp comment stream. +S_API void S_CALLTYPE SteamAPI_UseBreakpadCrashHandler( char const *pchVersion, char const *pchDate, char const *pchTime, bool bFullMemoryDumps, void *pvContext, PFNPreMinidumpCallback m_pfnPreMinidumpCallback ); +S_API void S_CALLTYPE SteamAPI_SetBreakpadAppID( uint32 unAppID ); +#endif + +#endif // STEAM_API_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steam_gameserver.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steam_gameserver.h new file mode 100644 index 0000000..f58791f --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steam_gameserver.h @@ -0,0 +1,191 @@ +//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +#ifndef STEAM_GAMESERVER_H +#define STEAM_GAMESERVER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "steam_api.h" +#include "isteamgameserver.h" +#include "isteamgameserverstats.h" + +enum EServerMode +{ + eServerModeInvalid = 0, // DO NOT USE + eServerModeNoAuthentication = 1, // Don't authenticate user logins and don't list on the server list + eServerModeAuthentication = 2, // Authenticate users, list on the server list, don't run VAC on clients that connect + eServerModeAuthenticationAndSecure = 3, // Authenticate users, list on the server list and VAC protect clients +}; + +// Initialize ISteamGameServer interface object, and set server properties which may not be changed. +// +// After calling this function, you should set any additional server parameters, and then +// call ISteamGameServer::LogOnAnonymous() or ISteamGameServer::LogOn() +// +// - usSteamPort is the local port used to communicate with the steam servers. +// - usGamePort is the port that clients will connect to for gameplay. +// - usQueryPort is the port that will manage server browser related duties and info +// pings from clients. If you pass MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE for usQueryPort, then it +// will use "GameSocketShare" mode, which means that the game is responsible for sending and receiving +// UDP packets for the master server updater. See references to GameSocketShare in isteamgameserver.h. +// - The version string is usually in the form x.x.x.x, and is used by the master server to detect when the +// server is out of date. (Only servers with the latest version will be listed.) +#ifndef _PS3 + +#ifdef VERSION_SAFE_STEAM_API_INTERFACES +S_API bool SteamGameServer_InitSafe( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ); +#else +S_API bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ); +#endif + +#else + +#ifdef VERSION_SAFE_STEAM_API_INTERFACES +S_API bool SteamGameServer_InitSafe( const SteamPS3Params_t *ps3Params, uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ); +#else +S_API bool SteamGameServer_Init( const SteamPS3Params_t *ps3Params, uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ); +#endif + +#endif + +#ifndef VERSION_SAFE_STEAM_API_INTERFACES +S_API ISteamGameServer *SteamGameServer(); +S_API ISteamUtils *SteamGameServerUtils(); +S_API ISteamNetworking *SteamGameServerNetworking(); +S_API ISteamGameServerStats *SteamGameServerStats(); +S_API ISteamHTTP *SteamGameServerHTTP(); +S_API ISteamInventory *SteamGameServerInventory(); +S_API ISteamUGC *SteamGameServerUGC(); +#endif + +S_API void SteamGameServer_Shutdown(); +S_API void SteamGameServer_RunCallbacks(); + +S_API bool SteamGameServer_BSecure(); +S_API uint64 SteamGameServer_GetSteamID(); + + +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// These macros are similar to the STEAM_CALLBACK_* macros in steam_api.h, but only trigger for gameserver callbacks +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +#define STEAM_GAMESERVER_CALLBACK( thisclass, func, /*callback_type, [deprecated] var*/... ) \ + _STEAM_CALLBACK_SELECT( ( __VA_ARGS__, GS, 3 ), ( this->SetGameserverFlag();, thisclass, func, __VA_ARGS__ ) ) + +#define STEAM_GAMESERVER_CALLBACK_MANUAL( thisclass, func, callback_type, var ) \ + CCallbackManual< thisclass, callback_type, true > var; void func( callback_type *pParam ) + + + +#define _STEAM_CALLBACK_GS( _, thisclass, func, param, var ) \ + CCallback< thisclass, param, true > var; void func( param *pParam ) + +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// steamclient.dll private wrapper functions +// +// The following functions are part of abstracting API access to the steamclient.dll, but should only be used in very specific cases +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +S_API HSteamPipe SteamGameServer_GetHSteamPipe(); + +#ifdef VERSION_SAFE_STEAM_API_INTERFACES +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// VERSION_SAFE_STEAM_API_INTERFACES uses CSteamAPIContext to provide interfaces to each module in a way that +// lets them each specify the interface versions they are compiled with. +// +// It's important that these stay inlined in the header so the calling module specifies the interface versions +// for whatever Steam API version it has. +//----------------------------------------------------------------------------------------------------------------------------------------------------------// + +S_API HSteamUser SteamGameServer_GetHSteamUser(); + +class CSteamGameServerAPIContext +{ +public: + CSteamGameServerAPIContext(); + void Clear(); + + bool Init(); + + ISteamGameServer *SteamGameServer() { return m_pSteamGameServer; } + ISteamUtils *SteamGameServerUtils() { return m_pSteamGameServerUtils; } + ISteamNetworking *SteamGameServerNetworking() { return m_pSteamGameServerNetworking; } + ISteamGameServerStats *SteamGameServerStats() { return m_pSteamGameServerStats; } + ISteamHTTP *SteamHTTP() { return m_pSteamHTTP; } + ISteamInventory *SteamInventory() { return m_pSteamInventory; } + ISteamUGC *SteamUGC() { return m_pSteamUGC; } + +private: + ISteamGameServer *m_pSteamGameServer; + ISteamUtils *m_pSteamGameServerUtils; + ISteamNetworking *m_pSteamGameServerNetworking; + ISteamGameServerStats *m_pSteamGameServerStats; + ISteamHTTP *m_pSteamHTTP; + ISteamInventory *m_pSteamInventory; + ISteamUGC *m_pSteamUGC; +}; + +inline CSteamGameServerAPIContext::CSteamGameServerAPIContext() +{ + Clear(); +} + +inline void CSteamGameServerAPIContext::Clear() +{ + m_pSteamGameServer = NULL; + m_pSteamGameServerUtils = NULL; + m_pSteamGameServerNetworking = NULL; + m_pSteamGameServerStats = NULL; + m_pSteamHTTP = NULL; + m_pSteamInventory = NULL; + m_pSteamUGC = NULL; +} + +S_API ISteamClient *g_pSteamClientGameServer; +// This function must be inlined so the module using steam_api.dll gets the version names they want. +inline bool CSteamGameServerAPIContext::Init() +{ + if ( !g_pSteamClientGameServer ) + return false; + + HSteamUser hSteamUser = SteamGameServer_GetHSteamUser(); + HSteamPipe hSteamPipe = SteamGameServer_GetHSteamPipe(); + + m_pSteamGameServer = g_pSteamClientGameServer->GetISteamGameServer( hSteamUser, hSteamPipe, STEAMGAMESERVER_INTERFACE_VERSION ); + if ( !m_pSteamGameServer ) + return false; + + m_pSteamGameServerUtils = g_pSteamClientGameServer->GetISteamUtils( hSteamPipe, STEAMUTILS_INTERFACE_VERSION ); + if ( !m_pSteamGameServerUtils ) + return false; + + m_pSteamGameServerNetworking = g_pSteamClientGameServer->GetISteamNetworking( hSteamUser, hSteamPipe, STEAMNETWORKING_INTERFACE_VERSION ); + if ( !m_pSteamGameServerNetworking ) + return false; + + m_pSteamGameServerStats = g_pSteamClientGameServer->GetISteamGameServerStats( hSteamUser, hSteamPipe, STEAMGAMESERVERSTATS_INTERFACE_VERSION ); + if ( !m_pSteamGameServerStats ) + return false; + + m_pSteamHTTP = g_pSteamClientGameServer->GetISteamHTTP( hSteamUser, hSteamPipe, STEAMHTTP_INTERFACE_VERSION ); + if ( !m_pSteamHTTP ) + return false; + + m_pSteamInventory = g_pSteamClientGameServer->GetISteamInventory( hSteamUser, hSteamPipe, STEAMINVENTORY_INTERFACE_VERSION ); + if ( !m_pSteamInventory ) + return false; + + m_pSteamUGC = g_pSteamClientGameServer->GetISteamUGC( hSteamUser, hSteamPipe, STEAMUGC_INTERFACE_VERSION ); + if ( !m_pSteamUGC ) + return false; + + return true; +} + +#endif // VERSION_SAFE_STEAM_API_INTERFACES + + +#endif // STEAM_GAMESERVER_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamclientpublic.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamclientpublic.h new file mode 100644 index 0000000..a90a13c --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamclientpublic.h @@ -0,0 +1,1165 @@ +//========= Copyright � 1996-2008, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +//============================================================================= + +#ifndef STEAMCLIENTPUBLIC_H +#define STEAMCLIENTPUBLIC_H +#ifdef _WIN32 +#pragma once +#endif +//lint -save -e1931 -e1927 -e1924 -e613 -e726 + +// This header file defines the interface between the calling application and the code that +// knows how to communicate with the connection manager (CM) from the Steam service + +// This header file is intended to be portable; ideally this 1 header file plus a lib or dll +// is all you need to integrate the client library into some other tree. So please avoid +// including or requiring other header files if possible. This header should only describe the +// interface layer, no need to include anything about the implementation. + +#include "steamtypes.h" +#include "steamuniverse.h" + +// General result codes +enum EResult +{ + k_EResultOK = 1, // success + k_EResultFail = 2, // generic failure + k_EResultNoConnection = 3, // no/failed network connection +// k_EResultNoConnectionRetry = 4, // OBSOLETE - removed + k_EResultInvalidPassword = 5, // password/ticket is invalid + k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere + k_EResultInvalidProtocolVer = 7, // protocol version is incorrect + k_EResultInvalidParam = 8, // a parameter is incorrect + k_EResultFileNotFound = 9, // file was not found + k_EResultBusy = 10, // called method busy - action not taken + k_EResultInvalidState = 11, // called object was in an invalid state + k_EResultInvalidName = 12, // name is invalid + k_EResultInvalidEmail = 13, // email is invalid + k_EResultDuplicateName = 14, // name is not unique + k_EResultAccessDenied = 15, // access is denied + k_EResultTimeout = 16, // operation timed out + k_EResultBanned = 17, // VAC2 banned + k_EResultAccountNotFound = 18, // account not found + k_EResultInvalidSteamID = 19, // steamID is invalid + k_EResultServiceUnavailable = 20, // The requested service is currently unavailable + k_EResultNotLoggedOn = 21, // The user is not logged on + k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party) + k_EResultEncryptionFailure = 23, // Encryption or Decryption failed + k_EResultInsufficientPrivilege = 24, // Insufficient privilege + k_EResultLimitExceeded = 25, // Too much of a good thing + k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes) + k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired + k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again + k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time + k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user + k_EResultIPNotFound = 31, // IP address not found + k_EResultPersistFailed = 32, // failed to write change to the data store + k_EResultLockingFailed = 33, // failed to acquire access lock for this operation + k_EResultLogonSessionReplaced = 34, + k_EResultConnectFailed = 35, + k_EResultHandshakeFailed = 36, + k_EResultIOFailure = 37, + k_EResultRemoteDisconnect = 38, + k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested + k_EResultBlocked = 40, // a user didn't allow it + k_EResultIgnored = 41, // target is ignoring sender + k_EResultNoMatch = 42, // nothing matching the request found + k_EResultAccountDisabled = 43, + k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now + k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available + k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin + k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol. + k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another. + k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed. + k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait + k_EResultSuspended = 51, // Long running operation (content download) suspended/paused + k_EResultCancelled = 52, // Operation canceled (typically by user: content download) + k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable + k_EResultDiskFull = 54, // Operation canceled - not enough disk space. + k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed + k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side + k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account + k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid + k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first + k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files + k_EResultIllegalPassword = 61, // The requested new password is not legal + k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer ) + k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure + k_EResultCannotUseOldPassword = 64, // The requested new password is not legal + k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid + k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent + k_EResultHardwareNotCapableOfIPT = 67, // + k_EResultIPTInitError = 68, // + k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user + k_EResultFacebookQueryError = 70, // Facebook query returned an error + k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired + k_EResultIPLoginRestrictionFailed = 72, + k_EResultAccountLockedDown = 73, + k_EResultAccountLogonDeniedVerifiedEmailRequired = 74, + k_EResultNoMatchingURL = 75, + k_EResultBadResponse = 76, // parse failure, missing field, etc. + k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password + k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range + k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen + k_EResultDisabled = 80, // The requested service has been configured to be unavailable + k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid ! + k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action + k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted + k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent + k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login + k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted + k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker + k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch + k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match + k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners + k_EResultNotModified = 91, // data not modified + k_EResultNoMobileDevice = 92, // the account does not have a mobile device associated with it + k_EResultTimeNotSynced = 93, // the time presented is out of range or tolerance + k_EResultSmsCodeFailed = 94, // SMS code failure (no match, none pending, etc.) + k_EResultAccountLimitExceeded = 95, // Too many accounts access this resource + k_EResultAccountActivityLimitExceeded = 96, // Too many changes to this account + k_EResultPhoneActivityLimitExceeded = 97, // Too many changes to this phone + k_EResultRefundToWallet = 98, // Cannot refund to payment method, must use wallet + k_EResultEmailSendFailure = 99, // Cannot send an email + k_EResultNotSettled = 100, // Can't perform operation till payment has settled + k_EResultNeedCaptcha = 101, // Needs to provide a valid captcha +}; + +// Error codes for use with the voice functions +enum EVoiceResult +{ + k_EVoiceResultOK = 0, + k_EVoiceResultNotInitialized = 1, + k_EVoiceResultNotRecording = 2, + k_EVoiceResultNoData = 3, + k_EVoiceResultBufferTooSmall = 4, + k_EVoiceResultDataCorrupted = 5, + k_EVoiceResultRestricted = 6, + k_EVoiceResultUnsupportedCodec = 7, + k_EVoiceResultReceiverOutOfDate = 8, + k_EVoiceResultReceiverDidNotAnswer = 9, + +}; + +// Result codes to GSHandleClientDeny/Kick +enum EDenyReason +{ + k_EDenyInvalid = 0, + k_EDenyInvalidVersion = 1, + k_EDenyGeneric = 2, + k_EDenyNotLoggedOn = 3, + k_EDenyNoLicense = 4, + k_EDenyCheater = 5, + k_EDenyLoggedInElseWhere = 6, + k_EDenyUnknownText = 7, + k_EDenyIncompatibleAnticheat = 8, + k_EDenyMemoryCorruption = 9, + k_EDenyIncompatibleSoftware = 10, + k_EDenySteamConnectionLost = 11, + k_EDenySteamConnectionError = 12, + k_EDenySteamResponseTimedOut = 13, + k_EDenySteamValidationStalled = 14, + k_EDenySteamOwnerLeftGuestUser = 15, +}; + +// return type of GetAuthSessionTicket +typedef uint32 HAuthTicket; +const HAuthTicket k_HAuthTicketInvalid = 0; + +// results from BeginAuthSession +enum EBeginAuthSessionResult +{ + k_EBeginAuthSessionResultOK = 0, // Ticket is valid for this game and this steamID. + k_EBeginAuthSessionResultInvalidTicket = 1, // Ticket is not valid. + k_EBeginAuthSessionResultDuplicateRequest = 2, // A ticket has already been submitted for this steamID + k_EBeginAuthSessionResultInvalidVersion = 3, // Ticket is from an incompatible interface version + k_EBeginAuthSessionResultGameMismatch = 4, // Ticket is not for this game + k_EBeginAuthSessionResultExpiredTicket = 5, // Ticket has expired +}; + +// Callback values for callback ValidateAuthTicketResponse_t which is a response to BeginAuthSession +enum EAuthSessionResponse +{ + k_EAuthSessionResponseOK = 0, // Steam has verified the user is online, the ticket is valid and ticket has not been reused. + k_EAuthSessionResponseUserNotConnectedToSteam = 1, // The user in question is not connected to steam + k_EAuthSessionResponseNoLicenseOrExpired = 2, // The license has expired. + k_EAuthSessionResponseVACBanned = 3, // The user is VAC banned for this game. + k_EAuthSessionResponseLoggedInElseWhere = 4, // The user account has logged in elsewhere and the session containing the game instance has been disconnected. + k_EAuthSessionResponseVACCheckTimedOut = 5, // VAC has been unable to perform anti-cheat checks on this user + k_EAuthSessionResponseAuthTicketCanceled = 6, // The ticket has been canceled by the issuer + k_EAuthSessionResponseAuthTicketInvalidAlreadyUsed = 7, // This ticket has already been used, it is not valid. + k_EAuthSessionResponseAuthTicketInvalid = 8, // This ticket is not from a user instance currently connected to steam. + k_EAuthSessionResponsePublisherIssuedBan = 9, // The user is banned for this game. The ban came via the web api and not VAC +}; + +// results from UserHasLicenseForApp +enum EUserHasLicenseForAppResult +{ + k_EUserHasLicenseResultHasLicense = 0, // User has a license for specified app + k_EUserHasLicenseResultDoesNotHaveLicense = 1, // User does not have a license for the specified app + k_EUserHasLicenseResultNoAuth = 2, // User has not been authenticated +}; + + +// Steam account types +enum EAccountType +{ + k_EAccountTypeInvalid = 0, + k_EAccountTypeIndividual = 1, // single user account + k_EAccountTypeMultiseat = 2, // multiseat (e.g. cybercafe) account + k_EAccountTypeGameServer = 3, // game server account + k_EAccountTypeAnonGameServer = 4, // anonymous game server account + k_EAccountTypePending = 5, // pending + k_EAccountTypeContentServer = 6, // content server + k_EAccountTypeClan = 7, + k_EAccountTypeChat = 8, + k_EAccountTypeConsoleUser = 9, // Fake SteamID for local PSN account on PS3 or Live account on 360, etc. + k_EAccountTypeAnonUser = 10, + + // Max of 16 items in this field + k_EAccountTypeMax +}; + + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +enum EAppReleaseState +{ + k_EAppReleaseState_Unknown = 0, // unknown, required appinfo or license info is missing + k_EAppReleaseState_Unavailable = 1, // even if user 'just' owns it, can see game at all + k_EAppReleaseState_Prerelease = 2, // can be purchased and is visible in games list, nothing else. Common appInfo section released + k_EAppReleaseState_PreloadOnly = 3, // owners can preload app, not play it. AppInfo fully released. + k_EAppReleaseState_Released = 4, // owners can download and play app. +}; + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +enum EAppOwnershipFlags +{ + k_EAppOwnershipFlags_None = 0x0000, // unknown + k_EAppOwnershipFlags_OwnsLicense = 0x0001, // owns license for this game + k_EAppOwnershipFlags_FreeLicense = 0x0002, // not paid for game + k_EAppOwnershipFlags_RegionRestricted = 0x0004, // owns app, but not allowed to play in current region + k_EAppOwnershipFlags_LowViolence = 0x0008, // only low violence version + k_EAppOwnershipFlags_InvalidPlatform = 0x0010, // app not supported on current platform + k_EAppOwnershipFlags_SharedLicense = 0x0020, // license was granted by authorized local device + k_EAppOwnershipFlags_FreeWeekend = 0x0040, // owned by a free weekend licenses + k_EAppOwnershipFlags_RetailLicense = 0x0080, // has a retail license for game, (CD-Key etc) + k_EAppOwnershipFlags_LicenseLocked = 0x0100, // shared license is locked (in use) by other user + k_EAppOwnershipFlags_LicensePending = 0x0200, // owns app, but transaction is still pending. Can't install or play + k_EAppOwnershipFlags_LicenseExpired = 0x0400, // doesn't own app anymore since license expired + k_EAppOwnershipFlags_LicensePermanent = 0x0800, // permanent license, not borrowed, or guest or freeweekend etc + k_EAppOwnershipFlags_LicenseRecurring = 0x1000, // Recurring license, user is charged periodically + k_EAppOwnershipFlags_LicenseCanceled = 0x2000, // Mark as canceled, but might be still active if recurring + k_EAppOwnershipFlags_AutoGrant = 0x4000, // Ownership is based on any kind of autogrant license + k_EAppOwnershipFlags_PendingGift = 0x8000, // user has pending gift to redeem +}; + + +//----------------------------------------------------------------------------- +// Purpose: designed as flags to allow filters masks +//----------------------------------------------------------------------------- +enum EAppType +{ + k_EAppType_Invalid = 0x000, // unknown / invalid + k_EAppType_Game = 0x001, // playable game, default type + k_EAppType_Application = 0x002, // software application + k_EAppType_Tool = 0x004, // SDKs, editors & dedicated servers + k_EAppType_Demo = 0x008, // game demo + k_EAppType_Media_DEPRECATED = 0x010, // legacy - was used for game trailers, which are now just videos on the web + k_EAppType_DLC = 0x020, // down loadable content + k_EAppType_Guide = 0x040, // game guide, PDF etc + k_EAppType_Driver = 0x080, // hardware driver updater (ATI, Razor etc) + k_EAppType_Config = 0x100, // hidden app used to config Steam features (backpack, sales, etc) + k_EAppType_Hardware = 0x200, // a hardware device (Steam Machine, Steam Controller, Steam Link, etc.) + // 0x400 is up for grabs here + k_EAppType_Video = 0x800, // A video component of either a Film or TVSeries (may be the feature, an episode, preview, making-of, etc) + k_EAppType_Plugin = 0x1000, // Plug-in types for other Apps + k_EAppType_Music = 0x2000, // Music files + + k_EAppType_Shortcut = 0x40000000, // just a shortcut, client side only + k_EAppType_DepotOnly = 0x80000000, // placeholder since depots and apps share the same namespace +}; + + + +//----------------------------------------------------------------------------- +// types of user game stats fields +// WARNING: DO NOT RENUMBER EXISTING VALUES - STORED IN DATABASE +//----------------------------------------------------------------------------- +enum ESteamUserStatType +{ + k_ESteamUserStatTypeINVALID = 0, + k_ESteamUserStatTypeINT = 1, + k_ESteamUserStatTypeFLOAT = 2, + // Read as FLOAT, set with count / session length + k_ESteamUserStatTypeAVGRATE = 3, + k_ESteamUserStatTypeACHIEVEMENTS = 4, + k_ESteamUserStatTypeGROUPACHIEVEMENTS = 5, + + // max, for sanity checks + k_ESteamUserStatTypeMAX +}; + + +//----------------------------------------------------------------------------- +// Purpose: Chat Entry Types (previously was only friend-to-friend message types) +//----------------------------------------------------------------------------- +enum EChatEntryType +{ + k_EChatEntryTypeInvalid = 0, + k_EChatEntryTypeChatMsg = 1, // Normal text message from another user + k_EChatEntryTypeTyping = 2, // Another user is typing (not used in multi-user chat) + k_EChatEntryTypeInviteGame = 3, // Invite from other user into that users current game + k_EChatEntryTypeEmote = 4, // text emote message (deprecated, should be treated as ChatMsg) + //k_EChatEntryTypeLobbyGameStart = 5, // lobby game is starting (dead - listen for LobbyGameCreated_t callback instead) + k_EChatEntryTypeLeftConversation = 6, // user has left the conversation ( closed chat window ) + // Above are previous FriendMsgType entries, now merged into more generic chat entry types + k_EChatEntryTypeEntered = 7, // user has entered the conversation (used in multi-user chat and group chat) + k_EChatEntryTypeWasKicked = 8, // user was kicked (data: 64-bit steamid of actor performing the kick) + k_EChatEntryTypeWasBanned = 9, // user was banned (data: 64-bit steamid of actor performing the ban) + k_EChatEntryTypeDisconnected = 10, // user disconnected + k_EChatEntryTypeHistoricalChat = 11, // a chat message from user's chat history or offilne message + k_EChatEntryTypeReserved1 = 12, + k_EChatEntryTypeReserved2 = 13, + k_EChatEntryTypeLinkBlocked = 14, // a link was removed by the chat filter. +}; + + +//----------------------------------------------------------------------------- +// Purpose: Chat Room Enter Responses +//----------------------------------------------------------------------------- +enum EChatRoomEnterResponse +{ + k_EChatRoomEnterResponseSuccess = 1, // Success + k_EChatRoomEnterResponseDoesntExist = 2, // Chat doesn't exist (probably closed) + k_EChatRoomEnterResponseNotAllowed = 3, // General Denied - You don't have the permissions needed to join the chat + k_EChatRoomEnterResponseFull = 4, // Chat room has reached its maximum size + k_EChatRoomEnterResponseError = 5, // Unexpected Error + k_EChatRoomEnterResponseBanned = 6, // You are banned from this chat room and may not join + k_EChatRoomEnterResponseLimited = 7, // Joining this chat is not allowed because you are a limited user (no value on account) + k_EChatRoomEnterResponseClanDisabled = 8, // Attempt to join a clan chat when the clan is locked or disabled + k_EChatRoomEnterResponseCommunityBan = 9, // Attempt to join a chat when the user has a community lock on their account + k_EChatRoomEnterResponseMemberBlockedYou = 10, // Join failed - some member in the chat has blocked you from joining + k_EChatRoomEnterResponseYouBlockedMember = 11, // Join failed - you have blocked some member already in the chat + // k_EChatRoomEnterResponseNoRankingDataLobby = 12, // No longer used + // k_EChatRoomEnterResponseNoRankingDataUser = 13, // No longer used + // k_EChatRoomEnterResponseRankOutOfRange = 14, // No longer used +}; + + +typedef void (*PFNLegacyKeyRegistration)( const char *pchCDKey, const char *pchInstallPath ); +typedef bool (*PFNLegacyKeyInstalled)(); + +const unsigned int k_unSteamAccountIDMask = 0xFFFFFFFF; +const unsigned int k_unSteamAccountInstanceMask = 0x000FFFFF; +// we allow 3 simultaneous user account instances right now, 1= desktop, 2 = console, 4 = web, 0 = all +const unsigned int k_unSteamUserDesktopInstance = 1; +const unsigned int k_unSteamUserConsoleInstance = 2; +const unsigned int k_unSteamUserWebInstance = 4; + +// Special flags for Chat accounts - they go in the top 8 bits +// of the steam ID's "instance", leaving 12 for the actual instances +enum EChatSteamIDInstanceFlags +{ + k_EChatAccountInstanceMask = 0x00000FFF, // top 8 bits are flags + + k_EChatInstanceFlagClan = ( k_unSteamAccountInstanceMask + 1 ) >> 1, // top bit + k_EChatInstanceFlagLobby = ( k_unSteamAccountInstanceMask + 1 ) >> 2, // next one down, etc + k_EChatInstanceFlagMMSLobby = ( k_unSteamAccountInstanceMask + 1 ) >> 3, // next one down, etc + + // Max of 8 flags +}; + + +//----------------------------------------------------------------------------- +// Purpose: Marketing message flags that change how a client should handle them +//----------------------------------------------------------------------------- +enum EMarketingMessageFlags +{ + k_EMarketingMessageFlagsNone = 0, + k_EMarketingMessageFlagsHighPriority = 1 << 0, + k_EMarketingMessageFlagsPlatformWindows = 1 << 1, + k_EMarketingMessageFlagsPlatformMac = 1 << 2, + k_EMarketingMessageFlagsPlatformLinux = 1 << 3, + + //aggregate flags + k_EMarketingMessageFlagsPlatformRestrictions = + k_EMarketingMessageFlagsPlatformWindows | + k_EMarketingMessageFlagsPlatformMac | + k_EMarketingMessageFlagsPlatformLinux, +}; + + + +//----------------------------------------------------------------------------- +// Purpose: Possible positions to tell the overlay to show notifications in +//----------------------------------------------------------------------------- +enum ENotificationPosition +{ + k_EPositionTopLeft = 0, + k_EPositionTopRight = 1, + k_EPositionBottomLeft = 2, + k_EPositionBottomRight = 3, +}; + + +//----------------------------------------------------------------------------- +// Purpose: Broadcast upload result details +//----------------------------------------------------------------------------- +enum EBroadcastUploadResult +{ + k_EBroadcastUploadResultNone = 0, // broadcast state unknown + k_EBroadcastUploadResultOK = 1, // broadcast was good, no problems + k_EBroadcastUploadResultInitFailed = 2, // broadcast init failed + k_EBroadcastUploadResultFrameFailed = 3, // broadcast frame upload failed + k_EBroadcastUploadResultTimeout = 4, // broadcast upload timed out + k_EBroadcastUploadResultBandwidthExceeded = 5, // broadcast send too much data + k_EBroadcastUploadResultLowFPS = 6, // broadcast FPS too low + k_EBroadcastUploadResultMissingKeyFrames = 7, // broadcast sending not enough key frames + k_EBroadcastUploadResultNoConnection = 8, // broadcast client failed to connect to relay + k_EBroadcastUploadResultRelayFailed = 9, // relay dropped the upload + k_EBroadcastUploadResultSettingsChanged = 10, // the client changed broadcast settings + k_EBroadcastUploadResultMissingAudio = 11, // client failed to send audio data + k_EBroadcastUploadResultTooFarBehind = 12, // clients was too slow uploading + k_EBroadcastUploadResultTranscodeBehind = 13, // server failed to keep up with transcode +}; + + +//----------------------------------------------------------------------------- +// Purpose: codes for well defined launch options +//----------------------------------------------------------------------------- +enum ELaunchOptionType +{ + k_ELaunchOptionType_None = 0, // unknown what launch option does + k_ELaunchOptionType_Default = 1, // runs the game, app, whatever in default mode + k_ELaunchOptionType_SafeMode = 2, // runs the game in safe mode + k_ELaunchOptionType_Multiplayer = 3, // runs the game in multiplayer mode + k_ELaunchOptionType_Config = 4, // runs config tool for this game + k_ELaunchOptionType_VR = 5, // runs game in VR mode + k_ELaunchOptionType_Server = 6, // runs dedicated server for this game + k_ELaunchOptionType_Editor = 7, // runs game editor + k_ELaunchOptionType_Manual = 8, // shows game manual + k_ELaunchOptionType_Benchmark = 9, // runs game benchmark + k_ELaunchOptionType_Option1 = 10, // generic run option, uses description field for game name + k_ELaunchOptionType_Option2 = 11, // generic run option, uses description field for game name + k_ELaunchOptionType_Option3 = 12, // generic run option, uses description field for game name + + + k_ELaunchOptionType_Dialog = 1000, // show launch options dialog +}; + + +#pragma pack( push, 1 ) + +#define CSTEAMID_DEFINED + +// Steam ID structure (64 bits total) +class CSteamID +{ +public: + + //----------------------------------------------------------------------------- + // Purpose: Constructor + //----------------------------------------------------------------------------- + CSteamID() + { + m_steamid.m_comp.m_unAccountID = 0; + m_steamid.m_comp.m_EAccountType = k_EAccountTypeInvalid; + m_steamid.m_comp.m_EUniverse = k_EUniverseInvalid; + m_steamid.m_comp.m_unAccountInstance = 0; + } + + + //----------------------------------------------------------------------------- + // Purpose: Constructor + // Input : unAccountID - 32-bit account ID + // eUniverse - Universe this account belongs to + // eAccountType - Type of account + //----------------------------------------------------------------------------- + CSteamID( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType ) + { + Set( unAccountID, eUniverse, eAccountType ); + } + + + //----------------------------------------------------------------------------- + // Purpose: Constructor + // Input : unAccountID - 32-bit account ID + // unAccountInstance - instance + // eUniverse - Universe this account belongs to + // eAccountType - Type of account + //----------------------------------------------------------------------------- + CSteamID( uint32 unAccountID, unsigned int unAccountInstance, EUniverse eUniverse, EAccountType eAccountType ) + { +#if defined(_SERVER) && defined(Assert) + Assert( ! ( ( k_EAccountTypeIndividual == eAccountType ) && ( unAccountInstance > k_unSteamUserWebInstance ) ) ); // enforce that for individual accounts, instance is always 1 +#endif // _SERVER + InstancedSet( unAccountID, unAccountInstance, eUniverse, eAccountType ); + } + + + //----------------------------------------------------------------------------- + // Purpose: Constructor + // Input : ulSteamID - 64-bit representation of a Steam ID + // Note: Will not accept a uint32 or int32 as input, as that is a probable mistake. + // See the stubbed out overloads in the private: section for more info. + //----------------------------------------------------------------------------- + CSteamID( uint64 ulSteamID ) + { + SetFromUint64( ulSteamID ); + } +#ifdef INT64_DIFFERENT_FROM_INT64_T + CSteamID( uint64_t ulSteamID ) + { + SetFromUint64( (uint64)ulSteamID ); + } +#endif + + + //----------------------------------------------------------------------------- + // Purpose: Sets parameters for steam ID + // Input : unAccountID - 32-bit account ID + // eUniverse - Universe this account belongs to + // eAccountType - Type of account + //----------------------------------------------------------------------------- + void Set( uint32 unAccountID, EUniverse eUniverse, EAccountType eAccountType ) + { + m_steamid.m_comp.m_unAccountID = unAccountID; + m_steamid.m_comp.m_EUniverse = eUniverse; + m_steamid.m_comp.m_EAccountType = eAccountType; + + if ( eAccountType == k_EAccountTypeClan || eAccountType == k_EAccountTypeGameServer ) + { + m_steamid.m_comp.m_unAccountInstance = 0; + } + else + { + // by default we pick the desktop instance + m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance; + } + } + + + //----------------------------------------------------------------------------- + // Purpose: Sets parameters for steam ID + // Input : unAccountID - 32-bit account ID + // eUniverse - Universe this account belongs to + // eAccountType - Type of account + //----------------------------------------------------------------------------- + void InstancedSet( uint32 unAccountID, uint32 unInstance, EUniverse eUniverse, EAccountType eAccountType ) + { + m_steamid.m_comp.m_unAccountID = unAccountID; + m_steamid.m_comp.m_EUniverse = eUniverse; + m_steamid.m_comp.m_EAccountType = eAccountType; + m_steamid.m_comp.m_unAccountInstance = unInstance; + } + + + //----------------------------------------------------------------------------- + // Purpose: Initializes a steam ID from its 52 bit parts and universe/type + // Input : ulIdentifier - 52 bits of goodness + //----------------------------------------------------------------------------- + void FullSet( uint64 ulIdentifier, EUniverse eUniverse, EAccountType eAccountType ) + { + m_steamid.m_comp.m_unAccountID = ( ulIdentifier & k_unSteamAccountIDMask ); // account ID is low 32 bits + m_steamid.m_comp.m_unAccountInstance = ( ( ulIdentifier >> 32 ) & k_unSteamAccountInstanceMask ); // account instance is next 20 bits + m_steamid.m_comp.m_EUniverse = eUniverse; + m_steamid.m_comp.m_EAccountType = eAccountType; + } + + + //----------------------------------------------------------------------------- + // Purpose: Initializes a steam ID from its 64-bit representation + // Input : ulSteamID - 64-bit representation of a Steam ID + //----------------------------------------------------------------------------- + void SetFromUint64( uint64 ulSteamID ) + { + m_steamid.m_unAll64Bits = ulSteamID; + } + + + //----------------------------------------------------------------------------- + // Purpose: Clear all fields, leaving an invalid ID. + //----------------------------------------------------------------------------- + void Clear() + { + m_steamid.m_comp.m_unAccountID = 0; + m_steamid.m_comp.m_EAccountType = k_EAccountTypeInvalid; + m_steamid.m_comp.m_EUniverse = k_EUniverseInvalid; + m_steamid.m_comp.m_unAccountInstance = 0; + } + + +#if defined( INCLUDED_STEAM2_USERID_STRUCTS ) + //----------------------------------------------------------------------------- + // Purpose: Initializes a steam ID from a Steam2 ID structure + // Input: pTSteamGlobalUserID - Steam2 ID to convert + // eUniverse - universe this ID belongs to + //----------------------------------------------------------------------------- + void SetFromSteam2( TSteamGlobalUserID *pTSteamGlobalUserID, EUniverse eUniverse ) + { + m_steamid.m_comp.m_unAccountID = pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits * 2 + + pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits; + m_steamid.m_comp.m_EUniverse = eUniverse; // set the universe + m_steamid.m_comp.m_EAccountType = k_EAccountTypeIndividual; // Steam 2 accounts always map to account type of individual + m_steamid.m_comp.m_unAccountInstance = k_unSteamUserDesktopInstance; // Steam2 only knew desktop instances + } + + //----------------------------------------------------------------------------- + // Purpose: Fills out a Steam2 ID structure + // Input: pTSteamGlobalUserID - Steam2 ID to write to + //----------------------------------------------------------------------------- + void ConvertToSteam2( TSteamGlobalUserID *pTSteamGlobalUserID ) const + { + // only individual accounts have any meaning in Steam 2, only they can be mapped + // Assert( m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual ); + + pTSteamGlobalUserID->m_SteamInstanceID = 0; + pTSteamGlobalUserID->m_SteamLocalUserID.Split.High32bits = m_steamid.m_comp.m_unAccountID % 2; + pTSteamGlobalUserID->m_SteamLocalUserID.Split.Low32bits = m_steamid.m_comp.m_unAccountID / 2; + } +#endif // defined( INCLUDED_STEAM_COMMON_STEAMCOMMON_H ) + + //----------------------------------------------------------------------------- + // Purpose: Converts steam ID to its 64-bit representation + // Output : 64-bit representation of a Steam ID + //----------------------------------------------------------------------------- + uint64 ConvertToUint64() const + { + return m_steamid.m_unAll64Bits; + } + + + //----------------------------------------------------------------------------- + // Purpose: Converts the static parts of a steam ID to a 64-bit representation. + // For multiseat accounts, all instances of that account will have the + // same static account key, so they can be grouped together by the static + // account key. + // Output : 64-bit static account key + //----------------------------------------------------------------------------- + uint64 GetStaticAccountKey() const + { + // note we do NOT include the account instance (which is a dynamic property) in the static account key + return (uint64) ( ( ( (uint64) m_steamid.m_comp.m_EUniverse ) << 56 ) + ((uint64) m_steamid.m_comp.m_EAccountType << 52 ) + m_steamid.m_comp.m_unAccountID ); + } + + + //----------------------------------------------------------------------------- + // Purpose: create an anonymous game server login to be filled in by the AM + //----------------------------------------------------------------------------- + void CreateBlankAnonLogon( EUniverse eUniverse ) + { + m_steamid.m_comp.m_unAccountID = 0; + m_steamid.m_comp.m_EAccountType = k_EAccountTypeAnonGameServer; + m_steamid.m_comp.m_EUniverse = eUniverse; + m_steamid.m_comp.m_unAccountInstance = 0; + } + + + //----------------------------------------------------------------------------- + // Purpose: create an anonymous game server login to be filled in by the AM + //----------------------------------------------------------------------------- + void CreateBlankAnonUserLogon( EUniverse eUniverse ) + { + m_steamid.m_comp.m_unAccountID = 0; + m_steamid.m_comp.m_EAccountType = k_EAccountTypeAnonUser; + m_steamid.m_comp.m_EUniverse = eUniverse; + m_steamid.m_comp.m_unAccountInstance = 0; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this an anonymous game server login that will be filled in? + //----------------------------------------------------------------------------- + bool BBlankAnonAccount() const + { + return m_steamid.m_comp.m_unAccountID == 0 && BAnonAccount() && m_steamid.m_comp.m_unAccountInstance == 0; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this a game server account id? (Either persistent or anonymous) + //----------------------------------------------------------------------------- + bool BGameServerAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer || m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this a persistent (not anonymous) game server account id? + //----------------------------------------------------------------------------- + bool BPersistentGameServerAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this an anonymous game server account id? + //----------------------------------------------------------------------------- + bool BAnonGameServerAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this a content server account id? + //----------------------------------------------------------------------------- + bool BContentServerAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeContentServer; + } + + + //----------------------------------------------------------------------------- + // Purpose: Is this a clan account id? + //----------------------------------------------------------------------------- + bool BClanAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeClan; + } + + + //----------------------------------------------------------------------------- + // Purpose: Is this a chat account id? + //----------------------------------------------------------------------------- + bool BChatAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeChat; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this a chat account id? + //----------------------------------------------------------------------------- + bool IsLobby() const + { + return ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeChat ) + && ( m_steamid.m_comp.m_unAccountInstance & k_EChatInstanceFlagLobby ); + } + + + //----------------------------------------------------------------------------- + // Purpose: Is this an individual user account id? + //----------------------------------------------------------------------------- + bool BIndividualAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual || m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser; + } + + + //----------------------------------------------------------------------------- + // Purpose: Is this an anonymous account? + //----------------------------------------------------------------------------- + bool BAnonAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonUser || m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonGameServer; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this an anonymous user account? ( used to create an account or reset a password ) + //----------------------------------------------------------------------------- + bool BAnonUserAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeAnonUser; + } + + //----------------------------------------------------------------------------- + // Purpose: Is this a faked up Steam ID for a PSN friend account? + //----------------------------------------------------------------------------- + bool BConsoleUserAccount() const + { + return m_steamid.m_comp.m_EAccountType == k_EAccountTypeConsoleUser; + } + + // simple accessors + void SetAccountID( uint32 unAccountID ) { m_steamid.m_comp.m_unAccountID = unAccountID; } + void SetAccountInstance( uint32 unInstance ){ m_steamid.m_comp.m_unAccountInstance = unInstance; } + void ClearIndividualInstance() { if ( BIndividualAccount() ) m_steamid.m_comp.m_unAccountInstance = 0; } + bool HasNoIndividualInstance() const { return BIndividualAccount() && (m_steamid.m_comp.m_unAccountInstance==0); } + AccountID_t GetAccountID() const { return m_steamid.m_comp.m_unAccountID; } + uint32 GetUnAccountInstance() const { return m_steamid.m_comp.m_unAccountInstance; } + EAccountType GetEAccountType() const { return ( EAccountType ) m_steamid.m_comp.m_EAccountType; } + EUniverse GetEUniverse() const { return m_steamid.m_comp.m_EUniverse; } + void SetEUniverse( EUniverse eUniverse ) { m_steamid.m_comp.m_EUniverse = eUniverse; } + bool IsValid() const; + + // this set of functions is hidden, will be moved out of class + explicit CSteamID( const char *pchSteamID, EUniverse eDefaultUniverse = k_EUniverseInvalid ); + const char * Render() const; // renders this steam ID to string + static const char * Render( uint64 ulSteamID ); // static method to render a uint64 representation of a steam ID to a string + + void SetFromString( const char *pchSteamID, EUniverse eDefaultUniverse ); + // SetFromString allows many partially-correct strings, constraining how + // we might be able to change things in the future. + // SetFromStringStrict requires the exact string forms that we support + // and is preferred when the caller knows it's safe to be strict. + // Returns whether the string parsed correctly. + bool SetFromStringStrict( const char *pchSteamID, EUniverse eDefaultUniverse ); + bool SetFromSteam2String( const char *pchSteam2ID, EUniverse eUniverse ); + + inline bool operator==( const CSteamID &val ) const { return m_steamid.m_unAll64Bits == val.m_steamid.m_unAll64Bits; } + inline bool operator!=( const CSteamID &val ) const { return !operator==( val ); } + inline bool operator<( const CSteamID &val ) const { return m_steamid.m_unAll64Bits < val.m_steamid.m_unAll64Bits; } + inline bool operator>( const CSteamID &val ) const { return m_steamid.m_unAll64Bits > val.m_steamid.m_unAll64Bits; } + + // DEBUG function + bool BValidExternalSteamID() const; + +private: + // These are defined here to prevent accidental implicit conversion of a u32AccountID to a CSteamID. + // If you get a compiler error about an ambiguous constructor/function then it may be because you're + // passing a 32-bit int to a function that takes a CSteamID. You should explicitly create the SteamID + // using the correct Universe and account Type/Instance values. + CSteamID( uint32 ); + CSteamID( int32 ); + + // 64 bits total + union SteamID_t + { + struct SteamIDComponent_t + { +#ifdef VALVE_BIG_ENDIAN + EUniverse m_EUniverse : 8; // universe this account belongs to + unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference + unsigned int m_unAccountInstance : 20; // dynamic instance ID + uint32 m_unAccountID : 32; // unique account identifier +#else + uint32 m_unAccountID : 32; // unique account identifier + unsigned int m_unAccountInstance : 20; // dynamic instance ID + unsigned int m_EAccountType : 4; // type of account - can't show as EAccountType, due to signed / unsigned difference + EUniverse m_EUniverse : 8; // universe this account belongs to +#endif + } m_comp; + + uint64 m_unAll64Bits; + } m_steamid; +}; + +inline bool CSteamID::IsValid() const +{ + if ( m_steamid.m_comp.m_EAccountType <= k_EAccountTypeInvalid || m_steamid.m_comp.m_EAccountType >= k_EAccountTypeMax ) + return false; + + if ( m_steamid.m_comp.m_EUniverse <= k_EUniverseInvalid || m_steamid.m_comp.m_EUniverse >= k_EUniverseMax ) + return false; + + if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeIndividual ) + { + if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance > k_unSteamUserWebInstance ) + return false; + } + + if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeClan ) + { + if ( m_steamid.m_comp.m_unAccountID == 0 || m_steamid.m_comp.m_unAccountInstance != 0 ) + return false; + } + + if ( m_steamid.m_comp.m_EAccountType == k_EAccountTypeGameServer ) + { + if ( m_steamid.m_comp.m_unAccountID == 0 ) + return false; + // Any limit on instances? We use them for local users and bots + } + return true; +} + +// generic invalid CSteamID +#define k_steamIDNil CSteamID() + +// This steamID comes from a user game connection to an out of date GS that hasnt implemented the protocol +// to provide its steamID +#define k_steamIDOutofDateGS CSteamID( 0, 0, k_EUniverseInvalid, k_EAccountTypeInvalid ) +// This steamID comes from a user game connection to an sv_lan GS +#define k_steamIDLanModeGS CSteamID( 0, 0, k_EUniversePublic, k_EAccountTypeInvalid ) +// This steamID can come from a user game connection to a GS that has just booted but hasnt yet even initialized +// its steam3 component and started logging on. +#define k_steamIDNotInitYetGS CSteamID( 1, 0, k_EUniverseInvalid, k_EAccountTypeInvalid ) +// This steamID can come from a user game connection to a GS that isn't using the steam authentication system but still +// wants to support the "Join Game" option in the friends list +#define k_steamIDNonSteamGS CSteamID( 2, 0, k_EUniverseInvalid, k_EAccountTypeInvalid ) + + +#ifdef STEAM +// Returns the matching chat steamID, with the default instance of 0 +// If the steamID passed in is already of type k_EAccountTypeChat it will be returned with the same instance +CSteamID ChatIDFromSteamID( const CSteamID &steamID ); +// Returns the matching clan steamID, with the default instance of 0 +// If the steamID passed in is already of type k_EAccountTypeClan it will be returned with the same instance +CSteamID ClanIDFromSteamID( const CSteamID &steamID ); +// Asserts steamID type before conversion +CSteamID ChatIDFromClanID( const CSteamID &steamIDClan ); +// Asserts steamID type before conversion +CSteamID ClanIDFromChatID( const CSteamID &steamIDChat ); + +#endif // _STEAM + + +//----------------------------------------------------------------------------- +// Purpose: encapsulates an appID/modID pair +//----------------------------------------------------------------------------- +class CGameID +{ +public: + + CGameID() + { + m_gameID.m_nType = k_EGameIDTypeApp; + m_gameID.m_nAppID = k_uAppIdInvalid; + m_gameID.m_nModID = 0; + } + + explicit CGameID( uint64 ulGameID ) + { + m_ulGameID = ulGameID; + } +#ifdef INT64_DIFFERENT_FROM_INT64_T + CGameID( uint64_t ulGameID ) + { + m_ulGameID = (uint64)ulGameID; + } +#endif + + explicit CGameID( int32 nAppID ) + { + m_ulGameID = 0; + m_gameID.m_nAppID = nAppID; + } + + explicit CGameID( uint32 nAppID ) + { + m_ulGameID = 0; + m_gameID.m_nAppID = nAppID; + } + + CGameID( uint32 nAppID, uint32 nModID ) + { + m_ulGameID = 0; + m_gameID.m_nAppID = nAppID; + m_gameID.m_nModID = nModID; + m_gameID.m_nType = k_EGameIDTypeGameMod; + } + + // Hidden functions used only by Steam + explicit CGameID( const char *pchGameID ); + const char *Render() const; // render this Game ID to string + static const char *Render( uint64 ulGameID ); // static method to render a uint64 representation of a Game ID to a string + + // must include checksum_crc.h first to get this functionality +#if defined( CHECKSUM_CRC_H ) + CGameID( uint32 nAppID, const char *pchModPath ) + { + m_ulGameID = 0; + m_gameID.m_nAppID = nAppID; + m_gameID.m_nType = k_EGameIDTypeGameMod; + + char rgchModDir[MAX_PATH]; + V_FileBase( pchModPath, rgchModDir, sizeof( rgchModDir ) ); + CRC32_t crc32; + CRC32_Init( &crc32 ); + CRC32_ProcessBuffer( &crc32, rgchModDir, V_strlen( rgchModDir ) ); + CRC32_Final( &crc32 ); + + // set the high-bit on the mod-id + // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique + // replacement for appID's + m_gameID.m_nModID = crc32 | (0x80000000); + } + + CGameID( const char *pchExePath, const char *pchAppName ) + { + m_ulGameID = 0; + m_gameID.m_nAppID = k_uAppIdInvalid; + m_gameID.m_nType = k_EGameIDTypeShortcut; + + CRC32_t crc32; + CRC32_Init( &crc32 ); + CRC32_ProcessBuffer( &crc32, pchExePath, V_strlen( pchExePath ) ); + CRC32_ProcessBuffer( &crc32, pchAppName, V_strlen( pchAppName ) ); + CRC32_Final( &crc32 ); + + // set the high-bit on the mod-id + // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique + // replacement for appID's + m_gameID.m_nModID = crc32 | (0x80000000); + } + +#if defined( VSTFILEID_H ) + + CGameID( VstFileID vstFileID ) + { + m_ulGameID = 0; + m_gameID.m_nAppID = k_uAppIdInvalid; + m_gameID.m_nType = k_EGameIDTypeP2P; + + CRC32_t crc32; + CRC32_Init( &crc32 ); + const char *pchFileId = vstFileID.Render(); + CRC32_ProcessBuffer( &crc32, pchFileId, V_strlen( pchFileId ) ); + CRC32_Final( &crc32 ); + + // set the high-bit on the mod-id + // reduces crc32 to 31bits, but lets us use the modID as a guaranteed unique + // replacement for appID's + m_gameID.m_nModID = crc32 | (0x80000000); + } + +#endif /* VSTFILEID_H */ + +#endif /* CHECKSUM_CRC_H */ + + + uint64 ToUint64() const + { + return m_ulGameID; + } + + uint64 *GetUint64Ptr() + { + return &m_ulGameID; + } + + void Set( uint64 ulGameID ) + { + m_ulGameID = ulGameID; + } + + bool IsMod() const + { + return ( m_gameID.m_nType == k_EGameIDTypeGameMod ); + } + + bool IsShortcut() const + { + return ( m_gameID.m_nType == k_EGameIDTypeShortcut ); + } + + bool IsP2PFile() const + { + return ( m_gameID.m_nType == k_EGameIDTypeP2P ); + } + + bool IsSteamApp() const + { + return ( m_gameID.m_nType == k_EGameIDTypeApp ); + } + + uint32 ModID() const + { + return m_gameID.m_nModID; + } + + uint32 AppID() const + { + return m_gameID.m_nAppID; + } + + bool operator == ( const CGameID &rhs ) const + { + return m_ulGameID == rhs.m_ulGameID; + } + + bool operator != ( const CGameID &rhs ) const + { + return !(*this == rhs); + } + + bool operator < ( const CGameID &rhs ) const + { + return ( m_ulGameID < rhs.m_ulGameID ); + } + + bool IsValid() const + { + // each type has it's own invalid fixed point: + switch( m_gameID.m_nType ) + { + case k_EGameIDTypeApp: + return m_gameID.m_nAppID != k_uAppIdInvalid; + + case k_EGameIDTypeGameMod: + return m_gameID.m_nAppID != k_uAppIdInvalid && m_gameID.m_nModID & 0x80000000; + + case k_EGameIDTypeShortcut: + return (m_gameID.m_nModID & 0x80000000) != 0; + + case k_EGameIDTypeP2P: + return m_gameID.m_nAppID == k_uAppIdInvalid && m_gameID.m_nModID & 0x80000000; + + default: +#if defined(Assert) + Assert(false); +#endif + return false; + } + + } + + void Reset() + { + m_ulGameID = 0; + } + + + +private: + + enum EGameIDType + { + k_EGameIDTypeApp = 0, + k_EGameIDTypeGameMod = 1, + k_EGameIDTypeShortcut = 2, + k_EGameIDTypeP2P = 3, + }; + + struct GameID_t + { +#ifdef VALVE_BIG_ENDIAN + unsigned int m_nModID : 32; + unsigned int m_nType : 8; + unsigned int m_nAppID : 24; +#else + unsigned int m_nAppID : 24; + unsigned int m_nType : 8; + unsigned int m_nModID : 32; +#endif + }; + + union + { + uint64 m_ulGameID; + GameID_t m_gameID; + }; +}; + +#pragma pack( pop ) + +const int k_cchGameExtraInfoMax = 64; + + +//----------------------------------------------------------------------------- +// Constants used for query ports. +//----------------------------------------------------------------------------- + +#define QUERY_PORT_NOT_INITIALIZED 0xFFFF // We haven't asked the GS for this query port's actual value yet. +#define QUERY_PORT_ERROR 0xFFFE // We were unable to get the query port for this server. + + +//----------------------------------------------------------------------------- +// Purpose: Passed as argument to SteamAPI_UseBreakpadCrashHandler to enable optional callback +// just before minidump file is captured after a crash has occurred. (Allows app to append additional comment data to the dump, etc.) +//----------------------------------------------------------------------------- +typedef void (*PFNPreMinidumpCallback)(void *context); + +//----------------------------------------------------------------------------- +// Purpose: Used by ICrashHandler interfaces to reference particular installed crash handlers +//----------------------------------------------------------------------------- +typedef void *BREAKPAD_HANDLE; +#define BREAKPAD_INVALID_HANDLE (BREAKPAD_HANDLE)0 + +#endif // STEAMCLIENTPUBLIC_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamcontrollerpublic.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamcontrollerpublic.h new file mode 100644 index 0000000..6ab5bc9 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamcontrollerpublic.h @@ -0,0 +1,79 @@ +//========= Copyright © 1996-2013, Valve LLC, All rights reserved. ============ +// +// Purpose: Controller related public types/constants +// +//============================================================================= + +#ifndef STEAMCONTROLLERPUBLIC_H +#define STEAMCONTROLLERPUBLIC_H +#ifdef _WIN32 +#pragma once +#endif + + +#if defined( STEAM ) || defined( ISTEAMCONTROLLER_H ) +// This file should only be included by the Steam build or directly from +// isteamcontroller.h. +#include "steamtypes.h" +#else +#include +typedef uint32_t uint32; +#ifdef __C51__ +typedef uint8_t uint64[8]; +#else +typedef uint64_t uint64; +#endif +#endif + +#pragma pack(1) + +// Safe to add new bitfields at the end of this list for new buttons/actions, +// but never re-use or re-number an existing flag as old client code will be +// confused. +#define STEAM_RIGHT_TRIGGER_MASK 0x0000000000000001l +#define STEAM_LEFT_TRIGGER_MASK 0x0000000000000002l +#define STEAM_RIGHT_BUMPER_MASK 0x0000000000000004l +#define STEAM_LEFT_BUMPER_MASK 0x0000000000000008l +#define STEAM_BUTTON_0_MASK 0x0000000000000010l +#define STEAM_BUTTON_1_MASK 0x0000000000000020l +#define STEAM_BUTTON_2_MASK 0x0000000000000040l +#define STEAM_BUTTON_3_MASK 0x0000000000000080l +#define STEAM_TOUCH_0_MASK 0x0000000000000100l +#define STEAM_TOUCH_1_MASK 0x0000000000000200l +#define STEAM_TOUCH_2_MASK 0x0000000000000400l +#define STEAM_TOUCH_3_MASK 0x0000000000000800l +#define STEAM_BUTTON_MENU_MASK 0x0000000000001000l +#define STEAM_BUTTON_STEAM_MASK 0x0000000000002000l +#define STEAM_BUTTON_ESCAPE_MASK 0x0000000000004000l +#define STEAM_BUTTON_BACK_LEFT_MASK 0x0000000000008000l +#define STEAM_BUTTON_BACK_RIGHT_MASK 0x0000000000010000l +#define STEAM_BUTTON_LEFTPAD_CLICKED_MASK 0x0000000000020000l +#define STEAM_BUTTON_RIGHTPAD_CLICKED_MASK 0x0000000000040000l +#define STEAM_LEFTPAD_FINGERDOWN_MASK 0x0000000000080000l +#define STEAM_RIGHTPAD_FINGERDOWN_MASK 0x0000000000100000l + +// Only add fields to the end of this struct, or if you need to change it in a larger +// way add a new message id and new struct completely so as to not break old clients. +struct SteamControllerState_t +{ + // If packet num matches that on your prior call, then the controller state hasn't been changed since + // your last call and there is no need to process it + uint32 unPacketNum; + + // bit flags for each of the buttons + uint64 ulButtons; + + // Left pad coordinates + short sLeftPadX; + short sLeftPadY; + + // Right pad coordinates + short sRightPadX; + short sRightPadY; + +}; + +#pragma pack() + +#endif // STEAMCONTROLLERPUBLIC_H + diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamencryptedappticket.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamencryptedappticket.h new file mode 100644 index 0000000..48c63b4 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamencryptedappticket.h @@ -0,0 +1,32 @@ +//========= Copyright © 1996-2010, Valve LLC, All rights reserved. ============ +// +// Purpose: utilities to decode/decrypt a ticket from the +// ISteamUser::RequestEncryptedAppTicket, ISteamUser::GetEncryptedAppTicket API +// +// To use: declare CSteamEncryptedAppTicket, then call BDecryptTicket +// if BDecryptTicket returns true, other accessors are valid +// +//============================================================================= + +#include "steam_api.h" + +static const int k_nSteamEncryptedAppTicketSymmetricKeyLen = 32; + + +S_API bool SteamEncryptedAppTicket_BDecryptTicket( const uint8 *rgubTicketEncrypted, uint32 cubTicketEncrypted, + uint8 *rgubTicketDecrypted, uint32 *pcubTicketDecrypted, + const uint8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen], int cubKey ); + +S_API bool SteamEncryptedAppTicket_BIsTicketForApp( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID ); + +S_API RTime32 SteamEncryptedAppTicket_GetTicketIssueTime( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted ); + +S_API void SteamEncryptedAppTicket_GetTicketSteamID( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, CSteamID *psteamID ); + +S_API AppId_t SteamEncryptedAppTicket_GetTicketAppID( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted ); + +S_API bool SteamEncryptedAppTicket_BUserOwnsAppInTicket( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID ); + +S_API bool SteamEncryptedAppTicket_BUserIsVacBanned( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted ); + +S_API const uint8 *SteamEncryptedAppTicket_GetUserVariableData( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, uint32 *pcubUserData ); \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamhttpenums.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamhttpenums.h new file mode 100644 index 0000000..e15171f --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamhttpenums.h @@ -0,0 +1,97 @@ +//====== Copyright © 1996-2010, Valve Corporation, All rights reserved. ======= +// +// Purpose: HTTP related enums, stuff that is shared by both clients and servers, and our +// UI projects goes here. +// +//============================================================================= + +#ifndef STEAMHTTPENUMS_H +#define STEAMHTTPENUMS_H +#ifdef _WIN32 +#pragma once +#endif + +// HTTP related types + +// This enum is used in client API methods, do not re-number existing values. +enum EHTTPMethod +{ + k_EHTTPMethodInvalid = 0, + k_EHTTPMethodGET, + k_EHTTPMethodHEAD, + k_EHTTPMethodPOST, + k_EHTTPMethodPUT, + k_EHTTPMethodDELETE, + k_EHTTPMethodOPTIONS, + + // The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for + // a compliant general purpose server. We'll likely add more as we find uses for them. + + // k_EHTTPMethodTRACE, + // k_EHTTPMethodCONNECT +}; + + +// HTTP Status codes that the server can send in response to a request, see rfc2616 section 10.3 for descriptions +// of each of these. +enum EHTTPStatusCode +{ + // Invalid status code (this isn't defined in HTTP, used to indicate unset in our code) + k_EHTTPStatusCodeInvalid = 0, + + // Informational codes + k_EHTTPStatusCode100Continue = 100, + k_EHTTPStatusCode101SwitchingProtocols = 101, + + // Success codes + k_EHTTPStatusCode200OK = 200, + k_EHTTPStatusCode201Created = 201, + k_EHTTPStatusCode202Accepted = 202, + k_EHTTPStatusCode203NonAuthoritative = 203, + k_EHTTPStatusCode204NoContent = 204, + k_EHTTPStatusCode205ResetContent = 205, + k_EHTTPStatusCode206PartialContent = 206, + + // Redirection codes + k_EHTTPStatusCode300MultipleChoices = 300, + k_EHTTPStatusCode301MovedPermanently = 301, + k_EHTTPStatusCode302Found = 302, + k_EHTTPStatusCode303SeeOther = 303, + k_EHTTPStatusCode304NotModified = 304, + k_EHTTPStatusCode305UseProxy = 305, + //k_EHTTPStatusCode306Unused = 306, (used in old HTTP spec, now unused in 1.1) + k_EHTTPStatusCode307TemporaryRedirect = 307, + + // Error codes + k_EHTTPStatusCode400BadRequest = 400, + k_EHTTPStatusCode401Unauthorized = 401, // You probably want 403 or something else. 401 implies you're sending a WWW-Authenticate header and the client can sent an Authorization header in response. + k_EHTTPStatusCode402PaymentRequired = 402, // This is reserved for future HTTP specs, not really supported by clients + k_EHTTPStatusCode403Forbidden = 403, + k_EHTTPStatusCode404NotFound = 404, + k_EHTTPStatusCode405MethodNotAllowed = 405, + k_EHTTPStatusCode406NotAcceptable = 406, + k_EHTTPStatusCode407ProxyAuthRequired = 407, + k_EHTTPStatusCode408RequestTimeout = 408, + k_EHTTPStatusCode409Conflict = 409, + k_EHTTPStatusCode410Gone = 410, + k_EHTTPStatusCode411LengthRequired = 411, + k_EHTTPStatusCode412PreconditionFailed = 412, + k_EHTTPStatusCode413RequestEntityTooLarge = 413, + k_EHTTPStatusCode414RequestURITooLong = 414, + k_EHTTPStatusCode415UnsupportedMediaType = 415, + k_EHTTPStatusCode416RequestedRangeNotSatisfiable = 416, + k_EHTTPStatusCode417ExpectationFailed = 417, + k_EHTTPStatusCode4xxUnknown = 418, // 418 is reserved, so we'll use it to mean unknown + k_EHTTPStatusCode429TooManyRequests = 429, + + // Server error codes + k_EHTTPStatusCode500InternalServerError = 500, + k_EHTTPStatusCode501NotImplemented = 501, + k_EHTTPStatusCode502BadGateway = 502, + k_EHTTPStatusCode503ServiceUnavailable = 503, + k_EHTTPStatusCode504GatewayTimeout = 504, + k_EHTTPStatusCode505HTTPVersionNotSupported = 505, + k_EHTTPStatusCode5xxUnknown = 599, +}; + +#endif // STEAMHTTPENUMS_H \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamps3params.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamps3params.h new file mode 100644 index 0000000..c0741b4 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamps3params.h @@ -0,0 +1,112 @@ +//====== Copyright 1996-2008, Valve Corporation, All rights reserved. ======= +// +// Purpose: +// +//============================================================================= + +#ifndef STEAMPS3PARAMS_H +#define STEAMPS3PARAMS_H +#ifdef _WIN32 +#pragma once +#endif + +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// PlayStation 3 initialization parameters +// +// The following structure must be passed to when loading steam_api_ps3.prx +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +#define STEAM_PS3_PATH_MAX 1055 +#define STEAM_PS3_SERVICE_ID_MAX 32 +#define STEAM_PS3_COMMUNICATION_ID_MAX 10 +#define STEAM_PS3_COMMUNICATION_SIG_MAX 160 +#define STEAM_PS3_LANGUAGE_MAX 64 +#define STEAM_PS3_REGION_CODE_MAX 16 +#define STEAM_PS3_CURRENT_PARAMS_VER 2 +struct SteamPS3Params_t +{ + uint32 m_unVersion; // set to STEAM_PS3_CURRENT_PARAMS_VER + + void *pReserved; + uint32 m_nAppId; // set to your game's appid + + char m_rgchInstallationPath[ STEAM_PS3_PATH_MAX ]; // directory containing latest steam prx's and sdata. Can be read only (BDVD) + char m_rgchSystemCache[ STEAM_PS3_PATH_MAX ]; // temp working cache, not persistent + char m_rgchGameData[ STEAM_PS3_PATH_MAX ]; // persistent game data path for storing user data + char m_rgchNpServiceID[ STEAM_PS3_SERVICE_ID_MAX ]; + char m_rgchNpCommunicationID[ STEAM_PS3_COMMUNICATION_ID_MAX ]; + char m_rgchNpCommunicationSig[ STEAM_PS3_COMMUNICATION_SIG_MAX ]; + + // Language should be one of the following. must be zero terminated + // danish + // dutch + // english + // finnish + // french + // german + // italian + // korean + // norwegian + // polish + // portuguese + // russian + // schinese + // spanish + // swedish + // tchinese + char m_rgchSteamLanguage[ STEAM_PS3_LANGUAGE_MAX ]; + + // region codes are "SCEA", "SCEE", "SCEJ". must be zero terminated + char m_rgchRegionCode[ STEAM_PS3_REGION_CODE_MAX ]; + + // Should be SYS_TTYP3 through SYS_TTYP10, if it's 0 then Steam won't spawn a + // thread to read console input at all. Using this let's you use Steam console commands + // like: profile_on, profile_off, profile_dump, mem_stats, mem_validate. + unsigned int m_cSteamInputTTY; + + struct Ps3netInit_t + { + bool m_bNeedInit; + void *m_pMemory; + int m_nMemorySize; + int m_flags; + } m_sysNetInitInfo; + + struct Ps3jpgInit_t + { + bool m_bNeedInit; + } m_sysJpgInitInfo; + + struct Ps3pngInit_t + { + bool m_bNeedInit; + } m_sysPngInitInfo; + + struct Ps3sysutilUserInfo_t + { + bool m_bNeedInit; + } m_sysSysUtilUserInfo; + + bool m_bIncludeNewsPage; +}; + + +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +// PlayStation 3 memory structure +//----------------------------------------------------------------------------------------------------------------------------------------------------------// +#define STEAMPS3_MALLOC_INUSE 0x53D04A51 +#define STEAMPS3_MALLOC_SYSTEM 0x0D102C48 +#define STEAMPS3_MALLOC_OK 0xFFD04A51 +struct SteamPS3Memory_t +{ + bool m_bSingleAllocation; // If true, Steam will request one 6MB allocation and use the returned memory for all future allocations + // If false, Steam will make call malloc for each allocation + + // required function pointers + void* (*m_pfMalloc)(size_t); + void* (*m_pfRealloc)(void *, size_t); + void (*m_pfFree)(void *); + size_t (*m_pUsable_size)(void*); +}; + + +#endif // STEAMPS3PARAMS_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamtypes.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamtypes.h new file mode 100644 index 0000000..22ce3e6 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamtypes.h @@ -0,0 +1,179 @@ +//========= Copyright © 1996-2008, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +//============================================================================= + +#ifndef STEAMTYPES_H +#define STEAMTYPES_H +#ifdef _WIN32 +#pragma once +#endif + +#define S_CALLTYPE __cdecl + +// Steam-specific types. Defined here so this header file can be included in other code bases. +#ifndef WCHARTYPES_H +typedef unsigned char uint8; +#endif + +#if defined( __GNUC__ ) && !defined(POSIX) + #if __GNUC__ < 4 + #error "Steamworks requires GCC 4.X (4.2 or 4.4 have been tested)" + #endif + #define POSIX 1 +#endif + +#if defined(__x86_64__) || defined(_WIN64) +#define X64BITS +#endif + +// Make sure VALVE_BIG_ENDIAN gets set on PS3, may already be set previously in Valve internal code. +#if !defined(VALVE_BIG_ENDIAN) && defined(_PS3) +#define VALVE_BIG_ENDIAN +#endif + +typedef unsigned char uint8; +typedef signed char int8; + +#if defined( _WIN32 ) + +typedef __int16 int16; +typedef unsigned __int16 uint16; +typedef __int32 int32; +typedef unsigned __int32 uint32; +typedef __int64 int64; +typedef unsigned __int64 uint64; + +typedef int64 lint64; +typedef uint64 ulint64; + +#ifdef X64BITS +typedef __int64 intp; // intp is an integer that can accomodate a pointer +typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) +#else +typedef __int32 intp; +typedef unsigned __int32 uintp; +#endif + +#else // _WIN32 + +typedef short int16; +typedef unsigned short uint16; +typedef int int32; +typedef unsigned int uint32; +typedef long long int64; +typedef unsigned long long uint64; + +// [u]int64 are actually defined as 'long long' and gcc 64-bit +// doesn't automatically consider them the same as 'long int'. +// Changing the types for [u]int64 is complicated by +// there being many definitions, so we just +// define a 'long int' here and use it in places that would +// otherwise confuse the compiler. +typedef long int lint64; +typedef unsigned long int ulint64; + +#ifdef X64BITS +typedef long long intp; +typedef unsigned long long uintp; +#else +typedef int intp; +typedef unsigned int uintp; +#endif + +#endif // else _WIN32 + +#ifdef __clang__ +# define CLANG_ATTR(ATTR) __attribute__((annotate( ATTR ))) +#else +# define CLANG_ATTR(ATTR) +#endif + +#define METHOD_DESC(DESC) CLANG_ATTR( "desc:" #DESC ";" ) +#define IGNOREATTR() CLANG_ATTR( "ignore" ) +#define OUT_STRUCT() CLANG_ATTR( "out_struct: ;" ) +#define OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" ) +#define OUT_ARRAY_COUNT(COUNTER, DESC) CLANG_ATTR( "out_array_count:" #COUNTER ";desc:" #DESC ) +#define ARRAY_COUNT(COUNTER) CLANG_ATTR( "array_count:" #COUNTER ";" ) +#define ARRAY_COUNT_D(COUNTER, DESC) CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC ) +#define BUFFER_COUNT(COUNTER) CLANG_ATTR( "buffer_count:" #COUNTER ";" ) +#define OUT_BUFFER_COUNT(COUNTER) CLANG_ATTR( "out_buffer_count:" #COUNTER ";" ) +#define OUT_STRING_COUNT(COUNTER) CLANG_ATTR( "out_string_count:" #COUNTER ";" ) +#define DESC(DESC) CLANG_ATTR("desc:" #DESC ";") + + +const int k_cubSaltSize = 8; +typedef uint8 Salt_t[ k_cubSaltSize ]; + +//----------------------------------------------------------------------------- +// GID (GlobalID) stuff +// This is a globally unique identifier. It's guaranteed to be unique across all +// racks and servers for as long as a given universe persists. +//----------------------------------------------------------------------------- +// NOTE: for GID parsing/rendering and other utils, see gid.h +typedef uint64 GID_t; + +const GID_t k_GIDNil = 0xffffffffffffffffull; + +// For convenience, we define a number of types that are just new names for GIDs +typedef uint64 JobID_t; // Each Job has a unique ID +typedef GID_t TxnID_t; // Each financial transaction has a unique ID + +const GID_t k_TxnIDNil = k_GIDNil; +const GID_t k_TxnIDUnknown = 0; + +const JobID_t k_JobIDNil = 0xffffffffffffffffull; + +// this is baked into client messages and interfaces as an int, +// make sure we never break this. +typedef uint32 PackageId_t; +const PackageId_t k_uPackageIdFreeSub = 0x0; +const PackageId_t k_uPackageIdInvalid = 0xFFFFFFFF; + +typedef uint32 BundleId_t; +const BundleId_t k_uBundleIdInvalid = 0; + +// this is baked into client messages and interfaces as an int, +// make sure we never break this. +typedef uint32 AppId_t; +const AppId_t k_uAppIdInvalid = 0x0; + +typedef uint64 AssetClassId_t; +const AssetClassId_t k_ulAssetClassIdInvalid = 0x0; + +typedef uint32 PhysicalItemId_t; +const PhysicalItemId_t k_uPhysicalItemIdInvalid = 0x0; + + +// this is baked into client messages and interfaces as an int, +// make sure we never break this. AppIds and DepotIDs also presently +// share the same namespace, but since we'd like to change that in the future +// I've defined it seperately here. +typedef uint32 DepotId_t; +const DepotId_t k_uDepotIdInvalid = 0x0; + +// RTime32 +// We use this 32 bit time representing real world time. +// It offers 1 second resolution beginning on January 1, 1970 (Unix time) +typedef uint32 RTime32; + +typedef uint32 CellID_t; +const CellID_t k_uCellIDInvalid = 0xFFFFFFFF; + +// handle to a Steam API call +typedef uint64 SteamAPICall_t; +const SteamAPICall_t k_uAPICallInvalid = 0x0; + +typedef uint32 AccountID_t; + +typedef uint32 PartnerId_t; +const PartnerId_t k_uPartnerIdInvalid = 0; + +// ID for a depot content manifest +typedef uint64 ManifestId_t; +const ManifestId_t k_uManifestIdInvalid = 0; + + + +#endif // STEAMTYPES_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamuniverse.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamuniverse.h new file mode 100644 index 0000000..dd384dc --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamuniverse.h @@ -0,0 +1,27 @@ +//========= Copyright � 1996-2008, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +//============================================================================= + +#ifndef STEAMUNIVERSE_H +#define STEAMUNIVERSE_H +#ifdef _WIN32 +#pragma once +#endif + + +// Steam universes. Each universe is a self-contained Steam instance. +enum EUniverse +{ + k_EUniverseInvalid = 0, + k_EUniversePublic = 1, + k_EUniverseBeta = 2, + k_EUniverseInternal = 3, + k_EUniverseDev = 4, + // k_EUniverseRC = 5, // no such universe anymore + k_EUniverseMax +}; + + +#endif // STEAMUNIVERSE_H diff --git a/GameGuru Core/SDK/Steamworks SDK/public/steam/steamvr.h b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamvr.h new file mode 100644 index 0000000..1e84b66 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/public/steam/steamvr.h @@ -0,0 +1,263 @@ +#pragma once + +#include + +namespace vr +{ + +#if defined(__linux__) || defined(__APPLE__) + // The 32-bit version of gcc has the alignment requirement for uint64 and double set to + // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. + // The 64-bit version of gcc has the alignment requirement for these types set to + // 8 meaning that unless we use #pragma pack(4) our structures will get bigger. + // The 64-bit structure packing has to match the 32-bit structure packing for each platform. +#pragma pack( push, 4 ) +#else +#pragma pack( push, 8 ) +#endif + + +// right-handed system +// +y is up +// +x is to the right +// -z is going away from you +// Distance unit is meters +struct HmdMatrix34_t +{ + float m[3][4]; +}; + +struct HmdMatrix44_t +{ + float m[4][4]; +}; + + +/** Used to return the post-distortion UVs for each color channel. +* UVs range from 0 to 1 with 0,0 in the upper left corner of the +* source render target. The 0,0 to 1,1 range covers a single eye. */ +struct DistortionCoordinates_t +{ + float rfRed[2]; + float rfGreen[2]; + float rfBlue[2]; +}; + + +enum Hmd_Eye +{ + Eye_Left = 0, + Eye_Right = 1 +}; + +enum GraphicsAPIConvention +{ + API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane + API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane +}; + +enum HmdTrackingResult +{ + TrackingResult_Uninitialized = 1, + + TrackingResult_Calibrating_InProgress = 100, + TrackingResult_Calibrating_OutOfRange = 101, + + TrackingResult_Running_OK = 200, + TrackingResult_Running_OutOfRange = 201, +}; + +class IHmd +{ +public: + + + // ------------------------------------ + // Display Methods + // ------------------------------------ + + /** Size and position that the window needs to be on the VR display. */ + virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0; + + /** Suggested size for the intermediate render target that the distortion pulls from. */ + virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0; + + /** Gets the viewport in the frame buffer to draw the output of the distortion into */ + virtual void GetEyeOutputViewport( Hmd_Eye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0; + + /** The projection matrix for the specified eye */ + virtual HmdMatrix44_t GetProjectionMatrix( Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType ) = 0; + + /** The components necessary to build your own projection matrix in case your + * application is doing something fancy like infinite Z */ + virtual void GetProjectionRaw( Hmd_Eye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0; + + /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in + * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */ + virtual DistortionCoordinates_t ComputeDistortion( Hmd_Eye eEye, float fU, float fV ) = 0; + + /** Returns the transform from eye space to the head space. Eye space is the per-eye flavor of head + * space that provides stereo disparity. Instead of Model * View * Projection the sequence is Model * View * Eye^-1 * Projection. + * Normally View and Eye^-1 will be multiplied together and treated as View in your application. + */ + virtual HmdMatrix34_t GetHeadFromEyePose( Hmd_Eye eEye ) = 0; + + /** For use in simple VR apps, this method returns the concatenation of the + * tracking pose and the eye matrix to get a full view matrix for each eye. + * This is ( GetEyeMatrix() ) * (GetWorldFromHeadPose() ^ -1 ) */ + virtual bool GetViewMatrix( float fSecondsFromNow, HmdMatrix44_t *pMatLeftView, HmdMatrix44_t *pMatRightView, HmdTrackingResult *peResult ) = 0; + + /** [D3D9 Only] + * Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such + * a way that it can go full screen exclusive on the HMD. Returns -1 if there was an error. + */ + virtual int32_t GetD3D9AdapterIndex() = 0; + + /** [D3D10/11 Only] + * Returns the adapter index and output index that the user should pass into EnumAdapters adn EnumOutputs + * to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1. + */ + virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex, int32_t *pnAdapterOutputIndex ) = 0; + + /** [Windows Only] + * Notifies the system that the VR output will appear in a particular window. + */ + virtual void AttachToWindow( void *hWnd ) = 0; + + // ------------------------------------ + // Tracking Methods + // ------------------------------------ + + /** The pose that the tracker thinks that the HMD will be in at the specified + * number of seconds into the future. Pass 0 to get the current state. + * + * This is roughly analogous to the inverse of the view matrix in most applications, though + * many games will need to do some additional rotation or translation on top of the rotation + * and translation provided by the head pose. + * + * If this function returns true the pose has been populated with a pose that can be used by the application. + * Check peResult for details about the pose, including messages that should be displayed to the user. + */ + virtual bool GetTrackerFromHeadPose( float fPredictedSecondsFromNow, HmdMatrix34_t *pmPose, HmdTrackingResult *peResult ) = 0; + + /** Passes back the pose matrix from the last successful call to GetWorldFromHeadPose(). Returns true if that matrix is + * valid (because there has been a previous successful pose.) */ + virtual bool GetLastTrackerFromHeadPose( HmdMatrix34_t *pmPose ) = 0; + + /** Returns true if the tracker for this HMD will drift the Yaw component of its pose over time regardless of + * actual head motion. This is true for gyro-based trackers with no ground truth. */ + virtual bool WillDriftInYaw() = 0; + + /** Sets the zero pose for the tracker coordinate system. After this call all WorldFromHead poses will be relative + * to the pose whenever this was called. The new zero coordinate system will not change the fact that the Y axis is + * up in the real world, so the next pose returned from GetWorldFromHeadPose after a call to ZeroTracker may not be + * exactly an identity matrix. */ + virtual void ZeroTracker() = 0; + + /** Returns the zero pose for the tracker coordinate system. If the tracker has never had a valid pose, this + * will be an identity matrix. */ + virtual HmdMatrix34_t GetTrackerZeroPose() = 0; + + // ------------------------------------ + // Administrative methods + // ------------------------------------ + + /** The ID of the driver this HMD uses as a UTF-8 string. Returns the length of the ID in bytes. If + * the buffer is not large enough to fit the ID an empty string will be returned. In general, 128 bytes + * will be enough to fit any ID. */ + virtual uint32_t GetDriverId( char *pchBuffer, uint32_t unBufferLen ) = 0; + + /** The ID of this display within its driver this HMD uses as a UTF-8 string. Returns the length of the ID in bytes. If + * the buffer is not large enough to fit the ID an empty string will be returned. In general, 128 bytes + * will be enough to fit any ID. */ + virtual uint32_t GetDisplayId( char *pchBuffer, uint32_t unBufferLen ) = 0; +}; + +static const char * const IHmd_Version = "IHmd_005"; + +/** error codes returned by Vr_Init */ +enum HmdError +{ + HmdError_None = 0, + + HmdError_Init_InstallationNotFound = 100, + HmdError_Init_InstallationCorrupt = 101, + HmdError_Init_VRClientDLLNotFound = 102, + HmdError_Init_FileNotFound = 103, + HmdError_Init_FactoryNotFound = 104, + HmdError_Init_InterfaceNotFound = 105, + HmdError_Init_InvalidInterface = 106, + HmdError_Init_UserConfigDirectoryInvalid = 107, + HmdError_Init_HmdNotFound = 108, + HmdError_Init_NotInitialized = 109, + + HmdError_Driver_Failed = 200, + HmdError_Driver_Unknown = 201, + HmdError_Driver_HmdUnknown = 202, + HmdError_Driver_NotLoaded = 203, + + HmdError_IPC_ServerInitFailed = 300, + HmdError_IPC_ConnectFailed = 301, + HmdError_IPC_SharedStateInitFailed = 302, + + HmdError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, + + HmdError_Steam_SteamInstallationNotFound = 2000, + +}; + + +// figure out how to import from the VR API dll +#if defined(_WIN32) + +#ifdef VR_API_EXPORT +#define VR_INTERFACE extern "C" __declspec( dllexport ) +#else +#define VR_INTERFACE extern "C" __declspec( dllimport ) +#endif + +#elif defined(GNUC) || defined(COMPILER_GCC) + +#ifdef VR_API_EXPORT +#define VR_INTERFACE extern "C" __attribute__((visibility("default"))) +#else +#define VR_INTERFACE extern "C" +#endif + +#else +#error "Unsupported Platform." +#endif + + + + +/** Finds the active installation of the VR API and initializes it. The priority for figuring +* out where to load vrclient from are: +* 1. The convar "VR_OVERRIDE", which should contain an absolute path to the root of +* an vr API directory. +* 2. The pchVROverride argument. This should be an absolute path or a path relative to +* the current executable. +* 3. The path "./vr" relative to the current executable's path. +* +* Each of these paths are to the "root" of the VR API install. That's the directory with +* the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself. +*/ +VR_INTERFACE IHmd *VR_Init( HmdError *peError ); + +/** unloads vrclient.dll. Any interface pointers from the interface are +* invalid after this point */ +VR_INTERFACE void VR_Shutdown( ); + +/** Returns true if there is an HMD attached. This check is as lightweight as possible and +* can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants +* to know if initializing VR is a possibility but isn't ready to take that step yet. +*/ +VR_INTERFACE bool VR_IsHmdPresent(); + +/** Returns the string version of an HMD error. This function may be called outside of VR_Init()/VR_Shutdown(). */ +VR_INTERFACE const char *VR_GetStringForHmdError( HmdError error ); + +#pragma pack( pop ) + + +} \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/osx32/libsteam_api.dylib b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/osx32/libsteam_api.dylib new file mode 100644 index 0000000..337e13c Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/osx32/libsteam_api.dylib differ diff --git a/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/steam_api.dll b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/steam_api.dll new file mode 100644 index 0000000..f2a0450 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/steam_api.dll differ diff --git a/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/steam_api.lib b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/steam_api.lib new file mode 100644 index 0000000..591f5fd Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/steam_api.lib differ diff --git a/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/win64/steam_api64.dll b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/win64/steam_api64.dll new file mode 100644 index 0000000..d3c9268 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/win64/steam_api64.dll differ diff --git a/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/win64/steam_api64.lib b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/win64/steam_api64.lib new file mode 100644 index 0000000..cfc1b63 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/redistributable_bin/win64/steam_api64.lib differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/A REAL STEAM BUILD.bat b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/A REAL STEAM BUILD.bat new file mode 100644 index 0000000..3ac10f8 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/A REAL STEAM BUILD.bat @@ -0,0 +1,3 @@ +"Steam Build Filemaker.exe" +"F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Media List Builder.exe" +builder\steamcmd.exe +login daveravey cabbagexr137 +run_app_build ..\scripts\app_build_266310.vdf diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/COPY TO LAPTOP AND STEAM.bat b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/COPY TO LAPTOP AND STEAM.bat new file mode 100644 index 0000000..010fc6c --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/COPY TO LAPTOP AND STEAM.bat @@ -0,0 +1,6 @@ +"F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Media List Builder.exe" +xcopy "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\Files\editors\baseList.dat" "F:\Steam\steamapps\common\Game Guru\Files\editors\baseList.dat" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\Files\editors\baseList.dat" "\\dave-laptop\Game Guru\Files\editors\baseList.dat" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Guru-MapEditor.exe" "\\dave-laptop\Game Guru\Guru-MapEditor.exe" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Guru-MapEditor.exe" "F:\Steam\steamapps\common\Game Guru\Guru-MapEditor.exe" /Y + diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/DLC Mega Pack 1 BUILD.bat b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/DLC Mega Pack 1 BUILD.bat new file mode 100644 index 0000000..3ce782d --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/DLC Mega Pack 1 BUILD.bat @@ -0,0 +1 @@ +builder\steamcmd.exe +login daveravey cabbagexr137 +run_app_build ..\scripts\app_build_mega_pack_1_321140.vdf diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/MAKE PROTO BUILD.bat b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/MAKE PROTO BUILD.bat new file mode 100644 index 0000000..71258a9 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/MAKE PROTO BUILD.bat @@ -0,0 +1,6 @@ +"F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Media List Builder.exe" +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\FPSC-Proto-Game.exe" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\FPSC-Proto-Game.exe" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Files\mapbank\multiplayerlevel.fpm" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\Files\mapbank\multiplayerlevel.fpm" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Files\scriptbank\global.lua" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\Files\scriptbank\global.lua" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Files\scriptbank\multiplayer_first_to_10.lua" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\Files\scriptbank\multiplayer_first_to_10.lua" /Y +builder\steamcmd.exe +login daveravey cabbagexr137 +run_app_build ..\scripts\app_build_266310.vdf diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/Make FPSCR Build For Steam.bat b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/Make FPSCR Build For Steam.bat new file mode 100644 index 0000000..b7b9399 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/Make FPSCR Build For Steam.bat @@ -0,0 +1,7 @@ +"F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Media List Builder.exe" +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\changelog.txt" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\changelog.txt" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\version.ini" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\version.ini" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Guru-MapEditor.exe" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\Guru-MapEditor.exe" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Guru-Lightmapper.exe" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\Guru-Lightmapper.exe" /Y +xcopy "F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\GameGuru.exe" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\GameGuru.exe" /Y +builder\steamcmd.exe +login daveravey cabbagexr137 +run_app_build ..\scripts\app_build_266310.vdf diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/Make Game Guru Build For Steam.bat b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/Make Game Guru Build For Steam.bat new file mode 100644 index 0000000..3ac10f8 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/Make Game Guru Build For Steam.bat @@ -0,0 +1,3 @@ +"Steam Build Filemaker.exe" +"F:\TGCSHARED\fpsc-reloaded\FPS Creator Files\Media List Builder.exe" +builder\steamcmd.exe +login daveravey cabbagexr137 +run_app_build ..\scripts\app_build_266310.vdf diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/app_build_266310.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/app_build_266310.vdf new file mode 100644 index 0000000..cbe9407 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/app_build_266310.vdf @@ -0,0 +1,21 @@ +"appbuild" +{ + "appid" "266310" + "desc" "Game Guru" // description for this build + "buildoutput" "..\output\" // build output folder for .log, .csm & .csd files, relative to location of this file + "contentroot" "..\content\" // root content folder, relative to location of this file + "setlive" "" // branch to set live after successful build, non if empty + "preview" "0" // to enable preview builds + "local" "" // set to flie path of local content server + + "depots" + { + "266311" "depot_build_266311.vdf" + "321140" "depot_build_mega_pack_1_321140.vdf" + "321141" "depot_build_mega_pack_2_321141.vdf" + "321142" "depot_build_mega_pack_3_321142.vdf" + "365520" "depot_build_buildings_pack_365520.vdf" + "365540" "depot_build_death_valley_pack_365540.vdf" + "365530" "depot_build_fantasy_pack_365530.vdf" + } +} \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_266311.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_266311.vdf new file mode 100644 index 0000000..2067c6a --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_266311.vdf @@ -0,0 +1,31 @@ +"DepotBuildConfig" +{ + // Set your assigned depot ID here + "DepotID" "266311" + + // Set a root for all content. + // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths) + // will be resolved relative to this root. + // If you don't define ContentRoot, then it will be assumed to be + // the location of this script file, which probably isn't what you want + "ContentRoot" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content\" + + // include all files recursivley + "FileMapping" + { + // This can be a full path, or a path relative to ContentRoot + "LocalPath" "*" + + // This is a path relative to the install folder of your game + "DepotPath" "." + + // If LocalPath contains wildcards, setting this means that all + // matching files within subdirectories of LocalPath will also + // be included. + "recursive" "1" + } + + // but exclude all symbol files + // This can be a full path, or a path relative to ContentRoot + "FileExclusion" "*.pdb" +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_buildings_pack_365520.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_buildings_pack_365520.vdf new file mode 100644 index 0000000..851092a --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_buildings_pack_365520.vdf @@ -0,0 +1,31 @@ +"DepotBuildConfig" +{ + // Set your assigned depot ID here + "DepotID" "365520" + + // Set a root for all content. + // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths) + // will be resolved relative to this root. + // If you don't define ContentRoot, then it will be assumed to be + // the location of this script file, which probably isn't what you want + "ContentRoot" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content_buildings_pack\" + + // include all files recursivley + "FileMapping" + { + // This can be a full path, or a path relative to ContentRoot + "LocalPath" "*" + + // This is a path relative to the install folder of your game + "DepotPath" "." + + // If LocalPath contains wildcards, setting this means that all + // matching files within subdirectories of LocalPath will also + // be included. + "recursive" "1" + } + + // but exclude all symbol files + // This can be a full path, or a path relative to ContentRoot + "FileExclusion" "*.pdb" +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_death_valley_pack_365540.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_death_valley_pack_365540.vdf new file mode 100644 index 0000000..4697505 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_death_valley_pack_365540.vdf @@ -0,0 +1,31 @@ +"DepotBuildConfig" +{ + // Set your assigned depot ID here + "DepotID" "365540" + + // Set a root for all content. + // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths) + // will be resolved relative to this root. + // If you don't define ContentRoot, then it will be assumed to be + // the location of this script file, which probably isn't what you want + "ContentRoot" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content_death_valley_pack\" + + // include all files recursivley + "FileMapping" + { + // This can be a full path, or a path relative to ContentRoot + "LocalPath" "*" + + // This is a path relative to the install folder of your game + "DepotPath" "." + + // If LocalPath contains wildcards, setting this means that all + // matching files within subdirectories of LocalPath will also + // be included. + "recursive" "1" + } + + // but exclude all symbol files + // This can be a full path, or a path relative to ContentRoot + "FileExclusion" "*.pdb" +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_fantasy_pack_365530.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_fantasy_pack_365530.vdf new file mode 100644 index 0000000..5f46948 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_fantasy_pack_365530.vdf @@ -0,0 +1,31 @@ +"DepotBuildConfig" +{ + // Set your assigned depot ID here + "DepotID" "365530" + + // Set a root for all content. + // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths) + // will be resolved relative to this root. + // If you don't define ContentRoot, then it will be assumed to be + // the location of this script file, which probably isn't what you want + "ContentRoot" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content_fantasy_pack\" + + // include all files recursivley + "FileMapping" + { + // This can be a full path, or a path relative to ContentRoot + "LocalPath" "*" + + // This is a path relative to the install folder of your game + "DepotPath" "." + + // If LocalPath contains wildcards, setting this means that all + // matching files within subdirectories of LocalPath will also + // be included. + "recursive" "1" + } + + // but exclude all symbol files + // This can be a full path, or a path relative to ContentRoot + "FileExclusion" "*.pdb" +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_1_321140.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_1_321140.vdf new file mode 100644 index 0000000..53466f2 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_1_321140.vdf @@ -0,0 +1,31 @@ +"DepotBuildConfig" +{ + // Set your assigned depot ID here + "DepotID" "321140" + + // Set a root for all content. + // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths) + // will be resolved relative to this root. + // If you don't define ContentRoot, then it will be assumed to be + // the location of this script file, which probably isn't what you want + "ContentRoot" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content_mega_pack_1\" + + // include all files recursivley + "FileMapping" + { + // This can be a full path, or a path relative to ContentRoot + "LocalPath" "*" + + // This is a path relative to the install folder of your game + "DepotPath" "." + + // If LocalPath contains wildcards, setting this means that all + // matching files within subdirectories of LocalPath will also + // be included. + "recursive" "1" + } + + // but exclude all symbol files + // This can be a full path, or a path relative to ContentRoot + "FileExclusion" "*.pdb" +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_2_321141.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_2_321141.vdf new file mode 100644 index 0000000..75f2688 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_2_321141.vdf @@ -0,0 +1,31 @@ +"DepotBuildConfig" +{ + // Set your assigned depot ID here + "DepotID" "321141" + + // Set a root for all content. + // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths) + // will be resolved relative to this root. + // If you don't define ContentRoot, then it will be assumed to be + // the location of this script file, which probably isn't what you want + "ContentRoot" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content_mega_pack_2\" + + // include all files recursivley + "FileMapping" + { + // This can be a full path, or a path relative to ContentRoot + "LocalPath" "*" + + // This is a path relative to the install folder of your game + "DepotPath" "." + + // If LocalPath contains wildcards, setting this means that all + // matching files within subdirectories of LocalPath will also + // be included. + "recursive" "1" + } + + // but exclude all symbol files + // This can be a full path, or a path relative to ContentRoot + "FileExclusion" "*.pdb" +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_3_321142.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_3_321142.vdf new file mode 100644 index 0000000..485987d --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/scripts/depot_build_mega_pack_3_321142.vdf @@ -0,0 +1,31 @@ +"DepotBuildConfig" +{ + // Set your assigned depot ID here + "DepotID" "321142" + + // Set a root for all content. + // All relative paths specified below (LocalPath in FileMapping entries, and FileExclusion paths) + // will be resolved relative to this root. + // If you don't define ContentRoot, then it will be assumed to be + // the location of this script file, which probably isn't what you want + "ContentRoot" "F:\TGCSHARED\fpsc-reloaded\Reloaded MP\Steamworks SDK\tools\ContentBuilder\content_mega_pack_3\" + + // include all files recursivley + "FileMapping" + { + // This can be a full path, or a path relative to ContentRoot + "LocalPath" "*" + + // This is a path relative to the install folder of your game + "DepotPath" "." + + // If LocalPath contains wildcards, setting this means that all + // matching files within subdirectories of LocalPath will also + // be included. + "recursive" "1" + } + + // but exclude all symbol files + // This can be a full path, or a path relative to ContentRoot + "FileExclusion" "*.pdb" +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/steam_install.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/steam_install.vdf new file mode 100644 index 0000000..aae4afb --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentBuilder/steam_install.vdf @@ -0,0 +1,19 @@ +"InstallScript" +{ + "Registry" + { + "HKLM\\SOFTWARE\\The Game Creators\\FPSCRELOADED" + { + "string" + { + "INSTALL-PATH" "%INSTALLDIR%" + } + } + } + + "Firewall" + { + "FPS Creator Reloaded" "%INSTALLDIR%\\FPSC-MapEditor.exe" + } + +} \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentPrep.zip b/GameGuru Core/SDK/Steamworks SDK/tools/ContentPrep.zip new file mode 100644 index 0000000..cf7b256 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/ContentPrep.zip differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/htdocs/index.html b/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/htdocs/index.html new file mode 100644 index 0000000..46572bc --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/htdocs/index.html @@ -0,0 +1,7 @@ + +

Steam Local Content Server

+ +To download Steam content from this local content server, add "@localcontentserver [thishostname]" to the steam_dev.cfg right next to Steam.exe
+Browse local content here
+For more information, see the SteamWorks SDK documentation
+ \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/mongoose-license.txt b/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/mongoose-license.txt new file mode 100644 index 0000000..7c16b24 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/mongoose-license.txt @@ -0,0 +1,16 @@ +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/mongoose.conf b/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/mongoose.conf new file mode 100644 index 0000000..2187935 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/ContentServer/mongoose.conf @@ -0,0 +1,30 @@ +# Mongoose web server configuration file. +# Lines starting with '#' and empty lines are ignored. +# For detailed description of every option, visit +# http://code.google.com/p/mongoose/wiki/MongooseManual + +# cgi_pattern **.cgi$|**.pl$|**.php$ +# cgi_environment +# put_delete_passwords_file +# cgi_interpreter +# protect_uri +# authentication_domain mydomain.com +# ssi_pattern **.shtml$|**.shtm$ +# access_log_file +# ssl_chain_file +# global_passwords_file +# index_files index.html,index.htm,index.cgi +# access_control_list +# max_request_size 16384 +# extra_mime_types +# ssl_certificate +# num_threads 10 +# run_as_user +# url_rewrite_patterns + +document_root D:\ContentServer\htdocs +listening_ports 80 +enable_directory_listing yes +enable_keep_alive yes +error_log_file error.log + diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/drm/Readme.txt b/GameGuru Core/SDK/Steamworks SDK/tools/drm/Readme.txt new file mode 100644 index 0000000..3501ef7 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/drm/Readme.txt @@ -0,0 +1,54 @@ +================================================== +Using the DRM tool +================================================== + +1. Create a steam account just for submitting builds via DRM tool. Set it up with a strong password. +2. Add the account to your Steam publishing group using the steamworks user admin. +3. Give the account access to submit DRM +4. Enter the account user name and password into the drmtool.cfg file that sits with the drmtool.exe +5. run DRM tool using the appropriate path to your exe, app ID, and flags +6. If sign-in fails due to Steam Guard, see the Steam Guard section below + + +================================================== +Flag values +================================================== +Default: 0 +Min compatibility mode: 4 +Max compatibility mode: 38 + +Try it with flag = 0, if that breaks the game, try with flag = 4, if that still breaks the game, try with flag = 38. + +================================================== +Steam Guard +================================================== +Steam Guard may block you from authenticating. If so, do the following. + +1. Log into the partner site using the build account to force a steamguard code to be sent +2. Take the steam guard code from email and paste it in place of “code” in the cfg file after “auth:” +3. Run the DRM tool +4. Once you’ve successfully signed in and drm’ed an exe, remove the auth line from the cfg file + +================================================== +Example usage +================================================== +drmtool.exe -remotedrm build_path\Auslandia.exe 107700 0 + +================================================== +Example drmtool.cfg file +================================================== +server:partner.steamgames.com +user:ACCOUNT_NAME +pw:VERY_STRONG_PASSWORD +universe:public +auth:STEAM_GUARD_CODE_IF_NECESSARY + +================================================== +Note on applying the DRM wrapper on top of other DRM systems +================================================== +If you are applying another DRM technology to the executable, wrap the exe with Steam DRM first in max compatibility mode (38) then apply the additional DRM. + +================================================== +Note on .Net executables +================================================== +Note: The DRM tool breaks most .net executables. If you are building a .Net executable, you can skip the DRM wrapper, but please put in your own Steam check using SteamAPI_RestartAppIfNecessary( unOwnAppID ). diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/drm/drmtool.cfg b/GameGuru Core/SDK/Steamworks SDK/tools/drm/drmtool.cfg new file mode 100644 index 0000000..5733df5 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/drm/drmtool.cfg @@ -0,0 +1,5 @@ +server:partner.steamgames.com +user:account +pw:password +universe:public +auth:code diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/drm/ubuntu12_32/drmtoolp b/GameGuru Core/SDK/Steamworks SDK/tools/drm/ubuntu12_32/drmtoolp new file mode 100644 index 0000000..16af4af Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/drm/ubuntu12_32/drmtoolp differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/drm/ubuntu12_64/drmtoolp b/GameGuru Core/SDK/Steamworks SDK/tools/drm/ubuntu12_64/drmtoolp new file mode 100644 index 0000000..f10bdfd Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/drm/ubuntu12_64/drmtoolp differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamRetailInstaller.dmg b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamRetailInstaller.dmg new file mode 100644 index 0000000..d5b0812 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamRetailInstaller.dmg differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1.sim b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1.sim new file mode 100644 index 0000000..c735d1d Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1.sim differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1.sis b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1.sis new file mode 100644 index 0000000..69d34c0 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1.sis @@ -0,0 +1,21 @@ +"sku" +{ + "name" "Spacewar" + "subscriptionID" "0" + "appID" "480" + "disks" "1" + "language" "english" + "backup" "0" + "apps" + { + "0" "480" + } + "depots" + { + "0" "481" + } + "packages" + { + "1 0" "179664" + } +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1_0.sid b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1_0.sid new file mode 100644 index 0000000..8aaffa5 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/SteamworksExample_disk1_0.sid differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/autorun.inf b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/autorun.inf new file mode 100644 index 0000000..e78922c --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/autorun.inf @@ -0,0 +1,4 @@ +[autorun] +OPEN=SETUP.EXE +ICON=ICON.ICO + diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/icon.ico b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/icon.ico new file mode 100644 index 0000000..3e890dd Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/icon.ico differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/click.wav b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/click.wav new file mode 100644 index 0000000..670b30e Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/click.wav differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/eula.rtf b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/eula.rtf new file mode 100644 index 0000000..30979d6 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/eula.rtf @@ -0,0 +1,26 @@ +{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fcharset0 Times;}{\f1\froman\fcharset0 Times New Roman;}{\f2\fswiss\fcharset0 Arial;}} +{\colortbl ;\red0\green0\blue0;} +{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\nowidctlpar\fi720\qc\b\f0\fs20 YOU SHOULD CAREFULLY READ THE ENTIRE FOLLOWING LICENSE AGREEMENT BEFORE INSTALLING THIS SOFTWARE PROGRAM. THIS AGREEMENT CONTAINS IMPORTANT TERMS THAT AFFECT YOUR LEGAL RIGHTS. BY INSTALLING THE SOFTWARE PROGRAM, YOU AGREE TO BE BOUND BY THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, PLEASE DO NOT INSTALL THIS SOFTWARE PROGRAM.\par + \par +\pard\nowidctlpar\sa120\qj\tx360\tx720\b0 The software application(s) (the \ldblquote\ul Program\ulnone\rdblquote ), and any and all copies of the Program are the copyrighted work of Valve Corporation (\ldblquote\ul Valve\ulnone\rdblquote ) or its suppliers. All rights reserved, except as expressly stated herein. The Program is provided solely for installation by end users according to the terms of this License Agreement. All use of the Program is governed by the terms of the Steam Agreement as described below. Any use, reproduction or redistribution of the Program not in accordance with the terms of the License Agreement and the Steam Agreement is expressly prohibited.\par +\pard\nowidctlpar\qc\ul\b\f1 LICENSE AGREEMENT\par +\pard\nowidctlpar\par +\pard\nowidctlpar\qj\tx360\ulnone\b0\tab 1. \ul Limited Installation License\ulnone . \par +\par +\pard\nowidctlpar\fi720\qj\tx360 A. Valve hereby grants, and by installing the Program you thereby accept, a limited, non-exclusive license and right to install one (1) copy of the Program on a computer. In order to use the Program you will have to obtain an account with the Steam service and accept the terms of the \f0 Steam subscriber agreement (\ldblquote\ul Steam Agreement\ulnone\rdblquote )\f1 . \f0 By installing the Program, you agree that your future use of the Program will be subject to the terms of the Steam Agreement. A copy of the Steam Agreement is available at \ul www.steampowered.com/agreement.\ulnone \f1 The Steam Agreement will be displayed to you when you obtain an account with the Steam service. The Program is licensed, not sold. Your license confers no title or ownership in the Program or copies thereof.\par +\pard\nowidctlpar\qj\tx360\par +\pard\nowidctlpar\fi720 B. \f0 You may not, in whole or in part: copy, photocopy, reproduce, translate, reverse engineer\cf1 (with the exception of specific circumstances where such act is permitted by law)\cf0 , derive source code, modify, disassemble, decompile, or create derivative works based on the Program; remove any proprietary notices or labels on the Program; or attempt in any manner to circumvent any security measures designed to control access to the Program. The Program is licensed to you as a single product. Its component parts may not be separated for use on more than one computer. You may not sell, grant a security interest in or transfer reproductions of the Program to other parties in any way, nor to rent, lease or license the Program to others without the prior written consent of Valve.\f1\par +\pard\nowidctlpar\sa120\qj\tx360\tx720\f0\tab\par +\tab 2. \ul Ownership\ulnone . All title, ownership rights and intellectual property rights in and to the Program and any and all copies thereof (including but not limited to any titles, computer code, themes, objects, characters, character names, stories, dialog, catch phrases, locations, concepts, artwork, animations, sounds, musical compositions, audio-visual effects, methods of operation, moral rights, any related documentation, and \ldblquote applets\rdblquote incorporated into the Program) are owned by Valve or its licensors. The Program is protected by the copyright laws of the United States, international copyright treaties and conventions and other laws. All rights are reserved. The Program contains certain licensed materials and Valve\rquote s licensors may protect their rights in the event of any violation of this Agreement.\par +\tab 3. \ul Termination\ulnone . This License Agreement is effective until terminated. You may terminate the License Agreement at any time by destroying the Program. Valve may, at its discretion, terminate this License Agreement in the event that you fail to comply with the terms and conditions contained herein. This License Agreement shall automatically terminate in the event that you fail to comply with the terms and conditions contained herein. In such event, you must immediately destroy the Program. The provisions of Sections 2, 3, and 5-8 will survive any termination of the Agreement. \par +\tab 4. \ul Export Controls\ulnone . The Program may not be re-exported, downloaded or otherwise exported into (or to a national or resident of) any country to which the U.S. has embargoed goods, or to anyone on the U.S. Treasury Department\rquote s list of Specially Designated Nationals or the U.S. Commerce Department\rquote s Table of Denial Orders. By installing the Program, you are agreeing to the foregoing and you are representing and warranting that you are not located in, under the control of, or a national or resident of any such country or on any such list.\par +\pard\nowidctlpar\fi360\qj\tx8100\f1 5. \ul Limited Warranty\ulnone . The entire risk arising out of use or performance of the Program and any printed material(s) remains with the User.\f2 \f1 EXCEPT AS PROVIDED ABOVE, \caps The Program and ANY PRINTED MATERIAL(s) are provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties of merchantability, fitness for a particular purpose, or noninfringement. \caps0 ANY WARRANTY AGAINST INFRINGEMENT THAT MAY BE PROVIDED IN SECTION 2-312(3) OF THE UNIFORM COMMERCIAL CODE AND/OR IN ANY OTHER COMPARABLE STATE STATUTE IS EXPRESSLY DISCLAIMED. Some states/jurisdictions do not allow the exclusion or limitation of implied warranties, so the above limitations may not apply to you.\par +\pard\nowidctlpar\qj\tx360\tx720\f0\fs18\par +\pard\nowidctlpar\qj\tx360\f1\tab 6. \ul\fs20 Limitation of Liability\ulnone . VALVE, ITS SUPPLIERS AND DISTRIBUTORS SHALL NOT BE LIABLE IN ANY WAY FOR LOSS OR DAMAGE OF ANY KIND RESULTING FROM THE USE OF THE PROGRAM INCLUDING, BUT NOT LIMITED TO, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES. ANY WARRANTY AGAINST INFRINGEMENT THAT MAY BE PROVIDED IN SECTION 2-312(3) OF THE UNIFORM COMMERCIAL CODE AND/OR IN ANY OTHER COMPARABLE STATE STATUTE IS EXPRESSLY DISCLAIMED. \caps Valve CANNOT AND WILL NOT BE RESPONSIBLE FOR ANY SOFTWARE OR HARDWARE FAILURES OR ANY OTHER EVENT WHICH MAY RESULT IN A LOSS OF DATA OR DISRUPTION OF SERVICE. \caps0 Some states/jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so the above limitations may not apply. \par +\pard\nowidctlpar\qj\par +\pard\nowidctlpar\sa120\qj\tx360\tab 7. \ul Equitable Remedies\ulnone . You hereby agree that Valve would be irreparably damaged if the terms of this License Agreement were not specifically enforced, and therefore you agree that Valve shall be entitled to appropriate equitable remedies with respect to breaches of this License Agreement, in addition to such other remedies as Valve may otherwise have available to it under applicable laws. In the event any litigation is brought by either party in connection with this License Agreement, the prevailing party in such litigation shall be entitled to recover from the other party all the costs, attorneys\rquote fees and other expenses incurred by such prevailing party in the litigation.\par +\tab 8. \ul Miscellaneous\ulnone .\cf1 The terms of this paragraph do not apply to European Union consumers in the sense of Art. 5 of the Convention on the Law Applicable to Contractual Obligations opened for signature in Rome on 19 June 1980 (Rome Convention, 80/934/EEC) and national legislation based thereon.\cf0 You agree that this Agreement shall be deemed to have been made and executed in the State of Washington, and any dispute arising hereunder shall be resolved in accordance with the law of Washington. You agree that any claim asserted in any legal proceeding by you against Valve shall only be commenced and maintained in any state or federal court located in King County, Washington, and you agree to submit to the exclusive jurisdiction of those courts. In any dispute arising under this Agreement, the prevailing party will be entitled to attorneys' fees and expenses. This License Agreement may be amended, altered or modified only by an instrument in writing, specifying such amendment, alteration or modification, executed by both you and Valve. In the event that any provision of this License Agreement shall be held by a court or other tribunal of competent jurisdiction to be unenforceable, such provision will be enforced to the maximum extent permissible and the remaining portions of this License Agreement shall remain in full force and effect. This License Agreement and the Steam Agreement constitute and contain the entire agreement between the parties with respect to the subject matter hereof and supersede any prior oral or written agreements.\par +You hereby acknowledge that you have read and understand the foregoing License Agreement and agree that the action of installing the Program is an acknowledgment of your agreement to be bound by the terms and conditions of the License Agreement contained herein.\par +\par +} + \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/hover.wav b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/hover.wav new file mode 100644 index 0000000..c1ecd70 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/hover.wav differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/installscript.vdf b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/installscript.vdf new file mode 100644 index 0000000..67b94ba --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/installscript.vdf @@ -0,0 +1,18 @@ +"InstallScript" +{ + + // Install scripts on the Gold Master are only necessary for Games for Windows titles. + // Otherwise this file doesn't need to be shipped on the GM and the Steam client + // will run the install script shipped with your depots at a later point + + "Run Process" + { + "VCRedist" + { + "process 1" "%INSTALLDIR%\\redist\\vcredist_x86.exe" + "command 1" "/q:a" + "Description" "Microsoft VC Redist Package" + "NoCleanUp" "1" + } + } +} \ No newline at end of file diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/launch.wav b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/launch.wav new file mode 100644 index 0000000..9bb36f8 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/launch.wav differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/readme.txt b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/readme.txt new file mode 100644 index 0000000..92a6650 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/readme.txt @@ -0,0 +1,78 @@ +Steam Retail Setup File Overview: +--------------------------------- + +root\Setup.exe : + The main splash screen setup application launched when the customer inserts + the disc. Setup detects the current installation state and displays a simple + menu to install/play/reinstall or uninstall the game. Setup first loads + setup_default.ini, then the setup_.ini for the language chosen by + the user, then all other resource files are loaded based on the current + language configuration. Setup.exe itself does not require admin rights. + +root\SteamService.exe : + Helper application to run all additional 3rd party installers from a single + elevated process under Vista. If you don't need to run 3rd party installers, + this executable can be removed. + +root\SteamSetup.exe + Used to install Steam on the users machine. + +root\autorun.inf : + Tells Windows to run Setup.exe when user inserts disc + +root\splash.tga : + Image displayed by Steam while installing files from disk (392x165 pixel) + +root\setup.ini : + This is the first config file loaded by Setup regardless the chosen + language. This file configures any language independent settings for this + game like AppID or menu appearance. The syntax is "parameter" "value", a full + list of configuration parameters is given later. + +root\resources\setup_.ini : + These files configure Setup for the chosen language. The files are Unicode + encoded. They are loaded after setup_default.ini and can override any + configuration value for this language. Usually they don't need modification. + Currently supported language names are: english, german, french, italian, + korean, spanish, schinese, tchinese, russian, thai, japanese, portuguese, + polish, danish, dutch, finnish, norwegian, swedish, hungarian, czech + +root\resources\installscript.vdf : + This is a script file in KeyValues format to run 3rd party installers before + Steam and the game are installed. This file is optional and can be removed. + +root\resources\eula.rtf : + The end user license agreement shown before the user installs the game. + This file is optional. If you have localized versions of this file, + name them eula_.rtf + +root\resources\setup.bmp : + The Setup background image as 640x480 pixel BMP file. If you have + localized versions of this file, name them setup_.bmp + +root\resources\click.wav : + Played when a button is click. Delete file to play no sound. + +root\resources\hover.wav : + Played when a mouse hovers over a button. Delete file to play no sound. + +root\resources\launch.wav : + Played when Setup starts. File can be deleted. + + +Setup_*.ini configuration values: +------------------------------- + +"Game" : game name as it appears in the Setup menu +"AppID" : Steam AppID for this game +"Language" : overrides current language, usually not needed +"RequiredSize" : Required free disc space in KB +"URL" : target web URL for technical support button +"FontName" : menu Windows font like "Impact" or "Arial" +"FontHeight" : menu font height, eg "24" +"MenuPos" : menu X and Y coordinates, eg "100 100" +"MenuStyle" : menu text style, 0 = align left, 1 = center, 2 = right +"ColorDefault" : default menu text color in RGB, eg "255 0 255" +"ColorHover" : menu text color for mouse hover event +"ColorDown" : menu text color for mouse pressed event + diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup.bmp b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup.bmp new file mode 100644 index 0000000..3cd9546 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup.bmp differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_arabic.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_arabic.ini new file mode 100644 index 0000000..745789b Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_arabic.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_czech.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_czech.ini new file mode 100644 index 0000000..9debfcc Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_czech.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_danish.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_danish.ini new file mode 100644 index 0000000..4bc9aee Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_danish.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_dutch.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_dutch.ini new file mode 100644 index 0000000..2338039 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_dutch.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_english.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_english.ini new file mode 100644 index 0000000..3be6d37 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_english.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_finnish.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_finnish.ini new file mode 100644 index 0000000..baafec2 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_finnish.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_french.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_french.ini new file mode 100644 index 0000000..f849410 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_french.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_german.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_german.ini new file mode 100644 index 0000000..98d42e4 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_german.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_hungarian.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_hungarian.ini new file mode 100644 index 0000000..abc1b1a Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_hungarian.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_italian.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_italian.ini new file mode 100644 index 0000000..b05004a Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_italian.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_japanese.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_japanese.ini new file mode 100644 index 0000000..515415b Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_japanese.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_korean.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_korean.ini new file mode 100644 index 0000000..00f1a9d Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_korean.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_norwegian.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_norwegian.ini new file mode 100644 index 0000000..adf21cf Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_norwegian.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_polish.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_polish.ini new file mode 100644 index 0000000..2b7b7ff Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_polish.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_portuguese.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_portuguese.ini new file mode 100644 index 0000000..f1bb366 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_portuguese.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_russian.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_russian.ini new file mode 100644 index 0000000..0a45071 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_russian.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_schinese.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_schinese.ini new file mode 100644 index 0000000..af9455b Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_schinese.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_spanish.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_spanish.ini new file mode 100644 index 0000000..881c7a7 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_spanish.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_swedish.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_swedish.ini new file mode 100644 index 0000000..06e282a Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_swedish.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_tchinese.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_tchinese.ini new file mode 100644 index 0000000..7f1ba8e Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_tchinese.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_thai.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_thai.ini new file mode 100644 index 0000000..1469ea2 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/resources/setup_thai.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/setup.ini b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/setup.ini new file mode 100644 index 0000000..1f866e8 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/setup.ini differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/splash.tga b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/splash.tga new file mode 100644 index 0000000..a2d38e4 Binary files /dev/null and b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/disk_assets/splash.tga differ diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/project_example.bat b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/project_example.bat new file mode 100644 index 0000000..eba6034 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/project_example.bat @@ -0,0 +1,2 @@ +steam.exe -login -language english -build_install sku_project_example.txt -dest +@type logs\build_log.txt diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/sku_project_example.txt b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/sku_project_example.txt new file mode 100644 index 0000000..8029dfa --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/goldmaster/sku_project_example.txt @@ -0,0 +1,17 @@ +"sku" +{ + "appID" 20000 + "disk_size_mb" 4700 + + "included_depots" + { + "1" 20001 + "2" 20002 + } + + "excluded_depots" + { + + "1" 20003 + } +} diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/linux/README.txt b/GameGuru Core/SDK/Steamworks SDK/tools/linux/README.txt new file mode 100644 index 0000000..139afe8 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/linux/README.txt @@ -0,0 +1,77 @@ + +This is a set of tools targeting the Steam Linux Runtime. + +Setup +------------- + +The first time you install the runtime SDK, you should run the setup +script from the command line to download the set of packages you need +for development: + bash setup.sh + +You can pick your target architecture(s) and either the release or debug +version of the runtime. The debug runtime is built without optimizations +and includes full source code. + +You can re-run the script at any time to reconfigure the SDK. There are +a number of command line options for automating the script, which you can +see by running the script with the --help option. + + +Updates +------- + +You can run the setup script at any time to get the latest version of the SDK: + setup.sh --auto-update + +If you need to get an old version, you can specify it with --version: + setup.sh --version=2013-02-22 + + +Builds +------- + +Use the appropriate shell script to set up the environment for building with +the runtime, or just look to see what environment variables it sets and use +them directly in your build process. + +For example to run a shell targeting 32-bit architecture: + shell-i386.sh + +For example to run a shell targeting 64-bit architecture: + shell-amd64.sh + + +Testing +------- + +Once you have built a program that targets the runtime, you can verify +that all the dependencies are covered by the runtime with: + runtime/scripts/check-program.sh | grep " /usr" + +(note that the C library, OpenGL and 3D drivers are outside the runtime) + +You can run programs in the runtime environment for testing with: + run.sh +e.g. + run.sh ./MyGame -windowed + +You can debug your programs in the runtime environment with run.sh as well: + run.sh gdb MyGame + (gdb) r -windowed + + +Steam Depots +------------ + +When you are ready to build and upload your Steam depots, you will need to use +Steamcmd.exe on a Windows machine. + + +More Info +--------- + +You can get the scripts used to build these tools and report issues at: + https://github.com/ValveSoftware/steam-runtime + +Enjoy! diff --git a/GameGuru Core/SDK/Steamworks SDK/tools/linux/setup.sh b/GameGuru Core/SDK/Steamworks SDK/tools/linux/setup.sh new file mode 100644 index 0000000..0b6a864 --- /dev/null +++ b/GameGuru Core/SDK/Steamworks SDK/tools/linux/setup.sh @@ -0,0 +1,368 @@ +#!/bin/bash +# +# This script runs a shell with the environment set up for the Steam runtime +# development environment. + +# The top level of the cross-compiler tree +ORIG_PWD="${PWD}" +TOP=$(cd "${0%/*}" 2>/dev/null; echo "${PWD}") +cd "${TOP}" + +CONFIG=.config +ARCHITECTURES="i386 amd64" +ARCHIVE_EXT="tar.xz" +RUNTIME_VERSION=latest + +exit_usage() +{ + echo "Usage: $0 [--host=] [--target=] [--debug|--release] [--version=] [--depot=] [--perforce] [--reset] [--auto-update] [--checkonly]" >&2 + exit 1 +} + +function has_command() +{ + command -v $1 >/dev/null + return $? +} + +function detect_arch() +{ + case $(uname -m) in + *64) + echo "amd64" + ;; + *) + echo "i386" + ;; + esac +} + +function reset_sdk() +{ + if [ "${AUTO_UPGRADE}" != "true" ]; then + echo "This will clean the SDK and redownload packages." + read -p "Are you sure you want to continue? [y/N]: " response + if [ "${response}" != "y" -a "${response}" != "Y" ]; then + exit 2 + fi + fi + + rm -rf checksums ${ARCHITECTURES} runtime* + echo "Reset complete." + echo +} + +declare -a ARGS=("$@") +while [ "$1" ]; do + case "$1" in + --relaunch) + RELAUNCHED=true + ;; + --host=*) + HOST_ARCH=$(expr "$1" : '[^=]*=\(.*\)') + ;; + --target=*) + TARGET_ARCH=$(expr "$1" : '[^=]*=\(.*\)') + ;; + --debug) + RUNTIME_FLAVOR="debug" + ;; + --release) + RUNTIME_FLAVOR="release" + ;; + --version=*) + RUNTIME_VERSION=$(expr "$1" : '[^=]*=\(.*\)') + ;; + --depot=*) + URL_PREFIX=$(expr "$1" : '[^=]*=\(.*\)') + ;; + --perforce) + USE_P4=true + ;; + --reset) + if [ "${RELAUNCHED}" != "true" ]; then + reset_sdk + fi + ;; + --auto-update|--auto-upgrade) + AUTO_UPGRADE=true + ;; + --checkonly) + CHECK_ONLY=true + ;; + -h|--help) + exit_usage + ;; + -*) + echo "Unknown command line parameter: $1" >&2 + exit_usage + ;; + *) + break + ;; + esac + + shift +done + +function check_curl() +{ + if ! has_command curl; then + if has_command apt-get; then + echo "Installing curl to download packages..." + sudo apt-get install curl + echo + else + echo "Please install curl to download packages." + exit 2 + fi + fi +} + +# Make sure we have curl to download packages +check_curl + +if [ -z "${HOST_ARCH}" ]; then + HOST_ARCH=$(grep HOST_ARCH ${CONFIG} 2>/dev/null | awk -F= '{print $2}') + if [ "${HOST_ARCH}" = "" ]; then + HOST_ARCH=$(detect_arch) + fi +fi + +DEFAULT_TARGET=$(grep TARGET_ARCH ${CONFIG} 2>/dev/null | awk -F= '{print $2}') +if [ "${DEFAULT_TARGET}" = "" ]; then + # Most people are targeting i386 (for now!) + DEFAULT_TARGET=i386 +fi +if [ -z "${TARGET_ARCH}" -a "${AUTO_UPGRADE}" = "true" ]; then + TARGET_ARCH="${DEFAULT_TARGET}" +fi +if [ -z "${TARGET_ARCH}" ]; then + cat <<__EOF__ +====================================== +Which architectures would you like to target? + 1) i386 (x86 32-bit) + 2) amd64 (x64 64-bit) + 3) all supported architectures +__EOF__ + read -p "Default ${DEFAULT_TARGET}: " response + case "${response}" in + 1|i386) + TARGET_ARCH=i386 + ;; + 2|amd64) + TARGET_ARCH=amd64 + ;; + 3|all) + TARGET_ARCH="${ARCHITECTURES}" + ;; + *) + TARGET_ARCH="${DEFAULT_TARGET}" + ;; + esac + echo "Set target architecture to: ${TARGET_ARCH}" + echo +fi + +DEFAULT_FLAVOR=$(grep RUNTIME_FLAVOR ${CONFIG} 2>/dev/null | awk -F= '{print $2}') +if [ "${DEFAULT_FLAVOR}" = "" ]; then + DEFAULT_FLAVOR=release +fi +if [ -z "${RUNTIME_FLAVOR}" -a "${AUTO_UPGRADE}" = "true" ]; then + RUNTIME_FLAVOR="${DEFAULT_FLAVOR}" +fi +if [ -z "${RUNTIME_FLAVOR}" ]; then + cat <<__EOF__ +====================================== +Which runtime flavor would you like to use? + 1) release + 2) debug +__EOF__ + read -p "Default ${DEFAULT_FLAVOR}: " response + case "${response}" in + 1) RUNTIME_FLAVOR=release;; + 2) RUNTIME_FLAVOR=debug;; + *) RUNTIME_FLAVOR="${DEFAULT_FLAVOR}";; + esac + echo "Set runtime flavor to: ${RUNTIME_FLAVOR}" + echo +fi + +if [ -z "${URL_PREFIX}" ]; then + URL_PREFIX="http://media.steampowered.com/client/runtime" +fi + +# Make everything writable if we're using Perforce +if [ "${USE_P4}" = "true" ]; then + chmod -R +w . +fi + +# Save our config +: >${CONFIG} +echo "HOST_ARCH=${HOST_ARCH}" >>${CONFIG} +echo "TARGET_ARCH=${TARGET_ARCH}" >>${CONFIG} +echo "RUNTIME_FLAVOR=${RUNTIME_FLAVOR}" >>${CONFIG} + + +UPDATED_FILES_RETURNCODE=42 + +function update_archive() +{ + local NAME=$1 + local DEST=$2 + + if [ -z "${NAME}" -o -z "${DEST}" ]; then + echo "Internal error: update_archive " 2>&1 + exit 255 + fi + + # Download the latest archive checksum and see if we already have it + local ARCHIVE="${NAME}_${RUNTIME_VERSION}.${ARCHIVE_EXT}" + local CHECKSUM_FILE="${ARCHIVE}.md5" + local CHECKSUM=$(curl -sf "${URL_PREFIX}/${CHECKSUM_FILE}") + if [ "${CHECKSUM}" = "" ]; then + # No updates available + return 0 + fi + if [ -f "checksums/${CHECKSUM_FILE}" ] && \ + [ "$(cat "checksums/${CHECKSUM_FILE}")" = "${CHECKSUM}" ]; then + # We're all done! + return 0 + fi + + if [ "$CHECK_ONLY" = "true" ]; then + echo "Update available: ${URL_PREFIX}/${ARCHIVE}" + return 1 + fi + + # Download and extract the archive + echo "Installing ${URL_PREFIX}/${ARCHIVE}..." + curl -#f "${URL_PREFIX}/${ARCHIVE}" | tar xJf - --strip-components=1 -C "${DEST}" + + # Update the checksum + mkdir -p checksums + rm -f checksums/${NAME}_* + echo "${CHECKSUM}" >"checksums/${CHECKSUM_FILE}" + + # All done! + return ${UPDATED_FILES_RETURNCODE} +} + +function fold_case() +{ + echo "Removing files with the same case..." + find . \( -type f -o -type l \) | sort -f | uniq -i -d | while read file; do + find "$(dirname "$file")" -iname "$(basename "$file")" | while read other; do + if [ "$other" != "$file" ]; then + rm -v "$other" + fi + done + done +} + +function p4reconcile() +{ + P4LOG=/tmp/p4.log + fold_case + p4 reconcile -f ... >"${P4LOG}" + echo "Perforce log is in ${P4LOG}" +} + +# Update SDK files and restart if necessary +if [ "${RELAUNCHED}" = "true" ]; then + response=n +elif [ "${AUTO_UPGRADE}" = "true" ]; then + response=y +else + echo "======================================" + read -p "Update base SDK? [Y/n]: " response +fi +if [ "${response}" != "n" ]; then + update_archive steam-runtime-sdk . + case $? in + 0) + if [ "${AUTO_UPGRADE}" != "true" ]; then + echo "No updates available." + fi + ;; + ${UPDATED_FILES_RETURNCODE}) + echo + cd "${ORIG_PWD}" + exec "$0" --relaunch --host="${HOST_ARCH}" --target="${TARGET_ARCH}" --${RUNTIME_FLAVOR} "${ARGS[@]}" + ;; + esac + echo +fi + +# Update tools +if [ "${AUTO_UPGRADE}" = "true" ]; then + response=y +else + echo "======================================" + read -p "Update tools? [Y/n]: " response +fi +if [ "${response}" != "n" ]; then + AVAILABLE_UPDATES=false + for host_arch in ${HOST_ARCH}; do + for target_arch in ${TARGET_ARCH}; do + update_archive x-tools-${host_arch}-${target_arch} . + case $? in + 0) + ;; + *) + AVAILABLE_UPDATES=true + ;; + esac + done + done + if [ "${AVAILABLE_UPDATES}" != "true" -a "${AUTO_UPGRADE}" != "true" ]; then + echo "No updates available." + fi + echo +fi + +# Update runtime +if [ "${AUTO_UPGRADE}" = "true" ]; then + response=y +else + echo "======================================" + read -p "Update runtime? [Y/n]: " response +fi +if [ "${response}" != "n" ]; then + AVAILABLE_UPDATES=false + for target_arch in ${TARGET_ARCH}; do + mkdir -p runtime-${RUNTIME_FLAVOR} + update_archive steam-runtime-dev-${RUNTIME_FLAVOR}-${target_arch} runtime-${RUNTIME_FLAVOR} + case $? in + 0) + ;; + *) + AVAILABLE_UPDATES=true + ;; + esac + done + if [ "${AVAILABLE_UPDATES}" != "true" -a "${AUTO_UPGRADE}" != "true" ]; then + echo "No updates available." + fi + echo +fi +rm -f runtime || exit 16 +ln -s runtime-${RUNTIME_FLAVOR} runtime + +# Set up symbolic link to automatically find source when debugging +if [ "${RUNTIME_FLAVOR}" = "debug" ]; then + rm -f /tmp/source && \ + ln -sf "${TOP}/runtime-${RUNTIME_FLAVOR}/source" /tmp/source +fi + +if [ "${USE_P4}" = "true" ]; then + echo "======================================" + echo "Creating Perforce changelist..." + p4reconcile + echo +fi + +echo "======================================" +echo "Update complete!" + +# vi: ts=4 sw=4 expandtab diff --git a/README.md b/README.md index bb32d7d..37817da 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,4 @@ Steam Product: https://store.steampowered.com/app/266310/?utm_source=githubrepo& This Guru-Converter.exe is to be placed in the GameGuru Classic root folder. -This source code requires Visual Studio 2017 Community Edition and is compiled as a 32-bit executable. - -NOTE: If anyone would like to convert this project so it compiles and runs in 64-bit, that would be much appreciated. The DirectX code used to do the X file parsing is 32-bit only and there was no clear way of performing the same parse using a 64-bit executable. If this can be converted, the whole converter can be embedded into the now 64-bit version of GameGuru Classic. - -TIP: There are MANY files in this project set that are not required for the converter to setup, load a X file, save a DBO file and exit. A good cleanup exercise on a separate branch might be to see just how many files can be removed from this repo and still allow the Guru-Converter.exe to be compiled and run successfully :) +This source code requires Visual Studio 2022 Community Edition and is compiled as a 64-bit executable.